@colixsystems/widget-sdk 0.351.0 → 0.353.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 +11 -1
- package/dist/button-tokens.js +2 -12
- package/dist/button-variants.cjs +24 -0
- package/dist/button-variants.js +16 -0
- package/dist/contract.cjs +13 -5
- package/dist/contract.js +13 -5
- package/dist/hooks.js +4 -0
- package/dist/index.d.ts +24 -9
- package/dist/linter.cjs +96 -11
- package/dist/linter.js +96 -11
- package/dist/theme-components.cjs +24 -7
- package/dist/theme-components.js +24 -7
- package/package.json +1 -1
- package/src/contract.js +13 -5
package/README.md
CHANGED
|
@@ -91,7 +91,17 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
94
|
+
`v0.353.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.353.0 (contract 1.290.0)
|
|
97
|
+
|
|
98
|
+
**The app's button colours paint the primary button only.** When Design > Components > Buttons set a fill, a gradient, a label colour or a border colour, every `<Button>` that was not danger, ghost or link took it, so `secondary` and `outlined` drew as loud as `primary` and a page lost its order of actions. Now those four colours reach the `primary` button only. A `secondary` button draws the theme's secondary and border colours, an `outlined` one the accent as its border and label, and both still take the look's corner radius, size, weight and shadow. On a painted section they take the section's ink again where their own colours would not read. A colour you pass in `fields`, `style` or `labelStyle` still wins, so a secondary button can still be filled on purpose. The built-in Button widget's Secondary and Outlined variants follow the same rule. A danger, ghost or link button, the Link widget's action and form submit buttons are unchanged, since they already worked this way or are primary. The maker's app-wide Button widget colours (`widgetStyles["appstudio.button"]`) are a deliberate choice, so they still reach every variant but danger. Hosts get the same rule from `applyThemeComponentStyle`, which leaves the Buttons scope's four colours out of an `appstudio.button` whose `props.variant` is not primary (a missing or unknown variant is primary).
|
|
99
|
+
|
|
100
|
+
**An unknown `variant` is a lint error.** `<Button variant="outline">` is not a variant, and the button fell back to `primary` without a word. A `<Button>` or `<IconButton>` imported from the SDK whose literal `variant` is not `primary`, `secondary`, `outlined`, `danger`, `ghost` or `link` is now the publish-blocking `button-unknown-variant` finding, which names the variant meant where it can tell (`outline` → `outlined`). A variant chosen at run time is not checked, and neither is markup inside a string or a `variant` inside a handler. Stricter lint.
|
|
101
|
+
|
|
102
|
+
### What's new in 0.352.0 (contract 1.289.0)
|
|
103
|
+
|
|
104
|
+
**The server prices an order, so a buyer cannot lower what is charged.** Until now an order's total was whatever the buyer's own create wrote, so a shop that took prices from the browser could be paid any amount a buyer typed into a page address. The server now prices the order itself when its charge opens, from the shop's own price tables, and a payer who could write or create a price there is refused. Declare it in the `datastoreTemplate`: `unitPrice: true` on a products table's NUMBER price column (minor units), a lines table with a write-once relation to the orders table, a write-once `pricedItem: true` relation to the products table and an optional write-once NUMBER `lineQuantity: true` (1 to 999; empty is 1), and on the orders table `orderTotal: { lines: "<lines table suffix>", via: "<the lines table's relation to the orders>" }`. An orders table may also hold one `pricedItem` of its own, counted once (a shipping option), and an order without lines may be priced by that alone (`orderTotal: true`). Create the order, then its lines, then call `requestPayment({ description, kind, order })` (or `requestGuestPayment`) without `amount_cents`: the server sums quantity × unit price plus the order's own item, writes the total on the order and charges exactly that. Any total or price the widget writes or sends is ignored or refused, so a buyer cannot lower the charge by editing the total or the prices they send. A payer who could write or create a price (by a grant on a priced row or its table, write on a parent a new row could inherit from, or a priced row they created; a shop's own admin included) is refused with `ORDER_NOT_PAYABLE`, as is an order whose total is not priced by the server: publishing a `datastoreTemplate` with an unpriced `orderTotal` is refused (a template already published still installs). Once an order holds its total its lines are fixed: adding or removing one answers `409 ORDER_LOCKED`, and a retried charge charges the same total. New non-retryable `PaymentError` code `ORDER_LINES_INVALID`: no lines, a gone or unpriced product, a quantity outside 1–999, or more than 100 lines. Breaking for order charges on a table whose total the server does not price.
|
|
95
105
|
|
|
96
106
|
### What's new in 0.351.0 (contract 1.288.0)
|
|
97
107
|
|
package/dist/button-tokens.js
CHANGED
|
@@ -3,15 +3,9 @@
|
|
|
3
3
|
// pin it.
|
|
4
4
|
|
|
5
5
|
import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
|
|
6
|
+
import { BUTTON_VARIANTS, resolveButtonVariant } from "./button-variants.js";
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
-
"primary",
|
|
9
|
-
"secondary",
|
|
10
|
-
"outlined",
|
|
11
|
-
"danger",
|
|
12
|
-
"ghost",
|
|
13
|
-
"link",
|
|
14
|
-
]);
|
|
8
|
+
export { BUTTON_VARIANTS, resolveButtonVariant };
|
|
15
9
|
export const BUTTON_SIZES = Object.freeze(["sm", "md", "lg"]);
|
|
16
10
|
export const DEFAULT_BUTTON_SIZE = "md";
|
|
17
11
|
|
|
@@ -42,10 +36,6 @@ export const ICON_BUTTON_SIZES = Object.freeze({
|
|
|
42
36
|
// device, while the web only ever has the box itself.
|
|
43
37
|
const NATIVE_TOUCH_TARGET = 44;
|
|
44
38
|
|
|
45
|
-
export function resolveButtonVariant(variant) {
|
|
46
|
-
return BUTTON_VARIANTS.includes(variant) ? variant : "primary";
|
|
47
|
-
}
|
|
48
|
-
|
|
49
39
|
export function resolveButtonSize(size) {
|
|
50
40
|
return BUTTON_SIZES.includes(size) ? size : DEFAULT_BUTTON_SIZE;
|
|
51
41
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// GENERATED from button-variants.js by scripts/generate-cjs.js — DO NOT EDIT.
|
|
2
|
+
// Change button-variants.js, then run `npm run generate:cjs` in packages/widget-sdk.
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
// The variant names `<Button>` and `<IconButton>` draw. One list for the
|
|
6
|
+
// button itself, the theme fold both hosts run and the widget linter.
|
|
7
|
+
|
|
8
|
+
const BUTTON_VARIANTS = Object.freeze([
|
|
9
|
+
"primary",
|
|
10
|
+
"secondary",
|
|
11
|
+
"outlined",
|
|
12
|
+
"danger",
|
|
13
|
+
"ghost",
|
|
14
|
+
"link",
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
/** A known variant, or `primary` for any other value. */
|
|
18
|
+
function resolveButtonVariant(variant) {
|
|
19
|
+
return BUTTON_VARIANTS.includes(variant) ? variant : "primary";
|
|
20
|
+
}
|
|
21
|
+
module.exports = {
|
|
22
|
+
BUTTON_VARIANTS,
|
|
23
|
+
resolveButtonVariant,
|
|
24
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The variant names `<Button>` and `<IconButton>` draw. One list for the
|
|
2
|
+
// button itself, the theme fold both hosts run and the widget linter.
|
|
3
|
+
|
|
4
|
+
export const BUTTON_VARIANTS = Object.freeze([
|
|
5
|
+
"primary",
|
|
6
|
+
"secondary",
|
|
7
|
+
"outlined",
|
|
8
|
+
"danger",
|
|
9
|
+
"ghost",
|
|
10
|
+
"link",
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
/** A known variant, or `primary` for any other value. */
|
|
14
|
+
export function resolveButtonVariant(variant) {
|
|
15
|
+
return BUTTON_VARIANTS.includes(variant) ? variant : "primary";
|
|
16
|
+
}
|
package/dist/contract.cjs
CHANGED
|
@@ -2517,11 +2517,11 @@ const HOOKS = [
|
|
|
2517
2517
|
signature: "usePayments()",
|
|
2518
2518
|
returnShape: {
|
|
2519
2519
|
requestPayment:
|
|
2520
|
-
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column (orderTotal; without one: ORDER_NOT_PAYABLE) and the server
|
|
2520
|
+
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column the server prices (orderTotal: { lines, via } in the datastoreTemplate; without one: ORDER_NOT_PAYABLE): create the order, then its lines, then pass order and omit amount_cents — the server sums quantity × the products table's unitPrice (plus the order's own pricedItem, e.g. shipping), writes the total and charges it; never compute, write or send a total (if amount_cents is sent it must equal the total; refused, not retryable: ORDER_LINES_INVALID when the lines cannot be priced, ORDER_TOTAL_INVALID when the total is zero, ORDER_AMOUNT_MISMATCH when amount_cents differs; ORDER_NOT_PAYABLE also when the payer could write or create a price). Once priced, the order's lines are fixed (adding or removing one: ORDER_LOCKED); host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2521
2521
|
getPayment:
|
|
2522
2522
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2523
2523
|
requestGuestPayment:
|
|
2524
|
-
"({ 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
|
|
2524
|
+
"({ 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 a server-priced order-total column, as for requestPayment: create the order, then its lines, 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 orders table needs a buyerEmail column the order is created with: the platform emails the order confirmation there, and an order without a valid address is refused with BUYER_EMAIL_INVALID (not retryable). 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",
|
|
2525
2525
|
getGuestPayment:
|
|
2526
2526
|
"(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",
|
|
2527
2527
|
},
|
|
@@ -3990,7 +3990,7 @@ const PRIMITIVES = [
|
|
|
3990
3990
|
{
|
|
3991
3991
|
name: "Button",
|
|
3992
3992
|
description:
|
|
3993
|
-
'Themed button. `<Button title="Save" onPress={save} />` — use it by default for a button: its fill, label colour, border, corner radius, padding, weight, shadow and gradient come from the app\'s button look (Design > Components > Buttons, and Danger buttons / Button outline for the danger variant and emphasis border), so it matches the built-in Button widget. Props: `title`, `onPress` (omit it for a purely visual button inside something else that is pressable), `variant` ("primary" default | "secondary" | "outlined" | "danger" | "ghost", no fill or border with the accent as its label, for a quiet action such as "Load more" or "Cancel" | "link", underlined accent text with no side padding, for an inline action), `size` ("sm", 36px high | "md", 44px, the default | "lg", 52px), `busy` (an action in flight: a `<Spinner>` over the label, which stays the button\'s accessible name and keeps its width, and the button cannot be pressed; use it for a save or an upload instead of swapping the label), `selected` (a toggle\'s on state, drawn in the accent\'s quiet tint; omit it for a plain button), `icon` (a lucide name) with `iconPosition` ("leading" | "trailing"), `disabled`, `accessibilityLabel`, `testID`, `style` (extra container style) and `labelStyle`. It hugs its label and follows its parent\'s alignment: centred in a column with `alignItems: "center"`, vertically centred in such a row, at the start of a plain column. A `style` with `alignSelf`, `flex` or a percentage width makes it an ordinary flex item the parent may stretch. Pass `fields` — `{ background, textColor, borderColor, borderWidth, paddingX, paddingY, radius, fontWeight, fontSize, shadow, gradient }` — to override one button, e.g. from style fields your widget declares. A ghost or link button takes the look\'s shape and type but not its fill, border, shadow or label colour, unless you pass them in `fields`. On a section that paints its own fill (`theme.colors.backdrop` there), a variant colour that the section makes unreadable takes that section\'s text colour, as its text does: an outlined label and border, a secondary whose fill disappears becomes outlined, and a primary or danger fill turns inverse (that text colour as its fill, its own colour as its label). A white or lightly tinted panel changes nothing, and a button inside a `<Card>` is measured against that card. A colour you pass in `fields`, `style` or `labelStyle`, or that the app\'s button look sets, is never changed. A button with only an icon is `<IconButton>`. For any other button, when the request needs one it cannot draw (a round floating action button, a tile with an image and two lines of text, a split button with a menu half), build your own from `Pressable` with `pressableLift` in the app\'s look (theme colours, radii and spacing), at least 44px high (a compact icon control in a dense row may go down to 36px, never below) and with an `accessibilityLabel`.',
|
|
3993
|
+
'Themed button. `<Button title="Save" onPress={save} />` — use it by default for a button: its fill, label colour, border, corner radius, padding, weight, shadow and gradient come from the app\'s button look (Design > Components > Buttons, and Danger buttons / Button outline for the danger variant and emphasis border), so it matches the built-in Button widget. The look\'s fill, gradient, label colour and border colour paint the `primary` button only: every other variant keeps its own colours (a `secondary` the theme\'s secondary and border colours, an `outlined` the accent as its border and label, a `danger` the Danger buttons colours) and takes the look\'s shape, size, weight and shadow, so a page\'s secondary actions stay quieter than its main one. Props: `title`, `onPress` (omit it for a purely visual button inside something else that is pressable), `variant` ("primary" default | "secondary" | "outlined" | "danger" | "ghost", no fill or border with the accent as its label, for a quiet action such as "Load more" or "Cancel" | "link", underlined accent text with no side padding, for an inline action; any other value is a check error), `size` ("sm", 36px high | "md", 44px, the default | "lg", 52px), `busy` (an action in flight: a `<Spinner>` over the label, which stays the button\'s accessible name and keeps its width, and the button cannot be pressed; use it for a save or an upload instead of swapping the label), `selected` (a toggle\'s on state, drawn in the accent\'s quiet tint; omit it for a plain button), `icon` (a lucide name) with `iconPosition` ("leading" | "trailing"), `disabled`, `accessibilityLabel`, `testID`, `style` (extra container style) and `labelStyle`. It hugs its label and follows its parent\'s alignment: centred in a column with `alignItems: "center"`, vertically centred in such a row, at the start of a plain column. A `style` with `alignSelf`, `flex` or a percentage width makes it an ordinary flex item the parent may stretch. Pass `fields` — `{ background, textColor, borderColor, borderWidth, paddingX, paddingY, radius, fontWeight, fontSize, shadow, gradient }` — to override one button, e.g. from style fields your widget declares. A ghost or link button takes the look\'s shape and type but not its fill, border, shadow or label colour, unless you pass them in `fields`. On a section that paints its own fill (`theme.colors.backdrop` there), a variant colour that the section makes unreadable takes that section\'s text colour, as its text does: an outlined label and border, a secondary whose fill disappears becomes outlined, and a primary or danger fill turns inverse (that text colour as its fill, its own colour as its label). A white or lightly tinted panel changes nothing, and a button inside a `<Card>` is measured against that card. A colour you pass in `fields`, `style` or `labelStyle`, or that the app\'s button look sets, is never changed. A button with only an icon is `<IconButton>`. For any other button, when the request needs one it cannot draw (a round floating action button, a tile with an image and two lines of text, a split button with a menu half), build your own from `Pressable` with `pressableLift` in the app\'s look (theme colours, radii and spacing), at least 44px high (a compact icon control in a dense row may go down to 36px, never below) and with an `accessibilityLabel`.',
|
|
3994
3994
|
rnComponent: null,
|
|
3995
3995
|
docsUrl: null,
|
|
3996
3996
|
},
|
|
@@ -4390,7 +4390,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4390
4390
|
type: "object",
|
|
4391
4391
|
required: false,
|
|
4392
4392
|
description:
|
|
4393
|
-
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal:
|
|
4393
|
+
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: { lines: \"<lines table suffix>\", via: \"<its relation to this table>\" }` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The SERVER prices it when the charge opens and ignores any client value: Σ over the order's lines of `lineQuantity` × the `unitPrice` of the row the line's `pricedItem` names, plus the order table's own `pricedItem` once (a shipping option). `via` is a write-once ONE_TO_MANY relation on the lines table pointing at this table. A bare `orderTotal: true` is accepted only on an orders table that has its own `pricedItem`; publishing any other unpriced order total is refused (an already published template still installs, and its order charges are refused with ORDER_NOT_PAYABLE). `unitPrice: true` makes a NUMBER column a product's price in minor units (one per table). `pricedItem: true` makes a write-once single RELATION (one per table) to a table with a unitPrice column the item a line or an order is priced by. `lineQuantity: true` makes a write-once NUMBER column (one per table) a line's quantity, a whole number from 1 to 999 (empty is 1). A payer who may edit or create rows in a priced table is refused, and once an order holds its total no line is added or removed (ORDER_LOCKED). `buyerEmail: true` makes a STRING column the buyer's email address, at most one per table, only in a table with a paymentStatus column, and it must be `immutable: true` (not encrypted, latestVia or copyOf): when a charge marks the order paid the platform emails the buyer an order confirmation (a guest at this address, a signed-in buyer at their account's address), and a refund notice after a full refund, so a widget never sends its own. A guest charge (`requestGuestPayment`) for an order whose table has no buyerEmail column, or whose address is empty or invalid, is refused. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4394
4394
|
},
|
|
4395
4395
|
translations: {
|
|
4396
4396
|
type: "object",
|
|
@@ -7192,7 +7192,15 @@ const CONTRACT = deepFreeze({
|
|
|
7192
7192
|
// covers a run found on mount, cancel() really stops it and send() resolves
|
|
7193
7193
|
// with the stopped row, messages carry `outcome`, and a send during a run
|
|
7194
7194
|
// rejects TURN_IN_PROGRESS. A rejection says `stored` when the message was kept.
|
|
7195
|
-
|
|
7195
|
+
// 1.289.0 (sc-16651): the server prices an order. Template columns
|
|
7196
|
+
// `unitPrice`, `pricedItem`, `lineQuantity` and `orderTotal: { lines, via }`;
|
|
7197
|
+
// an unpriced order total is refused at publish and its order charges
|
|
7198
|
+
// with ORDER_NOT_PAYABLE (breaking for those). New PaymentError code
|
|
7199
|
+
// ORDER_LINES_INVALID; a priced order's line writes refuse ORDER_LOCKED.
|
|
7200
|
+
// 1.290.0: stricter lint (sc-17804) — the app's button colours paint the
|
|
7201
|
+
// primary `<Button>` only, and a literal `variant` the button does not
|
|
7202
|
+
// draw is the publish-blocking `button-unknown-variant` finding.
|
|
7203
|
+
version: "1.290.0",
|
|
7196
7204
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7197
7205
|
hooks: HOOKS,
|
|
7198
7206
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -2512,11 +2512,11 @@ const HOOKS = [
|
|
|
2512
2512
|
signature: "usePayments()",
|
|
2513
2513
|
returnShape: {
|
|
2514
2514
|
requestPayment:
|
|
2515
|
-
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column (orderTotal; without one: ORDER_NOT_PAYABLE) and the server
|
|
2515
|
+
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column the server prices (orderTotal: { lines, via } in the datastoreTemplate; without one: ORDER_NOT_PAYABLE): create the order, then its lines, then pass order and omit amount_cents — the server sums quantity × the products table's unitPrice (plus the order's own pricedItem, e.g. shipping), writes the total and charges it; never compute, write or send a total (if amount_cents is sent it must equal the total; refused, not retryable: ORDER_LINES_INVALID when the lines cannot be priced, ORDER_TOTAL_INVALID when the total is zero, ORDER_AMOUNT_MISMATCH when amount_cents differs; ORDER_NOT_PAYABLE also when the payer could write or create a price). Once priced, the order's lines are fixed (adding or removing one: ORDER_LOCKED); host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2516
2516
|
getPayment:
|
|
2517
2517
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2518
2518
|
requestGuestPayment:
|
|
2519
|
-
"({ 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
|
|
2519
|
+
"({ 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 a server-priced order-total column, as for requestPayment: create the order, then its lines, 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 orders table needs a buyerEmail column the order is created with: the platform emails the order confirmation there, and an order without a valid address is refused with BUYER_EMAIL_INVALID (not retryable). 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",
|
|
2520
2520
|
getGuestPayment:
|
|
2521
2521
|
"(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",
|
|
2522
2522
|
},
|
|
@@ -3985,7 +3985,7 @@ const PRIMITIVES = [
|
|
|
3985
3985
|
{
|
|
3986
3986
|
name: "Button",
|
|
3987
3987
|
description:
|
|
3988
|
-
'Themed button. `<Button title="Save" onPress={save} />` — use it by default for a button: its fill, label colour, border, corner radius, padding, weight, shadow and gradient come from the app\'s button look (Design > Components > Buttons, and Danger buttons / Button outline for the danger variant and emphasis border), so it matches the built-in Button widget. Props: `title`, `onPress` (omit it for a purely visual button inside something else that is pressable), `variant` ("primary" default | "secondary" | "outlined" | "danger" | "ghost", no fill or border with the accent as its label, for a quiet action such as "Load more" or "Cancel" | "link", underlined accent text with no side padding, for an inline action), `size` ("sm", 36px high | "md", 44px, the default | "lg", 52px), `busy` (an action in flight: a `<Spinner>` over the label, which stays the button\'s accessible name and keeps its width, and the button cannot be pressed; use it for a save or an upload instead of swapping the label), `selected` (a toggle\'s on state, drawn in the accent\'s quiet tint; omit it for a plain button), `icon` (a lucide name) with `iconPosition` ("leading" | "trailing"), `disabled`, `accessibilityLabel`, `testID`, `style` (extra container style) and `labelStyle`. It hugs its label and follows its parent\'s alignment: centred in a column with `alignItems: "center"`, vertically centred in such a row, at the start of a plain column. A `style` with `alignSelf`, `flex` or a percentage width makes it an ordinary flex item the parent may stretch. Pass `fields` — `{ background, textColor, borderColor, borderWidth, paddingX, paddingY, radius, fontWeight, fontSize, shadow, gradient }` — to override one button, e.g. from style fields your widget declares. A ghost or link button takes the look\'s shape and type but not its fill, border, shadow or label colour, unless you pass them in `fields`. On a section that paints its own fill (`theme.colors.backdrop` there), a variant colour that the section makes unreadable takes that section\'s text colour, as its text does: an outlined label and border, a secondary whose fill disappears becomes outlined, and a primary or danger fill turns inverse (that text colour as its fill, its own colour as its label). A white or lightly tinted panel changes nothing, and a button inside a `<Card>` is measured against that card. A colour you pass in `fields`, `style` or `labelStyle`, or that the app\'s button look sets, is never changed. A button with only an icon is `<IconButton>`. For any other button, when the request needs one it cannot draw (a round floating action button, a tile with an image and two lines of text, a split button with a menu half), build your own from `Pressable` with `pressableLift` in the app\'s look (theme colours, radii and spacing), at least 44px high (a compact icon control in a dense row may go down to 36px, never below) and with an `accessibilityLabel`.',
|
|
3988
|
+
'Themed button. `<Button title="Save" onPress={save} />` — use it by default for a button: its fill, label colour, border, corner radius, padding, weight, shadow and gradient come from the app\'s button look (Design > Components > Buttons, and Danger buttons / Button outline for the danger variant and emphasis border), so it matches the built-in Button widget. The look\'s fill, gradient, label colour and border colour paint the `primary` button only: every other variant keeps its own colours (a `secondary` the theme\'s secondary and border colours, an `outlined` the accent as its border and label, a `danger` the Danger buttons colours) and takes the look\'s shape, size, weight and shadow, so a page\'s secondary actions stay quieter than its main one. Props: `title`, `onPress` (omit it for a purely visual button inside something else that is pressable), `variant` ("primary" default | "secondary" | "outlined" | "danger" | "ghost", no fill or border with the accent as its label, for a quiet action such as "Load more" or "Cancel" | "link", underlined accent text with no side padding, for an inline action; any other value is a check error), `size` ("sm", 36px high | "md", 44px, the default | "lg", 52px), `busy` (an action in flight: a `<Spinner>` over the label, which stays the button\'s accessible name and keeps its width, and the button cannot be pressed; use it for a save or an upload instead of swapping the label), `selected` (a toggle\'s on state, drawn in the accent\'s quiet tint; omit it for a plain button), `icon` (a lucide name) with `iconPosition` ("leading" | "trailing"), `disabled`, `accessibilityLabel`, `testID`, `style` (extra container style) and `labelStyle`. It hugs its label and follows its parent\'s alignment: centred in a column with `alignItems: "center"`, vertically centred in such a row, at the start of a plain column. A `style` with `alignSelf`, `flex` or a percentage width makes it an ordinary flex item the parent may stretch. Pass `fields` — `{ background, textColor, borderColor, borderWidth, paddingX, paddingY, radius, fontWeight, fontSize, shadow, gradient }` — to override one button, e.g. from style fields your widget declares. A ghost or link button takes the look\'s shape and type but not its fill, border, shadow or label colour, unless you pass them in `fields`. On a section that paints its own fill (`theme.colors.backdrop` there), a variant colour that the section makes unreadable takes that section\'s text colour, as its text does: an outlined label and border, a secondary whose fill disappears becomes outlined, and a primary or danger fill turns inverse (that text colour as its fill, its own colour as its label). A white or lightly tinted panel changes nothing, and a button inside a `<Card>` is measured against that card. A colour you pass in `fields`, `style` or `labelStyle`, or that the app\'s button look sets, is never changed. A button with only an icon is `<IconButton>`. For any other button, when the request needs one it cannot draw (a round floating action button, a tile with an image and two lines of text, a split button with a menu half), build your own from `Pressable` with `pressableLift` in the app\'s look (theme colours, radii and spacing), at least 44px high (a compact icon control in a dense row may go down to 36px, never below) and with an `accessibilityLabel`.',
|
|
3989
3989
|
rnComponent: null,
|
|
3990
3990
|
docsUrl: null,
|
|
3991
3991
|
},
|
|
@@ -4385,7 +4385,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4385
4385
|
type: "object",
|
|
4386
4386
|
required: false,
|
|
4387
4387
|
description:
|
|
4388
|
-
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal:
|
|
4388
|
+
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: { lines: \"<lines table suffix>\", via: \"<its relation to this table>\" }` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The SERVER prices it when the charge opens and ignores any client value: Σ over the order's lines of `lineQuantity` × the `unitPrice` of the row the line's `pricedItem` names, plus the order table's own `pricedItem` once (a shipping option). `via` is a write-once ONE_TO_MANY relation on the lines table pointing at this table. A bare `orderTotal: true` is accepted only on an orders table that has its own `pricedItem`; publishing any other unpriced order total is refused (an already published template still installs, and its order charges are refused with ORDER_NOT_PAYABLE). `unitPrice: true` makes a NUMBER column a product's price in minor units (one per table). `pricedItem: true` makes a write-once single RELATION (one per table) to a table with a unitPrice column the item a line or an order is priced by. `lineQuantity: true` makes a write-once NUMBER column (one per table) a line's quantity, a whole number from 1 to 999 (empty is 1). A payer who may edit or create rows in a priced table is refused, and once an order holds its total no line is added or removed (ORDER_LOCKED). `buyerEmail: true` makes a STRING column the buyer's email address, at most one per table, only in a table with a paymentStatus column, and it must be `immutable: true` (not encrypted, latestVia or copyOf): when a charge marks the order paid the platform emails the buyer an order confirmation (a guest at this address, a signed-in buyer at their account's address), and a refund notice after a full refund, so a widget never sends its own. A guest charge (`requestGuestPayment`) for an order whose table has no buyerEmail column, or whose address is empty or invalid, is refused. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4389
4389
|
},
|
|
4390
4390
|
translations: {
|
|
4391
4391
|
type: "object",
|
|
@@ -7187,7 +7187,15 @@ const CONTRACT = deepFreeze({
|
|
|
7187
7187
|
// covers a run found on mount, cancel() really stops it and send() resolves
|
|
7188
7188
|
// with the stopped row, messages carry `outcome`, and a send during a run
|
|
7189
7189
|
// rejects TURN_IN_PROGRESS. A rejection says `stored` when the message was kept.
|
|
7190
|
-
|
|
7190
|
+
// 1.289.0 (sc-16651): the server prices an order. Template columns
|
|
7191
|
+
// `unitPrice`, `pricedItem`, `lineQuantity` and `orderTotal: { lines, via }`;
|
|
7192
|
+
// an unpriced order total is refused at publish and its order charges
|
|
7193
|
+
// with ORDER_NOT_PAYABLE (breaking for those). New PaymentError code
|
|
7194
|
+
// ORDER_LINES_INVALID; a priced order's line writes refuse ORDER_LOCKED.
|
|
7195
|
+
// 1.290.0: stricter lint (sc-17804) — the app's button colours paint the
|
|
7196
|
+
// primary `<Button>` only, and a literal `variant` the button does not
|
|
7197
|
+
// draw is the publish-blocking `button-unknown-variant` finding.
|
|
7198
|
+
version: "1.290.0",
|
|
7191
7199
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7192
7200
|
hooks: HOOKS,
|
|
7193
7201
|
primitives: PRIMITIVES,
|
package/dist/hooks.js
CHANGED
|
@@ -7511,6 +7511,7 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7511
7511
|
"ORDER_ALREADY_PAID",
|
|
7512
7512
|
"ORDER_NOT_FOUND",
|
|
7513
7513
|
"ORDER_AMOUNT_MISMATCH",
|
|
7514
|
+
"ORDER_LINES_INVALID",
|
|
7514
7515
|
"ORDER_NOT_PAYABLE",
|
|
7515
7516
|
"ORDER_TOTAL_INVALID",
|
|
7516
7517
|
"PAYMENTS_DISABLED",
|
|
@@ -7548,6 +7549,9 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7548
7549
|
* or not a whole number of minor units
|
|
7549
7550
|
* - "ORDER_AMOUNT_MISMATCH" — `amount_cents` was sent and differs from
|
|
7550
7551
|
* the order's total; omit it
|
|
7552
|
+
* - "ORDER_LINES_INVALID" — the server cannot price the order's lines
|
|
7553
|
+
* (none, a gone or unpriced product, a
|
|
7554
|
+
* quantity outside 1–999, over 100 lines)
|
|
7551
7555
|
* - "BUYER_EMAIL_INVALID" — a guest's order has no valid email in
|
|
7552
7556
|
* its buyer-email column; the receipt needs one
|
|
7553
7557
|
* - "ORDER_PAYMENT_IN_PROGRESS" — another checkout for the order is open
|
package/dist/index.d.ts
CHANGED
|
@@ -292,11 +292,23 @@ export interface WidgetDatastoreTemplateColumn {
|
|
|
292
292
|
* NUMBER only, required once in every table with a `paymentStatus` column
|
|
293
293
|
* (and only there), and it must be `immutable: true` (not encrypted,
|
|
294
294
|
* `latestVia` or `copyOf`). The order's total in integer minor units (339 kr
|
|
295
|
-
* is 33900) of the workspace's charge currency
|
|
296
|
-
*
|
|
297
|
-
*
|
|
295
|
+
* is 33900) of the workspace's charge currency, which the SERVER prices when
|
|
296
|
+
* the charge opens: `{ lines, via }` names the lines table (its suffix) and
|
|
297
|
+
* its write-once relation back to this table. A bare `true` is accepted only
|
|
298
|
+
* where this table has its own `pricedItem`. `requestPayment({ order })`
|
|
299
|
+
* charges the priced total, so omit `amount_cents`; never write a total.
|
|
298
300
|
*/
|
|
299
|
-
orderTotal?: boolean;
|
|
301
|
+
orderTotal?: boolean | { lines: string; via: string };
|
|
302
|
+
/** NUMBER only, one per table: a product's price in integer minor units. */
|
|
303
|
+
unitPrice?: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Single RELATION only, `immutable: true`, one per table, pointing at a table
|
|
306
|
+
* with a `unitPrice`: the item a line is priced by (times its quantity), or
|
|
307
|
+
* on the orders table an item counted once (a shipping option).
|
|
308
|
+
*/
|
|
309
|
+
pricedItem?: boolean;
|
|
310
|
+
/** NUMBER only, `immutable: true`, one per table: a line's quantity, 1 to 999 (empty is 1). */
|
|
311
|
+
lineQuantity?: boolean;
|
|
300
312
|
/**
|
|
301
313
|
* STRING only, at most one per table, in a table with a `paymentStatus`
|
|
302
314
|
* column, and it must be `immutable: true` (not encrypted, `latestVia` or
|
|
@@ -1666,10 +1678,12 @@ export interface PaymentRequest {
|
|
|
1666
1678
|
* column, so never write "paid" yourself; the platform ignores it anyway.
|
|
1667
1679
|
* Refused with ORDER_NOT_FOUND, ORDER_NOT_PAYABLE or ORDER_ALREADY_PAID, and
|
|
1668
1680
|
* with the retryable ORDER_PAYMENT_IN_PROGRESS while another checkout is open.
|
|
1669
|
-
* The table also needs
|
|
1670
|
-
* one
|
|
1671
|
-
*
|
|
1672
|
-
*
|
|
1681
|
+
* The table also needs a server-priced order-total column (ORDER_NOT_PAYABLE
|
|
1682
|
+
* without one, or when the payer could write or create a price). The server prices the
|
|
1683
|
+
* order from its lines and charges that: ORDER_LINES_INVALID when it cannot,
|
|
1684
|
+
* ORDER_TOTAL_INVALID when the total is zero, and ORDER_AMOUNT_MISMATCH when
|
|
1685
|
+
* `amount_cents` differs from it. Once priced, adding or removing a line is
|
|
1686
|
+
* refused with ORDER_LOCKED.
|
|
1673
1687
|
*/
|
|
1674
1688
|
order?: PaymentOrder;
|
|
1675
1689
|
}
|
|
@@ -1697,7 +1711,7 @@ export interface PaymentResult {
|
|
|
1697
1711
|
* `buyerEmail` column holding a valid address (BUYER_EMAIL_INVALID otherwise).
|
|
1698
1712
|
*/
|
|
1699
1713
|
export interface GuestPaymentRequest {
|
|
1700
|
-
/** Optional: the server
|
|
1714
|
+
/** Optional: the server prices the order and charges that, as for `requestPayment`. */
|
|
1701
1715
|
amount_cents?: number;
|
|
1702
1716
|
currency?: string;
|
|
1703
1717
|
description: string;
|
|
@@ -1845,6 +1859,7 @@ export class PaymentError extends Error {
|
|
|
1845
1859
|
| "ORDER_ALREADY_PAID"
|
|
1846
1860
|
| "ORDER_TOTAL_INVALID"
|
|
1847
1861
|
| "ORDER_AMOUNT_MISMATCH"
|
|
1862
|
+
| "ORDER_LINES_INVALID"
|
|
1848
1863
|
| "BUYER_EMAIL_INVALID"
|
|
1849
1864
|
| "ORDER_PAYMENT_IN_PROGRESS"
|
|
1850
1865
|
| "ALREADY_OWNED"
|
package/dist/linter.cjs
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
const { CONTRACT, normaliseActionTriggerTypes } = require("./contract.cjs");
|
|
6
6
|
const { LUCIDE_ICON_NAMES, LUCIDE_VERSION } = require("./lucideIconNames.cjs");
|
|
7
7
|
const { groupIdTextFindings } = require("./group-id-text.cjs");
|
|
8
|
+
const { BUTTON_VARIANTS } = require("./button-variants.cjs");
|
|
8
9
|
const { stripNonCode: _stripNonCode } = require("./source-mask.cjs");
|
|
9
10
|
|
|
10
11
|
// Static-analysis linter per docs/architecture/widget-marketplace.md §3.1.
|
|
@@ -1098,33 +1099,38 @@ const LUCIDE_NAME_SET = new Set(LUCIDE_ICON_NAMES);
|
|
|
1098
1099
|
// `[^}]*` (not `[\s\S]*?`) so the brace capture can never cross a `}` into a
|
|
1099
1100
|
// neighbouring import — otherwise a preceding `import { View, Pressable } from
|
|
1100
1101
|
// "react-native"` is swallowed and its names get validated as lucide icons.
|
|
1101
|
-
const
|
|
1102
|
+
const NAMED_IMPORT_HEAD_RE = /import\s+(?:[A-Za-z0-9_$]+\s*,\s*)?\{/g;
|
|
1102
1103
|
const LUCIDE_IMPORT_TAIL_RE = /\}\s*from\s*["']lucide-react-native["']/y;
|
|
1103
1104
|
|
|
1104
|
-
// `import { … } from "
|
|
1105
|
-
// NEXT `}`, so every head sharing that brace
|
|
1106
|
-
// regex retried that run from each unclosed
|
|
1107
|
-
|
|
1105
|
+
// `import { … } from "<module>"` clauses, the module matched by the sticky
|
|
1106
|
+
// `tailRe`. The names run to the NEXT `}`, so every head sharing that brace
|
|
1107
|
+
// shares one tail check; one regex retried that run from each unclosed
|
|
1108
|
+
// `import {` (sc-8204).
|
|
1109
|
+
function _namedImports(source, tailRe) {
|
|
1108
1110
|
const found = [];
|
|
1109
1111
|
const tails = new Map();
|
|
1110
|
-
|
|
1112
|
+
NAMED_IMPORT_HEAD_RE.lastIndex = 0;
|
|
1111
1113
|
let head;
|
|
1112
|
-
while ((head =
|
|
1113
|
-
const from =
|
|
1114
|
+
while ((head = NAMED_IMPORT_HEAD_RE.exec(source))) {
|
|
1115
|
+
const from = NAMED_IMPORT_HEAD_RE.lastIndex;
|
|
1114
1116
|
const close = source.indexOf("}", from);
|
|
1115
1117
|
if (close === -1) break;
|
|
1116
1118
|
if (!tails.has(close)) {
|
|
1117
|
-
|
|
1118
|
-
tails.set(close,
|
|
1119
|
+
tailRe.lastIndex = close;
|
|
1120
|
+
tails.set(close, tailRe.test(source) ? tailRe.lastIndex : -1);
|
|
1119
1121
|
}
|
|
1120
1122
|
const end = tails.get(close);
|
|
1121
1123
|
if (end === -1) continue;
|
|
1122
1124
|
found.push({ index: head.index, names: source.slice(from, close) });
|
|
1123
|
-
|
|
1125
|
+
NAMED_IMPORT_HEAD_RE.lastIndex = end;
|
|
1124
1126
|
}
|
|
1125
1127
|
return found;
|
|
1126
1128
|
}
|
|
1127
1129
|
|
|
1130
|
+
function _lucideImports(source) {
|
|
1131
|
+
return _namedImports(source, LUCIDE_IMPORT_TAIL_RE);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1128
1134
|
// lucide re-exports each base icon as `<Name>`, `<Name>Icon`, and `Lucide<Name>`;
|
|
1129
1135
|
// the committed set holds only the base names, so normalise the alias forms
|
|
1130
1136
|
// before the membership check. No base name ends in "Icon" or starts with
|
|
@@ -1302,6 +1308,84 @@ function _textSymbolIconRules(source) {
|
|
|
1302
1308
|
return findings;
|
|
1303
1309
|
}
|
|
1304
1310
|
|
|
1311
|
+
// sc-17804 — an unknown variant draws the primary button, silently.
|
|
1312
|
+
const _SDK_IMPORT_TAIL_RE = /\}\s*from\s*["']@colixsystems\/widget-sdk["']/y;
|
|
1313
|
+
const _LITERAL_ATTR_VALUE_RE = /\s*(?:"([^"\n]*)"|'([^'\n]*)'|\{\s*(?:"([^"\n]*)"|'([^'\n]*)')\s*\})/y;
|
|
1314
|
+
const _VARIANTED_BUTTONS = new Set(["Button", "IconButton"]);
|
|
1315
|
+
|
|
1316
|
+
function _sdkButtonNames(code) {
|
|
1317
|
+
const names = new Set();
|
|
1318
|
+
for (const { names: clause } of _namedImports(code, _SDK_IMPORT_TAIL_RE)) {
|
|
1319
|
+
for (const spec of clause.split(",")) {
|
|
1320
|
+
const [imported, local] = spec.trim().split(/\s+as\s+/);
|
|
1321
|
+
if (_VARIANTED_BUTTONS.has(imported)) names.add((local || imported).trim());
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
return names;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
function _nearestButtonVariant(value) {
|
|
1328
|
+
const lower = value.trim().toLowerCase();
|
|
1329
|
+
if (!lower) return null;
|
|
1330
|
+
return BUTTON_VARIANTS.find((v) => v.startsWith(lower) || lower.startsWith(v)) || null;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
// Where attribute `name`'s `=` ends in a masked opening tag, or -1.
|
|
1334
|
+
// Only outside braces, so a `variant` inside a handler is not the prop.
|
|
1335
|
+
// The mask blanks quotes too, so the value is read from the kept source.
|
|
1336
|
+
function _jsxAttrValueAt(tag, name) {
|
|
1337
|
+
let depth = 0;
|
|
1338
|
+
for (let i = 0; i < tag.length; i += 1) {
|
|
1339
|
+
const ch = tag[i];
|
|
1340
|
+
if (ch === "{") depth += 1;
|
|
1341
|
+
else if (ch === "}") depth -= 1;
|
|
1342
|
+
else if (depth === 0 && /\s/.test(tag[i - 1] || "") && tag.startsWith(name, i)) {
|
|
1343
|
+
let at = i + name.length;
|
|
1344
|
+
while (/\s/.test(tag[at] || "")) at += 1;
|
|
1345
|
+
if (tag[at] !== "=") continue;
|
|
1346
|
+
return at + 1;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
return -1;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
function _buttonVariantRules(source) {
|
|
1353
|
+
const kept = _stripNonCode(source, { keepStrings: true });
|
|
1354
|
+
const names = _sdkButtonNames(kept);
|
|
1355
|
+
if (names.size === 0) return [];
|
|
1356
|
+
// Tags are found where strings are blanked, so markup in a string is not one.
|
|
1357
|
+
const code = _stripNonCode(source);
|
|
1358
|
+
const lineAt = _lineCounter(code);
|
|
1359
|
+
const sourceLines = source.split(/\r?\n/);
|
|
1360
|
+
const findings = [];
|
|
1361
|
+
const tagRe = new RegExp(`<(${[...names].map((n) => n.replace(/[$]/g, "\\$")).join("|")})(?![\\w$])`, "g");
|
|
1362
|
+
let tag;
|
|
1363
|
+
while ((tag = tagRe.exec(code))) {
|
|
1364
|
+
const end = _jsxOpenTagEnd(code, tag.index + tag[0].length);
|
|
1365
|
+
tagRe.lastIndex = end;
|
|
1366
|
+
const valueAt = _jsxAttrValueAt(code.slice(tag.index, end), "variant");
|
|
1367
|
+
if (valueAt === -1) continue;
|
|
1368
|
+
_LITERAL_ATTR_VALUE_RE.lastIndex = tag.index + valueAt;
|
|
1369
|
+
const hit = _LITERAL_ATTR_VALUE_RE.exec(kept);
|
|
1370
|
+
if (!hit) continue;
|
|
1371
|
+
const value = [hit[1], hit[2], hit[3], hit[4]].find((v) => v !== undefined);
|
|
1372
|
+
if (BUTTON_VARIANTS.includes(value)) continue;
|
|
1373
|
+
const near = _nearestButtonVariant(value);
|
|
1374
|
+
const line = lineAt(tag.index + valueAt);
|
|
1375
|
+
findings.push({
|
|
1376
|
+
rule: "button-unknown-variant",
|
|
1377
|
+
severity: "error",
|
|
1378
|
+
label:
|
|
1379
|
+
`<${tag[1]} variant="${value}">: "${value}" is not a button variant, so it draws as the ` +
|
|
1380
|
+
`primary button. ${near ? `Use variant="${near}". ` : ""}The variants are ` +
|
|
1381
|
+
`${BUTTON_VARIANTS.map((v) => `"${v}"`).join(", ")}.`,
|
|
1382
|
+
line,
|
|
1383
|
+
snippet: (sourceLines[line - 1] || "").trim().slice(0, 200),
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
return findings;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1305
1389
|
// sc-2353 / sc-5897 — widget source must be SELF-CONTAINED: every identifier it
|
|
1306
1390
|
// references needs a binding in that file. Two rules share ONE detector here
|
|
1307
1391
|
// because they are one bug with one cause (CLAUDE.md §3):
|
|
@@ -4970,6 +5054,7 @@ function lintSource(source, options) {
|
|
|
4970
5054
|
findings.push(..._handBuiltPageUrlRules(source));
|
|
4971
5055
|
findings.push(..._lucideIconRules(source));
|
|
4972
5056
|
findings.push(..._textSymbolIconRules(source));
|
|
5057
|
+
findings.push(..._buttonVariantRules(source));
|
|
4973
5058
|
findings.push(..._bundledAssetRules(source, options && options.assetFiles));
|
|
4974
5059
|
// sc-2353 / sc-5897 — widget source must be self-contained: a referenced
|
|
4975
5060
|
// `React` global or SDK export with no import throws at render.
|
package/dist/linter.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { CONTRACT, normaliseActionTriggerTypes } from "./contract.js";
|
|
10
10
|
import { LUCIDE_ICON_NAMES, LUCIDE_VERSION } from "./lucideIconNames.js";
|
|
11
11
|
import { groupIdTextFindings } from "./group-id-text.js";
|
|
12
|
+
import { BUTTON_VARIANTS } from "./button-variants.js";
|
|
12
13
|
|
|
13
14
|
// Per-identifier match rule, run over the whole masked source. Most banned
|
|
14
15
|
// identifiers compile to a whole-word match.
|
|
@@ -1093,33 +1094,38 @@ const LUCIDE_NAME_SET = new Set(LUCIDE_ICON_NAMES);
|
|
|
1093
1094
|
// `[^}]*` (not `[\s\S]*?`) so the brace capture can never cross a `}` into a
|
|
1094
1095
|
// neighbouring import — otherwise a preceding `import { View, Pressable } from
|
|
1095
1096
|
// "react-native"` is swallowed and its names get validated as lucide icons.
|
|
1096
|
-
const
|
|
1097
|
+
const NAMED_IMPORT_HEAD_RE = /import\s+(?:[A-Za-z0-9_$]+\s*,\s*)?\{/g;
|
|
1097
1098
|
const LUCIDE_IMPORT_TAIL_RE = /\}\s*from\s*["']lucide-react-native["']/y;
|
|
1098
1099
|
|
|
1099
|
-
// `import { … } from "
|
|
1100
|
-
// NEXT `}`, so every head sharing that brace
|
|
1101
|
-
// regex retried that run from each unclosed
|
|
1102
|
-
|
|
1100
|
+
// `import { … } from "<module>"` clauses, the module matched by the sticky
|
|
1101
|
+
// `tailRe`. The names run to the NEXT `}`, so every head sharing that brace
|
|
1102
|
+
// shares one tail check; one regex retried that run from each unclosed
|
|
1103
|
+
// `import {` (sc-8204).
|
|
1104
|
+
function _namedImports(source, tailRe) {
|
|
1103
1105
|
const found = [];
|
|
1104
1106
|
const tails = new Map();
|
|
1105
|
-
|
|
1107
|
+
NAMED_IMPORT_HEAD_RE.lastIndex = 0;
|
|
1106
1108
|
let head;
|
|
1107
|
-
while ((head =
|
|
1108
|
-
const from =
|
|
1109
|
+
while ((head = NAMED_IMPORT_HEAD_RE.exec(source))) {
|
|
1110
|
+
const from = NAMED_IMPORT_HEAD_RE.lastIndex;
|
|
1109
1111
|
const close = source.indexOf("}", from);
|
|
1110
1112
|
if (close === -1) break;
|
|
1111
1113
|
if (!tails.has(close)) {
|
|
1112
|
-
|
|
1113
|
-
tails.set(close,
|
|
1114
|
+
tailRe.lastIndex = close;
|
|
1115
|
+
tails.set(close, tailRe.test(source) ? tailRe.lastIndex : -1);
|
|
1114
1116
|
}
|
|
1115
1117
|
const end = tails.get(close);
|
|
1116
1118
|
if (end === -1) continue;
|
|
1117
1119
|
found.push({ index: head.index, names: source.slice(from, close) });
|
|
1118
|
-
|
|
1120
|
+
NAMED_IMPORT_HEAD_RE.lastIndex = end;
|
|
1119
1121
|
}
|
|
1120
1122
|
return found;
|
|
1121
1123
|
}
|
|
1122
1124
|
|
|
1125
|
+
function _lucideImports(source) {
|
|
1126
|
+
return _namedImports(source, LUCIDE_IMPORT_TAIL_RE);
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1123
1129
|
// lucide re-exports each base icon as `<Name>`, `<Name>Icon`, and `Lucide<Name>`;
|
|
1124
1130
|
// the committed set holds only the base names, so normalise the alias forms
|
|
1125
1131
|
// before the membership check. No base name ends in "Icon" or starts with
|
|
@@ -1297,6 +1303,84 @@ function _textSymbolIconRules(source) {
|
|
|
1297
1303
|
return findings;
|
|
1298
1304
|
}
|
|
1299
1305
|
|
|
1306
|
+
// sc-17804 — an unknown variant draws the primary button, silently.
|
|
1307
|
+
const _SDK_IMPORT_TAIL_RE = /\}\s*from\s*["']@colixsystems\/widget-sdk["']/y;
|
|
1308
|
+
const _LITERAL_ATTR_VALUE_RE = /\s*(?:"([^"\n]*)"|'([^'\n]*)'|\{\s*(?:"([^"\n]*)"|'([^'\n]*)')\s*\})/y;
|
|
1309
|
+
const _VARIANTED_BUTTONS = new Set(["Button", "IconButton"]);
|
|
1310
|
+
|
|
1311
|
+
function _sdkButtonNames(code) {
|
|
1312
|
+
const names = new Set();
|
|
1313
|
+
for (const { names: clause } of _namedImports(code, _SDK_IMPORT_TAIL_RE)) {
|
|
1314
|
+
for (const spec of clause.split(",")) {
|
|
1315
|
+
const [imported, local] = spec.trim().split(/\s+as\s+/);
|
|
1316
|
+
if (_VARIANTED_BUTTONS.has(imported)) names.add((local || imported).trim());
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
return names;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
function _nearestButtonVariant(value) {
|
|
1323
|
+
const lower = value.trim().toLowerCase();
|
|
1324
|
+
if (!lower) return null;
|
|
1325
|
+
return BUTTON_VARIANTS.find((v) => v.startsWith(lower) || lower.startsWith(v)) || null;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
// Where attribute `name`'s `=` ends in a masked opening tag, or -1.
|
|
1329
|
+
// Only outside braces, so a `variant` inside a handler is not the prop.
|
|
1330
|
+
// The mask blanks quotes too, so the value is read from the kept source.
|
|
1331
|
+
function _jsxAttrValueAt(tag, name) {
|
|
1332
|
+
let depth = 0;
|
|
1333
|
+
for (let i = 0; i < tag.length; i += 1) {
|
|
1334
|
+
const ch = tag[i];
|
|
1335
|
+
if (ch === "{") depth += 1;
|
|
1336
|
+
else if (ch === "}") depth -= 1;
|
|
1337
|
+
else if (depth === 0 && /\s/.test(tag[i - 1] || "") && tag.startsWith(name, i)) {
|
|
1338
|
+
let at = i + name.length;
|
|
1339
|
+
while (/\s/.test(tag[at] || "")) at += 1;
|
|
1340
|
+
if (tag[at] !== "=") continue;
|
|
1341
|
+
return at + 1;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
return -1;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
function _buttonVariantRules(source) {
|
|
1348
|
+
const kept = _stripNonCode(source, { keepStrings: true });
|
|
1349
|
+
const names = _sdkButtonNames(kept);
|
|
1350
|
+
if (names.size === 0) return [];
|
|
1351
|
+
// Tags are found where strings are blanked, so markup in a string is not one.
|
|
1352
|
+
const code = _stripNonCode(source);
|
|
1353
|
+
const lineAt = _lineCounter(code);
|
|
1354
|
+
const sourceLines = source.split(/\r?\n/);
|
|
1355
|
+
const findings = [];
|
|
1356
|
+
const tagRe = new RegExp(`<(${[...names].map((n) => n.replace(/[$]/g, "\\$")).join("|")})(?![\\w$])`, "g");
|
|
1357
|
+
let tag;
|
|
1358
|
+
while ((tag = tagRe.exec(code))) {
|
|
1359
|
+
const end = _jsxOpenTagEnd(code, tag.index + tag[0].length);
|
|
1360
|
+
tagRe.lastIndex = end;
|
|
1361
|
+
const valueAt = _jsxAttrValueAt(code.slice(tag.index, end), "variant");
|
|
1362
|
+
if (valueAt === -1) continue;
|
|
1363
|
+
_LITERAL_ATTR_VALUE_RE.lastIndex = tag.index + valueAt;
|
|
1364
|
+
const hit = _LITERAL_ATTR_VALUE_RE.exec(kept);
|
|
1365
|
+
if (!hit) continue;
|
|
1366
|
+
const value = [hit[1], hit[2], hit[3], hit[4]].find((v) => v !== undefined);
|
|
1367
|
+
if (BUTTON_VARIANTS.includes(value)) continue;
|
|
1368
|
+
const near = _nearestButtonVariant(value);
|
|
1369
|
+
const line = lineAt(tag.index + valueAt);
|
|
1370
|
+
findings.push({
|
|
1371
|
+
rule: "button-unknown-variant",
|
|
1372
|
+
severity: "error",
|
|
1373
|
+
label:
|
|
1374
|
+
`<${tag[1]} variant="${value}">: "${value}" is not a button variant, so it draws as the ` +
|
|
1375
|
+
`primary button. ${near ? `Use variant="${near}". ` : ""}The variants are ` +
|
|
1376
|
+
`${BUTTON_VARIANTS.map((v) => `"${v}"`).join(", ")}.`,
|
|
1377
|
+
line,
|
|
1378
|
+
snippet: (sourceLines[line - 1] || "").trim().slice(0, 200),
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
return findings;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1300
1384
|
// sc-2353 / sc-5897 — widget source must be SELF-CONTAINED: every identifier it
|
|
1301
1385
|
// references needs a binding in that file. Two rules share ONE detector here
|
|
1302
1386
|
// because they are one bug with one cause (CLAUDE.md §3):
|
|
@@ -4965,6 +5049,7 @@ export function lintSource(source, options) {
|
|
|
4965
5049
|
findings.push(..._handBuiltPageUrlRules(source));
|
|
4966
5050
|
findings.push(..._lucideIconRules(source));
|
|
4967
5051
|
findings.push(..._textSymbolIconRules(source));
|
|
5052
|
+
findings.push(..._buttonVariantRules(source));
|
|
4968
5053
|
findings.push(..._bundledAssetRules(source, options && options.assetFiles));
|
|
4969
5054
|
// sc-2353 / sc-5897 — widget source must be self-contained: a referenced
|
|
4970
5055
|
// `React` global or SDK export with no import throws at render.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
const { CONTRACT, normaliseComponentGradient } = require("./contract.cjs");
|
|
6
6
|
const { isPlainObject } = require("./plain-object.cjs");
|
|
7
|
+
const { resolveButtonVariant } = require("./button-variants.cjs");
|
|
7
8
|
|
|
8
9
|
// REQ-THEME-15 (sc-1497) — the host side of per-component style tokens.
|
|
9
10
|
//
|
|
@@ -346,6 +347,8 @@ function styleSchemaDefaults(styleSchema) {
|
|
|
346
347
|
return out;
|
|
347
348
|
}
|
|
348
349
|
|
|
350
|
+
const NO_SKIPS = new Set();
|
|
351
|
+
|
|
349
352
|
/**
|
|
350
353
|
* The per-component style fields that apply to one widget, keyed by the
|
|
351
354
|
* `styleSchema` field name the widget actually reads. A widget may sit in more
|
|
@@ -360,10 +363,11 @@ function styleSchemaDefaults(styleSchema) {
|
|
|
360
363
|
* component scopes, then `widgetStyles[manifestId]`. The caller spreads the
|
|
361
364
|
* per-instance `props.style` last, so the full order is
|
|
362
365
|
* styleSchema default -> palette/scopes -> widgetStyles -> props.style.
|
|
366
|
+
* `scopeSkips` names fields the scopes may not set; widgetStyles still may.
|
|
363
367
|
*
|
|
364
368
|
* @returns {Record<string, unknown>|null} null when nothing applies.
|
|
365
369
|
*/
|
|
366
|
-
function componentStyleFor(manifestId, components, styleSchema, widgetStyles) {
|
|
370
|
+
function componentStyleFor(manifestId, components, styleSchema, widgetStyles, scopeSkips = NO_SKIPS) {
|
|
367
371
|
if (typeof manifestId !== "string") return null;
|
|
368
372
|
const validated = normaliseThemeComponents(components);
|
|
369
373
|
// sc-6750: the author's declared defaults are the WEAKEST layer, so they go
|
|
@@ -391,13 +395,13 @@ function componentStyleFor(manifestId, components, styleSchema, widgetStyles) {
|
|
|
391
395
|
// that reads named fields, but a widget spreading `props.style` onto a
|
|
392
396
|
// View would get an unknown style key. Built-ins thread no styleSchema and
|
|
393
397
|
// are covered by `targets` below, so their behaviour is unchanged.
|
|
394
|
-
if (!declared || declared[field] === undefined) continue;
|
|
398
|
+
if (!declared || declared[field] === undefined || scopeSkips.has(field)) continue;
|
|
395
399
|
if (tokens[token] !== undefined) out[field] = tokens[token];
|
|
396
400
|
}
|
|
397
401
|
const fields = definition.targets[manifestId];
|
|
398
402
|
if (!fields) continue;
|
|
399
403
|
for (const [token, field] of Object.entries(fields)) {
|
|
400
|
-
if (tokens[token] !== undefined) out[field] = tokens[token];
|
|
404
|
+
if (tokens[token] !== undefined && !scopeSkips.has(field)) out[field] = tokens[token];
|
|
401
405
|
}
|
|
402
406
|
}
|
|
403
407
|
// REQ-THEME-ELEMENT: the per-WIDGET-TYPE values land last of the theme layers,
|
|
@@ -412,13 +416,25 @@ function componentStyleFor(manifestId, components, styleSchema, widgetStyles) {
|
|
|
412
416
|
return Object.keys(out).length > 0 ? out : null;
|
|
413
417
|
}
|
|
414
418
|
|
|
415
|
-
// The general button colours
|
|
419
|
+
// The general button colours, as against the look's shape and size.
|
|
416
420
|
const GENERAL_BUTTON_PAINT = Object.freeze(["background", "gradient", "textColor", "borderColor"]);
|
|
421
|
+
const GENERAL_BUTTON_PAINT_SET = new Set(GENERAL_BUTTON_PAINT);
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* The Buttons scope's colours paint the primary button only, so a page keeps
|
|
425
|
+
* its hierarchy: secondary and outlined draw their own surface and border
|
|
426
|
+
* tokens. The maker's Button widget colours (`widgetStyles`) still reach
|
|
427
|
+
* them, and the look's shape, size and shadow still apply.
|
|
428
|
+
*/
|
|
429
|
+
function scopeSkipsFor(manifestId, props) {
|
|
430
|
+
if (manifestId !== "appstudio.button") return NO_SKIPS;
|
|
431
|
+
return resolveButtonVariant(props.variant) === "primary" ? NO_SKIPS : GENERAL_BUTTON_PAINT_SET;
|
|
432
|
+
}
|
|
417
433
|
|
|
418
434
|
/**
|
|
419
435
|
* A danger button is coloured by the `destructive` scope (its `danger*`
|
|
420
|
-
* fields) over the variant's danger colour, so
|
|
421
|
-
* colours
|
|
436
|
+
* fields) over the variant's danger colour, so no theme layer's general
|
|
437
|
+
* button colours reach it. Its own `props.style` still wins.
|
|
422
438
|
*/
|
|
423
439
|
function withoutGeneralButtonPaint(manifestId, props, themed) {
|
|
424
440
|
if (manifestId !== "appstudio.button" || props.variant !== "danger") return themed;
|
|
@@ -454,13 +470,14 @@ function withoutGeneralButtonPaint(manifestId, props, themed) {
|
|
|
454
470
|
* @returns {object} props, with `style` folded when anything applies.
|
|
455
471
|
*/
|
|
456
472
|
function applyThemeComponentStyle(manifestId, theme, props, styleSchema) {
|
|
473
|
+
const base = isPlainObject(props) ? props : {};
|
|
457
474
|
const themed = componentStyleFor(
|
|
458
475
|
manifestId,
|
|
459
476
|
theme && theme.components,
|
|
460
477
|
styleSchema,
|
|
461
478
|
theme && theme.widgetStyles,
|
|
479
|
+
scopeSkipsFor(manifestId, base),
|
|
462
480
|
);
|
|
463
|
-
const base = isPlainObject(props) ? props : {};
|
|
464
481
|
const authored = isPlainObject(base.style) ? base.style : null;
|
|
465
482
|
if (!themed) {
|
|
466
483
|
const floored = floorStyleFontSizes(authored, styleSchema);
|
package/dist/theme-components.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import { CONTRACT, normaliseComponentGradient } from "./contract.js";
|
|
19
19
|
import { isPlainObject } from "./plain-object.js";
|
|
20
|
+
import { resolveButtonVariant } from "./button-variants.js";
|
|
20
21
|
|
|
21
22
|
// 3-, 6- and 8-digit hex, matching what the build runner persists — the host
|
|
22
23
|
// must never drop a colour the runner already accepted.
|
|
@@ -341,6 +342,8 @@ function styleSchemaDefaults(styleSchema) {
|
|
|
341
342
|
return out;
|
|
342
343
|
}
|
|
343
344
|
|
|
345
|
+
const NO_SKIPS = new Set();
|
|
346
|
+
|
|
344
347
|
/**
|
|
345
348
|
* The per-component style fields that apply to one widget, keyed by the
|
|
346
349
|
* `styleSchema` field name the widget actually reads. A widget may sit in more
|
|
@@ -355,10 +358,11 @@ function styleSchemaDefaults(styleSchema) {
|
|
|
355
358
|
* component scopes, then `widgetStyles[manifestId]`. The caller spreads the
|
|
356
359
|
* per-instance `props.style` last, so the full order is
|
|
357
360
|
* styleSchema default -> palette/scopes -> widgetStyles -> props.style.
|
|
361
|
+
* `scopeSkips` names fields the scopes may not set; widgetStyles still may.
|
|
358
362
|
*
|
|
359
363
|
* @returns {Record<string, unknown>|null} null when nothing applies.
|
|
360
364
|
*/
|
|
361
|
-
function componentStyleFor(manifestId, components, styleSchema, widgetStyles) {
|
|
365
|
+
function componentStyleFor(manifestId, components, styleSchema, widgetStyles, scopeSkips = NO_SKIPS) {
|
|
362
366
|
if (typeof manifestId !== "string") return null;
|
|
363
367
|
const validated = normaliseThemeComponents(components);
|
|
364
368
|
// sc-6750: the author's declared defaults are the WEAKEST layer, so they go
|
|
@@ -386,13 +390,13 @@ function componentStyleFor(manifestId, components, styleSchema, widgetStyles) {
|
|
|
386
390
|
// that reads named fields, but a widget spreading `props.style` onto a
|
|
387
391
|
// View would get an unknown style key. Built-ins thread no styleSchema and
|
|
388
392
|
// are covered by `targets` below, so their behaviour is unchanged.
|
|
389
|
-
if (!declared || declared[field] === undefined) continue;
|
|
393
|
+
if (!declared || declared[field] === undefined || scopeSkips.has(field)) continue;
|
|
390
394
|
if (tokens[token] !== undefined) out[field] = tokens[token];
|
|
391
395
|
}
|
|
392
396
|
const fields = definition.targets[manifestId];
|
|
393
397
|
if (!fields) continue;
|
|
394
398
|
for (const [token, field] of Object.entries(fields)) {
|
|
395
|
-
if (tokens[token] !== undefined) out[field] = tokens[token];
|
|
399
|
+
if (tokens[token] !== undefined && !scopeSkips.has(field)) out[field] = tokens[token];
|
|
396
400
|
}
|
|
397
401
|
}
|
|
398
402
|
// REQ-THEME-ELEMENT: the per-WIDGET-TYPE values land last of the theme layers,
|
|
@@ -407,13 +411,25 @@ function componentStyleFor(manifestId, components, styleSchema, widgetStyles) {
|
|
|
407
411
|
return Object.keys(out).length > 0 ? out : null;
|
|
408
412
|
}
|
|
409
413
|
|
|
410
|
-
// The general button colours
|
|
414
|
+
// The general button colours, as against the look's shape and size.
|
|
411
415
|
const GENERAL_BUTTON_PAINT = Object.freeze(["background", "gradient", "textColor", "borderColor"]);
|
|
416
|
+
const GENERAL_BUTTON_PAINT_SET = new Set(GENERAL_BUTTON_PAINT);
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* The Buttons scope's colours paint the primary button only, so a page keeps
|
|
420
|
+
* its hierarchy: secondary and outlined draw their own surface and border
|
|
421
|
+
* tokens. The maker's Button widget colours (`widgetStyles`) still reach
|
|
422
|
+
* them, and the look's shape, size and shadow still apply.
|
|
423
|
+
*/
|
|
424
|
+
function scopeSkipsFor(manifestId, props) {
|
|
425
|
+
if (manifestId !== "appstudio.button") return NO_SKIPS;
|
|
426
|
+
return resolveButtonVariant(props.variant) === "primary" ? NO_SKIPS : GENERAL_BUTTON_PAINT_SET;
|
|
427
|
+
}
|
|
412
428
|
|
|
413
429
|
/**
|
|
414
430
|
* A danger button is coloured by the `destructive` scope (its `danger*`
|
|
415
|
-
* fields) over the variant's danger colour, so
|
|
416
|
-
* colours
|
|
431
|
+
* fields) over the variant's danger colour, so no theme layer's general
|
|
432
|
+
* button colours reach it. Its own `props.style` still wins.
|
|
417
433
|
*/
|
|
418
434
|
function withoutGeneralButtonPaint(manifestId, props, themed) {
|
|
419
435
|
if (manifestId !== "appstudio.button" || props.variant !== "danger") return themed;
|
|
@@ -449,13 +465,14 @@ function withoutGeneralButtonPaint(manifestId, props, themed) {
|
|
|
449
465
|
* @returns {object} props, with `style` folded when anything applies.
|
|
450
466
|
*/
|
|
451
467
|
export function applyThemeComponentStyle(manifestId, theme, props, styleSchema) {
|
|
468
|
+
const base = isPlainObject(props) ? props : {};
|
|
452
469
|
const themed = componentStyleFor(
|
|
453
470
|
manifestId,
|
|
454
471
|
theme && theme.components,
|
|
455
472
|
styleSchema,
|
|
456
473
|
theme && theme.widgetStyles,
|
|
474
|
+
scopeSkipsFor(manifestId, base),
|
|
457
475
|
);
|
|
458
|
-
const base = isPlainObject(props) ? props : {};
|
|
459
476
|
const authored = isPlainObject(base.style) ? base.style : null;
|
|
460
477
|
if (!themed) {
|
|
461
478
|
const floored = floorStyleFontSizes(authored, styleSchema);
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -2512,11 +2512,11 @@ const HOOKS = [
|
|
|
2512
2512
|
signature: "usePayments()",
|
|
2513
2513
|
returnShape: {
|
|
2514
2514
|
requestPayment:
|
|
2515
|
-
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column (orderTotal; without one: ORDER_NOT_PAYABLE) and the server
|
|
2515
|
+
"({ amount_cents?, currency?, description, kind, return_path?, order? }) => Promise<{ id, status, order }> // kind is REQUIRED: \"physical\" | \"service\" | \"digital\" — what is sold; a digital charge is refused in an iOS/Android build (DIGITAL_SALE_NEEDS_STORE_BILLING); amount_cents (minor units) is REQUIRED without order; order: { table_id, record_id } — the order row this pays for, in a table with a payment-status column; the SERVER marks it paid when the payment settles, so never write \"paid\" yourself (refused: ORDER_NOT_FOUND, ORDER_NOT_PAYABLE, ORDER_ALREADY_PAID; ORDER_PAYMENT_IN_PROGRESS is retryable while another checkout for the order is open). The orders table also REQUIRES an order-total column the server prices (orderTotal: { lines, via } in the datastoreTemplate; without one: ORDER_NOT_PAYABLE): create the order, then its lines, then pass order and omit amount_cents — the server sums quantity × the products table's unitPrice (plus the order's own pricedItem, e.g. shipping), writes the total and charges it; never compute, write or send a total (if amount_cents is sent it must equal the total; refused, not retryable: ORDER_LINES_INVALID when the lines cannot be priced, ORDER_TOTAL_INVALID when the total is zero, ORDER_AMOUNT_MISMATCH when amount_cents differs; ORDER_NOT_PAYABLE also when the payer could write or create a price). Once priced, the order's lines are fixed (adding or removing one: ORDER_LOCKED); host opens hosted Checkout; rejects with PaymentError { code, message, retryable } — render the message when retryable is false, never \"try again\"",
|
|
2516
2516
|
getPayment:
|
|
2517
2517
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2518
2518
|
requestGuestPayment:
|
|
2519
|
-
"({ 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
|
|
2519
|
+
"({ 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 a server-priced order-total column, as for requestPayment: create the order, then its lines, 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 orders table needs a buyerEmail column the order is created with: the platform emails the order confirmation there, and an order without a valid address is refused with BUYER_EMAIL_INVALID (not retryable). 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",
|
|
2520
2520
|
getGuestPayment:
|
|
2521
2521
|
"(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",
|
|
2522
2522
|
},
|
|
@@ -3985,7 +3985,7 @@ const PRIMITIVES = [
|
|
|
3985
3985
|
{
|
|
3986
3986
|
name: "Button",
|
|
3987
3987
|
description:
|
|
3988
|
-
'Themed button. `<Button title="Save" onPress={save} />` — use it by default for a button: its fill, label colour, border, corner radius, padding, weight, shadow and gradient come from the app\'s button look (Design > Components > Buttons, and Danger buttons / Button outline for the danger variant and emphasis border), so it matches the built-in Button widget. Props: `title`, `onPress` (omit it for a purely visual button inside something else that is pressable), `variant` ("primary" default | "secondary" | "outlined" | "danger" | "ghost", no fill or border with the accent as its label, for a quiet action such as "Load more" or "Cancel" | "link", underlined accent text with no side padding, for an inline action), `size` ("sm", 36px high | "md", 44px, the default | "lg", 52px), `busy` (an action in flight: a `<Spinner>` over the label, which stays the button\'s accessible name and keeps its width, and the button cannot be pressed; use it for a save or an upload instead of swapping the label), `selected` (a toggle\'s on state, drawn in the accent\'s quiet tint; omit it for a plain button), `icon` (a lucide name) with `iconPosition` ("leading" | "trailing"), `disabled`, `accessibilityLabel`, `testID`, `style` (extra container style) and `labelStyle`. It hugs its label and follows its parent\'s alignment: centred in a column with `alignItems: "center"`, vertically centred in such a row, at the start of a plain column. A `style` with `alignSelf`, `flex` or a percentage width makes it an ordinary flex item the parent may stretch. Pass `fields` — `{ background, textColor, borderColor, borderWidth, paddingX, paddingY, radius, fontWeight, fontSize, shadow, gradient }` — to override one button, e.g. from style fields your widget declares. A ghost or link button takes the look\'s shape and type but not its fill, border, shadow or label colour, unless you pass them in `fields`. On a section that paints its own fill (`theme.colors.backdrop` there), a variant colour that the section makes unreadable takes that section\'s text colour, as its text does: an outlined label and border, a secondary whose fill disappears becomes outlined, and a primary or danger fill turns inverse (that text colour as its fill, its own colour as its label). A white or lightly tinted panel changes nothing, and a button inside a `<Card>` is measured against that card. A colour you pass in `fields`, `style` or `labelStyle`, or that the app\'s button look sets, is never changed. A button with only an icon is `<IconButton>`. For any other button, when the request needs one it cannot draw (a round floating action button, a tile with an image and two lines of text, a split button with a menu half), build your own from `Pressable` with `pressableLift` in the app\'s look (theme colours, radii and spacing), at least 44px high (a compact icon control in a dense row may go down to 36px, never below) and with an `accessibilityLabel`.',
|
|
3988
|
+
'Themed button. `<Button title="Save" onPress={save} />` — use it by default for a button: its fill, label colour, border, corner radius, padding, weight, shadow and gradient come from the app\'s button look (Design > Components > Buttons, and Danger buttons / Button outline for the danger variant and emphasis border), so it matches the built-in Button widget. The look\'s fill, gradient, label colour and border colour paint the `primary` button only: every other variant keeps its own colours (a `secondary` the theme\'s secondary and border colours, an `outlined` the accent as its border and label, a `danger` the Danger buttons colours) and takes the look\'s shape, size, weight and shadow, so a page\'s secondary actions stay quieter than its main one. Props: `title`, `onPress` (omit it for a purely visual button inside something else that is pressable), `variant` ("primary" default | "secondary" | "outlined" | "danger" | "ghost", no fill or border with the accent as its label, for a quiet action such as "Load more" or "Cancel" | "link", underlined accent text with no side padding, for an inline action; any other value is a check error), `size` ("sm", 36px high | "md", 44px, the default | "lg", 52px), `busy` (an action in flight: a `<Spinner>` over the label, which stays the button\'s accessible name and keeps its width, and the button cannot be pressed; use it for a save or an upload instead of swapping the label), `selected` (a toggle\'s on state, drawn in the accent\'s quiet tint; omit it for a plain button), `icon` (a lucide name) with `iconPosition` ("leading" | "trailing"), `disabled`, `accessibilityLabel`, `testID`, `style` (extra container style) and `labelStyle`. It hugs its label and follows its parent\'s alignment: centred in a column with `alignItems: "center"`, vertically centred in such a row, at the start of a plain column. A `style` with `alignSelf`, `flex` or a percentage width makes it an ordinary flex item the parent may stretch. Pass `fields` — `{ background, textColor, borderColor, borderWidth, paddingX, paddingY, radius, fontWeight, fontSize, shadow, gradient }` — to override one button, e.g. from style fields your widget declares. A ghost or link button takes the look\'s shape and type but not its fill, border, shadow or label colour, unless you pass them in `fields`. On a section that paints its own fill (`theme.colors.backdrop` there), a variant colour that the section makes unreadable takes that section\'s text colour, as its text does: an outlined label and border, a secondary whose fill disappears becomes outlined, and a primary or danger fill turns inverse (that text colour as its fill, its own colour as its label). A white or lightly tinted panel changes nothing, and a button inside a `<Card>` is measured against that card. A colour you pass in `fields`, `style` or `labelStyle`, or that the app\'s button look sets, is never changed. A button with only an icon is `<IconButton>`. For any other button, when the request needs one it cannot draw (a round floating action button, a tile with an image and two lines of text, a split button with a menu half), build your own from `Pressable` with `pressableLift` in the app\'s look (theme colours, radii and spacing), at least 44px high (a compact icon control in a dense row may go down to 36px, never below) and with an `accessibilityLabel`.',
|
|
3989
3989
|
rnComponent: null,
|
|
3990
3990
|
docsUrl: null,
|
|
3991
3991
|
},
|
|
@@ -4385,7 +4385,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4385
4385
|
type: "object",
|
|
4386
4386
|
required: false,
|
|
4387
4387
|
description:
|
|
4388
|
-
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal:
|
|
4388
|
+
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: { lines: \"<lines table suffix>\", via: \"<its relation to this table>\" }` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The SERVER prices it when the charge opens and ignores any client value: Σ over the order's lines of `lineQuantity` × the `unitPrice` of the row the line's `pricedItem` names, plus the order table's own `pricedItem` once (a shipping option). `via` is a write-once ONE_TO_MANY relation on the lines table pointing at this table. A bare `orderTotal: true` is accepted only on an orders table that has its own `pricedItem`; publishing any other unpriced order total is refused (an already published template still installs, and its order charges are refused with ORDER_NOT_PAYABLE). `unitPrice: true` makes a NUMBER column a product's price in minor units (one per table). `pricedItem: true` makes a write-once single RELATION (one per table) to a table with a unitPrice column the item a line or an order is priced by. `lineQuantity: true` makes a write-once NUMBER column (one per table) a line's quantity, a whole number from 1 to 999 (empty is 1). A payer who may edit or create rows in a priced table is refused, and once an order holds its total no line is added or removed (ORDER_LOCKED). `buyerEmail: true` makes a STRING column the buyer's email address, at most one per table, only in a table with a paymentStatus column, and it must be `immutable: true` (not encrypted, latestVia or copyOf): when a charge marks the order paid the platform emails the buyer an order confirmation (a guest at this address, a signed-in buyer at their account's address), and a refund notice after a full refund, so a widget never sends its own. A guest charge (`requestGuestPayment`) for an order whose table has no buyerEmail column, or whose address is empty or invalid, is refused. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4389
4389
|
},
|
|
4390
4390
|
translations: {
|
|
4391
4391
|
type: "object",
|
|
@@ -7187,7 +7187,15 @@ const CONTRACT = deepFreeze({
|
|
|
7187
7187
|
// covers a run found on mount, cancel() really stops it and send() resolves
|
|
7188
7188
|
// with the stopped row, messages carry `outcome`, and a send during a run
|
|
7189
7189
|
// rejects TURN_IN_PROGRESS. A rejection says `stored` when the message was kept.
|
|
7190
|
-
|
|
7190
|
+
// 1.289.0 (sc-16651): the server prices an order. Template columns
|
|
7191
|
+
// `unitPrice`, `pricedItem`, `lineQuantity` and `orderTotal: { lines, via }`;
|
|
7192
|
+
// an unpriced order total is refused at publish and its order charges
|
|
7193
|
+
// with ORDER_NOT_PAYABLE (breaking for those). New PaymentError code
|
|
7194
|
+
// ORDER_LINES_INVALID; a priced order's line writes refuse ORDER_LOCKED.
|
|
7195
|
+
// 1.290.0: stricter lint (sc-17804) — the app's button colours paint the
|
|
7196
|
+
// primary `<Button>` only, and a literal `variant` the button does not
|
|
7197
|
+
// draw is the publish-blocking `button-unknown-variant` finding.
|
|
7198
|
+
version: "1.290.0",
|
|
7191
7199
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7192
7200
|
hooks: HOOKS,
|
|
7193
7201
|
primitives: PRIMITIVES,
|