@colixsystems/widget-sdk 0.329.1 → 0.331.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/contract.cjs +11 -4
- package/dist/contract.js +11 -4
- package/dist/hooks.js +15 -1
- package/dist/index.d.ts +11 -1
- package/dist/list-view.js +6 -0
- package/package.json +1 -1
- package/src/contract.js +11 -4
package/README.md
CHANGED
|
@@ -91,7 +91,15 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
94
|
+
`v0.331.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.331.0 (contract 1.270.0)
|
|
97
|
+
|
|
98
|
+
**A `datastoreTemplate` column can start every row at its default.** A column with `defaultOnCreate: true` ignores any value a client sends when a row is created and takes its `defaultValue` instead (or stays empty without one). An update may still change it, through the row's normal access. Use it for an approval or status column: whoever files a receipt gets `"Submitted"`, never `"Approved"`, and the approver sets the status later. It protects only a table whose filers cannot edit their row afterwards, so leave `grantCreatorPermissions` off it and let reviewers write through a `roleGrants` group. A required column needs a non-empty default, and a `paymentStatus`, `latestVia` or `copyOf` column cannot take it. Additive.
|
|
99
|
+
|
|
100
|
+
### What's new in 0.330.0 (contract 1.269.0)
|
|
101
|
+
|
|
102
|
+
**A `<ListRow>` takes a `ref`, and `useCanWrite` waits for its answer.** The ref reaches the row's press target (the row itself when it has no `onPress`), so a list-and-detail widget can put focus back on the row a person opened when they go back. `useCanWrite` now reports `loading: true` until the answer for the bound table (and row) has arrived: a widget that binds its table after mount, or whose viewer signs in, no longer sees `canWrite: false, loading: false` for a render and flashes its "not allowed" state. Additive.
|
|
95
103
|
|
|
96
104
|
### What's new in 0.329.1 (contract 1.268.0)
|
|
97
105
|
|
package/dist/contract.cjs
CHANGED
|
@@ -3083,7 +3083,8 @@ const HOOKS = [
|
|
|
3083
3083
|
"NOT distinguish 'not signed in' from 'signed in but forbidden' (both resolve canWrite:false); pair it with useUser() when the UI needs to " +
|
|
3084
3084
|
"tell those apart. For a LIST, gate each row's edit/delete on useDatastoreQuery's `includeCapabilities` answer instead — a " +
|
|
3085
3085
|
"{ recordId } check per row is one request per row, and the table-level answer only says whether they may CREATE. myPermissions is a newer client method: a host that has not injected it is NOT a hard error — this hook collapses to " +
|
|
3086
|
-
"{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy."
|
|
3086
|
+
"{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy. " +
|
|
3087
|
+
"With a table bound, loading stays true until the answer for that table (and row) has arrived, so canWrite:false with loading:false is always an answer.",
|
|
3087
3088
|
returnShape: {
|
|
3088
3089
|
canWrite: "boolean",
|
|
3089
3090
|
loading: "boolean",
|
|
@@ -3766,7 +3767,7 @@ const PRIMITIVES = [
|
|
|
3766
3767
|
{
|
|
3767
3768
|
name: "ListRow",
|
|
3768
3769
|
description:
|
|
3769
|
-
'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
|
|
3770
|
+
'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, `ref` (the row\'s press target, so focus can return to the row a person opened), plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
|
|
3770
3771
|
rnComponent: null,
|
|
3771
3772
|
docsUrl: null,
|
|
3772
3773
|
},
|
|
@@ -4333,7 +4334,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4333
4334
|
type: "object",
|
|
4334
4335
|
required: false,
|
|
4335
4336
|
description:
|
|
4336
|
-
"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). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4337
|
+
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4337
4338
|
},
|
|
4338
4339
|
translations: {
|
|
4339
4340
|
type: "object",
|
|
@@ -7060,7 +7061,13 @@ const CONTRACT = deepFreeze({
|
|
|
7060
7061
|
// email? })` opens the app's sign-in screen over the page on both hosts,
|
|
7061
7062
|
// and an event declared for the page to bind to Sign in is the
|
|
7062
7063
|
// `sign-in-event` error.
|
|
7063
|
-
|
|
7064
|
+
// 1.269.0: additive (sc-17385) — `<ListRow ref>` reaches the row's press
|
|
7065
|
+
// target, so a widget can return focus to it; useCanWrite stays
|
|
7066
|
+
// loading until it has the answer for the bound table.
|
|
7067
|
+
// 1.270.0: additive (sc-17197) — a `datastoreTemplate` column may declare
|
|
7068
|
+
// `defaultOnCreate: true`: a create stamps its default over any client
|
|
7069
|
+
// value, and an update may still change it.
|
|
7070
|
+
version: "1.270.0",
|
|
7064
7071
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7065
7072
|
hooks: HOOKS,
|
|
7066
7073
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -3078,7 +3078,8 @@ const HOOKS = [
|
|
|
3078
3078
|
"NOT distinguish 'not signed in' from 'signed in but forbidden' (both resolve canWrite:false); pair it with useUser() when the UI needs to " +
|
|
3079
3079
|
"tell those apart. For a LIST, gate each row's edit/delete on useDatastoreQuery's `includeCapabilities` answer instead — a " +
|
|
3080
3080
|
"{ recordId } check per row is one request per row, and the table-level answer only says whether they may CREATE. myPermissions is a newer client method: a host that has not injected it is NOT a hard error — this hook collapses to " +
|
|
3081
|
-
"{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy."
|
|
3081
|
+
"{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy. " +
|
|
3082
|
+
"With a table bound, loading stays true until the answer for that table (and row) has arrived, so canWrite:false with loading:false is always an answer.",
|
|
3082
3083
|
returnShape: {
|
|
3083
3084
|
canWrite: "boolean",
|
|
3084
3085
|
loading: "boolean",
|
|
@@ -3761,7 +3762,7 @@ const PRIMITIVES = [
|
|
|
3761
3762
|
{
|
|
3762
3763
|
name: "ListRow",
|
|
3763
3764
|
description:
|
|
3764
|
-
'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
|
|
3765
|
+
'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, `ref` (the row\'s press target, so focus can return to the row a person opened), plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
|
|
3765
3766
|
rnComponent: null,
|
|
3766
3767
|
docsUrl: null,
|
|
3767
3768
|
},
|
|
@@ -4328,7 +4329,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4328
4329
|
type: "object",
|
|
4329
4330
|
required: false,
|
|
4330
4331
|
description:
|
|
4331
|
-
"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). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4332
|
+
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4332
4333
|
},
|
|
4333
4334
|
translations: {
|
|
4334
4335
|
type: "object",
|
|
@@ -7055,7 +7056,13 @@ const CONTRACT = deepFreeze({
|
|
|
7055
7056
|
// email? })` opens the app's sign-in screen over the page on both hosts,
|
|
7056
7057
|
// and an event declared for the page to bind to Sign in is the
|
|
7057
7058
|
// `sign-in-event` error.
|
|
7058
|
-
|
|
7059
|
+
// 1.269.0: additive (sc-17385) — `<ListRow ref>` reaches the row's press
|
|
7060
|
+
// target, so a widget can return focus to it; useCanWrite stays
|
|
7061
|
+
// loading until it has the answer for the bound table.
|
|
7062
|
+
// 1.270.0: additive (sc-17197) — a `datastoreTemplate` column may declare
|
|
7063
|
+
// `defaultOnCreate: true`: a create stamps its default over any client
|
|
7064
|
+
// value, and an update may still change it.
|
|
7065
|
+
version: "1.270.0",
|
|
7059
7066
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7060
7067
|
hooks: HOOKS,
|
|
7061
7068
|
primitives: PRIMITIVES,
|
package/dist/hooks.js
CHANGED
|
@@ -4701,6 +4701,11 @@ export function useCanWrite(tableId, options) {
|
|
|
4701
4701
|
const [canWrite, setCanWrite] = useState(false);
|
|
4702
4702
|
const [loading, setLoading] = useState(ready);
|
|
4703
4703
|
const [error, setError] = useState(null);
|
|
4704
|
+
// sc-17385 — the table (and row) the last answer was for. Until it matches
|
|
4705
|
+
// the current one the hook is still loading, so a widget never reads a
|
|
4706
|
+
// render-long canWrite:false before the first request has even started.
|
|
4707
|
+
const [answeredFor, setAnsweredFor] = useState(null);
|
|
4708
|
+
const askedFor = ready ? `${tableId}|${recordId || ""}` : null;
|
|
4704
4709
|
|
|
4705
4710
|
// Same ref discipline as useDatastoreSchema / useRecordPermissions — `ctx`
|
|
4706
4711
|
// is a fresh object identity on every host render, so we hold the live
|
|
@@ -4724,6 +4729,7 @@ export function useCanWrite(tableId, options) {
|
|
|
4724
4729
|
setCanWrite(false);
|
|
4725
4730
|
return;
|
|
4726
4731
|
}
|
|
4732
|
+
const asked = `${t}|${recordIdRef.current || ""}`;
|
|
4727
4733
|
setLoading(true);
|
|
4728
4734
|
setError(null);
|
|
4729
4735
|
// A permission must fail CLOSED: never carry the previous table's or row's
|
|
@@ -4738,6 +4744,7 @@ export function useCanWrite(tableId, options) {
|
|
|
4738
4744
|
? Boolean(result && result.record && result.record.can_write)
|
|
4739
4745
|
: Boolean(result && result.can_create),
|
|
4740
4746
|
);
|
|
4747
|
+
setAnsweredFor(asked);
|
|
4741
4748
|
setLoading(false);
|
|
4742
4749
|
} catch (err) {
|
|
4743
4750
|
if (runRef.current !== myRun) return;
|
|
@@ -4746,6 +4753,7 @@ export function useCanWrite(tableId, options) {
|
|
|
4746
4753
|
// A refusal IS the answer here, not a failure: an anonymous visitor on a
|
|
4747
4754
|
// private table 404s by design. Surfacing it would banner every guest.
|
|
4748
4755
|
setError(e.code === "NOT_FOUND" || e.code === "FORBIDDEN" ? null : e);
|
|
4756
|
+
setAnsweredFor(asked);
|
|
4749
4757
|
setLoading(false);
|
|
4750
4758
|
}
|
|
4751
4759
|
}, []);
|
|
@@ -4763,7 +4771,13 @@ export function useCanWrite(tableId, options) {
|
|
|
4763
4771
|
return _NOOP_CAN_WRITE_RESULT;
|
|
4764
4772
|
}
|
|
4765
4773
|
|
|
4766
|
-
|
|
4774
|
+
const answered = answeredFor === askedFor;
|
|
4775
|
+
return {
|
|
4776
|
+
canWrite: answered && canWrite,
|
|
4777
|
+
loading: loading || !answered,
|
|
4778
|
+
error: answered ? error : null,
|
|
4779
|
+
refetch,
|
|
4780
|
+
};
|
|
4767
4781
|
}
|
|
4768
4782
|
|
|
4769
4783
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -238,6 +238,13 @@ export interface WidgetDatastoreTemplateColumn {
|
|
|
238
238
|
* and on update, so an author column cannot be forged.
|
|
239
239
|
*/
|
|
240
240
|
defaultLocked?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Every create starts the column at `defaultValue` (or empty without one),
|
|
243
|
+
* whatever the client sends; an update may change it through the row's
|
|
244
|
+
* normal access. For a status an approver sets, never the creator. A
|
|
245
|
+
* required column needs a non-empty default.
|
|
246
|
+
*/
|
|
247
|
+
defaultOnCreate?: boolean;
|
|
241
248
|
/**
|
|
242
249
|
* Write-once: a create sets the column as usual (the value sent, or the
|
|
243
250
|
* default), and any value sent for it on update is ignored. Not valid on a
|
|
@@ -4214,7 +4221,8 @@ export interface CanWriteResult {
|
|
|
4214
4221
|
* "signed in but forbidden". Falsy `tableId`, or a host that has not
|
|
4215
4222
|
* injected `ctx.datastore.myPermissions`, collapses to `{ canWrite: false,
|
|
4216
4223
|
* loading: false, error: null, refetch: async () => undefined }` rather than
|
|
4217
|
-
* throwing.
|
|
4224
|
+
* throwing. With a table bound, `loading` stays true until the answer for
|
|
4225
|
+
* that table (and row) has arrived.
|
|
4218
4226
|
*/
|
|
4219
4227
|
export function useCanWrite(
|
|
4220
4228
|
tableId: string | null | undefined,
|
|
@@ -4567,6 +4575,8 @@ export const ListRow: (props: ListRowTokens & {
|
|
|
4567
4575
|
disabled?: boolean;
|
|
4568
4576
|
/** Defaults to true; pass false on the last row. */
|
|
4569
4577
|
divider?: boolean;
|
|
4578
|
+
/** The row's press target (the row itself when it is not pressable), so focus can return to it. */
|
|
4579
|
+
ref?: { current: any } | ((node: any) => void);
|
|
4570
4580
|
accessibilityLabel?: string;
|
|
4571
4581
|
style?: any;
|
|
4572
4582
|
testID?: string;
|
package/dist/list-view.js
CHANGED
|
@@ -192,6 +192,7 @@ export function makeList(rn) {
|
|
|
192
192
|
Pressable,
|
|
193
193
|
{
|
|
194
194
|
...pressProps(props),
|
|
195
|
+
ref: props.ref,
|
|
195
196
|
onPressIn: () => row.setPressed(true),
|
|
196
197
|
onPressOut: () => row.setPressed(false),
|
|
197
198
|
style: [pressRegionStyle(style, row.theme.spacing), disabled ? { opacity: 0.5 } : null],
|
|
@@ -215,6 +216,7 @@ export function makeList(rn) {
|
|
|
215
216
|
View,
|
|
216
217
|
{
|
|
217
218
|
style: [rowStyle, row.pressed ? pressedFill : null, style],
|
|
219
|
+
ref: row.splitPress ? undefined : props.ref,
|
|
218
220
|
testID,
|
|
219
221
|
accessibilityLabel: row.splitPress ? undefined : accessibilityLabel,
|
|
220
222
|
accessible: accessibilityLabel && !row.splitPress ? true : undefined,
|
|
@@ -226,6 +228,7 @@ export function makeList(rn) {
|
|
|
226
228
|
Pressable,
|
|
227
229
|
{
|
|
228
230
|
...pressProps(props),
|
|
231
|
+
ref: props.ref,
|
|
229
232
|
testID,
|
|
230
233
|
style: ({ pressed }) => [
|
|
231
234
|
rowStyle,
|
|
@@ -258,6 +261,7 @@ export function makeList(rn) {
|
|
|
258
261
|
Card,
|
|
259
262
|
{
|
|
260
263
|
testID,
|
|
264
|
+
ref: row.splitPress ? undefined : props.ref,
|
|
261
265
|
accessibilityLabel: row.splitPress ? undefined : accessibilityLabel,
|
|
262
266
|
accessible: accessibilityLabel && !row.splitPress ? true : undefined,
|
|
263
267
|
containerStyle: [frame, mark, row.pressed ? pressedFill : null, style],
|
|
@@ -271,6 +275,7 @@ export function makeList(rn) {
|
|
|
271
275
|
as: Pressable,
|
|
272
276
|
fillInGradient: true,
|
|
273
277
|
...pressProps(props),
|
|
278
|
+
ref: props.ref,
|
|
274
279
|
testID,
|
|
275
280
|
containerStyle: ({ pressed }) => [
|
|
276
281
|
frame,
|
|
@@ -306,6 +311,7 @@ export function makeList(rn) {
|
|
|
306
311
|
}
|
|
307
312
|
List.displayName = "List";
|
|
308
313
|
|
|
314
|
+
// React 19 hands `ref` over as a prop; it reaches the row's press target.
|
|
309
315
|
function ListRow(props) {
|
|
310
316
|
const [theme, tokens, list] = useRowTokens(props);
|
|
311
317
|
const [pressed, setPressed] = React.useState(false);
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -3078,7 +3078,8 @@ const HOOKS = [
|
|
|
3078
3078
|
"NOT distinguish 'not signed in' from 'signed in but forbidden' (both resolve canWrite:false); pair it with useUser() when the UI needs to " +
|
|
3079
3079
|
"tell those apart. For a LIST, gate each row's edit/delete on useDatastoreQuery's `includeCapabilities` answer instead — a " +
|
|
3080
3080
|
"{ recordId } check per row is one request per row, and the table-level answer only says whether they may CREATE. myPermissions is a newer client method: a host that has not injected it is NOT a hard error — this hook collapses to " +
|
|
3081
|
-
"{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy."
|
|
3081
|
+
"{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy. " +
|
|
3082
|
+
"With a table bound, loading stays true until the answer for that table (and row) has arrived, so canWrite:false with loading:false is always an answer.",
|
|
3082
3083
|
returnShape: {
|
|
3083
3084
|
canWrite: "boolean",
|
|
3084
3085
|
loading: "boolean",
|
|
@@ -3761,7 +3762,7 @@ const PRIMITIVES = [
|
|
|
3761
3762
|
{
|
|
3762
3763
|
name: "ListRow",
|
|
3763
3764
|
description:
|
|
3764
|
-
'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
|
|
3765
|
+
'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, `ref` (the row\'s press target, so focus can return to the row a person opened), plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
|
|
3765
3766
|
rnComponent: null,
|
|
3766
3767
|
docsUrl: null,
|
|
3767
3768
|
},
|
|
@@ -4328,7 +4329,7 @@ const MANIFEST_SCHEMA = {
|
|
|
4328
4329
|
type: "object",
|
|
4329
4330
|
required: false,
|
|
4330
4331
|
description:
|
|
4331
|
-
"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). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4332
|
+
"Optional. Tables the widget needs, seeded into the workspace at install time. Authors wire them into the widget's `tableRef` properties via the Properties Panel — the SDK does not auto-bind. Limits: 100 tables, 200 columns per table, 100 sample rows per table and 20000 sample cells across the whole template (each row counts the keys it sets, and at least one, summed over every table). RELATION columns address siblings by `targetSuffix` (any table in the same array, in any order; tables may relate to each other both ways). Tables persist across uninstalls. A `tableRef` property may also carry `sharedTable: true`, declaring that the table is the APP'S OWN — the author picks an existing table and the widget seeds nothing for it. That is the correct shape for a widget that reads data it does not own (a chart, a metric, a manager view over another widget's table). `sharedTable` exempts the property from needing a seeded table at publish (`manifest.requiredTableRefsHaveTemplate`) WITHOUT making it optional: the author must still bind one, and the host still refuses to place the widget unbound. Use it instead of dropping `required` — a widget that silently renders an empty tile is the defect it looks like a fix for. sc-7530: a table may also declare `roleGrants` — group-scoped access named SYMBOLICALLY, because a group id belongs to the workspace that installs the widget and could never travel in the manifest. Declare the audiences once at template level as `roles: [{ key, label, description? }]` (key is lowercase kebab, max 32 roles), then per table `roleGrants: [{ role, canRead?, canWrite?, canDelete? }]`. The installing workspace binds each role to one of its own user groups (or has one created) during the install consent step, so a permission model where an admin group does everything and signed-in users only read survives the trip between workspaces. Use `publicGrant` for the two id-less audiences (everyone / any signed-in user) and `roleGrants` for anything that names a group. A role nobody binds simply writes no grant — it never fails the install. sc-7557: a column may declare `encrypted: true` — its values are stored AES-256-GCM encrypted at rest under a per-workspace subkey. The widget still reads and writes PLAINTEXT (the platform encrypts on write, decrypts for end users); studio users see `🔒` instead, and the column cannot be searched, filtered or sorted on. Sample `rows` you seed for it are encrypted the same way. Not valid on `RELATION` — its value is a foreign key the backend must resolve — and publishing one is rejected. An `inheritAcl` RELATION column may add `inheritAclReadOnly: true` — rows then inherit READ access only, so members of the parent read every child and may add children, but change or delete only the rows they created (pair with `grantCreatorPermissions`). A column may declare `defaultValue`, written when a create omits it: `@currentUser` on USER, `@now` on DATE / DATETIME, `@uuid` on UUID (a new random id per row), or a literal of the column's own type (none on FILE, RELATION or USER_GROUP — ids belong to the installing workspace). `defaultLocked: true` on an `@currentUser` / `@now` / `@uuid` default makes the server always stamp it and ignore any client value on create and update, so an author column cannot be forged. `immutable: true` makes a column write-once: a create sets it as usual and any value sent for it on update is ignored (not valid on a MANY_TO_MANY relation). `defaultOnCreate: true` makes every create start the column at its `defaultValue` (or empty without one) whatever the client sends, while an update may change it through the row's normal access, so a creator cannot file a row already approved; it protects only a table whose filers cannot edit their row afterwards, so no `grantCreatorPermissions` there (a required column needs a non-empty default; not on a paymentStatus, latestVia or copyOf column). `paymentStatus: true` makes a STRING or BOOL column the table's payment status (at most one per table; not required, encrypted, immutable or defaulting to paid): a settled `requestPayment({ order: { table_id, record_id } })` for one of its rows writes it (`PAID`, or `true` on a BOOL; `REFUNDED` / `false` after a full refund), and every client value for it is ignored, so a buyer cannot mark their own order paid. A table may declare `presence: true` so the people who share a row see which of each other are online (useOnlineMembers); it takes effect only while the workspace records user activity, and an upgrade that declares it turns it on for the existing table. A table whose rows people join and leave through per-record grants (conversations) may declare `deleteWhenLastMemberLeaves: true`: when a signed-in member giving up their own grant leaves a row with no grant and no table-wide grant lets anyone read it, the row and every row a CASCADE relation ties to it (including rows deleted earlier) are deleted for good. A row that never had a grant (a seeded sample row) is never deleted this way, and a revoke made in the Studio never deletes. An upgrade that declares it turns it on for the existing table. A ONE_TO_ONE / ONE_TO_MANY RELATION may declare `latestVia: \"<relation column on its target that points back>\"` (onDelete left at SET_NULL; that relation must have inheritAcl and be immutable): the server keeps it at the newest row of the target table that points back at this row. A column may declare `copyOf: { via, column }`: the server keeps it equal to `column` on the row the latest-row column `via` points at (same type, or text into text, cut to 140 characters in a STRING column; a copy of an encrypted column must be encrypted, and a copy cannot inheritAcl). Both are written only by the server, in the same write as the related row; a client value is ignored. A table may declare `constraints`, checked on every write for every client and refused as CONSTRAINT_VIOLATION: `unique` ({ columns, partitionColumns?, unlessRelated?: { relation, column } } — waived for rows whose related row has that yes/no column set), `no-overlap` ({ startColumn, endColumn, partitionColumns? }), `related-open` ({ relation, closedColumn } — no row is added, changed or removed while the related row's column is filled) and `related-index` ({ column, relation, listColumn } — the number must be a position in the related row's list). An upgrade adds a declared constraint to an existing table without judging the rows already in it.",
|
|
4332
4333
|
},
|
|
4333
4334
|
translations: {
|
|
4334
4335
|
type: "object",
|
|
@@ -7055,7 +7056,13 @@ const CONTRACT = deepFreeze({
|
|
|
7055
7056
|
// email? })` opens the app's sign-in screen over the page on both hosts,
|
|
7056
7057
|
// and an event declared for the page to bind to Sign in is the
|
|
7057
7058
|
// `sign-in-event` error.
|
|
7058
|
-
|
|
7059
|
+
// 1.269.0: additive (sc-17385) — `<ListRow ref>` reaches the row's press
|
|
7060
|
+
// target, so a widget can return focus to it; useCanWrite stays
|
|
7061
|
+
// loading until it has the answer for the bound table.
|
|
7062
|
+
// 1.270.0: additive (sc-17197) — a `datastoreTemplate` column may declare
|
|
7063
|
+
// `defaultOnCreate: true`: a create stamps its default over any client
|
|
7064
|
+
// value, and an update may still change it.
|
|
7065
|
+
version: "1.270.0",
|
|
7059
7066
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7060
7067
|
hooks: HOOKS,
|
|
7061
7068
|
primitives: PRIMITIVES,
|