@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/automations/index.cjs +71 -0
  3. package/dist/automations/index.d.cts +1590 -0
  4. package/dist/automations/index.d.ts +1590 -0
  5. package/dist/automations/index.js +6 -0
  6. package/dist/{chunk-RSHMA4KT.cjs → chunk-2SPPU2WG.cjs} +68 -68
  7. package/dist/{chunk-VS2DEUTN.js → chunk-356SF5Y2.js} +463 -26
  8. package/dist/chunk-5F3YYPLZ.cjs +19237 -0
  9. package/dist/chunk-7I3SC7SV.cjs +40 -0
  10. package/dist/chunk-DBYMG6MQ.cjs +535 -0
  11. package/dist/chunk-DI6KFDBO.js +43 -0
  12. package/dist/chunk-HDHBYYEY.js +36 -0
  13. package/dist/chunk-L6DXCKVQ.cjs +50 -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-NN45CSPZ.cjs +872 -0
  17. package/dist/{chunk-6E22GYPB.cjs → chunk-P23G5NXD.cjs} +781 -337
  18. package/dist/chunk-PZCDJFMA.js +19195 -0
  19. package/dist/chunk-T7LGREB3.js +848 -0
  20. package/dist/{chunk-BBUB7C2Z.js → chunk-W2A4OTCI.js} +3 -3
  21. package/dist/chunk-W2GRVXDG.js +520 -0
  22. package/dist/{chunk-5UMY6CS4.js → chunk-ZAKEY6DY.js} +3 -3
  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-AuL9-oz6.d.cts → define-content-type-BZ6X8GvL.d.cts} +4547 -842
  29. package/dist/{define-content-type-BGoQxqLf.d.ts → define-content-type-C12jh8cY.d.ts} +4547 -842
  30. package/dist/{define-schema-DgCX9YB7.d.ts → define-schema-BPlZl4a2.d.cts} +258 -10
  31. package/dist/{define-schema-DkXwpp0I.d.cts → define-schema-CK7TtYot.d.ts} +258 -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 +100 -0
  35. package/dist/extensions/index.d.cts +6 -0
  36. package/dist/extensions/index.d.ts +6 -0
  37. package/dist/extensions/index.js +96 -0
  38. package/dist/functions/index.cjs +71 -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 +62 -0
  42. package/dist/{index-BBp8_tn9.d.ts → index-BxNnlc5D.d.ts} +167 -494
  43. package/dist/{index-DaMZ4FQ_.d.ts → index-C-MymZTe.d.ts} +1 -1
  44. package/dist/{index-DxRmKPrR.d.cts → index-D5jyIeQ5.d.cts} +167 -494
  45. package/dist/{index-Bp4AiNT3.d.cts → index-DN0l8RHw.d.cts} +1 -1
  46. package/dist/index.cjs +208 -185
  47. package/dist/index.d.cts +147 -17
  48. package/dist/index.d.ts +147 -17
  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-BiMQKVp-.d.ts +693 -0
  55. package/dist/register-DeMsaurp.d.cts +693 -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 +63 -34
  61. package/dist/schema/index.d.cts +14 -5
  62. package/dist/schema/index.d.ts +14 -5
  63. package/dist/schema/index.js +3 -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 +23 -5
  69. package/dist/chunk-6PTRZP5U.cjs +0 -433
  70. package/dist/chunk-DIZY6CKM.js +0 -950
  71. package/dist/chunk-GHYB6IZK.cjs +0 -983
  72. package/dist/chunk-MWMSFIWN.cjs +0 -17
  73. package/dist/chunk-OVMIHAYK.js +0 -411
  74. package/dist/chunk-XQ4QHWZE.js +0 -13
@@ -1,81 +1,81 @@
1
1
  'use strict';
2
2
 
3
- var chunkTZL374LS_cjs = require('../chunk-TZL374LS.cjs');
4
- require('../chunk-MWMSFIWN.cjs');
3
+ var chunkM7MWNV3Q_cjs = require('../chunk-M7MWNV3Q.cjs');
4
+ require('../chunk-L6DXCKVQ.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "camelToSnake", {
9
9
  enumerable: true,
10
- get: function () { return chunkTZL374LS_cjs.camelToSnake; }
10
+ get: function () { return chunkM7MWNV3Q_cjs.camelToSnake; }
11
11
  });
