@relyio/sdk 0.18.0 → 0.20.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 (58) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/automations/index.cjs +18 -17
  3. package/dist/automations/index.d.cts +2 -1307
  4. package/dist/automations/index.d.ts +2 -1307
  5. package/dist/automations/index.js +3 -2
  6. package/dist/{chunk-ZAMAR3X2.cjs → chunk-5F3YYPLZ.cjs} +11249 -10771
  7. package/dist/{chunk-ZO6QDYJG.cjs → chunk-5WGMIQBH.cjs} +2 -2
  8. package/dist/{chunk-LSI26ZN2.cjs → chunk-DBYMG6MQ.cjs} +5 -5
  9. package/dist/{chunk-W2A4OTCI.js → chunk-EQUZNVAR.js} +2 -2
  10. package/dist/{chunk-IFKF72VJ.cjs → chunk-K66MBRI4.cjs} +147 -71
  11. package/dist/{chunk-ZHTJ7GXH.js → chunk-L42C4G2S.js} +106 -31
  12. package/dist/{chunk-EDE2H37D.js → chunk-OUR7OUUZ.js} +174 -12
  13. package/dist/{chunk-W7JFHSFM.js → chunk-PZCDJFMA.js} +11249 -10772
  14. package/dist/{chunk-SHSK7UUY.cjs → chunk-UO2QRYKV.cjs} +177 -11
  15. package/dist/{chunk-R6E4HE7R.js → chunk-W2GRVXDG.js} +3 -3
  16. package/dist/client/index.cjs +5 -5
  17. package/dist/client/index.d.cts +4 -4
  18. package/dist/client/index.d.ts +4 -4
  19. package/dist/client/index.js +3 -3
  20. package/dist/{define-content-type-NEQDrvdq.d.cts → define-content-type-C2HnCYYX.d.cts} +1324 -156
  21. package/dist/{define-content-type-fb-WCD5e.d.ts → define-content-type-CVLUusfx.d.ts} +1324 -156
  22. package/dist/dev-handshake/index.cjs +8 -8
  23. package/dist/dev-handshake/index.d.cts +1 -1
  24. package/dist/dev-handshake/index.d.ts +1 -1
  25. package/dist/dev-handshake/index.js +1 -1
  26. package/dist/extensions/index.cjs +26 -6
  27. package/dist/extensions/index.d.cts +3 -791
  28. package/dist/extensions/index.d.ts +3 -791
  29. package/dist/extensions/index.js +24 -4
  30. package/dist/functions/index.cjs +7 -4
  31. package/dist/functions/index.d.cts +2 -4
  32. package/dist/functions/index.d.ts +2 -4
  33. package/dist/functions/index.js +5 -2
  34. package/dist/{index-DwHcL6x5.d.cts → index-BLVNMYUU.d.cts} +142 -79
  35. package/dist/{index-C4LqrNd1.d.ts → index-BY1xU93u.d.ts} +1 -1
  36. package/dist/{index-Dnmt_UOo.d.cts → index-Cmup6HJY.d.cts} +1 -1
  37. package/dist/index-D1fiaQlK.d.ts +2284 -0
  38. package/dist/index-DImzg3ew.d.cts +2284 -0
  39. package/dist/{index-M3luH06A.d.ts → index-IjSyBr8f.d.ts} +142 -79
  40. package/dist/index.cjs +89 -85
  41. package/dist/index.d.cts +64 -15
  42. package/dist/index.d.ts +64 -15
  43. package/dist/index.js +5 -5
  44. package/dist/preview/index.cjs +3 -3
  45. package/dist/preview/index.js +1 -1
  46. package/dist/rich-text/index.d.cts +2 -2
  47. package/dist/rich-text/index.d.ts +2 -2
  48. package/dist/schema/index.cjs +41 -40
  49. package/dist/schema/index.d.cts +948 -118
  50. package/dist/schema/index.d.ts +948 -118
  51. package/dist/schema/index.js +2 -1
  52. package/dist/types/index.d.cts +1 -1
  53. package/dist/types/index.d.ts +1 -1
  54. package/package.json +5 -5
  55. package/dist/define-schema-DZhtvLiK.d.cts +0 -846
  56. package/dist/define-schema-Dlwh6l_J.d.ts +0 -846
  57. package/dist/register-B53i97A9.d.ts +0 -677
  58. package/dist/register-BYCs0FpF.d.cts +0 -677
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @relyio/sdk
2
2
 
