@colixsystems/widget-sdk 0.359.0 → 0.360.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -93,7 +93,11 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
93
93
 
94
94
  ## Status
95
95
 
96
- `v0.359.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
96
+ `v0.360.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
97
+
98
+ ### What's new in 0.360.0 (contract 1.296.0)
99
+
100
+ **A rental is priced by the days it covers.** A per-day rental priced by a quantity the buyer wrote let a buyer book five days and pay for one. A table that holds a `pricedItem` (a lines table, or a bookings table that names the rented item itself) may now declare `rentalStart: true` and `rentalEnd: true` on two write-once (`immutable: true`) DATE columns in a `datastoreTemplate`, one of each, declared together, instead of a `lineQuantity`. When `requestPayment({ order })` opens the charge, the server counts that priced item once per inclusive calendar day between the two dates (1–3 Dec is 3, a single day is 1) times its `unitPrice`. A missing date, an end before the start or a rental longer than 999 days is refused with the non-retryable `ORDER_LINES_INVALID`. The rented items' table cannot also declare a `stockQuantity`. For a per-night stay (a room or an apartment) also declare `rentalByNight: true` on the `rentalEnd` column: the end date is then the check-out day, so 1–3 Dec is 2 nights and a same-day stay is refused. Write the dates when creating the row; never compute or send the price from the widget.
97
101
 
98
102
  ### What's new in 0.359.0 (contract 1.295.0)
99
103
 
package/dist/contract.cjs CHANGED
@@ -4444,7 +4444,7 @@ const MANIFEST_SCHEMA = {
4444
4444
  type: "object",
4445
4445
  required: false,
4446
4446
  description:
4447
- "Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: { lines: \"<lines table suffix>\", via: \"<its relation to this table>\" }` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The SERVER prices it when the charge opens and ignores any client value: Σ over the order's lines of `lineQuantity` × the `unitPrice` of the row the line's `pricedItem` names, plus the order table's own `pricedItem` once (a shipping option). `via` is a write-once ONE_TO_MANY relation on the lines table pointing at this table. A bare `orderTotal: true` is accepted only on an orders table that has its own `pricedItem`; publishing any other unpriced order total is refused (an already published template still installs, and its order charges are refused with ORDER_NOT_PAYABLE). `unitPrice: true` makes a NUMBER column a product's price in minor units (one per table). `pricedItem: true` makes a write-once single RELATION (one per table) to a table with a unitPrice column the item a line or an order is priced by. `lineQuantity: true` makes a write-once NUMBER column (one per table) a line's quantity, a whole number from 1 to 999 (empty is 1). `stockQuantity: true` makes a NUMBER column (one per table, in a table with a unitPrice column, not immutable) how many of a product are left, a whole number of 0 or more (empty is not counted): a charge takes its order's quantities when it opens, refusing with OUT_OF_STOCK when one cannot be covered, and gives them back exactly once if it fails, is cancelled or stays unpaid past 15 minutes; a paid order keeps them and a refund does not restock (the seller restocks in the Studio). Read it to show a product sold out at 0; a widget never writes it. A payer who may edit or create rows in a priced table is refused, and once an order holds its total no line is added or removed (ORDER_LOCKED). `buyerEmail: true` makes a STRING column the buyer's email address, at most one per table, only in a table with a paymentStatus column, and it must be `immutable: true` (not encrypted, latestVia or copyOf): when a charge marks the order paid the platform emails the buyer an order confirmation (a guest at this address, a signed-in buyer at their account's address), and a refund notice after a full refund, so a widget never sends its own. A guest charge (`requestGuestPayment`) for an order whose table has no buyerEmail column, or whose address is empty or invalid, is refused. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
4447
+ "Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: { lines: \"<lines table suffix>\", via: \"<its relation to this table>\" }` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The SERVER prices it when the charge opens and ignores any client value: Σ over the order's lines of `lineQuantity` × the `unitPrice` of the row the line's `pricedItem` names, plus the order table's own `pricedItem` once (a shipping option). `via` is a write-once ONE_TO_MANY relation on the lines table pointing at this table. A bare `orderTotal: true` is accepted only on an orders table that has its own `pricedItem`; publishing any other unpriced order total is refused (an already published template still installs, and its order charges are refused with ORDER_NOT_PAYABLE). `unitPrice: true` makes a NUMBER column a product's price in minor units (one per table). `pricedItem: true` makes a write-once single RELATION (one per table) to a table with a unitPrice column the item a line or an order is priced by. `lineQuantity: true` makes a write-once NUMBER column (one per table) a line's quantity, a whole number from 1 to 999 (empty is 1). `stockQuantity: true` makes a NUMBER column (one per table, in a table with a unitPrice column, not immutable) how many of a product are left, a whole number of 0 or more (empty is not counted): a charge takes its order's quantities when it opens, refusing with OUT_OF_STOCK when one cannot be covered, and gives them back exactly once if it fails, is cancelled or stays unpaid past 15 minutes; a paid order keeps them and a refund does not restock (the seller restocks in the Studio). Read it to show a product sold out at 0; a widget never writes it. `rentalStart: true` and `rentalEnd: true` make two write-once DATE columns (one each per table, declared together, in a table with a `pricedItem` and no `lineQuantity`) a rental's first and last day: the server charges that priced item once per inclusive day between them (1–3 Dec is 3) instead of a quantity, refusing with ORDER_LINES_INVALID when a date is missing, the end is before the start or the rental is over 999 days; the rented items' table cannot count stock. For a per-night stay, `rentalByNight: true` beside `rentalEnd: true` makes the end date the check-out day: the server then charges the nights (1–3 Dec is 2) and refuses a same-day stay. Never compute the price in the widget. A payer who may edit or create rows in a priced table is refused, and once an order holds its total no line is added or removed (ORDER_LOCKED). `buyerEmail: true` makes a STRING column the buyer's email address, at most one per table, only in a table with a paymentStatus column, and it must be `immutable: true` (not encrypted, latestVia or copyOf): when a charge marks the order paid the platform emails the buyer an order confirmation (a guest at this address, a signed-in buyer at their account's address), and a refund notice after a full refund, so a widget never sends its own. A guest charge (`requestGuestPayment`) for an order whose table has no buyerEmail column, or whose address is empty or invalid, is refused. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
4448
4448
  },
