diff --git a/.changeset/35496-skills-teach-five-landed-behaviours.md b/.changeset/35496-skills-teach-five-landed-behaviours.md new file mode 100644 index 00000000000..792f668b5bb --- /dev/null +++ b/.changeset/35496-skills-teach-five-landed-behaviours.md @@ -0,0 +1,35 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): the data, query and ui skills teach five landed refusals and behaviours + +Clause-②: no +Metadata-protocol: none + +Five pieces of published skill text, one per landed behaviour the skills did not teach. Each comes with its own eval case. + +**The `{current_iso_week}` period key.** objectstack-query's `rules/filters.md`, section "Date Macros", now names the period key beside the date macros and the session tokens. `{current_iso_week}` (or `${current_iso_week}`) resolves to today's ISO week key, `YYYY-Www`, in the workspace time zone: Monday-start weeks, the ISO week-year at year edges. It is text, for a text field that stores week keys. A `date`, `datetime` or `time` field refuses it with `INVALID_FILTER` / 400, as it refuses the literal key; a date dashboard filter's `defaultValue` and `calendar.initialDate` refuse it too. On a date field write `{current_week_start}` / `{current_week_end}`. The section also names `resolveFilterPlaceholders()` as the client resolver for all three vocabularies and `isKnownFilterToken()` as the one spelling check. One eval case covers the text-field / date-field split. + +**A hook or job `js` body that does not compile is refused.** objectstack-data's `references/data-hooks.md`, "Sandbox restrictions": + +- A new bullet says a `js` source is compiled, without being run, inside the `(async (ctx) => { … })` wrapper the runtime runs it in, where `ctx` is already declared. `const ctx = ctx.input || {};` (or `let ctx`, one name declared twice, any syntax error) is `hook-body-does-not-compile`: an error from `os validate`, `os build`, `os lint` and a runtime hook save (`422 INVALID_METADATA`), naming the hook, the `SyntaxError` and its line. The fix is to use `ctx` as it is or rename the local (`const input = ctx.input || {};`). A job's `js` body runs in the same wrapper and is `job-body-does-not-compile` from the three commands. A regular-expression pattern the checking engine refuses is a warning: the runtime may accept it. +- Six restatements in the same file were removed to pay for the new text; the file is four lines shorter and no larger in tokens than before. + +`evals/hooks-security-seeds-datasources.json` gains one case on the refusal and its fix. + +**A seed record with a blank key field is refused at load, and a saved seed naming an unknown object is refused 422.** objectstack-data's `references/seeds.md`: + +- "`externalId` selection" says every record carries a value for each `externalId` field (each field of a list, or `name` when the seed names none), and that a record leaving one blank (no value, `null` or `''`; whitespace is a value) is refused at load in every mode: the load result names the object, the record index, the field and the fix, and the other records still load. The `externalId` row of the field table points at it. +- The note under the field table says a `seed` saved at runtime names its `object` itself, and that one resolving to nothing is refused with `422 INVALID_METADATA` at `object` ("which is not defined"). The fix is the object's full name (`crm_lead`, not `lead`) or creating the object first: a draft of it is enough for a draft seed, a live seed needs it published. The `object` row points at the note. +- Three restatements in the same file were removed to pay for part of the new text: the `columns` row's shape literal, the one-row best-practices table (now a sentence) and the second telling of what a refused seed value leaves behind. + +`evals/hooks-security-seeds-datasources.json` gains one case on each refusal. + +**A `master_detail` child is a record-page body table by default.** The record page draws a `master_detail` child as a full-width body table whenever its FK declares no `relatedList`. The skills still tied that to `inlineEdit`. They now teach the rule the runtime applies. + +- objectstack-data's `rules/relationships.md`, "Detail-page related lists": a `master_detail` child is a body table by default and a `lookup` child is a panel. `inlineEdit` governs entry in the parent's form only. The `relatedList` list reads `'primary'` (the `master_detail` default), `true` (the `lookup` default) and `false`. The example no longer writes `inlineEdit` and `relatedList: 'primary'` on a `master_detail` field to get the table. +- objectstack-ui's `rules/record-page.md`, step 2: the same defaults, the body table is drawn after the open field sections (it used to say after the first one), and "put the tasks first" is the parent's `relatedLists`. The example field drops its `relatedList: 'primary'`. +- objectstack-ui's `evals/record-page.json`, case 1: the expected answer adds no placement flag to a `master_detail` field, and an answer that authors `inlineEdit` fails the case. `evals/README.md` follows. + +Both of those rules files are shorter than before, and neither one's token ceiling moves. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index a78922b645d..582384924b7 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1370,7 +1370,21 @@ export const CEILINGS = new Map([ // paragraph (home: SKILL.md, String Operators) and a second `$between` Date // example (home: the operator table's `$between` row). Arithmetic in bytes: // 9925 -> 9892 (-33 net) -> ceil(9892 / 4) = 2473; headroom 0 tokens. - ['skills/objectstack-query/rules/filters.md', 2473], + // 2473 -> 2596 (#35496): the `{current_iso_week}` period key in § Date Macros + // (its `YYYY-Www` value, the text-field-only rule, the `INVALID_FILTER` / 400 + // refusal on date / datetime / time fields, the two date-only surfaces that + // refuse it) and the client resolver that covers all three vocabularies. + // Raise path the standing ruling 「A:先削重复,余额按实测提高」 (ruling record + // 6513306068, letter B). PAID DOWN FIRST — five restatements cut in the same + // section: the wrapper regex beside the prose that already says both + // spellings parse, the code comment repeating the sentence above its block, + // the second date-macro comparison in the session-token example (the week key + // takes its place), the two per-vocabulary predicates (one predicate answers + // for all three) and the driver sentence's list of value kinds. Arithmetic in + // bytes: 9876 landed -> 10382, +506 -> 127 tokens, the row's 4 tokens of + // headroom absorbed, ceiling +123, pinned AT the measurement. + // ceil($(wc -c < skills/objectstack-query/rules/filters.md) / 4) == ceil(10382 / 4) + ['skills/objectstack-query/rules/filters.md', 2596], ['skills/objectstack-query/rules/pagination.md', 1382], // objectstack-ui `rules/` — the five files the #14296 item 1 split created. @@ -1846,7 +1860,24 @@ export const CEILINGS = new Map([ // 6984 -> 6570 after the cuts (-414); the teaching nets +466 -> 7036 -> // ceil(7036 / 4) = 1759; headroom was 0, so the ceiling moves +13, the // measured remainder only. Pinned AT the measurement. - ['skills/objectstack-data/references/seeds.md', 1759], + // 1759 -> 1812: `### externalId selection` says every record carries a value + // for each `externalId` field and that a blank one is refused at load, and the + // `externalId` row points at it. Raise path the standing ruling + // 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). PAID DOWN + // FIRST — restatement cut in the same file: the `columns` row's shape literal + // (its own section shows it), the one-row best-practices table (a sentence + // now) and the second telling of what a refused seed value leaves behind. + // Arithmetic in bytes: 7033 -> 6905 after the cuts (-128); the teaching nets + // +340 -> 7245 -> ceil(7245 / 4) = 1812; headroom was 0, so the ceiling moves + // +53, the measured remainder only. Pinned AT the measurement. + // 1812 -> 1898: the note under the field table says a `seed` saved at runtime + // names an object that exists or the save answers `422 INVALID_METADATA` at + // `object`, and that a draft object is enough for a draft seed; the `object` + // row points at it in place of "never write manually". Same raise path and + // the same paydown as the step above (one PR, the cuts are its deletion): + // 7245 -> 7590 bytes (+345) -> ceil(7590 / 4) = 1898; headroom was 0, so the + // ceiling moves +86, the measured remainder only. Pinned AT the measurement. + ['skills/objectstack-data/references/seeds.md', 1898], // 1351 -> 1343: the body-pin values left the count (#31115, ruling B; see // BODY_PIN_REPIN); the file's count fell by the same 8, headroom unchanged. ['skills/objectstack-platform/references/bootstrap.md', 1343], diff --git a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json index c0242d92b87..86aa7940d15 100644 --- a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json +++ b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json @@ -61,6 +61,26 @@ "must_not_contain": [] } }, + { + "id": 34, + "prompt": "Our `sales_team` seed is `upsert`, keyed on `externalId: 'code'`. Two of its ten records have no `code` yet; we want to load all ten now and fill those two codes in later. Write the seed.", + "expected_output": "Redirects: the two records cannot load without a `code`. Every record carries a value for each `externalId` field, and a record that leaves one blank (no value, `null` or `''`) is refused at load: the load result names the object, the record index, the blank field and the fix, and the other eight records still load. So the answer gives those two records a real `code` now (`defineSeed(SalesTeam, { externalId: 'code', mode: 'upsert', records })` with ten codes), or keys the seed on a field every record carries. It does not write `code: ''` or `code: null`, does not pad the key with whitespace to pass, and does not switch the mode: `ignore`, `upsert` and `update` all refuse the record.", + "files": [], + "assertions": { + "must_contain": ["defineSeed", "externalId", "refused"], + "must_not_contain": [] + } + }, + { + "id": 35, + "prompt": "In the running app I saved a draft `seed` item with `object: 'lead'` and three records, through the metadata save. The save answered 422. Our lead object is `crm_lead`, still a draft in the same package. What is wrong, and what do I save instead?", + "expected_output": "The seed names an object that does not exist: the save door refuses a `seed` whose `object` resolves to nothing with `422 INVALID_METADATA`, one finding at `object` saying the seed loads its records into object 'lead', which is not defined, so publishing it would load no record. The fix is the object's full name: save the seed with `object: 'crm_lead'`. The draft `crm_lead` is enough for a draft seed, so nothing has to be published first; a live (published) seed needs the object published. Does not create a second `lead` object to satisfy the save and does not retry the same body.", + "files": [], + "assertions": { + "must_contain": ["422", "crm_lead", "not defined"], + "must_not_contain": [] + } + }, { "id": 5, "prompt": "Finance may edit a contract's legal terms (`governing_law`, `liability_cap`) while it is a draft, not once approved, signing or active; legal still edits them.", @@ -326,6 +346,16 @@ "amount_paid: 2000" ] } + }, + { + "id": 33, + "prompt": "`os validate` reports an error on this `beforeInsert` hook on `lead`, and I cannot see why: `body: { language: 'js', source: \"const ctx = ctx.input || {}; if (!ctx.status) ctx.status = 'new';\", capabilities: [] }`. What is wrong, and what should the source be?", + "expected_output": "The `js` source is compiled inside the wrapper the runtime runs it in, `(async (ctx) => { … })`, where `ctx` is already the parameter: `const ctx = …` declares it a second time, a SyntaxError before any statement runs. The finding is `hook-body-does-not-compile`, an error from `os validate`, `os build` and `os lint`, and a runtime save of the hook is refused with `422 INVALID_METADATA`. Fix: use `ctx` as it is (`if (!ctx.input.status) ctx.input.status = 'new';`) or give the local another name (`const input = ctx.input || {}; if (!input.status) input.status = 'new';`). Does not suppress the rule, and does not move the logic to a deprecated `handler`.", + "files": [], + "assertions": { + "must_contain": ["hook-body-does-not-compile", "input.status"], + "must_not_contain": [] + } } ] } diff --git a/skills/objectstack-data/references/data-hooks.md b/skills/objectstack-data/references/data-hooks.md index f3c8acfcff8..22c88f9b4aa 100644 --- a/skills/objectstack-data/references/data-hooks.md +++ b/skills/objectstack-data/references/data-hooks.md @@ -123,11 +123,6 @@ const myHook = defineHook({ ### Key Properties Explained -#### `body` — Implementation - -A `source` of statements against `ctx`; a throw aborts the write -([Sandboxed Hook Bodies](#sandboxed-hook-bodies-body--what-the-sandbox-ctx-can-call)). - #### `condition` — Declarative Filtering Skip the hook if the condition is false. Author it as a **CEL @@ -155,9 +150,7 @@ made total over the object's **declared** fields (`null` when a declared field i in neither). So: - Reference **any** declared field, not just the ones this update touches — - `record.done == true` works on an update that only sets `status`. (This is - unlike `ctx.input` / `ctx.result` inside the body, which stay partial — see - Gotcha 1.) + `record.done == true` works on an update that only sets `status`. - `record` describes the record's **state**, not the diff. `record.done == true` fires on every update of an already-done record, not only on the update that set it. **For the transition, compare against `previous`**: @@ -344,6 +337,15 @@ The body runs in an isolated QuickJS VM, **not** Node: a name bound at module scope, e.g. a `const slugify = …` helper sitting next to the hook. A `body` must be **self-contained**: inline the helper, or keep that hook as a bundled (deprecated) `handler`. +- **Refused when it does not compile:** a `js` source is compiled, unrun, inside + its `(async (ctx) => { … })` wrapper, where `ctx` is already declared. So + `const ctx = ctx.input || {};` (or `let ctx`, one name declared twice, any + syntax error) is `hook-body-does-not-compile`: an **error** from `os validate`, + `os build`, `os lint` and a runtime hook save (`422 INVALID_METADATA`), naming + the hook, the `SyntaxError` and its line. Fix: use `ctx` as it is, or rename + the local (`const input = ctx.input || {};`). A job's `js` body runs in the + same wrapper: `job-body-does-not-compile`, from the three commands. A regex + pattern the checking engine refuses is a warning: the runtime may accept it. > **A deadline stamped from an hours table is calendar hours** — nights, weekends and > holidays count. Name it `*_CALENDAR_HOURS` (`SLA_CALENDAR_HOURS`, or its camelCase) @@ -450,8 +452,7 @@ interface HookContext { // Execution context session?: { userId?: string; - organizationId?: string; // Active org — the single blessed name. Matches the - // `organization_id` column + `current_user.organizationId` (RLS). + organizationId?: string; // Active org — the single blessed name. // The former `tenantId` alias was removed in v16. // Privilege is judged by the security service, // never by a session claim. @@ -660,11 +661,8 @@ const cascadeAccountUpdate = defineHook({ A `body` cannot do this: it writes back only `ctx.input`, and its `ctx.result` is a snapshot. -> For **static** field masking (a field is always hidden/masked for a permission -> set or position), prefer declarative **field-level metadata** (secret/masked -> fields) — it applies on every read path automatically. Use an `afterFind` hook -> only for masking that depends on runtime logic the field metadata can't -> express. +> Static masking is declarative **field-level metadata** (secret/masked fields); +> an `afterFind` hook is only for masking that depends on runtime logic. ```typescript const maskSensitiveData = defineHook({ @@ -674,7 +672,6 @@ const maskSensitiveData = defineHook({ handler: async (ctx) => { // Exempt the engine's own elevated reads (`isSystem`) — internal writes // and self-reads must see the real values. - // ⚠️ Never a session claim (`ctx.session.roles` is gone, ctx table above). const isElevated = ctx.session?.isSystem === true; if (!isElevated) { @@ -777,9 +774,8 @@ the layout both real hook modules in the repo use. ## Best Practices -✅ **DO** — use `before*` for validation and `after*` for side effects; set -`async: true` for non-critical background work; go through `ctx.api` for -cross-object operations; refuse a business rule by a +✅ **DO** — set `async: true` for non-critical background work; go through +`ctx.api` for cross-object operations; refuse a business rule by a [declared code](#declared-refusals-refusals); test hooks in isolation. ❌ **DON'T** — do expensive work in `before*` (it blocks the transaction); write diff --git a/skills/objectstack-data/references/seeds.md b/skills/objectstack-data/references/seeds.md index 3c9597261e0..3b1bffdba93 100644 --- a/skills/objectstack-data/references/seeds.md +++ b/skills/objectstack-data/references/seeds.md @@ -44,10 +44,10 @@ export const SeedData = [statusSeed, categorySeed]; | Field | Default | Purpose | |:------|:--------|:--------| -| `object` | derived | Auto-set from `objectDef.name` — never write manually | -| `externalId` | `'name'` | Stable business key (or field list) every mode matches on | +| `object` | derived | Auto-set from `objectDef.name`; hand-written only in a runtime save (below) | +| `externalId` | `'name'` | Stable business key (or field list) every mode matches on; required in every record (below) | | `mode` | `'ignore'` | Import strategy (see below) | -| `columns` | — | Per-column write policy, keyed by field: `{ FIELD: { applyOn: 'create' } }` (below) | +| `columns` | — | Per-column write policy, keyed by field (below) | | `env` | `['prod','dev','test']` | Environments where the seed loads | | `locale` | — (every locale) | BCP-47 tags it loads for; a locale no set of the object names gets none | | `fallback` | — | `true` on ONE `locale` set per object: also loads for a locale no set names | @@ -56,6 +56,12 @@ export const SeedData = [statusSeed, categorySeed]; Full Zod shape: `node_modules/@objectstack/spec/src/data/seed.zod.ts`. +A `seed` saved at runtime names its `object` itself. One that resolves to +nothing is refused: `422 INVALID_METADATA` at `object`, "which is not defined". +Correct the name to the object's full name (`crm_lead`, not `lead`) or create +the object first: a draft of it is enough for a draft seed; a live seed needs +it published. + ### Import modes | Mode | Behavior | Use for | @@ -95,6 +101,11 @@ defineSeed(Invoice, { **Never use `id`** for generated UUIDs — they differ across environments. +Every record carries a value for each `externalId` field (each field of a +list; `name` when the seed names none). One left blank (no value, `null` or +`''`; whitespace is a value) is refused at load in every mode: the result names +the object, record index, field and fix, and the other records still load. + | Scenario | Key | |:---------|:----| | Named entities (country, currency) | `'code'` / `'slug'` | @@ -165,13 +176,10 @@ produce byte-identical `dist/objectstack.json`. ### Seed best practices -| Practice | Why | -|:---------|:----| -| TypeScript: `defineSeed()`, never `SeedSchema.parse()` | Lose compile-time field checks otherwise | +In TypeScript use `defineSeed()`, never `SeedSchema.parse()`: it loses compile-time field checks. **Fictional is fine; malformed is not.** A seed row passes the same field -validation as a user's insert; a refused value leaves the table short or empty -while sibling rows point at records that do not exist. +validation as a user's insert; a refused value drops the row its siblings point at. `os validate` / `os build` refuse such a value first, at the record's field — run them before trusting the load. So never mask or placeholder a sample value: no `138****4207`, diff --git a/skills/objectstack-data/rules/relationships.md b/skills/objectstack-data/rules/relationships.md index 8cad00d2b0a..3109d864bb7 100644 --- a/skills/objectstack-data/rules/relationships.md +++ b/skills/objectstack-data/rules/relationships.md @@ -345,16 +345,14 @@ InvoiceLine = { ### Detail-page related lists (the read-side mirror) You usually don't declare the **related list** on the parent's record detail page: every child relationship -(`master_detail` and `lookup`) is shown **by default** — owned (`master_detail`) -children first. The relationship -flags exist to *refine* that: +is shown **by default** — a `master_detail` child as a body table, a `lookup` +child as a panel. `inlineEdit` plays no part: it governs entry in the parent's +form only. The relationship flags *refine* that: ```typescript project: { type: 'master_detail', - reference: 'project', - inlineEdit: true, - relatedList: 'primary', // read side: a body table + reference: 'project', // no relatedList: a body table relatedListTitle: 'Tasks', relatedListColumns: ['title', 'status', 'priority', 'due_date'], }, @@ -365,10 +363,9 @@ audit_ref: { type: 'master_detail', reference: 'invoice', relatedList: false }, `relatedList` is tri-state — placement: -- `'primary'` — a full-width table in the record's detail body. Default for a `master_detail` FK with `inlineEdit`. +- `'primary'` — a full-width table in the record's detail body. Default for a `master_detail` FK. - `false` — the child object is not shown on the parent record page. -- `true`, or omitted (except inline-edited `master_detail`) — an auxiliary - panel on the record page. +- `true` — an auxiliary panel on the record page. Default for a `lookup` FK. - Order is the parent's: `relatedLists: ['task', 'event.related_to']` (child, or `object.field`) lists those first. A child in the stack with no inbound FK is refused everywhere; one that exists nowhere is refused by `os validate` / diff --git a/skills/objectstack-query/evals/filters-pagination-search.json b/skills/objectstack-query/evals/filters-pagination-search.json index 427213b337b..ca6ec196760 100644 --- a/skills/objectstack-query/evals/filters-pagination-search.json +++ b/skills/objectstack-query/evals/filters-pagination-search.json @@ -90,6 +90,16 @@ "must_contain": ["timezone: 'Asia/Taipei'", "dateGranularity: 'month'", "zonedDateBucketing", "in memory", "in the database"], "must_not_contain": ["date_trunc"] } + }, + { + "id": 10, + "prompt": "A dashboard widget over `supply_plan` must always show the current week. `plan_week` is a text field holding ISO week keys such as `2026-W47`; `ship_date` is a date field. Write the widget filter on `plan_week`, then the same week as a filter on `ship_date`.", + "expected_output": "`{ plan_week: '{current_iso_week}' }` — the period-key token resolves to today's ISO week key (`YYYY-Www`, workspace time zone, Monday-start weeks), so it matches a text field that stores those keys. It is text, not a date: on `ship_date` it is refused (`INVALID_FILTER` / 400), so the date field takes the week's boundaries, `{ ship_date: { $gte: '{current_week_start}', $lte: '{current_week_end}' } }`. No hand-computed key or date, which would freeze into the metadata.", + "files": [], + "assertions": { + "must_contain": ["plan_week: '{current_iso_week}'", "{current_week_start}", "{current_week_end}"], + "must_not_contain": ["{current_week}", "ship_date: '{current_iso_week}'"] + } } ] } diff --git a/skills/objectstack-query/rules/filters.md b/skills/objectstack-query/rules/filters.md index 2f432bcf8c8..44591ad9b3e 100644 --- a/skills/objectstack-query/rules/filters.md +++ b/skills/objectstack-query/rules/filters.md @@ -152,7 +152,6 @@ pages — cannot run code, so they use **date macro tokens** instead (defined in `@objectstack/spec` `data/date-macros.zod.ts`): ```typescript -// List-view / dashboard filter values where: { signal_at: { $gte: '{30_days_ago}' }, published_at: { $gte: '{last_quarter_start}' } @@ -164,24 +163,33 @@ where: { `{next_year_start}` (and bare aliases like `{month_start}`). - **Parameterised tokens:** `{N__ago}` / `{N__from_now}` with units `minute|hour|day|week|month|year` — e.g. `{2_weeks_from_now}`. -- **Both spellings parse:** `{today}` and `${today}` are the same token - (`DATE_MACRO_WRAPPED_RE` is `/^\$?\{([a-zA-Z0-9_]+)\}$/`, and the context - tokens share it). +- **Both spellings parse:** `{today}` and `${today}` are the same token, in + every vocabulary here. + +**Period key** (`PERIOD_KEY_TOKENS`, not a date macro): `{current_iso_week}` +is today's ISO week key, `YYYY-Www`, in the workspace time zone — Monday-start +weeks, the ISO week-year at year edges (2027-01-01 is `2026-W53`). It is text, +for a text field storing week keys. A `date` / `datetime` / `time` field +refuses it (`INVALID_FILTER` / 400) like the literal key — use +`{current_week_start}` / `{current_week_end}` there — as do a date dashboard +filter's `defaultValue` and `calendar.initialDate`; a text dashboard filter +may default to it. There is no last- or next-week key. **Session tokens:** the same value positions accept `{current_user_id}` and `{current_org_id}` (defined in `data/context-tokens.zod.ts`) — the signed-in user's id and the active organization id. ```typescript -where: { owner_id: '{current_user_id}', close_date: { $gte: '{current_year_start}' } } +where: { owner_id: '{current_user_id}', cost_week: '{current_iso_week}' } ``` **Scope:** tokens expand on **both** sides of the wire — client-side by -`resolveDateMacros()` / `resolveContextTokens()` in `@object-ui/core`, +`resolveFilterPlaceholders()` in `@object-ui/core` (`resolveDateMacros()`, +`resolvePeriodKeyTokens()` and `resolveContextTokens()` in one call), server-side by `resolveFilterTokens()` in `@objectstack/core`, wired into the ObjectQL read AND write paths (`find`/`findOne`/`count`/`aggregate`/`update`/ -`delete`) plus the analytics dataset executor. The driver only ever sees ISO -strings and concrete ids. So use tokens in a hand-issued engine query too: +`delete`) plus the analytics dataset executor. The driver only ever sees +resolved values. So use tokens in a hand-issued engine query too: computing "today" at module load freezes the date into the built artifact. A **flow node's** `config.filter` takes these tokens too. What a dropped @@ -200,8 +208,7 @@ indistinguishable from "there is no data". Near-misses, not tokens: (a real `titleFormat` interpolation) and `{organization_id}` (the column name); the error names the correction. A value that merely *contains* braces is left untouched — `'user-{current_user_id}'` is a literal. Check a spelling with -`isDateMacroToken(tok)` / `isContextToken(tok)` from `@objectstack/spec/data`, -WITHOUT braces. +`isKnownFilterToken(tok)` from `@objectstack/spec/data`, WITHOUT braces. **`*_end` is a calendar DAY; an upper bound means the WHOLE day.** `<= {current_year_end}` already reaches the final instant of Dec 31 diff --git a/skills/objectstack-ui/evals/README.md b/skills/objectstack-ui/evals/README.md index 2bc42952c4a..3bfea55d099 100644 --- a/skills/objectstack-ui/evals/README.md +++ b/skills/objectstack-ui/evals/README.md @@ -12,7 +12,7 @@ view / page / dashboard / report metadata. for a Chinese brief, whose members carry Chinese `synonyms` and a one-sentence `description`. - `record-page.json` — the record page as the object declares it: a child - table placed first by `relatedList: 'primary'` (no page file), + body table ordered first by `relatedLists` (no page file), `navigation: { mode: 'page' }` on the list view with the reader's own open choice left out of metadata, and `placedActions: true` on a full page's `page:header` so packaged header actions draw without an id list. diff --git a/skills/objectstack-ui/evals/record-page.json b/skills/objectstack-ui/evals/record-page.json index 8e82e621480..4f7e8e98374 100644 --- a/skills/objectstack-ui/evals/record-page.json +++ b/skills/objectstack-ui/evals/record-page.json @@ -4,14 +4,15 @@ { "id": 1, "prompt": "On the lead record page, put the tasks first: our reps want the open tasks table before anything else when they open a lead. The `task` object already has a `lead` master_detail field.", - "expected_output": "No page file. One flag on the child's reference field — `relatedList: 'primary'` on `task.lead` — makes the tasks a full-width body table in the lead's details, after the first field section; `relatedListFilter: { status: { $ne: 'done' } }` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it before the other lists. Not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.", + "expected_output": "No page file and no placement flag: `task.lead` is a `master_detail` with no `relatedList`, so it is already a full-width body table, drawn after the lead's open field sections. `relatedListFilter: { status: { $ne: 'done' } }` on `task.lead` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it first among the tables, directly under those field sections. Not `inlineEdit` (form entry, not the page), not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.", "files": [], "assertions": { "must_contain": [ - "relatedList: 'primary'", + "relatedListFilter", "relatedLists" ], "must_not_contain": [ + "inlineEdit:", "definePage(", "slots: { tabs", "kind: 'full'," diff --git a/skills/objectstack-ui/rules/record-page.md b/skills/objectstack-ui/rules/record-page.md index c2cfd4f6da2..c2953b4d4fd 100644 --- a/skills/objectstack-ui/rules/record-page.md +++ b/skills/objectstack-ui/rules/record-page.md @@ -16,15 +16,15 @@ one tab per panel with its count) enlarges a panel at `?related=object.field`. **2 · Relationship flags shape the related column.** On the CHILD object's reference field: `relatedList: 'primary'` draws the child as a full-width body -table in the details after the first field section (the default for a -`master_detail` with `inlineEdit`); `true` / absent is a panel in the right +table in the details after the open field sections (the default for a +`master_detail`); `true` (a `lookup`'s default) is a panel in the right column; `false` leaves the child off the page. `relatedListTitle` / `relatedListColumns` (child field names) replace the derived title / columns; `relatedListFilter` (Query-DSL, `{ status: { $ne: 'done' } }`) is AND-composed with the parent condition, and the panel's count honours it. Rows follow the child's default list view `sort` (`isDefault`, else the first declared); the parent's `relatedLists` orders tables and panels alike. "Put the tasks first on -the lead page" is `relatedList: 'primary'` on `task.lead` — no page file. +the lead page" is `relatedLists: ['task']` on `lead` — no page file. **3 · A slotted page overrides one slot.** `kind: 'slotted'` replaces only the slots it names — `header`, `actions`, `alerts`, `highlights`, `details`, @@ -59,7 +59,7 @@ import { Field, ObjectSchema } from '@objectstack/spec/data'; export const Task = ObjectSchema.create({ name: 'task', sharingModel: 'controlled_by_parent', fields: { - lead: Field.masterDetail('lead', { relatedList: 'primary', relatedListFilter: { status: { $ne: 'done' } } }), + lead: Field.masterDetail('lead', { relatedListFilter: { status: { $ne: 'done' } } }), // a body table }, }); ```