@colixsystems/widget-sdk 0.345.0 → 0.347.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 +18 -2
- package/dist/contract.cjs +13 -5
- package/dist/contract.js +13 -5
- package/dist/hooks.js +6 -0
- package/dist/index.d.ts +30 -2
- package/dist/linter.cjs +60 -11
- package/dist/linter.js +60 -11
- package/dist/popover-view.js +19 -3
- package/package.json +1 -1
- package/src/contract.js +13 -5
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ The data layer lives in **four separate domain-client packages**, each instantia
|
|
|
77
77
|
| **FILESTORE** (`ctx.filestore`) | `usePdfExport({ spaceType, folderId })` (optional: spaceType, folderId) | `{ openPdf, opening, canOpenPdf, exportToPdf, exporting, error, lastExported }` | `ctx.filestore.files.renderPdf` + `ctx.device.pdfViewer`, `ctx.filestore.files.exportPdf` — `files.write:*`. `openPdf(html, { fileName? })` renders the HTML to a PDF server-side and OPENS it (web: PDF tab; native: print / share sheet) without saving. `exportToPdf(html, { fileName?, folderId? })` renders it and saves it as a file (`application/pdf`). Same server-side renderer on web + native. |
|
|
78
78
|
| **PAYMENTS** (`ctx.payments`) | `useAccessPlans()` | `{ plans, loading, error, purchaseAvailable, purchase, cancel, refresh }` | `ctx.payments.{listAccessPlans,purchaseAccessPlan,cancelAccessPlan}` — `payments.charge:appUser`. Plans selling access to restricted pages; `purchase(planId)` names only the plan, the server sets price and group. A held plan's `member_since` is when the user became a member (first paid charge, else when access was granted). `purchaseAvailable` is `false` in an iOS / Android build (digital goods need store billing): show a visible not-available state. |
|
|
79
79
|
| **PAYMENTS** (`ctx.payments`) | `useAppSubscription()` | `{ subscription, loading, error, cancel, refresh }` | `ctx.payments.{getAppSubscription,cancelAppSubscription}` — `payments.charge:appUser`. The signed-in user's subscription to a paid app (`{ active, renews, access_ends_at, member_since }`); `cancel()` stops it renewing, and access runs to `access_ends_at`. `member_since` is when they became a subscriber. |
|
|
80
|
-
| **PAYMENTS** (`ctx.payments`) | `usePayments()` | `{ requestPayment, getPayment, requestGuestPayment, getGuestPayment }` | `ctx.payments.*` — `payments.charge:appUser`; guest checkout (`requestGuestPayment`, a visitor with no account buying physical goods for an order they created) also `payments.charge:guest`. `requestPayment` requires `kind` (`"physical"` \| `"service"` \| `"digital"`): what is sold. A call without it is a publish-blocking `payment-kind-required` finding. A `"digital"` charge is refused in an iOS or Android build (`DIGITAL_SALE_NEEDS_STORE_BILLING`). Selling an order (goods, a booking, a ticket)? Create
|
|
80
|
+
| **PAYMENTS** (`ctx.payments`) | `usePayments()` | `{ requestPayment, getPayment, requestGuestPayment, getGuestPayment }` | `ctx.payments.*` — `payments.charge:appUser`; guest checkout (`requestGuestPayment`, a visitor with no account buying physical goods for an order they created) also `payments.charge:guest`. `requestPayment` requires `kind` (`"physical"` \| `"service"` \| `"digital"`): what is sold. A call without it is a publish-blocking `payment-kind-required` finding. A `"digital"` charge is refused in an iOS or Android build (`DIGITAL_SALE_NEEDS_STORE_BILLING`). Selling an order (goods, a booking, a ticket)? The orders table needs a payment-status column AND an order-total column (a write-once NUMBER holding the total in minor units). Create the row with its total, then pass `order: { table_id, record_id }` and omit `amount_cents` (or send the same value): the server charges the stored total, and only the payment marks the order paid, so never write a paid status yourself (a `payment-status-written` finding). The server refuses an order it cannot settle with `ORDER_NOT_FOUND`, `ORDER_NOT_PAYABLE` (also: no order-total column), `ORDER_ALREADY_PAID`, `ORDER_TOTAL_INVALID` or `ORDER_AMOUNT_MISMATCH`, none retryable. Rejects with `PaymentError { code, message, retryable }`; when `retryable` is `false` show `message` and drop the retry. Charges are accepted ONLY in the currency the workspace sells in — omit `currency` and the platform applies it (a disagreeing literal is a publish-blocking `payment-currency` finding). |
|
|
81
81
|
| **NOTIFICATIONS** (`ctx.notifications`) | `useSendNotification()` | `{ send, sending, error }` | `ctx.notifications.send` — `notifications.send:appUser`. `send({ recipient_user_id, title, body, link?, payload? })` notifies one app user in the same workspace; call from an event handler (never render); rejects with `NotificationError`. |
|
|
82
82
|
| **NOTIFICATIONS** (`ctx.notifications`) | `useRecordMutes(tableId)` | `{ isMuted, loading, error, refetch }` | `ctx.notifications.mutes` — no scope. Which records of one table the signed-in user has muted, in one request for a whole list; `isMuted(recordId)` turns false when a timed mute lapses, and a `useRecordMute` write shows at once. |
|
|
83
83
|
| **NOTIFICATIONS** (`ctx.notifications`) | `useRecordMute(tableId, recordId)` | `{ muted, mutedUntil, loading, error, mute, unmute, refetch }` | `ctx.notifications.mutes` — no scope. Mutes one record's notifications for the signed-in user, `mute(until)` with an ISO time, a `Date`, or `null` for until unmuted. Needs read access to the record (`RECORD_NOT_FOUND` otherwise). |
|
|
@@ -91,7 +91,23 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
94
|
+
`v0.347.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.347.0 (contract 1.284.0)
|
|
97
|
+
|
|
98
|
+
**A charge for an order bills the order's own total.** A widget sent `amount_cents` beside `order`, so the amount charged was whatever the request said, unrelated to the order. An orders table with a payment-status column now REQUIRES one order-total column: a NUMBER column, write-once (`immutable: true`), holding the total in whole minor units of the workspace's charge currency (339 kr is `33900`; the column stores no currency). Create the order row with its total, then call `requestPayment({ description, kind, order: { table_id, record_id } })` (or `requestGuestPayment`) without `amount_cents`: the server reads the stored total and charges that. `amount_cents` is now optional when `order` is given; if you send it, it must equal the total. The total cannot change once the order is placed, and the order reads paid only when the full total settled. The total is still whatever the order's creator wrote, so compute it from prices the buyer cannot change where you can; server-side pricing is coming. A charge for an order in a table without an order-total column is refused with `ORDER_NOT_PAYABLE`, and a `datastoreTemplate` that declares `paymentStatus: true` without an `orderTotal: true` column (beside `immutable: true`) is refused when the widget is published (a template already published still installs). Two new non-retryable `PaymentError` codes: `ORDER_TOTAL_INVALID` (the order's total is empty, zero, negative or not a whole number) and `ORDER_AMOUNT_MISMATCH` (`amount_cents` differs from the total). An update to the total is ignored, so the new `order-total-updated` lint warning flags a charging widget whose `update` sets a total-looking key (`total`, `orderTotal`, `order_total`, …). A charge without `order` behaves as before.
|
|
99
|
+
|
|
100
|
+
### What's new in 0.346.0 (contract 1.283.0)
|
|
101
|
+
|
|
102
|
+
**A `<Popover>` can open a dialog of its own.** The `close` a popover hands its children now takes what to run next: `close(then)` closes the popover and runs `then` once it has left the screen. Open a dialog, a `<Modal>` or an `<EmojiPicker>` from a button inside the popover that way. iOS cannot show a dialog while another is still leaving the screen, so one opened in the same press that closed the popover never appeared there. The new `onDismiss` prop runs at the same moment after every close, the backdrop and Escape included. `<Menu>` already runs a picked item's `onPress` this way. Additive.
|
|
103
|
+
|
|
104
|
+
```jsx
|
|
105
|
+
<Popover trigger={trigger}>
|
|
106
|
+
{({ close }) => (
|
|
107
|
+
<Button title={t("more", "More")} onPress={() => close(() => setPickerOpen(true))} />
|
|
108
|
+
)}
|
|
109
|
+
</Popover>
|
|
110
|
+
```
|
|
95
111
|
|
|
96
112
|
### What's new in 0.345.0 (contract 1.282.0)
|
|
97
113
|
|
package/dist/contract.cjs
CHANGED
|
@@ -2504,11 +2504,11 @@ const HOOKS = [
|
|
|
2504
2504
|
signature: "usePayments()",
|
|
2505
2505
|
returnShape: {
|
|
2506
2506
|
requestPayment:
|
|
2507
|
-
"({ amount_cents
|
|
2507
|
+
"({ 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 (orderTotal; without one: ORDER_NOT_PAYABLE) and the server charges the total stored on the order: create the order with its total, then pass order and omit amount_cents (if sent it must equal the total; refused, not retryable: ORDER_TOTAL_INVALID when the total is empty, zero, negative or not whole, ORDER_AMOUNT_MISMATCH when amount_cents differs). The total is write-once but written by the order's creator, so compute it from prices the buyer cannot change; host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2508
2508
|
getPayment:
|
|
2509
2509
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2510
2510
|
requestGuestPayment:
|
|
2511
|
-
"({ amount_cents
|
|
2511
|
+
"({ amount_cents?, currency?, description, return_path?, order }) => Promise<{ id, status, order }> // a visitor who is NOT signed in buys physical goods (no kind). The orders table needs a payment-status AND an order-total column, as for requestPayment: create the order with its total and omit amount_cents (if sent it must equal the total). order is REQUIRED: create the order row first with useDatastoreMutation().create (the maker lets everyone add rows to the orders table and nobody read them; collect the shipping address and contact there), then pay for it within 15 minutes — only the visitor who created it can. Needs the payments.charge:guest scope too. The host runs a security check and opens hosted Checkout. Refused: TRIAL_RESTRICTED, GUEST_CHECKOUT_LIMIT_REACHED (retryable), CAPTCHA_FAILED / CAPTCHA_UNAVAILABLE (retryable), NOT_FOUND where the shop does not offer guest checkout, plus the requestPayment refusals",
|
|
2512
2512
|
getGuestPayment:
|
|
2513
2513
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // a guest's status read; the host holds the guest's one-time credential, so pass only the id",
|
|
2514
2514
|
},
|
|
@@ -4077,7 +4077,7 @@ const PRIMITIVES = [
|
|
|
4077
4077
|
{
|
|
4078
4078
|
name: "Popover",
|
|
4079
4079
|
description:
|
|
4080
|
-
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4080
|
+
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. A dialog or `<EmojiPicker>` opened from inside it waits until the popover has left the screen: call `close(() => setPickerOpen(true))`, or open it in `onDismiss`, which runs then too; opened in the same press that closes it, it fails to show on iOS. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `onDismiss`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4081
4081
|
rnComponent: null,
|
|
4082
4082
|
docsUrl: null,
|
|
4083
4083
|
},
|
|
@@ -4375,7 +4375,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4375
4375
|
type: "object",
|
|
4376
4376
|
required: false,
|
|
4377
4377
|
description:
|
|
4378
|
-
"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): 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. 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.",
|
|
4378
|
+
"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: true` 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 order's creator writes it on create and a later update is ignored; `requestPayment({ order })` then charges that stored total, so omit `amount_cents`. It fixes the total, not the price: compute it from prices the buyer cannot change. 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.",
|
|
4379
4379
|
},
|
|
4380
4380
|
translations: {
|
|
4381
4381
|
type: "object",
|
|
@@ -7156,7 +7156,15 @@ const CONTRACT = deepFreeze({
|
|
|
7156
7156
|
// 1.282.0: additive (sc-18485) — useAccessPlans() plans and
|
|
7157
7157
|
// useAppSubscription() subscription carry member_since, the member's start
|
|
7158
7158
|
// date: first paid charge, else when access was granted (null when not held).
|
|
7159
|
-
|
|
7159
|
+
// 1.283.0: additive (sc-17852) — `<Popover onDismiss>` and the children's
|
|
7160
|
+
// `close(then)` run once the closed popover has left the screen, so a
|
|
7161
|
+
// dialog it opens presents on iOS.
|
|
7162
|
+
// 1.284.0 (sc-15916): a `paymentStatus` table requires an `orderTotal: true`
|
|
7163
|
+
// column (an immutable NUMBER in minor units); a charge with `order` bills
|
|
7164
|
+
// that total, so `amount_cents` is optional with `order`. Breaking for an
|
|
7165
|
+
// order charge on a table without one (ORDER_NOT_PAYABLE). Two new
|
|
7166
|
+
// PaymentError codes and the `order-total-updated` warning.
|
|
7167
|
+
version: "1.284.0",
|
|
7160
7168
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7161
7169
|
hooks: HOOKS,
|
|
7162
7170
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -2499,11 +2499,11 @@ const HOOKS = [
|
|
|
2499
2499
|
signature: "usePayments()",
|
|
2500
2500
|
returnShape: {
|
|
2501
2501
|
requestPayment:
|
|
2502
|
-
"({ amount_cents
|
|
2502
|
+
"({ 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 (orderTotal; without one: ORDER_NOT_PAYABLE) and the server charges the total stored on the order: create the order with its total, then pass order and omit amount_cents (if sent it must equal the total; refused, not retryable: ORDER_TOTAL_INVALID when the total is empty, zero, negative or not whole, ORDER_AMOUNT_MISMATCH when amount_cents differs). The total is write-once but written by the order's creator, so compute it from prices the buyer cannot change; host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2503
2503
|
getPayment:
|
|
2504
2504
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2505
2505
|
requestGuestPayment:
|
|
2506
|
-
"({ amount_cents
|
|
2506
|
+
"({ amount_cents?, currency?, description, return_path?, order }) => Promise<{ id, status, order }> // a visitor who is NOT signed in buys physical goods (no kind). The orders table needs a payment-status AND an order-total column, as for requestPayment: create the order with its total and omit amount_cents (if sent it must equal the total). order is REQUIRED: create the order row first with useDatastoreMutation().create (the maker lets everyone add rows to the orders table and nobody read them; collect the shipping address and contact there), then pay for it within 15 minutes — only the visitor who created it can. Needs the payments.charge:guest scope too. The host runs a security check and opens hosted Checkout. Refused: TRIAL_RESTRICTED, GUEST_CHECKOUT_LIMIT_REACHED (retryable), CAPTCHA_FAILED / CAPTCHA_UNAVAILABLE (retryable), NOT_FOUND where the shop does not offer guest checkout, plus the requestPayment refusals",
|
|
2507
2507
|
getGuestPayment:
|
|
2508
2508
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // a guest's status read; the host holds the guest's one-time credential, so pass only the id",
|
|
2509
2509
|
},
|
|
@@ -4072,7 +4072,7 @@ const PRIMITIVES = [
|
|
|
4072
4072
|
{
|
|
4073
4073
|
name: "Popover",
|
|
4074
4074
|
description:
|
|
4075
|
-
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4075
|
+
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. A dialog or `<EmojiPicker>` opened from inside it waits until the popover has left the screen: call `close(() => setPickerOpen(true))`, or open it in `onDismiss`, which runs then too; opened in the same press that closes it, it fails to show on iOS. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `onDismiss`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4076
4076
|
rnComponent: null,
|
|
4077
4077
|
docsUrl: null,
|
|
4078
4078
|
},
|
|
@@ -4370,7 +4370,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4370
4370
|
type: "object",
|
|
4371
4371
|
required: false,
|
|
4372
4372
|
description:
|
|
4373
|
-
"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): 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. 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.",
|
|
4373
|
+
"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: true` 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 order's creator writes it on create and a later update is ignored; `requestPayment({ order })` then charges that stored total, so omit `amount_cents`. It fixes the total, not the price: compute it from prices the buyer cannot change. 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.",
|
|
4374
4374
|
},
|
|
4375
4375
|
translations: {
|
|
4376
4376
|
type: "object",
|
|
@@ -7151,7 +7151,15 @@ const CONTRACT = deepFreeze({
|
|
|
7151
7151
|
// 1.282.0: additive (sc-18485) — useAccessPlans() plans and
|
|
7152
7152
|
// useAppSubscription() subscription carry member_since, the member's start
|
|
7153
7153
|
// date: first paid charge, else when access was granted (null when not held).
|
|
7154
|
-
|
|
7154
|
+
// 1.283.0: additive (sc-17852) — `<Popover onDismiss>` and the children's
|
|
7155
|
+
// `close(then)` run once the closed popover has left the screen, so a
|
|
7156
|
+
// dialog it opens presents on iOS.
|
|
7157
|
+
// 1.284.0 (sc-15916): a `paymentStatus` table requires an `orderTotal: true`
|
|
7158
|
+
// column (an immutable NUMBER in minor units); a charge with `order` bills
|
|
7159
|
+
// that total, so `amount_cents` is optional with `order`. Breaking for an
|
|
7160
|
+
// order charge on a table without one (ORDER_NOT_PAYABLE). Two new
|
|
7161
|
+
// PaymentError codes and the `order-total-updated` warning.
|
|
7162
|
+
version: "1.284.0",
|
|
7155
7163
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7156
7164
|
hooks: HOOKS,
|
|
7157
7165
|
primitives: PRIMITIVES,
|
package/dist/hooks.js
CHANGED
|
@@ -7302,7 +7302,9 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7302
7302
|
"NOT_FOUND",
|
|
7303
7303
|
"ORDER_ALREADY_PAID",
|
|
7304
7304
|
"ORDER_NOT_FOUND",
|
|
7305
|
+
"ORDER_AMOUNT_MISMATCH",
|
|
7305
7306
|
"ORDER_NOT_PAYABLE",
|
|
7307
|
+
"ORDER_TOTAL_INVALID",
|
|
7306
7308
|
"PAYMENTS_DISABLED",
|
|
7307
7309
|
"PAYMENTS_SCOPE_NOT_GRANTED",
|
|
7308
7310
|
"PAYMENTS_UNAVAILABLE",
|
|
@@ -7334,6 +7336,10 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7334
7336
|
* build: store policy requires store billing
|
|
7335
7337
|
* - "ORDER_NOT_FOUND" / "ORDER_NOT_PAYABLE" / "ORDER_ALREADY_PAID" — the
|
|
7336
7338
|
* `order` is not one this user can pay for
|
|
7339
|
+
* - "ORDER_TOTAL_INVALID" — the order's total is empty, zero, negative
|
|
7340
|
+
* or not a whole number of minor units
|
|
7341
|
+
* - "ORDER_AMOUNT_MISMATCH" — `amount_cents` was sent and differs from
|
|
7342
|
+
* the order's total; omit it
|
|
7337
7343
|
* - "ORDER_PAYMENT_IN_PROGRESS" — another checkout for the order is open
|
|
7338
7344
|
* (retryable: it clears when that one ends)
|
|
7339
7345
|
* - "ALREADY_OWNED" — `useAccessPlans().purchase` for a plan the
|
package/dist/index.d.ts
CHANGED
|
@@ -281,6 +281,22 @@ export interface WidgetDatastoreTemplateColumn {
|
|
|
281
281
|
* `MANY_TO_MANY` relation, whose links live outside the row.
|
|
282
282
|
*/
|
|
283
283
|
immutable?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* STRING or BOOL only, at most one per table: the order's payment status.
|
|
286
|
+
* The table also needs an `orderTotal` column. A settled
|
|
287
|
+
* `requestPayment({ order })` writes it; every client value for it is
|
|
288
|
+
* ignored, so a buyer cannot mark their own order paid.
|
|
289
|
+
*/
|
|
290
|
+
paymentStatus?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* NUMBER only, required once in every table with a `paymentStatus` column
|
|
293
|
+
* (and only there), and it must be `immutable: true` (not encrypted,
|
|
294
|
+
* `latestVia` or `copyOf`). The order's total in integer minor units (339 kr
|
|
295
|
+
* is 33900) of the workspace's charge currency. The order's creator sets it
|
|
296
|
+
* on create, and `requestPayment({ order })` charges it, so omit
|
|
297
|
+
* `amount_cents`. Compute it from prices the buyer cannot change.
|
|
298
|
+
*/
|
|
299
|
+
orderTotal?: boolean;
|
|
284
300
|
/**
|
|
285
301
|
* ONE_TO_ONE / ONE_TO_MANY RELATION only, with `onDelete` left at
|
|
286
302
|
* `SET_NULL`: the server keeps this column pointing at the newest row of its
|
|
@@ -1614,7 +1630,12 @@ export function useWidgetInput(inputName: string): unknown;
|
|
|
1614
1630
|
* currency's minor unit; the app user confirms it in hosted Checkout.
|
|
1615
1631
|
*/
|
|
1616
1632
|
export interface PaymentRequest {
|
|
1617
|
-
|
|
1633
|
+
/**
|
|
1634
|
+
* Required without `order`. With `order` the server charges the order's
|
|
1635
|
+
* stored total: omit this, or send the same value (a different one is
|
|
1636
|
+
* refused with ORDER_AMOUNT_MISMATCH).
|
|
1637
|
+
*/
|
|
1638
|
+
amount_cents?: number;
|
|
1618
1639
|
currency?: string;
|
|
1619
1640
|
description: string;
|
|
1620
1641
|
/**
|
|
@@ -1636,6 +1657,10 @@ export interface PaymentRequest {
|
|
|
1636
1657
|
* column, so never write "paid" yourself; the platform ignores it anyway.
|
|
1637
1658
|
* Refused with ORDER_NOT_FOUND, ORDER_NOT_PAYABLE or ORDER_ALREADY_PAID, and
|
|
1638
1659
|
* with the retryable ORDER_PAYMENT_IN_PROGRESS while another checkout is open.
|
|
1660
|
+
* The table also needs an order-total column (ORDER_NOT_PAYABLE without
|
|
1661
|
+
* one), and the charge is the order's stored total: ORDER_TOTAL_INVALID when
|
|
1662
|
+
* it is empty, zero, negative or not whole, and ORDER_AMOUNT_MISMATCH when
|
|
1663
|
+
* `amount_cents` differs from it.
|
|
1639
1664
|
*/
|
|
1640
1665
|
order?: PaymentOrder;
|
|
1641
1666
|
}
|
|
@@ -1662,7 +1687,8 @@ export interface PaymentResult {
|
|
|
1662
1687
|
* `kind`: guest checkout sells physical goods only.
|
|
1663
1688
|
*/
|
|
1664
1689
|
export interface GuestPaymentRequest {
|
|
1665
|
-
|
|
1690
|
+
/** Optional: the server charges the order's stored total, as for `requestPayment`. */
|
|
1691
|
+
amount_cents?: number;
|
|
1666
1692
|
currency?: string;
|
|
1667
1693
|
description: string;
|
|
1668
1694
|
return_path?: string;
|
|
@@ -1807,6 +1833,8 @@ export class PaymentError extends Error {
|
|
|
1807
1833
|
| "ORDER_NOT_FOUND"
|
|
1808
1834
|
| "ORDER_NOT_PAYABLE"
|
|
1809
1835
|
| "ORDER_ALREADY_PAID"
|
|
1836
|
+
| "ORDER_TOTAL_INVALID"
|
|
1837
|
+
| "ORDER_AMOUNT_MISMATCH"
|
|
1810
1838
|
| "ORDER_PAYMENT_IN_PROGRESS"
|
|
1811
1839
|
| "ALREADY_OWNED"
|
|
1812
1840
|
| "PURCHASE_IN_PROGRESS"
|
package/dist/linter.cjs
CHANGED
|
@@ -1678,8 +1678,8 @@ const _PAID_WRITE_RES = [
|
|
|
1678
1678
|
/:\s*(['"`])paid\1/gi,
|
|
1679
1679
|
];
|
|
1680
1680
|
|
|
1681
|
-
/** Local names the widget's
|
|
1682
|
-
function _writeCallees(code) {
|
|
1681
|
+
/** Local names the widget's `methods` calls go through, and named mutation objects. */
|
|
1682
|
+
function _writeCallees(code, methods) {
|
|
1683
1683
|
const verbs = [];
|
|
1684
1684
|
const objects = [];
|
|
1685
1685
|
for (const call of _mutationHookCalls(code)) {
|
|
@@ -1689,12 +1689,25 @@ function _writeCallees(code) {
|
|
|
1689
1689
|
}
|
|
1690
1690
|
for (const entry of call.destructured.split(",")) {
|
|
1691
1691
|
const [key, local] = entry.split(":").map((part) => part.trim());
|
|
1692
|
-
if (
|
|
1692
|
+
if (methods.has(key)) verbs.push(local || key);
|
|
1693
1693
|
}
|
|
1694
1694
|
}
|
|
1695
1695
|
return { verbs, objects };
|
|
1696
1696
|
}
|
|
1697
1697
|
|
|
1698
|
+
/** Matches the widget's own mutation calls of `methods` up to their `(`, or null when it makes none. */
|
|
1699
|
+
function _mutationCallRe(masked, methods) {
|
|
1700
|
+
const { verbs, objects } = _writeCallees(masked, methods);
|
|
1701
|
+
const escape = (name) => name.replace(/\$/g, "\\$");
|
|
1702
|
+
const methodAlt = [...methods].join("|");
|
|
1703
|
+
const callees = [
|
|
1704
|
+
...verbs.map((v) => `(?<![\\w$.])${escape(v)}`),
|
|
1705
|
+
...objects.map((o) => `(?<![\\w$])${escape(o)}\\s*\\.\\s*(?:${methodAlt})`),
|
|
1706
|
+
];
|
|
1707
|
+
if (callees.length === 0) return null;
|
|
1708
|
+
return new RegExp(`(?:${callees.join("|")})\\s*\\(`, "g");
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1698
1711
|
/** Index of the parenthesis closing the one opening at `open`, or -1. */
|
|
1699
1712
|
function _closingParen(masked, open) {
|
|
1700
1713
|
let depth = 0;
|
|
@@ -1710,19 +1723,14 @@ function _closingParen(masked, open) {
|
|
|
1710
1723
|
function _paymentStatusWrittenRules(source) {
|
|
1711
1724
|
const masked = _stripNonCode(source);
|
|
1712
1725
|
if (!PAYMENT_CHARGE_CALL_RE.test(masked)) return [];
|
|
1713
|
-
const
|
|
1714
|
-
|
|
1715
|
-
const callees = [
|
|
1716
|
-
...verbs.map((v) => `(?<![\\w$.])${escape(v)}`),
|
|
1717
|
-
...objects.map((o) => `(?<![\\w$])${escape(o)}\\s*\\.\\s*(?:create|update)`),
|
|
1718
|
-
];
|
|
1719
|
-
if (callees.length === 0) return [];
|
|
1726
|
+
const writeCall = _mutationCallRe(masked, _WRITE_VERBS);
|
|
1727
|
+
if (!writeCall) return [];
|
|
1720
1728
|
const kept = _stripNonCode(source, { keepStrings: true });
|
|
1721
1729
|
const sourceLines = source.split(/\r?\n/);
|
|
1722
1730
|
const lineAt = _lineCounter(masked);
|
|
1723
1731
|
const findings = [];
|
|
1724
1732
|
const reported = new Set();
|
|
1725
|
-
for (const call of masked.matchAll(
|
|
1733
|
+
for (const call of masked.matchAll(writeCall)) {
|
|
1726
1734
|
const open = call.index + call[0].length - 1;
|
|
1727
1735
|
const close = _closingParen(masked, open);
|
|
1728
1736
|
if (close === -1) continue;
|
|
@@ -1749,6 +1757,46 @@ function _paymentStatusWrittenRules(source) {
|
|
|
1749
1757
|
return findings;
|
|
1750
1758
|
}
|
|
1751
1759
|
|
|
1760
|
+
// sc-15916 — order-total-updated.
|
|
1761
|
+
//
|
|
1762
|
+
// An order-total column is write-once and a charge with `order` bills the
|
|
1763
|
+
// total stored on the order. An update setting it is silently ignored, so the
|
|
1764
|
+
// widget believes it changed the price and the buyer is charged the old one.
|
|
1765
|
+
// A warning: the scan matches the key's name, not the workspace's column.
|
|
1766
|
+
const _UPDATE_VERB = new Set(["update"]);
|
|
1767
|
+
const _ORDER_TOTAL_KEY_RE = /(?<![\w$])(['"]?)(?:order_?)?total(?:_?(?:cents|minor))?\1\s*:/i;
|
|
1768
|
+
|
|
1769
|
+
function _orderTotalUpdatedRules(source) {
|
|
1770
|
+
const masked = _stripNonCode(source);
|
|
1771
|
+
if (!PAYMENT_CHARGE_CALL_RE.test(masked)) return [];
|
|
1772
|
+
const updateCall = _mutationCallRe(masked, _UPDATE_VERB);
|
|
1773
|
+
if (!updateCall) return [];
|
|
1774
|
+
const kept = _stripNonCode(source, { keepStrings: true });
|
|
1775
|
+
const sourceLines = source.split(/\r?\n/);
|
|
1776
|
+
const lineAt = _lineCounter(masked);
|
|
1777
|
+
const findings = [];
|
|
1778
|
+
for (const call of masked.matchAll(updateCall)) {
|
|
1779
|
+
const open = call.index + call[0].length - 1;
|
|
1780
|
+
const close = _closingParen(masked, open);
|
|
1781
|
+
if (close === -1) continue;
|
|
1782
|
+
const hit = _ORDER_TOTAL_KEY_RE.exec(kept.slice(open, close));
|
|
1783
|
+
if (!hit) continue;
|
|
1784
|
+
const line = lineAt(open + hit.index);
|
|
1785
|
+
findings.push({
|
|
1786
|
+
rule: "order-total-updated",
|
|
1787
|
+
severity: "warning",
|
|
1788
|
+
label:
|
|
1789
|
+
`the order total is write-once, so this update is ignored and the ` +
|
|
1790
|
+
`charge bills the stored total. Set the total when you create the ` +
|
|
1791
|
+
`order, then pass order: { table_id, record_id } to requestPayment ` +
|
|
1792
|
+
`and omit amount_cents.`,
|
|
1793
|
+
line,
|
|
1794
|
+
snippet: (sourceLines[line - 1] || "").trim().slice(0, 200),
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
return findings;
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1752
1800
|
// sc-4686 — no-hardcoded-currency-label.
|
|
1753
1801
|
//
|
|
1754
1802
|
// The charge is safe once `currency` is omitted, but the DISPLAY is not: a "kr"
|
|
@@ -4779,6 +4827,7 @@ function lintSource(source, options) {
|
|
|
4779
4827
|
findings.push(..._paymentCurrencyRules(source));
|
|
4780
4828
|
findings.push(..._paymentKindRules(source));
|
|
4781
4829
|
findings.push(..._paymentStatusWrittenRules(source));
|
|
4830
|
+
findings.push(..._orderTotalUpdatedRules(source));
|
|
4782
4831
|
findings.push(..._hardcodedCurrencyLabelRules(source));
|
|
4783
4832
|
findings.push(..._fixedDateFormatRules(source));
|
|
4784
4833
|
findings.push(..._paymentErrorHandlingRules(source));
|
package/dist/linter.js
CHANGED
|
@@ -1673,8 +1673,8 @@ const _PAID_WRITE_RES = [
|
|
|
1673
1673
|
/:\s*(['"`])paid\1/gi,
|
|
1674
1674
|
];
|
|
1675
1675
|
|
|
1676
|
-
/** Local names the widget's
|
|
1677
|
-
function _writeCallees(code) {
|
|
1676
|
+
/** Local names the widget's `methods` calls go through, and named mutation objects. */
|
|
1677
|
+
function _writeCallees(code, methods) {
|
|
1678
1678
|
const verbs = [];
|
|
1679
1679
|
const objects = [];
|
|
1680
1680
|
for (const call of _mutationHookCalls(code)) {
|
|
@@ -1684,12 +1684,25 @@ function _writeCallees(code) {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
for (const entry of call.destructured.split(",")) {
|
|
1686
1686
|
const [key, local] = entry.split(":").map((part) => part.trim());
|
|
1687
|
-
if (
|
|
1687
|
+
if (methods.has(key)) verbs.push(local || key);
|
|
1688
1688
|
}
|
|
1689
1689
|
}
|
|
1690
1690
|
return { verbs, objects };
|
|
1691
1691
|
}
|
|
1692
1692
|
|
|
1693
|
+
/** Matches the widget's own mutation calls of `methods` up to their `(`, or null when it makes none. */
|
|
1694
|
+
function _mutationCallRe(masked, methods) {
|
|
1695
|
+
const { verbs, objects } = _writeCallees(masked, methods);
|
|
1696
|
+
const escape = (name) => name.replace(/\$/g, "\\$");
|
|
1697
|
+
const methodAlt = [...methods].join("|");
|
|
1698
|
+
const callees = [
|
|
1699
|
+
...verbs.map((v) => `(?<![\\w$.])${escape(v)}`),
|
|
1700
|
+
...objects.map((o) => `(?<![\\w$])${escape(o)}\\s*\\.\\s*(?:${methodAlt})`),
|
|
1701
|
+
];
|
|
1702
|
+
if (callees.length === 0) return null;
|
|
1703
|
+
return new RegExp(`(?:${callees.join("|")})\\s*\\(`, "g");
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1693
1706
|
/** Index of the parenthesis closing the one opening at `open`, or -1. */
|
|
1694
1707
|
function _closingParen(masked, open) {
|
|
1695
1708
|
let depth = 0;
|
|
@@ -1705,19 +1718,14 @@ function _closingParen(masked, open) {
|
|
|
1705
1718
|
function _paymentStatusWrittenRules(source) {
|
|
1706
1719
|
const masked = _stripNonCode(source);
|
|
1707
1720
|
if (!PAYMENT_CHARGE_CALL_RE.test(masked)) return [];
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1710
|
-
const callees = [
|
|
1711
|
-
...verbs.map((v) => `(?<![\\w$.])${escape(v)}`),
|
|
1712
|
-
...objects.map((o) => `(?<![\\w$])${escape(o)}\\s*\\.\\s*(?:create|update)`),
|
|
1713
|
-
];
|
|
1714
|
-
if (callees.length === 0) return [];
|
|
1721
|
+
const writeCall = _mutationCallRe(masked, _WRITE_VERBS);
|
|
1722
|
+
if (!writeCall) return [];
|
|
1715
1723
|
const kept = _stripNonCode(source, { keepStrings: true });
|
|
1716
1724
|
const sourceLines = source.split(/\r?\n/);
|
|
1717
1725
|
const lineAt = _lineCounter(masked);
|
|
1718
1726
|
const findings = [];
|
|
1719
1727
|
const reported = new Set();
|
|
1720
|
-
for (const call of masked.matchAll(
|
|
1728
|
+
for (const call of masked.matchAll(writeCall)) {
|
|
1721
1729
|
const open = call.index + call[0].length - 1;
|
|
1722
1730
|
const close = _closingParen(masked, open);
|
|
1723
1731
|
if (close === -1) continue;
|
|
@@ -1744,6 +1752,46 @@ function _paymentStatusWrittenRules(source) {
|
|
|
1744
1752
|
return findings;
|
|
1745
1753
|
}
|
|
1746
1754
|
|
|
1755
|
+
// sc-15916 — order-total-updated.
|
|
1756
|
+
//
|
|
1757
|
+
// An order-total column is write-once and a charge with `order` bills the
|
|
1758
|
+
// total stored on the order. An update setting it is silently ignored, so the
|
|
1759
|
+
// widget believes it changed the price and the buyer is charged the old one.
|
|
1760
|
+
// A warning: the scan matches the key's name, not the workspace's column.
|
|
1761
|
+
const _UPDATE_VERB = new Set(["update"]);
|
|
1762
|
+
const _ORDER_TOTAL_KEY_RE = /(?<![\w$])(['"]?)(?:order_?)?total(?:_?(?:cents|minor))?\1\s*:/i;
|
|
1763
|
+
|
|
1764
|
+
function _orderTotalUpdatedRules(source) {
|
|
1765
|
+
const masked = _stripNonCode(source);
|
|
1766
|
+
if (!PAYMENT_CHARGE_CALL_RE.test(masked)) return [];
|
|
1767
|
+
const updateCall = _mutationCallRe(masked, _UPDATE_VERB);
|
|
1768
|
+
if (!updateCall) return [];
|
|
1769
|
+
const kept = _stripNonCode(source, { keepStrings: true });
|
|
1770
|
+
const sourceLines = source.split(/\r?\n/);
|
|
1771
|
+
const lineAt = _lineCounter(masked);
|
|
1772
|
+
const findings = [];
|
|
1773
|
+
for (const call of masked.matchAll(updateCall)) {
|
|
1774
|
+
const open = call.index + call[0].length - 1;
|
|
1775
|
+
const close = _closingParen(masked, open);
|
|
1776
|
+
if (close === -1) continue;
|
|
1777
|
+
const hit = _ORDER_TOTAL_KEY_RE.exec(kept.slice(open, close));
|
|
1778
|
+
if (!hit) continue;
|
|
1779
|
+
const line = lineAt(open + hit.index);
|
|
1780
|
+
findings.push({
|
|
1781
|
+
rule: "order-total-updated",
|
|
1782
|
+
severity: "warning",
|
|
1783
|
+
label:
|
|
1784
|
+
`the order total is write-once, so this update is ignored and the ` +
|
|
1785
|
+
`charge bills the stored total. Set the total when you create the ` +
|
|
1786
|
+
`order, then pass order: { table_id, record_id } to requestPayment ` +
|
|
1787
|
+
`and omit amount_cents.`,
|
|
1788
|
+
line,
|
|
1789
|
+
snippet: (sourceLines[line - 1] || "").trim().slice(0, 200),
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
return findings;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1747
1795
|
// sc-4686 — no-hardcoded-currency-label.
|
|
1748
1796
|
//
|
|
1749
1797
|
// The charge is safe once `currency` is omitted, but the DISPLAY is not: a "kr"
|
|
@@ -4774,6 +4822,7 @@ export function lintSource(source, options) {
|
|
|
4774
4822
|
findings.push(..._paymentCurrencyRules(source));
|
|
4775
4823
|
findings.push(..._paymentKindRules(source));
|
|
4776
4824
|
findings.push(..._paymentStatusWrittenRules(source));
|
|
4825
|
+
findings.push(..._orderTotalUpdatedRules(source));
|
|
4777
4826
|
findings.push(..._hardcodedCurrencyLabelRules(source));
|
|
4778
4827
|
findings.push(..._fixedDateFormatRules(source));
|
|
4779
4828
|
findings.push(..._paymentErrorHandlingRules(source));
|
package/dist/popover-view.js
CHANGED
|
@@ -191,12 +191,15 @@ export function makePopover(rn, Overlay) {
|
|
|
191
191
|
*
|
|
192
192
|
* @param {object} props
|
|
193
193
|
* @param {any} props.trigger — the pressable element that opens it.
|
|
194
|
-
* @param {any|((api: {close: () => void}) => any)} props.children
|
|
194
|
+
* @param {any|((api: {close: (then?: () => void) => void}) => any)} props.children
|
|
195
|
+
* — `close(then)` runs `then` once the popover has left the screen.
|
|
195
196
|
* @param {boolean} [props.visible] — set it to control the popover.
|
|
196
197
|
* @param {(visible: boolean) => void} [props.onVisibleChange]
|
|
197
198
|
* @param {"bottom"|"top"} [props.placement] — default "bottom"; flips.
|
|
198
199
|
* @param {string} [props.accessibilityLabel] — names the panel.
|
|
199
200
|
* @param {string} [props.closeAccessibilityLabel] — the sheet backdrop's name.
|
|
201
|
+
* @param {() => void} [props.onDismiss] — runs once a closed popover has
|
|
202
|
+
* left the screen, so a dialog it opens presents on every host.
|
|
200
203
|
* @param {string} [props.testID] — on the panel.
|
|
201
204
|
*/
|
|
202
205
|
function Popover({
|
|
@@ -207,6 +210,7 @@ export function makePopover(rn, Overlay) {
|
|
|
207
210
|
placement = "bottom",
|
|
208
211
|
accessibilityLabel,
|
|
209
212
|
closeAccessibilityLabel,
|
|
213
|
+
onDismiss,
|
|
210
214
|
testID,
|
|
211
215
|
}) {
|
|
212
216
|
const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
|
|
@@ -218,7 +222,18 @@ export function makePopover(rn, Overlay) {
|
|
|
218
222
|
if (!controlled) setOwnOpen(next);
|
|
219
223
|
if (typeof onVisibleChange === "function") onVisibleChange(next);
|
|
220
224
|
};
|
|
221
|
-
|
|
225
|
+
// What `close(then)` asked to run once the popover has left the screen.
|
|
226
|
+
const afterClose = React.useRef(null);
|
|
227
|
+
const close = (then) => {
|
|
228
|
+
afterClose.current = typeof then === "function" ? then : null;
|
|
229
|
+
setOpen(false);
|
|
230
|
+
};
|
|
231
|
+
const dismissed = () => {
|
|
232
|
+
const run = afterClose.current;
|
|
233
|
+
afterClose.current = null;
|
|
234
|
+
if (run) run();
|
|
235
|
+
if (typeof onDismiss === "function") onDismiss();
|
|
236
|
+
};
|
|
222
237
|
const spacing = theme.spacing || DEFAULT_THEME_TOKENS.spacing;
|
|
223
238
|
|
|
224
239
|
return h(
|
|
@@ -233,7 +248,8 @@ export function makePopover(rn, Overlay) {
|
|
|
233
248
|
AnchoredSurface,
|
|
234
249
|
{
|
|
235
250
|
visible: open,
|
|
236
|
-
onRequestClose: close,
|
|
251
|
+
onRequestClose: () => close(),
|
|
252
|
+
onDismiss: dismissed,
|
|
237
253
|
anchorRef,
|
|
238
254
|
placement,
|
|
239
255
|
padding: spacing.md,
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -2499,11 +2499,11 @@ const HOOKS = [
|
|
|
2499
2499
|
signature: "usePayments()",
|
|
2500
2500
|
returnShape: {
|
|
2501
2501
|
requestPayment:
|
|
2502
|
-
"({ amount_cents
|
|
2502
|
+
"({ 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 (orderTotal; without one: ORDER_NOT_PAYABLE) and the server charges the total stored on the order: create the order with its total, then pass order and omit amount_cents (if sent it must equal the total; refused, not retryable: ORDER_TOTAL_INVALID when the total is empty, zero, negative or not whole, ORDER_AMOUNT_MISMATCH when amount_cents differs). The total is write-once but written by the order's creator, so compute it from prices the buyer cannot change; host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2503
2503
|
getPayment:
|
|
2504
2504
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2505
2505
|
requestGuestPayment:
|
|
2506
|
-
"({ amount_cents
|
|
2506
|
+
"({ amount_cents?, currency?, description, return_path?, order }) => Promise<{ id, status, order }> // a visitor who is NOT signed in buys physical goods (no kind). The orders table needs a payment-status AND an order-total column, as for requestPayment: create the order with its total and omit amount_cents (if sent it must equal the total). order is REQUIRED: create the order row first with useDatastoreMutation().create (the maker lets everyone add rows to the orders table and nobody read them; collect the shipping address and contact there), then pay for it within 15 minutes — only the visitor who created it can. Needs the payments.charge:guest scope too. The host runs a security check and opens hosted Checkout. Refused: TRIAL_RESTRICTED, GUEST_CHECKOUT_LIMIT_REACHED (retryable), CAPTCHA_FAILED / CAPTCHA_UNAVAILABLE (retryable), NOT_FOUND where the shop does not offer guest checkout, plus the requestPayment refusals",
|
|
2507
2507
|
getGuestPayment:
|
|
2508
2508
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // a guest's status read; the host holds the guest's one-time credential, so pass only the id",
|
|
2509
2509
|
},
|
|
@@ -4072,7 +4072,7 @@ const PRIMITIVES = [
|
|
|
4072
4072
|
{
|
|
4073
4073
|
name: "Popover",
|
|
4074
4074
|
description:
|
|
4075
|
-
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4075
|
+
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. A dialog or `<EmojiPicker>` opened from inside it waits until the popover has left the screen: call `close(() => setPickerOpen(true))`, or open it in `onDismiss`, which runs then too; opened in the same press that closes it, it fails to show on iOS. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `onDismiss`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4076
4076
|
rnComponent: null,
|
|
4077
4077
|
docsUrl: null,
|
|
4078
4078
|
},
|
|
@@ -4370,7 +4370,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4370
4370
|
type: "object",
|
|
4371
4371
|
required: false,
|
|
4372
4372
|
description:
|
|
4373
|
-
"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): 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. 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.",
|
|
4373
|
+
"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: true` 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 order's creator writes it on create and a later update is ignored; `requestPayment({ order })` then charges that stored total, so omit `amount_cents`. It fixes the total, not the price: compute it from prices the buyer cannot change. 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.",
|
|
4374
4374
|
},
|
|
4375
4375
|
translations: {
|
|
4376
4376
|
type: "object",
|
|
@@ -7151,7 +7151,15 @@ const CONTRACT = deepFreeze({
|
|
|
7151
7151
|
// 1.282.0: additive (sc-18485) — useAccessPlans() plans and
|
|
7152
7152
|
// useAppSubscription() subscription carry member_since, the member's start
|
|
7153
7153
|
// date: first paid charge, else when access was granted (null when not held).
|
|
7154
|
-
|
|
7154
|
+
// 1.283.0: additive (sc-17852) — `<Popover onDismiss>` and the children's
|
|
7155
|
+
// `close(then)` run once the closed popover has left the screen, so a
|
|
7156
|
+
// dialog it opens presents on iOS.
|
|
7157
|
+
// 1.284.0 (sc-15916): a `paymentStatus` table requires an `orderTotal: true`
|
|
7158
|
+
// column (an immutable NUMBER in minor units); a charge with `order` bills
|
|
7159
|
+
// that total, so `amount_cents` is optional with `order`. Breaking for an
|
|
7160
|
+
// order charge on a table without one (ORDER_NOT_PAYABLE). Two new
|
|
7161
|
+
// PaymentError codes and the `order-total-updated` warning.
|
|
7162
|
+
version: "1.284.0",
|
|
7155
7163
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7156
7164
|
hooks: HOOKS,
|
|
7157
7165
|
primitives: PRIMITIVES,
|