@colixsystems/widget-sdk 0.355.0 → 0.356.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 +9 -1
- package/dist/contract.cjs +6 -3
- package/dist/contract.js +6 -3
- package/dist/hooks.js +4 -0
- package/dist/index.d.ts +12 -1
- package/dist/linter.cjs +32 -5
- package/dist/linter.js +32 -5
- package/package.json +1 -1
- package/src/contract.js +6 -3
package/README.md
CHANGED
|
@@ -91,7 +91,15 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
94
|
+
`v0.356.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**.
|
|
95
|
+
|
|
96
|
+
### What's new in 0.356.0 (contract 1.292.0)
|
|
97
|
+
|
|
98
|
+
**A shop cannot sell what it does not have.** Two buyers of the last item could both pay, and the seller had to refund one. A products table can now hold a stock column: a NUMBER column declared with `stockQuantity: true` in a `datastoreTemplate`, one per table, in a table with a `unitPrice` column, and NOT `immutable` (the seller restocks it in the Studio). It holds how many are left, a whole number of 0 or more; an empty cell is not counted and sells without limit. When `requestPayment({ order })` (or `requestGuestPayment`) opens a charge, the server takes each line's quantity off its product's stock in the same step that prices the order, so of two buyers of the last item one charge opens and the other is refused with the new non-retryable `PaymentError` code `OUT_OF_STOCK`, whose message names the product. An order refused before it was ever priced stays editable, so the buyer can remove the sold-out line; one already priced by an earlier charge is fixed, so start a new order. The stock goes back exactly once when the payment provider reports the charge failed, cancelled or expired, and an open checkout keeps it however old; a paid order keeps it, and a refund does not restock. The stock value is what is available to sell: items in checkouts still in progress are already taken off. Read the stock cell to show a product as sold out at 0, and never write it from a widget: a payer who may edit the products is refused anyway.
|
|
99
|
+
|
|
100
|
+
### What's new in 0.355.1 (contract 1.291.0)
|
|
101
|
+
|
|
102
|
+
**The date rule reads date-fns options it cannot see.** `date-shown-fixed-format` no longer flags a date-fns pattern that prints words when the call's options may carry the app's locale without spelling it out: options held in a variable (`format(d, "PPP", opts)`), an options object with a spread (`{ ...dfOptions }`), or a call with no `locale` after date-fns `setDefaultOptions` was given one (`setDefaultOptions({ locale: appLocale })`, imported by name, by default from `date-fns/setDefaultOptions` or through a namespace). A fixed `date-fns/locale` import is still one language, so `setDefaultOptions({ locale: sv })` or `{ ...dfOptions, locale: sv }` still flags, and a numeric day-before-month pattern flags whatever the options. Fewer findings, no new ones.
|
|
95
103
|
|
|
96
104
|
### What's new in 0.355.0 (contract 1.291.0)
|
|
97
105
|
|
package/dist/contract.cjs
CHANGED
|
@@ -2517,7 +2517,7 @@ const HOOKS = [
|
|
|
2517
2517
|
signature: "usePayments()",
|
|
2518
2518
|
returnShape: {
|
|
2519
2519
|
requestPayment:
|
|
2520
|
-
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column the server prices (orderTotal: { lines, via } in the datastoreTemplate; without one: ORDER_NOT_PAYABLE): create the order, then its lines, then pass order and omit amount_cents — the server sums quantity × the products table's unitPrice (plus the order's own pricedItem, e.g. shipping), writes the total and charges it; never compute, write or send a total (if amount_cents is sent it must equal the total; refused, not retryable: ORDER_LINES_INVALID when the lines cannot be priced, ORDER_TOTAL_INVALID when the total is zero, ORDER_AMOUNT_MISMATCH when amount_cents differs; ORDER_NOT_PAYABLE also when the payer could write or create a price). Once priced, the order's lines are fixed (adding or removing one: ORDER_LOCKED); host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2520
|
+
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column the server prices (orderTotal: { lines, via } in the datastoreTemplate; without one: ORDER_NOT_PAYABLE): create the order, then its lines, then pass order and omit amount_cents — the server sums quantity × the products table's unitPrice (plus the order's own pricedItem, e.g. shipping), writes the total and charges it; never compute, write or send a total (if amount_cents is sent it must equal the total; refused, not retryable: ORDER_LINES_INVALID when the lines cannot be priced, ORDER_TOTAL_INVALID when the total is zero, ORDER_AMOUNT_MISMATCH when amount_cents differs; ORDER_NOT_PAYABLE also when the payer could write or create a price; OUT_OF_STOCK, naming the product, when a product's stockQuantity cannot cover the order — show it sold out and let the buyer start a new order without it). Once priced, the order's lines are fixed (adding or removing one: ORDER_LOCKED); host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2521
2521
|
getPayment:
|
|
2522
2522
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2523
2523
|
requestGuestPayment:
|
|
@@ -4390,7 +4390,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4390
4390
|
type: "object",
|
|
4391
4391
|
required: false,
|
|
4392
4392
|
description:
|
|
4393
|
-
"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). 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.",
|
|
4393
|
+
"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.",
|
|
4394
4394
|
},
|
|
4395
4395
|
translations: {
|
|
4396
4396
|
type: "object",
|
|
@@ -7202,7 +7202,10 @@ const CONTRACT = deepFreeze({
|
|
|
7202
7202
|
// draw is the publish-blocking `button-unknown-variant` finding.
|
|
7203
7203
|
// 1.291.0: behaviour (sc-18689) — a vertical native `ScrollView`, `FlatList`
|
|
7204
7204
|
// or `SectionList` sets `nestedScrollEnabled` unless inverted or the author sets it.
|
|
7205
|
-
|
|
7205
|
+
// 1.292.0: additive (sc-18009) — a template column may declare
|
|
7206
|
+
// `stockQuantity: true`; a charge reserves stock and refuses with the new
|
|
7207
|
+
// PaymentError code OUT_OF_STOCK when a product cannot cover the order.
|
|
7208
|
+
version: "1.292.0",
|
|
7206
7209
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7207
7210
|
hooks: HOOKS,
|
|
7208
7211
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -2512,7 +2512,7 @@ const HOOKS = [
|
|
|
2512
2512
|
signature: "usePayments()",
|
|
2513
2513
|
returnShape: {
|
|
2514
2514
|
requestPayment:
|
|
2515
|
-
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column the server prices (orderTotal: { lines, via } in the datastoreTemplate; without one: ORDER_NOT_PAYABLE): create the order, then its lines, then pass order and omit amount_cents — the server sums quantity × the products table's unitPrice (plus the order's own pricedItem, e.g. shipping), writes the total and charges it; never compute, write or send a total (if amount_cents is sent it must equal the total; refused, not retryable: ORDER_LINES_INVALID when the lines cannot be priced, ORDER_TOTAL_INVALID when the total is zero, ORDER_AMOUNT_MISMATCH when amount_cents differs; ORDER_NOT_PAYABLE also when the payer could write or create a price). Once priced, the order's lines are fixed (adding or removing one: ORDER_LOCKED); host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2515
|
+
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column the server prices (orderTotal: { lines, via } in the datastoreTemplate; without one: ORDER_NOT_PAYABLE): create the order, then its lines, then pass order and omit amount_cents — the server sums quantity × the products table's unitPrice (plus the order's own pricedItem, e.g. shipping), writes the total and charges it; never compute, write or send a total (if amount_cents is sent it must equal the total; refused, not retryable: ORDER_LINES_INVALID when the lines cannot be priced, ORDER_TOTAL_INVALID when the total is zero, ORDER_AMOUNT_MISMATCH when amount_cents differs; ORDER_NOT_PAYABLE also when the payer could write or create a price; OUT_OF_STOCK, naming the product, when a product's stockQuantity cannot cover the order — show it sold out and let the buyer start a new order without it). Once priced, the order's lines are fixed (adding or removing one: ORDER_LOCKED); host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2516
2516
|
getPayment:
|
|
2517
2517
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2518
2518
|
requestGuestPayment:
|
|
@@ -4385,7 +4385,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4385
4385
|
type: "object",
|
|
4386
4386
|
required: false,
|
|
4387
4387
|
description:
|
|
4388
|
-
"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). 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.",
|
|
4388
|
+
"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.",
|
|
4389
4389
|
},
|
|
4390
4390
|
translations: {
|
|
4391
4391
|
type: "object",
|
|
@@ -7197,7 +7197,10 @@ const CONTRACT = deepFreeze({
|
|
|
7197
7197
|
// draw is the publish-blocking `button-unknown-variant` finding.
|
|
7198
7198
|
// 1.291.0: behaviour (sc-18689) — a vertical native `ScrollView`, `FlatList`
|
|
7199
7199
|
// or `SectionList` sets `nestedScrollEnabled` unless inverted or the author sets it.
|
|
7200
|
-
|
|
7200
|
+
// 1.292.0: additive (sc-18009) — a template column may declare
|
|
7201
|
+
// `stockQuantity: true`; a charge reserves stock and refuses with the new
|
|
7202
|
+
// PaymentError code OUT_OF_STOCK when a product cannot cover the order.
|
|
7203
|
+
version: "1.292.0",
|
|
7201
7204
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7202
7205
|
hooks: HOOKS,
|
|
7203
7206
|
primitives: PRIMITIVES,
|
package/dist/hooks.js
CHANGED
|
@@ -7514,6 +7514,7 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7514
7514
|
"ORDER_LINES_INVALID",
|
|
7515
7515
|
"ORDER_NOT_PAYABLE",
|
|
7516
7516
|
"ORDER_TOTAL_INVALID",
|
|
7517
|
+
"OUT_OF_STOCK",
|
|
7517
7518
|
"PAYMENTS_DISABLED",
|
|
7518
7519
|
"PAYMENTS_SCOPE_NOT_GRANTED",
|
|
7519
7520
|
"PAYMENTS_UNAVAILABLE",
|
|
@@ -7552,6 +7553,9 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7552
7553
|
* - "ORDER_LINES_INVALID" — the server cannot price the order's lines
|
|
7553
7554
|
* (none, a gone or unpriced product, a
|
|
7554
7555
|
* quantity outside 1–999, over 100 lines)
|
|
7556
|
+
* - "OUT_OF_STOCK" — a product's stock cannot cover the order;
|
|
7557
|
+
* the message names it. Start a new order
|
|
7558
|
+
* without it (a priced order's lines are fixed)
|
|
7555
7559
|
* - "BUYER_EMAIL_INVALID" — a guest's order has no valid email in
|
|
7556
7560
|
* its buyer-email column; the receipt needs one
|
|
7557
7561
|
* - "ORDER_PAYMENT_IN_PROGRESS" — another checkout for the order is open
|
package/dist/index.d.ts
CHANGED
|
@@ -309,6 +309,15 @@ export interface WidgetDatastoreTemplateColumn {
|
|
|
309
309
|
pricedItem?: boolean;
|
|
310
310
|
/** NUMBER only, `immutable: true`, one per table: a line's quantity, 1 to 999 (empty is 1). */
|
|
311
311
|
lineQuantity?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* NUMBER only, one per table, in a table with a `unitPrice`, NOT immutable:
|
|
314
|
+
* how many of a product are left (a whole number, 0 or more; empty is not
|
|
315
|
+
* counted). The server takes an order's quantities when its charge opens
|
|
316
|
+
* and gives them back once its provider reports it failed, cancelled or
|
|
317
|
+
* expired; a refund does not restock. It is what is available: items in
|
|
318
|
+
* checkouts in progress are already taken off. Read it to show a product as sold out; never write it.
|
|
319
|
+
*/
|
|
320
|
+
stockQuantity?: boolean;
|
|
312
321
|
/**
|
|
313
322
|
* STRING only, at most one per table, in a table with a `paymentStatus`
|
|
314
323
|
* column, and it must be `immutable: true` (not encrypted, `latestVia` or
|
|
@@ -1683,7 +1692,8 @@ export interface PaymentRequest {
|
|
|
1683
1692
|
* order from its lines and charges that: ORDER_LINES_INVALID when it cannot,
|
|
1684
1693
|
* ORDER_TOTAL_INVALID when the total is zero, and ORDER_AMOUNT_MISMATCH when
|
|
1685
1694
|
* `amount_cents` differs from it. Once priced, adding or removing a line is
|
|
1686
|
-
* refused with ORDER_LOCKED.
|
|
1695
|
+
* refused with ORDER_LOCKED. OUT_OF_STOCK when a product's `stockQuantity`
|
|
1696
|
+
* cannot cover the order; its message names the product.
|
|
1687
1697
|
*/
|
|
1688
1698
|
order?: PaymentOrder;
|
|
1689
1699
|
}
|
|
@@ -1860,6 +1870,7 @@ export class PaymentError extends Error {
|
|
|
1860
1870
|
| "ORDER_TOTAL_INVALID"
|
|
1861
1871
|
| "ORDER_AMOUNT_MISMATCH"
|
|
1862
1872
|
| "ORDER_LINES_INVALID"
|
|
1873
|
+
| "OUT_OF_STOCK"
|
|
1863
1874
|
| "BUYER_EMAIL_INVALID"
|
|
1864
1875
|
| "ORDER_PAYMENT_IN_PROGRESS"
|
|
1865
1876
|
| "ALREADY_OWNED"
|
package/dist/linter.cjs
CHANGED
|
@@ -2012,7 +2012,14 @@ const MEMBER_CALL_RE = /(?<![\w$.])([\w$]+)\s*\.\s*([\w$]+)\s*\(/g;
|
|
|
2012
2012
|
|
|
2013
2013
|
/** date-fns formatter names and namespaces, and the locale objects it was given. */
|
|
2014
2014
|
function _dateFnsImports(strings) {
|
|
2015
|
-
const imports = {
|
|
2015
|
+
const imports = {
|
|
2016
|
+
formatters: new Map(),
|
|
2017
|
+
namespaces: new Set(),
|
|
2018
|
+
locales: new Set(),
|
|
2019
|
+
localeNamespaces: new Set(),
|
|
2020
|
+
defaultSetters: new Set(),
|
|
2021
|
+
defaultAppLocale: false,
|
|
2022
|
+
};
|
|
2016
2023
|
for (const [, ns, deflt, named, , subpath = ""] of strings.matchAll(DATE_FNS_IMPORT_RE)) {
|
|
2017
2024
|
if (subpath.startsWith("/locale")) {
|
|
2018
2025
|
if (ns) imports.localeNamespaces.add(ns);
|
|
@@ -2025,9 +2032,11 @@ function _dateFnsImports(strings) {
|
|
|
2025
2032
|
}
|
|
2026
2033
|
if (ns && !subpath) imports.namespaces.add(ns);
|
|
2027
2034
|
if (deflt && DATE_FNS_FORMATTERS.has(subpath.slice(1))) imports.formatters.set(deflt, DATE_FNS_FORMATTERS.get(subpath.slice(1)));
|
|
2035
|
+
if (deflt && subpath === "/setDefaultOptions") imports.defaultSetters.add(deflt);
|
|
2028
2036
|
for (const spec of (named || "").split(",")) {
|
|
2029
2037
|
const [imported, local] = spec.trim().split(/\s+as\s+/);
|
|
2030
2038
|
if (DATE_FNS_FORMATTERS.has(imported)) imports.formatters.set(local || imported, DATE_FNS_FORMATTERS.get(imported));
|
|
2039
|
+
if (imported === "setDefaultOptions") imports.defaultSetters.add(local || imported);
|
|
2031
2040
|
}
|
|
2032
2041
|
}
|
|
2033
2042
|
return imports;
|
|
@@ -2051,12 +2060,16 @@ function _callArgs(code, openParen) {
|
|
|
2051
2060
|
|
|
2052
2061
|
const _stringLiteral = (text) => /^\s*(["'`])((?:(?!\1)[^$\\]){1,80})\1/.exec(text)?.[2] ?? null;
|
|
2053
2062
|
|
|
2054
|
-
/**
|
|
2063
|
+
/**
|
|
2064
|
+
* True when the options may carry a locale that is not one fixed date-fns locale:
|
|
2065
|
+
* named in them, in an object held elsewhere or spread in, or set by setDefaultOptions.
|
|
2066
|
+
*/
|
|
2055
2067
|
function _appLocaleOption(options, imports) {
|
|
2056
2068
|
const m = LOCALE_OPTION_RE.exec(options);
|
|
2057
|
-
if (
|
|
2058
|
-
|
|
2059
|
-
|
|
2069
|
+
if (m) return !m[1] || !(imports.locales.has(m[1]) || (imports.localeNamespaces.has(m[1]) && m[2]));
|
|
2070
|
+
const literal = options.trimStart();
|
|
2071
|
+
if (literal && (!literal.startsWith("{") || literal.includes("..."))) return true;
|
|
2072
|
+
return imports.defaultAppLocale;
|
|
2060
2073
|
}
|
|
2061
2074
|
|
|
2062
2075
|
/** A date-fns pattern that prints words without the app's locale, or a day and month not year-first. */
|
|
@@ -2102,6 +2115,20 @@ function _fixedDateFormatRules(source) {
|
|
|
2102
2115
|
const options = starts.length > patternArg + 1 ? code.slice(starts[patternArg + 1], end) : "";
|
|
2103
2116
|
if (pattern && _fixedDatePattern(pattern, _appLocaleOption(options, imports))) report(m.index, `pattern "${pattern}"`);
|
|
2104
2117
|
};
|
|
2118
|
+
const setsAppLocale = (m) => {
|
|
2119
|
+
const { starts, end } = _callArgs(code, m.index + m[0].length - 1);
|
|
2120
|
+
return _appLocaleOption(code.slice(starts[0], end), imports);
|
|
2121
|
+
};
|
|
2122
|
+
if (imports.defaultSetters.size > 0) {
|
|
2123
|
+
for (const m of code.matchAll(CALL_RE)) {
|
|
2124
|
+
if (imports.defaultSetters.has(m[1]) && setsAppLocale(m)) imports.defaultAppLocale = true;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
if (imports.namespaces.size > 0) {
|
|
2128
|
+
for (const m of code.matchAll(MEMBER_CALL_RE)) {
|
|
2129
|
+
if (imports.namespaces.has(m[1]) && m[2] === "setDefaultOptions" && setsAppLocale(m)) imports.defaultAppLocale = true;
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2105
2132
|
if (imports.formatters.size > 0) {
|
|
2106
2133
|
for (const m of code.matchAll(CALL_RE)) {
|
|
2107
2134
|
if (imports.formatters.has(m[1])) checkCall(m, imports.formatters.get(m[1]));
|
package/dist/linter.js
CHANGED
|
@@ -2007,7 +2007,14 @@ const MEMBER_CALL_RE = /(?<![\w$.])([\w$]+)\s*\.\s*([\w$]+)\s*\(/g;
|
|
|
2007
2007
|
|
|
2008
2008
|
/** date-fns formatter names and namespaces, and the locale objects it was given. */
|
|
2009
2009
|
function _dateFnsImports(strings) {
|
|
2010
|
-
const imports = {
|
|
2010
|
+
const imports = {
|
|
2011
|
+
formatters: new Map(),
|
|
2012
|
+
namespaces: new Set(),
|
|
2013
|
+
locales: new Set(),
|
|
2014
|
+
localeNamespaces: new Set(),
|
|
2015
|
+
defaultSetters: new Set(),
|
|
2016
|
+
defaultAppLocale: false,
|
|
2017
|
+
};
|
|
2011
2018
|
for (const [, ns, deflt, named, , subpath = ""] of strings.matchAll(DATE_FNS_IMPORT_RE)) {
|
|
2012
2019
|
if (subpath.startsWith("/locale")) {
|
|
2013
2020
|
if (ns) imports.localeNamespaces.add(ns);
|
|
@@ -2020,9 +2027,11 @@ function _dateFnsImports(strings) {
|
|
|
2020
2027
|
}
|
|
2021
2028
|
if (ns && !subpath) imports.namespaces.add(ns);
|
|
2022
2029
|
if (deflt && DATE_FNS_FORMATTERS.has(subpath.slice(1))) imports.formatters.set(deflt, DATE_FNS_FORMATTERS.get(subpath.slice(1)));
|
|
2030
|
+
if (deflt && subpath === "/setDefaultOptions") imports.defaultSetters.add(deflt);
|
|
2023
2031
|
for (const spec of (named || "").split(",")) {
|
|
2024
2032
|
const [imported, local] = spec.trim().split(/\s+as\s+/);
|
|
2025
2033
|
if (DATE_FNS_FORMATTERS.has(imported)) imports.formatters.set(local || imported, DATE_FNS_FORMATTERS.get(imported));
|
|
2034
|
+
if (imported === "setDefaultOptions") imports.defaultSetters.add(local || imported);
|
|
2026
2035
|
}
|
|
2027
2036
|
}
|
|
2028
2037
|
return imports;
|
|
@@ -2046,12 +2055,16 @@ function _callArgs(code, openParen) {
|
|
|
2046
2055
|
|
|
2047
2056
|
const _stringLiteral = (text) => /^\s*(["'`])((?:(?!\1)[^$\\]){1,80})\1/.exec(text)?.[2] ?? null;
|
|
2048
2057
|
|
|
2049
|
-
/**
|
|
2058
|
+
/**
|
|
2059
|
+
* True when the options may carry a locale that is not one fixed date-fns locale:
|
|
2060
|
+
* named in them, in an object held elsewhere or spread in, or set by setDefaultOptions.
|
|
2061
|
+
*/
|
|
2050
2062
|
function _appLocaleOption(options, imports) {
|
|
2051
2063
|
const m = LOCALE_OPTION_RE.exec(options);
|
|
2052
|
-
if (
|
|
2053
|
-
|
|
2054
|
-
|
|
2064
|
+
if (m) return !m[1] || !(imports.locales.has(m[1]) || (imports.localeNamespaces.has(m[1]) && m[2]));
|
|
2065
|
+
const literal = options.trimStart();
|
|
2066
|
+
if (literal && (!literal.startsWith("{") || literal.includes("..."))) return true;
|
|
2067
|
+
return imports.defaultAppLocale;
|
|
2055
2068
|
}
|
|
2056
2069
|
|
|
2057
2070
|
/** A date-fns pattern that prints words without the app's locale, or a day and month not year-first. */
|
|
@@ -2097,6 +2110,20 @@ function _fixedDateFormatRules(source) {
|
|
|
2097
2110
|
const options = starts.length > patternArg + 1 ? code.slice(starts[patternArg + 1], end) : "";
|
|
2098
2111
|
if (pattern && _fixedDatePattern(pattern, _appLocaleOption(options, imports))) report(m.index, `pattern "${pattern}"`);
|
|
2099
2112
|
};
|
|
2113
|
+
const setsAppLocale = (m) => {
|
|
2114
|
+
const { starts, end } = _callArgs(code, m.index + m[0].length - 1);
|
|
2115
|
+
return _appLocaleOption(code.slice(starts[0], end), imports);
|
|
2116
|
+
};
|
|
2117
|
+
if (imports.defaultSetters.size > 0) {
|
|
2118
|
+
for (const m of code.matchAll(CALL_RE)) {
|
|
2119
|
+
if (imports.defaultSetters.has(m[1]) && setsAppLocale(m)) imports.defaultAppLocale = true;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
if (imports.namespaces.size > 0) {
|
|
2123
|
+
for (const m of code.matchAll(MEMBER_CALL_RE)) {
|
|
2124
|
+
if (imports.namespaces.has(m[1]) && m[2] === "setDefaultOptions" && setsAppLocale(m)) imports.defaultAppLocale = true;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2100
2127
|
if (imports.formatters.size > 0) {
|
|
2101
2128
|
for (const m of code.matchAll(CALL_RE)) {
|
|
2102
2129
|
if (imports.formatters.has(m[1])) checkCall(m, imports.formatters.get(m[1]));
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -2512,7 +2512,7 @@ const HOOKS = [
|
|
|
2512
2512
|
signature: "usePayments()",
|
|
2513
2513
|
returnShape: {
|
|
2514
2514
|
requestPayment:
|
|
2515
|
-
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column the server prices (orderTotal: { lines, via } in the datastoreTemplate; without one: ORDER_NOT_PAYABLE): create the order, then its lines, then pass order and omit amount_cents — the server sums quantity × the products table's unitPrice (plus the order's own pricedItem, e.g. shipping), writes the total and charges it; never compute, write or send a total (if amount_cents is sent it must equal the total; refused, not retryable: ORDER_LINES_INVALID when the lines cannot be priced, ORDER_TOTAL_INVALID when the total is zero, ORDER_AMOUNT_MISMATCH when amount_cents differs; ORDER_NOT_PAYABLE also when the payer could write or create a price). Once priced, the order's lines are fixed (adding or removing one: ORDER_LOCKED); host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2515
|
+
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column the server prices (orderTotal: { lines, via } in the datastoreTemplate; without one: ORDER_NOT_PAYABLE): create the order, then its lines, then pass order and omit amount_cents — the server sums quantity × the products table's unitPrice (plus the order's own pricedItem, e.g. shipping), writes the total and charges it; never compute, write or send a total (if amount_cents is sent it must equal the total; refused, not retryable: ORDER_LINES_INVALID when the lines cannot be priced, ORDER_TOTAL_INVALID when the total is zero, ORDER_AMOUNT_MISMATCH when amount_cents differs; ORDER_NOT_PAYABLE also when the payer could write or create a price; OUT_OF_STOCK, naming the product, when a product's stockQuantity cannot cover the order — show it sold out and let the buyer start a new order without it). Once priced, the order's lines are fixed (adding or removing one: ORDER_LOCKED); host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2516
2516
|
getPayment:
|
|
2517
2517
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2518
2518
|
requestGuestPayment:
|
|
@@ -4385,7 +4385,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4385
4385
|
type: "object",
|
|
4386
4386
|
required: false,
|
|
4387
4387
|
description:
|
|
4388
|
-
"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). 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.",
|
|
4388
|
+
"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.",
|
|
4389
4389
|
},
|
|
4390
4390
|
translations: {
|
|
4391
4391
|
type: "object",
|
|
@@ -7197,7 +7197,10 @@ const CONTRACT = deepFreeze({
|
|
|
7197
7197
|
// draw is the publish-blocking `button-unknown-variant` finding.
|
|
7198
7198
|
// 1.291.0: behaviour (sc-18689) — a vertical native `ScrollView`, `FlatList`
|
|
7199
7199
|
// or `SectionList` sets `nestedScrollEnabled` unless inverted or the author sets it.
|
|
7200
|
-
|
|
7200
|
+
// 1.292.0: additive (sc-18009) — a template column may declare
|
|
7201
|
+
// `stockQuantity: true`; a charge reserves stock and refuses with the new
|
|
7202
|
+
// PaymentError code OUT_OF_STOCK when a product cannot cover the order.
|
|
7203
|
+
version: "1.292.0",
|
|
7201
7204
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7202
7205
|
hooks: HOOKS,
|
|
7203
7206
|
primitives: PRIMITIVES,
|