12
12
  Object.defineProperty(exports, "createDeferred", {
13
13
  enumerable: true,
14
- get: function () { return chunkTZL374LS_cjs.createDeferred; }
14
+ get: function () { return chunkM7MWNV3Q_cjs.createDeferred; }
15
15
  });
16
16
  Object.defineProperty(exports, "debounce", {
17
17
  enumerable: true,
18
- get: function () { return chunkTZL374LS_cjs.debounce; }
18
+ get: function () { return chunkM7MWNV3Q_cjs.debounce; }
19
19
  });
20
20
  Object.defineProperty(exports, "deepClone", {
21
21
  enumerable: true,
22
- get: function () { return chunkTZL374LS_cjs.deepClone; }
22
+ get: function () { return chunkM7MWNV3Q_cjs.deepClone; }
23
23
  });
24
24
  Object.defineProperty(exports, "generateId", {
25
25
  enumerable: true,
26
- get: function () { return chunkTZL374LS_cjs.generateId; }
26
+ get: function () { return chunkM7MWNV3Q_cjs.generateId; }
27
27
  });
28
28
  Object.defineProperty(exports, "isBrowser", {
29
29
  enumerable: true,
30
- get: function () { return chunkTZL374LS_cjs.isBrowser; }
30
+ get: function () { return chunkM7MWNV3Q_cjs.isBrowser; }
31
31
  });
32
32
  Object.defineProperty(exports, "isNode", {
33
33
  enumerable: true,
34
- get: function () { return chunkTZL374LS_cjs.isNode; }
34
+ get: function () { return chunkM7MWNV3Q_cjs.isNode; }
35
35
  });
36
36
  Object.defineProperty(exports, "isPlainObject", {
37
37
  enumerable: true,
38
- get: function () { return chunkTZL374LS_cjs.isPlainObject; }
38
+ get: function () { return chunkM7MWNV3Q_cjs.isPlainObject; }
39
39
  });
40
40
  Object.defineProperty(exports, "isValidEmail", {
41
41
  enumerable: true,
42
- get: function () { return chunkTZL374LS_cjs.isValidEmail; }
42
+ get: function () { return chunkM7MWNV3Q_cjs.isValidEmail; }
43
43
  });
44
44
  Object.defineProperty(exports, "isValidUrl", {
45
45
  enumerable: true,
46
- get: function () { return chunkTZL374LS_cjs.isValidUrl; }
46
+ get: function () { return chunkM7MWNV3Q_cjs.isValidUrl; }
47
47
  });
48
48
  Object.defineProperty(exports, "mergeDeep", {
49
49
  enumerable: true,
50
- get: function () { return chunkTZL374LS_cjs.mergeDeep; }
50
+ get: function () { return chunkM7MWNV3Q_cjs.mergeDeep; }
51
51
  });
52
52
  Object.defineProperty(exports, "omit", {
53
53
  enumerable: true,
54
- get: function () { return chunkTZL374LS_cjs.omit; }
54
+ get: function () { return chunkM7MWNV3Q_cjs.omit; }
55
55
  });
56
56
  Object.defineProperty(exports, "pick", {
57
57
  enumerable: true,
58
- get: function () { return chunkTZL374LS_cjs.pick; }
58
+ get: function () { return chunkM7MWNV3Q_cjs.pick; }
59
59
  });
60
60
  Object.defineProperty(exports, "retry", {
61
61
  enumerable: true,
62
- get: function () { return chunkTZL374LS_cjs.retry; }
62
+ get: function () { return chunkM7MWNV3Q_cjs.retry; }
63
63
  });
64
64
  Object.defineProperty(exports, "sleep", {
65
65
  enumerable: true,
66
- get: function () { return chunkTZL374LS_cjs.sleep; }
66
+ get: function () { return chunkM7MWNV3Q_cjs.sleep; }
67
67
  });
