@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
@@ -1,30 +1,31 @@
1
1
  'use strict';
2
2
 
3
- var chunkLSRPMNPT_cjs = require('./chunk-LSRPMNPT.cjs');
4
- var chunk7BZW6XYJ_cjs = require('./chunk-7BZW6XYJ.cjs');
5
- var chunkTZL374LS_cjs = require('./chunk-TZL374LS.cjs');
6
- var chunkMWMSFIWN_cjs = require('./chunk-MWMSFIWN.cjs');
3
+ var chunkM7MWNV3Q_cjs = require('./chunk-M7MWNV3Q.cjs');
4
+ var chunkZO6QDYJG_cjs = require('./chunk-ZO6QDYJG.cjs');
5
+ var chunk7I3SC7SV_cjs = require('./chunk-7I3SC7SV.cjs');
6
+ var chunkSHSK7UUY_cjs = require('./chunk-SHSK7UUY.cjs');
7
+ var chunkL6DXCKVQ_cjs = require('./chunk-L6DXCKVQ.cjs');
7
8
 
8
9
  /* RelyIO SDK - Built with ❤️ by the RelyIO Team */
9
10
 
10
11
  // src/config/key-kind.ts
11
12
  var PUBLISHABLE_KEY_PREFIX = "rly_pub_";
12
- var isPublishableKey = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((apiKey) => apiKey?.startsWith(PUBLISHABLE_KEY_PREFIX) === true, "isPublishableKey");
13
+ var isPublishableKey = /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name((apiKey) => apiKey?.startsWith(PUBLISHABLE_KEY_PREFIX) === true, "isPublishableKey");
13
14
  var PREVIEW_KEY_PREFIX = "rly_prev_";
14
- var isPreviewKey = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((apiKey) => apiKey?.startsWith(PREVIEW_KEY_PREFIX) === true, "isPreviewKey");
15
+ var isPreviewKey = /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name((apiKey) => apiKey?.startsWith(PREVIEW_KEY_PREFIX) === true, "isPreviewKey");
15
16
 
16
17
  // src/errors/sdk-error.ts
17
18
  var _SDKError = class _SDKError extends Error {
18
19
  constructor(message, statusCode, cause, context) {
19
20
  super(message);
20
21
  /** HTTP status code if applicable */
21
- chunkMWMSFIWN_cjs.__publicField(this, "statusCode");
22
+ chunkL6DXCKVQ_cjs.__publicField(this, "statusCode");
22
23
  /** Original error that caused this error */
23
- chunkMWMSFIWN_cjs.__publicField(this, "cause");
24
+ chunkL6DXCKVQ_cjs.__publicField(this, "cause");
24
25
  /** Additional context about the error */
25
- chunkMWMSFIWN_cjs.__publicField(this, "context");
26
+ chunkL6DXCKVQ_cjs.__publicField(this, "context");
26
27
  /** Timestamp when the error occurred */
27
- chunkMWMSFIWN_cjs.__publicField(this, "timestamp");
28
+ chunkL6DXCKVQ_cjs.__publicField(this, "timestamp");
28
29
  this.name = this.constructor.name;
29
30
  this.statusCode = statusCode;
30
31
  this.cause = cause;
@@ -90,15 +91,15 @@ var _SDKError = class _SDKError extends Error {
90
91
  });
91
92
  }
92
93
  };
93
- chunkMWMSFIWN_cjs.__name(_SDKError, "SDKError");
94
+ chunkL6DXCKVQ_cjs.__name(_SDKError, "SDKError");
94
95
  var SDKError = _SDKError;
95
96
 
96
97
  // src/errors/content-errors.ts
97
98
  var _ResourceNotFoundError = class _ResourceNotFoundError extends SDKError {
98
99
  constructor(message = "Resource not found", statusCode = 404, cause, context) {
99
100
  super(message, statusCode, cause, context);
100
- chunkMWMSFIWN_cjs.__publicField(this, "code", "RESOURCE_NOT_FOUND");
101
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
101
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "RESOURCE_NOT_FOUND");
102
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
102
103
  }
103
104
  getUserMessage() {
104
105
  const resourceType = this.context?.resourceType;
@@ -109,90 +110,154 @@ var _ResourceNotFoundError = class _ResourceNotFoundError extends SDKError {
109
110
  return "The requested resource was not found.";
110
111
  }
111
112
  };
112
- chunkMWMSFIWN_cjs.__name(_ResourceNotFoundError, "ResourceNotFoundError");
113
+ chunkL6DXCKVQ_cjs.__name(_ResourceNotFoundError, "ResourceNotFoundError");
113
114
  var ResourceNotFoundError = _ResourceNotFoundError;
114
115
  var _ResourceConflictError = class _ResourceConflictError extends SDKError {
115
116
  constructor(message = "Resource conflict", statusCode = 409, cause, context) {
116
117
  super(message, statusCode, cause, context);
117
- chunkMWMSFIWN_cjs.__publicField(this, "code", "RESOURCE_CONFLICT");
118
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
118
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "RESOURCE_CONFLICT");
119
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
119
120
  }
120
121
  getUserMessage() {
121
122
  return "The resource could not be created or updated due to a conflict.";
122
123
  }
123
124
  };
124
- chunkMWMSFIWN_cjs.__name(_ResourceConflictError, "ResourceConflictError");
125
+ chunkL6DXCKVQ_cjs.__name(_ResourceConflictError, "ResourceConflictError");
125
126
  var ResourceConflictError = _ResourceConflictError;
126
127
  var _ResourceExpiredError = class _ResourceExpiredError extends SDKError {
127
128
  constructor(message = "Resource has expired", statusCode = 410, cause, context) {
128
129
  super(message, statusCode, cause, context);
129
- chunkMWMSFIWN_cjs.__publicField(this, "code", "RESOURCE_EXPIRED");
130
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
130
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "RESOURCE_EXPIRED");
131
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
131
132
  }
132
133
  getUserMessage() {
133
134
  return "The resource is no longer available.";
134
135
  }
135
136
  };
136
- chunkMWMSFIWN_cjs.__name(_ResourceExpiredError, "ResourceExpiredError");
137
+ chunkL6DXCKVQ_cjs.__name(_ResourceExpiredError, "ResourceExpiredError");
137
138
  var ResourceExpiredError = _ResourceExpiredError;
138
139
  function isResourceNotFound(error) {
139
140
  return error instanceof ResourceNotFoundError;
140
141
  }
141
- chunkMWMSFIWN_cjs.__name(isResourceNotFound, "isResourceNotFound");
142
+ chunkL6DXCKVQ_cjs.__name(isResourceNotFound, "isResourceNotFound");
142
143
  function isMissingEntry(error) {
143
144
  return error instanceof ResourceNotFoundError && error.context?.resourceType === "entry";
144
145
  }
145
- chunkMWMSFIWN_cjs.__name(isMissingEntry, "isMissingEntry");
146
+ chunkL6DXCKVQ_cjs.__name(isMissingEntry, "isMissingEntry");
146
147
 
147
148
  // src/errors/contract-errors.ts
148
149
  var _MissingApiKeyError = class _MissingApiKeyError extends SDKError {
149
150
  constructor(message = "No API key was sent", context) {
150
151
  super(message, 401, void 0, context);
151
- chunkMWMSFIWN_cjs.__publicField(this, "code", "MISSING_API_KEY");
152
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
152
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "MISSING_API_KEY");
153
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
153
154
  }
154
155
  getUserMessage() {
155
156
  return "No API key was sent. Set `apiKey` when creating the client.";
156
157
  }
157
158
  };
158
- chunkMWMSFIWN_cjs.__name(_MissingApiKeyError, "MissingApiKeyError");
159
+ chunkL6DXCKVQ_cjs.__name(_MissingApiKeyError, "MissingApiKeyError");
159
160
  var MissingApiKeyError = _MissingApiKeyError;
160
161
  var _ReadOnlyKeyError = class _ReadOnlyKeyError extends SDKError {
161
162
  constructor(message = "This API key is read-only", context) {
162
163
  super(message, 403, void 0, context);
163
- chunkMWMSFIWN_cjs.__publicField(this, "code", "READ_ONLY_KEY");
164
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
164
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "READ_ONLY_KEY");
165
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
165
166
  }
166
167
  getUserMessage() {
167
168
  return "This API key is read-only. Use a key with write access for this operation.";
168
169
  }
169
170
  };
170
- chunkMWMSFIWN_cjs.__name(_ReadOnlyKeyError, "ReadOnlyKeyError");
171
+ chunkL6DXCKVQ_cjs.__name(_ReadOnlyKeyError, "ReadOnlyKeyError");
171
172
  var ReadOnlyKeyError = _ReadOnlyKeyError;
173
+ var _PublishableKeyRefusedError = class _PublishableKeyRefusedError extends SDKError {
174
+ constructor(message = "A publishable key cannot read or write Records or run Functions", context) {
175
+ super(message, 403, void 0, context);
176
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "PUBLISHABLE_KEY_REFUSED");
177
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
178
+ }
179
+ getUserMessage() {
180
+ return "A publishable key cannot reach Records or Functions. Call them from your server with a secret key.";
181
+ }
182
+ };
183
+ chunkL6DXCKVQ_cjs.__name(_PublishableKeyRefusedError, "PublishableKeyRefusedError");
184
+ var PublishableKeyRefusedError = _PublishableKeyRefusedError;
185
+ var _FunctionRunFailedError = class _FunctionRunFailedError extends SDKError {
186
+ constructor(message = "The Function ended without an answer", run = {}, context) {
187
+ super(message, 500, void 0, context);
188
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "FUNCTION_RUN_FAILED");
189
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
190
+ chunkL6DXCKVQ_cjs.__publicField(this, "runId");
191
+ chunkL6DXCKVQ_cjs.__publicField(this, "failure");
192
+ chunkL6DXCKVQ_cjs.__publicField(this, "runError");
193
+ this.runId = run.runId;
194
+ this.failure = run.failure;
195
+ this.runError = run.runError;
196
+ }
197
+ getUserMessage() {
198
+ return this.runId === void 0 ? "The Function ended without an answer." : `The Function ended without an answer; its run is ${this.runId}.`;
199
+ }
200
+ };
201
+ chunkL6DXCKVQ_cjs.__name(_FunctionRunFailedError, "FunctionRunFailedError");
202
+ var FunctionRunFailedError = _FunctionRunFailedError;
203
+ var _FunctionContainersBusyError = class _FunctionContainersBusyError extends SDKError {
204
+ constructor(message = "The project is running as many Containers as its plan includes", name, context, retryAfterMs) {
205
+ super(message, 429, void 0, context);
206
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "FUNCTION_CONTAINERS_BUSY");
207
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
208
+ /** The Function that was not started. */
209
+ chunkL6DXCKVQ_cjs.__publicField(this, "function");
210
+ /** `Retry-After`, in milliseconds, where the response carried a readable one. */
211
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryAfterMs");
212
+ this.function = name;
213
+ this.retryAfterMs = retryAfterMs;
214
+ }
215
+ getUserMessage() {
216
+ return "Every Container this project may run at once is busy. Call again shortly.";
217
+ }
218
+ };
219
+ chunkL6DXCKVQ_cjs.__name(_FunctionContainersBusyError, "FunctionContainersBusyError");
220
+ var FunctionContainersBusyError = _FunctionContainersBusyError;
221
+ var _FunctionRunTimedOutError = class _FunctionRunTimedOutError extends SDKError {
222
+ constructor(message = "The Function had not answered within the wait", run = {}, context) {
223
+ super(message, 504, void 0, context);
224
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "FUNCTION_RUN_TIMED_OUT");
225
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
226
+ chunkL6DXCKVQ_cjs.__publicField(this, "runId");
227
+ chunkL6DXCKVQ_cjs.__publicField(this, "waitedMs");
228
+ this.runId = run.runId;
229
+ this.waitedMs = run.waitedMs;
230
+ }
231
+ getUserMessage() {
232
+ return this.runId === void 0 ? "The Function had not answered within the wait; it runs on." : `The Function had not answered within the wait; run ${this.runId} runs on.`;
233
+ }
234
+ };
235
+ chunkL6DXCKVQ_cjs.__name(_FunctionRunTimedOutError, "FunctionRunTimedOutError");
236
+ var FunctionRunTimedOutError = _FunctionRunTimedOutError;
172
237
  var _PlanFeatureUnavailableError = class _PlanFeatureUnavailableError extends SDKError {
173
238
  constructor(message = "This feature is not available on the current plan", feature, context) {
174
239
  super(message, 403, void 0, context);
175
- chunkMWMSFIWN_cjs.__publicField(this, "code", "PLAN_FEATURE_UNAVAILABLE");
176
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
240
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "PLAN_FEATURE_UNAVAILABLE");
241
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
177
242
  /** The entitlement key the service named, when it named one. */
178
- chunkMWMSFIWN_cjs.__publicField(this, "feature");
243
+ chunkL6DXCKVQ_cjs.__publicField(this, "feature");
179
244
  this.feature = feature;
180
245
  }
181
246
  getUserMessage() {
182
247
  return this.feature === void 0 ? "This feature is not available on the current plan." : `The current plan does not include "${this.feature}".`;
183
248
  }
184
249
  };
185
- chunkMWMSFIWN_cjs.__name(_PlanFeatureUnavailableError, "PlanFeatureUnavailableError");
250
+ chunkL6DXCKVQ_cjs.__name(_PlanFeatureUnavailableError, "PlanFeatureUnavailableError");
186
251
  var PlanFeatureUnavailableError = _PlanFeatureUnavailableError;
187
252
  var _UsageQuotaExceededError = class _UsageQuotaExceededError extends SDKError {
188
253
  constructor(message = "Usage quota exceeded", meter, limit, context) {
189
254
  super(message, 403, void 0, context);
190
- chunkMWMSFIWN_cjs.__publicField(this, "code", "USAGE_QUOTA_EXCEEDED");
191
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
255
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "USAGE_QUOTA_EXCEEDED");
256
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
192
257
  /** The meter the service named. Always present on a refusal from the contract. */
193
- chunkMWMSFIWN_cjs.__publicField(this, "meter");
258
+ chunkL6DXCKVQ_cjs.__publicField(this, "meter");
194
259
  /** The threshold, where the deciding seam carried one — often it does not. */
195
- chunkMWMSFIWN_cjs.__publicField(this, "limit");
260
+ chunkL6DXCKVQ_cjs.__publicField(this, "limit");
196
261
  this.meter = meter;
197
262
  this.limit = limit;
198
263
  }
@@ -200,17 +265,17 @@ var _UsageQuotaExceededError = class _UsageQuotaExceededError extends SDKError {
200
265
  return this.meter === void 0 ? "A usage quota for this account has been exceeded." : `The "${this.meter}" quota for this account has been exceeded.`;
201
266
  }
202
267
  };
203
- chunkMWMSFIWN_cjs.__name(_UsageQuotaExceededError, "UsageQuotaExceededError");
268
+ chunkL6DXCKVQ_cjs.__name(_UsageQuotaExceededError, "UsageQuotaExceededError");
204
269
  var UsageQuotaExceededError = _UsageQuotaExceededError;
205
270
  var _RateLimitError = class _RateLimitError extends SDKError {
206
271
  constructor(message = "Rate limit exceeded", limit, resetAt, context, retryAfterMs) {
207
272
  super(message, 429, void 0, context);
208
- chunkMWMSFIWN_cjs.__publicField(this, "code", "RATE_LIMIT_EXCEEDED");
209
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", true);
210
- chunkMWMSFIWN_cjs.__publicField(this, "limit");
211
- chunkMWMSFIWN_cjs.__publicField(this, "resetAt");
273
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "RATE_LIMIT_EXCEEDED");
274
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", true);
275
+ chunkL6DXCKVQ_cjs.__publicField(this, "limit");
276
+ chunkL6DXCKVQ_cjs.__publicField(this, "resetAt");
212
277
  /** `Retry-After`, in milliseconds, where the response carried a readable one. */
213
- chunkMWMSFIWN_cjs.__publicField(this, "retryAfterMs");
278
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryAfterMs");
214
279
  this.limit = limit;
215
280
  this.resetAt = resetAt;
216
281
  this.retryAfterMs = retryAfterMs;
@@ -219,56 +284,56 @@ var _RateLimitError = class _RateLimitError extends SDKError {
219
284
  return this.resetAt === void 0 ? "Too many requests. Please retry shortly." : `Too many requests. The window resets at ${this.resetAt}.`;
220
285
  }
221
286
  };
222
- chunkMWMSFIWN_cjs.__name(_RateLimitError, "RateLimitError");
287
+ chunkL6DXCKVQ_cjs.__name(_RateLimitError, "RateLimitError");
223
288
  var RateLimitError = _RateLimitError;
224
289
  var _MethodNotAllowedError = class _MethodNotAllowedError extends SDKError {
225
290
  constructor(message = "Method not allowed", context) {
226
291
  super(message, 405, void 0, context);
227
- chunkMWMSFIWN_cjs.__publicField(this, "code", "METHOD_NOT_ALLOWED");
228
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
292
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "METHOD_NOT_ALLOWED");
293
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
229
294
  }
230
295
  getUserMessage() {
231
296
  return "That operation is not available on this resource.";
232
297
  }
233
298
  };
234
- chunkMWMSFIWN_cjs.__name(_MethodNotAllowedError, "MethodNotAllowedError");
299
+ chunkL6DXCKVQ_cjs.__name(_MethodNotAllowedError, "MethodNotAllowedError");
235
300
  var MethodNotAllowedError = _MethodNotAllowedError;
236
301
  var _PayloadTooLargeError = class _PayloadTooLargeError extends SDKError {
237
302
  constructor(message = "Payload too large", limitBytes, context) {
238
303
  super(message, 413, void 0, context);
239
- chunkMWMSFIWN_cjs.__publicField(this, "code", "PAYLOAD_TOO_LARGE");
240
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
241
- chunkMWMSFIWN_cjs.__publicField(this, "limitBytes");
304
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "PAYLOAD_TOO_LARGE");
305
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
306
+ chunkL6DXCKVQ_cjs.__publicField(this, "limitBytes");
242
307
  this.limitBytes = limitBytes;
243
308
  }
244
309
  getUserMessage() {
245
310
  return this.limitBytes === void 0 ? "The request body is larger than this endpoint accepts." : `The request body is larger than the ${this.limitBytes}-byte limit.`;
246
311
  }
247
312
  };
248
- chunkMWMSFIWN_cjs.__name(_PayloadTooLargeError, "PayloadTooLargeError");
313
+ chunkL6DXCKVQ_cjs.__name(_PayloadTooLargeError, "PayloadTooLargeError");
249
314
  var PayloadTooLargeError = _PayloadTooLargeError;
250
315
  var _TransactionRolledBackError = class _TransactionRolledBackError extends SDKError {
251
316
  constructor(message = "Transaction rolled back", failedIndex, context) {
252
317
  super(message, 409, void 0, context);
253
- chunkMWMSFIWN_cjs.__publicField(this, "code", "TRANSACTION_ROLLED_BACK");
254
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
255
- chunkMWMSFIWN_cjs.__publicField(this, "failedIndex");
318
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "TRANSACTION_ROLLED_BACK");
319
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
320
+ chunkL6DXCKVQ_cjs.__publicField(this, "failedIndex");
256
321
  this.failedIndex = failedIndex;
257
322
  }
258
323
  getUserMessage() {
259
324
  return this.failedIndex === void 0 ? "The batch was rolled back; nothing was written." : `The batch was rolled back; nothing was written. This refusal is for operation ${this.failedIndex} of the batch, which is not necessarily the one that failed.`;
260
325
  }
