@colixsystems/widget-sdk 0.347.0 → 0.349.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 +17 -3
- package/dist/contract.cjs +10 -4
- package/dist/contract.js +10 -4
- package/dist/hooks.js +3 -0
- package/dist/index.d.ts +19 -2
- package/dist/linter.cjs +172 -0
- package/dist/linter.js +172 -0
- package/package.json +1 -1
- package/src/contract.js +10 -4
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ The data layer lives in **four separate domain-client packages**, each instantia
|
|
|
77
77
|
| **FILESTORE** (`ctx.filestore`) | `usePdfExport({ spaceType, folderId })` (optional: spaceType, folderId) | `{ openPdf, opening, canOpenPdf, exportToPdf, exporting, error, lastExported }` | `ctx.filestore.files.renderPdf` + `ctx.device.pdfViewer`, `ctx.filestore.files.exportPdf` — `files.write:*`. `openPdf(html, { fileName? })` renders the HTML to a PDF server-side and OPENS it (web: PDF tab; native: print / share sheet) without saving. `exportToPdf(html, { fileName?, folderId? })` renders it and saves it as a file (`application/pdf`). Same server-side renderer on web + native. |
|
|
78
78
|
| **PAYMENTS** (`ctx.payments`) | `useAccessPlans()` | `{ plans, loading, error, purchaseAvailable, purchase, cancel, refresh }` | `ctx.payments.{listAccessPlans,purchaseAccessPlan,cancelAccessPlan}` — `payments.charge:appUser`. Plans selling access to restricted pages; `purchase(planId)` names only the plan, the server sets price and group. A held plan's `member_since` is when the user became a member (first paid charge, else when access was granted). `purchaseAvailable` is `false` in an iOS / Android build (digital goods need store billing): show a visible not-available state. |
|
|
79
79
|
| **PAYMENTS** (`ctx.payments`) | `useAppSubscription()` | `{ subscription, loading, error, cancel, refresh }` | `ctx.payments.{getAppSubscription,cancelAppSubscription}` — `payments.charge:appUser`. The signed-in user's subscription to a paid app (`{ active, renews, access_ends_at, member_since }`); `cancel()` stops it renewing, and access runs to `access_ends_at`. `member_since` is when they became a subscriber. |
|
|
80
|
-
| **PAYMENTS** (`ctx.payments`) | `usePayments()` | `{ requestPayment, getPayment, requestGuestPayment, getGuestPayment }` | `ctx.payments.*` — `payments.charge:appUser`; guest checkout (`requestGuestPayment`, a visitor with no account buying physical goods for an order they created) also `payments.charge:guest`. `requestPayment` requires `kind` (`"physical"` \| `"service"` \| `"digital"`): what is sold. A call without it is a publish-blocking `payment-kind-required` finding. A `"digital"` charge is refused in an iOS or Android build (`DIGITAL_SALE_NEEDS_STORE_BILLING`). Selling an order (goods, a booking, a ticket)? The orders table needs a payment-status column AND an order-total column (a write-once NUMBER holding the total in minor units). Create the row with its total, then pass `order: { table_id, record_id }` and omit `amount_cents` (or send the same value): the server charges the stored total, and only the payment marks the order paid, so never write a paid status yourself (a `payment-status-written` finding). The server refuses an order it cannot settle with `ORDER_NOT_FOUND`, `ORDER_NOT_PAYABLE` (also: no order-total column), `ORDER_ALREADY_PAID`, `ORDER_TOTAL_INVALID` or `ORDER_AMOUNT_MISMATCH`, none retryable. Rejects with `PaymentError { code, message, retryable }`; when `retryable` is `false` show `message` and drop the retry. Charges are accepted ONLY in the currency the workspace sells in — omit `currency` and the platform applies it (a disagreeing literal is a publish-blocking `payment-currency` finding). |
|
|
80
|
+
| **PAYMENTS** (`ctx.payments`) | `usePayments()` | `{ requestPayment, getPayment, requestGuestPayment, getGuestPayment }` | `ctx.payments.*` — `payments.charge:appUser`; guest checkout (`requestGuestPayment`, a visitor with no account buying physical goods for an order they created) also `payments.charge:guest`. `requestPayment` requires `kind` (`"physical"` \| `"service"` \| `"digital"`): what is sold. A call without it is a publish-blocking `payment-kind-required` finding. A `"digital"` charge is refused in an iOS or Android build (`DIGITAL_SALE_NEEDS_STORE_BILLING`). Selling an order (goods, a booking, a ticket)? The orders table needs a payment-status column AND an order-total column (a write-once NUMBER holding the total in minor units). Create the row with its total, then pass `order: { table_id, record_id }` and omit `amount_cents` (or send the same value): the server charges the stored total, and only the payment marks the order paid, so never write a paid status yourself (a `payment-status-written` finding). The server refuses an order it cannot settle with `ORDER_NOT_FOUND`, `ORDER_NOT_PAYABLE` (also: no order-total column), `ORDER_ALREADY_PAID`, `ORDER_TOTAL_INVALID` or `ORDER_AMOUNT_MISMATCH`, none retryable. Give the table a `buyerEmail` column too: the platform emails the buyer's order confirmation and refund notice, and a guest charge needs a valid address there (`BUYER_EMAIL_INVALID`). Rejects with `PaymentError { code, message, retryable }`; when `retryable` is `false` show `message` and drop the retry. Charges are accepted ONLY in the currency the workspace sells in — omit `currency` and the platform applies it (a disagreeing literal is a publish-blocking `payment-currency` finding). |
|
|
81
81
|
| **NOTIFICATIONS** (`ctx.notifications`) | `useSendNotification()` | `{ send, sending, error }` | `ctx.notifications.send` — `notifications.send:appUser`. `send({ recipient_user_id, title, body, link?, payload? })` notifies one app user in the same workspace; call from an event handler (never render); rejects with `NotificationError`. |
|
|
82
82
|
| **NOTIFICATIONS** (`ctx.notifications`) | `useRecordMutes(tableId)` | `{ isMuted, loading, error, refetch }` | `ctx.notifications.mutes` — no scope. Which records of one table the signed-in user has muted, in one request for a whole list; `isMuted(recordId)` turns false when a timed mute lapses, and a `useRecordMute` write shows at once. |
|
|
83
83
|
| **NOTIFICATIONS** (`ctx.notifications`) | `useRecordMute(tableId, recordId)` | `{ muted, mutedUntil, loading, error, mute, unmute, refetch }` | `ctx.notifications.mutes` — no scope. Mutes one record's notifications for the signed-in user, `mute(until)` with an ISO time, a `Date`, or `null` for until unmuted. Needs read access to the record (`RECORD_NOT_FOUND` otherwise). |
|
|
@@ -91,7 +91,17 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
94
|
+
`v0.349.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.349.0 (contract 1.286.0)
|
|
97
|
+
|
|
98
|
+
**A full-screen `<Overlay>` draws its own close control, and the new linter rule `full-overlay-no-close` (severity `warning`, non-blocking) flags the clearest case.** `onRequestClose` fires on the backdrop, the Escape key and the Android back button; at `size="full"` there is no backdrop, and an iPhone has no back button, so content with no close of its own traps the user. Draw a visible close (or pause) button inside the overlay that runs the same handler, padded by `useSafeAreaInsets()`. The rule flags only plain display content (text, pictures, video, layout) in an overlay that a press opens. A press handler, a spread, a component of your own or a state that code clears keeps it quiet, so a quiet rule is no proof of a close.
|
|
99
|
+
|
|
100
|
+
Use `size="full"` for content that needs the whole screen or uninterrupted touch: a game, an image, video or PDF preview, a lightbox, a signature or drawing pad, a map's full view, a slideshow. Open it from an inline launcher (a thumbnail, a title card, a button): inside the page, every drag scrolls the page instead.
|
|
101
|
+
|
|
102
|
+
### What's new in 0.348.0 (contract 1.285.0)
|
|
103
|
+
|
|
104
|
+
**The platform emails the buyer's order confirmation.** A guest buyer has no account, so nothing a shop built could reach them after they paid. An orders table with a payment-status column can now have one buyer-email column: a STRING column, write-once (`immutable: true`), declared with `buyerEmail: true` in a `datastoreTemplate`. Write the buyer's address into it when creating the order. When a charge marks the order paid, the platform emails the buyer an order confirmation (the shop and the business behind it, a short order reference, the amount and the date paid) through the workspace's own email provider when one is connected; a full refund sends a refund notice the same way. A guest's mail goes to the buyer-email cell, a signed-in buyer's to their account's address. Each is sent once, however often the payment is reported. `requestGuestPayment` for an order whose table has no buyer-email column answers `ORDER_NOT_PAYABLE`, and one whose address is empty or invalid answers the new non-retryable `BUYER_EMAIL_INVALID`. Do not build a confirmation email of your own.
|
|
95
105
|
|
|
96
106
|
### What's new in 0.347.0 (contract 1.284.0)
|
|
97
107
|
|
|
@@ -2750,6 +2760,9 @@ Start the reading from a **user gesture** on both hosts — iOS Safari also need
|
|
|
2750
2760
|
|
|
2751
2761
|
```jsx
|
|
2752
2762
|
<Overlay visible={!!preview} onRequestClose={() => setPreview(null)} size="full">
|
|
2763
|
+
<View style={{ paddingTop: insets.top, paddingRight: insets.right, alignItems: "flex-end" }}>
|
|
2764
|
+
<IconButton icon="x" accessibilityLabel="Close" onPress={() => setPreview(null)} />
|
|
2765
|
+
</View>
|
|
2753
2766
|
<ScrollView>{renderPreview(preview)}</ScrollView>
|
|
2754
2767
|
</Overlay>
|
|
2755
2768
|
```
|
|
@@ -2790,6 +2803,7 @@ Additive — one new hook, one new optional context-slice member; no existing ex
|
|
|
2790
2803
|
**Two linter rules make the styling contract checkable, and `lintStyleWiring` joins the linter export (sc-6455).** Every visual value a widget writes reaches the app's owner through one of exactly two channels — a **theme token** (`useTheme()`), which is the app-wide default and follows a look change, or a **`styleSchema` field** read off `props.style`, which the Studio offers per instance in the widget editor *and* app-wide under **Design → Widget appearance**. A literal reaches neither: it outranks the theme permanently and no control on either surface can move it, so the owner finds a corner of their app they cannot restyle. Until now that rule was documentation only.
|
|
2791
2804
|
|
|
2792
2805
|
- **`no-hardcoded-design`** flags a colour literal (`#rgb` / `#rrggbb` / `#rrggbbaa`, `rgb()`, `rgba()`, `hsl()`, `hsla()`), a `fontFamily` string literal or (since 0.326.0) a family named as the fallback of a font read (`style.titleFont || "Lora"`), a numeric `fontSize`, or (since 0.165.0) a literal non-zero corner radius (`borderRadius: 12`, any per-corner spelling). A `fontSize` resolved off a theme token or a style field (`style.valueSize ?? 18`) is *not* flagged — a literal `default` beside a declared field is the contract working — and neither is a computed radius (`size / 2`) or `0`. Raw `padding` / `margin` numbers are deliberately out of scope: measured layout legitimately carries them, so a spacing rule would be noise.
|
|
2806
|
+
- **`full-overlay-no-close`** flags an `<Overlay size="full">` that only displays content, with no control to close it. Add a visible close or pause button that runs the same handler as `onRequestClose`.
|
|
2793
2807
|
- **`style-field-unread`** flags a `styleSchema` field whose name appears nowhere in the widget's source — a dead control the author moves to no effect. It runs over the WHOLE bundle, not per file, so a split-impl widget that reads a field in `widget.web.jsx` and not in `widget.native.jsx` is correctly counted as wired. Since 0.343.2 a field is also read when the widget hands its own style (from `useWidgetStyle()` or `props.style`) whole to the SDK consumer that paints it: `<Card style={style}>` (less a field a `<Card>` prop overrides, `margin` under `withoutMargin` and `cardGradient` on a photo card), `cardOverlay`, `cardSurfaceStyle`, `cardGradientProps` or `marginStyle`, imported from the SDK.
|
|
2794
2808
|
|
|
2795
2809
|
A value that genuinely cannot be a token — a categorical series palette, a video letterbox, a scannable QR plate — is licensed with a preceding comment. **The reason is mandatory**; a bare marker licenses nothing. A marker on its own line covers the whole statement below it (bracket-balanced, so one marker covers a multi-line palette); a trailing marker covers only its own line.
|
|
@@ -3774,7 +3788,7 @@ import { defineWidget, validateManifest, useDatastoreQuery, Text, View } from "@
|
|
|
3774
3788
|
- `useDatastoreQuery`, `useDatastoreRecord`, `useDatastoreSchema`, `useDatastoreMutation`, `useDirectory`, `useUsers`, `useGroups`, `useRecordPermissions`, `useAsset`, `useWidgetEvent`, `useWidgetInput`, `usePayments`, `useSendNotification`, `useTheme`, `useI18n`, `useUser`, `useNavigation`, `useRouteParams`, `usePageContext`, `useWidgetRoute`, `useChildRenderer`, `useClipboard`, `useToast` — hooks that read from the host-provided `WidgetContext` (or, for `useClipboard`, the platform clipboard API directly). `useDirectory(query?)` returns `{ users, loading, error, refetch }` (each user `{ id, name, role }`) and requires the `directory.read:users` scope. `useUsers(query?)` returns `{ users, loading, error, refetch, invite, deactivate, reactivate, remove }` and requires `users.read:*` (mutations also need `users.write:*`); rejections are a `DirectoryError`. `useGroups(query?)` returns `{ groups, loading, error, refetch, create, remove, addMember, removeMember }` and requires `groups.read:*` (mutations also need `groups.write:*`). `usePayments()` returns `{ requestPayment, getPayment }` and requires the `payments.charge:appUser` scope; `requestPayment(...)` rejects with a `PaymentError` carrying `code`, the server's user-safe `message`, and `retryable` (`false` = this charge cannot succeed until the workspace, manifest, or amount changes — show the message, not a retry). `useSendNotification()` returns `{ send, sending, error }` and requires the `notifications.send:appUser` scope; `send({ recipient_user_id, title, body, link?, payload? })` notifies one app user in the same workspace (cross-workspace `recipient_user_id` is rejected), must be called from an event handler rather than render, and rejects with a `NotificationError`. `useUser()` returns the active end-user identity `{ id, email, displayName, roles, groupIds }` (camelCase — the host-built context object, not a wire payload; `id` is `null` for anonymous / preview). `useNavigation()` returns `{ goTo, goToStartPage, scrollToSection, scrollIntoView, goBack, push, replace, back, currentRoute, openLink }` for internal page navigation; `goToStartPage()` opens the signed-in user's own start page (the page the app opens on for them); `scrollToSection(sectionId)` scrolls the current page to one of its sections (bind the id with a `sectionRef` prop); `scrollIntoView(ref)` scrolls it to an element inside the calling widget; `openLink(link)` follows an author- or data-supplied link of unknown shape through the host's shared resolver (in-app page → internal route, off-app http(s) → opened outside, unsafe → refused) and is the safe choice for any value your code did not construct, while `Linking.openURL(url)` is for an external URL you built yourself. `useRouteParams()` returns the current route's params object (`currentRoute.params`) — the flat master→detail accessor; read a param off it (e.g. `recordId`), never call it. `useDatastoreRecord(tableId, recordId)` returns `{ data, loading, error, refetch }` for a single record (data is one row or null). `useDatastoreSchema(tableId)` returns `{ schema, loading, error, refetch }` where `schema` is `{ id, name, columns: [{ id, name, data_type, required, relation_type, target_table_id, is_identification }] }` (structure only, no row data; snake_case verbatim) — use it to resolve a stored `columnId` to its column type at runtime; requires the `datastore.read:<table>` scope. `useAsset(fileId)` returns `{ url, file, loading, error, refetch }` — the `url` is an absolute URL composed against the host's API base. `useChildRenderer()` returns `{ renderNode(node) }` — container widgets call it to render arbitrary child page-tree nodes (prefer the `WidgetTree` component for the common case). `useWidgetInput(inputName)` returns the latest payload a sibling widget published on the event the page author wired to this widget's declared `inputs` entry (`undefined` when unwired or not yet published).
|
|
3775
3789
|
- `WidgetTree({ node })` — component that renders an author-authored child node through the host's renderer; used by Tabs / Card / custom containers to host arbitrary child widgets.
|
|
3776
3790
|
- `Text`, `View`, `Pressable`, `Image`, `ScrollView`, `TextInput`, `FlatList`, `SectionList`, `ActivityIndicator`, `Switch`, `StyleSheet`, `Linking`, `Icon`, `DateTimePicker` — re-exported from `react-native` (the RN primitives) or implemented in the SDK (`Icon` wraps `lucide-react-native`; `DateTimePicker` wraps `@react-native-community/datetimepicker` on native and renders `<input type="date|time|datetime-local">` directly on web because the RN library has no react-native-web mapping). The web build aliases `react-native` to `react-native-web` so the RN-re-exported primitives render in the browser without any per-platform code; the exported Expo app's Metro bundler resolves the real `react-native` library. `Linking` is a static API (`Linking.openURL(url)`) — use it for external URLs, and use `useNavigation().goTo(pageId)` for internal page navigation. See https://reactnative.dev/docs/ for per-component props.
|
|
3777
|
-
- `Overlay` — the screen-level overlay. `<Overlay visible={!!preview} onRequestClose={() => setPreview(null)} size="full">…</Overlay>` renders its children OUTSIDE the widget's layout box on both hosts (web portals it to the document root, native uses the OS modal), so no clipping card, `ScrollView` or neighbouring widget can cut off a document/media preview, lightbox or confirm dialog — which absolute positioning inside the widget cannot achieve on either platform. Children stay in your own React tree, so state and hooks work normally. `onRequestClose` carries the backdrop press, Escape on web, and the Android back button; `size` is `sm` | `md` (default) | `lg` | `full
|
|
3791
|
+
- `Overlay` — the screen-level overlay. `<Overlay visible={!!preview} onRequestClose={() => setPreview(null)} size="full">…</Overlay>` renders its children OUTSIDE the widget's layout box on both hosts (web portals it to the document root, native uses the OS modal), so no clipping card, `ScrollView` or neighbouring widget can cut off a document/media preview, lightbox or confirm dialog — which absolute positioning inside the widget cannot achieve on either platform. Children stay in your own React tree, so state and hooks work normally. `onRequestClose` carries the backdrop press, Escape on web, and the Android back button; `size` is `sm` | `md` (default) | `lg` | `full` (draw its own visible close: it has no backdrop); the scrim, surface, radius, padding and elevation come from the workspace theme. An anchored dropdown still belongs inside your own root.
|
|
3778
3792
|
- `ConfirmDialog` — the standard confirmation prompt, a preset of `Modal` and `Button`. `<ConfirmDialog visible={asking} tone="destructive" title="Delete this order?" message="This cannot be undone." confirmLabel="Delete" onCancel={() => setAsking(false)} onConfirm={removeOrder} />` asks before a delete or any other action that cannot be undone. Cancel, the close button, the backdrop, Escape and the Android back button fire `onCancel`; a promise returned from `onConfirm` keeps it busy (buttons disabled, a second press ignored) until it settles. Props: `visible`, `title`, `message`, `confirmLabel`, `cancelLabel`, `tone` (`default` | `destructive`), `busy`, `onConfirm`, `onCancel`, `closeAccessibilityLabel`, `testID`. Use it instead of building a confirmation from `Modal` yourself.
|
|
3779
3793
|
- `Modal` — the standard dialog, built on `Overlay`. `<Modal visible={open} onRequestClose={() => setOpen(false)} title="Edit order" footer={<Button title="Save" onPress={save} />}>…</Modal>` draws a title, a close button, a body that scrolls when it is long and a footer action row laid out below it. Its background, corner radius, padding, scrim, shadow and title colour come from the theme's `modal` scope (Design > Components > Dialogs), so every dialog in an app matches. Props: `visible`, `onRequestClose`, `dismissible`, `title`, `footer`, `presentation` (`dialog` | `sheet`), `size` (`sm` | `md` | `lg` | `full`), `dismissOnBackdropPress`, `role`, `initialFocusRef`, `closeAccessibilityLabel`, `accessibilityLabel`, `testID`. Use it for every dialog instead of hand-building a header and an action row inside `Overlay`.
|
|
3780
3794
|
- `RichText` — the formatted-content renderer. `<RichText value={post.body} />` parses the markdown subset (`**bold**`, `*italic*` / `_italic_`, `` `code` ``, `#`/`##`/`###` headings, `-`/`*` bullets, `1.` ordered items, one-line `` images) and renders it with SDK primitives, so formatted content reads the same in the web Player and the exported Expo app. `value` is markdown, NOT HTML — widgets have no `dangerouslySetInnerHTML` on either host, so tags in a content string render as literal tag soup; stored text that still holds legacy HTML is stripped to plain text rather than shown as markup. Props: `value`, `renderImage` (`({ src, alt, size }) => node` — supply it when images are filestore ids, because resolving one needs the scopes your own widget holds; without it only absolute `http(s)` URLs render), `style`, `testID`. Colour, type scale and leading come from the workspace theme — never re-style them.
|
package/dist/contract.cjs
CHANGED
|
@@ -2508,7 +2508,7 @@ const HOOKS = [
|
|
|
2508
2508
|
getPayment:
|
|
2509
2509
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2510
2510
|
requestGuestPayment:
|
|
2511
|
-
"({ amount_cents?, currency?, description, return_path?, order }) => Promise<{ id, status, order }> // a visitor who is NOT signed in buys physical goods (no kind). The orders table needs a payment-status AND an order-total column, as for requestPayment: create the order with its total and omit amount_cents (if sent it must equal the total). order is REQUIRED: create the order row first with useDatastoreMutation().create (the maker lets everyone add rows to the orders table and nobody read them; collect the shipping address and contact there), then pay for it within 15 minutes — only the visitor who created it can. Needs the payments.charge:guest scope too. The host runs a security check and opens hosted Checkout. Refused: TRIAL_RESTRICTED, GUEST_CHECKOUT_LIMIT_REACHED (retryable), CAPTCHA_FAILED / CAPTCHA_UNAVAILABLE (retryable), NOT_FOUND where the shop does not offer guest checkout, plus the requestPayment refusals",
|
|
2511
|
+
"({ amount_cents?, currency?, description, return_path?, order }) => Promise<{ id, status, order }> // a visitor who is NOT signed in buys physical goods (no kind). The orders table needs a payment-status AND an order-total column, as for requestPayment: create the order with its total and omit amount_cents (if sent it must equal the total). order is REQUIRED: create the order row first with useDatastoreMutation().create (the maker lets everyone add rows to the orders table and nobody read them; collect the shipping address and contact there), then pay for it within 15 minutes — only the visitor who created it can. Needs the payments.charge:guest scope too. The 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",
|
|
2512
2512
|
getGuestPayment:
|
|
2513
2513
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // a guest's status read; the host holds the guest's one-time credential, so pass only the id",
|
|
2514
2514
|
},
|
|
@@ -3751,7 +3751,7 @@ const PRIMITIVES = [
|
|
|
3751
3751
|
{
|
|
3752
3752
|
name: "Overlay",
|
|
3753
3753
|
description:
|
|
3754
|
-
'Screen-level overlay. `<Overlay visible={open} onRequestClose={() => setOpen(false)} size="md">…panel…</Overlay>`. THE way to open anything that must cover the SCREEN rather than the widget and is not a dialog — a preview (PDF, image, video), a lightbox, a full-screen viewer. A dialog (a title, a close button, actions) is `<Modal>`, which is built on this. It renders OUTSIDE the widget layout box on both hosts (react-native-web portals it to the document root; native uses the OS modal), so no `overflow: hidden` card, scroll container or sibling widget can clip or cover it — which absolute positioning inside the widget cannot achieve on either host. Children stay in your own React tree, so state and hooks work normally. Props: `visible` (boolean, required to show), `onRequestClose` (fired by the backdrop press, the Escape key on web, and the Android back button — always wire it or the overlay cannot be closed), `size` ("sm" | "md" | "lg" | "full", default "md"; `full` runs edge to edge for
|
|
3754
|
+
'Screen-level overlay. `<Overlay visible={open} onRequestClose={() => setOpen(false)} size="md">…panel…</Overlay>`. THE way to open anything that must cover the SCREEN rather than the widget and is not a dialog — a preview (PDF, image, video), a lightbox, a full-screen viewer. A dialog (a title, a close button, actions) is `<Modal>`, which is built on this. It renders OUTSIDE the widget layout box on both hosts (react-native-web portals it to the document root; native uses the OS modal), so no `overflow: hidden` card, scroll container or sibling widget can clip or cover it — which absolute positioning inside the widget cannot achieve on either host. Children stay in your own React tree, so state and hooks work normally. Props: `visible` (boolean, required to show), `onRequestClose` (fired by the backdrop press, the Escape key on web, and the Android back button — always wire it or the overlay cannot be closed), `size` ("sm" | "md" | "lg" | "full", default "md"; `full` runs edge to edge: use it for content that needs the whole screen or uninterrupted touch — a game, an image, video or PDF preview, a lightbox, a signature or drawing pad, a map\'s full view, a slideshow — opened from an inline launcher, because inside the page every drag scrolls the page instead; a `full` overlay MUST draw its own visible close or pause control that runs the same handler as `onRequestClose`, padded by `useSafeAreaInsets()` so a notch never covers it: it has no backdrop to tap and an iPhone has no back button, so without one the user is trapped), `presentation` ("dialog", centred, the default | "sheet", anchored to the bottom edge), `dismissOnBackdropPress` (default true), `role` ("dialog" default | "alertdialog"; web only), `initialFocusRef` (web only), `accessibilityLabel` (names the dialog), `testID`, and `style` for extra panel styles. The scrim, surface, radius, padding and elevation come from the workspace theme (the scrim from Design > Components > Dialogs) — never re-style them. Keep it for screen-level surfaces: a dropdown anchored to its trigger still belongs inside the widget.',
|
|
3755
3755
|
rnComponent: null,
|
|
3756
3756
|
docsUrl: null,
|
|
3757
3757
|
},
|
|
@@ -4375,7 +4375,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4375
4375
|
type: "object",
|
|
4376
4376
|
required: false,
|
|
4377
4377
|
description:
|
|
4378
|
-
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: true` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The order's creator writes it on create and a later update is ignored; `requestPayment({ order })` then charges that stored total, so omit `amount_cents`. It fixes the total, not the price: compute it from prices the buyer cannot change. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4378
|
+
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: true` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The order's creator writes it on create and a later update is ignored; `requestPayment({ order })` then charges that stored total, so omit `amount_cents`. It fixes the total, not the price: compute it from prices the buyer cannot change. `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.",
|
|
4379
4379
|
},
|
|
4380
4380
|
translations: {
|
|
4381
4381
|
type: "object",
|
|
@@ -7164,7 +7164,13 @@ const CONTRACT = deepFreeze({
|
|
|
7164
7164
|
// that total, so `amount_cents` is optional with `order`. Breaking for an
|
|
7165
7165
|
// order charge on a table without one (ORDER_NOT_PAYABLE). Two new
|
|
7166
7166
|
// PaymentError codes and the `order-total-updated` warning.
|
|
7167
|
-
|
|
7167
|
+
// 1.285.0: additive (sc-18008) — a `datastoreTemplate` column may declare
|
|
7168
|
+
// `buyerEmail: true` (an immutable STRING); the platform emails the order
|
|
7169
|
+
// confirmation there. New PaymentError code BUYER_EMAIL_INVALID.
|
|
7170
|
+
// 1.286.0: guidance (sc-16714) — when an Overlay goes `full`, and that a
|
|
7171
|
+
// full one draws its own close control; the `full-overlay-no-close`
|
|
7172
|
+
// lint warning flags one that does not.
|
|
7173
|
+
version: "1.286.0",
|
|
7168
7174
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7169
7175
|
hooks: HOOKS,
|
|
7170
7176
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -2503,7 +2503,7 @@ const HOOKS = [
|
|
|
2503
2503
|
getPayment:
|
|
2504
2504
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2505
2505
|
requestGuestPayment:
|
|
2506
|
-
"({ amount_cents?, currency?, description, return_path?, order }) => Promise<{ id, status, order }> // a visitor who is NOT signed in buys physical goods (no kind). The orders table needs a payment-status AND an order-total column, as for requestPayment: create the order with its total and omit amount_cents (if sent it must equal the total). order is REQUIRED: create the order row first with useDatastoreMutation().create (the maker lets everyone add rows to the orders table and nobody read them; collect the shipping address and contact there), then pay for it within 15 minutes — only the visitor who created it can. Needs the payments.charge:guest scope too. The host runs a security check and opens hosted Checkout. Refused: TRIAL_RESTRICTED, GUEST_CHECKOUT_LIMIT_REACHED (retryable), CAPTCHA_FAILED / CAPTCHA_UNAVAILABLE (retryable), NOT_FOUND where the shop does not offer guest checkout, plus the requestPayment refusals",
|
|
2506
|
+
"({ amount_cents?, currency?, description, return_path?, order }) => Promise<{ id, status, order }> // a visitor who is NOT signed in buys physical goods (no kind). The orders table needs a payment-status AND an order-total column, as for requestPayment: create the order with its total and omit amount_cents (if sent it must equal the total). order is REQUIRED: create the order row first with useDatastoreMutation().create (the maker lets everyone add rows to the orders table and nobody read them; collect the shipping address and contact there), then pay for it within 15 minutes — only the visitor who created it can. Needs the payments.charge:guest scope too. The 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",
|
|
2507
2507
|
getGuestPayment:
|
|
2508
2508
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // a guest's status read; the host holds the guest's one-time credential, so pass only the id",
|
|
2509
2509
|
},
|
|
@@ -3746,7 +3746,7 @@ const PRIMITIVES = [
|
|
|
3746
3746
|
{
|
|
3747
3747
|
name: "Overlay",
|
|
3748
3748
|
description:
|
|
3749
|
-
'Screen-level overlay. `<Overlay visible={open} onRequestClose={() => setOpen(false)} size="md">…panel…</Overlay>`. THE way to open anything that must cover the SCREEN rather than the widget and is not a dialog — a preview (PDF, image, video), a lightbox, a full-screen viewer. A dialog (a title, a close button, actions) is `<Modal>`, which is built on this. It renders OUTSIDE the widget layout box on both hosts (react-native-web portals it to the document root; native uses the OS modal), so no `overflow: hidden` card, scroll container or sibling widget can clip or cover it — which absolute positioning inside the widget cannot achieve on either host. Children stay in your own React tree, so state and hooks work normally. Props: `visible` (boolean, required to show), `onRequestClose` (fired by the backdrop press, the Escape key on web, and the Android back button — always wire it or the overlay cannot be closed), `size` ("sm" | "md" | "lg" | "full", default "md"; `full` runs edge to edge for
|
|
3749
|
+
'Screen-level overlay. `<Overlay visible={open} onRequestClose={() => setOpen(false)} size="md">…panel…</Overlay>`. THE way to open anything that must cover the SCREEN rather than the widget and is not a dialog — a preview (PDF, image, video), a lightbox, a full-screen viewer. A dialog (a title, a close button, actions) is `<Modal>`, which is built on this. It renders OUTSIDE the widget layout box on both hosts (react-native-web portals it to the document root; native uses the OS modal), so no `overflow: hidden` card, scroll container or sibling widget can clip or cover it — which absolute positioning inside the widget cannot achieve on either host. Children stay in your own React tree, so state and hooks work normally. Props: `visible` (boolean, required to show), `onRequestClose` (fired by the backdrop press, the Escape key on web, and the Android back button — always wire it or the overlay cannot be closed), `size` ("sm" | "md" | "lg" | "full", default "md"; `full` runs edge to edge: use it for content that needs the whole screen or uninterrupted touch — a game, an image, video or PDF preview, a lightbox, a signature or drawing pad, a map\'s full view, a slideshow — opened from an inline launcher, because inside the page every drag scrolls the page instead; a `full` overlay MUST draw its own visible close or pause control that runs the same handler as `onRequestClose`, padded by `useSafeAreaInsets()` so a notch never covers it: it has no backdrop to tap and an iPhone has no back button, so without one the user is trapped), `presentation` ("dialog", centred, the default | "sheet", anchored to the bottom edge), `dismissOnBackdropPress` (default true), `role` ("dialog" default | "alertdialog"; web only), `initialFocusRef` (web only), `accessibilityLabel` (names the dialog), `testID`, and `style` for extra panel styles. The scrim, surface, radius, padding and elevation come from the workspace theme (the scrim from Design > Components > Dialogs) — never re-style them. Keep it for screen-level surfaces: a dropdown anchored to its trigger still belongs inside the widget.',
|
|
3750
3750
|
rnComponent: null,
|
|
3751
3751
|
docsUrl: null,
|
|
3752
3752
|
},
|
|
@@ -4370,7 +4370,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4370
4370
|
type: "object",
|
|
4371
4371
|
required: false,
|
|
4372
4372
|
description:
|
|
4373
|
-
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: true` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The order's creator writes it on create and a later update is ignored; `requestPayment({ order })` then charges that stored total, so omit `amount_cents`. It fixes the total, not the price: compute it from prices the buyer cannot change. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4373
|
+
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: true` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The order's creator writes it on create and a later update is ignored; `requestPayment({ order })` then charges that stored total, so omit `amount_cents`. It fixes the total, not the price: compute it from prices the buyer cannot change. `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.",
|
|
4374
4374
|
},
|
|
4375
4375
|
translations: {
|
|
4376
4376
|
type: "object",
|
|
@@ -7159,7 +7159,13 @@ const CONTRACT = deepFreeze({
|
|
|
7159
7159
|
// that total, so `amount_cents` is optional with `order`. Breaking for an
|
|
7160
7160
|
// order charge on a table without one (ORDER_NOT_PAYABLE). Two new
|
|
7161
7161
|
// PaymentError codes and the `order-total-updated` warning.
|
|
7162
|
-
|
|
7162
|
+
// 1.285.0: additive (sc-18008) — a `datastoreTemplate` column may declare
|
|
7163
|
+
// `buyerEmail: true` (an immutable STRING); the platform emails the order
|
|
7164
|
+
// confirmation there. New PaymentError code BUYER_EMAIL_INVALID.
|
|
7165
|
+
// 1.286.0: guidance (sc-16714) — when an Overlay goes `full`, and that a
|
|
7166
|
+
// full one draws its own close control; the `full-overlay-no-close`
|
|
7167
|
+
// lint warning flags one that does not.
|
|
7168
|
+
version: "1.286.0",
|
|
7163
7169
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7164
7170
|
hooks: HOOKS,
|
|
7165
7171
|
primitives: PRIMITIVES,
|
package/dist/hooks.js
CHANGED
|
@@ -7293,6 +7293,7 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7293
7293
|
"AUTH_REQUIRED",
|
|
7294
7294
|
"AMOUNT_TOO_LARGE",
|
|
7295
7295
|
"BUSINESS_IDENTITY_REQUIRED",
|
|
7296
|
+
"BUYER_EMAIL_INVALID",
|
|
7296
7297
|
"CHARGE_KIND_NOT_ENABLED",
|
|
7297
7298
|
"CHARGE_KIND_REQUIRED",
|
|
7298
7299
|
"CONNECT_NOT_READY",
|
|
@@ -7340,6 +7341,8 @@ const NON_RETRYABLE_PAYMENT_CODES = new Set([
|
|
|
7340
7341
|
* or not a whole number of minor units
|
|
7341
7342
|
* - "ORDER_AMOUNT_MISMATCH" — `amount_cents` was sent and differs from
|
|
7342
7343
|
* the order's total; omit it
|
|
7344
|
+
* - "BUYER_EMAIL_INVALID" — a guest's order has no valid email in
|
|
7345
|
+
* its buyer-email column; the receipt needs one
|
|
7343
7346
|
* - "ORDER_PAYMENT_IN_PROGRESS" — another checkout for the order is open
|
|
7344
7347
|
* (retryable: it clears when that one ends)
|
|
7345
7348
|
* - "ALREADY_OWNED" — `useAccessPlans().purchase` for a plan the
|
package/dist/index.d.ts
CHANGED
|
@@ -297,6 +297,15 @@ export interface WidgetDatastoreTemplateColumn {
|
|
|
297
297
|
* `amount_cents`. Compute it from prices the buyer cannot change.
|
|
298
298
|
*/
|
|
299
299
|
orderTotal?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* STRING only, at most one per table, in a table with a `paymentStatus`
|
|
302
|
+
* column, and it must be `immutable: true` (not encrypted, `latestVia` or
|
|
303
|
+
* `copyOf`). The buyer's email address: when a charge marks the order paid
|
|
304
|
+
* the platform emails an order confirmation there (a signed-in buyer gets it
|
|
305
|
+
* at their account's address), and a refund notice after a full refund. A
|
|
306
|
+
* guest charge needs a valid address in it.
|
|
307
|
+
*/
|
|
308
|
+
buyerEmail?: boolean;
|
|
300
309
|
/**
|
|
301
310
|
* ONE_TO_ONE / ONE_TO_MANY RELATION only, with `onDelete` left at
|
|
302
311
|
* `SET_NULL`: the server keeps this column pointing at the newest row of its
|
|
@@ -1684,7 +1693,8 @@ export interface PaymentResult {
|
|
|
1684
1693
|
|
|
1685
1694
|
/**
|
|
1686
1695
|
* A visitor who is not signed in paying for physical goods. There is no
|
|
1687
|
-
* `kind`: guest checkout sells physical goods only.
|
|
1696
|
+
* `kind`: guest checkout sells physical goods only. The order's table needs a
|
|
1697
|
+
* `buyerEmail` column holding a valid address (BUYER_EMAIL_INVALID otherwise).
|
|
1688
1698
|
*/
|
|
1689
1699
|
export interface GuestPaymentRequest {
|
|
1690
1700
|
/** Optional: the server charges the order's stored total, as for `requestPayment`. */
|
|
@@ -1835,6 +1845,7 @@ export class PaymentError extends Error {
|
|
|
1835
1845
|
| "ORDER_ALREADY_PAID"
|
|
1836
1846
|
| "ORDER_TOTAL_INVALID"
|
|
1837
1847
|
| "ORDER_AMOUNT_MISMATCH"
|
|
1848
|
+
| "BUYER_EMAIL_INVALID"
|
|
1838
1849
|
| "ORDER_PAYMENT_IN_PROGRESS"
|
|
1839
1850
|
| "ALREADY_OWNED"
|
|
1840
1851
|
| "PURCHASE_IN_PROGRESS"
|
|
@@ -4470,6 +4481,9 @@ export const Video: (props: {
|
|
|
4470
4481
|
*
|
|
4471
4482
|
* @example
|
|
4472
4483
|
* <Overlay visible={!!preview} onRequestClose={() => setPreview(null)} size="full">
|
|
4484
|
+
* <View style={{ paddingTop: insets.top, paddingRight: insets.right, alignItems: "flex-end" }}>
|
|
4485
|
+
* <IconButton icon="x" accessibilityLabel="Close" onPress={() => setPreview(null)} />
|
|
4486
|
+
* </View>
|
|
4473
4487
|
* <ScrollView>{renderPreview(preview)}</ScrollView>
|
|
4474
4488
|
* </Overlay>
|
|
4475
4489
|
*/
|
|
@@ -4478,7 +4492,10 @@ export const Overlay: (props: {
|
|
|
4478
4492
|
visible?: boolean;
|
|
4479
4493
|
/** Backdrop press, Escape (web) and the Android back button all fire this. */
|
|
4480
4494
|
onRequestClose?: () => void;
|
|
4481
|
-
/**
|
|
4495
|
+
/**
|
|
4496
|
+
* Panel width tier. `full` runs edge to edge, with no backdrop: draw a
|
|
4497
|
+
* visible close that runs `onRequestClose`'s handler. Defaults to `md`.
|
|
4498
|
+
*/
|
|
4482
4499
|
size?: "sm" | "md" | "lg" | "full";
|
|
4483
4500
|
/** Centred (`dialog`, the default) or anchored to the bottom edge (`sheet`). */
|
|
4484
4501
|
presentation?: OverlayPresentation;
|
package/dist/linter.cjs
CHANGED
|
@@ -4714,6 +4714,177 @@ function lintEditability(manifest, files) {
|
|
|
4714
4714
|
return { ok: true, findings };
|
|
4715
4715
|
}
|
|
4716
4716
|
|
|
4717
|
+
// Story 16714 — a full-screen overlay has no backdrop to tap and an iPhone has
|
|
4718
|
+
// no back button, so one with no close control of its own traps the user. The
|
|
4719
|
+
// agent's publish gate blocks on it and a close takes many forms, so no handler
|
|
4720
|
+
// is followed: only an overlay of plain display components is flagged.
|
|
4721
|
+
const _OVERLAY_TAG_RE = /<(\/?)Overlay(?![\w$.])/g;
|
|
4722
|
+
const _FULL_SIZE_RE = /(?:^|\s)size\s{0,20}=\s{0,20}(?:(["'])full\1|\{\s{0,20}(["'`])full\2\s{0,20}\}|\{[^{}]{0,200}[?:]\s{0,20}(["'`])full\3\s{0,20}[:}])/;
|
|
4723
|
+
const _PACKAGE_IMPORT_RE = /(?<![\w$.])from\s*["']([^"'\n]{1,200})["']/g;
|
|
4724
|
+
const _STATE_SETTER_RE = /(?<![\w$])(?:const|let|var)\s{0,40}\[\s{0,40}([\w$]+)\s{0,40},\s{0,40}([\w$]+)\s{0,40}\]\s{0,40}=\s{0,40}(?:React\s{0,40}\.\s{0,40})?useState(?![\w$])/g;
|
|
4725
|
+
const _STATE_VISIBLE_RE = /(?:^|\s)visible\s{0,40}=\s{0,40}\{\s{0,40}(?:!!\s{0,40})?([A-Za-z_$][\w$]*)\s{0,40}(?:!==?\s{0,40}null\s{0,40})?\}/;
|
|
4726
|
+
const _PRESS_ATTR_RE = /^on(?:Press(?:In|Out)?|LongPress|RequestClose|Close)$/;
|
|
4727
|
+
const _ONE_LINE_HELPER_RE = /(?<![\w$])const\s{1,20}([A-Za-z_$][\w$]*)\s{0,20}=\s{0,20}(?:\([^()]{0,100}\)|[A-Za-z_$][\w$]*)\s{0,20}=>[^\n;{}]{0,200}$/;
|
|
4728
|
+
const _DISPLAY_TAGS = new Set([
|
|
4729
|
+
"View", "Text", "Image", "FileImage", "ImageBackground", "ScrollView", "Card", "Grid", "Icon",
|
|
4730
|
+
"ActivityIndicator", "Spinner", "Divider", "Skeleton", "Video", "RichText", "MapView",
|
|
4731
|
+
]);
|
|
4732
|
+
const _INERT_ATTR_RE =
|
|
4733
|
+
/^(?:source|uri|src|fileId|assetId|style|contentContainerStyle|resizeMode|contentFit|aspectRatio|key|testID|alt|size|color|name|width|height|radius|gap|padding|align|justify|numberOfLines|horizontal|pagingEnabled|bounces|scrollEnabled|shows[A-Z]\w*|pointerEvents|accessible|accessibility(?:Label|Role|Hint)|poster|autoPlay|loop|muted|initialRegion|onLoad|onLayout|onError)$/;
|
|
4734
|
+
const _LIVE_VALUE_RE = /<|=>|(?<![\w$])function(?![\w$])|\)\s{0,20}\{|(?<![\w$])on[A-Z]/;
|
|
4735
|
+
const _EVENT_ATTR_RE = /^on[A-Z]/;
|
|
4736
|
+
const _CONTENT_ATTR_RE = /(?<![\w$.-])([A-Za-z_$][\w$-]*)\s{0,20}=\s{0,20}\{/g;
|
|
4737
|
+
const _COPY_RE = /<Text(?![\w$.])[^<>]{0,400}>(?:[^<{}]|\{\s{0,20}t\([^(){}<]{0,400}\)\s{0,20}\}){0,1000}<\/Text>/g;
|
|
4738
|
+
const _CONDITION_RE = /\{\s{0,20}!{0,2}[A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*){0,8}\s{0,20}(?:&&|\?(?![.?]))/g;
|
|
4739
|
+
const _NOTHING_RE = /(?<![\w$.])(?:null|undefined|false)(?![\w$])/g;
|
|
4740
|
+
// What a quote in JSX text would hide from the mask.
|
|
4741
|
+
const _MARKUP_RE = /<\/?[A-Za-z]|\.\.\.|(?<![\w$])on[A-Z]\w{0,40}\s{0,20}=/g;
|
|
4742
|
+
const _OVERLAY_CAP = 16;
|
|
4743
|
+
const _CONTENT_CAP = 20000;
|
|
4744
|
+
const _NAME_USE_CAP = 50;
|
|
4745
|
+
|
|
4746
|
+
/** Local names bound by package imports; a sibling file's markup is out of sight. */
|
|
4747
|
+
function _packageImports(code, kept) {
|
|
4748
|
+
const names = new Set();
|
|
4749
|
+
let count = 0;
|
|
4750
|
+
for (const m of kept.matchAll(_PACKAGE_IMPORT_RE)) {
|
|
4751
|
+
if (m[1].startsWith(".") || !code.startsWith("from", m.index)) continue;
|
|
4752
|
+
if (++count > 200) break;
|
|
4753
|
+
const head = code.slice(Math.max(0, m.index - 2000), m.index);
|
|
4754
|
+
const clause = head.slice(head.lastIndexOf("import") + 6);
|
|
4755
|
+
for (const name of clause.match(/[A-Za-z_$][\w$]*/g) || []) names.add(name);
|
|
4756
|
+
}
|
|
4757
|
+
return names;
|
|
4758
|
+
}
|
|
4759
|
+
|
|
4760
|
+
/** The file's press handlers, as disjoint [from, to) spans in order. */
|
|
4761
|
+
function _pressSpans(code, partner) {
|
|
4762
|
+
const spans = [];
|
|
4763
|
+
let done = -1;
|
|
4764
|
+
for (const m of code.matchAll(_CONTENT_ATTR_RE)) {
|
|
4765
|
+
if (m.index < done || !_PRESS_ATTR_RE.test(m[1])) continue;
|
|
4766
|
+
const open = m.index + m[0].length - 1;
|
|
4767
|
+
if (partner[open] === -1) continue;
|
|
4768
|
+
done = partner[open];
|
|
4769
|
+
spans.push([open, done]);
|
|
4770
|
+
}
|
|
4771
|
+
return spans;
|
|
4772
|
+
}
|
|
4773
|
+
|
|
4774
|
+
/** Whether `name` is used in press handlers only, or in a one-line helper that is. */
|
|
4775
|
+
function _usedByPressOnly(ctx, name, declaredAt, followsHelper) {
|
|
4776
|
+
let uses = 0;
|
|
4777
|
+
for (let at = ctx.code.indexOf(name); at !== -1; at = ctx.code.indexOf(name, at + name.length)) {
|
|
4778
|
+
const whole = !/[\w$]/.test(ctx.code[at - 1] || "") && !/[\w$]/.test(ctx.code[at + name.length] || "");
|
|
4779
|
+
if (!whole || declaredAt(at)) continue;
|
|
4780
|
+
if (++uses > _NAME_USE_CAP) return false;
|
|
4781
|
+
if (ctx.presses.some(([from, to]) => at > from && at < to)) continue;
|
|
4782
|
+
const lead = ctx.code.slice(Math.max(0, at - 300), at);
|
|
4783
|
+
const helper = followsHelper && _ONE_LINE_HELPER_RE.exec(lead.slice(lead.lastIndexOf("const ")));
|
|
4784
|
+
if (!helper) return false;
|
|
4785
|
+
const helperAt = at - helper[0].length;
|
|
4786
|
+
const isDeclaration = (i) => i > helperAt && i < at;
|
|
4787
|
+
if (!_usedByPressOnly(ctx, helper[1], isDeclaration, false)) return false;
|
|
4788
|
+
}
|
|
4789
|
+
return true;
|
|
4790
|
+
}
|
|
4791
|
+
|
|
4792
|
+
/** Whether `visible` is one state only presses change: a cover that code closes traps nobody. */
|
|
4793
|
+
function _opensByPressOnly(ctx, attrs) {
|
|
4794
|
+
const shown = _STATE_VISIBLE_RE.exec(attrs);
|
|
4795
|
+
const setter = shown && ctx.setterOf.get(shown[1]);
|
|
4796
|
+
if (!setter) return false;
|
|
4797
|
+
const inState = (at) => /^\s{0,20}\]/.test(ctx.code.slice(at + setter.length, at + setter.length + 24));
|
|
4798
|
+
return _usedByPressOnly(ctx, setter, inState, true);
|
|
4799
|
+
}
|
|
4800
|
+
|
|
4801
|
+
/** Whether everything between the overlay's tags only displays. */
|
|
4802
|
+
function _contentOnlyDisplays(ctx, [from, to]) {
|
|
4803
|
+
if (to - from > _CONTENT_CAP) return false;
|
|
4804
|
+
const code = ctx.code.slice(from, to);
|
|
4805
|
+
const raw = ctx.kept.slice(from, to);
|
|
4806
|
+
const markup = (text) => (text.match(_MARKUP_RE) || []).length;
|
|
4807
|
+
if (code.includes("...") || markup(code) !== markup(raw)) return false;
|
|
4808
|
+
let content = "";
|
|
4809
|
+
let done = 0;
|
|
4810
|
+
for (const m of code.matchAll(_CONTENT_ATTR_RE)) {
|
|
4811
|
+
if (m.index < done) continue;
|
|
4812
|
+
const open = m.index + m[0].length - 1;
|
|
4813
|
+
const close = ctx.partner[from + open] - from;
|
|
4814
|
+
if (close <= open || close >= code.length) return false;
|
|
4815
|
+
const value = code.slice(open + 1, close);
|
|
4816
|
+
if (_EVENT_ATTR_RE.test(m[1]) ? value.includes("<") : _LIVE_VALUE_RE.test(value)) return false;
|
|
4817
|
+
content += code.slice(done, open) + " ";
|
|
4818
|
+
done = close + 1;
|
|
4819
|
+
}
|
|
4820
|
+
content += code.slice(done);
|
|
4821
|
+
for (const [, name, attrs] of content.matchAll(/<([A-Za-z_$][\w$.]*)([^<>]{0,2000})/g)) {
|
|
4822
|
+
if (!_DISPLAY_TAGS.has(name) || !ctx.imports.has(name)) return false;
|
|
4823
|
+
if ((attrs.match(/[A-Za-z_$][\w$-]*/g) || []).some((attr) => !_INERT_ATTR_RE.test(attr))) return false;
|
|
4824
|
+
}
|
|
4825
|
+
// Copy, conditions and tags aside, any name left is rendered from out of sight.
|
|
4826
|
+
const rest = content
|
|
4827
|
+
.replace(_COPY_RE, " ")
|
|
4828
|
+
.replace(/<[^<>]{0,2000}>/g, " ")
|
|
4829
|
+
.replace(_CONDITION_RE, " ")
|
|
4830
|
+
.replace(_NOTHING_RE, " ");
|
|
4831
|
+
return !/[\w$]/.test(rest);
|
|
4832
|
+
}
|
|
4833
|
+
|
|
4834
|
+
function _overlayTags(code) {
|
|
4835
|
+
const index = _jsxScanIndex(code);
|
|
4836
|
+
const tags = [];
|
|
4837
|
+
for (const m of code.matchAll(_OVERLAY_TAG_RE)) {
|
|
4838
|
+
const end = index.tagEnd(m.index);
|
|
4839
|
+
const inLast = tags.length > 0 && m.index <= tags[tags.length - 1].end;
|
|
4840
|
+
if (end !== -1 && !inLast) tags.push({ at: m.index, end, closing: Boolean(m[1]) });
|
|
4841
|
+
}
|
|
4842
|
+
return tags;
|
|
4843
|
+
}
|
|
4844
|
+
|
|
4845
|
+
function _fullOverlayCloseRules(source) {
|
|
4846
|
+
if (!source.includes("<Overlay")) return [];
|
|
4847
|
+
const kept = _stripNonCode(source, { keepStrings: true, keepHoleBraces: true });
|
|
4848
|
+
if (!_FULL_SIZE_RE.test(kept)) return [];
|
|
4849
|
+
const code = _stripNonCode(source, { keepHoleBraces: true });
|
|
4850
|
+
const ctx = {
|
|
4851
|
+
code,
|
|
4852
|
+
kept,
|
|
4853
|
+
imports: _packageImports(code, kept),
|
|
4854
|
+
setterOf: new Map([...code.matchAll(_STATE_SETTER_RE)].map((m) => [m[1], m[2]])),
|
|
4855
|
+
partner: _bracketPartners(code),
|
|
4856
|
+
};
|
|
4857
|
+
if (!ctx.imports.has("Overlay")) return [];
|
|
4858
|
+
ctx.presses = _pressSpans(code, ctx.partner);
|
|
4859
|
+
const tags = _overlayTags(code);
|
|
4860
|
+
const lineAt = _lineCounter(code);
|
|
4861
|
+
const lines = source.split(/\r?\n/);
|
|
4862
|
+
const findings = [];
|
|
4863
|
+
let judged = 0;
|
|
4864
|
+
for (let i = 0; i < tags.length && judged < _OVERLAY_CAP; i += 1) {
|
|
4865
|
+
const { at, end, closing } = tags[i];
|
|
4866
|
+
const next = tags[i + 1];
|
|
4867
|
+
if (closing || _selfClosing(code, end) || !next || !next.closing) continue;
|
|
4868
|
+
const attrs = kept.slice(at, end);
|
|
4869
|
+
// A spread carries anything.
|
|
4870
|
+
if (!_FULL_SIZE_RE.test(attrs) || attrs.includes("...")) continue;
|
|
4871
|
+
judged += 1;
|
|
4872
|
+
if (!_contentOnlyDisplays(ctx, [end + 1, next.at]) || !_opensByPressOnly(ctx, attrs)) continue;
|
|
4873
|
+
const line = lineAt(at);
|
|
4874
|
+
findings.push({
|
|
4875
|
+
rule: "full-overlay-no-close",
|
|
4876
|
+
severity: "warning",
|
|
4877
|
+
label:
|
|
4878
|
+
`<Overlay size="full"> draws no close control, so on an iPhone there is no way out: ` +
|
|
4879
|
+
`no backdrop to tap and no back button. Draw a visible close (or pause) button inside it ` +
|
|
4880
|
+
`that runs the same handler as onRequestClose, padded by useSafeAreaInsets().`,
|
|
4881
|
+
line,
|
|
4882
|
+
snippet: (lines[line - 1] || "").trim().slice(0, 200),
|
|
4883
|
+
});
|
|
4884
|
+
}
|
|
4885
|
+
return findings;
|
|
4886
|
+
}
|
|
4887
|
+
|
|
4717
4888
|
// sc-10829 — `manifest.badgeCounter` promises the host a hook it can run
|
|
4718
4889
|
// while the page is closed; each shipped entry must export it by name.
|
|
4719
4890
|
function _exportedNameLine(code, name) {
|
|
@@ -4842,6 +5013,7 @@ function lintSource(source, options) {
|
|
|
4842
5013
|
findings.push(..._useAssetOnFileColumnRules(source));
|
|
4843
5014
|
findings.push(..._rowActionGatingRules(source));
|
|
4844
5015
|
findings.push(..._unknownMutationMethodRules(source));
|
|
5016
|
+
findings.push(..._fullOverlayCloseRules(source));
|
|
4845
5017
|
// REQ-USERMGMT / REQ-ACL-SYS M3 — scope-aware rules. Run after the
|
|
4846
5018
|
// line-by-line scan so banned-identifier findings stay first in the
|
|
4847
5019
|
// output.
|
package/dist/linter.js
CHANGED
|
@@ -4709,6 +4709,177 @@ export function lintEditability(manifest, files) {
|
|
|
4709
4709
|
return { ok: true, findings };
|
|
4710
4710
|
}
|
|
4711
4711
|
|
|
4712
|
+
// Story 16714 — a full-screen overlay has no backdrop to tap and an iPhone has
|
|
4713
|
+
// no back button, so one with no close control of its own traps the user. The
|
|
4714
|
+
// agent's publish gate blocks on it and a close takes many forms, so no handler
|
|
4715
|
+
// is followed: only an overlay of plain display components is flagged.
|
|
4716
|
+
const _OVERLAY_TAG_RE = /<(\/?)Overlay(?![\w$.])/g;
|
|
4717
|
+
const _FULL_SIZE_RE = /(?:^|\s)size\s{0,20}=\s{0,20}(?:(["'])full\1|\{\s{0,20}(["'`])full\2\s{0,20}\}|\{[^{}]{0,200}[?:]\s{0,20}(["'`])full\3\s{0,20}[:}])/;
|
|
4718
|
+
const _PACKAGE_IMPORT_RE = /(?<![\w$.])from\s*["']([^"'\n]{1,200})["']/g;
|
|
4719
|
+
const _STATE_SETTER_RE = /(?<![\w$])(?:const|let|var)\s{0,40}\[\s{0,40}([\w$]+)\s{0,40},\s{0,40}([\w$]+)\s{0,40}\]\s{0,40}=\s{0,40}(?:React\s{0,40}\.\s{0,40})?useState(?![\w$])/g;
|
|
4720
|
+
const _STATE_VISIBLE_RE = /(?:^|\s)visible\s{0,40}=\s{0,40}\{\s{0,40}(?:!!\s{0,40})?([A-Za-z_$][\w$]*)\s{0,40}(?:!==?\s{0,40}null\s{0,40})?\}/;
|
|
4721
|
+
const _PRESS_ATTR_RE = /^on(?:Press(?:In|Out)?|LongPress|RequestClose|Close)$/;
|
|
4722
|
+
const _ONE_LINE_HELPER_RE = /(?<![\w$])const\s{1,20}([A-Za-z_$][\w$]*)\s{0,20}=\s{0,20}(?:\([^()]{0,100}\)|[A-Za-z_$][\w$]*)\s{0,20}=>[^\n;{}]{0,200}$/;
|
|
4723
|
+
const _DISPLAY_TAGS = new Set([
|
|
4724
|
+
"View", "Text", "Image", "FileImage", "ImageBackground", "ScrollView", "Card", "Grid", "Icon",
|
|
4725
|
+
"ActivityIndicator", "Spinner", "Divider", "Skeleton", "Video", "RichText", "MapView",
|
|
4726
|
+
]);
|
|
4727
|
+
const _INERT_ATTR_RE =
|
|
4728
|
+
/^(?:source|uri|src|fileId|assetId|style|contentContainerStyle|resizeMode|contentFit|aspectRatio|key|testID|alt|size|color|name|width|height|radius|gap|padding|align|justify|numberOfLines|horizontal|pagingEnabled|bounces|scrollEnabled|shows[A-Z]\w*|pointerEvents|accessible|accessibility(?:Label|Role|Hint)|poster|autoPlay|loop|muted|initialRegion|onLoad|onLayout|onError)$/;
|
|
4729
|
+
const _LIVE_VALUE_RE = /<|=>|(?<![\w$])function(?![\w$])|\)\s{0,20}\{|(?<![\w$])on[A-Z]/;
|
|
4730
|
+
const _EVENT_ATTR_RE = /^on[A-Z]/;
|
|
4731
|
+
const _CONTENT_ATTR_RE = /(?<![\w$.-])([A-Za-z_$][\w$-]*)\s{0,20}=\s{0,20}\{/g;
|
|
4732
|
+
const _COPY_RE = /<Text(?![\w$.])[^<>]{0,400}>(?:[^<{}]|\{\s{0,20}t\([^(){}<]{0,400}\)\s{0,20}\}){0,1000}<\/Text>/g;
|
|
4733
|
+
const _CONDITION_RE = /\{\s{0,20}!{0,2}[A-Za-z_$][\w$]*(?:\??\.[A-Za-z_$][\w$]*){0,8}\s{0,20}(?:&&|\?(?![.?]))/g;
|
|
4734
|
+
const _NOTHING_RE = /(?<![\w$.])(?:null|undefined|false)(?![\w$])/g;
|
|
4735
|
+
// What a quote in JSX text would hide from the mask.
|
|
4736
|
+
const _MARKUP_RE = /<\/?[A-Za-z]|\.\.\.|(?<![\w$])on[A-Z]\w{0,40}\s{0,20}=/g;
|
|
4737
|
+
const _OVERLAY_CAP = 16;
|
|
4738
|
+
const _CONTENT_CAP = 20000;
|
|
4739
|
+
const _NAME_USE_CAP = 50;
|
|
4740
|
+
|
|
4741
|
+
/** Local names bound by package imports; a sibling file's markup is out of sight. */
|
|
4742
|
+
function _packageImports(code, kept) {
|
|
4743
|
+
const names = new Set();
|
|
4744
|
+
let count = 0;
|
|
4745
|
+
for (const m of kept.matchAll(_PACKAGE_IMPORT_RE)) {
|
|
4746
|
+
if (m[1].startsWith(".") || !code.startsWith("from", m.index)) continue;
|
|
4747
|
+
if (++count > 200) break;
|
|
4748
|
+
const head = code.slice(Math.max(0, m.index - 2000), m.index);
|
|
4749
|
+
const clause = head.slice(head.lastIndexOf("import") + 6);
|
|
4750
|
+
for (const name of clause.match(/[A-Za-z_$][\w$]*/g) || []) names.add(name);
|
|
4751
|
+
}
|
|
4752
|
+
return names;
|
|
4753
|
+
}
|
|
4754
|
+
|
|
4755
|
+
/** The file's press handlers, as disjoint [from, to) spans in order. */
|
|
4756
|
+
function _pressSpans(code, partner) {
|
|
4757
|
+
const spans = [];
|
|
4758
|
+
let done = -1;
|
|
4759
|
+
for (const m of code.matchAll(_CONTENT_ATTR_RE)) {
|
|
4760
|
+
if (m.index < done || !_PRESS_ATTR_RE.test(m[1])) continue;
|
|
4761
|
+
const open = m.index + m[0].length - 1;
|
|
4762
|
+
if (partner[open] === -1) continue;
|
|
4763
|
+
done = partner[open];
|
|
4764
|
+
spans.push([open, done]);
|
|
4765
|
+
}
|
|
4766
|
+
return spans;
|
|
4767
|
+
}
|
|
4768
|
+
|
|
4769
|
+
/** Whether `name` is used in press handlers only, or in a one-line helper that is. */
|
|
4770
|
+
function _usedByPressOnly(ctx, name, declaredAt, followsHelper) {
|
|
4771
|
+
let uses = 0;
|
|
4772
|
+
for (let at = ctx.code.indexOf(name); at !== -1; at = ctx.code.indexOf(name, at + name.length)) {
|
|
4773
|
+
const whole = !/[\w$]/.test(ctx.code[at - 1] || "") && !/[\w$]/.test(ctx.code[at + name.length] || "");
|
|
4774
|
+
if (!whole || declaredAt(at)) continue;
|
|
4775
|
+
if (++uses > _NAME_USE_CAP) return false;
|
|
4776
|
+
if (ctx.presses.some(([from, to]) => at > from && at < to)) continue;
|
|
4777
|
+
const lead = ctx.code.slice(Math.max(0, at - 300), at);
|
|
4778
|
+
const helper = followsHelper && _ONE_LINE_HELPER_RE.exec(lead.slice(lead.lastIndexOf("const ")));
|
|
4779
|
+
if (!helper) return false;
|
|
4780
|
+
const helperAt = at - helper[0].length;
|
|
4781
|
+
const isDeclaration = (i) => i > helperAt && i < at;
|
|
4782
|
+
if (!_usedByPressOnly(ctx, helper[1], isDeclaration, false)) return false;
|
|
4783
|
+
}
|
|
4784
|
+
return true;
|
|
4785
|
+
}
|
|
4786
|
+
|
|
4787
|
+
/** Whether `visible` is one state only presses change: a cover that code closes traps nobody. */
|
|
4788
|
+
function _opensByPressOnly(ctx, attrs) {
|
|
4789
|
+
const shown = _STATE_VISIBLE_RE.exec(attrs);
|
|
4790
|
+
const setter = shown && ctx.setterOf.get(shown[1]);
|
|
4791
|
+
if (!setter) return false;
|
|
4792
|
+
const inState = (at) => /^\s{0,20}\]/.test(ctx.code.slice(at + setter.length, at + setter.length + 24));
|
|
4793
|
+
return _usedByPressOnly(ctx, setter, inState, true);
|
|
4794
|
+
}
|
|
4795
|
+
|
|
4796
|
+
/** Whether everything between the overlay's tags only displays. */
|
|
4797
|
+
function _contentOnlyDisplays(ctx, [from, to]) {
|
|
4798
|
+
if (to - from > _CONTENT_CAP) return false;
|
|
4799
|
+
const code = ctx.code.slice(from, to);
|
|
4800
|
+
const raw = ctx.kept.slice(from, to);
|
|
4801
|
+
const markup = (text) => (text.match(_MARKUP_RE) || []).length;
|
|
4802
|
+
if (code.includes("...") || markup(code) !== markup(raw)) return false;
|
|
4803
|
+
let content = "";
|
|
4804
|
+
let done = 0;
|
|
4805
|
+
for (const m of code.matchAll(_CONTENT_ATTR_RE)) {
|
|
4806
|
+
if (m.index < done) continue;
|
|
4807
|
+
const open = m.index + m[0].length - 1;
|
|
4808
|
+
const close = ctx.partner[from + open] - from;
|
|
4809
|
+
if (close <= open || close >= code.length) return false;
|
|
4810
|
+
const value = code.slice(open + 1, close);
|
|
4811
|
+
if (_EVENT_ATTR_RE.test(m[1]) ? value.includes("<") : _LIVE_VALUE_RE.test(value)) return false;
|
|
4812
|
+
content += code.slice(done, open) + " ";
|
|
4813
|
+
done = close + 1;
|
|
4814
|
+
}
|
|
4815
|
+
content += code.slice(done);
|
|
4816
|
+
for (const [, name, attrs] of content.matchAll(/<([A-Za-z_$][\w$.]*)([^<>]{0,2000})/g)) {
|
|
4817
|
+
if (!_DISPLAY_TAGS.has(name) || !ctx.imports.has(name)) return false;
|
|
4818
|
+
if ((attrs.match(/[A-Za-z_$][\w$-]*/g) || []).some((attr) => !_INERT_ATTR_RE.test(attr))) return false;
|
|
4819
|
+
}
|
|
4820
|
+
// Copy, conditions and tags aside, any name left is rendered from out of sight.
|
|
4821
|
+
const rest = content
|
|
4822
|
+
.replace(_COPY_RE, " ")
|
|
4823
|
+
.replace(/<[^<>]{0,2000}>/g, " ")
|
|
4824
|
+
.replace(_CONDITION_RE, " ")
|
|
4825
|
+
.replace(_NOTHING_RE, " ");
|
|
4826
|
+
return !/[\w$]/.test(rest);
|
|
4827
|
+
}
|
|
4828
|
+
|
|
4829
|
+
function _overlayTags(code) {
|
|
4830
|
+
const index = _jsxScanIndex(code);
|
|
4831
|
+
const tags = [];
|
|
4832
|
+
for (const m of code.matchAll(_OVERLAY_TAG_RE)) {
|
|
4833
|
+
const end = index.tagEnd(m.index);
|
|
4834
|
+
const inLast = tags.length > 0 && m.index <= tags[tags.length - 1].end;
|
|
4835
|
+
if (end !== -1 && !inLast) tags.push({ at: m.index, end, closing: Boolean(m[1]) });
|
|
4836
|
+
}
|
|
4837
|
+
return tags;
|
|
4838
|
+
}
|
|
4839
|
+
|
|
4840
|
+
function _fullOverlayCloseRules(source) {
|
|
4841
|
+
if (!source.includes("<Overlay")) return [];
|
|
4842
|
+
const kept = _stripNonCode(source, { keepStrings: true, keepHoleBraces: true });
|
|
4843
|
+
if (!_FULL_SIZE_RE.test(kept)) return [];
|
|
4844
|
+
const code = _stripNonCode(source, { keepHoleBraces: true });
|
|
4845
|
+
const ctx = {
|
|
4846
|
+
code,
|
|
4847
|
+
kept,
|
|
4848
|
+
imports: _packageImports(code, kept),
|
|
4849
|
+
setterOf: new Map([...code.matchAll(_STATE_SETTER_RE)].map((m) => [m[1], m[2]])),
|
|
4850
|
+
partner: _bracketPartners(code),
|
|
4851
|
+
};
|
|
4852
|
+
if (!ctx.imports.has("Overlay")) return [];
|
|
4853
|
+
ctx.presses = _pressSpans(code, ctx.partner);
|
|
4854
|
+
const tags = _overlayTags(code);
|
|
4855
|
+
const lineAt = _lineCounter(code);
|
|
4856
|
+
const lines = source.split(/\r?\n/);
|
|
4857
|
+
const findings = [];
|
|
4858
|
+
let judged = 0;
|
|
4859
|
+
for (let i = 0; i < tags.length && judged < _OVERLAY_CAP; i += 1) {
|
|
4860
|
+
const { at, end, closing } = tags[i];
|
|
4861
|
+
const next = tags[i + 1];
|
|
4862
|
+
if (closing || _selfClosing(code, end) || !next || !next.closing) continue;
|
|
4863
|
+
const attrs = kept.slice(at, end);
|
|
4864
|
+
// A spread carries anything.
|
|
4865
|
+
if (!_FULL_SIZE_RE.test(attrs) || attrs.includes("...")) continue;
|
|
4866
|
+
judged += 1;
|
|
4867
|
+
if (!_contentOnlyDisplays(ctx, [end + 1, next.at]) || !_opensByPressOnly(ctx, attrs)) continue;
|
|
4868
|
+
const line = lineAt(at);
|
|
4869
|
+
findings.push({
|
|
4870
|
+
rule: "full-overlay-no-close",
|
|
4871
|
+
severity: "warning",
|
|
4872
|
+
label:
|
|
4873
|
+
`<Overlay size="full"> draws no close control, so on an iPhone there is no way out: ` +
|
|
4874
|
+
`no backdrop to tap and no back button. Draw a visible close (or pause) button inside it ` +
|
|
4875
|
+
`that runs the same handler as onRequestClose, padded by useSafeAreaInsets().`,
|
|
4876
|
+
line,
|
|
4877
|
+
snippet: (lines[line - 1] || "").trim().slice(0, 200),
|
|
4878
|
+
});
|
|
4879
|
+
}
|
|
4880
|
+
return findings;
|
|
4881
|
+
}
|
|
4882
|
+
|
|
4712
4883
|
// sc-10829 — `manifest.badgeCounter` promises the host a hook it can run
|
|
4713
4884
|
// while the page is closed; each shipped entry must export it by name.
|
|
4714
4885
|
function _exportedNameLine(code, name) {
|
|
@@ -4837,6 +5008,7 @@ export function lintSource(source, options) {
|
|
|
4837
5008
|
findings.push(..._useAssetOnFileColumnRules(source));
|
|
4838
5009
|
findings.push(..._rowActionGatingRules(source));
|
|
4839
5010
|
findings.push(..._unknownMutationMethodRules(source));
|
|
5011
|
+
findings.push(..._fullOverlayCloseRules(source));
|
|
4840
5012
|
// REQ-USERMGMT / REQ-ACL-SYS M3 — scope-aware rules. Run after the
|
|
4841
5013
|
// line-by-line scan so banned-identifier findings stay first in the
|
|
4842
5014
|
// output.
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -2503,7 +2503,7 @@ const HOOKS = [
|
|
|
2503
2503
|
getPayment:
|
|
2504
2504
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // order: { table_id, record_id } | null — read it after returning from Checkout",
|
|
2505
2505
|
requestGuestPayment:
|
|
2506
|
-
"({ amount_cents?, currency?, description, return_path?, order }) => Promise<{ id, status, order }> // a visitor who is NOT signed in buys physical goods (no kind). The orders table needs a payment-status AND an order-total column, as for requestPayment: create the order with its total and omit amount_cents (if sent it must equal the total). order is REQUIRED: create the order row first with useDatastoreMutation().create (the maker lets everyone add rows to the orders table and nobody read them; collect the shipping address and contact there), then pay for it within 15 minutes — only the visitor who created it can. Needs the payments.charge:guest scope too. The host runs a security check and opens hosted Checkout. Refused: TRIAL_RESTRICTED, GUEST_CHECKOUT_LIMIT_REACHED (retryable), CAPTCHA_FAILED / CAPTCHA_UNAVAILABLE (retryable), NOT_FOUND where the shop does not offer guest checkout, plus the requestPayment refusals",
|
|
2506
|
+
"({ amount_cents?, currency?, description, return_path?, order }) => Promise<{ id, status, order }> // a visitor who is NOT signed in buys physical goods (no kind). The orders table needs a payment-status AND an order-total column, as for requestPayment: create the order with its total and omit amount_cents (if sent it must equal the total). order is REQUIRED: create the order row first with useDatastoreMutation().create (the maker lets everyone add rows to the orders table and nobody read them; collect the shipping address and contact there), then pay for it within 15 minutes — only the visitor who created it can. Needs the payments.charge:guest scope too. The 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",
|
|
2507
2507
|
getGuestPayment:
|
|
2508
2508
|
"(paymentId) => Promise<{ id, status, amount_cents, currency, description, order }> // a guest's status read; the host holds the guest's one-time credential, so pass only the id",
|
|
2509
2509
|
},
|
|
@@ -3746,7 +3746,7 @@ const PRIMITIVES = [
|
|
|
3746
3746
|
{
|
|
3747
3747
|
name: "Overlay",
|
|
3748
3748
|
description:
|
|
3749
|
-
'Screen-level overlay. `<Overlay visible={open} onRequestClose={() => setOpen(false)} size="md">…panel…</Overlay>`. THE way to open anything that must cover the SCREEN rather than the widget and is not a dialog — a preview (PDF, image, video), a lightbox, a full-screen viewer. A dialog (a title, a close button, actions) is `<Modal>`, which is built on this. It renders OUTSIDE the widget layout box on both hosts (react-native-web portals it to the document root; native uses the OS modal), so no `overflow: hidden` card, scroll container or sibling widget can clip or cover it — which absolute positioning inside the widget cannot achieve on either host. Children stay in your own React tree, so state and hooks work normally. Props: `visible` (boolean, required to show), `onRequestClose` (fired by the backdrop press, the Escape key on web, and the Android back button — always wire it or the overlay cannot be closed), `size` ("sm" | "md" | "lg" | "full", default "md"; `full` runs edge to edge for
|
|
3749
|
+
'Screen-level overlay. `<Overlay visible={open} onRequestClose={() => setOpen(false)} size="md">…panel…</Overlay>`. THE way to open anything that must cover the SCREEN rather than the widget and is not a dialog — a preview (PDF, image, video), a lightbox, a full-screen viewer. A dialog (a title, a close button, actions) is `<Modal>`, which is built on this. It renders OUTSIDE the widget layout box on both hosts (react-native-web portals it to the document root; native uses the OS modal), so no `overflow: hidden` card, scroll container or sibling widget can clip or cover it — which absolute positioning inside the widget cannot achieve on either host. Children stay in your own React tree, so state and hooks work normally. Props: `visible` (boolean, required to show), `onRequestClose` (fired by the backdrop press, the Escape key on web, and the Android back button — always wire it or the overlay cannot be closed), `size` ("sm" | "md" | "lg" | "full", default "md"; `full` runs edge to edge: use it for content that needs the whole screen or uninterrupted touch — a game, an image, video or PDF preview, a lightbox, a signature or drawing pad, a map\'s full view, a slideshow — opened from an inline launcher, because inside the page every drag scrolls the page instead; a `full` overlay MUST draw its own visible close or pause control that runs the same handler as `onRequestClose`, padded by `useSafeAreaInsets()` so a notch never covers it: it has no backdrop to tap and an iPhone has no back button, so without one the user is trapped), `presentation` ("dialog", centred, the default | "sheet", anchored to the bottom edge), `dismissOnBackdropPress` (default true), `role` ("dialog" default | "alertdialog"; web only), `initialFocusRef` (web only), `accessibilityLabel` (names the dialog), `testID`, and `style` for extra panel styles. The scrim, surface, radius, padding and elevation come from the workspace theme (the scrim from Design > Components > Dialogs) — never re-style them. Keep it for screen-level surfaces: a dropdown anchored to its trigger still belongs inside the widget.',
|
|
3750
3750
|
rnComponent: null,
|
|
3751
3751
|
docsUrl: null,
|
|
3752
3752
|
},
|
|
@@ -4370,7 +4370,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4370
4370
|
type: "object",
|
|
4371
4371
|
required: false,
|
|
4372
4372
|
description:
|
|
4373
|
-
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: true` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The order's creator writes it on create and a later update is ignored; `requestPayment({ order })` then charges that stored total, so omit `amount_cents`. It fixes the total, not the price: compute it from prices the buyer cannot change. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4373
|
+
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): the table also needs an `orderTotal` column; a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. `orderTotal: true` makes a NUMBER column the order's total, which a charge for the order bills: integer MINOR units (339 kr is 33900) in the workspace's charge currency, no currency stored. A table with a paymentStatus column REQUIRES exactly one (and it is valid only beside one), and it must be `immutable: true` (not encrypted, latestVia or copyOf). The order's creator writes it on create and a later update is ignored; `requestPayment({ order })` then charges that stored total, so omit `amount_cents`. It fixes the total, not the price: compute it from prices the buyer cannot change. `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.",
|
|
4374
4374
|
},
|
|
4375
4375
|
translations: {
|
|
4376
4376
|
type: "object",
|
|
@@ -7159,7 +7159,13 @@ const CONTRACT = deepFreeze({
|
|
|
7159
7159
|
// that total, so `amount_cents` is optional with `order`. Breaking for an
|
|
7160
7160
|
// order charge on a table without one (ORDER_NOT_PAYABLE). Two new
|
|
7161
7161
|
// PaymentError codes and the `order-total-updated` warning.
|
|
7162
|
-
|
|
7162
|
+
// 1.285.0: additive (sc-18008) — a `datastoreTemplate` column may declare
|
|
7163
|
+
// `buyerEmail: true` (an immutable STRING); the platform emails the order
|
|
7164
|
+
// confirmation there. New PaymentError code BUYER_EMAIL_INVALID.
|
|
7165
|
+
// 1.286.0: guidance (sc-16714) — when an Overlay goes `full`, and that a
|
|
7166
|
+
// full one draws its own close control; the `full-overlay-no-close`
|
|
7167
|
+
// lint warning flags one that does not.
|
|
7168
|
+
version: "1.286.0",
|
|
7163
7169
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7164
7170
|
hooks: HOOKS,
|
|
7165
7171
|
primitives: PRIMITIVES,
|