68
68
  Object.defineProperty(exports, "snakeToCamel", {
69
69
  enumerable: true,
70
- get: function () { return chunkTZL374LS_cjs.snakeToCamel; }
70
+ get: function () { return chunkM7MWNV3Q_cjs.snakeToCamel; }
71
71
  });
72
72
  Object.defineProperty(exports, "throttle", {
73
73
  enumerable: true,
74
- get: function () { return chunkTZL374LS_cjs.throttle; }
74
+ get: function () { return chunkM7MWNV3Q_cjs.throttle; }
75
75
  });
76
76
  Object.defineProperty(exports, "toSafeString", {
77
77
  enumerable: true,
78
- get: function () { return chunkTZL374LS_cjs.toSafeString; }
78
+ get: function () { return chunkM7MWNV3Q_cjs.toSafeString; }
79
79
  });
80
80
  //# sourceMappingURL=index.cjs.map
81
81
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- export { camelToSnake, createDeferred, debounce, deepClone, generateId, isBrowser, isNode, isPlainObject, isValidEmail, isValidUrl, mergeDeep, omit, pick, retry, sleep, snakeToCamel, throttle, toSafeString } from '../chunk-H6IBQSMM.js';
2
- import '../chunk-XQ4QHWZE.js';
1
+ export { camelToSnake, createDeferred, debounce, deepClone, generateId, isBrowser, isNode, isPlainObject, isValidEmail, isValidUrl, mergeDeep, omit, pick, retry, sleep, snakeToCamel, throttle, toSafeString } from '../chunk-NJQK5STK.js';
2
+ import '../chunk-DI6KFDBO.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relyio/sdk",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "RelyIO is coming soon — this package is not ready for general use yet.",
5
5
  "keywords": [
6
6
  "relyio"
@@ -38,6 +38,24 @@
38
38
  "import": "./dist/preview/index.js",
39
39
  "require": "./dist/preview/index.cjs"
40
40
  },
41
+ "./functions": {
42
+ "types": "./dist/functions/index.d.ts",
43
+ "source": "./src/functions/index.ts",
44
+ "import": "./dist/functions/index.js",
45
+ "require": "./dist/functions/index.cjs"
46
+ },
47
+ "./automations": {
48
+ "types": "./dist/automations/index.d.ts",
49
+ "source": "./src/automations/index.ts",
50
+ "import": "./dist/automations/index.js",
51
+ "require": "./dist/automations/index.cjs"
52
+ },
53
+ "./extensions": {
54
+ "types": "./dist/extensions/index.d.ts",
55
+ "source": "./src/extensions/index.ts",
56
+ "import": "./dist/extensions/index.js",
57
+ "require": "./dist/extensions/index.cjs"
58
+ },
41
59
  "./schema": {
42
60
  "types": "./dist/schema/index.d.ts",
43
61
  "import": "./dist/schema/index.js",
@@ -101,10 +119,10 @@
101
119
  "typedoc": "^0.28.20",
102
120
  "typescript": "npm:@typescript/typescript6@6.0.2",
103
121
  "vitest": "4.1.11",
104
- "@relyio/rich-text-markdown": "0.0.0",
105
- "@relyio/schema": "0.0.1",
122
+ "@relyio/api-contract": "0.1.0",
106
123
  "@relyio/eslint-config": "0.0.0",
107
- "@relyio/api-contract": "0.1.0"
124
+ "@relyio/rich-text-markdown": "0.0.0",
125
+ "@relyio/schema": "0.0.1"
108
126
  },
