@relyio/sdk 0.16.0 → 0.18.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/automations/index.cjs +70 -0
  3. package/dist/automations/index.d.cts +1309 -0
  4. package/dist/automations/index.d.ts +1309 -0
  5. package/dist/automations/index.js +5 -0
  6. package/dist/{chunk-RSHMA4KT.cjs → chunk-2SPPU2WG.cjs} +68 -68
  7. package/dist/chunk-7I3SC7SV.cjs +40 -0
  8. package/dist/chunk-DI6KFDBO.js +43 -0
  9. package/dist/chunk-EDE2H37D.js +686 -0
  10. package/dist/chunk-HDHBYYEY.js +36 -0
  11. package/dist/{chunk-RLLZUFDB.cjs → chunk-IFKF72VJ.cjs} +718 -331
  12. package/dist/chunk-L6DXCKVQ.cjs +50 -0
  13. package/dist/chunk-LSI26ZN2.cjs +535 -0
  14. package/dist/{chunk-TZL374LS.cjs → chunk-M7MWNV3Q.cjs} +21 -21
  15. package/dist/{chunk-H6IBQSMM.js → chunk-NJQK5STK.js} +3 -3
  16. package/dist/chunk-R6E4HE7R.js +520 -0
  17. package/dist/chunk-SHSK7UUY.cjs +706 -0
  18. package/dist/{chunk-BBUB7C2Z.js → chunk-W2A4OTCI.js} +3 -3
  19. package/dist/chunk-W7JFHSFM.js +18718 -0
  20. package/dist/{chunk-5UMY6CS4.js → chunk-ZAKEY6DY.js} +3 -3
  21. package/dist/chunk-ZAMAR3X2.cjs +18759 -0
  22. package/dist/{chunk-NIUOPIIB.js → chunk-ZHTJ7GXH.js} +400 -19
  23. package/dist/{chunk-LSRPMNPT.cjs → chunk-ZO6QDYJG.cjs} +7 -7
  24. package/dist/client/index.cjs +8 -7
  25. package/dist/client/index.d.cts +4 -3
  26. package/dist/client/index.d.ts +4 -3
  27. package/dist/client/index.js +6 -5
  28. package/dist/{define-content-type-LkI0rS2W.d.cts → define-content-type-NEQDrvdq.d.cts} +3420 -749
  29. package/dist/{define-content-type-CAWSlgn0.d.ts → define-content-type-fb-WCD5e.d.ts} +3420 -749
  30. package/dist/{define-schema-Dxu3RoHV.d.ts → define-schema-DZhtvLiK.d.cts} +157 -10
  31. package/dist/{define-schema-wlsJOrnY.d.cts → define-schema-Dlwh6l_J.d.ts} +157 -10
  32. package/dist/dev-handshake/index.cjs +9 -9
  33. package/dist/dev-handshake/index.js +2 -2
  34. package/dist/extensions/index.cjs +80 -0
  35. package/dist/extensions/index.d.cts +792 -0
  36. package/dist/extensions/index.d.ts +792 -0
  37. package/dist/extensions/index.js +76 -0
  38. package/dist/functions/index.cjs +68 -0
  39. package/dist/functions/index.d.cts +6 -0
  40. package/dist/functions/index.d.ts +6 -0
  41. package/dist/functions/index.js +59 -0
  42. package/dist/{index-CGtYxUuh.d.ts → index-C4LqrNd1.d.ts} +1 -1
  43. package/dist/{index-CcHmRALk.d.cts → index-Dnmt_UOo.d.cts} +1 -1
  44. package/dist/{index-D80MXUkf.d.cts → index-DwHcL6x5.d.cts} +103 -442
  45. package/dist/{index-BH8JksfG.d.ts → index-M3luH06A.d.ts} +103 -442
  46. package/dist/index.cjs +204 -185
  47. package/dist/index.d.cts +93 -13
  48. package/dist/index.d.ts +93 -13
  49. package/dist/index.js +11 -16
  50. package/dist/markdown/index.cjs +382 -382
  51. package/dist/markdown/index.js +1 -1
  52. package/dist/preview/index.cjs +11 -10
  53. package/dist/preview/index.js +3 -2
  54. package/dist/register-B53i97A9.d.ts +677 -0
  55. package/dist/register-BYCs0FpF.d.cts +677 -0
  56. package/dist/rich-text/index.cjs +12 -12
  57. package/dist/rich-text/index.d.cts +2 -2
  58. package/dist/rich-text/index.d.ts +2 -2
  59. package/dist/rich-text/index.js +2 -2
  60. package/dist/schema/index.cjs +62 -34
  61. package/dist/schema/index.d.cts +127 -5
  62. package/dist/schema/index.d.ts +127 -5
  63. package/dist/schema/index.js +2 -2
  64. package/dist/types/index.d.cts +1 -1
  65. package/dist/types/index.d.ts +1 -1
  66. package/dist/utils/index.cjs +20 -20
  67. package/dist/utils/index.js +2 -2
  68. package/package.json +21 -3
  69. package/dist/chunk-7BZW6XYJ.cjs +0 -433
  70. package/dist/chunk-CQHEG7QA.js +0 -411
  71. package/dist/chunk-DIZY6CKM.js +0 -950
  72. package/dist/chunk-GHYB6IZK.cjs +0 -983
  73. package/dist/chunk-MWMSFIWN.cjs +0 -17
  74. package/dist/chunk-XQ4QHWZE.js +0 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @relyio/sdk
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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.
8
+ - 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.
9
+ - 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.
10
+ - 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.
11
+ - 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.
12
+ - 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.
13
+ - 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>`.
14
+ - 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.
15
+ - 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`.
16
+ - 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.
17
+
18
+ ## 0.17.0
19
+
20
+ ### Minor Changes
21
+
22
+ - fb6625a: `content(type).create()` and `update()` answer `_metadata.warnings`: each reference the content type declares `weak` that the write published while the entry it points at is unpublished, as `{ path, code: 'REFERENCE_NOT_PUBLISHED', message }`. Always present, `[]` when there are none; the write is never refused for them. `create()` now returns `CreatedContent<T>`, the entry with that list.
23
+
24
+ `singleton(key).update()`, `settings(group).update()` and `settings(group).reset()` answer the same `_metadata.warnings`, beside the `_metadata.brokenLinks` they already carried; they now return `WrittenSingleton<T>` and `WrittenSettingsGroup<T>`. A `batch()` item for any write but a delete carries the list under `data._metadata.warnings` as well.
25
+
3
26
  ## 0.16.0