261
326
  };
262
- chunkMWMSFIWN_cjs.__name(_TransactionRolledBackError, "TransactionRolledBackError");
327
+ chunkL6DXCKVQ_cjs.__name(_TransactionRolledBackError, "TransactionRolledBackError");
263
328
  var TransactionRolledBackError = _TransactionRolledBackError;
264
329
  var _ServiceIndeterminateError = class _ServiceIndeterminateError extends SDKError {
265
330
  constructor(message = "The service could not decide this request", missing, context, retryAfterMs) {
266
331
  super(message, 503, void 0, context);
267
- chunkMWMSFIWN_cjs.__publicField(this, "code", "SERVICE_INDETERMINATE");
268
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", true);
269
- chunkMWMSFIWN_cjs.__publicField(this, "missing");
332
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "SERVICE_INDETERMINATE");
333
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", true);
334
+ chunkL6DXCKVQ_cjs.__publicField(this, "missing");
270
335
  /** `Retry-After`, in milliseconds. The contract requires the header on this code. */
271
- chunkMWMSFIWN_cjs.__publicField(this, "retryAfterMs");
336
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryAfterMs");
272
337
  this.missing = missing;
273
338
  this.retryAfterMs = retryAfterMs;
274
339
  }
@@ -276,72 +341,72 @@ var _ServiceIndeterminateError = class _ServiceIndeterminateError extends SDKErr
276
341
  return "The service is temporarily unable to answer. Please retry.";
277
342
  }
278
343
  };
279
- chunkMWMSFIWN_cjs.__name(_ServiceIndeterminateError, "ServiceIndeterminateError");
344
+ chunkL6DXCKVQ_cjs.__name(_ServiceIndeterminateError, "ServiceIndeterminateError");
280
345
  var ServiceIndeterminateError = _ServiceIndeterminateError;
281
346
  var _ServerError = class _ServerError extends SDKError {
282
347
  constructor(message = "The service failed to handle the request", statusCode = 500, context) {
283
348
  super(message, statusCode, void 0, context);
284
- chunkMWMSFIWN_cjs.__publicField(this, "code", "INTERNAL_ERROR");
285
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", true);
349
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "INTERNAL_ERROR");
350
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", true);
286
351
  }
287
352
  getUserMessage() {
288
353
  return "Something went wrong on the RelyIO side. Please retry.";
289
354
  }
290
355
  };
291
- chunkMWMSFIWN_cjs.__name(_ServerError, "ServerError");
356
+ chunkL6DXCKVQ_cjs.__name(_ServerError, "ServerError");
292
357
  var ServerError = _ServerError;
293
358
  var _UnknownContractError = class _UnknownContractError extends SDKError {
294
359
  constructor(code, message, statusCode, context) {
295
360
  super(message, statusCode, void 0, context);
296
- chunkMWMSFIWN_cjs.__publicField(this, "code");
297
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
361
+ chunkL6DXCKVQ_cjs.__publicField(this, "code");
362
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
298
363
  this.code = code;
299
364
  }
300
365
  getUserMessage() {
301
366
  return `The service refused this request with "${this.code}".`;
302
367
  }
303
368
  };
304
- chunkMWMSFIWN_cjs.__name(_UnknownContractError, "UnknownContractError");
369
+ chunkL6DXCKVQ_cjs.__name(_UnknownContractError, "UnknownContractError");
305
370
  var UnknownContractError = _UnknownContractError;
306
371
 
307
372
  // src/errors/auth-errors.ts
308
373
  var _AuthorizationError = class _AuthorizationError extends SDKError {
309
374
  constructor(message = "Authorization failed", statusCode = 403, cause, context) {
310
375
  super(message, statusCode, cause, context);
311
- chunkMWMSFIWN_cjs.__publicField(this, "code", "AUTHORIZATION_ERROR");
312
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
376
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "AUTHORIZATION_ERROR");
377
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
313
378
  }
314
379
  getUserMessage() {
315
380
  return "You do not have permission to access this resource.";
316
381
  }
317
382
  };
318
- chunkMWMSFIWN_cjs.__name(_AuthorizationError, "AuthorizationError");
383
+ chunkL6DXCKVQ_cjs.__name(_AuthorizationError, "AuthorizationError");
319
384
  var AuthorizationError = _AuthorizationError;
320
385
  var _InvalidApiKeyError = class _InvalidApiKeyError extends SDKError {
321
386
  constructor(message = "Invalid API key", cause, context) {
322
387
  super(message, 401, cause, context);
323
- chunkMWMSFIWN_cjs.__publicField(this, "code", "INVALID_API_KEY");
324
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
388
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "INVALID_API_KEY");
389
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
325
390
  }
326
391
  getUserMessage() {
327
392
  return "Invalid API key. Please check your API key and try again.";
328
393
  }
329
394
  };
330
- chunkMWMSFIWN_cjs.__name(_InvalidApiKeyError, "InvalidApiKeyError");
395
+ chunkL6DXCKVQ_cjs.__name(_InvalidApiKeyError, "InvalidApiKeyError");
331
396
  var InvalidApiKeyError = _InvalidApiKeyError;
332
397
 
333
398
  // src/errors/network-errors.ts
334
399
  var _NetworkError = class _NetworkError extends SDKError {
335
400
  constructor(message = "Network request failed", statusCode, cause, context) {
336
401
  super(message, statusCode, cause, context);
337
- chunkMWMSFIWN_cjs.__publicField(this, "code", "NETWORK_ERROR");
338
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", true);
402
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "NETWORK_ERROR");
403
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", true);
339
404
  }
340
405
  getUserMessage() {
341
406
  return "Network connection failed. Please check your internet connection and try again.";
342
407
  }
343
408
  };
344
- chunkMWMSFIWN_cjs.__name(_NetworkError, "NetworkError");
409
+ chunkL6DXCKVQ_cjs.__name(_NetworkError, "NetworkError");
345
410
  var NetworkError = _NetworkError;
346
411
  var _TimeoutError = class _TimeoutError extends SDKError {
347
412
  /**
@@ -350,27 +415,27 @@ var _TimeoutError = class _TimeoutError extends SDKError {
350
415
  */
351
416
  constructor(message = "Request timed out", timeout, statusCode, cause, context) {
352
417
  super(message, statusCode, cause, { ...context, timeout });
353
- chunkMWMSFIWN_cjs.__publicField(this, "code", "TIMEOUT_ERROR");
354
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", true);
418
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "TIMEOUT_ERROR");
419
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", true);
355
420
  }
356
421
  getUserMessage() {
357
422
  const timeout = this.context?.timeout;
358
423
  return `Request timed out${timeout != null ? ` after ${timeout}ms` : ""}. Please try again.`;
359
424
  }
360
425
  };
361
- chunkMWMSFIWN_cjs.__name(_TimeoutError, "TimeoutError");
426
+ chunkL6DXCKVQ_cjs.__name(_TimeoutError, "TimeoutError");
362
427
  var TimeoutError = _TimeoutError;
363
428
  var _ConnectionError = class _ConnectionError extends SDKError {
364
429
  constructor(message = "Connection failed", statusCode, cause, context) {
365
430
  super(message, statusCode, cause, context);
366
- chunkMWMSFIWN_cjs.__publicField(this, "code", "CONNECTION_ERROR");
367
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", true);
431
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "CONNECTION_ERROR");
432
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", true);
368
433
  }
369
434
  getUserMessage() {
370
435
  return "Failed to connect to RelyIO servers. Please check your connection and try again.";
371
436
  }
372
437
  };
373
- chunkMWMSFIWN_cjs.__name(_ConnectionError, "ConnectionError");
438
+ chunkL6DXCKVQ_cjs.__name(_ConnectionError, "ConnectionError");
374
439
  var ConnectionError = _ConnectionError;
375
440
 
376
441
  // src/errors/validation-errors.ts
@@ -382,8 +447,8 @@ var _BaseValidationError = class _BaseValidationError extends SDKError {
382
447
  */
383
448
  constructor(message = "Validation failed", violations = [], statusCode = 400, cause, context) {
384
449
  super(message, statusCode, cause, { ...context, violations });
385
- chunkMWMSFIWN_cjs.__publicField(this, "retryable", false);
386
- chunkMWMSFIWN_cjs.__publicField(this, "violations");
450
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable", false);
451
+ chunkL6DXCKVQ_cjs.__publicField(this, "violations");
387
452
  this.violations = violations;
388
453
  }
389
454
  getUserMessage() {
@@ -415,26 +480,26 @@ var _BaseValidationError = class _BaseValidationError extends SDKError {
415
480
  return this.violations.map((v) => `${v.field}: ${v.message}`).join("\n");
416
481
  }
417
482
  };
418
- chunkMWMSFIWN_cjs.__name(_BaseValidationError, "BaseValidationError");
483
+ chunkL6DXCKVQ_cjs.__name(_BaseValidationError, "BaseValidationError");
419
484
  var BaseValidationError = _BaseValidationError;
420
485
  var _ValidationError = class _ValidationError extends BaseValidationError {
421
486
  constructor() {
422
487
  super(...arguments);
423
- chunkMWMSFIWN_cjs.__publicField(this, "code", "VALIDATION_ERROR");
488
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "VALIDATION_ERROR");
424
489
  }
425
490
  };
426
- chunkMWMSFIWN_cjs.__name(_ValidationError, "ValidationError");
491
+ chunkL6DXCKVQ_cjs.__name(_ValidationError, "ValidationError");
427
492
  var ValidationError = _ValidationError;
428
493
  var _InvalidPayloadError = class _InvalidPayloadError extends BaseValidationError {
429
494
  constructor(message = "Invalid payload", violations = [], cause, context) {
430
495
  super(message, violations, 400, cause, context);
431
- chunkMWMSFIWN_cjs.__publicField(this, "code", "INVALID_PAYLOAD");
496
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "INVALID_PAYLOAD");
432
497
  }
433
498
  getUserMessage() {
434
499
  return "The request payload is invalid. Please check your data and try again.";
435
500
  }
436
501
  };
437
- chunkMWMSFIWN_cjs.__name(_InvalidPayloadError, "InvalidPayloadError");
502
+ chunkL6DXCKVQ_cjs.__name(_InvalidPayloadError, "InvalidPayloadError");
438
503
  var InvalidPayloadError = _InvalidPayloadError;
439
504
 
440
505
  // ../../platform/api-contract/dist/client/index.js