3
+ ## 0.20.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d0114a0: **`relyio.functions` calls are typed.** `relyio generate-types` reads your `relyio/functions/` and its `schema.ts` registers each Function's input and output Fields, so `relyio.functions.checkout({ cartId })` takes and answers what `checkout` declares: a misnamed, missing or mistyped input field, or a Function your project does not declare, is a type error. A project with no Function files stays as it was, its calls untyped. `relyio ci check` compares committed types against the repository's own Functions too.
8
+
9
+ ### Patch Changes
10
+
11
+ - fd31efe: **`validateFile` accepts a wildcard MIME pattern.** A schema's `allowedMimeTypes: ['image/*']` no longer refuses `image/png` client-side; matching is case-insensitive, ignores `;` parameters and takes `*/*`, as the server's presign does.
12
+
13
+ ## 0.19.0
14
+
15
+ ### Minor Changes
16
+
17
+ - 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`.
18
+
19
+ **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.
20
+
21
+ **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.
22
+
23
+ **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.
24
+
25
+ - 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).
26
+
27
+ **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`.
28
+
29
+ - 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`.
30
+
31
+ **`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.
32
+
3
33
  ## 0.18.0
4
34
 
5
35
  ### Minor Changes
@@ -1,70 +1,71 @@
1
1
  'use strict';
2
2
 
3
- var chunkLSI26ZN2_cjs = require('../chunk-LSI26ZN2.cjs');
4
- var chunkZAMAR3X2_cjs = require('../chunk-ZAMAR3X2.cjs');
3
+ var chunkDBYMG6MQ_cjs = require('../chunk-DBYMG6MQ.cjs');
4
+ var chunk5F3YYPLZ_cjs = require('../chunk-5F3YYPLZ.cjs');
5
+ require('../chunk-UO2QRYKV.cjs');
5
6
  require('../chunk-L6DXCKVQ.cjs');
6
7
 
7
8
 
8
9
 
9
10
  Object.defineProperty(exports, "and", {
10
11
  enumerable: true,
11
- get: function () { return chunkLSI26ZN2_cjs.and; }
12
+ get: function () { return chunkDBYMG6MQ_cjs.and; }
12
13
  });
13
14
  Object.defineProperty(exports, "anyEntry", {
14
15
  enumerable: true,
15
- get: function () { return chunkLSI26ZN2_cjs.anyEntry; }
16
+ get: function () { return chunkDBYMG6MQ_cjs.anyEntry; }
16
17
  });
17
18
  Object.defineProperty(exports, "automations", {
18
19
  enumerable: true,
19
- get: function () { return chunkLSI26ZN2_cjs.automations; }
20
+ get: function () { return chunkDBYMG6MQ_cjs.automations; }
20
21
  });
21
22
  Object.defineProperty(exports, "defineAutomation", {
22
23
  enumerable: true,
23
- get: function () { return chunkLSI26ZN2_cjs.defineAutomation; }
24
+ get: function () { return chunkDBYMG6MQ_cjs.defineAutomation; }
24
25
  });
25
26
  Object.defineProperty(exports, "entries", {
26
27
  enumerable: true,
27
- get: function () { return chunkLSI26ZN2_cjs.entries; }
28
+ get: function () { return chunkDBYMG6MQ_cjs.entries; }
28
29
  });
29
30
  Object.defineProperty(exports, "extensionTrigger", {
30
31
  enumerable: true,
31
- get: function () { return chunkLSI26ZN2_cjs.extensionTrigger; }
32
+ get: function () { return chunkDBYMG6MQ_cjs.extensionTrigger; }
32
33
  });
33
34
  Object.defineProperty(exports, "isAutomationFile", {
34
35
  enumerable: true,
35
- get: function () { return chunkLSI26ZN2_cjs.isAutomationFile; }
36
+ get: function () { return chunkDBYMG6MQ_cjs.isAutomationFile; }
36
37
  });
37
38
  Object.defineProperty(exports, "not", {
38
39
  enumerable: true,
39
- get: function () { return chunkLSI26ZN2_cjs.not; }
40
+ get: function () { return chunkDBYMG6MQ_cjs.not; }
40
41
  });
41
42
  Object.defineProperty(exports, "on", {
42
43
  enumerable: true,
43
- get: function () { return chunkLSI26ZN2_cjs.on; }
44
+ get: function () { return chunkDBYMG6MQ_cjs.on; }
44
45
  });
45
46
  Object.defineProperty(exports, "or", {
46
47
  enumerable: true,
47
- get: function () { return chunkLSI26ZN2_cjs.or; }
48
+ get: function () { return chunkDBYMG6MQ_cjs.or; }
48
49
  });
49
50
  Object.defineProperty(exports, "records", {
50
51
  enumerable: true,
51
- get: function () { return chunkLSI26ZN2_cjs.records; }
52
+ get: function () { return chunkDBYMG6MQ_cjs.records; }
52
53
  });
53
54
  Object.defineProperty(exports, "resolveAutomation", {
54
55
  enumerable: true,
55
- get: function () { return chunkLSI26ZN2_cjs.resolveAutomation; }
56
+ get: function () { return chunkDBYMG6MQ_cjs.resolveAutomation; }
56
57
  });
57
58
  Object.defineProperty(exports, "schedule", {
58
59
  enumerable: true,
59
- get: function () { return chunkLSI26ZN2_cjs.schedule; }
60
+ get: function () { return chunkDBYMG6MQ_cjs.schedule; }
60
61
  });
61
62
  Object.defineProperty(exports, "tpl", {
62
63
  enumerable: true,
63
- get: function () { return chunkLSI26ZN2_cjs.tpl; }
64
+ get: function () { return chunkDBYMG6MQ_cjs.tpl; }
64
65
  });
65
66
  Object.defineProperty(exports, "fields", {
66
67
  enumerable: true,
67
- get: function () { return chunkZAMAR3X2_cjs.fields; }
68
+ get: function () { return chunk5F3YYPLZ_cjs.fields; }
68
69
  });
69
70
  //# sourceMappingURL=index.cjs.map
70
71
  //# sourceMappingURL=index.cjs.map