Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changeset/34275-blueprint-field-multiple-accept-maxsize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@objectstack/spec': minor
---

feat(spec): an AI blueprint field can declare `multiple`, `accept` and `maxSize`

Clause-②: yes (widening) — a blueprint field carrying `multiple` on a type that can hold several values, or `accept` / `maxSize`, parses where it was refused as an unrecognized key; the strict mirror gains the same three keys, nullable. `@objectstack/spec/data` gains one export, `multiDeclarableFieldTypes()`. Nothing is removed or narrowed.
Metadata-protocol: added
Skills-docs: none — `skills/**` teaches no blueprint field key; the blueprint guide the design model reads lives with the applier in cloud, which carries the keys next.

`BlueprintFieldSchema` (what `apply_blueprint` parses) and its strict mirror (what the in-app design model generates against) now declare three keys the object field contract already had, with `FieldSchema`'s own value shapes:

- **`multiple`** (boolean): several values in one field — several related records on a `lookup` / `user`, several files on a `file` / `image`, several chosen options on a `select`. "An expense claim with its e-invoices attached" is now one blueprint field, `{ name: 'invoices', type: 'file', multiple: true }`.
- **`accept`** (array of MIME types or extensions) and **`maxSize`** (a positive integer, in bytes): the upload types and the size limit of a media field.

FROM → TO for an author: before, `{ type: 'file', multiple: true }` in a blueprint was refused with `unrecognized_keys` at the field's `multiple`; now it parses, and the applier carries the key into the built field. At the `apply_blueprint` door nothing an author wrote before parses differently: the door refused the three keys, and a field that declares none of them parses exactly as before and gains no key. A direct `BlueprintFieldSchema.parse` (or `SolutionBlueprintSchema.parse`) is different, because it used to strip an undeclared key: FROM `{ type: 'text', multiple: true }`, `{ type: 'file', maxSize: 0 }` or `{ type: 'select', options, multiple: true, defaultValue: 'open' }` parsing with the key silently dropped, TO each refused at that key (`multiple`, `maxSize`, `defaultValue`). The fix is the one the message names: drop the key, or give it a value the field takes.