109
127
  "peerDependencies": {
110
128
  "typescript": ">=4.9.0"
@@ -155,7 +173,7 @@
155
173
  "test:watch": "vitest --watch",
156
174
  "test:coverage": "vitest --coverage",
157
175
  "test:ui": "vitest --ui",
158
- "type:check": "tsc --noEmit && tsc --noEmit -p tsconfig.register-types.json",
176
+ "type:check": "tsc --noEmit && tsc --noEmit -p tsconfig.register-types.json && tsc --noEmit -p tsconfig.register-functions-types.json",
159
177
  "test:types": "tsc --noEmit -p tsconfig.test.json",
160
178
  "codegen:openapi": "node ../../../scripts/emit-openapi-types.mjs ../../../apps/services/api/openapi-spec.json src/http/api-schema.ts",
161
179
  "lint:write": "relyio-lint --fix",
@@ -1,433 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkMWMSFIWN_cjs = require('./chunk-MWMSFIWN.cjs');
4
-
5
- /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
6
-
7
- // ../../platform/api-contract/dist/chunk-46347LG2.js
8
- function defineRoute(route) {
9
- if (route.kind === "raw" && route.standardShape === void 0) {
10
- throw new Error("kind 'raw' requires a named StandardShape");
11
- }
12
- if (route.kind === "raw" && route.success === 302 && !route.headers.some((header) => header.name === "Location")) {
13
- throw new Error("a raw route declaring success 302 must declare its 'Location' header");
14
- }
15
- if (route.kind === "stream" && route.stream === void 0) {
16
- throw new Error("kind 'stream' requires a StreamDeclaration");
17
- }
18
- if (route.kind === "collection" && route.page === void 0) {
19
- throw new Error("kind 'collection' requires a page dialect");
20
- }
21
- if (route.queues === true) {
22
- if (route.kind !== "object" && route.kind !== "empty") {
23
- throw new Error(
24
- `kind '${route.kind}' cannot declare \`queues\`: only an object or empty route answers 202 beside its own status`
25
- );
26
- }
27
- if (route.kind === "object" && route.success === 202) {
28
- throw new Error("a route whose own status is 202 cannot also declare `queues`");
29
- }
30
- }
31
- if ((route.kind === "object" || route.kind === "collection") && route.negotiated !== void 0) {
32
- refuseMismatchedAlternate(route, route.negotiated["text/event-stream"]);
33
- }
34
- return route;
35
- }
36
- chunkMWMSFIWN_cjs.__name(defineRoute, "defineRoute");
37
- function refuseMismatchedAlternate(route, stream) {
38
- if (stream.kind !== "stream") {
39
- throw new Error("a negotiated 'text/event-stream' alternate must be kind 'stream'");
40
- }
41
- if (stream.stream.mediaType !== "text/event-stream") {
42
- throw new Error(
43
- `a negotiated 'text/event-stream' alternate declares media type "${stream.stream.mediaType}"`
44
- );
45
- }
46
- const own = [...new Set(route.codes)].sort();
47
- const alternate = [...new Set(stream.codes)].sort();
48
- if (own.length !== alternate.length || own.some((code, index) => code !== alternate[index])) {
49
- throw new Error(
50
- `a negotiated alternate refuses with [${alternate.join(", ")}] while its route refuses with [${own.join(", ")}]; one route refuses with one set of codes on every transport`
51
- );
52
- }
53
- }
54
- chunkMWMSFIWN_cjs.__name(refuseMismatchedAlternate, "refuseMismatchedAlternate");
55
-
56
- // ../../platform/api-contract/dist/index.js
57
- var HEADER_RETRY_AFTER = { name: "Retry-After" };
58
- var HEADER_IF_MATCH = {
59
- name: "If-Match",
60
- in: "request",
61
- required: false
62
- };
63
- function entityTag(parts) {
64
- return `"${parts.entryUid}:${parts.locale}:${parts.version}:${parts.sharedVersion}"`;
65
- }
66
- chunkMWMSFIWN_cjs.__name(entityTag, "entityTag");
67
- var HEADER_IDEMPOTENCY_KEY = {
68
- name: "Idempotency-Key",
69
- in: "request",
70
- required: false
71
- };
72
- var FRESH_PARAMETER = "_fresh";
73
- var K = new Uint32Array([
74
- 1116352408,
75
- 1899447441,
76
- 3049323471,
77
- 3921009573,
78
- 961987163,
79
- 1508970993,
80
- 2453635748,
81
- 2870763221,
82
- 3624381080,
83
- 310598401,
84
- 607225278,
85
- 1426881987,
86
- 1925078388,
87
- 2162078206,
88
- 2614888103,
89
- 3248222580,
90
- 3835390401,
91
- 4022224774,
92
- 264347078,
93
- 604807628,
94
- 770255983,
95
- 1249150122,
96
- 1555081692,
97
- 1996064986,
98
- 2554220882,
99
- 2821834349,
100
- 2952996808,
101
- 3210313671,
102
- 3336571891,
103
- 3584528711,
104
- 113926993,
105
- 338241895,
106
- 666307205,
107
- 773529912,
108
- 1294757372,
109
- 1396182291,
110
- 1695183700,
111
- 1986661051,
112
- 2177026350,
113
- 2456956037,
114
- 2730485921,
115
- 2820302411,
116
- 3259730800,
117
- 3345764771,
118
- 3516065817,
119
- 3600352804,
120
- 4094571909,
121
- 275423344,
122
- 430227734,
123
- 506948616,
124
- 659060556,
125
- 883997877,
126
- 958139571,
127
- 1322822218,
128
- 1537002063,
129
- 1747873779,
130
- 1955562222,
131
- 2024104815,
132
- 2227730452,
133
- 2361852424,
134
- 2428436474,
135
- 2756734187,
136
- 3204031479,
137
- 3329325298
138
- ]);
139
- var rotr = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((value, bits) => value >>> bits | value << 32 - bits, "rotr");
140
- function sha256Hex(text) {
141
- const bytes = new globalThis.TextEncoder().encode(text);
142
- const blocks = Math.ceil((bytes.length + 9) / 64);
143
- const padded = new Uint8Array(blocks * 64);
144
- padded.set(bytes);
145
- padded[bytes.length] = 128;
146
- const view = new DataView(padded.buffer);
147
- const bits = bytes.length * 8;
148
- view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
149
- view.setUint32(padded.length - 4, bits >>> 0);
150
- const hash = new Uint32Array([
151
- 1779033703,
152
- 3144134277,
153
- 1013904242,
154
- 2773480762,
155
- 1359893119,
156
- 2600822924,
157
- 528734635,
158
- 1541459225
159
- ]);
160
- const w = new Uint32Array(64);
161
- for (let block = 0; block < blocks; block++) {
162
- for (let i = 0; i < 16; i++) w[i] = view.getUint32(block * 64 + i * 4);
163
- for (let i = 16; i < 64; i++) {
164
- const w15 = w[i - 15];
165
- const w2 = w[i - 2];
166
- const s0 = rotr(w15, 7) ^ rotr(w15, 18) ^ w15 >>> 3;
167
- const s1 = rotr(w2, 17) ^ rotr(w2, 19) ^ w2 >>> 10;
168
- w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
169
- }
170
- let a = hash[0];
171
- let b = hash[1];
172
- let c = hash[2];
173
- let d = hash[3];
174
- let e = hash[4];
175
- let f = hash[5];
176
- let g = hash[6];
177
- let h = hash[7];
178
- for (let i = 0; i < 64; i++) {
179
- const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
180
- const choice = e & f ^ ~e & g;
181
- const t1 = h + s1 + choice + K[i] + w[i] >>> 0;
182
- const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
183
- const majority = a & b ^ a & c ^ b & c;
184
- const t2 = s0 + majority >>> 0;
185
- h = g;
186
- g = f;
187
- f = e;
188
- e = d + t1 >>> 0;
189
- d = c;
190
- c = b;
191
- b = a;
192
- a = t1 + t2 >>> 0;
193
- }
194
- hash[0] = hash[0] + a;
195
- hash[1] = hash[1] + b;
196
- hash[2] = hash[2] + c;
197
- hash[3] = hash[3] + d;
198
- hash[4] = hash[4] + e;
199
- hash[5] = hash[5] + f;
200
- hash[6] = hash[6] + g;
201
- hash[7] = hash[7] + h;
202
- }
203
- return Array.from(hash, (word) => word.toString(16).padStart(8, "0")).join("");
204
- }
205
- chunkMWMSFIWN_cjs.__name(sha256Hex, "sha256Hex");
206
- var PREVIEW_DATASET_PREFIX = "preview/";
207
- var READABLE_MAX = 40;
208
- var HASH_DIGITS = 8;
209
- function previewDatasetSlug(branch) {
210
- const name = branch.startsWith("refs/heads/") ? branch.slice("refs/heads/".length) : branch;
211
- if (name === "") {
212
- throw new TypeError(`previewDatasetSlug: ${JSON.stringify(branch)} names no Git branch`);
213
- }
214
- const readable = name.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/^-+|-+$/g, "").slice(0, READABLE_MAX).replace(/-+$/, "");
215
- const hash = sha256Hex(name).slice(0, HASH_DIGITS);
216
- return `${PREVIEW_DATASET_PREFIX}${readable === "" ? "" : `${readable}-`}${hash}`;
217
- }
218
- chunkMWMSFIWN_cjs.__name(previewDatasetSlug, "previewDatasetSlug");
219
- var VISITOR_LIVE_PATH = "/visitor/changes";
220
- var VISITOR_QUERY = {
221
- /** The publishable key. */
222
- key: "key",
223
- /** A dataset id or name the key reaches; absent, the key's default dataset. */
224
- dataset: "dataset",
225
- /** The cursor to continue from; absent, the socket starts now. */
226
- since: "since",
227
- /** Comma-separated content types to keep; absent keeps every type. */
228
- types: "types",
229
- /** Comma-separated entry ids to keep; absent keeps every entry. */
230
- ids: "ids",
231
- /** The poll's client id. Required on a poll, and not read on a socket. */
232
- client: "client"
233
- };
234
- var VISITOR_CURSOR = /^[\w.~-]{1,256}$/;
235
- var VISITOR_POLL_INTERVAL_MS = 15e3;
236
- var VISITOR_KEEPALIVE = { request: "ping", response: "pong" };
237
- var VISITOR_FRAMES = {
238
- opened: "feed.opened",
239
- changes: "feed.changes",
240
- resync: "feed.resync"
241
- };
242
- defineRoute({
243
- kind: "object",
244
- headers: [HEADER_RETRY_AFTER],
245
- codes: [
246
- "REQUEST_INVALID",
247
- "MISSING_API_KEY",
248
- "INVALID_API_KEY",
249
- "ACCESS_DENIED",
250
- "METHOD_NOT_ALLOWED",
251
- "SERVICE_INDETERMINATE",
252
- "USAGE_QUOTA_EXCEEDED",
253
- "RATE_LIMIT_EXCEEDED"
254
- ]
255
- });
256
- var VISITOR_CLOSE_CODES = {
257
- /** A query the door cannot read: a malformed `since`, filter, `dataset` or `client`. */
258
- requestInvalid: 4400,
259
- /** No publishable key, or one that is unknown, revoked, expired, a secret key or a preview key. */
260
- keyRefused: 4401,
261
- /** The page's `Origin` is absent, or not on the key's allowed origins. */
262
- originRefused: 4403,
263
- /** `dataset` names nothing the key reaches. */
264
- datasetRefused: 4404,
265
- /** The key's scope, the project's counter or the feed could not be reached just now. */
266
- unavailable: 1013,
267
- /**
268
- * The project holds as many visitor connections as its plan allows — Starter's 100 — or its
269
- * Organization is suspended. As HTTP's 402: more needs a bigger plan, or visitors leaving.
270
- */
271
- allowanceReached: 4402,
272
- /** This client's address holds as many connections to the project as one address may. */
273
- addressLimitReached: 4429,
274
- /** The project is at its per-project safety ceiling — Pro's 50,000 — whatever it would pay for. */
275
- ceilingReached: 4503
276
- };
277
- var VISITOR_CLOSE_RETRY = {
278
- 4400: "stop",
279
- 4401: "stop",
280
- 4403: "stop",
281
- 4404: "stop",
282
- 1013: "retry",
283
- 4402: "back-off",
284
- 4429: "back-off",
285
- 4503: "back-off"
286
- };
287
- var VISITOR_POLL_RETRY = {
288
- REQUEST_INVALID: "stop",
289
- MISSING_API_KEY: "stop",
290
- INVALID_API_KEY: "stop",
291
- ACCESS_DENIED: "stop",
292
- METHOD_NOT_ALLOWED: "stop",
293
- SERVICE_INDETERMINATE: "retry",
294
- USAGE_QUOTA_EXCEEDED: "back-off",
295
- RATE_LIMIT_EXCEEDED: "back-off"
296
- };
297
- var VISITOR_ADMISSION_RETRY_AFTER_SECONDS = 60;
298
- function parseVisitorFrame(text) {
299
- let value;
300
- try {
301
- value = JSON.parse(text);
302
- } catch {
303
- return null;
304
- }
305
- if (!isRecord2(value) || !isCursor(value.cursor)) return null;
306
- switch (value.type) {
307
- case VISITOR_FRAMES.opened: {
308
- return hasOnly(value, ["type", "cursor"]) ? { type: VISITOR_FRAMES.opened, cursor: value.cursor } : null;
309
- }
310
- case VISITOR_FRAMES.changes: {
311
- const changes = hasOnly(value, ["type", "changes", "cursor"]) ? readVisitorChanges(value.changes) : null;
312
- return changes === null ? null : { type: VISITOR_FRAMES.changes, changes, cursor: value.cursor };
313
- }
314
- case VISITOR_FRAMES.resync: {
315
- return hasOnly(value, ["type", "reason", "cursor"]) && isResyncReason(value.reason) ? { type: VISITOR_FRAMES.resync, reason: value.reason, cursor: value.cursor } : null;
316
- }
317
- default: {
318
- return null;
319
- }
320
- }
321
- }
322
- chunkMWMSFIWN_cjs.__name(parseVisitorFrame, "parseVisitorFrame");
323
- function readVisitorPollAnswer(value) {
324
- if (!isRecord2(value) || !isCursor(value.cursor)) return null;
325
- if (value.kind === "resync") {
326
- return hasOnly(value, ["kind", "reason", "cursor"]) && isResyncReason(value.reason) ? { kind: "resync", reason: value.reason, cursor: value.cursor } : null;
327
- }
328
- if (value.kind !== "changes" || !hasOnly(value, ["kind", "changes", "cursor"])) return null;
329
- const changes = readVisitorChanges(value.changes);
330
- return changes === null ? null : { kind: "changes", changes, cursor: value.cursor };
331
- }
332
- chunkMWMSFIWN_cjs.__name(readVisitorPollAnswer, "readVisitorPollAnswer");
333
- var CHANGE_KINDS = /* @__PURE__ */ new Set([
334
- "published",
335
- "updated",
336
- "unpublished",
337
- "deleted"
338
- ]);
339
- var RESYNC_REASONS = /* @__PURE__ */ new Set([
340
- "retention",
341
- "dataset-replaced",
342
- "ahead-of-head",
343
- "foreign-cursor",
344
- "too-far-behind"
345
- ]);
346
- function isResyncReason(value) {
347
- return typeof value === "string" && RESYNC_REASONS.has(value);
348
- }
349
- chunkMWMSFIWN_cjs.__name(isResyncReason, "isResyncReason");
350
- function readVisitorChanges(value) {
351
- if (!Array.isArray(value)) return null;
352
- const changes = [];
353
- for (const item of value) {
354
- if (!isRecord2(item) || !hasOnly(item, ["entryId", "contentType", "locale", "kind"])) return null;
355
- const { entryId, contentType, locale, kind } = item;
356
- if (!isNonEmptyString2(entryId) || !isNonEmptyString2(contentType)) return null;
357
- if (locale !== null && typeof locale !== "string") return null;
358
- if (typeof kind !== "string" || !CHANGE_KINDS.has(kind)) return null;
359
- changes.push({ entryId, contentType, locale, kind });
360
- }
361
- return changes;
362
- }
363
- chunkMWMSFIWN_cjs.__name(readVisitorChanges, "readVisitorChanges");
364
- function isCursor(value) {
365
- return typeof value === "string" && VISITOR_CURSOR.test(value);
366
- }
367
- chunkMWMSFIWN_cjs.__name(isCursor, "isCursor");
368
- function isRecord2(value) {
369
- return typeof value === "object" && value !== null && !Array.isArray(value);
370
- }
371
- chunkMWMSFIWN_cjs.__name(isRecord2, "isRecord2");
372
- function isNonEmptyString2(value) {
373
- return typeof value === "string" && value.length > 0;
374
- }
375
- chunkMWMSFIWN_cjs.__name(isNonEmptyString2, "isNonEmptyString2");
376
- function hasOnly(value, keys) {
377
- const present = Object.keys(value);
378
- return present.length === keys.length && present.every((key) => keys.includes(key));
379
- }
380
- chunkMWMSFIWN_cjs.__name(hasOnly, "hasOnly");
381
-
382
- // src/preview/index.ts
383
- var UNKNOWN_PREVIEW_RECHECK_MS = 6e4;
384
- var NOT_PREVIEW = Object.freeze({ state: "not-preview" });
385
- function previewAtRequest(env) {
386
- return vercel(env) ?? NOT_PREVIEW;
387
- }
388
- chunkMWMSFIWN_cjs.__name(previewAtRequest, "previewAtRequest");
389
- function previewAtBuild(env) {
390
- const fromVercel = vercel(env);
391
- if (fromVercel !== void 0) return fromVercel;
392
- if (env.CONTEXT !== void 0) {
393
- if (env.CONTEXT !== "deploy-preview") return NOT_PREVIEW;
394
- return hasValue(env.HEAD) ? { state: "preview", host: "netlify", branch: env.HEAD } : { state: "no-branch", host: "netlify" };
395
- }
396
- if (env.CF_PAGES !== void 0) return { state: "undecidable", host: "cloudflare-pages" };
397
- return NOT_PREVIEW;
398
- }
399
- chunkMWMSFIWN_cjs.__name(previewAtBuild, "previewAtBuild");
400
- function vercel(env) {
401
- if (env.VERCEL_ENV === void 0) return void 0;
402
- if (env.VERCEL_ENV !== "preview") return NOT_PREVIEW;
403
- return hasValue(env.VERCEL_GIT_COMMIT_REF) ? { state: "preview", host: "vercel", branch: env.VERCEL_GIT_COMMIT_REF } : { state: "no-branch", host: "vercel" };
404
- }
405
- chunkMWMSFIWN_cjs.__name(vercel, "vercel");
406
- function hasValue(value) {
407
- return value !== void 0 && value !== "";
408
- }
409
- chunkMWMSFIWN_cjs.__name(hasValue, "hasValue");
410
-
411
- exports.FRESH_PARAMETER = FRESH_PARAMETER;
412
- exports.HEADER_IDEMPOTENCY_KEY = HEADER_IDEMPOTENCY_KEY;
413
- exports.HEADER_IF_MATCH = HEADER_IF_MATCH;
414
- exports.HEADER_RETRY_AFTER = HEADER_RETRY_AFTER;
415
- exports.PREVIEW_DATASET_PREFIX = PREVIEW_DATASET_PREFIX;
416
- exports.UNKNOWN_PREVIEW_RECHECK_MS = UNKNOWN_PREVIEW_RECHECK_MS;
417
- exports.VISITOR_ADMISSION_RETRY_AFTER_SECONDS = VISITOR_ADMISSION_RETRY_AFTER_SECONDS;
418
- exports.VISITOR_CLOSE_CODES = VISITOR_CLOSE_CODES;
419
- exports.VISITOR_CLOSE_RETRY = VISITOR_CLOSE_RETRY;
420
- exports.VISITOR_FRAMES = VISITOR_FRAMES;
421
- exports.VISITOR_KEEPALIVE = VISITOR_KEEPALIVE;
422
- exports.VISITOR_LIVE_PATH = VISITOR_LIVE_PATH;
423
- exports.VISITOR_POLL_INTERVAL_MS = VISITOR_POLL_INTERVAL_MS;
424
- exports.VISITOR_POLL_RETRY = VISITOR_POLL_RETRY;
425
- exports.VISITOR_QUERY = VISITOR_QUERY;
426
- exports.entityTag = entityTag;
427
- exports.parseVisitorFrame = parseVisitorFrame;
428
- exports.previewAtBuild = previewAtBuild;
429
- exports.previewAtRequest = previewAtRequest;
430
- exports.previewDatasetSlug = previewDatasetSlug;
431
- exports.readVisitorPollAnswer = readVisitorPollAnswer;
432
- //# sourceMappingURL=chunk-6PTRZP5U.cjs.map
433
- //# sourceMappingURL=chunk-6PTRZP5U.cjs.map