4449
4449
  translations: {
4450
4450
  type: "object",
@@ -7273,7 +7273,10 @@ const CONTRACT = deepFreeze({
7273
7273
  // `connectors.accounts` host client + the `connectors.accounts:*` scope +
7274
7274
  // `use: "accounts"` on a `connectorRef` property. An app user connects
7275
7275
  // their own account at a connector's provider.
7276
- version: "1.295.0",
7276
+ // 1.296.0: additive (sc-18707) — a template column may declare
7277
+ // `rentalStart` / `rentalEnd` (and `rentalByNight` on the end); the
7278
+ // server prices a rental by its days or nights.
7279
+ version: "1.296.0",
7277
7280
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7278
7281
  hooks: HOOKS,
7279
7282
  primitives: PRIMITIVES,
package/dist/contract.js CHANGED
@@ -4439,7 +4439,7 @@ const MANIFEST_SCHEMA = {
4439
4439
  type: "object",
4440
4440
  required: false,
4441
4441
  description:
4442
- "Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: { lines: \"<lines table suffix>\", via: \"<its relation to this table>\" }` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The SERVER prices it when the charge opens and ignores any client value: Σ over the order's lines of `lineQuantity` × the `unitPrice` of the row the line's `pricedItem` names, plus the order table's own `pricedItem` once (a shipping option). `via` is a write-once ONE_TO_MANY relation on the lines table pointing at this table. A bare `orderTotal: true` is accepted only on an orders table that has its own `pricedItem`; publishing any other unpriced order total is refused (an already published template still installs, and its order charges are refused with ORDER_NOT_PAYABLE). `unitPrice: true` makes a NUMBER column a product's price in minor units (one per table). `pricedItem: true` makes a write-once single RELATION (one per table) to a table with a unitPrice column the item a line or an order is priced by. `lineQuantity: true` makes a write-once NUMBER column (one per table) a line's quantity, a whole number from 1 to 999 (empty is 1). `stockQuantity: true` makes a NUMBER column (one per table, in a table with a unitPrice column, not immutable) how many of a product are left, a whole number of 0 or more (empty is not counted): a charge takes its order's quantities when it opens, refusing with OUT_OF_STOCK when one cannot be covered, and gives them back exactly once if it fails, is cancelled or stays unpaid past 15 minutes; a paid order keeps them and a refund does not restock (the seller restocks in the Studio). Read it to show a product sold out at 0; a widget never writes it. A payer who may edit or create rows in a priced table is refused, and once an order holds its total no line is added or removed (ORDER_LOCKED). `buyerEmail: true` makes a STRING column the buyer's email address, at most one per table, only in a table with a paymentStatus column, and it must be `immutable: true` (not encrypted, latestVia or copyOf): when a charge marks the order paid the platform emails the buyer an order confirmation (a guest at this address, a signed-in buyer at their account's address), and a refund notice after a full refund, so a widget never sends its own. A guest charge (`requestGuestPayment`) for an order whose table has no buyerEmail column, or whose address is empty or invalid, is refused. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
4442
+ "Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: { lines: \"<lines table suffix>\", via: \"<its relation to this table>\" }` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The SERVER prices it when the charge opens and ignores any client value: Σ over the order's lines of `lineQuantity` × the `unitPrice` of the row the line's `pricedItem` names, plus the order table's own `pricedItem` once (a shipping option). `via` is a write-once ONE_TO_MANY relation on the lines table pointing at this table. A bare `orderTotal: true` is accepted only on an orders table that has its own `pricedItem`; publishing any other unpriced order total is refused (an already published template still installs, and its order charges are refused with ORDER_NOT_PAYABLE). `unitPrice: true` makes a NUMBER column a product's price in minor units (one per table). `pricedItem: true` makes a write-once single RELATION (one per table) to a table with a unitPrice column the item a line or an order is priced by. `lineQuantity: true` makes a write-once NUMBER column (one per table) a line's quantity, a whole number from 1 to 999 (empty is 1). `stockQuantity: true` makes a NUMBER column (one per table, in a table with a unitPrice column, not immutable) how many of a product are left, a whole number of 0 or more (empty is not counted): a charge takes its order's quantities when it opens, refusing with OUT_OF_STOCK when one cannot be covered, and gives them back exactly once if it fails, is cancelled or stays unpaid past 15 minutes; a paid order keeps them and a refund does not restock (the seller restocks in the Studio). Read it to show a product sold out at 0; a widget never writes it. `rentalStart: true` and `rentalEnd: true` make two write-once DATE columns (one each per table, declared together, in a table with a `pricedItem` and no `lineQuantity`) a rental's first and last day: the server charges that priced item once per inclusive day between them (1–3 Dec is 3) instead of a quantity, refusing with ORDER_LINES_INVALID when a date is missing, the end is before the start or the rental is over 999 days; the rented items' table cannot count stock. For a per-night stay, `rentalByNight: true` beside `rentalEnd: true` makes the end date the check-out day: the server then charges the nights (1–3 Dec is 2) and refuses a same-day stay. Never compute the price in the widget. A payer who may edit or create rows in a priced table is refused, and once an order holds its total no line is added or removed (ORDER_LOCKED). `buyerEmail: true` makes a STRING column the buyer's email address, at most one per table, only in a table with a paymentStatus column, and it must be `immutable: true` (not encrypted, latestVia or copyOf): when a charge marks the order paid the platform emails the buyer an order confirmation (a guest at this address, a signed-in buyer at their account's address), and a refund notice after a full refund, so a widget never sends its own. A guest charge (`requestGuestPayment`) for an order whose table has no buyerEmail column, or whose address is empty or invalid, is refused. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
4443
4443
  },
4444
4444
  translations: {
4445
4445
  type: "object",
@@ -7268,7 +7268,10 @@ const CONTRACT = deepFreeze({
7268
7268
  // `connectors.accounts` host client + the `connectors.accounts:*` scope +
7269
7269
  // `use: "accounts"` on a `connectorRef` property. An app user connects
7270
7270
  // their own account at a connector's provider.
7271
- version: "1.295.0",
7271
+ // 1.296.0: additive (sc-18707) — a template column may declare
7272
+ // `rentalStart` / `rentalEnd` (and `rentalByNight` on the end); the
7273
+ // server prices a rental by its days or nights.
7274
+ version: "1.296.0",
7272
7275
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7273
7276
  hooks: HOOKS,
7274
7277
  primitives: PRIMITIVES,
package/dist/index.d.ts CHANGED
@@ -324,6 +324,20 @@ export interface WidgetDatastoreTemplateColumn {
324
324
  * checkouts in progress are already taken off. Read it to show a product as sold out; never write it.
325
325
  */
326
326
  stockQuantity?: boolean;
327
+ /**
328
+ * DATE only, `immutable: true`, one per table, declared with `rentalEnd` in
329
+ * a table with a `pricedItem` and no `lineQuantity`: a rental's first day.
330
+ * The server charges that priced item once per inclusive day from
331
+ * `rentalStart` to `rentalEnd` (1–3 Dec is 3), so a widget never computes it.
332
+ */
333
+ rentalStart?: boolean;
334
+ /** DATE only, `immutable: true`: a rental's last day, under `rentalStart`'s rules. */
335
+ rentalEnd?: boolean;
336
+ /**
337
+ * Only beside `rentalEnd: true`: the end date is the check-out day, so the
338
+ * server charges per night (1–3 Dec is 2) and refuses a same-day stay.
339
+ */
340
+ rentalByNight?: boolean;
327
341
  /**
328
342
  * STRING only, at most one per table, in a table with a `paymentStatus`
329
343
  * column, and it must be `immutable: true` (not encrypted, `latestVia` or
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.359.0",
3
+ "version": "0.360.0",
4
4
  "description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/contract.js CHANGED
@@ -4439,7 +4439,7 @@ const MANIFEST_SCHEMA = {
4439
4439
  type: "object",
4440
4440
  required: false,
4441
4441
  description:
4442
- "Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: { lines: \"<lines table suffix>\", via: \"<its relation to this table>\" }` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The SERVER prices it when the charge opens and ignores any client value: Σ over the order's lines of `lineQuantity` × the `unitPrice` of the row the line's `pricedItem` names, plus the order table's own `pricedItem` once (a shipping option). `via` is a write-once ONE_TO_MANY relation on the lines table pointing at this table. A bare `orderTotal: true` is accepted only on an orders table that has its own `pricedItem`; publishing any other unpriced order total is refused (an already published template still installs, and its order charges are refused with ORDER_NOT_PAYABLE). `unitPrice: true` makes a NUMBER column a product's price in minor units (one per table). `pricedItem: true` makes a write-once single RELATION (one per table) to a table with a unitPrice column the item a line or an order is priced by. `lineQuantity: true` makes a write-once NUMBER column (one per table) a line's quantity, a whole number from 1 to 999 (empty is 1). `stockQuantity: true` makes a NUMBER column (one per table, in a table with a unitPrice column, not immutable) how many of a product are left, a whole number of 0 or more (empty is not counted): a charge takes its order's quantities when it opens, refusing with OUT_OF_STOCK when one cannot be covered, and gives them back exactly once if it fails, is cancelled or stays unpaid past 15 minutes; a paid order keeps them and a refund does not restock (the seller restocks in the Studio). Read it to show a product sold out at 0; a widget never writes it. A payer who may edit or create rows in a priced table is refused, and once an order holds its total no line is added or removed (ORDER_LOCKED). `buyerEmail: true` makes a STRING column the buyer's email address, at most one per table, only in a table with a paymentStatus column, and it must be `immutable: true` (not encrypted, latestVia or copyOf): when a charge marks the order paid the platform emails the buyer an order confirmation (a guest at this address, a signed-in buyer at their account's address), and a refund notice after a full refund, so a widget never sends its own. A guest charge (`requestGuestPayment`) for an order whose table has no buyerEmail column, or whose address is empty or invalid, is refused. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
4442
+ "Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: { lines: \"<lines table suffix>\", via: \"<its relation to this table>\" }` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The SERVER prices it when the charge opens and ignores any client value: Σ over the order's lines of `lineQuantity` × the `unitPrice` of the row the line's `pricedItem` names, plus the order table's own `pricedItem` once (a shipping option). `via` is a write-once ONE_TO_MANY relation on the lines table pointing at this table. A bare `orderTotal: true` is accepted only on an orders table that has its own `pricedItem`; publishing any other unpriced order total is refused (an already published template still installs, and its order charges are refused with ORDER_NOT_PAYABLE). `unitPrice: true` makes a NUMBER column a product's price in minor units (one per table). `pricedItem: true` makes a write-once single RELATION (one per table) to a table with a unitPrice column the item a line or an order is priced by. `lineQuantity: true` makes a write-once NUMBER column (one per table) a line's quantity, a whole number from 1 to 999 (empty is 1). `stockQuantity: true` makes a NUMBER column (one per table, in a table with a unitPrice column, not immutable) how many of a product are left, a whole number of 0 or more (empty is not counted): a charge takes its order's quantities when it opens, refusing with OUT_OF_STOCK when one cannot be covered, and gives them back exactly once if it fails, is cancelled or stays unpaid past 15 minutes; a paid order keeps them and a refund does not restock (the seller restocks in the Studio). Read it to show a product sold out at 0; a widget never writes it. `rentalStart: true` and `rentalEnd: true` make two write-once DATE columns (one each per table, declared together, in a table with a `pricedItem` and no `lineQuantity`) a rental's first and last day: the server charges that priced item once per inclusive day between them (1–3 Dec is 3) instead of a quantity, refusing with ORDER_LINES_INVALID when a date is missing, the end is before the start or the rental is over 999 days; the rented items' table cannot count stock. For a per-night stay, `rentalByNight: true` beside `rentalEnd: true` makes the end date the check-out day: the server then charges the nights (1–3 Dec is 2) and refuses a same-day stay. Never compute the price in the widget. A payer who may edit or create rows in a priced table is refused, and once an order holds its total no line is added or removed (ORDER_LOCKED). `buyerEmail: true` makes a STRING column the buyer's email address, at most one per table, only in a table with a paymentStatus column, and it must be `immutable: true` (not encrypted, latestVia or copyOf): when a charge marks the order paid the platform emails the buyer an order confirmation (a guest at this address, a signed-in buyer at their account's address), and a refund notice after a full refund, so a widget never sends its own. A guest charge (`requestGuestPayment`) for an order whose table has no buyerEmail column, or whose address is empty or invalid, is refused. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
4443
4443
  },
4444
4444
  translations: {
4445
4445
  type: "object",
@@ -7268,7 +7268,10 @@ const CONTRACT = deepFreeze({
7268
7268
  // `connectors.accounts` host client + the `connectors.accounts:*` scope +
7269
7269
  // `use: "accounts"` on a `connectorRef` property. An app user connects
7270
7270
  // their own account at a connector's provider.
7271
- version: "1.295.0",
7271
+ // 1.296.0: additive (sc-18707) — a template column may declare
7272
+ // `rentalStart` / `rentalEnd` (and `rentalByNight` on the end); the
7273
+ // server prices a rental by its days or nights.
7274
+ version: "1.296.0",
7272
7275
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7273
7276
  hooks: HOOKS,
7274
7277
  primitives: PRIMITIVES,