4
27
 
5
28
  ### Minor Changes
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ var chunkLSI26ZN2_cjs = require('../chunk-LSI26ZN2.cjs');
4
+ var chunkZAMAR3X2_cjs = require('../chunk-ZAMAR3X2.cjs');
5
+ require('../chunk-L6DXCKVQ.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "and", {
10
+ enumerable: true,
11
+ get: function () { return chunkLSI26ZN2_cjs.and; }
12
+ });
13
+ Object.defineProperty(exports, "anyEntry", {
14
+ enumerable: true,
15
+ get: function () { return chunkLSI26ZN2_cjs.anyEntry; }
16
+ });
17
+ Object.defineProperty(exports, "automations", {
18
+ enumerable: true,
19
+ get: function () { return chunkLSI26ZN2_cjs.automations; }
20
+ });
21
+ Object.defineProperty(exports, "defineAutomation", {
22
+ enumerable: true,
23
+ get: function () { return chunkLSI26ZN2_cjs.defineAutomation; }
24
+ });
25
+ Object.defineProperty(exports, "entries", {
26
+ enumerable: true,
27
+ get: function () { return chunkLSI26ZN2_cjs.entries; }
28
+ });
29
+ Object.defineProperty(exports, "extensionTrigger", {
30
+ enumerable: true,
31
+ get: function () { return chunkLSI26ZN2_cjs.extensionTrigger; }
32
+ });
33
+ Object.defineProperty(exports, "isAutomationFile", {
34
+ enumerable: true,
35
+ get: function () { return chunkLSI26ZN2_cjs.isAutomationFile; }
36
+ });
37
+ Object.defineProperty(exports, "not", {
38
+ enumerable: true,
39
+ get: function () { return chunkLSI26ZN2_cjs.not; }
40
+ });
41
+ Object.defineProperty(exports, "on", {
42
+ enumerable: true,
43
+ get: function () { return chunkLSI26ZN2_cjs.on; }
44
+ });
45
+ Object.defineProperty(exports, "or", {
46
+ enumerable: true,
47
+ get: function () { return chunkLSI26ZN2_cjs.or; }
48
+ });
49
+ Object.defineProperty(exports, "records", {
50
+ enumerable: true,
51
+ get: function () { return chunkLSI26ZN2_cjs.records; }
52
+ });
53
+ Object.defineProperty(exports, "resolveAutomation", {
54
+ enumerable: true,
55
+ get: function () { return chunkLSI26ZN2_cjs.resolveAutomation; }
56
+ });
57
+ Object.defineProperty(exports, "schedule", {
58
+ enumerable: true,
59
+ get: function () { return chunkLSI26ZN2_cjs.schedule; }
60
+ });
61
+ Object.defineProperty(exports, "tpl", {
62
+ enumerable: true,
63
+ get: function () { return chunkLSI26ZN2_cjs.tpl; }
64
+ });
65
+ Object.defineProperty(exports, "fields", {
66
+ enumerable: true,
67
+ get: function () { return chunkZAMAR3X2_cjs.fields; }
68
+ });
69
+ //# sourceMappingURL=index.cjs.map
70
+ //# sourceMappingURL=index.cjs.map