@@ -442,11 +507,11 @@ var _a;
442
507
  var ContractBodyError = (_a = class extends Error {
443
508
  constructor(message, body) {
444
509
  super(message);
445
- chunkMWMSFIWN_cjs.__publicField(this, "body");
510
+ chunkL6DXCKVQ_cjs.__publicField(this, "body");
446
511
  this.name = "ContractBodyError";
447
512
  this.body = body;
448
513
  }
449
- }, chunkMWMSFIWN_cjs.__name(_a, "ContractBodyError"), _a);
514
+ }, chunkL6DXCKVQ_cjs.__name(_a, "ContractBodyError"), _a);
450
515
  function describe(body) {
451
516
  try {
452
517
  return JSON.stringify(body)?.slice(0, 200) ?? String(body);
@@ -454,7 +519,7 @@ function describe(body) {
454
519
  return String(body);
455
520
  }
456
521
  }
457
- chunkMWMSFIWN_cjs.__name(describe, "describe");
522
+ chunkL6DXCKVQ_cjs.__name(describe, "describe");
458
523
  function readPayload(body) {
459
524
  if (typeof body !== "object" || body === null || !("data" in body)) {
460
525
  throw new ContractBodyError(
@@ -464,7 +529,7 @@ function readPayload(body) {
464
529
  }
465
530
  return body.data;
466
531
  }
467
- chunkMWMSFIWN_cjs.__name(readPayload, "readPayload");
532
+ chunkL6DXCKVQ_cjs.__name(readPayload, "readPayload");
468
533
  function readError(body) {
469
534
  if (typeof body !== "object" || body === null || !("error" in body)) return void 0;
470
535
  const error = body.error;
@@ -478,7 +543,7 @@ function readError(body) {
478
543
  ..."details" in error ? { details: error.details } : {}
479
544
  };
480
545
  }
481
- chunkMWMSFIWN_cjs.__name(readError, "readError");
546
+ chunkL6DXCKVQ_cjs.__name(readError, "readError");
482
547
 
483
548
  // src/http/retry-after.ts
484
549
  function headerValue(headers, name) {
@@ -489,7 +554,7 @@ function headerValue(headers, name) {
489
554
  }
490
555
  return void 0;
491
556
  }
492
- chunkMWMSFIWN_cjs.__name(headerValue, "headerValue");
557
+ chunkL6DXCKVQ_cjs.__name(headerValue, "headerValue");
493
558
  function parseRetryAfterMs(value, nowMs) {
494
559
  if (value === void 0) return void 0;
495
560
  const trimmed = value.trim();
@@ -502,7 +567,7 @@ function parseRetryAfterMs(value, nowMs) {
502
567
  if (Number.isNaN(at)) return void 0;
503
568
  return Math.max(0, at - nowMs);
504
569
  }
505
- chunkMWMSFIWN_cjs.__name(parseRetryAfterMs, "parseRetryAfterMs");
570
+ chunkL6DXCKVQ_cjs.__name(parseRetryAfterMs, "parseRetryAfterMs");
506
571
 
507
572
  // src/errors/error-mapper.ts
508
573
  var STALE_VERSION_GUIDANCE = "The entry changed since it was read: re-read it with `fresh: true` and retry the write with what that read returns.";
@@ -516,7 +581,7 @@ var _ErrorMapper = class _ErrorMapper {
516
581
  return new NetworkError(`HTTP ${status}: ${statusText}`.trim(), status, void 0, context);
517
582
  }
518
583
  const retryAfterMs = parseRetryAfterMs(
519
- headerValue(headers, chunk7BZW6XYJ_cjs.HEADER_RETRY_AFTER.name),
584
+ headerValue(headers, chunkSHSK7UUY_cjs.HEADER_RETRY_AFTER.name),
520
585
  Date.now()
521
586
  );
522
587
  return this.fromContractCode(refusal, status, context, retryAfterMs);
@@ -536,6 +601,9 @@ var _ErrorMapper = class _ErrorMapper {
536
601
  case "READ_ONLY_KEY": {
537
602
  return new ReadOnlyKeyError(message, context);
538
603
  }
604
+ case "PUBLISHABLE_KEY_REFUSED": {
605
+ return new PublishableKeyRefusedError(message, context);
606
+ }
539
607
  case "PLAN_FEATURE_UNAVAILABLE": {
540
608
  return new PlanFeatureUnavailableError(message, detailString(refusal, "feature"), context);
541
609
  }
@@ -579,7 +647,8 @@ var _ErrorMapper = class _ErrorMapper {
579
647
  return new ResourceConflictError(guidance, 409, void 0, {
580
648
  ...context,
581
649
  // What stands in the way, as a declared kind a program switches on: `draft-exists`,
582
- // `release-locked` or `slug-taken` from the Content API (REL-2446).
650
+ // `release-locked`, `slug-taken` or `value-taken` from the Content API (REL-2446,
651
+ // REL-3767).
583
652
  blockage,
584
653
  expectedVersion,
585
654
  actualVersion: detailNumber(refusal, "actualVersion"),
@@ -616,6 +685,32 @@ var _ErrorMapper = class _ErrorMapper {
616
685
  retryAfterMs
617
686
  );
618
687
  }
688
+ case "FUNCTION_RUN_FAILED": {
689
+ return new FunctionRunFailedError(
690
+ message,
691
+ {
692
+ runId: detailString(refusal, "runId"),
693
+ failure: detailString(refusal, "failure"),
694
+ runError: runErrorOf(refusal)
695
+ },
696
+ context
697
+ );
698
+ }
699
+ case "FUNCTION_RUN_TIMED_OUT": {
700
+ return new FunctionRunTimedOutError(
701
+ message,
702
+ { runId: detailString(refusal, "runId"), waitedMs: detailNumber(refusal, "waitedMs") },
703
+ context
704
+ );
705
+ }
706
+ case "FUNCTION_CONTAINERS_BUSY": {
707
+ return new FunctionContainersBusyError(
708
+ message,
709
+ detailString(refusal, "function"),
710
+ context,
711
+ retryAfterMs
712
+ );
713
+ }
619
714
  case "INTERNAL_ERROR": {
620
715
  return new ServerError(message, status, context);
621
716
  }
@@ -657,29 +752,36 @@ var _ErrorMapper = class _ErrorMapper {
657
752
  return error.name === "TypeError" && error.message.includes("fetch") || error.message.includes("timeout") || error.message.includes("Network Error") || error.message.includes("ECONNREFUSED");
658
753
  }
659
754
  };
660
- chunkMWMSFIWN_cjs.__name(_ErrorMapper, "ErrorMapper");
755
+ chunkL6DXCKVQ_cjs.__name(_ErrorMapper, "ErrorMapper");
661
756
  var ErrorMapper = _ErrorMapper;
662
757
  function knownCode(refusal) {
663
758
  return typeof refusal.code === "string" ? refusal.code : void 0;
664
759
  }
665
- chunkMWMSFIWN_cjs.__name(knownCode, "knownCode");
760
+ chunkL6DXCKVQ_cjs.__name(knownCode, "knownCode");
666
761
  function detailBag(refusal) {
667
762
  if (knownCode(refusal) === void 0) return void 0;
668
763
  const details = refusal.details;
669
764
  if (typeof details !== "object" || details === null) return void 0;
670
765
  return details;
671
766
  }
672
- chunkMWMSFIWN_cjs.__name(detailBag, "detailBag");
767
+ chunkL6DXCKVQ_cjs.__name(detailBag, "detailBag");
673
768
  function detailString(refusal, key) {
674
769
  const value = detailBag(refusal)?.[key];
675
770
  return typeof value === "string" ? value : void 0;
676
771
  }
677
- chunkMWMSFIWN_cjs.__name(detailString, "detailString");
772
+ chunkL6DXCKVQ_cjs.__name(detailString, "detailString");
678
773
  function detailNumber(refusal, key) {
679
774
  const value = detailBag(refusal)?.[key];
680
775
  return typeof value === "number" ? value : void 0;
681
776
  }
682
- chunkMWMSFIWN_cjs.__name(detailNumber, "detailNumber");
777
+ chunkL6DXCKVQ_cjs.__name(detailNumber, "detailNumber");
778
+ function runErrorOf(refusal) {
779
+ const error = detailBag(refusal)?.error;
780
+ if (typeof error !== "object" || error === null) return void 0;
781
+ const { name, message } = error;
782
+ return typeof name === "string" && typeof message === "string" ? { name, message } : void 0;
783
+ }
784
+ chunkL6DXCKVQ_cjs.__name(runErrorOf, "runErrorOf");
683
785
  function blockageOf(refusal) {
684
786
  const blockage = detailBag(refusal)?.blockage;
685
787
  if (typeof blockage !== "object" || blockage === null) return void 0;
@@ -688,7 +790,7 @@ function blockageOf(refusal) {
688
790
  const named = typeof facts === "object" && facts !== null && !Array.isArray(facts) ? facts : {};
689
791
  return { kind, facts: named };
690
792
  }
691
- chunkMWMSFIWN_cjs.__name(blockageOf, "blockageOf");
793
+ chunkL6DXCKVQ_cjs.__name(blockageOf, "blockageOf");
692
794
  function violationsOf(refusal) {
693
795
  const issues = detailBag(refusal)?.issues;
694
796
  if (!Array.isArray(issues)) return [];
@@ -699,7 +801,7 @@ function violationsOf(refusal) {
699
801
  path: issue.path === "" ? void 0 : issue.path.split(".")
700
802
  }));
701
803
  }
702
- chunkMWMSFIWN_cjs.__name(violationsOf, "violationsOf");
804
+ chunkL6DXCKVQ_cjs.__name(violationsOf, "violationsOf");
703
805
 
704
806
  // src/http/api-routes.ts
705
807
  function fillPath(template, params) {
@@ -721,12 +823,23 @@ function fillPath(template, params) {
721
823
  }
722
824
  return filled;
723
825
  }
724
- chunkMWMSFIWN_cjs.__name(fillPath, "fillPath");
826
+ chunkL6DXCKVQ_cjs.__name(fillPath, "fillPath");
725
827
  var DECLARED_PATHS = {
726
828
  "/health": true,
727
829
  "/health/cache": true,
728
830
  "/health/live": true,
729
831
  "/health/ready": true,
832
+ "/internal/functions/runs/{runId}/actions": true,
833
+ "/internal/functions/runs/{runId}/bundle": true,
834
+ "/internal/functions/runs/{runId}/content": true,
835
+ "/internal/functions/runs/{runId}/outcome": true,
836
+ "/internal/functions/runs/{runId}/recorded": true,
837
+ "/internal/functions/runs/{runId}/records/batch": true,
838
+ "/internal/functions/runs/{runId}/records/file": true,
839
+ "/internal/functions/runs/{runId}/records/read": true,
840
+ "/internal/functions/tasks/{taskId}/run": true,
841
+ "/internal/functions/test-runs/{projectId}/{name}": true,
842
+ "/internal/functions/tool-calls/{projectId}/{name}": true,
730
843
  "/internal/live/visitor-feed/{projectId}/{datasetId}/changes": true,
731
844
  "/internal/live/visitor-key": true,
732
845
  "/internal/media/claim": true,
@@ -763,6 +876,11 @@ var DECLARED_PATHS = {
763
876
  "/v1/project": true,
764
877
  "/v1/queries/{name}": true,
765
878
  "/v1/query": true,
879
+ "/v1/functions/{name}": true,
880
+ "/v1/records/batch": true,
881
+ "/v1/records/{recordType}": true,
882
+ "/v1/records/{recordType}/files": true,
883
+ "/v1/records/{recordType}/{uid}": true,
766
884
  "/v1/search": true,
767
885
  "/v1/search/autocomplete": true,
768
886
  "/v1/search/similar": true,
@@ -784,7 +902,7 @@ function compile(path) {
784
902
  });
785
903
  return { path, segments };
786
904
  }
787
- chunkMWMSFIWN_cjs.__name(compile, "compile");
905
+ chunkL6DXCKVQ_cjs.__name(compile, "compile");
788
906
  function byRouterPrecedence(a, b) {
789
907
  const shared = Math.min(a.segments.length, b.segments.length);
790
908
  for (let index = 0; index < shared; index += 1) {
@@ -794,7 +912,7 @@ function byRouterPrecedence(a, b) {
794
912
  }
795
913
  return 0;
796
914
  }
797
- chunkMWMSFIWN_cjs.__name(byRouterPrecedence, "byRouterPrecedence");
915
+ chunkL6DXCKVQ_cjs.__name(byRouterPrecedence, "byRouterPrecedence");
798
916
  var COMPILED_ROUTES = Object.keys(DECLARED_PATHS).map(compile).sort(byRouterPrecedence);
799
917
  function matchRoute(url, options = {}) {
800
918
  const parsed = new URL(url, "http://relative.invalid");
@@ -822,7 +940,7 @@ function matchRoute(url, options = {}) {
822
940
  }
823
941
  return null;
824
942
  }
825
- chunkMWMSFIWN_cjs.__name(matchRoute, "matchRoute");
943
+ chunkL6DXCKVQ_cjs.__name(matchRoute, "matchRoute");
826
944
  function readQuery(searchParams) {
827
945
  const query = {};
828
946
  for (const key of new Set(searchParams.keys())) {
@@ -831,7 +949,7 @@ function readQuery(searchParams) {
831
949
  }
832
950
  return query;
833
951
  }
834
- chunkMWMSFIWN_cjs.__name(readQuery, "readQuery");
952
+ chunkL6DXCKVQ_cjs.__name(readQuery, "readQuery");
835
953
 
836
954
  // src/errors/instructed-delay.ts
837
955
  function serviceInstructedDelayMs(error, nowMs) {
@@ -846,7 +964,7 @@ function serviceInstructedDelayMs(error, nowMs) {
846
964
  const wait = resetAtMs - nowMs;
847
965
  return wait > 0 ? wait : void 0;
848
966
  }
849
- chunkMWMSFIWN_cjs.__name(serviceInstructedDelayMs, "serviceInstructedDelayMs");
967
+ chunkL6DXCKVQ_cjs.__name(serviceInstructedDelayMs, "serviceInstructedDelayMs");
850
968
 
851
969
  // src/http/retry-policy.ts
852
970
  var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
@@ -859,9 +977,9 @@ var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
859
977
  ]);
860
978
  function isReplaySafe(request) {
861
979
  if (IDEMPOTENT_METHODS.has(request.method.toUpperCase())) return true;
862
- return headerValue(request.headers, chunk7BZW6XYJ_cjs.HEADER_IDEMPOTENCY_KEY.name) !== void 0;
980
+ return headerValue(request.headers, chunkSHSK7UUY_cjs.HEADER_IDEMPOTENCY_KEY.name) !== void 0;
863
981
  }
864
- chunkMWMSFIWN_cjs.__name(isReplaySafe, "isReplaySafe");
982
+ chunkL6DXCKVQ_cjs.__name(isReplaySafe, "isReplaySafe");
865
983
  var UNREACHABLE_CODES = /* @__PURE__ */ new Set(["ECONNREFUSED", "ENOTFOUND"]);
866
984
  function isUnreachableHost(error, depth = 0) {
867
985
  if (depth > 4 || typeof error !== "object" || error === null) return false;
@@ -872,10 +990,10 @@ function isUnreachableHost(error, depth = 0) {
872
990
  }
873
991
  return isUnreachableHost(cause, depth + 1);
874
992
  }
875
- chunkMWMSFIWN_cjs.__name(isUnreachableHost, "isUnreachableHost");
993
+ chunkL6DXCKVQ_cjs.__name(isUnreachableHost, "isUnreachableHost");
876
994
  var _DefaultRetryPolicy = class _DefaultRetryPolicy {
877
995
  constructor(config) {
878
- chunkMWMSFIWN_cjs.__publicField(this, "config");
996
+ chunkL6DXCKVQ_cjs.__publicField(this, "config");
879
997
  this.config = config;
880
998
  }
881
999
  shouldRetry(attempt, error, request) {
@@ -892,7 +1010,7 @@ var _DefaultRetryPolicy = class _DefaultRetryPolicy {
892
1010
  return this.config.jitter ? delay * (0.5 + Math.random() * 0.5) : delay;
893
1011
  }
894
1012
  };
895
- chunkMWMSFIWN_cjs.__name(_DefaultRetryPolicy, "DefaultRetryPolicy");
1013
+ chunkL6DXCKVQ_cjs.__name(_DefaultRetryPolicy, "DefaultRetryPolicy");
896
1014
  var DefaultRetryPolicy = _DefaultRetryPolicy;
897
1015
  function retryPolicyFor(maxAttempts) {
898
1016
  return new DefaultRetryPolicy({
@@ -903,7 +1021,7 @@ function retryPolicyFor(maxAttempts) {
903
1021
  jitter: true
904
1022
  });
905
1023
  }
906
- chunkMWMSFIWN_cjs.__name(retryPolicyFor, "retryPolicyFor");
1024
+ chunkL6DXCKVQ_cjs.__name(retryPolicyFor, "retryPolicyFor");
907
1025
 
908
1026
  // src/config/preview-read.ts
909
1027
  var derived = /* @__PURE__ */ new Set();
@@ -912,19 +1030,19 @@ var announced = /* @__PURE__ */ new Set();
912
1030
  function noteDerivedPreview(dataset) {
913
1031
  derived.add(dataset);
914
1032
  }
915
- chunkMWMSFIWN_cjs.__name(noteDerivedPreview, "noteDerivedPreview");
1033
+ chunkL6DXCKVQ_cjs.__name(noteDerivedPreview, "noteDerivedPreview");
916
1034
  function isDerivedPreview(dataset) {
917
1035
  return derived.has(dataset);
918
1036
  }
919
- chunkMWMSFIWN_cjs.__name(isDerivedPreview, "isDerivedPreview");
1037
+ chunkL6DXCKVQ_cjs.__name(isDerivedPreview, "isDerivedPreview");
920
1038
  function isUnknownPreview(dataset) {
921
1039
  const since = unknown.get(dataset);
922
1040
  if (since === void 0) return false;
923
- if (Date.now() - since < chunk7BZW6XYJ_cjs.UNKNOWN_PREVIEW_RECHECK_MS) return true;
1041
+ if (Date.now() - since < chunk7I3SC7SV_cjs.UNKNOWN_PREVIEW_RECHECK_MS) return true;
924
1042
  unknown.delete(dataset);
925
1043
  return false;
926
1044
  }
927
- chunkMWMSFIWN_cjs.__name(isUnknownPreview, "isUnknownPreview");
1045
+ chunkL6DXCKVQ_cjs.__name(isUnknownPreview, "isUnknownPreview");
928
1046
  function rememberUnknownPreview(dataset) {
929
1047
  unknown.set(dataset, Date.now());
930
1048
  if (announced.has(dataset)) return;
@@ -933,11 +1051,11 @@ function rememberUnknownPreview(dataset) {
933
1051
  `[RelyIO] No preview dataset "${dataset}" exists for this deployment's branch \u2014 reading the key's default dataset instead, and asking again in a minute.`
934
1052
  );
935
1053
  }
936
- chunkMWMSFIWN_cjs.__name(rememberUnknownPreview, "rememberUnknownPreview");
1054
+ chunkL6DXCKVQ_cjs.__name(rememberUnknownPreview, "rememberUnknownPreview");
937
1055
  function answersUnknownDataset(error, dataset) {
938
1056
  return error instanceof ResourceNotFoundError && error.context?.resourceType === "dataset" && error.context.resourceId === dataset;
939
1057
  }
940
- chunkMWMSFIWN_cjs.__name(answersUnknownDataset, "answersUnknownDataset");
1058
+ chunkL6DXCKVQ_cjs.__name(answersUnknownDataset, "answersUnknownDataset");
941
1059
 
942
1060
  // src/http/abortable-sleep.ts
943
1061
  function sleep(ms, signal) {
@@ -946,7 +1064,7 @@ function sleep(ms, signal) {
946
1064
  resolve();
947
1065
  return;
948
1066
  }
949
- const done = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name(() => {
1067
+ const done = /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name(() => {
950
1068
  clearTimeout(timer);
951
1069
  signal?.removeEventListener("abort", done);
952
1070
  resolve();
@@ -955,37 +1073,37 @@ function sleep(ms, signal) {
955
1073
  signal?.addEventListener("abort", done, { once: true });
956
1074
  });
957
1075
  }
958
- chunkMWMSFIWN_cjs.__name(sleep, "sleep");
1076
+ chunkL6DXCKVQ_cjs.__name(sleep, "sleep");
959
1077
  function isAborted(signal) {
960
1078
  return signal?.aborted === true;
961
1079
  }
962
- chunkMWMSFIWN_cjs.__name(isAborted, "isAborted");
1080
+ chunkL6DXCKVQ_cjs.__name(isAborted, "isAborted");
963
1081
 
964
1082
  // src/http/request-timeout.ts
965
1083
  var MAX_TIMER_DELAY_MS = 2147483647;
966
1084
  function isTimerDelay(value) {
967
1085
  return typeof value === "number" && value >= 1 && value <= MAX_TIMER_DELAY_MS;
968
1086
  }
969
- chunkMWMSFIWN_cjs.__name(isTimerDelay, "isTimerDelay");
1087
+ chunkL6DXCKVQ_cjs.__name(isTimerDelay, "isTimerDelay");
970
1088
  function assertRequestTimeout(timeout) {
971
1089
  if (isTimerDelay(timeout)) return;
972
1090
  throw new Error(
973
1091
  `timeout must be a number of milliseconds from 1 to ${MAX_TIMER_DELAY_MS} \u2014 a timer given 0, NaN, Infinity or more fires at once and ends every request \u2014 and got ${String(timeout)}`
974
1092
  );
975
1093
  }
976
- chunkMWMSFIWN_cjs.__name(assertRequestTimeout, "assertRequestTimeout");
1094
+ chunkL6DXCKVQ_cjs.__name(assertRequestTimeout, "assertRequestTimeout");
977
1095
 
978
1096
  // src/http/http-client.ts
979
1097
  var _HttpClient = class _HttpClient {
980
1098
  constructor(config) {
981
1099
  /** What every request reads off the configuration, derived by {@link configure} and nowhere else. */
982
- chunkMWMSFIWN_cjs.__publicField(this, "connection");
1100
+ chunkL6DXCKVQ_cjs.__publicField(this, "connection");
983
1101
  /**
984
1102
  * Set on a view {@link withHeaders} made: the client every request is sent through, and the
985
1103
  * headers laid beneath each request's own. A view keeps no connection of its own that matters —
986
1104
  * everything it is asked to change, it changes on that client.
987
1105
  */
988
- chunkMWMSFIWN_cjs.__publicField(this, "view");
1106
+ chunkL6DXCKVQ_cjs.__publicField(this, "view");
989
1107
  this.connection = connectionFor(config);
990
1108
  this.announce();
991
1109
  }
@@ -994,7 +1112,7 @@ var _HttpClient = class _HttpClient {
994
1112
  baseUrl: this.connection.baseUrl,
995
1113
  timeout: this.connection.timeout,
996
1114
  retryAttempts: this.connection.config.retryAttempts,
997
- environment: chunkTZL374LS_cjs.isBrowser() ? "browser" : "node"
1115
+ environment: chunkM7MWNV3Q_cjs.isBrowser() ? "browser" : "node"
998
1116
  });
999
1117
  }
1000
1118
  /**
@@ -1146,7 +1264,7 @@ var _HttpClient = class _HttpClient {
1146
1264
  timedOut = true;
1147
1265
  controller.abort();
1148
1266
  }, config.timeout ?? this.connection.timeout);
1149
- const onCallerAbort = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name(() => controller.abort(), "onCallerAbort");
1267
+ const onCallerAbort = /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name(() => controller.abort(), "onCallerAbort");
1150
1268
  caller?.addEventListener("abort", onCallerAbort, { once: true });
1151
1269
  try {
1152
1270
  const filteredHeaders = this.filterHeadersForBrowser(config.headers ?? {});
@@ -1159,7 +1277,7 @@ var _HttpClient = class _HttpClient {
1159
1277
  // runtime has no cookie jar for the mode to govern, so the field is left off and the
1160
1278
  // runtime's default stands; that includes Deno 1.x, whose global is a `window` with no
1161
1279
  // `document`. A Web Worker gets that default too: it has cookies but no `window`.
1162
- ...chunkTZL374LS_cjs.isBrowser() && {
1280
+ ...chunkM7MWNV3Q_cjs.isBrowser() && {
1163
1281
  credentials: credentialsModeFor(this.connection.config.browser.includeCredentials)
1164
1282
  }
1165
1283
  };
@@ -1212,7 +1330,7 @@ var _HttpClient = class _HttpClient {
1212
1330
  }
1213
1331
  );
1214
1332
  const { onCorsError } = this.connection.config.browser;
1215
- if (chunkTZL374LS_cjs.isBrowser() && onCorsError) {
1333
+ if (chunkM7MWNV3Q_cjs.isBrowser() && onCorsError) {
1216
1334
  try {
1217
1335
  onCorsError(corsError, {
1218
1336
  url: config.url,
@@ -1239,7 +1357,7 @@ var _HttpClient = class _HttpClient {
1239
1357
  * spellings, so `Origin` and `User-Agent` — how people write them — reached `fetch` (REL-1409).
1240
1358
  */
1241
1359
  filterHeadersForBrowser(headers) {
1242
- if (!chunkTZL374LS_cjs.isBrowser()) return headers;
1360
+ if (!chunkM7MWNV3Q_cjs.isBrowser()) return headers;
1243
1361
  return Object.fromEntries(
1244
1362
  Object.entries(headers).filter(
1245
1363
  ([name]) => !BROWSER_CONTROLLED_HEADERS.has(name.toLowerCase())
@@ -1327,7 +1445,7 @@ var _HttpClient = class _HttpClient {
1327
1445
  }
1328
1446
  }
1329
1447
  };
1330
- chunkMWMSFIWN_cjs.__name(_HttpClient, "HttpClient");
1448
+ chunkL6DXCKVQ_cjs.__name(_HttpClient, "HttpClient");
1331
1449
  var HttpClient = _HttpClient;
1332
1450
  var _ControlledHttpClient = class _ControlledHttpClient extends HttpClient {
1333
1451
  /**
@@ -1387,7 +1505,7 @@ var _ControlledHttpClient = class _ControlledHttpClient extends HttpClient {
1387
1505
  };
1388
1506
  }
1389
1507
  };
1390
- chunkMWMSFIWN_cjs.__name(_ControlledHttpClient, "ControlledHttpClient");
1508
+ chunkL6DXCKVQ_cjs.__name(_ControlledHttpClient, "ControlledHttpClient");
1391
1509
  var ControlledHttpClient = _ControlledHttpClient;
1392
1510
  var API_KEY_HEADER = "X-API-Key";
1393
1511
  var DATASET_HEADER = "X-RelyIO-Dataset";
@@ -1395,7 +1513,7 @@ function derivedPreviewIn(headers) {
1395
1513
  const dataset = headerValue(headers, DATASET_HEADER);
1396
1514
  return dataset !== void 0 && isDerivedPreview(dataset) ? dataset : void 0;
1397
1515
  }
1398
- chunkMWMSFIWN_cjs.__name(derivedPreviewIn, "derivedPreviewIn");
1516
+ chunkL6DXCKVQ_cjs.__name(derivedPreviewIn, "derivedPreviewIn");
1399
1517
  var BROWSER_CONTROLLED_HEADERS = /* @__PURE__ */ new Set([
1400
1518
  "user-agent",
1401
1519
  "referer",
@@ -1413,7 +1531,7 @@ function connectionFor(config) {
1413
1531
  [DATASET_HEADER]: config.dataset,
1414
1532
  // Only outside a browser, which controls this header. "A browser" is the core's one
1415
1533
  // definition, `isBrowser()` — every environment question in this file asks it.
1416
- "User-Agent": chunkTZL374LS_cjs.isBrowser() ? void 0 : `RelyIO-SDK/${globalWithVersion.__VERSION__ ?? "0.0.0"}`
1534
+ "User-Agent": chunkM7MWNV3Q_cjs.isBrowser() ? void 0 : `RelyIO-SDK/${globalWithVersion.__VERSION__ ?? "0.0.0"}`
1417
1535
  }
1418
1536
  );
1419
1537
  return {
@@ -1427,7 +1545,7 @@ function connectionFor(config) {
1427
1545
  retryPolicy: retryPolicyFor(config.retryAttempts)
1428
1546
  };
1429
1547
  }
1430
- chunkMWMSFIWN_cjs.__name(connectionFor, "connectionFor");
1548
+ chunkL6DXCKVQ_cjs.__name(connectionFor, "connectionFor");
1431
1549
  function layerHeaders(base, over) {
1432
1550
  const layered = { ...base };
1433
1551
  for (const [name, value] of Object.entries(over ?? {})) {
@@ -1440,62 +1558,62 @@ function layerHeaders(base, over) {
1440
1558
  }
1441
1559
  return layered;
1442
1560
  }
1443
- chunkMWMSFIWN_cjs.__name(layerHeaders, "layerHeaders");
1561
+ chunkL6DXCKVQ_cjs.__name(layerHeaders, "layerHeaders");
1444
1562
  function presentKey(value) {
1445
1563
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
1446
1564
  }
1447
- chunkMWMSFIWN_cjs.__name(presentKey, "presentKey");
1565
+ chunkL6DXCKVQ_cjs.__name(presentKey, "presentKey");
1448
1566
  function credentialsModeFor(includeCredentials) {
1449
1567
  return includeCredentials ? "include" : "same-origin";
1450
1568
  }
1451
- chunkMWMSFIWN_cjs.__name(credentialsModeFor, "credentialsModeFor");
1569
+ chunkL6DXCKVQ_cjs.__name(credentialsModeFor, "credentialsModeFor");
1452
1570
 
1453
1571
  // src/http/write-options.ts
1454
1572
  function versionCheckOf(entry) {
1455
1573
  const { id, locale, version, sharedVersion } = entry._metadata;
1456
- return { id, locale, ifMatch: chunk7BZW6XYJ_cjs.entityTag({ entryUid: id, locale, version, sharedVersion }) };
1574
+ return { id, locale, ifMatch: chunkSHSK7UUY_cjs.entityTag({ entryUid: id, locale, version, sharedVersion }) };
1457
1575
  }
1458
- chunkMWMSFIWN_cjs.__name(versionCheckOf, "versionCheckOf");
1576
+ chunkL6DXCKVQ_cjs.__name(versionCheckOf, "versionCheckOf");
1459
1577
  function mintIdempotencyKey() {
1460
1578
  const webCrypto = globalThis.crypto;
1461
1579
  if (typeof webCrypto?.randomUUID !== "function") return void 0;
1462
1580
  return webCrypto.randomUUID();
1463
1581
  }
1464
- chunkMWMSFIWN_cjs.__name(mintIdempotencyKey, "mintIdempotencyKey");
1582
+ chunkL6DXCKVQ_cjs.__name(mintIdempotencyKey, "mintIdempotencyKey");
1465
1583
  function writeHeaders(options) {
1466
1584
  const headers = {};
1467
1585
  if (options?.ifMatch !== void 0) {
1468
- headers[chunk7BZW6XYJ_cjs.HEADER_IF_MATCH.name] = options.ifMatch;
1586
+ headers[chunkSHSK7UUY_cjs.HEADER_IF_MATCH.name] = options.ifMatch;
1469
1587
  }
1470
1588
  const idempotencyKey = options?.idempotencyKey ?? mintIdempotencyKey();
1471
1589
  if (idempotencyKey !== void 0) {
1472
- headers[chunk7BZW6XYJ_cjs.HEADER_IDEMPOTENCY_KEY.name] = idempotencyKey;
1590
+ headers[chunkSHSK7UUY_cjs.HEADER_IDEMPOTENCY_KEY.name] = idempotencyKey;
1473
1591
  }
1474
1592
  return Object.keys(headers).length > 0 ? headers : void 0;
1475
1593
  }
1476
- chunkMWMSFIWN_cjs.__name(writeHeaders, "writeHeaders");
1594
+ chunkL6DXCKVQ_cjs.__name(writeHeaders, "writeHeaders");
1477
1595
 
1478
1596
  // src/content/client-locale.ts
1479
1597
  function callLocale(named, clientLocale) {
1480
1598
  if (named !== void 0) return named;
1481
1599
  return clientLocale === void 0 || clientLocale === "" ? void 0 : clientLocale;
1482
1600
  }
1483
- chunkMWMSFIWN_cjs.__name(callLocale, "callLocale");
1601
+ chunkL6DXCKVQ_cjs.__name(callLocale, "callLocale");
1484
1602
  function readClientLocale(locale) {
1485
1603
  return typeof locale === "function" ? locale : () => locale;
1486
1604
  }
1487
- chunkMWMSFIWN_cjs.__name(readClientLocale, "readClientLocale");
1605
+ chunkL6DXCKVQ_cjs.__name(readClientLocale, "readClientLocale");
1488
1606
 
1489
1607
  // src/content/read-terms.ts
1490
1608
  function writeChildrenQuery(params, options) {
1491
1609
  params.children = options.depth === void 0 ? "true" : `${options.depth}`;
1492
1610
  if (options.limit !== void 0) params.childrenLimit = options.limit;
1493
1611
  }
1494
- chunkMWMSFIWN_cjs.__name(writeChildrenQuery, "writeChildrenQuery");
1612
+ chunkL6DXCKVQ_cjs.__name(writeChildrenQuery, "writeChildrenQuery");
1495
1613
  function namesMetadata(key) {
1496
1614
  return key === "_metadata" || key.startsWith("_metadata.");
1497
1615
  }
1498
- chunkMWMSFIWN_cjs.__name(namesMetadata, "namesMetadata");
1616
+ chunkL6DXCKVQ_cjs.__name(namesMetadata, "namesMetadata");
1499
1617
  function refuseMetadataConditions(conditions) {
1500
1618
  const named = Object.keys(conditions).filter(namesMetadata);
1501
1619
  if (named.length === 0) return;
@@ -1508,7 +1626,7 @@ function refuseMetadataConditions(conditions) {
1508
1626
  }))
1509
1627
  );
1510
1628
  }
1511
- chunkMWMSFIWN_cjs.__name(refuseMetadataConditions, "refuseMetadataConditions");
1629
+ chunkL6DXCKVQ_cjs.__name(refuseMetadataConditions, "refuseMetadataConditions");
1512
1630
 
1513
1631
  // src/content/read-options.ts
1514
1632
  function listQuery(options, clientLocale) {
@@ -1532,7 +1650,7 @@ function listQuery(options, clientLocale) {
1532
1650
  writeReadTerms(query, options, clientLocale);
1533
1651
  return query;
1534
1652
  }
1535
- chunkMWMSFIWN_cjs.__name(listQuery, "listQuery");
1653
+ chunkL6DXCKVQ_cjs.__name(listQuery, "listQuery");
1536
1654
  function childrenQuery(options, clientLocale) {
1537
1655
  const query = {};
1538
1656
  if (options.limit !== void 0) query.limit = options.limit;
@@ -1541,34 +1659,34 @@ function childrenQuery(options, clientLocale) {
1541
1659
  writeReadTerms(query, options, clientLocale);
1542
1660
  return query;
1543
1661
  }
1544
- chunkMWMSFIWN_cjs.__name(childrenQuery, "childrenQuery");
1662
+ chunkL6DXCKVQ_cjs.__name(childrenQuery, "childrenQuery");
1545
1663
  function entryQuery(options, clientLocale) {
1546
1664
  const query = {};
1547
1665
  writeReadTerms(query, options, clientLocale);
1548
1666
  return query;
1549
1667
  }
1550
- chunkMWMSFIWN_cjs.__name(entryQuery, "entryQuery");
1668
+ chunkL6DXCKVQ_cjs.__name(entryQuery, "entryQuery");
1551
1669
  function documentQuery(options, clientLocale) {
1552
1670
  const query = {};
1553
1671
  writeDocumentTerms(query, options, clientLocale);
1554
1672
  return query;
1555
1673
  }
1556
- chunkMWMSFIWN_cjs.__name(documentQuery, "documentQuery");
1674
+ chunkL6DXCKVQ_cjs.__name(documentQuery, "documentQuery");
1557
1675
  function writeReadTerms(query, options, clientLocale) {
1558
1676
  writeDocumentTerms(query, options, clientLocale);
1559
1677
  if (options.children !== void 0) {
1560
1678
  writeChildrenQuery(query, options.children === true ? {} : options.children);
1561
1679
  }
1562
1680
  }
1563
- chunkMWMSFIWN_cjs.__name(writeReadTerms, "writeReadTerms");
1681
+ chunkL6DXCKVQ_cjs.__name(writeReadTerms, "writeReadTerms");
1564
1682
  function writeDocumentTerms(query, options, clientLocale) {
1565
1683
  if (options.include !== void 0 && options.include.length > 0) {
1566
1684
  query.include = options.include.join(",");
1567
1685
  }
1568
1686
  writeLocale(query, options.locale ?? clientLocale);
1569
- if (typeof options.fresh === "string") query[chunk7BZW6XYJ_cjs.FRESH_PARAMETER] = options.fresh;
1687
+ if (typeof options.fresh === "string") query[chunkSHSK7UUY_cjs.FRESH_PARAMETER] = options.fresh;
1570
1688
  }
1571
- chunkMWMSFIWN_cjs.__name(writeDocumentTerms, "writeDocumentTerms");
1689
+ chunkL6DXCKVQ_cjs.__name(writeDocumentTerms, "writeDocumentTerms");
1572
1690
  function writeLocale(query, locale) {
1573
1691
  if (locale === void 0) return;
1574
1692
  if (typeof locale === "string") {
@@ -1583,18 +1701,18 @@ function writeLocale(query, locale) {
1583
1701
  }
1584
1702
  query.locales = locale.join(",");
1585
1703
  }
1586
- chunkMWMSFIWN_cjs.__name(writeLocale, "writeLocale");
1704
+ chunkL6DXCKVQ_cjs.__name(writeLocale, "writeLocale");
1587
1705
  function signalOf(options) {
1588
1706
  return options.signal === void 0 ? {} : { signal: options.signal };
1589
1707
  }
1590
- chunkMWMSFIWN_cjs.__name(signalOf, "signalOf");
1708
+ chunkL6DXCKVQ_cjs.__name(signalOf, "signalOf");
1591
1709
  function readHeaders(options) {
1592
1710
  const headers = {};
1593
1711
  if (options.dataset !== void 0) headers[DATASET_HEADER] = options.dataset;
1594
1712
  if (options.fresh === true) headers["Cache-Control"] = "no-cache";
1595
1713
  return Object.keys(headers).length > 0 ? headers : void 0;
1596
1714
  }
1597
- chunkMWMSFIWN_cjs.__name(readHeaders, "readHeaders");
1715
+ chunkL6DXCKVQ_cjs.__name(readHeaders, "readHeaders");
1598
1716
 
1599
1717
  // src/content/entry-handle.ts
1600
1718
  var _EntryHandle = class _EntryHandle {
@@ -1607,7 +1725,7 @@ var _EntryHandle = class _EntryHandle {
1607
1725
  this.httpClient = httpClient;
1608
1726
  this.typeName = typeName;
1609
1727
  /** The client's locale, asked on every call rather than copied when this handle was taken. */
1610
- chunkMWMSFIWN_cjs.__publicField(this, "clientLocale");
1728
+ chunkL6DXCKVQ_cjs.__publicField(this, "clientLocale");
1611
1729
  this.clientLocale = readClientLocale(locale);
1612
1730
  }
1613
1731
  /**
@@ -1730,13 +1848,16 @@ var _EntryHandle = class _EntryHandle {
1730
1848
  });
1731
1849
  }
1732
1850
  };
1733
- chunkMWMSFIWN_cjs.__name(_EntryHandle, "EntryHandle");
1851
+ chunkL6DXCKVQ_cjs.__name(_EntryHandle, "EntryHandle");
1734
1852
  var EntryHandle = _EntryHandle;
1735
1853
 
1736
1854
  // src/content/content-client.ts
1737
1855
  var _ContentClient = class _ContentClient extends EntryHandle {
1738
1856
  /**
1739
- * Create a new content entry.
1857
+ * Create a new content entry, published. The answer's `_metadata.warnings` lists each reference
1858
+ * the content type declares `weak` that the create made live while the entry it points at is
1859
+ * unpublished (`REFERENCE_NOT_PUBLISHED`) — `[]` when there are none; the create is never refused
1860
+ * for them.
1740
1861
  *
1741
1862
  * `locale` defaults to the client's own, and `dataset` to the client's (`client.with({ dataset })`
1742
1863
  * sets it for every call).
@@ -1850,15 +1971,15 @@ var _ContentClient = class _ContentClient extends EntryHandle {
1850
1971
  return response.body;
1851
1972
  }
1852
1973
  };
1853
- chunkMWMSFIWN_cjs.__name(_ContentClient, "ContentClient");
1974
+ chunkL6DXCKVQ_cjs.__name(_ContentClient, "ContentClient");
1854
1975
  var ContentClient = _ContentClient;
1855
1976
 
1856
1977
  // src/errors/file-errors.ts
1857
1978
  var _FileUploadError = class _FileUploadError extends SDKError {
1858
1979
  constructor(code, message, options = {}) {
1859
1980
  super(message, options.statusCode, options.cause, { ...options.context, fileErrorCode: code });
1860
- chunkMWMSFIWN_cjs.__publicField(this, "code");
1861
- chunkMWMSFIWN_cjs.__publicField(this, "retryable");
1981
+ chunkL6DXCKVQ_cjs.__publicField(this, "code");
1982
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable");
1862
1983
  this.code = code;
1863
1984
  this.retryable = options.retriable ?? false;
1864
1985
  }
@@ -1866,19 +1987,19 @@ var _FileUploadError = class _FileUploadError extends SDKError {
1866
1987
  return this.message;
1867
1988
  }
1868
1989
  };
1869
- chunkMWMSFIWN_cjs.__name(_FileUploadError, "FileUploadError");
1990
+ chunkL6DXCKVQ_cjs.__name(_FileUploadError, "FileUploadError");
1870
1991
  var FileUploadError = _FileUploadError;
1871
1992
  var _FileValidationError = class _FileValidationError extends BaseValidationError {
1872
1993
  constructor(message, violations = [], cause) {
1873
1994
  super(message, violations, 400, cause);
1874
- chunkMWMSFIWN_cjs.__publicField(this, "code", "FILE_VALIDATION_ERROR");
1995
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "FILE_VALIDATION_ERROR");
1875
1996
  }
1876
1997
  getUserMessage() {
1877
1998
  if (this.violations.length === 1) return this.violations[0]?.message ?? this.message;
1878
1999
  return this.message;
1879
2000
  }
1880
2001
  };
1881
- chunkMWMSFIWN_cjs.__name(_FileValidationError, "FileValidationError");
2002
+ chunkL6DXCKVQ_cjs.__name(_FileValidationError, "FileValidationError");
1882
2003
  var FileValidationError = _FileValidationError;
1883
2004
  function validateFile(file, constraints = {}) {
1884
2005
  const violations = [];
@@ -1901,7 +2022,7 @@ function validateFile(file, constraints = {}) {
1901
2022
  }
1902
2023
  return violations;
1903
2024
  }
1904
- chunkMWMSFIWN_cjs.__name(validateFile, "validateFile");
2025
+ chunkL6DXCKVQ_cjs.__name(validateFile, "validateFile");
1905
2026
 
1906
2027
  // src/errors/file-error-codes.ts
1907
2028
  var FILE_ERROR_CODES = [
@@ -1931,11 +2052,11 @@ function assertWaitOptions(options) {
1931
2052
  );
1932
2053
  }
1933
2054
  }
1934
- chunkMWMSFIWN_cjs.__name(assertWaitOptions, "assertWaitOptions");
2055
+ chunkL6DXCKVQ_cjs.__name(assertWaitOptions, "assertWaitOptions");
1935
2056
  function hasText(value) {
1936
2057
  return value != null && value !== "";
1937
2058
  }
1938
- chunkMWMSFIWN_cjs.__name(hasText, "hasText");
2059
+ chunkL6DXCKVQ_cjs.__name(hasText, "hasText");
1939
2060
  function processingFailure(subject, stored) {
1940
2061
  const storedCode = stored?.code;
1941
2062
  const code = FILE_ERROR_CODES.find((known) => known === storedCode) ?? "PROCESSING_FAILED";
@@ -1948,7 +2069,7 @@ function processingFailure(subject, stored) {
1948
2069
  }
1949
2070
  );
1950
2071
  }
1951
- chunkMWMSFIWN_cjs.__name(processingFailure, "processingFailure");
2072
+ chunkL6DXCKVQ_cjs.__name(processingFailure, "processingFailure");
1952
2073
  async function computeSha256Hex(blob) {
1953
2074
  try {
1954
2075
  const subtle = globalThis.crypto?.subtle;
@@ -1962,7 +2083,7 @@ async function computeSha256Hex(blob) {
1962
2083
  return void 0;
1963
2084
  }
1964
2085
  }
1965
- chunkMWMSFIWN_cjs.__name(computeSha256Hex, "computeSha256Hex");
2086
+ chunkL6DXCKVQ_cjs.__name(computeSha256Hex, "computeSha256Hex");
1966
2087
  var _AssetFileBuilder = class _AssetFileBuilder {
1967
2088
  /**
1968
2089
  * @param locale - The client's locale, sent when a call names none: the function
@@ -1973,7 +2094,7 @@ var _AssetFileBuilder = class _AssetFileBuilder {
1973
2094
  this.assetType = assetType;
1974
2095
  this.entryUid = entryUid;
1975
2096
  /** The client's locale, asked on every call rather than copied when this builder was taken. */
1976
- chunkMWMSFIWN_cjs.__publicField(this, "clientLocale");
2097
+ chunkL6DXCKVQ_cjs.__publicField(this, "clientLocale");
1977
2098
  this.clientLocale = readClientLocale(locale);
1978
2099
  }
1979
2100
  /**
@@ -2230,7 +2351,7 @@ var _AssetFileBuilder = class _AssetFileBuilder {
2230
2351
  }
2231
2352
  }
2232
2353
  };
2233
- chunkMWMSFIWN_cjs.__name(_AssetFileBuilder, "AssetFileBuilder");
2354
+ chunkL6DXCKVQ_cjs.__name(_AssetFileBuilder, "AssetFileBuilder");
2234
2355
  var AssetFileBuilder = _AssetFileBuilder;
2235
2356
  var _AssetUploadBuilder = class _AssetUploadBuilder {
2236
2357
  /**
@@ -2241,19 +2362,19 @@ var _AssetUploadBuilder = class _AssetUploadBuilder {
2241
2362
  this.httpClient = httpClient;
2242
2363
  this.assetType = assetType;
2243
2364
  this.file = file;
2244
- chunkMWMSFIWN_cjs.__publicField(this, "_fileName");
2245
- chunkMWMSFIWN_cjs.__publicField(this, "_visibility");
2246
- chunkMWMSFIWN_cjs.__publicField(this, "_locale");
2247
- chunkMWMSFIWN_cjs.__publicField(this, "_publish");
2248
- chunkMWMSFIWN_cjs.__publicField(this, "_content", {});
2249
- chunkMWMSFIWN_cjs.__publicField(this, "_slug");
2250
- chunkMWMSFIWN_cjs.__publicField(this, "_waitForReady", false);
2251
- chunkMWMSFIWN_cjs.__publicField(this, "_waitOptions", {});
2252
- chunkMWMSFIWN_cjs.__publicField(this, "_onProgress");
2253
- chunkMWMSFIWN_cjs.__publicField(this, "_validate");
2254
- chunkMWMSFIWN_cjs.__publicField(this, "_maxPartRetries", 3);
2365
+ chunkL6DXCKVQ_cjs.__publicField(this, "_fileName");
2366
+ chunkL6DXCKVQ_cjs.__publicField(this, "_visibility");
2367
+ chunkL6DXCKVQ_cjs.__publicField(this, "_locale");
2368
+ chunkL6DXCKVQ_cjs.__publicField(this, "_publish");
2369
+ chunkL6DXCKVQ_cjs.__publicField(this, "_content", {});
2370
+ chunkL6DXCKVQ_cjs.__publicField(this, "_slug");
2371
+ chunkL6DXCKVQ_cjs.__publicField(this, "_waitForReady", false);
2372
+ chunkL6DXCKVQ_cjs.__publicField(this, "_waitOptions", {});
2373
+ chunkL6DXCKVQ_cjs.__publicField(this, "_onProgress");
2374
+ chunkL6DXCKVQ_cjs.__publicField(this, "_validate");
2375
+ chunkL6DXCKVQ_cjs.__publicField(this, "_maxPartRetries", 3);
2255
2376
  /** The client's locale, read once when the upload starts. */
2256
- chunkMWMSFIWN_cjs.__publicField(this, "clientLocale");
2377
+ chunkL6DXCKVQ_cjs.__publicField(this, "clientLocale");
2257
2378
  this.clientLocale = readClientLocale(locale);
2258
2379
  }
2259
2380
  /** Subscribe to client → storage upload progress (single PUT + multipart). */
@@ -2489,7 +2610,7 @@ var _AssetUploadBuilder = class _AssetUploadBuilder {
2489
2610
  this._onProgress({ phase: "upload", loaded, total, progress });
2490
2611
  }
2491
2612
  };
2492
- chunkMWMSFIWN_cjs.__name(_AssetUploadBuilder, "AssetUploadBuilder");
2613
+ chunkL6DXCKVQ_cjs.__name(_AssetUploadBuilder, "AssetUploadBuilder");
2493
2614
  var AssetUploadBuilder = _AssetUploadBuilder;
2494
2615
  var _AssetClient = class _AssetClient extends EntryHandle {
2495
2616
  /**
@@ -2520,14 +2641,14 @@ var _AssetClient = class _AssetClient extends EntryHandle {
2520
2641
  return new AssetUploadBuilder(this.httpClient, this.typeName, file, this.clientLocale);
2521
2642
  }
2522
2643
  };
2523
- chunkMWMSFIWN_cjs.__name(_AssetClient, "AssetClient");
2644
+ chunkL6DXCKVQ_cjs.__name(_AssetClient, "AssetClient");
2524
2645
  var AssetClient = _AssetClient;
2525
2646
  function isAssetEntry(entry) {
2526
2647
  if (entry == null || typeof entry !== "object") return false;
2527
2648
  const metadata = entry._metadata;
2528
2649
  return metadata?.entryType === "asset";
2529
2650
  }
2530
- chunkMWMSFIWN_cjs.__name(isAssetEntry, "isAssetEntry");
2651
+ chunkL6DXCKVQ_cjs.__name(isAssetEntry, "isAssetEntry");
2531
2652
 
2532
2653
  // src/content/document-handle.ts
2533
2654
  var _DocumentHandle = class _DocumentHandle {
@@ -2540,7 +2661,7 @@ var _DocumentHandle = class _DocumentHandle {
2540
2661
  this.httpClient = httpClient;
2541
2662
  this.name = name;
2542
2663
  /** The client's locale, asked on every call rather than copied when this handle was taken. */
2543
- chunkMWMSFIWN_cjs.__publicField(this, "clientLocale");
2664
+ chunkL6DXCKVQ_cjs.__publicField(this, "clientLocale");
2544
2665
  this.clientLocale = readClientLocale(locale);
2545
2666
  }
2546
2667
  async update(...args) {
@@ -2600,16 +2721,16 @@ var _DocumentHandle = class _DocumentHandle {
2600
2721
  return writeHeaders({ idempotencyKey: options?.idempotencyKey, ifMatch: write.ifMatch });
2601
2722
  }
2602
2723
  };
2603
- chunkMWMSFIWN_cjs.__name(_DocumentHandle, "DocumentHandle");
2724
+ chunkL6DXCKVQ_cjs.__name(_DocumentHandle, "DocumentHandle");
2604
2725
  var DocumentHandle = _DocumentHandle;
2605
2726
  function isCheckedUpdate(args) {
2606
2727
  return isRead(args[0]);
2607
2728
  }
2608
- chunkMWMSFIWN_cjs.__name(isCheckedUpdate, "isCheckedUpdate");
2729
+ chunkL6DXCKVQ_cjs.__name(isCheckedUpdate, "isCheckedUpdate");
2609
2730
  function isRead(value) {
2610
2731
  return "_metadata" in value && typeof value._metadata === "object" && value._metadata !== null;
2611
2732
  }
2612
- chunkMWMSFIWN_cjs.__name(isRead, "isRead");
2733
+ chunkL6DXCKVQ_cjs.__name(isRead, "isRead");
2613
2734
 
2614
2735
  // src/content/singleton-client.ts
2615
2736
  var _SingletonClient = class _SingletonClient extends DocumentHandle {
@@ -2642,7 +2763,10 @@ var _SingletonClient = class _SingletonClient extends DocumentHandle {
2642
2763
  throw error;
2643
2764
  }
2644
2765
  }
2645
- /** The API publishes on PATCH: there is no separate publish route. */
2766
+ /**
2767
+ * The API publishes on PATCH: there is no separate publish route. The answer's `_metadata` also
2768
+ * lists the links the write left pointing nowhere and its `warnings` (REL-3097).
2769
+ */
2646
2770
  patch(write, options) {
2647
2771
  return this.httpClient.fetchPayload(
2648
2772
  "/v1/singletons/{key}",
@@ -2664,7 +2788,7 @@ var _SingletonClient = class _SingletonClient extends DocumentHandle {
2664
2788
  });
2665
2789
  }
2666
2790
  };
2667
- chunkMWMSFIWN_cjs.__name(_SingletonClient, "SingletonClient");
2791
+ chunkL6DXCKVQ_cjs.__name(_SingletonClient, "SingletonClient");
2668
2792
  var SingletonClient = _SingletonClient;
2669
2793
 
2670
2794
  // src/content/settings-client.ts
@@ -2702,15 +2826,11 @@ var _SettingsClient = class _SettingsClient extends DocumentHandle {
2702
2826
  async reset(...args) {
2703
2827
  const [first, second] = args;
2704
2828
  const write = first !== void 0 && isRead(first) ? { ...versionCheckOf(first), options: second } : { locale: this.localeOf(first?.locale), ifMatch: void 0, options: first };
2705
- return this.httpClient.fetchPayload(
2706
- "/v1/settings/{groupId}/reset",
2707
- "post",
2708
- {
2709
- path: { groupId: this.name },
2710
- query: write.locale === void 0 ? void 0 : { locale: write.locale },
2711
- headers: DocumentHandle.headersOf(write, write.options)
2712
- }
2713
- );
2829
+ return this.httpClient.fetchPayload("/v1/settings/{groupId}/reset", "post", {
2830
+ path: { groupId: this.name },
2831
+ query: write.locale === void 0 ? void 0 : { locale: write.locale },
2832
+ headers: DocumentHandle.headersOf(write, write.options)
2833
+ });
2714
2834
  }
2715
2835
  /** The group's default values, as the schema declares them. */
2716
2836
  async getDefaults() {
@@ -2741,9 +2861,202 @@ var _SettingsClient = class _SettingsClient extends DocumentHandle {
2741
2861
  });
2742
2862
  }
2743
2863
  };
2744
- chunkMWMSFIWN_cjs.__name(_SettingsClient, "SettingsClient");
2864
+ chunkL6DXCKVQ_cjs.__name(_SettingsClient, "SettingsClient");
2745
2865
  var SettingsClient = _SettingsClient;
2746
2866
 
2867
+ // src/content/records-client.ts
2868
+ function isMissingRecord(error) {
2869
+ return error instanceof ResourceNotFoundError && error.context?.resourceType === "record";
2870
+ }
2871
+ chunkL6DXCKVQ_cjs.__name(isMissingRecord, "isMissingRecord");
2872
+ var _RecordsClient = class _RecordsClient {
2873
+ constructor(httpClient, recordType) {
2874
+ this.httpClient = httpClient;
2875
+ this.recordType = recordType;
2876
+ }
2877
+ /**
2878
+ * Store a Record, live the moment it lands. Values that break the Record type's fields are
2879
+ * refused with `ValidationError` naming each field, and nothing is stored. Values a unique set of
2880
+ * the type claims, held by another Record, are refused with `ResourceConflictError` — its
2881
+ * `blockage` is `{ kind: 'value-taken', facts: { fields, recordId } }` (REL-3782).
2882
+ */
2883
+ async create(fields, options = {}) {
2884
+ return this.httpClient.fetchPayload(
2885
+ "/v1/records/{recordType}",
2886
+ "post",
2887
+ {
2888
+ path: { recordType: this.recordType },
2889
+ body: { fields },
2890
+ headers: readHeaders(options),
2891
+ ...signalOf(options)
2892
+ }
2893
+ );
2894
+ }
2895
+ /** One page of the Records `where` keeps, newest first unless `sort` names one key. */
2896
+ async list(options = {}) {
2897
+ const response = await this.httpClient.send(
2898
+ "/v1/records/{recordType}",
2899
+ "get",
2900
+ {
2901
+ path: { recordType: this.recordType },
2902
+ query: {
2903
+ ...options.where === void 0 ? {} : { filters: JSON.stringify(options.where) },
2904
+ ...options.sort === void 0 ? {} : { sort: options.sort },
2905
+ ...options.limit === void 0 ? {} : { limit: options.limit },
2906
+ ...options.cursor === void 0 ? {} : { cursor: options.cursor },
2907
+ ...options.count === true ? { count: "true" } : {},
2908
+ ...options.facets === void 0 || options.facets.length === 0 ? {} : { facets: options.facets.join(",") },
2909
+ ...includeQuery(options)
2910
+ },
2911
+ headers: readHeaders(options),
2912
+ ...signalOf(options)
2913
+ }
2914
+ );
2915
+ return response.body;
2916
+ }
2917
+ /**
2918
+ * Upload a File for one of this Record type's file fields (REL-3824), and answer what a create or
2919
+ * update sets the field to. The bytes go straight to object storage at the address the upload
2920
+ * names, never through RelyIO; a File outside the field's `accept` or over its `maxSize` is
2921
+ * refused with `ValidationError` naming the field before any byte is sent. An upload no write
2922
+ * names within a day is deleted with its bytes. Server-side only, as every Record call is.
2923
+ *
2924
+ * @example
2925
+ * ```typescript
2926
+ * const invoice = await relyio.records('order').upload('invoice', pdfBytes, {
2927
+ * name: 'invoice-1001.pdf',
2928
+ * type: 'application/pdf',
2929
+ * })
2930
+ * await relyio.records('order').update(id, { invoice }, { revision })
2931
+ * ```
2932
+ */
2933
+ async upload(field, bytes, options) {
2934
+ const size = bytes instanceof Blob ? bytes.size : bytes.byteLength;
2935
+ const upload = await this.httpClient.fetchPayload("/v1/records/{recordType}/files", "post", {
2936
+ path: { recordType: this.recordType },
2937
+ body: { field, name: options.name, type: options.type, size },
2938
+ headers: readHeaders(options),
2939
+ ...signalOf(options)
2940
+ });
2941
+ const response = await HttpClient.transfer(this.httpClient, upload.url, {
2942
+ method: upload.method,
2943
+ headers: upload.headers,
2944
+ body: bytes,
2945
+ ...signalOf(options)
2946
+ });
2947
+ if (!response.ok) {
2948
+ throw new FileUploadError(
2949
+ "INTERNAL",
2950
+ `Upload failed (${response.status} ${response.statusText}) for ${this.recordType}.${field}`,
2951
+ { retriable: response.status >= 500, statusCode: response.status }
2952
+ );
2953
+ }
2954
+ return { upload: upload.id };
2955
+ }
2956
+ /**
2957
+ * One Record by its id, or `null` when none is stored. A Record type nobody deployed throws
2958
+ * `ResourceNotFoundError` naming it, so it never reads as a missing Record.
2959
+ */
2960
+ async get(id, options = {}) {
2961
+ try {
2962
+ return await this.httpClient.fetchPayload(
2963
+ "/v1/records/{recordType}/{uid}",
2964
+ "get",
2965
+ {
2966
+ path: { recordType: this.recordType, uid: id },
2967
+ query: includeQuery(options),
2968
+ headers: readHeaders(options),
2969
+ ...signalOf(options)
2970
+ }
2971
+ );
2972
+ } catch (error) {
2973
+ if (isMissingRecord(error)) return null;
2974
+ throw error;
2975
+ }
2976
+ }
2977
+ /**
2978
+ * Change the fields named, against the revision the change was made on, and answer the Record at
2979
+ * its next revision. A field given `null` is removed; one not named keeps its value. A Record
2980
+ * written since `revision` is refused with `ResourceConflictError` — its `blockage` is
2981
+ * `{ kind: 'revision-stale', facts: { changedFields } }` — and nothing is written. Values that
2982
+ * break the Record type are refused with `ValidationError` naming each field, and values another
2983
+ * Record holds under a unique set with `ResourceConflictError`, its blockage `value-taken`.
2984
+ *
2985
+ * @example
2986
+ * ```typescript
2987
+ * const order = await relyio.records('order').get(id)
2988
+ * await relyio.records('order').update(id, { status: 'shipped' }, {
2989
+ * revision: order._metadata.revision,
2990
+ * })
2991
+ * ```
2992
+ */
2993
+ async update(id, fields, options) {
2994
+ return this.httpClient.fetchPayload(
2995
+ "/v1/records/{recordType}/{uid}",
2996
+ "patch",
2997
+ {
2998
+ path: { recordType: this.recordType, uid: id },
2999
+ body: { fields },
3000
+ headers: { ...readHeaders(options), "If-Match": `"${options.revision}"` },
3001
+ ...signalOf(options)
3002
+ }
3003
+ );
3004
+ }
3005
+ /**
3006
+ * Remove a Record. Another Record holding it through a reference declared to block its delete —
3007
+ * the default — is refused with `ResourceConflictError`, its `blockage`
3008
+ * (`{ kind: 'referenced', facts: { referrers } }`) naming each; one declared `nullify` is cleared.
3009
+ */
3010
+ async delete(id, options = {}) {
3011
+ await this.httpClient.send(
3012
+ "/v1/records/{recordType}/{uid}",
3013
+ "delete",
3014
+ {
3015
+ path: { recordType: this.recordType, uid: id },
3016
+ headers: readHeaders(options),
3017
+ ...signalOf(options)
3018
+ }
3019
+ );
3020
+ }
3021
+ };
3022
+ chunkL6DXCKVQ_cjs.__name(_RecordsClient, "RecordsClient");
3023
+ var RecordsClient = _RecordsClient;
3024
+ function includeQuery(options) {
3025
+ return {
3026
+ ...options.include === void 0 || options.include.length === 0 ? {} : { include: options.include.join(",") },
3027
+ ...options.locale === void 0 ? {} : { locale: options.locale }
3028
+ };
3029
+ }
3030
+ chunkL6DXCKVQ_cjs.__name(includeQuery, "includeQuery");
3031
+
3032
+ // src/content/record-batch.ts
3033
+ async function sendRecordBatch(httpClient, operations, options = {}) {
3034
+ const { idempotencyKey, ...call } = options;
3035
+ return httpClient.fetchPayload(
3036
+ "/v1/records/batch",
3037
+ "post",
3038
+ {
3039
+ body: { operations },
3040
+ headers: { ...readHeaders(call), ...writeHeaders({ idempotencyKey }) },
3041
+ ...signalOf(call)
3042
+ }
3043
+ );
3044
+ }
3045
+ chunkL6DXCKVQ_cjs.__name(sendRecordBatch, "sendRecordBatch");
3046
+ var OPERATION_PATH = /^operations\[(\d+)\]/;
3047
+ function refusedOperationOf(error) {
3048
+ if (typeof error !== "object" || error === null) return void 0;
3049
+ const { context, violations } = error;
3050
+ const operation = context?.blockage?.facts?.operation;
3051
+ if (typeof operation === "number") return operation;
3052
+ for (const violation of violations ?? []) {
3053
+ const match = typeof violation.field === "string" ? OPERATION_PATH.exec(violation.field) : null;
3054
+ if (match?.[1] !== void 0) return Number(match[1]);
3055
+ }
3056
+ return void 0;
3057
+ }
3058
+ chunkL6DXCKVQ_cjs.__name(refusedOperationOf, "refusedOperationOf");
3059
+
2747
3060
  // src/changes/changes.ts
2748
3061
  var CHANGES_POLL_TIMEOUT_MS = 25e3 + 5e3;
2749
3062
  var EXPIRED_REASONS2 = {
@@ -2757,14 +3070,14 @@ var _ChangesExpiredError = class _ChangesExpiredError extends ResourceExpiredErr
2757
3070
  /** The base class's signature, so `withContext` can rebuild one; then the position resynced to. */
2758
3071
  constructor(message, statusCode = 410, cause, context, fresh) {
2759
3072
  super(message, statusCode, cause, context);
2760
- chunkMWMSFIWN_cjs.__publicField(this, "reason");
3073
+ chunkL6DXCKVQ_cjs.__publicField(this, "reason");
2761
3074
  /**
2762
3075
  * The position the feed resynced to, which a refetch of everything names as `?_fresh`, as a
2763
3076
  * change's {@link FeedChange.fresh} is named: the head a `/v1/changes` resync took, or the cursor
2764
3077
  * the edge's `feed.resync` sent. `undefined` when there was no resync to take one — the error was
2765
3078
  * thrown (`onExpired: 'throw'`) — and on an error a caller built itself.
2766
3079
  */
2767
- chunkMWMSFIWN_cjs.__publicField(this, "fresh");
3080
+ chunkL6DXCKVQ_cjs.__publicField(this, "fresh");
2768
3081
  this.name = "ChangesExpiredError";
2769
3082
  this.reason = expiredReasonOf(context?.reason);
2770
3083
  this.fresh = fresh;
@@ -2801,7 +3114,7 @@ var _ChangesExpiredError = class _ChangesExpiredError extends ResourceExpiredErr
2801
3114
  );
2802
3115
  }
2803
3116
  };
2804
- chunkMWMSFIWN_cjs.__name(_ChangesExpiredError, "ChangesExpiredError");
3117
+ chunkL6DXCKVQ_cjs.__name(_ChangesExpiredError, "ChangesExpiredError");
2805
3118
  var ChangesExpiredError = _ChangesExpiredError;
2806
3119
  function expiredReasonOf(named) {
2807
3120
  for (const reason of Object.values(EXPIRED_REASONS2)) {
@@ -2809,7 +3122,7 @@ function expiredReasonOf(named) {
2809
3122
  }
2810
3123
  return "unknown";
2811
3124
  }
2812
- chunkMWMSFIWN_cjs.__name(expiredReasonOf, "expiredReasonOf");
3125
+ chunkL6DXCKVQ_cjs.__name(expiredReasonOf, "expiredReasonOf");
2813
3126
  async function* pollChanges(http, options = {}) {
2814
3127
  const { signal } = options;
2815
3128
  let since = options.since;
@@ -2855,7 +3168,7 @@ async function* pollChanges(http, options = {}) {
2855
3168
  }
2856
3169
  }
2857
3170
  }
2858
- chunkMWMSFIWN_cjs.__name(pollChanges, "pollChanges");
3171
+ chunkL6DXCKVQ_cjs.__name(pollChanges, "pollChanges");
2859
3172
  async function readChangesHead(http, options = {}) {
2860
3173
  const response = await http.send("/v1/changes", "get", {
2861
3174
  query: {},
@@ -2870,7 +3183,7 @@ async function readChangesHead(http, options = {}) {
2870
3183
  }
2871
3184
  return page.nextCursor;
2872
3185
  }
2873
- chunkMWMSFIWN_cjs.__name(readChangesHead, "readChangesHead");
3186
+ chunkL6DXCKVQ_cjs.__name(readChangesHead, "readChangesHead");
2874
3187
  async function pollOnce(http, since, options) {
2875
3188
  const query = {};
2876
3189
  if (since !== void 0) query.since = since;
@@ -2883,18 +3196,18 @@ async function pollOnce(http, since, options) {
2883
3196
  ...options.signal === void 0 ? {} : { signal: options.signal }
2884
3197
  });
2885
3198
  }
2886
- chunkMWMSFIWN_cjs.__name(pollOnce, "pollOnce");
3199
+ chunkL6DXCKVQ_cjs.__name(pollOnce, "pollOnce");
2887
3200
 
2888
3201
  // src/errors/live-errors.ts
2889
3202
  var _LiveEdgeError = class _LiveEdgeError extends SDKError {
2890
3203
  constructor(message, end, retry, options = {}) {
2891
3204
  super(message, options.statusCode, options.cause, options.context);
2892
- chunkMWMSFIWN_cjs.__publicField(this, "code", "LIVE_EDGE_ENDED");
2893
- chunkMWMSFIWN_cjs.__publicField(this, "retryable");
2894
- chunkMWMSFIWN_cjs.__publicField(this, "end");
2895
- chunkMWMSFIWN_cjs.__publicField(this, "retry");
3205
+ chunkL6DXCKVQ_cjs.__publicField(this, "code", "LIVE_EDGE_ENDED");
3206
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryable");
3207
+ chunkL6DXCKVQ_cjs.__publicField(this, "end");
3208
+ chunkL6DXCKVQ_cjs.__publicField(this, "retry");
2896
3209
  /** A refused poll's `Retry-After`, in milliseconds, where it carried a readable one. */
2897
- chunkMWMSFIWN_cjs.__publicField(this, "retryAfterMs");
3210
+ chunkL6DXCKVQ_cjs.__publicField(this, "retryAfterMs");
2898
3211
  this.end = end;
2899
3212
  this.retry = retry;
2900
3213
  this.retryable = retry !== "stop";
@@ -2904,7 +3217,7 @@ var _LiveEdgeError = class _LiveEdgeError extends SDKError {
2904
3217
  return this.message;
2905
3218
  }
2906
3219
  };
2907
- chunkMWMSFIWN_cjs.__name(_LiveEdgeError, "LiveEdgeError");
3220
+ chunkL6DXCKVQ_cjs.__name(_LiveEdgeError, "LiveEdgeError");
2908
3221
  var LiveEdgeError = _LiveEdgeError;
2909
3222
 
2910
3223
  // src/config/live-url.ts
@@ -2927,7 +3240,7 @@ function liveEdgeAddress(config) {
2927
3240
  message: `Live updates need the address of RelyIO\u2019s live edge, and this client cannot derive it: \`baseUrl\` is not RelyIO\u2019s API (${Object.keys(LIVE_EDGE_OF_API).join(", ")}). Set \`liveUrl\` in createClient() to the live edge this API belongs with. Nothing was sent.`
2928
3241
  };
2929
3242
  }
2930
- chunkMWMSFIWN_cjs.__name(liveEdgeAddress, "liveEdgeAddress");
3243
+ chunkL6DXCKVQ_cjs.__name(liveEdgeAddress, "liveEdgeAddress");
2931
3244
  function readLiveUrl(liveUrl) {
2932
3245
  let url;
2933
3246
  try {
@@ -2947,7 +3260,7 @@ function readLiveUrl(liveUrl) {
2947
3260
  url.hash = "";
2948
3261
  return { ok: true, url };
2949
3262
  }
2950
- chunkMWMSFIWN_cjs.__name(readLiveUrl, "readLiveUrl");
3263
+ chunkL6DXCKVQ_cjs.__name(readLiveUrl, "readLiveUrl");
2951
3264
  function originOf(baseUrl) {
2952
3265
  try {
2953
3266
  return new URL(baseUrl).origin;
@@ -2955,11 +3268,11 @@ function originOf(baseUrl) {
2955
3268
  return void 0;
2956
3269
  }
2957
3270
  }
2958
- chunkMWMSFIWN_cjs.__name(originOf, "originOf");
3271
+ chunkL6DXCKVQ_cjs.__name(originOf, "originOf");
2959
3272
 
2960
3273
  // src/changes/live-edge.ts
2961
3274
  var LIVE_KEEPALIVE_INTERVAL_MS = 3e4;
2962
- var LIVE_SOCKET_OPEN_TIMEOUT_MS = chunk7BZW6XYJ_cjs.VISITOR_POLL_INTERVAL_MS;
3275
+ var LIVE_SOCKET_OPEN_TIMEOUT_MS = chunkSHSK7UUY_cjs.VISITOR_POLL_INTERVAL_MS;
2963
3276
  var LIVE_POLLS_BEFORE_SOCKET = 4;
2964
3277
  async function* subscribeLiveEdge(client, options = {}) {
2965
3278
  const { signal } = options;
@@ -2976,14 +3289,14 @@ async function* subscribeLiveEdge(client, options = {}) {
2976
3289
  if (polled === "aborted") return;
2977
3290
  }
2978
3291
  }
2979
- chunkMWMSFIWN_cjs.__name(subscribeLiveEdge, "subscribeLiveEdge");
3292
+ chunkL6DXCKVQ_cjs.__name(subscribeLiveEdge, "subscribeLiveEdge");
2980
3293
  var SOCKET_CONNECTING = 0;
2981
3294
  var SOCKET_OPEN = 1;
2982
3295
  function runtimeWebSocket() {
2983
3296
  const candidate = globalThis.WebSocket;
2984
3297
  return typeof candidate === "function" ? candidate : void 0;
2985
3298
  }
2986
- chunkMWMSFIWN_cjs.__name(runtimeWebSocket, "runtimeWebSocket");
3299
+ chunkL6DXCKVQ_cjs.__name(runtimeWebSocket, "runtimeWebSocket");
2987
3300
  function openSocket(client, url) {
2988
3301
  const Socket = client.webSocket ?? runtimeWebSocket();
2989
3302
  if (Socket === void 0) return void 0;
@@ -2993,7 +3306,7 @@ function openSocket(client, url) {
2993
3306
  return void 0;
2994
3307
  }
2995
3308
  }
2996
- chunkMWMSFIWN_cjs.__name(openSocket, "openSocket");
3309
+ chunkL6DXCKVQ_cjs.__name(openSocket, "openSocket");
2997
3310
  async function* followSocket(socket, reach, options) {
2998
3311
  const { signal } = options;
2999
3312
  const inbox = socketInbox(socket, signal);
@@ -3029,12 +3342,12 @@ async function* followSocket(socket, reach, options) {
3029
3342
  return "unopened";
3030
3343
  }
3031
3344
  case "message": {
3032
- if (event.data === chunk7BZW6XYJ_cjs.VISITOR_KEEPALIVE.response) continue;
3033
- const frame = typeof event.data === "string" ? chunk7BZW6XYJ_cjs.parseVisitorFrame(event.data) : null;
3345
+ if (event.data === chunkSHSK7UUY_cjs.VISITOR_KEEPALIVE.response) continue;
3346
+ const frame = typeof event.data === "string" ? chunkSHSK7UUY_cjs.parseVisitorFrame(event.data) : null;
3034
3347
  if (frame === null)
3035
3348
  throw unreadable(`a frame the wire does not declare: ${sample(event.data)}`);
3036
3349
  switch (frame.type) {
3037
- case chunk7BZW6XYJ_cjs.VISITOR_FRAMES.opened: {
3350
+ case chunkSHSK7UUY_cjs.VISITOR_FRAMES.opened: {
3038
3351
  caughtUp = true;
3039
3352
  inbox.caughtUp();
3040
3353
  reach.position = frame.cursor;
@@ -3042,7 +3355,7 @@ async function* followSocket(socket, reach, options) {
3042
3355
  options.reached?.(frame.cursor);
3043
3356
  continue;
3044
3357
  }
3045
- case chunk7BZW6XYJ_cjs.VISITOR_FRAMES.changes: {
3358
+ case chunkSHSK7UUY_cjs.VISITOR_FRAMES.changes: {
3046
3359
  const prior = reach.position;
3047
3360
  if (prior === void 0) throw unreadable("changes before the socket had a position");
3048
3361
  for (const change of changesOf(frame.changes, frame.cursor, prior)) {
@@ -3053,7 +3366,7 @@ async function* followSocket(socket, reach, options) {
3053
3366
  if (frame.changes.length === 0) options.reached?.(frame.cursor);
3054
3367
  continue;
3055
3368
  }
3056
- case chunk7BZW6XYJ_cjs.VISITOR_FRAMES.resync: {
3369
+ case chunkSHSK7UUY_cjs.VISITOR_FRAMES.resync: {
3057
3370
  await expire(frame.reason, frame.cursor, options);
3058
3371
  if (isAborted(signal)) return "aborted";
3059
3372
  reach.position = frame.cursor;
@@ -3068,19 +3381,19 @@ async function* followSocket(socket, reach, options) {
3068
3381
  inbox.dispose();
3069
3382
  }
3070
3383
  }
3071
- chunkMWMSFIWN_cjs.__name(followSocket, "followSocket");
3384
+ chunkL6DXCKVQ_cjs.__name(followSocket, "followSocket");
3072
3385
  function socketInbox(socket, signal) {
3073
3386
  const events = [];
3074
3387
  let wake;
3075
3388
  let disposed = false;
3076
3389
  let heard = true;
3077
3390
  let keepalive;
3078
- const rouse = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name(() => {
3391
+ const rouse = /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name(() => {
3079
3392
  const waking = wake;
3080
3393
  wake = void 0;
3081
3394
  waking?.();
3082
3395
  }, "rouse");
3083
- const push = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((event) => {
3396
+ const push = /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name((event) => {
3084
3397
  if (disposed) return;
3085
3398
  events.push(event);
3086
3399
  rouse();
@@ -3125,7 +3438,7 @@ function socketInbox(socket, signal) {
3125
3438
  return;
3126
3439
  }
3127
3440
  heard = false;
3128
- if (socket.readyState === SOCKET_OPEN) socket.send(chunk7BZW6XYJ_cjs.VISITOR_KEEPALIVE.request);
3441
+ if (socket.readyState === SOCKET_OPEN) socket.send(chunkSHSK7UUY_cjs.VISITOR_KEEPALIVE.request);
3129
3442
  }, LIVE_KEEPALIVE_INTERVAL_MS);
3130
3443
  },
3131
3444
  caughtUp() {
@@ -3143,7 +3456,7 @@ function socketInbox(socket, signal) {
3143
3456
  }
3144
3457
  };
3145
3458
  }
3146
- chunkMWMSFIWN_cjs.__name(socketInbox, "socketInbox");
3459
+ chunkL6DXCKVQ_cjs.__name(socketInbox, "socketInbox");
3147
3460
  function closedBy(code, reason) {
3148
3461
  const retry = closeRetryOf(code);
3149
3462
  const meaning = hasOwn(CLOSE_MEANING, code) ? CLOSE_MEANING[code] : code < 4e3 ? "the connection dropped" : "a refusal this version of the SDK does not know";
@@ -3154,26 +3467,26 @@ function closedBy(code, reason) {
3154
3467
  retry
3155
3468
  );
3156
3469
  }
3157
- chunkMWMSFIWN_cjs.__name(closedBy, "closedBy");
3470
+ chunkL6DXCKVQ_cjs.__name(closedBy, "closedBy");
3158
3471
  var AFTER_A_CLOSE = {
3159
3472
  stop: "The same request would be refused again, so it was not retried.",
3160
3473
  retry: "Reconnecting from the last cursor after a short back-off.",
3161
3474
  "back-off": "Retrying after a back-off of at least a minute, without polling, which the same admission refuses."
3162
3475
  };
3163
3476
  function closeRetryOf(code) {
3164
- if (hasOwn(chunk7BZW6XYJ_cjs.VISITOR_CLOSE_RETRY, code)) return chunk7BZW6XYJ_cjs.VISITOR_CLOSE_RETRY[code];
3477
+ if (hasOwn(chunkSHSK7UUY_cjs.VISITOR_CLOSE_RETRY, code)) return chunkSHSK7UUY_cjs.VISITOR_CLOSE_RETRY[code];
3165
3478
  return code < 4e3 ? "retry" : "stop";
3166
3479
  }
3167
- chunkMWMSFIWN_cjs.__name(closeRetryOf, "closeRetryOf");
3480
+ chunkL6DXCKVQ_cjs.__name(closeRetryOf, "closeRetryOf");
3168
3481
  var CLOSE_MEANING = {
3169
- [chunk7BZW6XYJ_cjs.VISITOR_CLOSE_CODES.requestInvalid]: "the edge could not read the request \u2014 a malformed cursor or filter",
3170
- [chunk7BZW6XYJ_cjs.VISITOR_CLOSE_CODES.keyRefused]: "the key is not a publishable key the edge accepts \u2014 unknown, revoked or expired",
3171
- [chunk7BZW6XYJ_cjs.VISITOR_CLOSE_CODES.originRefused]: "this page\u2019s origin is not on the publishable key\u2019s allowed origins",
3172
- [chunk7BZW6XYJ_cjs.VISITOR_CLOSE_CODES.datasetRefused]: "`dataset` names no dataset the key reaches",
3173
- [chunk7BZW6XYJ_cjs.VISITOR_CLOSE_CODES.unavailable]: "the edge could not serve this connection just now \u2014 it could not reach what it needed",
3174
- [chunk7BZW6XYJ_cjs.VISITOR_CLOSE_CODES.allowanceReached]: "the project holds as many live connections as its plan allows",
3175
- [chunk7BZW6XYJ_cjs.VISITOR_CLOSE_CODES.addressLimitReached]: "this address holds as many live connections to the project as one address may",
3176
- [chunk7BZW6XYJ_cjs.VISITOR_CLOSE_CODES.ceilingReached]: "the project is at its safety ceiling of live connections"
3482
+ [chunkSHSK7UUY_cjs.VISITOR_CLOSE_CODES.requestInvalid]: "the edge could not read the request \u2014 a malformed cursor or filter",
3483
+ [chunkSHSK7UUY_cjs.VISITOR_CLOSE_CODES.keyRefused]: "the key is not a publishable key the edge accepts \u2014 unknown, revoked or expired",
3484
+ [chunkSHSK7UUY_cjs.VISITOR_CLOSE_CODES.originRefused]: "this page\u2019s origin is not on the publishable key\u2019s allowed origins",
3485
+ [chunkSHSK7UUY_cjs.VISITOR_CLOSE_CODES.datasetRefused]: "`dataset` names no dataset the key reaches",
3486
+ [chunkSHSK7UUY_cjs.VISITOR_CLOSE_CODES.unavailable]: "the edge could not serve this connection just now \u2014 it could not reach what it needed",
3487
+ [chunkSHSK7UUY_cjs.VISITOR_CLOSE_CODES.allowanceReached]: "the project holds as many live connections as its plan allows",
3488
+ [chunkSHSK7UUY_cjs.VISITOR_CLOSE_CODES.addressLimitReached]: "this address holds as many live connections to the project as one address may",
3489
+ [chunkSHSK7UUY_cjs.VISITOR_CLOSE_CODES.ceilingReached]: "the project is at its safety ceiling of live connections"
3177
3490
  };
3178
3491
  async function* followPolls(client, request, reach, options) {
3179
3492
  const { signal } = options;
@@ -3201,11 +3514,11 @@ async function* followPolls(client, request, reach, options) {
3201
3514
  if (starting) options.reached?.(answer.cursor);
3202
3515
  }
3203
3516
  starting = false;
3204
- await sleep(chunk7BZW6XYJ_cjs.VISITOR_POLL_INTERVAL_MS, signal);
3517
+ await sleep(chunkSHSK7UUY_cjs.VISITOR_POLL_INTERVAL_MS, signal);
3205
3518
  }
3206
3519
  return isAborted(signal) ? "aborted" : "socket";
3207
3520
  }
3208
- chunkMWMSFIWN_cjs.__name(followPolls, "followPolls");
3521
+ chunkL6DXCKVQ_cjs.__name(followPolls, "followPolls");
3209
3522
  async function pollOnce2(client, request, since, signal) {
3210
3523
  if (isAborted(signal)) return void 0;
3211
3524
  const url = edgeUrl(request, since, "poll", client.clientId);
@@ -3216,7 +3529,7 @@ async function pollOnce2(client, request, since, signal) {
3216
3529
  timedOut = true;
3217
3530
  controller.abort();
3218
3531
  }, client.timeout);
3219
- const onAbort = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name(() => controller.abort(), "onAbort");
3532
+ const onAbort = /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name(() => controller.abort(), "onAbort");
3220
3533
  signal?.addEventListener("abort", onAbort, { once: true });
3221
3534
  try {
3222
3535
  let response;
@@ -3243,7 +3556,7 @@ async function pollOnce2(client, request, since, signal) {
3243
3556
  }
3244
3557
  const body = parseJson(text);
3245
3558
  if (!response.ok) throw refusedPoll(response, body, context);
3246
- const answer = chunk7BZW6XYJ_cjs.readVisitorPollAnswer(isRecord(body) ? body["data"] : void 0);
3559
+ const answer = chunkSHSK7UUY_cjs.readVisitorPollAnswer(isRecord(body) ? body["data"] : void 0);
3247
3560
  if (answer === null)
3248
3561
  throw unreadable(`a poll answer the wire does not declare: ${sample(text)}`);
3249
3562
  return answer;
@@ -3252,7 +3565,7 @@ async function pollOnce2(client, request, since, signal) {
3252
3565
  signal?.removeEventListener("abort", onAbort);
3253
3566
  }
3254
3567
  }
3255
- chunkMWMSFIWN_cjs.__name(pollOnce2, "pollOnce");
3568
+ chunkL6DXCKVQ_cjs.__name(pollOnce2, "pollOnce");
3256
3569
  function refusedPoll(response, body, context) {
3257
3570
  const headers = {};
3258
3571
  response.headers.forEach((value, name) => {
@@ -3263,13 +3576,13 @@ function refusedPoll(response, body, context) {
3263
3576
  { ...context, method: "GET" }
3264
3577
  );
3265
3578
  const refusal = readError(body);
3266
- if (refusal === void 0 || !hasOwn(chunk7BZW6XYJ_cjs.VISITOR_POLL_RETRY, refusal.code)) return mapped;
3579
+ if (refusal === void 0 || !hasOwn(chunkSHSK7UUY_cjs.VISITOR_POLL_RETRY, refusal.code)) return mapped;
3267
3580
  const code = refusal.code;
3268
3581
  const retryAfterMs = parseRetryAfterMs(headerValue(headers, "Retry-After"), Date.now());
3269
3582
  return new LiveEdgeError(
3270
3583
  `The live edge refused a poll (${code}): ${refusal.messages[0] ?? mapped.message}`,
3271
3584
  { kind: "refused", code },
3272
- chunk7BZW6XYJ_cjs.VISITOR_POLL_RETRY[code],
3585
+ chunkSHSK7UUY_cjs.VISITOR_POLL_RETRY[code],
3273
3586
  {
3274
3587
  statusCode: response.status,
3275
3588
  cause: mapped,
@@ -3278,7 +3591,7 @@ function refusedPoll(response, body, context) {
3278
3591
  }
3279
3592
  );
3280
3593
  }
3281
- chunkMWMSFIWN_cjs.__name(refusedPoll, "refusedPoll");
3594
+ chunkL6DXCKVQ_cjs.__name(refusedPoll, "refusedPoll");
3282
3595
  function edgeRequest(client, filter) {
3283
3596
  const key = client.apiKey;
3284
3597
  if (key === void 0 || !isPublishableKey(key)) {
@@ -3294,24 +3607,24 @@ function edgeRequest(client, filter) {
3294
3607
  ids: filter.ids
3295
3608
  };
3296
3609
  }
3297
- chunkMWMSFIWN_cjs.__name(edgeRequest, "edgeRequest");
3610
+ chunkL6DXCKVQ_cjs.__name(edgeRequest, "edgeRequest");
3298
3611
  function edgeUrl(request, since, transport, clientId) {
3299
3612
  const url = new URL(request.base.href);
3300
- url.pathname = `${url.pathname.replace(/\/+$/, "")}${chunk7BZW6XYJ_cjs.VISITOR_LIVE_PATH}`;
3613
+ url.pathname = `${url.pathname.replace(/\/+$/, "")}${chunkSHSK7UUY_cjs.VISITOR_LIVE_PATH}`;
3301
3614
  if (transport === "socket") url.protocol = url.protocol === "http:" ? "ws:" : "wss:";
3302
3615
  const query = new URLSearchParams();
3303
- if (request.key !== void 0) query.set(chunk7BZW6XYJ_cjs.VISITOR_QUERY.key, request.key);
3616
+ if (request.key !== void 0) query.set(chunkSHSK7UUY_cjs.VISITOR_QUERY.key, request.key);
3304
3617
  if (request.dataset !== void 0 && request.dataset !== "") {
3305
- query.set(chunk7BZW6XYJ_cjs.VISITOR_QUERY.dataset, request.dataset);
3618
+ query.set(chunkSHSK7UUY_cjs.VISITOR_QUERY.dataset, request.dataset);
3306
3619
  }
3307
- if (since !== void 0) query.set(chunk7BZW6XYJ_cjs.VISITOR_QUERY.since, since);
3308
- if (request.types !== void 0) query.set(chunk7BZW6XYJ_cjs.VISITOR_QUERY.types, request.types.join(","));
3309
- if (request.ids !== void 0) query.set(chunk7BZW6XYJ_cjs.VISITOR_QUERY.ids, request.ids.join(","));
3310
- if (transport === "poll" && clientId !== void 0) query.set(chunk7BZW6XYJ_cjs.VISITOR_QUERY.client, clientId);
3620
+ if (since !== void 0) query.set(chunkSHSK7UUY_cjs.VISITOR_QUERY.since, since);
3621
+ if (request.types !== void 0) query.set(chunkSHSK7UUY_cjs.VISITOR_QUERY.types, request.types.join(","));
3622
+ if (request.ids !== void 0) query.set(chunkSHSK7UUY_cjs.VISITOR_QUERY.ids, request.ids.join(","));
3623
+ if (transport === "poll" && clientId !== void 0) query.set(chunkSHSK7UUY_cjs.VISITOR_QUERY.client, clientId);
3311
3624
  url.search = query.toString();
3312
3625
  return url.href;
3313
3626
  }
3314
- chunkMWMSFIWN_cjs.__name(edgeUrl, "edgeUrl");
3627
+ chunkL6DXCKVQ_cjs.__name(edgeUrl, "edgeUrl");
3315
3628
  function changesOf(changes, cursor, prior) {
3316
3629
  const last = changes.length - 1;
3317
3630
  return changes.map((change, index) => ({
@@ -3323,14 +3636,14 @@ function changesOf(changes, cursor, prior) {
3323
3636
  fresh: cursor
3324
3637
  }));
3325
3638
  }
3326
- chunkMWMSFIWN_cjs.__name(changesOf, "changesOf");
3639
+ chunkL6DXCKVQ_cjs.__name(changesOf, "changesOf");
3327
3640
  async function expire(reason, cursor, options) {
3328
3641
  const expired = ChangesExpiredError.resync(reason, cursor);
3329
3642
  const onExpired = options.onExpired ?? "throw";
3330
3643
  if (onExpired === "throw") throw expired;
3331
3644
  if (typeof onExpired === "function") await onExpired(expired);
3332
3645
  }
3333
- chunkMWMSFIWN_cjs.__name(expire, "expire");
3646
+ chunkL6DXCKVQ_cjs.__name(expire, "expire");
3334
3647
  function unreadable(what) {
3335
3648
  return new LiveEdgeError(
3336
3649
  `The live edge sent ${what}. This version of the SDK cannot follow it, so it stopped.`,
@@ -3338,13 +3651,13 @@ function unreadable(what) {
3338
3651
  "stop"
3339
3652
  );
3340
3653
  }
3341
- chunkMWMSFIWN_cjs.__name(unreadable, "unreadable");
3654
+ chunkL6DXCKVQ_cjs.__name(unreadable, "unreadable");
3342
3655
  var NEEDS_PUBLISHABLE_KEY = `Live updates at RelyIO\u2019s edge need a publishable key (\`${PUBLISHABLE_KEY_PREFIX}\u2026\`), and this client holds none. A secret or preview key is never sent to the edge; on a server, follow \`changes()\` with it instead. Nothing was sent.`;
3343
3656
  function sample(value) {
3344
3657
  const text = typeof value === "string" ? value : `(${typeof value})`;
3345
3658
  return text.length > 200 ? `${text.slice(0, 200)}\u2026` : text;
3346
3659
  }
3347
- chunkMWMSFIWN_cjs.__name(sample, "sample");
3660
+ chunkL6DXCKVQ_cjs.__name(sample, "sample");
3348
3661
  function parseJson(text) {
3349
3662
  try {
3350
3663
  return JSON.parse(text);
@@ -3352,15 +3665,41 @@ function parseJson(text) {
3352
3665
  return void 0;
3353
3666
  }
3354
3667
  }
3355
- chunkMWMSFIWN_cjs.__name(parseJson, "parseJson");
3668
+ chunkL6DXCKVQ_cjs.__name(parseJson, "parseJson");
3356
3669
  function isRecord(value) {
3357
3670
  return typeof value === "object" && value !== null && !Array.isArray(value);
3358
3671
  }
3359
- chunkMWMSFIWN_cjs.__name(isRecord, "isRecord");
3672
+ chunkL6DXCKVQ_cjs.__name(isRecord, "isRecord");
3360
3673
  function hasOwn(object, key) {
3361
3674
  return Object.prototype.hasOwnProperty.call(object, key);
3362
3675
  }
3363
- chunkMWMSFIWN_cjs.__name(hasOwn, "hasOwn");
3676
+ chunkL6DXCKVQ_cjs.__name(hasOwn, "hasOwn");
3677
+
3678
+ // src/content/functions-client.ts
3679
+ var FUNCTION_CALL_TIMEOUT_MS = 31e4;
3680
+ async function callFunction(http, name, input, options) {
3681
+ return await http.fetchPayload("/v1/functions/{name}", "post", {
3682
+ path: { name },
3683
+ body: { input },
3684
+ headers: {
3685
+ ...readHeaders({ dataset: options.dataset }),
3686
+ ...options.idempotencyKey === void 0 ? {} : { [chunkSHSK7UUY_cjs.HEADER_IDEMPOTENCY_KEY.name]: options.idempotencyKey }
3687
+ },
3688
+ timeout: options.timeout ?? FUNCTION_CALL_TIMEOUT_MS,
3689
+ ...signalOf(options)
3690
+ });
3691
+ }
3692
+ chunkL6DXCKVQ_cjs.__name(callFunction, "callFunction");
3693
+ function functionsAccessor(http) {
3694
+ return new Proxy({}, {
3695
+ get: /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name((_target, property) => {
3696
+ if (typeof property !== "string" || property === "then") return void 0;
3697
+ const call = /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name((input = {}, options = {}) => callFunction(http(), property, input, options), "call");
3698
+ return call;
3699
+ }, "get")
3700
+ });
3701
+ }
3702
+ chunkL6DXCKVQ_cjs.__name(functionsAccessor, "functionsAccessor");
3364
3703
 
3365
3704
  // src/search/search-options.ts
3366
3705
  function scopeOf(contentType) {
@@ -3368,36 +3707,36 @@ function scopeOf(contentType) {
3368
3707
  if (typeof contentType === "string") return { contentType };
3369
3708
  return { contentTypes: [...contentType] };
3370
3709
  }
3371
- chunkMWMSFIWN_cjs.__name(scopeOf, "scopeOf");
3710
+ chunkL6DXCKVQ_cjs.__name(scopeOf, "scopeOf");
3372
3711
  function selectedFields(select) {
3373
3712
  if (select === void 0 || select.length === 0) return {};
3374
3713
  return { fields: Object.fromEntries(select.map((field) => [field, field])) };
3375
3714
  }
3376
- chunkMWMSFIWN_cjs.__name(selectedFields, "selectedFields");
3715
+ chunkL6DXCKVQ_cjs.__name(selectedFields, "selectedFields");
3377
3716
  function localeOf(own, client) {
3378
3717
  const locale = own ?? client;
3379
3718
  return locale === void 0 || locale === "" ? {} : { locale };
3380
3719
  }
3381
- chunkMWMSFIWN_cjs.__name(localeOf, "localeOf");
3720
+ chunkL6DXCKVQ_cjs.__name(localeOf, "localeOf");
3382
3721
  function whereOf(where) {
3383
3722
  if (where === void 0) return {};
3384
3723
  refuseMetadataConditions(where);
3385
3724
  return Object.keys(where).length === 0 ? {} : { where };
3386
3725
  }
3387
- chunkMWMSFIWN_cjs.__name(whereOf, "whereOf");
3726
+ chunkL6DXCKVQ_cjs.__name(whereOf, "whereOf");
3388
3727
  function given(options) {
3389
3728
  return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== void 0));
3390
3729
  }
3391
- chunkMWMSFIWN_cjs.__name(given, "given");
3730
+ chunkL6DXCKVQ_cjs.__name(given, "given");
3392
3731
  function transportOf(options) {
3393
3732
  const headers = readHeaders(options);
3394
3733
  return {
3395
3734
  ...signalOf(options),
3396
3735
  ...headers === void 0 ? {} : { headers },
3397
- ...typeof options.fresh === "string" ? { query: { [chunk7BZW6XYJ_cjs.FRESH_PARAMETER]: options.fresh } } : {}
3736
+ ...typeof options.fresh === "string" ? { query: { [chunkSHSK7UUY_cjs.FRESH_PARAMETER]: options.fresh } } : {}
3398
3737
  };
3399
3738
  }
3400
- chunkMWMSFIWN_cjs.__name(transportOf, "transportOf");
3739
+ chunkL6DXCKVQ_cjs.__name(transportOf, "transportOf");
3401
3740
  async function runSearch(http, q, options, clientLocale) {
3402
3741
  const sort = options.sort === void 0 ? [] : Object.entries(options.sort).flatMap(
3403
3742
  ([field, direction]) => direction === void 0 ? [] : [{ field, direction }]
@@ -3431,7 +3770,7 @@ async function runSearch(http, q, options, clientLocale) {
3431
3770
  );
3432
3771
  return response.body;
3433
3772
  }
3434
- chunkMWMSFIWN_cjs.__name(runSearch, "runSearch");
3773
+ chunkL6DXCKVQ_cjs.__name(runSearch, "runSearch");
3435
3774
  async function runAutocomplete(http, q, options, clientLocale) {
3436
3775
  const body = {
3437
3776
  q,
@@ -3449,7 +3788,7 @@ async function runAutocomplete(http, q, options, clientLocale) {
3449
3788
  );
3450
3789
  return response.body;
3451
3790
  }
3452
- chunkMWMSFIWN_cjs.__name(runAutocomplete, "runAutocomplete");
3791
+ chunkL6DXCKVQ_cjs.__name(runAutocomplete, "runAutocomplete");
3453
3792
  async function runSimilar(http, source, options, clientLocale) {
3454
3793
  const body = {
3455
3794
  source,
@@ -3465,7 +3804,7 @@ async function runSimilar(http, source, options, clientLocale) {
3465
3804
  );
3466
3805
  return response.body;
3467
3806
  }
3468
- chunkMWMSFIWN_cjs.__name(runSimilar, "runSimilar");
3807
+ chunkL6DXCKVQ_cjs.__name(runSimilar, "runSimilar");
3469
3808
 
3470
3809
  // src/batch/batch-operations.ts
3471
3810
  var VERBS = ["create", "update", "replace", "delete", "singleton"];
@@ -3488,7 +3827,7 @@ async function runBatch(http, operations, options, clientLocale) {
3488
3827
  });
3489
3828
  return response.body;
3490
3829
  }
3491
- chunkMWMSFIWN_cjs.__name(runBatch, "runBatch");
3830
+ chunkL6DXCKVQ_cjs.__name(runBatch, "runBatch");
3492
3831
  function operationOf(operation, index, clientLocale) {
3493
3832
  const named = VERBS.filter((verb2) => operation[verb2] !== void 0);
3494
3833
  const verb = named[0];
@@ -3504,7 +3843,7 @@ function operationOf(operation, index, clientLocale) {
3504
3843
  ...parentId === void 0 ? {} : { parentId },
3505
3844
  ...sortOrder === void 0 ? {} : { sortOrder }
3506
3845
  };
3507
- const located = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((locale) => locale === void 0 ? {} : { locale }, "located");
3846
+ const located = /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name((locale) => locale === void 0 ? {} : { locale }, "located");
3508
3847
  switch (verb) {
3509
3848
  case "create": {
3510
3849
  return {
@@ -3544,7 +3883,7 @@ function operationOf(operation, index, clientLocale) {
3544
3883
  }
3545
3884
  }
3546
3885
  }
3547
- chunkMWMSFIWN_cjs.__name(operationOf, "operationOf");
3886
+ chunkL6DXCKVQ_cjs.__name(operationOf, "operationOf");
3548
3887
  function targetOf(operation, clientLocale) {
3549
3888
  if (operation.entry !== void 0) return versionCheckOf(operation.entry);
3550
3889
  if (operation.id === void 0) {
@@ -3555,7 +3894,7 @@ function targetOf(operation, clientLocale) {
3555
3894
  const locale = callLocale(operation.locale, clientLocale);
3556
3895
  return { id: operation.id, ...locale === void 0 ? {} : { locale } };
3557
3896
  }
3558
- chunkMWMSFIWN_cjs.__name(targetOf, "targetOf");
3897
+ chunkL6DXCKVQ_cjs.__name(targetOf, "targetOf");
3559
3898
 
3560
3899
  // src/queries/query-call.ts
3561
3900
  async function runAdhocQuery(http, query, clientLocale) {
@@ -3575,7 +3914,7 @@ async function runAdhocQuery(http, query, clientLocale) {
3575
3914
  const terms = {};
3576
3915
  if (query.cursor !== void 0) terms.cursor = query.cursor;
3577
3916
  writeLocale(terms, query.locale ?? clientLocale);
3578
- if (typeof query.fresh === "string") terms[chunk7BZW6XYJ_cjs.FRESH_PARAMETER] = query.fresh;
3917
+ if (typeof query.fresh === "string") terms[chunkSHSK7UUY_cjs.FRESH_PARAMETER] = query.fresh;
3579
3918
  const parameters = { ...query.params };
3580
3919
  const body = {
3581
3920
  query: {
@@ -3595,7 +3934,7 @@ async function runAdhocQuery(http, query, clientLocale) {
3595
3934
  });
3596
3935
  return response.body;
3597
3936
  }
3598
- chunkMWMSFIWN_cjs.__name(runAdhocQuery, "runAdhocQuery");
3937
+ chunkL6DXCKVQ_cjs.__name(runAdhocQuery, "runAdhocQuery");
3599
3938
  function offsetOf(page, limit) {
3600
3939
  if (limit === void 0 || !Number.isInteger(page) || page < 1) {
3601
3940
  throw new ValidationError(
@@ -3605,12 +3944,12 @@ function offsetOf(page, limit) {
3605
3944
  }
3606
3945
  return (page - 1) * limit;
3607
3946
  }
3608
- chunkMWMSFIWN_cjs.__name(offsetOf, "offsetOf");
3947
+ chunkL6DXCKVQ_cjs.__name(offsetOf, "offsetOf");
3609
3948
  async function runNamedQuery(http, name, options, clientLocale) {
3610
3949
  const locale = options.locale ?? clientLocale;
3611
3950
  const terms = {};
3612
3951
  if (locale !== void 0 && locale !== "") terms.locale = locale;
3613
- if (typeof options.fresh === "string") terms[chunk7BZW6XYJ_cjs.FRESH_PARAMETER] = options.fresh;
3952
+ if (typeof options.fresh === "string") terms[chunkSHSK7UUY_cjs.FRESH_PARAMETER] = options.fresh;
3614
3953
  const headers = readHeaders(options);
3615
3954
  const response = await http.send(
3616
3955
  "/v1/queries/{name}",
@@ -3625,17 +3964,17 @@ async function runNamedQuery(http, name, options, clientLocale) {
3625
3964
  );
3626
3965
  return response.body;
3627
3966
  }
3628
- chunkMWMSFIWN_cjs.__name(runNamedQuery, "runNamedQuery");
3967
+ chunkL6DXCKVQ_cjs.__name(runNamedQuery, "runNamedQuery");
3629
3968
 
3630
3969
  // src/config/dev-detection.ts
3631
3970
  function sandboxStateOf(resolution) {
3632
3971
  return resolution.state === "active" ? resolution.sandbox : resolution;
3633
3972
  }
3634
- chunkMWMSFIWN_cjs.__name(sandboxStateOf, "sandboxStateOf");
3973
+ chunkL6DXCKVQ_cjs.__name(sandboxStateOf, "sandboxStateOf");
3635
3974
  function getProcess() {
3636
3975
  return typeof process !== "undefined" ? process : void 0;
3637
3976
  }
3638
- chunkMWMSFIWN_cjs.__name(getProcess, "getProcess");
3977
+ chunkL6DXCKVQ_cjs.__name(getProcess, "getProcess");
3639
3978
  function getBuiltin(proc, id) {
3640
3979
  if (proc == null || typeof proc.getBuiltinModule !== "function") return null;
3641
3980
  try {
@@ -3644,13 +3983,13 @@ function getBuiltin(proc, id) {
3644
3983
  return null;
3645
3984
  }
3646
3985
  }
3647
- chunkMWMSFIWN_cjs.__name(getBuiltin, "getBuiltin");
3986
+ chunkL6DXCKVQ_cjs.__name(getBuiltin, "getBuiltin");
3648
3987
  function isProduction(proc) {
3649
3988
  return proc?.env?.NODE_ENV === "production";
3650
3989
  }
3651
- chunkMWMSFIWN_cjs.__name(isProduction, "isProduction");
3990
+ chunkL6DXCKVQ_cjs.__name(isProduction, "isProduction");
3652
3991
  function resolveFromEnv(proc, now) {
3653
- const verdict = chunkLSRPMNPT_cjs.parseDevEnv(proc?.env, now);
3992
+ const verdict = chunkZO6QDYJG_cjs.parseDevEnv(proc?.env, now);
3654
3993
  switch (verdict.state) {
3655
3994
  case "active":
3656
3995
  return {
@@ -3672,7 +4011,7 @@ function resolveFromEnv(proc, now) {
3672
4011
  return { state: "absent" };
3673
4012
  }
3674
4013
  }
3675
- chunkMWMSFIWN_cjs.__name(resolveFromEnv, "resolveFromEnv");
4014
+ chunkL6DXCKVQ_cjs.__name(resolveFromEnv, "resolveFromEnv");
3676
4015
  function resolveFromFile(proc, now) {
3677
4016
  if (proc == null || typeof proc.cwd !== "function") return { state: "absent" };
3678
4017
  const fs = getBuiltin(proc, "node:fs");
@@ -3680,7 +4019,7 @@ function resolveFromFile(proc, now) {
3680
4019
  if (fs == null || path == null) return { state: "absent" };
3681
4020
  let dir = proc.cwd();
3682
4021
  for (; ; ) {
3683
- const candidate = path.join(dir, chunkLSRPMNPT_cjs.DEV_CONTEXT_DIR, chunkLSRPMNPT_cjs.DEV_CONTEXT_FILENAME);
4022
+ const candidate = path.join(dir, chunkZO6QDYJG_cjs.DEV_CONTEXT_DIR, chunkZO6QDYJG_cjs.DEV_CONTEXT_FILENAME);
3684
4023
  let raw = null;
3685
4024
  try {
3686
4025
  if (fs.existsSync(candidate)) raw = fs.readFileSync(candidate, "utf8");
@@ -3688,7 +4027,7 @@ function resolveFromFile(proc, now) {
3688
4027
  return { state: "absent" };
3689
4028
  }
3690
4029
  if (raw !== null) {
3691
- const verdict = chunkLSRPMNPT_cjs.parseDevContextFile(raw, now);
4030
+ const verdict = chunkZO6QDYJG_cjs.parseDevContextFile(raw, now);
3692
4031
  switch (verdict.state) {
3693
4032
  case "active":
3694
4033
  return {
@@ -3716,7 +4055,7 @@ function resolveFromFile(proc, now) {
3716
4055
  }
3717
4056
  return { state: "absent" };
3718
4057
  }
3719
- chunkMWMSFIWN_cjs.__name(resolveFromFile, "resolveFromFile");
4058
+ chunkL6DXCKVQ_cjs.__name(resolveFromFile, "resolveFromFile");
3720
4059
  function resolveDevOverride(dev) {
3721
4060
  if (dev === false) return { state: "disabled" };
3722
4061
  const proc = getProcess();
@@ -3726,18 +4065,18 @@ function resolveDevOverride(dev) {
3726
4065
  if (fromEnv.state !== "absent") return fromEnv;
3727
4066
  return resolveFromFile(proc, now);
3728
4067
  }
3729
- chunkMWMSFIWN_cjs.__name(resolveDevOverride, "resolveDevOverride");
4068
+ chunkL6DXCKVQ_cjs.__name(resolveDevOverride, "resolveDevOverride");
3730
4069
 
3731
4070
  // src/config/preview-environment.ts
3732
4071
  function readPreviewAtRequest() {
3733
4072
  const env = typeof process === "undefined" ? void 0 : process.env;
3734
- return chunk7BZW6XYJ_cjs.previewAtRequest(isEnvironment(env) ? env : {});
4073
+ return chunk7I3SC7SV_cjs.previewAtRequest(isEnvironment(env) ? env : {});
3735
4074
  }
3736
- chunkMWMSFIWN_cjs.__name(readPreviewAtRequest, "readPreviewAtRequest");
4075
+ chunkL6DXCKVQ_cjs.__name(readPreviewAtRequest, "readPreviewAtRequest");
3737
4076
  function isEnvironment(value) {
3738
4077
  return typeof value === "object" && value !== null;
3739
4078
  }
3740
- chunkMWMSFIWN_cjs.__name(isEnvironment, "isEnvironment");
4079
+ chunkL6DXCKVQ_cjs.__name(isEnvironment, "isEnvironment");
3741
4080
 
3742
4081
  // src/config/types.ts
3743
4082
  var DEFAULT_CONFIG = {
@@ -3787,27 +4126,27 @@ function validateConfig(config) {
3787
4126
  );
3788
4127
  }
3789
4128
  }
3790
- chunkMWMSFIWN_cjs.__name(validateConfig, "validateConfig");
4129
+ chunkL6DXCKVQ_cjs.__name(validateConfig, "validateConfig");
3791
4130
  var devOverrideNotified = false;
3792
4131
  function resolveConfig(userConfig) {
3793
4132
  validateConfig(userConfig);
3794
4133
  return withHandshake(withDefaults(DEFAULT_CONFIG, userConfig, DEFAULT_CONFIG));
3795
4134
  }
3796
- chunkMWMSFIWN_cjs.__name(resolveConfig, "resolveConfig");
4135
+ chunkL6DXCKVQ_cjs.__name(resolveConfig, "resolveConfig");
3797
4136
  function resolveConfigUpdate(configured, update) {
3798
4137
  validateConfig(update);
3799
4138
  const base = update.apiKey === void 0 ? configured : withoutKeyHeader(configured);
3800
4139
  return withHandshake(withDefaults(base, update, DEFAULT_CONFIG));
3801
4140
  }
3802
- chunkMWMSFIWN_cjs.__name(resolveConfigUpdate, "resolveConfigUpdate");
4141
+ chunkL6DXCKVQ_cjs.__name(resolveConfigUpdate, "resolveConfigUpdate");
3803
4142
  function withConfiguredKey(configured, apiKey) {
3804
4143
  return { ...withoutKeyHeader(configured), apiKey };
3805
4144
  }
3806
- chunkMWMSFIWN_cjs.__name(withConfiguredKey, "withConfiguredKey");
4145
+ chunkL6DXCKVQ_cjs.__name(withConfiguredKey, "withConfiguredKey");
3807
4146
  function withoutKeyHeader(configured) {
3808
4147
  return { ...configured, headers: layerHeaders(configured.headers, { [API_KEY_HEADER]: null }) };
3809
4148
  }
3810
- chunkMWMSFIWN_cjs.__name(withoutKeyHeader, "withoutKeyHeader");
4149
+ chunkL6DXCKVQ_cjs.__name(withoutKeyHeader, "withoutKeyHeader");
3811
4150
  function withHandshake(configured) {
3812
4151
  const dev = resolveDevOverride(configured.dev);
3813
4152
  const merged = withDefaults(
@@ -3835,13 +4174,13 @@ function withHandshake(configured) {
3835
4174
  }
3836
4175
  return { config: merged, sandbox: sandboxStateOf(dev), configured };
3837
4176
  }
3838
- chunkMWMSFIWN_cjs.__name(withHandshake, "withHandshake");
4177
+ chunkL6DXCKVQ_cjs.__name(withHandshake, "withHandshake");
3839
4178
  var previewNotified = false;
3840
4179
  function withPreview(configured) {
3841
4180
  if (configured.dataset !== void 0 || !isPreviewKey(configured.apiKey)) return configured;
3842
4181
  const preview = readPreviewAtRequest();
3843
4182
  if (preview.state !== "preview") return configured;
3844
- const dataset = chunk7BZW6XYJ_cjs.previewDatasetSlug(preview.branch);
4183
+ const dataset = chunkSHSK7UUY_cjs.previewDatasetSlug(preview.branch);
3845
4184
  noteDerivedPreview(dataset);
3846
4185
  if (!previewNotified) {
3847
4186
  previewNotified = true;
@@ -3851,7 +4190,7 @@ function withPreview(configured) {
3851
4190
  }
3852
4191
  return { ...configured, dataset };
3853
4192
  }
3854
- chunkMWMSFIWN_cjs.__name(withPreview, "withPreview");
4193
+ chunkL6DXCKVQ_cjs.__name(withPreview, "withPreview");
3855
4194
  function withDefaults(base, given2, defaults) {
3856
4195
  const merged = new Map(Object.entries(base));
3857
4196
  const givenValues = new Map(Object.entries(given2 ?? {}));
@@ -3874,11 +4213,11 @@ function withDefaults(base, given2, defaults) {
3874
4213
  }
3875
4214
  return Object.fromEntries(merged);
3876
4215
  }
3877
- chunkMWMSFIWN_cjs.__name(withDefaults, "withDefaults");
4216
+ chunkL6DXCKVQ_cjs.__name(withDefaults, "withDefaults");
3878
4217
  function isOptionBag(value) {
3879
4218
  return typeof value === "object" && value !== null && !Array.isArray(value);
3880
4219
  }
3881
- chunkMWMSFIWN_cjs.__name(isOptionBag, "isOptionBag");
4220
+ chunkL6DXCKVQ_cjs.__name(isOptionBag, "isOptionBag");
3882
4221
 
3883
4222
  // src/client/create-client.ts
3884
4223
  var _TypedRelyIOClient = class _TypedRelyIOClient {
@@ -3887,31 +4226,73 @@ var _TypedRelyIOClient = class _TypedRelyIOClient {
3887
4226
  * The one HTTP client every sub-client sends through. `updateConfig()` and `setApiKey()` change it
3888
4227
  * in place rather than replacing it, so a sub-client taken before either sends through the change.
3889
4228
  */
3890
- chunkMWMSFIWN_cjs.__publicField(this, "httpClient");
3891
- chunkMWMSFIWN_cjs.__publicField(this, "config");
4229
+ chunkL6DXCKVQ_cjs.__publicField(this, "httpClient");
4230
+ chunkL6DXCKVQ_cjs.__publicField(this, "config");
3892
4231
  /**
3893
4232
  * The configuration as `createClient()`, `setApiKey()` and `updateConfig()` gave it, before the
3894
4233
  * `relyio dev` handshake: what the next update is laid over, and what `with()` starts from.
3895
4234
  */
3896
- chunkMWMSFIWN_cjs.__publicField(this, "configured");
3897
- chunkMWMSFIWN_cjs.__publicField(this, "_sandbox");
3898
- chunkMWMSFIWN_cjs.__publicField(this, "_schema");
4235
+ chunkL6DXCKVQ_cjs.__publicField(this, "configured");
4236
+ chunkL6DXCKVQ_cjs.__publicField(this, "_sandbox");
4237
+ chunkL6DXCKVQ_cjs.__publicField(this, "_schema");
3899
4238
  /**
3900
4239
  * The client's locale as it is when a call is made. Every sub-client and builder is handed this
3901
4240
  * rather than a copy of the locale, so one taken before `updateConfig({ locale })` sends the new
3902
4241
  * locale, or none after `locale: null` (REL-1453).
3903
4242
  */
3904
- chunkMWMSFIWN_cjs.__publicField(this, "currentLocale", /* @__PURE__ */ chunkMWMSFIWN_cjs.__name(() => this.defaults.locale ?? (this.parent === void 0 ? this.config.locale : this.parent.currentLocale()), "currentLocale"));
4243
+ chunkL6DXCKVQ_cjs.__publicField(this, "currentLocale", /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name(() => this.defaults.locale ?? (this.parent === void 0 ? this.config.locale : this.parent.currentLocale()), "currentLocale"));
3905
4244
  /**
3906
4245
  * The client `with()` was called on, for a client it made: whose key, base URL and configuration
3907
4246
  * this one reads with as they are when each request is sent. `undefined` for a client
3908
4247
  * `createClient()` made, which reads its own.
3909
4248
  */
3910
- chunkMWMSFIWN_cjs.__publicField(this, "parent");
4249
+ chunkL6DXCKVQ_cjs.__publicField(this, "parent");
3911
4250
  /** What `with()` gave this client over its parent's: the locale and dataset it names, and no other. */
3912
- chunkMWMSFIWN_cjs.__publicField(this, "defaults", {});
4251
+ chunkL6DXCKVQ_cjs.__publicField(this, "defaults", {});
3913
4252
  /** The live edge's poll client id: chosen once, when first needed, and kept for this client's life. */
3914
- chunkMWMSFIWN_cjs.__publicField(this, "_liveClientId");
4253
+ chunkL6DXCKVQ_cjs.__publicField(this, "_liveClientId");
4254
+ /**
4255
+ * The Records of one Record type (spec 1, REL-3771): `create`, `list`, `get`, `update`, `delete`.
4256
+ * Type-safe when a schema is provided — the names autocomplete its `recordTypes` and the fields
4257
+ * are the type's. `relyio.records.batch([...])` writes Records of any types in one transaction,
4258
+ * all or none (REL-3774).
4259
+ *
4260
+ * A Record is an app's data, written by your server with a secret key and live the moment it
4261
+ * lands; a publishable key is refused on every Record route (`PUBLISHABLE_KEY_REFUSED`).
4262
+ *
4263
+ * @example
4264
+ * ```typescript
4265
+ * const order = await relyio.records('order').create({ shopperEmail: 'ada@example.com', total: 19 })
4266
+ * const { data: orders } = await relyio.records('order').list({ where: { status: 'paid' } })
4267
+ * await relyio.records.batch([
4268
+ * { op: 'decrement', type: 'inventory', where: { product: mugId }, field: 'available', by: 1 },
4269
+ * { op: 'create', type: 'order', fields: { shopperEmail: 'ada@example.com', total: 19 } },
4270
+ * ])
4271
+ * ```
4272
+ */
4273
+ chunkL6DXCKVQ_cjs.__publicField(this, "records", Object.assign(
4274
+ (recordType) => new RecordsClient(this.httpClient, recordType),
4275
+ {
4276
+ // Read when called, never when made: `with()` and `updateConfig()` move `httpClient`
4277
+ batch: /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name((operations, options) => sendRecordBatch(this.httpClient, operations, options), "batch")
4278
+ }
4279
+ // The one function both call signatures describe; the cast restates the schema's typing of its
4280
+ // argument and answer, as `content()` does, and widens nothing it is called with.
4281
+ ));
4282
+ /**
4283
+ * The project's Functions, by name (spec 2, REL-3821): `relyio.functions.checkout({ cartId })`
4284
+ * runs the Function `checkout` that the key's Branch runs, on the key's Dataset, and answers its
4285
+ * output. Call it from your server with a secret key; a run that failed throws
4286
+ * `FunctionRunFailedError` and one past five minutes `FunctionRunTimedOutError`, each naming the
4287
+ * run. Never retried: a Function may write.
4288
+ *
4289
+ * @example
4290
+ * ```typescript
4291
+ * const { orderId } = (await relyio.functions.checkout({ cartId })) as { orderId: string }
4292
+ * ```
4293
+ */
4294
+ // Read when called, never when made: `with()` and `updateConfig()` move `httpClient`
4295
+ chunkL6DXCKVQ_cjs.__publicField(this, "functions", functionsAccessor(() => this.httpClient));
3915
4296
  const { schema, ...clientConfig } = config;
3916
4297
  this._schema = schema;
3917
4298
  const resolved = resolveConfig(clientConfig);
@@ -3955,7 +4336,7 @@ var _TypedRelyIOClient = class _TypedRelyIOClient {
3955
4336
  * its own.
3956
4337
  */
3957
4338
  get query() {
3958
- const call = /* @__PURE__ */ chunkMWMSFIWN_cjs.__name((target, options = {}) => typeof target === "string" ? runNamedQuery(this.httpClient, target, options, this.currentLocale()) : runAdhocQuery(this.httpClient, target, this.currentLocale()), "call");
4339
+ const call = /* @__PURE__ */ chunkL6DXCKVQ_cjs.__name((target, options = {}) => typeof target === "string" ? runNamedQuery(this.httpClient, target, options, this.currentLocale()) : runAdhocQuery(this.httpClient, target, this.currentLocale()), "call");
3959
4340
  return call;
3960
4341
  }
3961
4342
  // ============================================================================
@@ -4412,12 +4793,12 @@ var _TypedRelyIOClient = class _TypedRelyIOClient {
4412
4793
  return locales.map((locale) => ({ ...locale, default: locale.code === defaultLocale }));
4413
4794
  }
4414
4795
  };
4415
- chunkMWMSFIWN_cjs.__name(_TypedRelyIOClient, "TypedRelyIOClient");
4796
+ chunkL6DXCKVQ_cjs.__name(_TypedRelyIOClient, "TypedRelyIOClient");
4416
4797
  var TypedRelyIOClient = _TypedRelyIOClient;
4417
4798
  function createClient(config) {
4418
4799
  return new TypedRelyIOClient(config);
4419
4800
  }
4420
- chunkMWMSFIWN_cjs.__name(createClient, "createClient");
4801
+ chunkL6DXCKVQ_cjs.__name(createClient, "createClient");
4421
4802
  function randomClientId() {
4422
4803
  const bytes = new Uint8Array(16);
4423
4804
  const random = globalThis.crypto;
@@ -4430,7 +4811,7 @@ function randomClientId() {
4430
4811
  }
4431
4812
  return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
4432
4813
  }
4433
- chunkMWMSFIWN_cjs.__name(randomClientId, "randomClientId");
4814
+ chunkL6DXCKVQ_cjs.__name(randomClientId, "randomClientId");
4434
4815
 
4435
4816
  exports.AssetClient = AssetClient;
4436
4817
  exports.AssetFileBuilder = AssetFileBuilder;
@@ -4444,6 +4825,9 @@ exports.DefaultRetryPolicy = DefaultRetryPolicy;
4444
4825
  exports.ErrorMapper = ErrorMapper;
4445
4826
  exports.FileUploadError = FileUploadError;
4446
4827
  exports.FileValidationError = FileValidationError;
4828
+ exports.FunctionContainersBusyError = FunctionContainersBusyError;
4829
+ exports.FunctionRunFailedError = FunctionRunFailedError;
4830
+ exports.FunctionRunTimedOutError = FunctionRunTimedOutError;
4447
4831
  exports.HttpClient = HttpClient;
4448
4832
  exports.InvalidApiKeyError = InvalidApiKeyError;
4449
4833
  exports.InvalidPayloadError = InvalidPayloadError;
@@ -4457,8 +4841,10 @@ exports.PREVIEW_KEY_PREFIX = PREVIEW_KEY_PREFIX;
4457
4841
  exports.PUBLISHABLE_KEY_PREFIX = PUBLISHABLE_KEY_PREFIX;
4458
4842
  exports.PayloadTooLargeError = PayloadTooLargeError;
4459
4843
  exports.PlanFeatureUnavailableError = PlanFeatureUnavailableError;
4844
+ exports.PublishableKeyRefusedError = PublishableKeyRefusedError;
4460
4845
  exports.RateLimitError = RateLimitError;
4461
4846
  exports.ReadOnlyKeyError = ReadOnlyKeyError;
4847
+ exports.RecordsClient = RecordsClient;
4462
4848
  exports.ResourceConflictError = ResourceConflictError;
4463
4849
  exports.ResourceExpiredError = ResourceExpiredError;
4464
4850
  exports.ResourceNotFoundError = ResourceNotFoundError;
@@ -4482,10 +4868,11 @@ exports.isPublishableKey = isPublishableKey;
4482
4868
  exports.isReplaySafe = isReplaySafe;
4483
4869
  exports.isResourceNotFound = isResourceNotFound;
4484
4870
  exports.matchRoute = matchRoute;
4871
+ exports.refusedOperationOf = refusedOperationOf;
4485
4872
  exports.retryPolicyFor = retryPolicyFor;
4486
4873
  exports.serviceInstructedDelayMs = serviceInstructedDelayMs;
4487
4874
  exports.sleep = sleep;
4488
4875
  exports.validateFile = validateFile;
4489
4876
  exports.versionCheckOf = versionCheckOf;
4490
- //# sourceMappingURL=chunk-RLLZUFDB.cjs.map
4491
- //# sourceMappingURL=chunk-RLLZUFDB.cjs.map
4877
+ //# sourceMappingURL=chunk-IFKF72VJ.cjs.map
4878
+ //# sourceMappingURL=chunk-IFKF72VJ.cjs.map