- **`multiple: true` is refused by name where the built field refuses it.** The blueprint field judges it against `FieldSchema`'s own declarable set, exported as `multiDeclarableFieldTypes()` rather than copied, so `multiple: true` is refused on exactly the types the built field refuses it on. A `radio` field is refused as on `FieldSchema`: a radio group is single-choice. The refusal lands on the field's `multiple` and names the types that take it.
- **A multi-value `select` takes no blueprint `defaultValue`.** It stores a list, and a blueprint default is one value; the built field would refuse the scalar too. The refusal lands on the field's `defaultValue`.
- **A multi-value `select`'s options take no `kind`.** A lifecycle kind says where one record stands, and the field holds no single option code per record; the built field refuses it too. One refusal per option, at that option's `kind`. Such a field is never an object's `stageField` either: the object's stage-field rule refuses it at `stageField`.
- **`accept` / `maxSize` outside the media family** parse and are read by nothing, as on `FieldSchema`; the describes say so.
10 changes: 8 additions & 2 deletions content/docs/references/ai/solution-blueprint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ const result = BlueprintAppSchema.parse(data);
| **options** | `{ label: string; value: string; kind?: Enum<'open' \| 'won' \| 'lost'> }[]` | optional | Choices for select / multiselect / radio fields |
| **summaryOperations** | `{ object: string; function: Enum<'count' \| 'sum' \| 'avg' \| 'min' \| 'max'>; field?: string; relationshipField?: string; … }` | optional | REQUIRED when `type` is "summary" (a roll-up of child records: 任务总数 / 报名人数 / 合计金额 / 已完成任务数). Names the child object, the aggregation, and — for a qualified count/sum — the condition. A "summary" field without it materializes runtime-dead. |
| **expression** | `string` | optional | The CEL body a computed field computes. Two uses. First, REQUIRED when `type` is "formula", e.g. "record.quantity * record.unit_price", or "record.order_no + ' · ' + record.customer.name" for a composed title. A formula reads a lookup / master_detail field's related record ONE hop through it — `record.<lookup>.<field>`, as `record.customer.name` above; the bare `record.customer` is the stored id, and a second hop (`record.customer.owner.name`) is refused at build. A "formula" field without it materializes runtime-dead: the engine builds its formula plan only from fields that HAVE an expression, so the field reads null everywhere, forever. Same failure shape as a "summary" with no `summaryOperations`. Note `nameField` on the object recommends a formula for numbered entities (invoice/ticket) — that formula needs THIS key, or the record title is blank on every card, lookup chip and breadcrumb. A "formula" is computed on read and stored nowhere: it is shown everywhere, but a list cannot sort by it, search does not scan it, and a `sum` / `avg` over it is refused with the one remedy every such refusal prints: "Computed on read, the field stores no value: make it a field of its return type with the same `expression` (computed and stored on write) and aggregate that. Counting records is a different question." Second, the stored computed value that remedy names: the same `expression` on a field of the value's own return type, never a "formula" (`number` / `currency` / `percent` for a quantity or an amount, `date` for a date). The engine computes it from the record on every write and keeps it in a column, so `sum` / `avg` and sort work on it as on any stored field of that type. Use it whenever the value is totalled, averaged or charted: 销售额 = 销量 × 单价 is a "currency" field with "record.quantity * record.unit_price". Name the return type, not "number" for every value: a date expression on a "number" field is refused at every write. A stored expression reads only this record's own fields: a value from a related record stays a "formula" (shown, not totalled) or is a snapshot field written by a flow on the related object when that value changes, and an input that changes over time (the current date, the acting user) is frozen at the write. Omit it on a field that is neither a formula nor a stored computed value. |
| **defaultValue** | `boolean \| number \| string` | optional | The built field's default: the value a new record gets when it is created without one, carried into the object field as its `defaultValue` and stored as written. It must fit `type`, and only these types take one: "boolean" / "toggle" → true or false; "number" / "currency" / "percent" / "rating" / "slider" / "progress" → a number; "text" / "textarea" / "email" / "url" / "phone" / "markdown" / "html" / "richtext" / "code" / "color" → a string; "time" → a time of day, "HH:MM"; "select" / "radio" → the `value` of one of the field's own `options`, never its label. Every other type is refused by name: a date is fixed at design time, a reference or file names no record yet, a multi-value field stores a list, a formula / summary / autonumber is computed, and a credential, signature or structured value has no one value right for every record. A yes/no flag (是否完成 / 已付款 / is_active) is a "boolean" field that is never `required` (omit `required` or set it false) and carries defaultValue false: a required flag refuses the unchecked switch, and a flag with no default is empty, not false, on every record created without it, so a filter on false misses those records. Omit it for a field with no default. |
| **defaultValue** | `boolean \| number \| string` | optional | The built field's default: the value a new record gets when it is created without one, carried into the object field as its `defaultValue` and stored as written. It must fit `type`, and only these types take one: "boolean" / "toggle" → true or false; "number" / "currency" / "percent" / "rating" / "slider" / "progress" → a number; "text" / "textarea" / "email" / "url" / "phone" / "markdown" / "html" / "richtext" / "code" / "color" → a string; "time" → a time of day, "HH:MM"; "select" / "radio" → the `value` of one of the field's own `options`, never its label. Every other type is refused by name, and so is a "select" with `multiple: true`: a date is fixed at design time, a reference or file names no record yet, a multi-value field stores a list, a formula / summary / autonumber is computed, and a credential, signature or structured value has no one value right for every record. A yes/no flag (是否完成 / 已付款 / is_active) is a "boolean" field that is never `required` (omit `required` or set it false) and carries defaultValue false: a required flag refuses the unchecked switch, and a flag with no default is empty, not false, on every record created without it, so a filter on false misses those records. Omit it for a field with no default. |
| **multiple** | `boolean` | optional | Several values in one field: true makes the built field hold a list — several related records on a "lookup" / "user", several files on a "file" / "image", several chosen options on a "select". Declarable only on "select" / "lookup" / "user" / "file" / "image" (and redundantly on "multiselect" / "checkboxes" / "tags", which are lists already); `multiple: true` on any other type, "radio" included, is refused by name. A multi-value "select" takes no defaultValue, and its options take no `kind` (a lifecycle is one value per record, so it is never an object's stage field). Carried into the built field by the applier as its `multiple`. Omit it for a single value. |
| **accept** | `string[]` | optional | The upload types a media field ("file" / "image" / "avatar" / "video" / "audio") permits, as MIME types or extensions, e.g. ["application/pdf", "image/*", ".ofd"]. Read only on the media family: on any other type it parses and nothing reads it. Carried into the built field by the applier as its `accept`, which the built field offers to the file picker and checks on write. Omit it to permit any type. |
| **maxSize** | `integer` | optional | The largest file a media field ("file" / "image" / "avatar" / "video" / "audio") takes, in BYTES (a positive integer: 10485760 for 10 MB). Read only on the media family: on any other type it parses and nothing reads it. Carried into the built field by the applier as its `maxSize`, which the built field checks on write against the stored file size. Omit it to set no limit on the field. |

### Allowed Values: `BlueprintField.type`

Expand Down Expand Up @@ -231,7 +234,10 @@ const result = BlueprintAppSchema.parse(data);
| **options** | `{ label: string; value: string; kind?: Enum<'open' \| 'won' \| 'lost'> }[]` | optional | Choices for select / multiselect / radio fields |
| **summaryOperations** | `{ object: string; function: Enum<'count' \| 'sum' \| 'avg' \| 'min' \| 'max'>; field?: string; relationshipField?: string; … }` | optional | REQUIRED when `type` is "summary" (a roll-up of child records: 任务总数 / 报名人数 / 合计金额 / 已完成任务数). Names the child object, the aggregation, and — for a qualified count/sum — the condition. A "summary" field without it materializes runtime-dead. |
| **expression** | `string` | optional | The CEL body a computed field computes. Two uses. First, REQUIRED when `type` is "formula", e.g. "record.quantity * record.unit_price", or "record.order_no + ' · ' + record.customer.name" for a composed title. A formula reads a lookup / master_detail field's related record ONE hop through it — `record.<lookup>.<field>`, as `record.customer.name` above; the bare `record.customer` is the stored id, and a second hop (`record.customer.owner.name`) is refused at build. A "formula" field without it materializes runtime-dead: the engine builds its formula plan only from fields that HAVE an expression, so the field reads null everywhere, forever. Same failure shape as a "summary" with no `summaryOperations`. Note `nameField` on the object recommends a formula for numbered entities (invoice/ticket) — that formula needs THIS key, or the record title is blank on every card, lookup chip and breadcrumb. A "formula" is computed on read and stored nowhere: it is shown everywhere, but a list cannot sort by it, search does not scan it, and a `sum` / `avg` over it is refused with the one remedy every such refusal prints: "Computed on read, the field stores no value: make it a field of its return type with the same `expression` (computed and stored on write) and aggregate that. Counting records is a different question." Second, the stored computed value that remedy names: the same `expression` on a field of the value's own return type, never a "formula" (`number` / `currency` / `percent` for a quantity or an amount, `date` for a date). The engine computes it from the record on every write and keeps it in a column, so `sum` / `avg` and sort work on it as on any stored field of that type. Use it whenever the value is totalled, averaged or charted: 销售额 = 销量 × 单价 is a "currency" field with "record.quantity * record.unit_price". Name the return type, not "number" for every value: a date expression on a "number" field is refused at every write. A stored expression reads only this record's own fields: a value from a related record stays a "formula" (shown, not totalled) or is a snapshot field written by a flow on the related object when that value changes, and an input that changes over time (the current date, the acting user) is frozen at the write. Omit it on a field that is neither a formula nor a stored computed value. |
| **defaultValue** | `boolean \| number \| string` | optional | The built field's default: the value a new record gets when it is created without one, carried into the object field as its `defaultValue` and stored as written. It must fit `type`, and only these types take one: "boolean" / "toggle" → true or false; "number" / "currency" / "percent" / "rating" / "slider" / "progress" → a number; "text" / "textarea" / "email" / "url" / "phone" / "markdown" / "html" / "richtext" / "code" / "color" → a string; "time" → a time of day, "HH:MM"; "select" / "radio" → the `value` of one of the field's own `options`, never its label. Every other type is refused by name: a date is fixed at design time, a reference or file names no record yet, a multi-value field stores a list, a formula / summary / autonumber is computed, and a credential, signature or structured value has no one value right for every record. A yes/no flag (是否完成 / 已付款 / is_active) is a "boolean" field that is never `required` (omit `required` or set it false) and carries defaultValue false: a required flag refuses the unchecked switch, and a flag with no default is empty, not false, on every record created without it, so a filter on false misses those records. Omit it for a field with no default. |
| **defaultValue** | `boolean \| number \| string` | optional | The built field's default: the value a new record gets when it is created without one, carried into the object field as its `defaultValue` and stored as written. It must fit `type`, and only these types take one: "boolean" / "toggle" → true or false; "number" / "currency" / "percent" / "rating" / "slider" / "progress" → a number; "text" / "textarea" / "email" / "url" / "phone" / "markdown" / "html" / "richtext" / "code" / "color" → a string; "time" → a time of day, "HH:MM"; "select" / "radio" → the `value` of one of the field's own `options`, never its label. Every other type is refused by name, and so is a "select" with `multiple: true`: a date is fixed at design time, a reference or file names no record yet, a multi-value field stores a list, a formula / summary / autonumber is computed, and a credential, signature or structured value has no one value right for every record. A yes/no flag (是否完成 / 已付款 / is_active) is a "boolean" field that is never `required` (omit `required` or set it false) and carries defaultValue false: a required flag refuses the unchecked switch, and a flag with no default is empty, not false, on every record created without it, so a filter on false misses those records. Omit it for a field with no default. |
| **multiple** | `boolean` | optional | Several values in one field: true makes the built field hold a list — several related records on a "lookup" / "user", several files on a "file" / "image", several chosen options on a "select". Declarable only on "select" / "lookup" / "user" / "file" / "image" (and redundantly on "multiselect" / "checkboxes" / "tags", which are lists already); `multiple: true` on any other type, "radio" included, is refused by name. A multi-value "select" takes no defaultValue, and its options take no `kind` (a lifecycle is one value per record, so it is never an object's stage field). Carried into the built field by the applier as its `multiple`. Omit it for a single value. |
| **accept** | `string[]` | optional | The upload types a media field ("file" / "image" / "avatar" / "video" / "audio") permits, as MIME types or extensions, e.g. ["application/pdf", "image/*", ".ofd"]. Read only on the media family: on any other type it parses and nothing reads it. Carried into the built field by the applier as its `accept`, which the built field offers to the file picker and checks on write. Omit it to permit any type. |
| **maxSize** | `integer` | optional | The largest file a media field ("file" / "image" / "avatar" / "video" / "audio") takes, in BYTES (a positive integer: 10485760 for 10 MB). Read only on the media family: on any other type it parses and nothing reads it. Carried into the built field by the applier as its `maxSize`, which the built field checks on write against the stored file size. Omit it to set no limit on the field. |


---
Expand Down
1 change: 1 addition & 0 deletions packages/spec/api-surface/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@
"matchesLikePattern (function)",
"materializeTreeSelfReferences (function)",
"missingFieldValues (function)",
"multiDeclarableFieldTypes (function)",
"nextUtcCalendarDay (function)",
"normalizeFilterComparandTypes (function)",
"numberComparandDoorVerdict (function)",
Expand Down
3 changes: 3 additions & 0 deletions packages/spec/authorable-surface/ai.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@
"ai/BlueprintDashboard:label",
"ai/BlueprintDashboard:name",
"ai/BlueprintDashboard:widgets",
"ai/BlueprintField:accept",
"ai/BlueprintField:defaultValue",
"ai/BlueprintField:expression",
"ai/BlueprintField:label",
"ai/BlueprintField:maxSize",
"ai/BlueprintField:multiple",
"ai/BlueprintField:name",
"ai/BlueprintField:options",
"ai/BlueprintField:reference",
Expand Down
1 change: 1 addition & 0 deletions packages/spec/export-origins/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@
"matchesLikePattern": "src/data/filter.zod.ts#matchesLikePattern (function)",
"materializeTreeSelfReferences": "src/data/object.zod.ts#materializeTreeSelfReferences (function)",
"missingFieldValues": "src/data/autonumber-format.ts#missingFieldValues (function)",
"multiDeclarableFieldTypes": "src/data/field.zod.ts#multiDeclarableFieldTypes (function)",
"nextUtcCalendarDay": "src/data/calendar-day.ts#nextUtcCalendarDay (function)",
"normalizeFilterComparandTypes": "src/data/filter-comparand-type.ts#normalizeFilterComparandTypes (function)",
"numberComparandDoorVerdict": "src/data/filter-number-comparand-declared-type.ts#numberComparandDoorVerdict (function)",
Expand Down
Loading
Loading