@relyio/sdk 0.17.0 → 0.19.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/CHANGELOG.md +35 -0
- package/dist/automations/index.cjs +71 -0
- package/dist/automations/index.d.cts +1590 -0
- package/dist/automations/index.d.ts +1590 -0
- package/dist/automations/index.js +6 -0
- package/dist/{chunk-RSHMA4KT.cjs → chunk-2SPPU2WG.cjs} +68 -68
- package/dist/{chunk-VS2DEUTN.js → chunk-356SF5Y2.js} +463 -26
- package/dist/chunk-5F3YYPLZ.cjs +19237 -0
- package/dist/chunk-7I3SC7SV.cjs +40 -0
- package/dist/chunk-DBYMG6MQ.cjs +535 -0
- package/dist/chunk-DI6KFDBO.js +43 -0
- package/dist/chunk-HDHBYYEY.js +36 -0
- package/dist/chunk-L6DXCKVQ.cjs +50 -0
- package/dist/{chunk-TZL374LS.cjs → chunk-M7MWNV3Q.cjs} +21 -21
- package/dist/{chunk-H6IBQSMM.js → chunk-NJQK5STK.js} +3 -3
- package/dist/chunk-NN45CSPZ.cjs +872 -0
- package/dist/{chunk-6E22GYPB.cjs → chunk-P23G5NXD.cjs} +781 -337
- package/dist/chunk-PZCDJFMA.js +19195 -0
- package/dist/chunk-T7LGREB3.js +848 -0
- package/dist/{chunk-BBUB7C2Z.js → chunk-W2A4OTCI.js} +3 -3
- package/dist/chunk-W2GRVXDG.js +520 -0
- package/dist/{chunk-5UMY6CS4.js → chunk-ZAKEY6DY.js} +3 -3
- package/dist/{chunk-LSRPMNPT.cjs → chunk-ZO6QDYJG.cjs} +7 -7
- package/dist/client/index.cjs +8 -7
- package/dist/client/index.d.cts +4 -3
- package/dist/client/index.d.ts +4 -3
- package/dist/client/index.js +6 -5
- package/dist/{define-content-type-AuL9-oz6.d.cts → define-content-type-BZ6X8GvL.d.cts} +4547 -842
- package/dist/{define-content-type-BGoQxqLf.d.ts → define-content-type-C12jh8cY.d.ts} +4547 -842
- package/dist/{define-schema-DgCX9YB7.d.ts → define-schema-BPlZl4a2.d.cts} +258 -10
- package/dist/{define-schema-DkXwpp0I.d.cts → define-schema-CK7TtYot.d.ts} +258 -10
- package/dist/dev-handshake/index.cjs +9 -9
- package/dist/dev-handshake/index.js +2 -2
- package/dist/extensions/index.cjs +100 -0
- package/dist/extensions/index.d.cts +6 -0
- package/dist/extensions/index.d.ts +6 -0
- package/dist/extensions/index.js +96 -0
- package/dist/functions/index.cjs +71 -0
- package/dist/functions/index.d.cts +6 -0
- package/dist/functions/index.d.ts +6 -0
- package/dist/functions/index.js +62 -0
- package/dist/{index-BBp8_tn9.d.ts → index-BxNnlc5D.d.ts} +167 -494
- package/dist/{index-DaMZ4FQ_.d.ts → index-C-MymZTe.d.ts} +1 -1
- package/dist/{index-DxRmKPrR.d.cts → index-D5jyIeQ5.d.cts} +167 -494
- package/dist/{index-Bp4AiNT3.d.cts → index-DN0l8RHw.d.cts} +1 -1
- package/dist/index.cjs +208 -185
- package/dist/index.d.cts +147 -17
- package/dist/index.d.ts +147 -17
- package/dist/index.js +11 -16
- package/dist/markdown/index.cjs +382 -382
- package/dist/markdown/index.js +1 -1
- package/dist/preview/index.cjs +11 -10
- package/dist/preview/index.js +3 -2
- package/dist/register-BiMQKVp-.d.ts +693 -0
- package/dist/register-DeMsaurp.d.cts +693 -0
- package/dist/rich-text/index.cjs +12 -12
- package/dist/rich-text/index.d.cts +2 -2
- package/dist/rich-text/index.d.ts +2 -2
- package/dist/rich-text/index.js +2 -2
- package/dist/schema/index.cjs +63 -34
- package/dist/schema/index.d.cts +14 -5
- package/dist/schema/index.d.ts +14 -5
- package/dist/schema/index.js +3 -2
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.cjs +20 -20
- package/dist/utils/index.js +2 -2
- package/package.json +23 -5
- package/dist/chunk-6PTRZP5U.cjs +0 -433
- package/dist/chunk-DIZY6CKM.js +0 -950
- package/dist/chunk-GHYB6IZK.cjs +0 -983
- package/dist/chunk-MWMSFIWN.cjs +0 -17
- package/dist/chunk-OVMIHAYK.js +0 -411
- package/dist/chunk-XQ4QHWZE.js +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @relyio/sdk
|
|
2
2
|
|
|
3
|
+
## 0.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0c154b3: **Declare who may read and write each type.** A Record type takes an Owner field, `fields.owner()`, which RelyIO sets from the signed-in End user's token, and `endUsers` names its Policies — `read`, `create`, `update` (with the `fields` an End user may set) and `delete`, each `'owner'`, `'signedIn'`, `'anyone'` (for a read) or a condition built with `conditionRoot('record' | 'claims')`, `and`, `or` and `not`. `perUser.writesPerMinute` caps one End user's writes, and `onOwnerDeleted: 'delete' | 'keep'` says what becomes of their Records when their identity provider deletes them. A content type's `endUsers.read: { when, otherwise }` Gates it: an entry `when` holds of is served whole, any other as its `otherwise` fields with `_gated: true`. The rule types are exported from `@relyio/sdk/schema` as `PolicyRule`, `NamedPolicyRule`, `WriteRule`, `FieldsWriteRule`, `RecordWriteRule`, `RecordTypeEndUsers` and `OwnerDeletedAction`.
|
|
8
|
+
|
|
9
|
+
**Private fields.** `private: true` on a field keeps it from every publishable-key read and every End user's, whatever key they come with; your server and your Functions still read it.
|
|
10
|
+
|
|
11
|
+
**Clerk's users.** With Clerk in `relyio/extensions.ts`, `clerk.userRef()` declares a reference to a `clerkUser` — the Record RelyIO keeps for each of your Clerk users — and a signed-in End user reads their own `clerkUser`, by its list, by its id, or through an Owner field's include.
|
|
12
|
+
|
|
13
|
+
**Refusals you can catch.** A refused End user token is `EndUserTokenInvalidError`, with `reason` (`expired`, `wrong-audience`, `missing`, …). `PublishableKeyRefusedError` now says how to fix it: send the End user's token, declare `endUsers` on the Function, or call from your server. A unique value an End user's write collides with names no `recordId`: it may be a Record they cannot read.
|
|
14
|
+
|
|
15
|
+
- 6acd363: **Every request carries the signed-in End user's token.** Hand the client your identity provider's token function once — `createClient({ apiKey, getToken })`, Clerk's `getToken` or your own — and each request asks it then: a token is sent as `X-RelyIO-End-User` beside the key, and `null` (or a blank string) sends nothing, so the request is the key's alone. It is asked once per call, so every retry sends the token the first attempt sent; a function that throws rejects the call with nothing sent. It works with a publishable key in a browser and a secret key on a server. `client.with({ getToken })` makes a client that asks its own function in place of its parent's, and `updateConfig({ getToken: null })` stops sending one. A token the API cannot verify is refused `END_USER_TOKEN_INVALID` (401).
|
|
16
|
+
|
|
17
|
+
**Claims are typed from `relyio/extensions.ts`.** `ClaimsOf<typeof extensions>` (`@relyio/sdk/extensions`) is an object with one optional key per Claim the identity Extension's `claims` setting names — `oidc: { claims: 'plan, role' }` is `{ plan?: unknown; role?: unknown }` — so `conditionRoot<ClaimsOf<typeof extensions>>('claims').plan.eq('paid')` compiles and a misspelt Claim does not. A setting is text, so a Claim's value is `unknown`.
|
|
18
|
+
|
|
19
|
+
- 10d761f: **A browser may call a Function that says so.** `defineFunction({ endUsers: 'required', … })` lets a publishable key call it through `relyio.functions.<name>(input)` for a signed-in End user — the call carries their token (`getToken`), and without one it is refused `END_USER_TOKEN_INVALID` (401, reason `missing`); `endUsers: 'optional'` lets it call with or without one. A Function that declares neither is still refused to a publishable key (`PUBLISHABLE_KEY_REFUSED`). The run is bound by the Function's own reach either way — a checkout takes stock the shopper could never write — and the plan names a new or widened `endUsers`.
|
|
20
|
+
|
|
21
|
+
**`run.endUser` names who called.** Any call carrying a verified token — with any key, or to a Public route sent one — hands the run `run.endUser`: `{ subject, claims }`, the subject an Owner field stores, and the Claims your `relyio/extensions.ts` declares. Type them by registering it: `declare module '@relyio/sdk' { interface Register { extensions: typeof extensions } }`. A Record the run creates with no owner named is that End user's; name one to set it yourself.
|
|
22
|
+
|
|
23
|
+
## 0.18.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- 87e12af: **A Function sends an Extension's Action without holding its key.** Declare the Actions a Function may send with the handles `relyio/extensions.ts` gives — `defineFunction({ actions: [webhook.post], … })` — and its `run` is handed `actions.<extension>.<action>(input)` for exactly those, its input and result typed by the Extension's own declaration; any other is a type error. A call is sent through RelyIO with the run's Environment: the run's code holds no Connection, no key and no webhook URL. In a Preview branch with no Preview Connection, nothing is sent: the call is Recorded on the run and answers the Action's sample. A refusal — an Extension with no Connection in Production, an input its fields refuse — throws an `ActionRefused` naming its `code` (`isActionRefused` narrows to it). A Function is never paused for an unconnected Extension; its call fails. Each call is keyed by the run and its order in it, so a run dispatched again sends nothing twice.
|
|
28
|
+
- f9523f7: **Call a Function from your server.** `relyio.functions.checkout({ cartId })` runs the Function `checkout` that your key's Branch runs, on its Dataset, and answers its output. Call it with a secret key: a publishable key is refused `PublishableKeyRefusedError`, and a read-only key runs only a Function whose reach writes nothing. A run whose code threw, or that was ended at its CPU or memory limit, throws `FunctionRunFailedError`, and one still running after five minutes `FunctionRunTimedOutError`; each names the run (`runId`), whose record and console output you can read with `relyio functions logs`. A call waits as long as the service does and is never retried.
|
|
29
|
+
- ebbfffe: **A test run from the Function editor says so.** A run the Function editor's Test run starts has `run.wayIn` `'editor'` and `run.caller` `user:<userId>`, and always runs in that person's own Preview branch: `run.environment` is `'preview'`, it reads Production's Records, and what it writes lands as copies there.
|
|
30
|
+
- 6177f0f: **A Function can store a File, and run in a Container.** In a Function's `run`, `records.file(bytes, { name })` answers a `FunctionFile` to set as the value of a File field in a create, an update or a batch — `records.order.update(id, { invoice: records.file(pdf, { name: 'invoice-1001.pdf' }) })`. The media type is read off the name's extension unless you pass `type`. The bytes are stored privately under the Record, as an upload's are, and a run retried after its write committed names the same File rather than storing it twice. A Function declaring `runtime: 'container'` with `container: { size }` now runs, in RelyIO's own Node 24 image with Chromium and fonts, for up to its `limits.duration` (15 minutes unless it declares up to 60); its requests leave only through the hosts its reach declares, as an Isolate's do.
|
|
31
|
+
- b6a45d3: **Records inside a Function, all or none, written once.** In a Function's `run`, `records.<type>` holds exactly the Record types its reach names: `get`, `list` and `count` for a type it reads, and `create`, `update`, `delete`, `increment` and `decrement` for one it writes, each sent as a batch of one. `records.batch(b => …)` collects operations synchronously — awaiting inside the callback is a type error — sends them as one atomic batch and answers the Records it `created`. A refusal throws a `BatchRefused` naming the `operation`, the `code` and the `field` (`isBatchRefused` narrows to it), and nothing of the batch is written. Every batch is keyed by the run, so a run dispatched again writes nothing twice; pass `idempotencyKey` to `relyio.functions.checkout(input, { idempotencyKey })` and the same key sent again writes nothing the first call wrote. The `upload` the capability object's types named is gone until a Function can store a File.
|
|
32
|
+
- 84df9fe: **A Function answers its own route.** A Function declaring `route: { method, path }` answers at `https://<projectId>.fn.relyio.com/<path>` — a Branch's at `https://<projectId>--<branchId>.fn.relyio.com/<path>` — with its input read from the JSON or form body and the path's `:params`, checked against its `input` fields. `request` on the capability object is the caller's request. Return `respond({ status, headers, body })` from `@relyio/sdk/functions` to answer with a status, headers and body of the Function's own — a redirect after a form post — or any other output to answer it as JSON. `route.public` takes the route without a key, limited to 60 calls a minute per address unless `perIp` says otherwise, and behind Turnstile when `turnstile` names the Secret holding its secret key; `route.cors` lists the browser origins allowed to call it.
|
|
33
|
+
- bb231a8: **Scheduled and Automation runs know what started them.** A Function declaring `schedule: { cron, timezone }` runs once at each firing on Production — never on a Preview branch — and after an outage only the latest missed firing runs. In `run`, `run.wayIn` is `'schedule'` and `run.event` is `{ type: 'function.schedule', scheduledFor }`, the UTC instant the firing was for; a run an Automation step dispatches carries its event there too. Such a run is retried under the same `run.id`, with `run.attempt` counting, so a Records batch it already committed answers as it did and writes nothing twice. `run.caller` names the task, `task:<taskId>`.
|
|
34
|
+
- 8ba3308: **A locale's publication status is `draft` or `published`; `archived` is gone from `localeStatus` and `availableLocales[].status`.** Nothing could archive a single locale — archiving is the entry's act, read from `_metadata.status` — so no read ever reported it. `buildLanguageSwitcher` loses the `showArchived` option and each option's `hasContent`, which only ever said whether a locale was archived and so was always `true`: delete `showArchived` from its calls and stop reading `hasContent`. Code that compared a locale's status to `'archived'` now fails to compile; delete that branch.
|
|
35
|
+
- f422624: **Records: app data your server writes, typed by your schema.** Declare a Record type with `defineRecordType` beside your content types — orders, stock, reviews, carts — with `fields.counter`, `fields.sequence` and `fields.file` among its fields, unique sets, and `expireAfter` for data that should go once it is left alone. `relyio.records(type)` creates, lists (filters, a sort, a count and facets), gets, updates against the revision it read (`If-Match`), deletes and uploads a File, typed by the schema: an update takes no Counter and no Sequence (`RecordUpdateFieldsOf`), and a read answers the fields with `RecordMetadata`. `relyio.records.batch([...])` runs creates, updates, deletes and counter moves across Record types in one transaction, all or none, under an `Idempotency-Key`; `refusedOperationOf(error)` names the operation refused. A content type keeps rollups over the Records that reference its entries (`rollup.count`, `sum`, `average`, `min`, `max`), read beside its fields. A Record route needs a secret key: a publishable key is refused `PublishableKeyRefusedError`.
|
|
36
|
+
- e5a5f94: **A field declared `unique: true` is unique, and a clash says which field, locale and entry in `error.context.blockage`.** A write whose value another entry of the content type already holds in a `unique` field — in that locale, for a localized field — is refused with a `ResourceConflictError` whose `context.blockage` is `{ kind: 'value-taken', facts: { path, code: 'VALUE_TAKEN', locale, value, entryId } }`: the field's path (with its locale for a localized field), the locale whose claim collided, the value, and the id of the entry that holds it. A slug keeps its `slug-taken` blockage. Before, `unique` was accepted on every field and enforced on none but the slug.
|
|
37
|
+
|
|
3
38
|
## 0.17.0
|
|
4
39
|
|
|
5
40
|
### Minor Changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkDBYMG6MQ_cjs = require('../chunk-DBYMG6MQ.cjs');
|
|
4
|
+
var chunk5F3YYPLZ_cjs = require('../chunk-5F3YYPLZ.cjs');
|
|
5
|
+
require('../chunk-NN45CSPZ.cjs');
|
|
6
|
+
require('../chunk-L6DXCKVQ.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "and", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunkDBYMG6MQ_cjs.and; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "anyEntry", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunkDBYMG6MQ_cjs.anyEntry; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "automations", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunkDBYMG6MQ_cjs.automations; }
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, "defineAutomation", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return chunkDBYMG6MQ_cjs.defineAutomation; }
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "entries", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return chunkDBYMG6MQ_cjs.entries; }
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "extensionTrigger", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return chunkDBYMG6MQ_cjs.extensionTrigger; }
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "isAutomationFile", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return chunkDBYMG6MQ_cjs.isAutomationFile; }
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "not", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () { return chunkDBYMG6MQ_cjs.not; }
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "on", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () { return chunkDBYMG6MQ_cjs.on; }
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, "or", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () { return chunkDBYMG6MQ_cjs.or; }
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "records", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () { return chunkDBYMG6MQ_cjs.records; }
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "resolveAutomation", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () { return chunkDBYMG6MQ_cjs.resolveAutomation; }
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(exports, "schedule", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () { return chunkDBYMG6MQ_cjs.schedule; }
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "tpl", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () { return chunkDBYMG6MQ_cjs.tpl; }
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "fields", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () { return chunk5F3YYPLZ_cjs.fields; }
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=index.cjs.map
|
|
71
|
+
//# sourceMappingURL=index.cjs.map
|