@oddington/sdk 0.1.85 → 0.1.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +410 -345
- package/dist/index.js +9 -9
- package/dist/types/packages/sdk/src/public.d.ts +1 -1
- package/dist/types/packages/sdk/src/query-definition-types.d.ts +3 -10
- package/dist/types/shared/routine-query-contract.d.ts +16 -3
- package/dist/types/shared/routine-query-results.d.ts +3 -10
- package/dist/types/shared/routine-webhook-contract.d.ts +26 -0
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -2098,11 +2098,11 @@ var require_luxon = /* @__PURE__ */ __commonJS({
|
|
|
2098
2098
|
static invalid(reason, explanation = null) {
|
|
2099
2099
|
if (!reason)
|
|
2100
2100
|
throw new InvalidArgumentError("need to specify a reason the Duration is invalid");
|
|
2101
|
-
let
|
|
2101
|
+
let invalid19 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|
2102
2102
|
if (Settings.throwOnInvalid)
|
|
2103
|
-
throw new InvalidDurationError(
|
|
2103
|
+
throw new InvalidDurationError(invalid19);
|
|
2104
2104
|
return new _Duration({
|
|
2105
|
-
invalid:
|
|
2105
|
+
invalid: invalid19
|
|
2106
2106
|
});
|
|
2107
2107
|
}
|
|
2108
2108
|
static normalizeUnit(unit) {
|
|
@@ -2369,11 +2369,11 @@ var require_luxon = /* @__PURE__ */ __commonJS({
|
|
|
2369
2369
|
static invalid(reason, explanation = null) {
|
|
2370
2370
|
if (!reason)
|
|
2371
2371
|
throw new InvalidArgumentError("need to specify a reason the Interval is invalid");
|
|
2372
|
-
let
|
|
2372
|
+
let invalid19 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|
2373
2373
|
if (Settings.throwOnInvalid)
|
|
2374
|
-
throw new InvalidIntervalError(
|
|
2374
|
+
throw new InvalidIntervalError(invalid19);
|
|
2375
2375
|
return new _Interval({
|
|
2376
|
-
invalid:
|
|
2376
|
+
invalid: invalid19
|
|
2377
2377
|
});
|
|
2378
2378
|
}
|
|
2379
2379
|
static fromDateTimes(start, end) {
|
|
@@ -3230,9 +3230,9 @@ var require_luxon = /* @__PURE__ */ __commonJS({
|
|
|
3230
3230
|
else {
|
|
3231
3231
|
for (let u of orderedUnits)
|
|
3232
3232
|
isUndefined(obj[u]) && (obj[u] = defaultUnitValues[u]);
|
|
3233
|
-
let
|
|
3234
|
-
if (
|
|
3235
|
-
return DateTime.invalid(
|
|
3233
|
+
let invalid19 = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj);
|
|
3234
|
+
if (invalid19)
|
|
3235
|
+
return DateTime.invalid(invalid19);
|
|
3236
3236
|
let offsetProvis = guessOffsetForZone(zone);
|
|
3237
3237
|
[ts, o] = objToTS(obj, offsetProvis, zone);
|
|
3238
3238
|
}
|
|
@@ -3260,17 +3260,17 @@ var require_luxon = /* @__PURE__ */ __commonJS({
|
|
|
3260
3260
|
}
|
|
3261
3261
|
var zoneOffsetTs, zoneOffsetGuessCache = /* @__PURE__ */ new Map(), DateTime = class _DateTime {
|
|
3262
3262
|
constructor(config) {
|
|
3263
|
-
let zone = config.zone || Settings.defaultZone,
|
|
3263
|
+
let zone = config.zone || Settings.defaultZone, invalid19 = config.invalid || (Number.isNaN(config.ts) ? new Invalid("invalid input") : null) || (zone.isValid ? null : unsupportedZone(zone));
|
|
3264
3264
|
this.ts = isUndefined(config.ts) ? Settings.now() : config.ts;
|
|
3265
3265
|
let c = null, o = null;
|
|
3266
|
-
if (!
|
|
3266
|
+
if (!invalid19)
|
|
3267
3267
|
if (config.old && config.old.ts === this.ts && config.old.zone.equals(zone))
|
|
3268
3268
|
[c, o] = [config.old.c, config.old.o];
|
|
3269
3269
|
else {
|
|
3270
3270
|
let ot = isNumber(config.o) && !config.old ? config.o : zone.offset(this.ts);
|
|
3271
|
-
c = tsToObj(this.ts, ot),
|
|
3271
|
+
c = tsToObj(this.ts, ot), invalid19 = Number.isNaN(c.year) ? new Invalid("invalid input") : null, c = invalid19 ? null : c, o = invalid19 ? null : ot;
|
|
3272
3272
|
}
|
|
3273
|
-
this._zone = zone, this.loc = config.loc || Locale.create(), this.invalid =
|
|
3273
|
+
this._zone = zone, this.loc = config.loc || Locale.create(), this.invalid = invalid19, this.weekData = null, this.localWeekData = null, this.c = c, this.o = o, this.isLuxonDateTime = !0;
|
|
3274
3274
|
}
|
|
3275
3275
|
// CONSTRUCT
|
|
3276
3276
|
static now() {
|
|
@@ -3349,9 +3349,9 @@ var require_luxon = /* @__PURE__ */ __commonJS({
|
|
|
3349
3349
|
let v = normalized[u];
|
|
3350
3350
|
isUndefined(v) ? foundFirst ? normalized[u] = defaultValues[u] : normalized[u] = objNow[u] : foundFirst = !0;
|
|
3351
3351
|
}
|
|
3352
|
-
let higherOrderInvalid = useWeekData ? hasInvalidWeekData(normalized, minDaysInFirstWeek, startOfWeek) : containsOrdinal ? hasInvalidOrdinalData(normalized) : hasInvalidGregorianData(normalized),
|
|
3353
|
-
if (
|
|
3354
|
-
return _DateTime.invalid(
|
|
3352
|
+
let higherOrderInvalid = useWeekData ? hasInvalidWeekData(normalized, minDaysInFirstWeek, startOfWeek) : containsOrdinal ? hasInvalidOrdinalData(normalized) : hasInvalidGregorianData(normalized), invalid19 = higherOrderInvalid || hasInvalidTimeData(normalized);
|
|
3353
|
+
if (invalid19)
|
|
3354
|
+
return _DateTime.invalid(invalid19);
|
|
3355
3355
|
let gregorian = useWeekData ? weekToGregorian(normalized, minDaysInFirstWeek, startOfWeek) : containsOrdinal ? ordinalToGregorian(normalized) : normalized, [tsFinal, offsetFinal] = objToTS(gregorian, offsetProvis, zoneToUse), inst = new _DateTime({
|
|
3356
3356
|
ts: tsFinal,
|
|
3357
3357
|
zone: zoneToUse,
|
|
@@ -3382,8 +3382,8 @@ var require_luxon = /* @__PURE__ */ __commonJS({
|
|
|
3382
3382
|
locale,
|
|
3383
3383
|
numberingSystem,
|
|
3384
3384
|
defaultToEN: !0
|
|
3385
|
-
}), [vals, parsedZone, specificOffset,
|
|
3386
|
-
return
|
|
3385
|
+
}), [vals, parsedZone, specificOffset, invalid19] = parseFromTokens(localeToUse, text5, fmt);
|
|
3386
|
+
return invalid19 ? _DateTime.invalid(invalid19) : parseDataToDateTime(vals, parsedZone, opts, `format ${fmt}`, text5, specificOffset);
|
|
3387
3387
|
}
|
|
3388
3388
|
static fromString(text5, fmt, opts = {}) {
|
|
3389
3389
|
return _DateTime.fromFormat(text5, fmt, opts);
|
|
@@ -3395,11 +3395,11 @@ var require_luxon = /* @__PURE__ */ __commonJS({
|
|
|
3395
3395
|
static invalid(reason, explanation = null) {
|
|
3396
3396
|
if (!reason)
|
|
3397
3397
|
throw new InvalidArgumentError("need to specify a reason the DateTime is invalid");
|
|
3398
|
-
let
|
|
3398
|
+
let invalid19 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|
3399
3399
|
if (Settings.throwOnInvalid)
|
|
3400
|
-
throw new InvalidDateTimeError(
|
|
3400
|
+
throw new InvalidDateTimeError(invalid19);
|
|
3401
3401
|
return new _DateTime({
|
|
3402
|
-
invalid:
|
|
3402
|
+
invalid: invalid19
|
|
3403
3403
|
});
|
|
3404
3404
|
}
|
|
3405
3405
|
static isDateTime(o) {
|
|
@@ -4043,10 +4043,10 @@ var require_CronDate = /* @__PURE__ */ __commonJS({
|
|
|
4043
4043
|
[TimeUnit.Second]: this.subtractSecond.bind(this)
|
|
4044
4044
|
}
|
|
4045
4045
|
};
|
|
4046
|
-
constructor(
|
|
4046
|
+
constructor(timestamp3, tz) {
|
|
4047
4047
|
let dateOpts = { zone: tz };
|
|
4048
|
-
if (
|
|
4049
|
-
throw new Error(`CronDate: unhandled timestamp: ${
|
|
4048
|
+
if (timestamp3 ? timestamp3 instanceof _CronDate ? (this.#date = timestamp3.#date, this.#dstStart = timestamp3.#dstStart, this.#dstEnd = timestamp3.#dstEnd) : timestamp3 instanceof Date ? this.#date = luxon_1.DateTime.fromJSDate(timestamp3, dateOpts) : typeof timestamp3 == "number" ? this.#date = luxon_1.DateTime.fromMillis(timestamp3, dateOpts) : (this.#date = luxon_1.DateTime.fromISO(timestamp3, dateOpts), this.#date.isValid || (this.#date = luxon_1.DateTime.fromRFC2822(timestamp3, dateOpts)), this.#date.isValid || (this.#date = luxon_1.DateTime.fromSQL(timestamp3, dateOpts)), this.#date.isValid || (this.#date = luxon_1.DateTime.fromFormat(timestamp3, "EEE, d MMM yyyy HH:mm:ss", dateOpts))) : this.#date = luxon_1.DateTime.local(), !this.#date.isValid)
|
|
4049
|
+
throw new Error(`CronDate: unhandled timestamp: ${timestamp3}`);
|
|
4050
4050
|
tz && tz !== this.#date.zoneName && (this.#date = this.#date.setZone(tz));
|
|
4051
4051
|
}
|
|
4052
4052
|
static #isLeapYear(year) {
|
|
@@ -4987,25 +4987,25 @@ function parseFileErrorDetail(value) {
|
|
|
4987
4987
|
...v.receivedAtLeast ? { receivedAtLeast: !0 } : {}
|
|
4988
4988
|
};
|
|
4989
4989
|
}
|
|
4990
|
-
function fileErrorExplanation(
|
|
4991
|
-
return
|
|
4990
|
+
function fileErrorExplanation(detail2) {
|
|
4991
|
+
return detail2.reason === "size_mismatch" ? `The request declared ${detail2.expectedBytes} bytes, but contained ${detail2.receivedAtLeast ? "at least " : ""}${detail2.receivedBytes} bytes.` : detail2.reason === "size_limit" ? `The file content exceeds the ${fileSizeLabel(detail2.limitBytes)} limit; received ${detail2.receivedAtLeast ? "at least " : ""}${fileSizeLabel(detail2.receivedBytes)}.` : Object.hasOwn(localStorageReasons, detail2.reason) ? localStorageReasons[detail2.reason] : fileValidationReasons[detail2.reason];
|
|
4992
4992
|
}
|
|
4993
4993
|
function fileSizeLabel(bytes) {
|
|
4994
4994
|
for (let [unit, size] of [["GiB", 1024 ** 3], ["MiB", 1024 ** 2], ["KiB", 1024]])
|
|
4995
4995
|
if (bytes >= size && bytes % size === 0) return `${bytes / size} ${unit}`;
|
|
4996
4996
|
return `${bytes} bytes`;
|
|
4997
4997
|
}
|
|
4998
|
-
function fileErrorDetailForCode(code,
|
|
4999
|
-
let parsed = parseFileErrorDetail(
|
|
4998
|
+
function fileErrorDetailForCode(code, detail2) {
|
|
4999
|
+
let parsed = parseFileErrorDetail(detail2);
|
|
5000
5000
|
if (!parsed) return;
|
|
5001
5001
|
if (Object.hasOwn(localStorageReasons, parsed.reason) ? code === "unavailable" : ["invalid_input", "request_too_large"].includes(code)) return parsed;
|
|
5002
5002
|
}
|
|
5003
5003
|
var FILE_CAPACITY_MESSAGE = "OS reached its file-processing limit. Try again in a moment. If this keeps happening with a large batch, split the files into smaller groups.", FILE_INTEGRITY_MESSAGE = "OS could not verify this File against its saved record. Try again. If the problem continues, add the original file again.";
|
|
5004
5004
|
function fileErrorMessage(error) {
|
|
5005
|
-
let
|
|
5006
|
-
if (
|
|
5007
|
-
return `${["invalid_enrichment_name", "invalid_enrichment_request", "invalid_replacement"].includes(
|
|
5008
|
-
` : ""}${fileErrorExplanation(
|
|
5005
|
+
let detail2 = fileErrorDetailForCode(error.code, error.detail);
|
|
5006
|
+
if (detail2)
|
|
5007
|
+
return `${["invalid_enrichment_name", "invalid_enrichment_request", "invalid_replacement"].includes(detail2.reason) ? `Couldn\u2019t save the file\u2019s enrichment.
|
|
5008
|
+
` : ""}${fileErrorExplanation(detail2)}`;
|
|
5009
5009
|
switch (error.code) {
|
|
5010
5010
|
case "invalid_input":
|
|
5011
5011
|
return "The file request is invalid.";
|
|
@@ -5034,8 +5034,8 @@ function fileErrorMessage(error) {
|
|
|
5034
5034
|
}
|
|
5035
5035
|
}
|
|
5036
5036
|
var FileOperationError = class extends Error {
|
|
5037
|
-
constructor(code, status, retryable = !1,
|
|
5038
|
-
let safe = fileErrorDetailForCode(code,
|
|
5037
|
+
constructor(code, status, retryable = !1, detail2) {
|
|
5038
|
+
let safe = fileErrorDetailForCode(code, detail2);
|
|
5039
5039
|
super(fileErrorMessage({ code, retryable, detail: safe }));
|
|
5040
5040
|
this.code = code;
|
|
5041
5041
|
this.status = status;
|
|
@@ -5049,40 +5049,40 @@ var FileOperationError = class extends Error {
|
|
|
5049
5049
|
};
|
|
5050
5050
|
var FILE_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/, FILE_ORIGINAL_MAX_BYTES = 5 * 1024 ** 3;
|
|
5051
5051
|
function parseFileDescriptor(value) {
|
|
5052
|
-
let
|
|
5052
|
+
let invalid19 = () => {
|
|
5053
5053
|
throw new FileOperationError("unavailable", 503, !0);
|
|
5054
5054
|
};
|
|
5055
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
5055
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid19();
|
|
5056
5056
|
let f = value;
|
|
5057
|
-
if (Object.keys(f).sort().join(",") !== "enrichments,id,mediaType,name,path,sha256,size" || typeof f.id != "string" || !FILE_ID_PATTERN.test(f.id) || !safeFileName(f.name) || !safeFilePath(f.path) || !Number.isSafeInteger(f.size) || f.size < 0 || f.size > FILE_ORIGINAL_MAX_BYTES || typeof f.sha256 != "string" || !/^[0-9a-f]{64}$/.test(f.sha256) || !f.enrichments || typeof f.enrichments != "object" || Array.isArray(f.enrichments) || !isCanonicalOriginalMediaType(f.mediaType)) return
|
|
5057
|
+
if (Object.keys(f).sort().join(",") !== "enrichments,id,mediaType,name,path,sha256,size" || typeof f.id != "string" || !FILE_ID_PATTERN.test(f.id) || !safeFileName(f.name) || !safeFilePath(f.path) || !Number.isSafeInteger(f.size) || f.size < 0 || f.size > FILE_ORIGINAL_MAX_BYTES || typeof f.sha256 != "string" || !/^[0-9a-f]{64}$/.test(f.sha256) || !f.enrichments || typeof f.enrichments != "object" || Array.isArray(f.enrichments) || !isCanonicalOriginalMediaType(f.mediaType)) return invalid19();
|
|
5058
5058
|
for (let [name4, descriptor] of Object.entries(f.enrichments)) {
|
|
5059
|
-
if (!safeEnrichmentName(name4)) return
|
|
5059
|
+
if (!safeEnrichmentName(name4)) return invalid19();
|
|
5060
5060
|
parseEnrichmentDescriptor(descriptor);
|
|
5061
5061
|
}
|
|
5062
|
-
return new TextEncoder().encode(JSON.stringify(f)).byteLength > 16 * 1024 ?
|
|
5062
|
+
return new TextEncoder().encode(JSON.stringify(f)).byteLength > 16 * 1024 ? invalid19() : f;
|
|
5063
5063
|
}
|
|
5064
5064
|
function parseEnrichmentDescriptor(value) {
|
|
5065
|
-
let
|
|
5065
|
+
let invalid19 = () => {
|
|
5066
5066
|
throw new FileOperationError("unavailable", 503, !0);
|
|
5067
5067
|
};
|
|
5068
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
5068
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid19();
|
|
5069
5069
|
let d = value;
|
|
5070
|
-
return Object.keys(d).sort().join(",") !== "mediaType,sha256,size" || !["application/octet-stream", "text/plain", "text/markdown", "application/json"].includes(d.mediaType) || !Number.isSafeInteger(d.size) || d.size < 0 || d.size > 16 * 1024 * 1024 || typeof d.sha256 != "string" || !/^[0-9a-f]{64}$/.test(d.sha256) ?
|
|
5070
|
+
return Object.keys(d).sort().join(",") !== "mediaType,sha256,size" || !["application/octet-stream", "text/plain", "text/markdown", "application/json"].includes(d.mediaType) || !Number.isSafeInteger(d.size) || d.size < 0 || d.size > 16 * 1024 * 1024 || typeof d.sha256 != "string" || !/^[0-9a-f]{64}$/.test(d.sha256) ? invalid19() : d;
|
|
5071
5071
|
}
|
|
5072
5072
|
function safeEnrichmentName(value) {
|
|
5073
5073
|
return safeFileName(value) && !/^original(?:\.|$)/i.test(value);
|
|
5074
5074
|
}
|
|
5075
5075
|
function parseFileEnrichMetadata(value, maxBytes) {
|
|
5076
|
-
let
|
|
5076
|
+
let invalid19 = (reason = "invalid_metadata") => {
|
|
5077
5077
|
throw new FileOperationError("invalid_input", 400, !1, { reason });
|
|
5078
5078
|
};
|
|
5079
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
5079
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid19();
|
|
5080
5080
|
let d = value;
|
|
5081
|
-
if (Object.keys(d).some((key) => !["name", "size", "mediaType", "replace"].includes(key))) return
|
|
5082
|
-
if (!safeEnrichmentName(d.name)) return
|
|
5083
|
-
if (!Number.isSafeInteger(d.size) || d.size < 0) return
|
|
5084
|
-
if (d.mediaType !== void 0 && (typeof d.mediaType != "string" || d.mediaType.length > 255 || /[\u0000-\u001f\u007f]/.test(d.mediaType))) return
|
|
5085
|
-
if (d.replace !== void 0 && (typeof d.replace != "string" || !/^[0-9a-f]{64}$/.test(d.replace))) return
|
|
5081
|
+
if (Object.keys(d).some((key) => !["name", "size", "mediaType", "replace"].includes(key))) return invalid19();
|
|
5082
|
+
if (!safeEnrichmentName(d.name)) return invalid19("invalid_enrichment_name");
|
|
5083
|
+
if (!Number.isSafeInteger(d.size) || d.size < 0) return invalid19("invalid_size");
|
|
5084
|
+
if (d.mediaType !== void 0 && (typeof d.mediaType != "string" || d.mediaType.length > 255 || /[\u0000-\u001f\u007f]/.test(d.mediaType))) return invalid19("invalid_media_type");
|
|
5085
|
+
if (d.replace !== void 0 && (typeof d.replace != "string" || !/^[0-9a-f]{64}$/.test(d.replace))) return invalid19("invalid_replacement");
|
|
5086
5086
|
if (d.size > maxBytes) throw new FileOperationError(
|
|
5087
5087
|
"request_too_large",
|
|
5088
5088
|
413,
|
|
@@ -5115,42 +5115,42 @@ function isCanonicalOriginalMediaType(value) {
|
|
|
5115
5115
|
}
|
|
5116
5116
|
}
|
|
5117
5117
|
function parseFileUpdate(value) {
|
|
5118
|
-
let
|
|
5118
|
+
let invalid19 = (reason = "invalid_metadata") => {
|
|
5119
5119
|
throw new FileOperationError("invalid_input", 400, !1, { reason });
|
|
5120
5120
|
};
|
|
5121
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
5121
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid19();
|
|
5122
5122
|
let input = value, update = {};
|
|
5123
|
-
if (!Object.keys(input).length || Object.keys(input).some((key) => !["name", "path", "mediaType"].includes(key))) return
|
|
5123
|
+
if (!Object.keys(input).length || Object.keys(input).some((key) => !["name", "path", "mediaType"].includes(key))) return invalid19();
|
|
5124
5124
|
if (Object.hasOwn(input, "name")) {
|
|
5125
|
-
if (!safeFileName(input.name)) return
|
|
5125
|
+
if (!safeFileName(input.name)) return invalid19("invalid_name");
|
|
5126
5126
|
update.name = input.name;
|
|
5127
5127
|
}
|
|
5128
5128
|
if (Object.hasOwn(input, "path")) {
|
|
5129
|
-
if (!safeManagedFilePath(input.path)) return
|
|
5129
|
+
if (!safeManagedFilePath(input.path)) return invalid19("invalid_path");
|
|
5130
5130
|
update.path = input.path;
|
|
5131
5131
|
}
|
|
5132
5132
|
return Object.hasOwn(input, "mediaType") && (update.mediaType = declaredOriginalMediaType(input.mediaType)), update;
|
|
5133
5133
|
}
|
|
5134
5134
|
function parseFileCreateMetadata(value, maxBytes) {
|
|
5135
|
-
let
|
|
5135
|
+
let invalid19 = (reason = "invalid_metadata") => {
|
|
5136
5136
|
throw new FileOperationError("invalid_input", 400, !1, { reason });
|
|
5137
5137
|
};
|
|
5138
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
5138
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid19();
|
|
5139
5139
|
let input = value;
|
|
5140
|
-
if (Object.keys(input).some((key) => !["name", "path", "storage", "mediaType", "size", "requestKey"].includes(key))) return
|
|
5140
|
+
if (Object.keys(input).some((key) => !["name", "path", "storage", "mediaType", "size", "requestKey"].includes(key))) return invalid19();
|
|
5141
5141
|
let path = input.path === void 0 ? "Files" : input.path;
|
|
5142
|
-
if (!safeFileName(input.name)) return
|
|
5143
|
-
if (!safeManagedFilePath(path)) return
|
|
5144
|
-
if (input.storage !== void 0 && input.storage !== "remote" && input.storage !== "local") return
|
|
5142
|
+
if (!safeFileName(input.name)) return invalid19("invalid_name");
|
|
5143
|
+
if (!safeManagedFilePath(path)) return invalid19("invalid_path");
|
|
5144
|
+
if (input.storage !== void 0 && input.storage !== "remote" && input.storage !== "local") return invalid19("invalid_storage");
|
|
5145
5145
|
let mediaType = input.mediaType === void 0 ? "application/octet-stream" : declaredOriginalMediaType(input.mediaType);
|
|
5146
|
-
if (!Number.isSafeInteger(input.size) || input.size < 0) return
|
|
5146
|
+
if (!Number.isSafeInteger(input.size) || input.size < 0) return invalid19("invalid_size");
|
|
5147
5147
|
if (input.size > maxBytes) throw new FileOperationError(
|
|
5148
5148
|
"request_too_large",
|
|
5149
5149
|
413,
|
|
5150
5150
|
!1,
|
|
5151
5151
|
{ reason: "size_limit", limitBytes: maxBytes, receivedBytes: input.size }
|
|
5152
5152
|
);
|
|
5153
|
-
return typeof input.requestKey != "string" || input.requestKey.length < 1 || input.requestKey.length > 256 || input.requestKey !== input.requestKey.trim() || /[\u0000-\u001f\u007f]/.test(input.requestKey) ?
|
|
5153
|
+
return typeof input.requestKey != "string" || input.requestKey.length < 1 || input.requestKey.length > 256 || input.requestKey !== input.requestKey.trim() || /[\u0000-\u001f\u007f]/.test(input.requestKey) ? invalid19("invalid_request_key") : {
|
|
5154
5154
|
name: input.name,
|
|
5155
5155
|
path,
|
|
5156
5156
|
...input.storage ? { storage: input.storage } : {},
|
|
@@ -6303,18 +6303,18 @@ function parseRoutineAIErrorDetail(code, value) {
|
|
|
6303
6303
|
return { reason: "unsupported_media_type", mediaType: v.mediaType };
|
|
6304
6304
|
}
|
|
6305
6305
|
function routineAIErrorMessage(code, value) {
|
|
6306
|
-
let
|
|
6307
|
-
if (code === "invalid_output" &&
|
|
6308
|
-
if (
|
|
6306
|
+
let detail2 = parseRoutineAIErrorDetail(code, value);
|
|
6307
|
+
if (code === "invalid_output" && detail2) return routineAIOutputMessage(detail2);
|
|
6308
|
+
if (detail2) switch (detail2.reason) {
|
|
6309
6309
|
case "model_output_limit":
|
|
6310
|
-
return `AI stopped because its response reached the model\u2019s ${
|
|
6310
|
+
return `AI stopped because its response reached the model\u2019s ${detail2.limit.toLocaleString("en-US")}-token output limit.`;
|
|
6311
6311
|
case "response_transport_limit":
|
|
6312
|
-
return `OS stopped accepting the AI response because it exceeded the ${formatBytes(
|
|
6312
|
+
return `OS stopped accepting the AI response because it exceeded the ${formatBytes(detail2.limitBytes)} response transport limit.`;
|
|
6313
6313
|
case "accepted_value_limit":
|
|
6314
|
-
return `OS couldn\u2019t accept the AI response because its final value exceeded the ${formatBytes(
|
|
6314
|
+
return `OS couldn\u2019t accept the AI response because its final value exceeded the ${formatBytes(detail2.limitBytes)} limit.`;
|
|
6315
6315
|
case "turn_limit":
|
|
6316
6316
|
return `AI stopped before finishing the request.
|
|
6317
|
-
It reached the ${
|
|
6317
|
+
It reached the ${detail2.limit}-turn limit.`;
|
|
6318
6318
|
case "runner_exit":
|
|
6319
6319
|
return `AI couldn\u2019t complete the request.
|
|
6320
6320
|
The local AI runner stopped before returning a usable answer.`;
|
|
@@ -6335,7 +6335,7 @@ Set tools to true or false.`;
|
|
|
6335
6335
|
Using tools requires a File input.`;
|
|
6336
6336
|
case "unsupported_media_type":
|
|
6337
6337
|
return `AI couldn\u2019t read this file.
|
|
6338
|
-
Its media type is ${
|
|
6338
|
+
Its media type is ${detail2.mediaType}, which this input path doesn\u2019t support.
|
|
6339
6339
|
|
|
6340
6340
|
Check the file\u2019s stored media type before retrying. The model was not called.`;
|
|
6341
6341
|
}
|
|
@@ -6370,22 +6370,22 @@ var ROUTINE_AI_VALUE_BYTES = 256 * 1024;
|
|
|
6370
6370
|
var ROUTINE_AI_RESULT_BYTES = 6 * ROUTINE_AI_VALUE_BYTES + 1024, ROUTINE_AI_EVIDENCE_BYTES = 4 * 1024;
|
|
6371
6371
|
var AIError = class extends Error {
|
|
6372
6372
|
constructor(code, options = {}) {
|
|
6373
|
-
let
|
|
6374
|
-
super(routineAIErrorMessage(code,
|
|
6373
|
+
let detail2 = parseRoutineAIErrorDetail(code, options.detail);
|
|
6374
|
+
super(routineAIErrorMessage(code, detail2));
|
|
6375
6375
|
this.code = code;
|
|
6376
|
-
this.name = "AIError",
|
|
6376
|
+
this.name = "AIError", detail2 && (this.detail = Object.freeze(detail2)), code === "invalid_output" && typeof options.text == "string" && new TextEncoder().encode(options.text).byteLength <= ROUTINE_AI_VALUE_BYTES && Object.defineProperty(this, "text", { value: options.text });
|
|
6377
6377
|
}
|
|
6378
6378
|
code;
|
|
6379
6379
|
detail;
|
|
6380
6380
|
};
|
|
6381
|
-
function capture(value,
|
|
6381
|
+
function capture(value, invalid19, oversized, limit = ROUTINE_AI_VALUE_BYTES) {
|
|
6382
6382
|
try {
|
|
6383
6383
|
assertRoutineJson(value);
|
|
6384
6384
|
let encoded = JSON.stringify(value);
|
|
6385
6385
|
if (new TextEncoder().encode(encoded).byteLength > limit) throw new AIError(oversized);
|
|
6386
6386
|
return freezeRoutineMetadata(JSON.parse(encoded));
|
|
6387
6387
|
} catch (error) {
|
|
6388
|
-
throw error instanceof AIError ? error : new AIError(
|
|
6388
|
+
throw error instanceof AIError ? error : new AIError(invalid19);
|
|
6389
6389
|
}
|
|
6390
6390
|
}
|
|
6391
6391
|
function parseRoutineAIRequest(value) {
|
|
@@ -6424,13 +6424,13 @@ function parseRoutineAIResult(request3, value) {
|
|
|
6424
6424
|
return validateObject(request3.schema, v.object), freezeRoutineMetadata({ object: v.object });
|
|
6425
6425
|
}
|
|
6426
6426
|
function validateObject(schema2, object11, text5) {
|
|
6427
|
-
let
|
|
6427
|
+
let detail2 = { reason: "invalid_response" };
|
|
6428
6428
|
try {
|
|
6429
6429
|
validateRoutineSchemaValue(schema2, object11, (issue) => {
|
|
6430
|
-
|
|
6430
|
+
detail2 = issue;
|
|
6431
6431
|
});
|
|
6432
6432
|
} catch {
|
|
6433
|
-
throw new AIError("invalid_output", { ...text5 === void 0 ? {} : { text: text5 }, detail });
|
|
6433
|
+
throw new AIError("invalid_output", { ...text5 === void 0 ? {} : { text: text5 }, detail: detail2 });
|
|
6434
6434
|
}
|
|
6435
6435
|
}
|
|
6436
6436
|
function acceptText(request3, text5) {
|
|
@@ -6450,22 +6450,22 @@ function acceptText(request3, text5) {
|
|
|
6450
6450
|
|
|
6451
6451
|
var ROUTINE_STEP_SUMMARY_BYTES = 256 * 1024, ROUTINE_STEP_OUTPUT_BYTES = 1024 * 1024;
|
|
6452
6452
|
function parseRoutineStepOutputDetail(value) {
|
|
6453
|
-
let
|
|
6453
|
+
let invalid19 = () => {
|
|
6454
6454
|
throw new AppRoutineContractError("invalid_value");
|
|
6455
6455
|
};
|
|
6456
6456
|
assertRoutineFields(value, ["step", "sizeBytes", "limitBytes", "summaryBytes", "dataBytes"]);
|
|
6457
6457
|
let { step, sizeBytes, limitBytes, summaryBytes, dataBytes } = value;
|
|
6458
|
-
return !isAppRoutineName(step) || ![sizeBytes, limitBytes, summaryBytes, dataBytes].every((bytes) => Number.isSafeInteger(bytes) && bytes > 0) || sizeBytes !== summaryBytes + dataBytes || limitBytes !== (summaryBytes > ROUTINE_STEP_SUMMARY_BYTES ? ROUTINE_STEP_SUMMARY_BYTES : ROUTINE_STEP_OUTPUT_BYTES) || (limitBytes === ROUTINE_STEP_SUMMARY_BYTES ? summaryBytes : sizeBytes) <= limitBytes ?
|
|
6458
|
+
return !isAppRoutineName(step) || ![sizeBytes, limitBytes, summaryBytes, dataBytes].every((bytes) => Number.isSafeInteger(bytes) && bytes > 0) || sizeBytes !== summaryBytes + dataBytes || limitBytes !== (summaryBytes > ROUTINE_STEP_SUMMARY_BYTES ? ROUTINE_STEP_SUMMARY_BYTES : ROUTINE_STEP_OUTPUT_BYTES) || (limitBytes === ROUTINE_STEP_SUMMARY_BYTES ? summaryBytes : sizeBytes) <= limitBytes ? invalid19() : freezeRoutineMetadata({ step, sizeBytes, limitBytes, summaryBytes, dataBytes });
|
|
6459
6459
|
}
|
|
6460
6460
|
function routineStepOutputMessage(value) {
|
|
6461
|
-
let
|
|
6462
|
-
return `Step ${
|
|
6461
|
+
let detail2 = parseRoutineStepOutputDetail(value), size = `${(detail2.sizeBytes / (1024 * 1024)).toFixed(1)} MB`, bound = detail2.limitBytes === ROUTINE_STEP_SUMMARY_BYTES ? `, including ${(detail2.summaryBytes / 1024).toFixed(1)} KB of summary. Each step's summary can return up to 256 KB.` : ". Each step can return up to 1 MB across its summary and data.";
|
|
6462
|
+
return `Step ${detail2.step} returned ${size} of output${bound} Return fewer fields or process a smaller batch, then try again.`;
|
|
6463
6463
|
}
|
|
6464
6464
|
var RoutineStepOutputError = class extends Error {
|
|
6465
6465
|
code = "step_output_too_large";
|
|
6466
6466
|
detail;
|
|
6467
|
-
constructor(
|
|
6468
|
-
let captured = parseRoutineStepOutputDetail(
|
|
6467
|
+
constructor(detail2) {
|
|
6468
|
+
let captured = parseRoutineStepOutputDetail(detail2);
|
|
6469
6469
|
super(routineStepOutputMessage(captured)), this.detail = captured, Object.freeze(this);
|
|
6470
6470
|
}
|
|
6471
6471
|
};
|
|
@@ -6667,9 +6667,9 @@ function createCapabilityRuntime(contract, runtime2, current2, owner) {
|
|
|
6667
6667
|
generateText: (value) => generate("generateText", value),
|
|
6668
6668
|
generateObject: (value) => generate("generateObject", value)
|
|
6669
6669
|
},
|
|
6670
|
-
connections: { ...runtime2.connections, get: async (
|
|
6671
|
-
if (!current2() || !contract.access.connections?.includes(
|
|
6672
|
-
let value = await runtime2.connections.get(
|
|
6670
|
+
connections: { ...runtime2.connections, get: async (identity4) => {
|
|
6671
|
+
if (!current2() || !contract.access.connections?.includes(identity4)) throw new Error("Connection unavailable");
|
|
6672
|
+
let value = await runtime2.connections.get(identity4);
|
|
6673
6673
|
if (!current2()) throw new Error(`${owner} authority ended`);
|
|
6674
6674
|
return value;
|
|
6675
6675
|
} },
|
|
@@ -6797,37 +6797,103 @@ function parseQueuePage(value) {
|
|
|
6797
6797
|
return { items: v.items.map(parseQueueItem), ...v.next === void 0 ? {} : { next: v.next } };
|
|
6798
6798
|
}
|
|
6799
6799
|
|
|
6800
|
+
var XERO_WEBHOOK_KINDS = ["invoice.created", "invoice.updated", "payment.created", "payment.updated"], invalid4 = () => {
|
|
6801
|
+
throw new Error("Invalid routine webhook");
|
|
6802
|
+
}, connection = (value) => typeof value == "string" && value.startsWith("xero/") && isAppRoutineName(value.slice(5)), identity = (value) => typeof value == "string" && value.length > 0 && value.length <= 256 && !/[\s\x00-\x1f\x7f]/.test(value);
|
|
6803
|
+
function timestamp(value) {
|
|
6804
|
+
return typeof value != "string" || value.length > 40 || !/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d{1,3})?(?:Z|[+-]\d\d:\d\d)$/.test(value) || !Number.isFinite(Date.parse(value)) ? invalid4() : value;
|
|
6805
|
+
}
|
|
6806
|
+
function parseWebhookQueryTrigger(value, access) {
|
|
6807
|
+
return assertRoutineFields(value, ["connection", "events"]), !connection(value.connection) || !access.connections?.includes(value.connection) || !Array.isArray(value.events) || value.events.length < 1 || value.events.length > XERO_WEBHOOK_KINDS.length || new Set(value.events).size !== value.events.length || value.events.some((kind) => !XERO_WEBHOOK_KINDS.includes(kind)) ? invalid4() : freezeRoutineMetadata({ webhook: { connection: value.connection, events: [...value.events] } });
|
|
6808
|
+
}
|
|
6809
|
+
function detail(value) {
|
|
6810
|
+
let nodes = 0, visit = (v, depth) => {
|
|
6811
|
+
if (++nodes > 256 || depth > 8) return invalid4();
|
|
6812
|
+
if (!(v === null || typeof v == "boolean" || typeof v == "number" && Number.isFinite(v))) {
|
|
6813
|
+
if (typeof v == "string")
|
|
6814
|
+
return v.length > 8192 ? invalid4() : void 0;
|
|
6815
|
+
if (Array.isArray(v)) {
|
|
6816
|
+
if (v.length > 256 || Reflect.ownKeys(v).length !== v.length + 1) return invalid4();
|
|
6817
|
+
for (let i = 0; i < v.length; i++) {
|
|
6818
|
+
let descriptor = Object.getOwnPropertyDescriptor(v, i);
|
|
6819
|
+
if (!descriptor?.enumerable || !Object.hasOwn(descriptor, "value")) return invalid4();
|
|
6820
|
+
visit(descriptor.value, depth + 1);
|
|
6821
|
+
}
|
|
6822
|
+
} else {
|
|
6823
|
+
assertRoutineFields(v);
|
|
6824
|
+
for (let [key, child] of Object.entries(v)) {
|
|
6825
|
+
if (key.length > 256) return invalid4();
|
|
6826
|
+
visit(child, depth + 1);
|
|
6827
|
+
}
|
|
6828
|
+
}
|
|
6829
|
+
}
|
|
6830
|
+
};
|
|
6831
|
+
visit(value, 0);
|
|
6832
|
+
let encoded = JSON.stringify(value);
|
|
6833
|
+
return new TextEncoder().encode(encoded).length > 8192 ? invalid4() : JSON.parse(encoded);
|
|
6834
|
+
}
|
|
6835
|
+
function parseWebhookEvent(value) {
|
|
6836
|
+
return assertRoutineFields(value, ["id", "provider", "connection", "kind", "resource", "occurredAt", "receivedAt", "detail"]), assertRoutineFields(value.resource, ["type", "id"]), !identity(value.id) || value.provider !== "xero" || !connection(value.connection) || !XERO_WEBHOOK_KINDS.includes(value.kind) || !identity(value.resource.id) || value.resource.type !== value.kind.split(".")[0] ? invalid4() : freezeRoutineMetadata({
|
|
6837
|
+
id: value.id,
|
|
6838
|
+
provider: "xero",
|
|
6839
|
+
connection: value.connection,
|
|
6840
|
+
kind: value.kind,
|
|
6841
|
+
resource: { type: value.resource.type, id: value.resource.id },
|
|
6842
|
+
receivedAt: timestamp(value.receivedAt),
|
|
6843
|
+
...value.occurredAt === void 0 ? {} : { occurredAt: timestamp(value.occurredAt) },
|
|
6844
|
+
...value.detail === void 0 ? {} : { detail: detail(value.detail) }
|
|
6845
|
+
});
|
|
6846
|
+
}
|
|
6847
|
+
|
|
6848
|
+
function parseQueryTriggers(value, access) {
|
|
6849
|
+
if (assertRoutineJson(value), !Array.isArray(value)) throw new Error("Invalid query triggers");
|
|
6850
|
+
return value.map((trigger) => {
|
|
6851
|
+
if (assertRoutineFields(trigger, ["schedule", "webhook"]), Object.keys(trigger).length !== 1) throw new Error("Invalid query trigger");
|
|
6852
|
+
return Object.hasOwn(trigger, "schedule") ? { schedule: parseRoutineSchedule(trigger.schedule) } : parseWebhookQueryTrigger(trigger.webhook, access);
|
|
6853
|
+
});
|
|
6854
|
+
}
|
|
6855
|
+
function parseQueryTriggerContext(value, query) {
|
|
6856
|
+
if (assertRoutineFields(value, ["type", "scheduledAt", "event"]), value.type === "manual" && Object.keys(value).length === 1) return { type: "manual" };
|
|
6857
|
+
if (value.type === "schedule" && Object.keys(value).length === 2 && typeof value.scheduledAt == "string" && Number.isFinite(Date.parse(value.scheduledAt))) return { type: "schedule", scheduledAt: value.scheduledAt };
|
|
6858
|
+
if (value.type === "webhook" && Object.keys(value).length === 2) {
|
|
6859
|
+
let event = parseWebhookEvent(value.event);
|
|
6860
|
+
if (query && (!query.access.connections?.includes(event.connection) || !query.triggers.some((trigger) => "webhook" in trigger && trigger.webhook.connection === event.connection && trigger.webhook.events.includes(event.kind)))) throw new Error("Invalid query trigger authority");
|
|
6861
|
+
return { type: "webhook", event };
|
|
6862
|
+
}
|
|
6863
|
+
throw new Error("Invalid query trigger");
|
|
6864
|
+
}
|
|
6865
|
+
|
|
6800
6866
|
var name = /^[a-z0-9][a-z0-9-]{0,62}$/, uuid2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
6801
|
-
function
|
|
6867
|
+
function invalid5() {
|
|
6802
6868
|
throw new Error("Invalid query result");
|
|
6803
6869
|
}
|
|
6804
6870
|
function object4(value) {
|
|
6805
|
-
return !value || typeof value != "object" || Array.isArray(value) ?
|
|
6871
|
+
return !value || typeof value != "object" || Array.isArray(value) ? invalid5() : value;
|
|
6806
6872
|
}
|
|
6807
6873
|
function id3(value) {
|
|
6808
|
-
return typeof value == "string" && uuid2.test(value) ? value :
|
|
6874
|
+
return typeof value == "string" && uuid2.test(value) ? value : invalid5();
|
|
6809
6875
|
}
|
|
6810
|
-
function
|
|
6811
|
-
return typeof value == "string" && name.test(value) ? value :
|
|
6876
|
+
function identity2(value) {
|
|
6877
|
+
return typeof value == "string" && name.test(value) ? value : invalid5();
|
|
6812
6878
|
}
|
|
6813
6879
|
function date2(value) {
|
|
6814
|
-
return typeof value == "string" && Number.isFinite(Date.parse(value)) ? value :
|
|
6880
|
+
return typeof value == "string" && Number.isFinite(Date.parse(value)) ? value : invalid5();
|
|
6815
6881
|
}
|
|
6816
6882
|
function count(value) {
|
|
6817
|
-
return typeof value == "number" && Number.isSafeInteger(value) && value >= 0 ? value :
|
|
6883
|
+
return typeof value == "number" && Number.isSafeInteger(value) && value >= 0 ? value : invalid5();
|
|
6818
6884
|
}
|
|
6819
6885
|
function parseQueryExecution(value) {
|
|
6820
6886
|
let v = object4(value), trigger = object4(v.trigger);
|
|
6821
|
-
if (!["queued", "running", "succeeded", "failed"].includes(v.status) || !["manual", "schedule"].includes(trigger.type)) return
|
|
6887
|
+
if (!["queued", "running", "succeeded", "failed"].includes(v.status) || !["manual", "schedule", "webhook"].includes(trigger.type)) return invalid5();
|
|
6822
6888
|
let found = count(v.found), added = count(v.added), skipped = count(v.skipped);
|
|
6823
|
-
if (added > found - skipped) return
|
|
6889
|
+
if (added > found - skipped) return invalid5();
|
|
6824
6890
|
let failure = v.failure === void 0 ? void 0 : object4(v.failure);
|
|
6825
|
-
return failure && typeof failure.message != "string" || v.status === "failed" && !failure ?
|
|
6891
|
+
return failure && typeof failure.message != "string" || v.status === "failed" && !failure ? invalid5() : {
|
|
6826
6892
|
id: id3(v.id),
|
|
6827
|
-
queryId:
|
|
6893
|
+
queryId: identity2(v.queryId),
|
|
6828
6894
|
deploymentId: id3(v.deploymentId),
|
|
6829
6895
|
status: v.status,
|
|
6830
|
-
trigger:
|
|
6896
|
+
trigger: parseQueryTriggerContext(trigger),
|
|
6831
6897
|
acceptedAt: date2(v.acceptedAt),
|
|
6832
6898
|
found,
|
|
6833
6899
|
added,
|
|
@@ -6840,19 +6906,19 @@ function parseQueryExecution(value) {
|
|
|
6840
6906
|
}
|
|
6841
6907
|
function parseQueryDescription(value) {
|
|
6842
6908
|
let v = object4(value);
|
|
6843
|
-
if (!Array.isArray(v.triggers)) return
|
|
6844
|
-
let result2 = {
|
|
6845
|
-
id:
|
|
6846
|
-
routineId:
|
|
6847
|
-
access
|
|
6848
|
-
triggers: v.triggers
|
|
6909
|
+
if (!Array.isArray(v.triggers)) return invalid5();
|
|
6910
|
+
let access = parseRoutineAccess(v.access), result2 = {
|
|
6911
|
+
id: identity2(v.id),
|
|
6912
|
+
routineId: identity2(v.routineId),
|
|
6913
|
+
access,
|
|
6914
|
+
triggers: parseQueryTriggers(v.triggers, access),
|
|
6849
6915
|
...v.latestExecution === void 0 ? {} : { latestExecution: parseQueryExecution(v.latestExecution) }
|
|
6850
6916
|
};
|
|
6851
|
-
return result2.latestExecution && result2.latestExecution.queryId !== result2.id ?
|
|
6917
|
+
return result2.latestExecution && result2.latestExecution.queryId !== result2.id ? invalid5() : result2;
|
|
6852
6918
|
}
|
|
6853
6919
|
function parseQueryExecutionPage(value) {
|
|
6854
6920
|
let v = object4(value);
|
|
6855
|
-
return !Array.isArray(v.items) || v.items.length > 500 || v.next !== void 0 && (typeof v.next != "string" || !v.next) ?
|
|
6921
|
+
return !Array.isArray(v.items) || v.items.length > 500 || v.next !== void 0 && (typeof v.next != "string" || !v.next) ? invalid5() : { items: v.items.map(parseQueryExecution), ...v.next === void 0 ? {} : { next: v.next } };
|
|
6856
6922
|
}
|
|
6857
6923
|
|
|
6858
6924
|
var fieldProblems = ["unknown", "missing", "invalid", "source_schema"], reasons = {
|
|
@@ -6958,39 +7024,39 @@ function parsePublicationConflict(value) {
|
|
|
6958
7024
|
function dataValidationMessageFacts(error) {
|
|
6959
7025
|
if (["invalid_change", "conflict"].includes(error.code) && error.detail && typeof error.detail == "object" && "code" in error.detail && error.detail.code === "publication_conflict")
|
|
6960
7026
|
try {
|
|
6961
|
-
let
|
|
7027
|
+
let detail2 = parsePublicationConflict(error.detail), descriptions = {
|
|
6962
7028
|
record_version_changed: "changed after it was reviewed",
|
|
6963
7029
|
record_missing: "is missing",
|
|
6964
7030
|
create_identity_conflict: "already exists",
|
|
6965
7031
|
filing_conflict: "has a conflicting filing path",
|
|
6966
7032
|
schema_changed: "has an unavailable or incompatible schema"
|
|
6967
7033
|
};
|
|
6968
|
-
return { detail, message: `Record "${
|
|
7034
|
+
return { detail: detail2, message: `Record "${detail2.record}" ${descriptions[detail2.conflict]}. No changes were saved.` };
|
|
6969
7035
|
} catch {
|
|
6970
7036
|
return {};
|
|
6971
7037
|
}
|
|
6972
7038
|
if (error.code === "invalid_change") {
|
|
6973
|
-
let
|
|
6974
|
-
if (
|
|
6975
|
-
let problem = fieldProblems.find((problem2) => reasons[problem2] ===
|
|
6976
|
-
return { detail, message: recordFieldMessage(
|
|
6977
|
-
|
|
6978
|
-
|
|
7039
|
+
let detail2 = parseDataValidationDetail(error.detail);
|
|
7040
|
+
if (detail2) {
|
|
7041
|
+
let problem = fieldProblems.find((problem2) => reasons[problem2] === detail2.reason);
|
|
7042
|
+
return { detail: detail2, message: recordFieldMessage(
|
|
7043
|
+
detail2.record,
|
|
7044
|
+
detail2.field,
|
|
6979
7045
|
problem,
|
|
6980
|
-
|
|
6981
|
-
|
|
7046
|
+
detail2.schemaFile,
|
|
7047
|
+
detail2.expected
|
|
6982
7048
|
) };
|
|
6983
7049
|
}
|
|
6984
7050
|
}
|
|
6985
7051
|
let message2 = error.code === "invalid_change" ? safeRecordFieldMessage(error.message) : void 0;
|
|
6986
7052
|
return message2 ? { message: message2 } : {};
|
|
6987
7053
|
}
|
|
6988
|
-
function explainDataValidation(error, message2,
|
|
6989
|
-
return Object.assign(error, dataValidationMessageFacts({ code: error.code, message: typeof message2 == "string" ? message2 : "", detail })), error;
|
|
7054
|
+
function explainDataValidation(error, message2, detail2) {
|
|
7055
|
+
return Object.assign(error, dataValidationMessageFacts({ code: error.code, message: typeof message2 == "string" ? message2 : "", detail: detail2 })), error;
|
|
6990
7056
|
}
|
|
6991
7057
|
|
|
6992
|
-
function dataPublicationFailureMessage(
|
|
6993
|
-
return
|
|
7058
|
+
function dataPublicationFailureMessage(detail2) {
|
|
7059
|
+
return detail2.preflight === "dirty_repository" ? `Data repository ${detail2.repository} has existing changes. No Record files were changed. Use os data push ${detail2.repository} or stash those Data changes with Git, then run the routine again.` : (detail2.state === "commit" ? `Data commit ${detail2.commit} remains in your checkout; its push is unconfirmed.` : detail2.state === "files" ? "Your Record files were applied, but Git could not create their commit." : "Data publication needs Git preparation. No Record files were changed.") + ` Review git status and your branch and destination, then use os data push ${detail2.repository}. Do not rerun the routine to recover this publication.`;
|
|
6994
7060
|
}
|
|
6995
7061
|
var localDataPath = (value, repository) => typeof value == "string" && value.length <= 1024 && value.startsWith(`${repository}/`) && !value.includes("\\") && !/[\x00-\x1f\x7f]/.test(value) && value.split("/").every((part) => !!part && part !== "." && part !== ".."), localDataFile = (value, repository) => {
|
|
6996
7062
|
if (!value || typeof value != "object" || Array.isArray(value)) return !1;
|
|
@@ -6998,20 +7064,20 @@ var localDataPath = (value, repository) => typeof value == "string" && value.len
|
|
|
6998
7064
|
return Object.keys(row).sort().join(",") === "action,path" && ["created", "updated", "deleted"].includes(String(row.action)) && localDataPath(row.path, repository);
|
|
6999
7065
|
};
|
|
7000
7066
|
function parseDataFailureDetail(value) {
|
|
7001
|
-
let
|
|
7067
|
+
let invalid19 = () => {
|
|
7002
7068
|
throw new Error("Invalid local Data failure detail");
|
|
7003
7069
|
};
|
|
7004
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
7070
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid19();
|
|
7005
7071
|
let row = value;
|
|
7006
|
-
if (Object.keys(row).sort().join(",") !== "cause,code,files,nextAction,operation,repository" || !["local_data_read_failed", "local_data_write_failed", "local_data_write_partial"].includes(String(row.code)) || !["read", "write"].includes(String(row.operation)) || typeof row.repository != "string" || !/^[a-z0-9][a-z0-9._/-]{0,127}$/.test(row.repository) || row.repository.includes("//") || row.repository.includes("..") || !["fix_failed_file_then_rerun", "review_resolve_then_rerun"].includes(String(row.nextAction))) return
|
|
7072
|
+
if (Object.keys(row).sort().join(",") !== "cause,code,files,nextAction,operation,repository" || !["local_data_read_failed", "local_data_write_failed", "local_data_write_partial"].includes(String(row.code)) || !["read", "write"].includes(String(row.operation)) || typeof row.repository != "string" || !/^[a-z0-9][a-z0-9._/-]{0,127}$/.test(row.repository) || row.repository.includes("//") || row.repository.includes("..") || !["fix_failed_file_then_rerun", "review_resolve_then_rerun"].includes(String(row.nextAction))) return invalid19();
|
|
7007
7073
|
let repository = row.repository;
|
|
7008
|
-
if (!row.cause || typeof row.cause != "object" || Array.isArray(row.cause)) return
|
|
7074
|
+
if (!row.cause || typeof row.cause != "object" || Array.isArray(row.cause)) return invalid19();
|
|
7009
7075
|
let cause = row.cause;
|
|
7010
|
-
if (!["code,message", "code,message,path"].includes(Object.keys(cause).sort().join(",")) || !["schema_validation_failed", "invalid_record", "unsafe_record", "stale_record", "path_conflict", "filesystem_unavailable"].includes(String(cause.code)) || typeof cause.message != "string" || !cause.message || cause.message.length > 512 || /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/.test(cause.message) || cause.path !== void 0 && !localDataPath(cause.path, repository) || !row.files || typeof row.files != "object" || Array.isArray(row.files)) return
|
|
7076
|
+
if (!["code,message", "code,message,path"].includes(Object.keys(cause).sort().join(",")) || !["schema_validation_failed", "invalid_record", "unsafe_record", "stale_record", "path_conflict", "filesystem_unavailable"].includes(String(cause.code)) || typeof cause.message != "string" || !cause.message || cause.message.length > 512 || /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/.test(cause.message) || cause.path !== void 0 && !localDataPath(cause.path, repository) || !row.files || typeof row.files != "object" || Array.isArray(row.files)) return invalid19();
|
|
7011
7077
|
let files3 = row.files;
|
|
7012
|
-
if (Object.keys(files3).some((key) => !["state", "saved", "failed", "notAttempted", "savedOmitted", "notAttemptedOmitted"].includes(key)) || !["none", "partial"].includes(String(files3.state)) || !Array.isArray(files3.saved) || files3.saved.length > 128 || !files3.saved.every((item) => localDataFile(item, repository)) || files3.failed !== void 0 && !localDataFile(files3.failed, repository) || !Array.isArray(files3.notAttempted) || files3.notAttempted.length > 128 || !files3.notAttempted.every((item) => localDataFile(item, repository))) return
|
|
7013
|
-
for (let key of ["savedOmitted", "notAttemptedOmitted"]) if (files3[key] !== void 0 && (!Number.isSafeInteger(files3[key]) || Number(files3[key]) < 1 || Number(files3[key]) > 1e4)) return
|
|
7014
|
-
return row.operation === "read" && (row.code !== "local_data_read_failed" || files3.state !== "none" || files3.saved.length || files3.failed !== void 0 || files3.notAttempted.length) || row.operation === "write" && row.code === "local_data_read_failed" || row.code === "local_data_write_partial" && (files3.state !== "partial" || !files3.saved.length) || row.code !== "local_data_write_partial" && files3.state === "partial" ?
|
|
7078
|
+
if (Object.keys(files3).some((key) => !["state", "saved", "failed", "notAttempted", "savedOmitted", "notAttemptedOmitted"].includes(key)) || !["none", "partial"].includes(String(files3.state)) || !Array.isArray(files3.saved) || files3.saved.length > 128 || !files3.saved.every((item) => localDataFile(item, repository)) || files3.failed !== void 0 && !localDataFile(files3.failed, repository) || !Array.isArray(files3.notAttempted) || files3.notAttempted.length > 128 || !files3.notAttempted.every((item) => localDataFile(item, repository))) return invalid19();
|
|
7079
|
+
for (let key of ["savedOmitted", "notAttemptedOmitted"]) if (files3[key] !== void 0 && (!Number.isSafeInteger(files3[key]) || Number(files3[key]) < 1 || Number(files3[key]) > 1e4)) return invalid19();
|
|
7080
|
+
return row.operation === "read" && (row.code !== "local_data_read_failed" || files3.state !== "none" || files3.saved.length || files3.failed !== void 0 || files3.notAttempted.length) || row.operation === "write" && row.code === "local_data_read_failed" || row.code === "local_data_write_partial" && (files3.state !== "partial" || !files3.saved.length) || row.code !== "local_data_write_partial" && files3.state === "partial" ? invalid19() : structuredClone(value);
|
|
7015
7081
|
}
|
|
7016
7082
|
function parseDataOperationDetail(value) {
|
|
7017
7083
|
if (value && typeof value == "object" && !Array.isArray(value) && value.code === "publication_conflict")
|
|
@@ -7032,9 +7098,9 @@ function parseDataOperationDetail(value) {
|
|
|
7032
7098
|
}
|
|
7033
7099
|
return parseDataFailureDetail(value);
|
|
7034
7100
|
}
|
|
7035
|
-
function dataRecordLimitMessage(
|
|
7036
|
-
let scope =
|
|
7037
|
-
return `The routine tried to load more than ${
|
|
7101
|
+
function dataRecordLimitMessage(detail2) {
|
|
7102
|
+
let scope = detail2.collections.length === 1 ? ` from ${detail2.collections[0]}` : ` across ${detail2.collections.join(", ")}`;
|
|
7103
|
+
return `The routine tried to load more than ${detail2.maxRecords.toLocaleString("en-US")} matching Records${scope}. Narrow the query or increase maxRecords.`;
|
|
7038
7104
|
}
|
|
7039
7105
|
function dataErrorMessage(code, effect) {
|
|
7040
7106
|
return effect === "uncertain" ? "We couldn\u2019t confirm whether your changes were saved." : code === "unavailable" && effect === "unapplied" ? "Your changes could not be saved." : code === "apply_pending" ? effect === "applied" ? "Your changes were saved, but confirmation is still pending." : effect === "unapplied" ? "Your changes have not been saved yet." : "We couldn\u2019t confirm whether your changes were saved." : {
|
|
@@ -7051,8 +7117,8 @@ function dataErrorMessage(code, effect) {
|
|
|
7051
7117
|
}[code] + (effect === "unapplied" ? " No changes were saved." : effect === "applied" ? " Your changes were saved." : "");
|
|
7052
7118
|
}
|
|
7053
7119
|
var DataOperationError = class extends Error {
|
|
7054
|
-
constructor(code, retryable = !1, effect, component,
|
|
7055
|
-
let parsed =
|
|
7120
|
+
constructor(code, retryable = !1, effect, component, detail2) {
|
|
7121
|
+
let parsed = detail2 === void 0 ? void 0 : parseDataOperationDetail(detail2);
|
|
7056
7122
|
if (parsed && ("reason" in parsed ? code !== "invalid_change" : parsed.code === "publication_conflict" ? !["invalid_change", "conflict"].includes(code) : parsed.code === "record_limit_exceeded" && code !== "capacity"))
|
|
7057
7123
|
throw new Error("Invalid Data operation detail");
|
|
7058
7124
|
super(parsed && "code" in parsed && parsed.code === "local_data_publication_failed" ? dataPublicationFailureMessage(parsed) : code === "capacity" && parsed && "code" in parsed && parsed.code === "record_limit_exceeded" ? dataRecordLimitMessage(parsed) : dataErrorMessage(code, effect));
|
|
@@ -7060,7 +7126,7 @@ var DataOperationError = class extends Error {
|
|
|
7060
7126
|
this.retryable = retryable;
|
|
7061
7127
|
this.effect = effect;
|
|
7062
7128
|
this.component = component;
|
|
7063
|
-
this.detail =
|
|
7129
|
+
this.detail = detail2;
|
|
7064
7130
|
this.name = "DataOperationError", parsed !== void 0 && (this.detail = parsed);
|
|
7065
7131
|
}
|
|
7066
7132
|
code;
|
|
@@ -7095,19 +7161,19 @@ function parseConnectionFailureDetail(value) {
|
|
|
7095
7161
|
};
|
|
7096
7162
|
}
|
|
7097
7163
|
function connectionFailureMessage(value) {
|
|
7098
|
-
let
|
|
7099
|
-
${
|
|
7164
|
+
let detail2 = parseConnectionFailureDetail(value), [, provider2, name4] = identityPattern.exec(detail2.identity), duration = detail2.elapsedMs < 1e3 ? `${detail2.elapsedMs}ms` : `${(detail2.elapsedMs / 1e3).toFixed(1)}s`, explanation = `OS couldn\u2019t grant this Run access to ${providerNames[provider2]} connection ${name4}.
|
|
7165
|
+
${detail2.attempts} ${detail2.attempts === 1 ? "attempt" : "attempts"} in ${duration}.
|
|
7100
7166
|
|
|
7101
7167
|
The routine received no provider access through this lease and made no provider business request through it.`;
|
|
7102
|
-
return
|
|
7168
|
+
return detail2.code !== "attention_required" ? explanation : detail2.workspace ? `${explanation}
|
|
7103
7169
|
|
|
7104
7170
|
Check it with:
|
|
7105
|
-
os connection test --workspace ${
|
|
7171
|
+
os connection test --workspace ${detail2.workspace} --connection ${detail2.identity}` : `${explanation}
|
|
7106
7172
|
|
|
7107
7173
|
Check or reconnect this Connection.`;
|
|
7108
7174
|
}
|
|
7109
|
-
function connectionRunFailureMessage(
|
|
7110
|
-
return connectionFailureMessage(
|
|
7175
|
+
function connectionRunFailureMessage(detail2, completedWork = !1) {
|
|
7176
|
+
return connectionFailureMessage(detail2) + `
|
|
7111
7177
|
|
|
7112
7178
|
The Run stopped safely.` + (completedWork ? `
|
|
7113
7179
|
|
|
@@ -7133,26 +7199,26 @@ var ConnectionOperationError = class extends Error {
|
|
|
7133
7199
|
get status() {
|
|
7134
7200
|
return this.detail.status;
|
|
7135
7201
|
}
|
|
7136
|
-
constructor(
|
|
7202
|
+
constructor(identity4, workspace, facts2 = {
|
|
7137
7203
|
code: "invalid_response",
|
|
7138
7204
|
stage: "validation",
|
|
7139
7205
|
retryable: !1,
|
|
7140
7206
|
attempts: 0,
|
|
7141
7207
|
elapsedMs: 0
|
|
7142
7208
|
}) {
|
|
7143
|
-
let
|
|
7144
|
-
super(connectionFailureMessage(
|
|
7209
|
+
let detail2 = parseConnectionFailureDetail({ ...facts2, identity: identity4, ...workspace === void 0 ? {} : { workspace } });
|
|
7210
|
+
super(connectionFailureMessage(detail2)), this.name = "ConnectionOperationError", this.detail = detail2;
|
|
7145
7211
|
}
|
|
7146
7212
|
};
|
|
7147
7213
|
|
|
7148
7214
|
var ROUTINE_ERROR_CODE_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
7149
7215
|
function parseRoutineErrorDeclaration(value) {
|
|
7150
|
-
let
|
|
7216
|
+
let invalid19 = () => {
|
|
7151
7217
|
throw new TypeError("Invalid RoutineError");
|
|
7152
7218
|
};
|
|
7153
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
7219
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid19();
|
|
7154
7220
|
let row = value;
|
|
7155
|
-
return Object.keys(row).some((key) => !["code", "message", "retryable"].includes(key)) || !Object.hasOwn(row, "code") || !Object.hasOwn(row, "message") || typeof row.code != "string" || !ROUTINE_ERROR_CODE_PATTERN.test(row.code) || typeof row.message != "string" || !row.message || row.message.startsWith(" ") || row.message.endsWith(" ") || /[\u0000-\u001f\u007f\u0085\u2028\u2029]/.test(row.message) || /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF])/.test(row.message) || new TextEncoder().encode(row.message).byteLength > 512 || Object.hasOwn(row, "retryable") && typeof row.retryable != "boolean" ?
|
|
7221
|
+
return Object.keys(row).some((key) => !["code", "message", "retryable"].includes(key)) || !Object.hasOwn(row, "code") || !Object.hasOwn(row, "message") || typeof row.code != "string" || !ROUTINE_ERROR_CODE_PATTERN.test(row.code) || typeof row.message != "string" || !row.message || row.message.startsWith(" ") || row.message.endsWith(" ") || /[\u0000-\u001f\u007f\u0085\u2028\u2029]/.test(row.message) || /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF])/.test(row.message) || new TextEncoder().encode(row.message).byteLength > 512 || Object.hasOwn(row, "retryable") && typeof row.retryable != "boolean" ? invalid19() : { code: row.code, message: row.message, retryable: row.retryable === !0 };
|
|
7156
7222
|
}
|
|
7157
7223
|
var RoutineError = class extends Error {
|
|
7158
7224
|
code;
|
|
@@ -7169,26 +7235,26 @@ Anything the routine completed before stopping is safe.`, ROUTINE_RUN_UNCERTAIN_
|
|
|
7169
7235
|
|
|
7170
7236
|
Some work may need review before you try again. Contact support.`;
|
|
7171
7237
|
function parseRoutineAuthoredRunFailure(value) {
|
|
7172
|
-
let
|
|
7238
|
+
let invalid19 = () => {
|
|
7173
7239
|
throw new Error("Invalid authored Run failure");
|
|
7174
7240
|
};
|
|
7175
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
7241
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid19();
|
|
7176
7242
|
let row = value;
|
|
7177
|
-
if (Object.keys(row).sort().join(",") !== "code,message,retryable" || typeof row.message != "string" || typeof row.retryable != "boolean") return
|
|
7243
|
+
if (Object.keys(row).sort().join(",") !== "code,message,retryable" || typeof row.message != "string" || typeof row.retryable != "boolean") return invalid19();
|
|
7178
7244
|
let authored = row.message.endsWith(ROUTINE_RUN_UNCERTAIN_SUFFIX) ? row.message.slice(0, -ROUTINE_RUN_UNCERTAIN_SUFFIX.length) : row.message.endsWith(ROUTINE_RUN_COMPLETED_SUFFIX) ? row.message.slice(0, -ROUTINE_RUN_COMPLETED_SUFFIX.length) : row.message;
|
|
7179
7245
|
try {
|
|
7180
7246
|
parseRoutineErrorDeclaration({ code: row.code, message: authored, retryable: row.retryable });
|
|
7181
7247
|
} catch {
|
|
7182
|
-
return
|
|
7248
|
+
return invalid19();
|
|
7183
7249
|
}
|
|
7184
7250
|
return { code: row.code, message: row.message, retryable: row.retryable };
|
|
7185
7251
|
}
|
|
7186
7252
|
|
|
7187
|
-
var name2 = /^[a-z0-9][a-z0-9-]{0,62}$/, uuid3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,
|
|
7253
|
+
var name2 = /^[a-z0-9][a-z0-9-]{0,62}$/, uuid3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/, invalid6 = () => {
|
|
7188
7254
|
throw new Error("Run state unavailable");
|
|
7189
|
-
}, record2 = (value) => value && typeof value == "object" && !Array.isArray(value) ? value :
|
|
7255
|
+
}, record2 = (value) => value && typeof value == "object" && !Array.isArray(value) ? value : invalid6();
|
|
7190
7256
|
function time(value) {
|
|
7191
|
-
return typeof value != "string" || value.length > 40 || !Number.isFinite(Date.parse(value)) ?
|
|
7257
|
+
return typeof value != "string" || value.length > 40 || !Number.isFinite(Date.parse(value)) ? invalid6() : value;
|
|
7192
7258
|
}
|
|
7193
7259
|
function times(value) {
|
|
7194
7260
|
return {
|
|
@@ -7197,16 +7263,16 @@ function times(value) {
|
|
|
7197
7263
|
};
|
|
7198
7264
|
}
|
|
7199
7265
|
function bounded(value) {
|
|
7200
|
-
return assertRoutineJson(value), new TextEncoder().encode(JSON.stringify(value)).byteLength > 256 * 1024 ?
|
|
7266
|
+
return assertRoutineJson(value), new TextEncoder().encode(JSON.stringify(value)).byteLength > 256 * 1024 ? invalid6() : value;
|
|
7201
7267
|
}
|
|
7202
7268
|
function progress(value) {
|
|
7203
7269
|
if (value === void 0) return {};
|
|
7204
7270
|
let v = record2(value);
|
|
7205
|
-
return Object.keys(v).sort().join(",") !== "completed,total" || !Number.isSafeInteger(v.completed) || !Number.isSafeInteger(v.total) || v.completed < 1 || v.completed > v.total ?
|
|
7271
|
+
return Object.keys(v).sort().join(",") !== "completed,total" || !Number.isSafeInteger(v.completed) || !Number.isSafeInteger(v.total) || v.completed < 1 || v.completed > v.total ? invalid6() : { progress: { completed: v.completed, total: v.total } };
|
|
7206
7272
|
}
|
|
7207
7273
|
function parseRunStep(value, expected) {
|
|
7208
7274
|
let v = record2(value);
|
|
7209
|
-
if (typeof v.id != "string" || !name2.test(v.id) || expected !== void 0 && v.id !== expected || typeof v.title != "string" || !v.title.trim() || v.title.length > 256 || !["pending", "running", "waiting", "completed", "failed", "skipped"].includes(v.status)) return
|
|
7275
|
+
if (typeof v.id != "string" || !name2.test(v.id) || expected !== void 0 && v.id !== expected || typeof v.title != "string" || !v.title.trim() || v.title.length > 256 || !["pending", "running", "waiting", "completed", "failed", "skipped"].includes(v.status)) return invalid6();
|
|
7210
7276
|
let output = captureRetainedStepOutput(v.id, {
|
|
7211
7277
|
...Object.hasOwn(v, "summary") ? { summary: v.summary } : {},
|
|
7212
7278
|
...Object.hasOwn(v, "data") ? { data: v.data } : {}
|
|
@@ -7223,31 +7289,31 @@ function parseRunStep(value, expected) {
|
|
|
7223
7289
|
}
|
|
7224
7290
|
function parseRemoteRun(value, expected = {}) {
|
|
7225
7291
|
let v = record2(value);
|
|
7226
|
-
if (typeof v.id != "string" || !uuid3.test(v.id) || expected.id !== void 0 && v.id !== expected.id || typeof v.routine != "string" || !name2.test(v.routine) || expected.routine !== void 0 && v.routine !== expected.routine || v.placement !== "remote" || !["queued", "running", "waiting", "succeeded", "failed"].includes(v.status) || !Array.isArray(v.steps) || v.steps.length > 64) return
|
|
7292
|
+
if (typeof v.id != "string" || !uuid3.test(v.id) || expected.id !== void 0 && v.id !== expected.id || typeof v.routine != "string" || !name2.test(v.routine) || expected.routine !== void 0 && v.routine !== expected.routine || v.placement !== "remote" || !["queued", "running", "waiting", "succeeded", "failed"].includes(v.status) || !Array.isArray(v.steps) || v.steps.length > 64) return invalid6();
|
|
7227
7293
|
let steps = v.steps.map((value2) => {
|
|
7228
7294
|
let step = record2(value2);
|
|
7229
|
-
return typeof step.detailAvailable != "boolean" || Object.hasOwn(step, "data") ?
|
|
7295
|
+
return typeof step.detailAvailable != "boolean" || Object.hasOwn(step, "data") ? invalid6() : { ...parseRunStep(step), detailAvailable: step.detailAvailable };
|
|
7230
7296
|
});
|
|
7231
|
-
if (new Set(steps.map((step) => step.id)).size !== steps.length) return
|
|
7297
|
+
if (new Set(steps.map((step) => step.id)).size !== steps.length) return invalid6();
|
|
7232
7298
|
let failure;
|
|
7233
7299
|
if (v.failure !== void 0) {
|
|
7234
7300
|
let f = record2(v.failure);
|
|
7235
|
-
if (v.status !== "failed" || typeof f.message != "string" || !f.message || f.message.length > 512) return
|
|
7301
|
+
if (v.status !== "failed" || typeof f.message != "string" || !f.message || f.message.length > 512) return invalid6();
|
|
7236
7302
|
if (f.code === "step_output_too_large") {
|
|
7237
|
-
let { code, message: message2, ...facts2 } = f,
|
|
7238
|
-
if (!steps.some((step) => step.id ===
|
|
7239
|
-
failure = { code, message: message2, ...
|
|
7303
|
+
let { code, message: message2, ...facts2 } = f, detail2 = parseRoutineStepOutputDetail(facts2);
|
|
7304
|
+
if (!steps.some((step) => step.id === detail2.step && step.status === "failed") || message2 !== routineStepOutputMessage(detail2)) return invalid6();
|
|
7305
|
+
failure = { code, message: message2, ...detail2 };
|
|
7240
7306
|
} else if (f.code !== void 0 || Object.hasOwn(f, "retryable"))
|
|
7241
7307
|
try {
|
|
7242
7308
|
failure = parseRoutineAuthoredRunFailure(f);
|
|
7243
7309
|
} catch {
|
|
7244
|
-
return
|
|
7310
|
+
return invalid6();
|
|
7245
7311
|
}
|
|
7246
7312
|
else failure = { message: f.message };
|
|
7247
7313
|
}
|
|
7248
|
-
if (Object.hasOwn(v, "result") && v.status !== "succeeded") return
|
|
7314
|
+
if (Object.hasOwn(v, "result") && v.status !== "succeeded") return invalid6();
|
|
7249
7315
|
let askWait = v.askWait === void 0 ? void 0 : parseQueueAskWait(v.askWait);
|
|
7250
|
-
return askWait && askWait.runId !== v.id ?
|
|
7316
|
+
return askWait && askWait.runId !== v.id ? invalid6() : {
|
|
7251
7317
|
id: v.id,
|
|
7252
7318
|
routine: v.routine,
|
|
7253
7319
|
placement: "remote",
|
|
@@ -7255,7 +7321,7 @@ function parseRemoteRun(value, expected = {}) {
|
|
|
7255
7321
|
createdAt: time(v.createdAt),
|
|
7256
7322
|
...times(v),
|
|
7257
7323
|
steps,
|
|
7258
|
-
...v.queueItemId === void 0 ? {} : { queueItemId: typeof v.queueItemId == "string" && uuid3.test(v.queueItemId) ? v.queueItemId :
|
|
7324
|
+
...v.queueItemId === void 0 ? {} : { queueItemId: typeof v.queueItemId == "string" && uuid3.test(v.queueItemId) ? v.queueItemId : invalid6() },
|
|
7259
7325
|
...askWait === void 0 ? {} : { askWait },
|
|
7260
7326
|
...Object.hasOwn(v, "result") ? { result: bounded(v.result) } : {},
|
|
7261
7327
|
...failure ? { failure } : {}
|
|
@@ -7277,65 +7343,65 @@ function routineRunHandle(operations2) {
|
|
|
7277
7343
|
});
|
|
7278
7344
|
}
|
|
7279
7345
|
|
|
7280
|
-
var
|
|
7346
|
+
var invalid7 = () => {
|
|
7281
7347
|
throw new DataOperationError("invalid_query");
|
|
7282
7348
|
}, dataText = (value) => typeof value == "string" && !/[\u0000\uD800-\uDFFF]/u.test(value), dataVersion = (value) => dataText(value) && value.length > 0 && new TextEncoder().encode(value).length <= 1024 && !/[\u0000-\u001f\u007f-\u009f]/.test(value) && !/^[0-9a-f]{40}$/i.test(value);
|
|
7283
7349
|
function dataProperties(value) {
|
|
7284
|
-
if (!value || typeof value != "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) return
|
|
7350
|
+
if (!value || typeof value != "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) return invalid7();
|
|
7285
7351
|
let descriptors = Object.getOwnPropertyDescriptors(value);
|
|
7286
|
-
return Reflect.ownKeys(value).some((key) => typeof key != "string" || !descriptors[key]?.enumerable || !Object.hasOwn(descriptors[key], "value")) ?
|
|
7352
|
+
return Reflect.ownKeys(value).some((key) => typeof key != "string" || !descriptors[key]?.enumerable || !Object.hasOwn(descriptors[key], "value")) ? invalid7() : descriptors;
|
|
7287
7353
|
}
|
|
7288
7354
|
function dataArray(value) {
|
|
7289
|
-
if (!Array.isArray(value) || Object.getPrototypeOf(value) !== Array.prototype) return
|
|
7355
|
+
if (!Array.isArray(value) || Object.getPrototypeOf(value) !== Array.prototype) return invalid7();
|
|
7290
7356
|
let descriptors = Object.getOwnPropertyDescriptors(value);
|
|
7291
|
-
if (Reflect.ownKeys(value).length !== value.length + 1) return
|
|
7357
|
+
if (Reflect.ownKeys(value).length !== value.length + 1) return invalid7();
|
|
7292
7358
|
let result2 = [];
|
|
7293
7359
|
for (let index = 0; index < value.length; index++) {
|
|
7294
7360
|
let descriptor = descriptors[index];
|
|
7295
|
-
if (!descriptor?.enumerable || !Object.hasOwn(descriptor, "value")) return
|
|
7361
|
+
if (!descriptor?.enumerable || !Object.hasOwn(descriptor, "value")) return invalid7();
|
|
7296
7362
|
result2.push(descriptor.value);
|
|
7297
7363
|
}
|
|
7298
7364
|
return result2;
|
|
7299
7365
|
}
|
|
7300
7366
|
|
|
7301
|
-
var
|
|
7367
|
+
var invalid8 = () => {
|
|
7302
7368
|
throw new DataOperationError("invalid_query");
|
|
7303
7369
|
};
|
|
7304
7370
|
function captureRecordsBacklinksInput(ref, value) {
|
|
7305
|
-
if (!validRecordRef(ref)) return
|
|
7371
|
+
if (!validRecordRef(ref)) return invalid8();
|
|
7306
7372
|
if (value === void 0) return { ref, options: { limit: 100 } };
|
|
7307
7373
|
let descriptors = dataProperties(value);
|
|
7308
|
-
if (Object.keys(descriptors).some((key) => !["limit", "after"].includes(key))) return
|
|
7374
|
+
if (Object.keys(descriptors).some((key) => !["limit", "after"].includes(key))) return invalid8();
|
|
7309
7375
|
let options = Object.fromEntries(Object.entries(descriptors).map(([key, descriptor]) => [key, descriptor.value])), limit = Object.hasOwn(options, "limit") ? options.limit : 100;
|
|
7310
|
-
return !Number.isSafeInteger(limit) || limit < 1 || limit > 500 || Object.hasOwn(options, "after") && (!dataText(options.after) || !options.after.length || options.after.length > 16384) ?
|
|
7376
|
+
return !Number.isSafeInteger(limit) || limit < 1 || limit > 500 || Object.hasOwn(options, "after") && (!dataText(options.after) || !options.after.length || options.after.length > 16384) ? invalid8() : { ref, options: { limit, ...options.after === void 0 ? {} : { after: options.after } } };
|
|
7311
7377
|
}
|
|
7312
7378
|
|
|
7313
|
-
var
|
|
7379
|
+
var invalid9 = () => {
|
|
7314
7380
|
throw new DataOperationError("invalid_query");
|
|
7315
7381
|
};
|
|
7316
7382
|
function captureRecordsSearchInput(query, options) {
|
|
7317
|
-
if (!dataText(query)) return
|
|
7383
|
+
if (!dataText(query)) return invalid9();
|
|
7318
7384
|
let length = [...query.trim()].length;
|
|
7319
|
-
if (length < 1 || length > 256) return
|
|
7385
|
+
if (length < 1 || length > 256) return invalid9();
|
|
7320
7386
|
if (options === void 0) return { query };
|
|
7321
7387
|
let descriptors = dataProperties(options);
|
|
7322
|
-
if (Object.keys(descriptors).some((key) => !["collections", "limit"].includes(key))) return
|
|
7388
|
+
if (Object.keys(descriptors).some((key) => !["collections", "limit"].includes(key))) return invalid9();
|
|
7323
7389
|
let captured = {};
|
|
7324
7390
|
if (Object.hasOwn(descriptors, "collections")) {
|
|
7325
7391
|
let supplied = descriptors.collections.value;
|
|
7326
|
-
if (!Array.isArray(supplied) || supplied.length < 1 || supplied.length > 16 || Reflect.ownKeys(supplied).length !== supplied.length + 1) return
|
|
7392
|
+
if (!Array.isArray(supplied) || supplied.length < 1 || supplied.length > 16 || Reflect.ownKeys(supplied).length !== supplied.length + 1) return invalid9();
|
|
7327
7393
|
let collections = [];
|
|
7328
7394
|
for (let index = 0; index < supplied.length; index++) {
|
|
7329
7395
|
let descriptor = Object.getOwnPropertyDescriptor(supplied, String(index));
|
|
7330
|
-
if (!descriptor?.enumerable || !Object.hasOwn(descriptor, "value") || !dataText(descriptor.value)) return
|
|
7396
|
+
if (!descriptor?.enumerable || !Object.hasOwn(descriptor, "value") || !dataText(descriptor.value)) return invalid9();
|
|
7331
7397
|
collections.push(descriptor.value);
|
|
7332
7398
|
}
|
|
7333
|
-
if (new Set(collections).size !== collections.length) return
|
|
7399
|
+
if (new Set(collections).size !== collections.length) return invalid9();
|
|
7334
7400
|
captured.collections = collections;
|
|
7335
7401
|
}
|
|
7336
7402
|
if (Object.hasOwn(descriptors, "limit")) {
|
|
7337
7403
|
let supplied = descriptors.limit.value;
|
|
7338
|
-
if (!Number.isInteger(supplied) || supplied < 1 || supplied > 100) return
|
|
7404
|
+
if (!Number.isInteger(supplied) || supplied < 1 || supplied > 100) return invalid9();
|
|
7339
7405
|
captured.limit = supplied;
|
|
7340
7406
|
}
|
|
7341
7407
|
return { query, options: captured };
|
|
@@ -7375,21 +7441,21 @@ function captureRecordsQuery(query) {
|
|
|
7375
7441
|
return capture3(query);
|
|
7376
7442
|
}
|
|
7377
7443
|
function captureRecordsAll(query, options) {
|
|
7378
|
-
let
|
|
7444
|
+
let invalid19 = () => {
|
|
7379
7445
|
throw new DataOperationError("invalid_query");
|
|
7380
7446
|
};
|
|
7381
7447
|
try {
|
|
7382
7448
|
let properties = dataProperties(options), maxRecords = properties.maxRecords?.value;
|
|
7383
|
-
if (Object.keys(properties).join(",") !== "maxRecords" || !Number.isSafeInteger(maxRecords) || maxRecords < 1) return
|
|
7449
|
+
if (Object.keys(properties).join(",") !== "maxRecords" || !Number.isSafeInteger(maxRecords) || maxRecords < 1) return invalid19();
|
|
7384
7450
|
let detached = capture3(query), selections = dataProperties(detached);
|
|
7385
|
-
if (Object.keys(selections).length < 1 || Object.keys(selections).length > 16) return
|
|
7451
|
+
if (Object.keys(selections).length < 1 || Object.keys(selections).length > 16) return invalid19();
|
|
7386
7452
|
for (let selection2 of Object.values(selections)) {
|
|
7387
7453
|
let fields4 = dataProperties(selection2.value);
|
|
7388
|
-
if (fields4.$ && Object.hasOwn(dataProperties(fields4.$.value), "after")) return
|
|
7454
|
+
if (fields4.$ && Object.hasOwn(dataProperties(fields4.$.value), "after")) return invalid19();
|
|
7389
7455
|
}
|
|
7390
7456
|
return { query: detached, maxRecords };
|
|
7391
7457
|
} catch {
|
|
7392
|
-
return
|
|
7458
|
+
return invalid19();
|
|
7393
7459
|
}
|
|
7394
7460
|
}
|
|
7395
7461
|
|
|
@@ -7524,8 +7590,8 @@ function captureValue(value, ancestors = /* @__PURE__ */ new Set(), depth = 0) {
|
|
|
7524
7590
|
}
|
|
7525
7591
|
}
|
|
7526
7592
|
function captureDataDelete(record4) {
|
|
7527
|
-
let
|
|
7528
|
-
return !validRecordRef(
|
|
7593
|
+
let identity4 = mapping2(record4);
|
|
7594
|
+
return !validRecordRef(identity4.$ref) || typeof identity4.$version != "string" || !identity4.$version.length || identity4.$version.length > 512 ? invalidChange() : { ref: identity4.$ref, expectedVersion: identity4.$version };
|
|
7529
7595
|
}
|
|
7530
7596
|
function captureDataUpdate(record4, set) {
|
|
7531
7597
|
if (!validRecordRef(record4)) return invalidChange();
|
|
@@ -7537,11 +7603,11 @@ function captureIdentities(value, update, allowEmpty = !0) {
|
|
|
7537
7603
|
let captured = value.map((item) => {
|
|
7538
7604
|
let row = mapping2(item);
|
|
7539
7605
|
if (Object.keys(row).filter((key) => !update || !["body", "expectedVersion", "signals", "timeline"].includes(key)).sort().join(",") !== (update ? "ref,set" : "expectedVersion,ref")) return invalidChange();
|
|
7540
|
-
let
|
|
7606
|
+
let identity4 = { $ref: row.ref, $version: row.expectedVersion };
|
|
7541
7607
|
if (update && Object.keys(mapping2(row.set)).some((key) => key.startsWith("$"))) return invalidChange();
|
|
7542
|
-
if (!update) return captureDataDelete(
|
|
7608
|
+
if (!update) return captureDataDelete(identity4);
|
|
7543
7609
|
let tables = captureDataTables(row);
|
|
7544
|
-
return { ...Object.keys(mapping2(row.set)).length || Object.hasOwn(row, "body") ? captureDataUpdate(row.ref, { ...mapping2(row.set), ...Object.hasOwn(row, "body") ? { $body: row.body } : {} }) : validRecordRef(row.ref) && Object.keys(tables).length ? { ref: row.ref, set: {} } : invalidChange(), ...tables, ...Object.hasOwn(row, "expectedVersion") ? { expectedVersion: captureDataDelete(
|
|
7610
|
+
return { ...Object.keys(mapping2(row.set)).length || Object.hasOwn(row, "body") ? captureDataUpdate(row.ref, { ...mapping2(row.set), ...Object.hasOwn(row, "body") ? { $body: row.body } : {} }) : validRecordRef(row.ref) && Object.keys(tables).length ? { ref: row.ref, set: {} } : invalidChange(), ...tables, ...Object.hasOwn(row, "expectedVersion") ? { expectedVersion: captureDataDelete(identity4).expectedVersion } : {} };
|
|
7545
7611
|
});
|
|
7546
7612
|
return new Set(captured.map((item) => item.ref)).size !== captured.length ? invalidChange() : captured;
|
|
7547
7613
|
}
|
|
@@ -7592,17 +7658,17 @@ function dataTransportError(status, value) {
|
|
|
7592
7658
|
413: ["request_too_large"],
|
|
7593
7659
|
429: ["capacity"],
|
|
7594
7660
|
503: ["unavailable", "apply_pending"]
|
|
7595
|
-
}, error = value && typeof value == "object" && "error" in value ? value.error : void 0, row = error && typeof error == "object" ? error : void 0, code = failures2[status]?.find((allowed) => allowed === row?.code) ?? "unavailable", effect = ["unapplied", "uncertain", "applied"].includes(String(row?.effect)) ? row.effect : void 0,
|
|
7661
|
+
}, error = value && typeof value == "object" && "error" in value ? value.error : void 0, row = error && typeof error == "object" ? error : void 0, code = failures2[status]?.find((allowed) => allowed === row?.code) ?? "unavailable", effect = ["unapplied", "uncertain", "applied"].includes(String(row?.effect)) ? row.effect : void 0, detail2;
|
|
7596
7662
|
try {
|
|
7597
|
-
|
|
7663
|
+
detail2 = row?.detail === void 0 ? void 0 : parseDataOperationDetail(row.detail);
|
|
7598
7664
|
} catch {
|
|
7599
7665
|
}
|
|
7600
|
-
return
|
|
7666
|
+
return detail2 && ("reason" in detail2 && code !== "invalid_change" || "code" in detail2 && detail2.code === "publication_conflict" && !["invalid_change", "conflict"].includes(code)) && (detail2 = void 0), explainDataValidation(new DataOperationError(
|
|
7601
7667
|
code,
|
|
7602
7668
|
typeof row?.retryable == "boolean" ? row.retryable : ["capacity", "unavailable", "apply_pending"].includes(code),
|
|
7603
7669
|
code === "conflict" ? "unapplied" : effect,
|
|
7604
7670
|
(["invalid_change", "conflict"].includes(code) || code === "unavailable" && row?.component === "deletion_waits_for_current_data") && typeof row?.component == "string" && /^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/.test(row.component) ? row.component : void 0,
|
|
7605
|
-
|
|
7671
|
+
detail2
|
|
7606
7672
|
), row?.message, row?.detail);
|
|
7607
7673
|
}
|
|
7608
7674
|
|
|
@@ -7627,10 +7693,10 @@ function parseStoredRecordLink(value) {
|
|
|
7627
7693
|
return typeof value == "string" && value.startsWith("[[") && value.endsWith("]]") ? parseRecordLink(value.slice(2, -2)) : void 0;
|
|
7628
7694
|
}
|
|
7629
7695
|
|
|
7630
|
-
var NAME = /^[a-zA-Z][a-zA-Z0-9_-]*$/,
|
|
7696
|
+
var NAME = /^[a-zA-Z][a-zA-Z0-9_-]*$/, invalid10 = (message2) => {
|
|
7631
7697
|
throw new Error(message2);
|
|
7632
7698
|
};
|
|
7633
|
-
function parseRecordDisplay(value, definitions3, fail9 =
|
|
7699
|
+
function parseRecordDisplay(value, definitions3, fail9 = invalid10) {
|
|
7634
7700
|
if (value === void 0) return;
|
|
7635
7701
|
if (!value || typeof value != "object" || Array.isArray(value)) return fail9("Expected a field mapping");
|
|
7636
7702
|
let row = value;
|
|
@@ -8628,7 +8694,7 @@ function routineTransport() {
|
|
|
8628
8694
|
var fail3 = (code) => {
|
|
8629
8695
|
throw new RoutineOperationError(code);
|
|
8630
8696
|
}, uuid4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
8631
|
-
function
|
|
8697
|
+
function identity3(id5) {
|
|
8632
8698
|
return (typeof id5 != "string" || !uuid4.test(id5)) && fail3("invalid_input"), id5;
|
|
8633
8699
|
}
|
|
8634
8700
|
function name3(id5) {
|
|
@@ -8715,16 +8781,16 @@ function routineOperations(routine, host) {
|
|
|
8715
8781
|
pause: () => request3(`${root}/queue/pause`, summary3, {}),
|
|
8716
8782
|
resume: () => request3(`${root}/queue/resume`, summary3, {}),
|
|
8717
8783
|
list: (options = {}) => request3(`${root}/queue/items${pageOptions(options, options.states ?? [])}`, parseQueuePage, void 0, void 0, 500 * 327680),
|
|
8718
|
-
get: (id5) => request3(`${root}/queue/items/${
|
|
8784
|
+
get: (id5) => request3(`${root}/queue/items/${identity3(id5)}`, selectedItem(id5)),
|
|
8719
8785
|
async add(input, options = {}) {
|
|
8720
8786
|
(!options || Object.keys(options).some((key) => key !== "idempotencyKey") || options.idempotencyKey !== void 0 && typeof options.idempotencyKey != "string") && fail3("invalid_input");
|
|
8721
8787
|
let body = { input, ...options };
|
|
8722
8788
|
return new TextEncoder().encode(json2(input)).byteLength > 262144 && fail3("invalid_input"), host ? request3(`${root}/queue/items`, selectedItem(), body) : managedQueue("queue/add", { routineId: routine, ...body }, selectedItem(), !0);
|
|
8723
8789
|
},
|
|
8724
8790
|
async remove(id5) {
|
|
8725
|
-
return id5 =
|
|
8791
|
+
return id5 = identity3(id5), host ? request3(`${root}/queue/items/${id5}/remove`, selectedItem(id5), {}) : managedQueue("queue/remove", { routineId: routine, itemId: id5 }, selectedItem(id5));
|
|
8726
8792
|
},
|
|
8727
|
-
retry: (id5, options) => ((!options || Object.keys(options).join() !== "failureId") && fail3("invalid_input"),
|
|
8793
|
+
retry: (id5, options) => ((!options || Object.keys(options).join() !== "failureId") && fail3("invalid_input"), identity3(options.failureId), request3(`${root}/queue/items/${identity3(id5)}/retry`, selectedItem(id5), options))
|
|
8728
8794
|
},
|
|
8729
8795
|
queries: {
|
|
8730
8796
|
list: () => request3(`${root}/queries`, (value) => Array.isArray(value) ? value.map((v) => {
|
|
@@ -8737,7 +8803,7 @@ function routineOperations(routine, host) {
|
|
|
8737
8803
|
let result2 = parseQueryExecution(value);
|
|
8738
8804
|
return (result2.queryId !== query || id5 !== void 0 && result2.id !== id5) && fail3("unavailable"), result2;
|
|
8739
8805
|
}, handle2 = (id5) => {
|
|
8740
|
-
|
|
8806
|
+
identity3(id5);
|
|
8741
8807
|
let read2 = () => request3(`${path}/executions/${id5}`, execution(id5));
|
|
8742
8808
|
return Object.freeze({ current: read2, async *watch() {
|
|
8743
8809
|
let previous;
|
|
@@ -8767,7 +8833,7 @@ function routineOperations(routine, host) {
|
|
|
8767
8833
|
runs: {
|
|
8768
8834
|
list: () => request3(`${root}/runs`, (value) => !Array.isArray(value) || value.length > 20 ? fail3("unavailable") : value.map(readRun()), void 0, void 0, 340 * 1024 * 1024),
|
|
8769
8835
|
async get(id5) {
|
|
8770
|
-
return
|
|
8836
|
+
return identity3(id5), current2(), runHandle(id5);
|
|
8771
8837
|
}
|
|
8772
8838
|
},
|
|
8773
8839
|
async run(input) {
|
|
@@ -8799,18 +8865,17 @@ function inspectRoutineQueueReference(queue) {
|
|
|
8799
8865
|
return id5;
|
|
8800
8866
|
}
|
|
8801
8867
|
|
|
8802
|
-
var definitions2 = /* @__PURE__ */ new WeakMap(),
|
|
8868
|
+
var definitions2 = /* @__PURE__ */ new WeakMap(), invalid11 = () => {
|
|
8803
8869
|
throw new AppRoutineContractError("invalid_contract");
|
|
8804
8870
|
}, defineQuery = (definition) => {
|
|
8805
|
-
if (assertRoutineFields(definition, ["id", "queue", "triggers", "access", "run"]), !isAppRoutineName(definition.id) || typeof definition.run != "function") return
|
|
8806
|
-
let routineId = inspectRoutineQueueReference(definition.queue), triggers;
|
|
8871
|
+
if (assertRoutineFields(definition, ["id", "queue", "triggers", "access", "run"]), !isAppRoutineName(definition.id) || typeof definition.run != "function") return invalid11();
|
|
8872
|
+
let routineId = inspectRoutineQueueReference(definition.queue), access = parseRoutineAccess(definition.access), triggers;
|
|
8807
8873
|
try {
|
|
8808
|
-
|
|
8809
|
-
triggers = definition.triggers.map((trigger) => (assertRoutineFields(trigger, ["schedule"]), { schedule: parseRoutineSchedule(trigger.schedule) }));
|
|
8874
|
+
triggers = parseQueryTriggers(definition.triggers, access);
|
|
8810
8875
|
} catch {
|
|
8811
|
-
return
|
|
8876
|
+
return invalid11();
|
|
8812
8877
|
}
|
|
8813
|
-
let
|
|
8878
|
+
let contract = freezeRoutineMetadata({ id: definition.id, routineId, access, triggers }), captured = Object.freeze({ ...definition, access, triggers: contract.triggers });
|
|
8814
8879
|
return definitions2.set(captured, contract), captured;
|
|
8815
8880
|
};
|
|
8816
8881
|
|
|
@@ -8917,14 +8982,14 @@ function checked(workspace, endpoint, headers) {
|
|
|
8917
8982
|
return { url: `${origin.origin}/api/data`, headers: { ...headers, "x-os-workspace": workspace } };
|
|
8918
8983
|
}
|
|
8919
8984
|
|
|
8920
|
-
var
|
|
8985
|
+
var invalid12 = () => {
|
|
8921
8986
|
throw new DataOperationError("invalid_query");
|
|
8922
8987
|
}, unavailable = () => {
|
|
8923
8988
|
throw new DataOperationError("unavailable");
|
|
8924
8989
|
}, text3 = (value) => typeof value == "string" && value.length > 0;
|
|
8925
8990
|
function capture4(value, ancestors = /* @__PURE__ */ new Set(), depth = 0) {
|
|
8926
8991
|
if (value === null || typeof value == "string" || typeof value == "boolean" || typeof value == "number" && Number.isFinite(value)) return value;
|
|
8927
|
-
if (!value || typeof value != "object" || ancestors.has(value) || depth > 32) return
|
|
8992
|
+
if (!value || typeof value != "object" || ancestors.has(value) || depth > 32) return invalid12();
|
|
8928
8993
|
ancestors.add(value);
|
|
8929
8994
|
try {
|
|
8930
8995
|
return Array.isArray(value) ? dataArray(value).map((item) => capture4(item, ancestors, depth + 1)) : Object.fromEntries(Object.entries(dataProperties(value)).map(([key, descriptor]) => [key, capture4(descriptor.value, ancestors, depth + 1)]));
|
|
@@ -8939,7 +9004,7 @@ function recordPagination(queryRecords) {
|
|
|
8939
9004
|
let selection2 = dataProperties(captured[name4]);
|
|
8940
9005
|
if (Object.hasOwn(selection2, "$")) {
|
|
8941
9006
|
let options = dataProperties(selection2.$.value);
|
|
8942
|
-
if (Object.hasOwn(options, "after")) return
|
|
9007
|
+
if (Object.hasOwn(options, "after")) return invalid12();
|
|
8943
9008
|
}
|
|
8944
9009
|
}
|
|
8945
9010
|
return iterate();
|
|
@@ -9447,9 +9512,9 @@ function cursorPosition(value, binding, limit) {
|
|
|
9447
9512
|
return Object.keys(payload).length !== 4 || payload.format !== 1 || payload.binding !== binding || typeof position != "number" || !Number.isSafeInteger(position) || position <= 0 || position % limit !== 0 || typeof ref != "string" || !validRecordRef(ref) ? fail5("incompatible cursor") : { position, ref };
|
|
9448
9513
|
}
|
|
9449
9514
|
|
|
9450
|
-
var
|
|
9515
|
+
var invalid13 = () => {
|
|
9451
9516
|
throw new DataOperationError("unavailable", !0);
|
|
9452
|
-
}, object7 = (value) => !value || typeof value != "object" || Array.isArray(value) ?
|
|
9517
|
+
}, object7 = (value) => !value || typeof value != "object" || Array.isArray(value) ? invalid13() : value, keys4 = (value, expected) => Object.keys(value).sort().join(",") === expected, hash = (value) => typeof value == "string" && /^[0-9a-f]{40}$/.test(value), time2 = (value) => typeof value == "string" && /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?(?:Z|[+-]\d\d:\d\d)$/.test(value) && Number.isFinite(Date.parse(value)), sorted = (values) => values.every((value, i) => i === 0 || values[i - 1] < value);
|
|
9453
9518
|
function json3(value) {
|
|
9454
9519
|
if (!(value === null || typeof value == "boolean" || typeof value == "number" && Number.isFinite(value) || dataText(value))) {
|
|
9455
9520
|
if (Array.isArray(value)) {
|
|
@@ -9457,7 +9522,7 @@ function json3(value) {
|
|
|
9457
9522
|
return;
|
|
9458
9523
|
}
|
|
9459
9524
|
for (let [key, item] of Object.entries(object7(value))) {
|
|
9460
|
-
if (!dataText(key)) return
|
|
9525
|
+
if (!dataText(key)) return invalid13();
|
|
9461
9526
|
json3(item);
|
|
9462
9527
|
}
|
|
9463
9528
|
}
|
|
@@ -9469,66 +9534,66 @@ var slot = (values, field) => Object.hasOwn(values, field) ? { present: !0, valu
|
|
|
9469
9534
|
function apply(book, event) {
|
|
9470
9535
|
let records = book.get(event.collection), prior = records.get(event.ref);
|
|
9471
9536
|
if (event.kind === "create") {
|
|
9472
|
-
if (prior) return
|
|
9537
|
+
if (prior) return invalid13();
|
|
9473
9538
|
records.set(event.ref, structuredClone(event.values));
|
|
9474
9539
|
} else if (event.kind === "delete") {
|
|
9475
|
-
if (!prior || stable(prior) !== stable(event.values)) return
|
|
9540
|
+
if (!prior || stable(prior) !== stable(event.values)) return invalid13();
|
|
9476
9541
|
records.delete(event.ref);
|
|
9477
9542
|
} else if (event.kind === "rename") {
|
|
9478
9543
|
let before = records.get(event.previousRef);
|
|
9479
|
-
if (!before || prior) return
|
|
9544
|
+
if (!before || prior) return invalid13();
|
|
9480
9545
|
records.delete(event.previousRef), records.set(event.ref, before);
|
|
9481
9546
|
} else if (event.kind === "update") {
|
|
9482
|
-
if (!prior || stable(slot(prior, event.field)) !== stable(event.before) || stable(event.before) === stable(event.after)) return
|
|
9547
|
+
if (!prior || stable(slot(prior, event.field)) !== stable(event.before) || stable(event.before) === stable(event.after)) return invalid13();
|
|
9483
9548
|
event.after.present ? Object.defineProperty(prior, event.field, { value: structuredClone(event.after.value), enumerable: !0, configurable: !0, writable: !0 }) : delete prior[event.field];
|
|
9484
9549
|
}
|
|
9485
9550
|
}
|
|
9486
9551
|
function validateSnapshotHistory(input, collections, version) {
|
|
9487
9552
|
let row = object7(input), selections = object7(row.fields);
|
|
9488
|
-
if (!keys4(row, "commits,fields,through") || !hash(row.through) || version !== `current-${row.through}` || !Array.isArray(row.commits) || !row.commits.length || !Object.keys(selections).length || !sorted(Object.keys(selections))) return
|
|
9553
|
+
if (!keys4(row, "commits,fields,through") || !hash(row.through) || version !== `current-${row.through}` || !Array.isArray(row.commits) || !row.commits.length || !Object.keys(selections).length || !sorted(Object.keys(selections))) return invalid13();
|
|
9489
9554
|
let book = /* @__PURE__ */ new Map();
|
|
9490
9555
|
for (let [collection, selection2] of Object.entries(selections)) {
|
|
9491
9556
|
let selected = object7(selection2), fields4 = selected.fields;
|
|
9492
|
-
if (!Object.hasOwn(collections, collection) || !keys4(selected, "fields") || !Array.isArray(fields4) || !fields4.length || fields4.some((field) => typeof field != "string" || !/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(field)) || !sorted(fields4)) return
|
|
9557
|
+
if (!Object.hasOwn(collections, collection) || !keys4(selected, "fields") || !Array.isArray(fields4) || !fields4.length || fields4.some((field) => typeof field != "string" || !/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(field)) || !sorted(fields4)) return invalid13();
|
|
9493
9558
|
book.set(collection, /* @__PURE__ */ new Map());
|
|
9494
9559
|
}
|
|
9495
9560
|
let history = row, seen = /* @__PURE__ */ new Set(), parent = null;
|
|
9496
9561
|
for (let group of history.commits) {
|
|
9497
|
-
if (!keys4(object7(group), "authoredAt,commit,committedAt,events,firstParent") || !hash(group.commit) || seen.has(group.commit) || group.firstParent !== parent || !time2(group.authoredAt) || !time2(group.committedAt) || !Array.isArray(group.events)) return
|
|
9562
|
+
if (!keys4(object7(group), "authoredAt,commit,committedAt,events,firstParent") || !hash(group.commit) || seen.has(group.commit) || group.firstParent !== parent || !time2(group.authoredAt) || !time2(group.committedAt) || !Array.isArray(group.events)) return invalid13();
|
|
9498
9563
|
seen.add(group.commit), parent = group.commit;
|
|
9499
9564
|
let previous, created = /* @__PURE__ */ new Set();
|
|
9500
9565
|
for (let event of group.events) {
|
|
9501
|
-
if (object7(event), !book.has(event.collection) || !validRecordRef(event.ref) || !event.ref.startsWith(`${event.collection}/`)) return
|
|
9566
|
+
if (object7(event), !book.has(event.collection) || !validRecordRef(event.ref) || !event.ref.startsWith(`${event.collection}/`)) return invalid13();
|
|
9502
9567
|
let fields4 = history.fields[event.collection].fields;
|
|
9503
9568
|
if (event.kind === "create" || event.kind === "delete") {
|
|
9504
|
-
if (!keys4(event, "collection,kind,ref,values") || Object.keys(object7(event.values)).some((field) => !fields4.includes(field))) return
|
|
9569
|
+
if (!keys4(event, "collection,kind,ref,values") || Object.keys(object7(event.values)).some((field) => !fields4.includes(field))) return invalid13();
|
|
9505
9570
|
json3(event.values), event.kind === "create" && created.add(event.ref);
|
|
9506
9571
|
} else if (event.kind === "rename") {
|
|
9507
|
-
if (!keys4(event, "collection,kind,previousRef,ref") || !validRecordRef(event.previousRef) || !event.previousRef.startsWith(`${event.collection}/`) || event.previousRef === event.ref) return
|
|
9572
|
+
if (!keys4(event, "collection,kind,previousRef,ref") || !validRecordRef(event.previousRef) || !event.previousRef.startsWith(`${event.collection}/`) || event.previousRef === event.ref) return invalid13();
|
|
9508
9573
|
} else if (event.kind === "update") {
|
|
9509
|
-
if (!keys4(event, "after,before,collection,field,kind,ref") || !fields4.includes(event.field) || created.has(event.ref)) return
|
|
9574
|
+
if (!keys4(event, "after,before,collection,field,kind,ref") || !fields4.includes(event.field) || created.has(event.ref)) return invalid13();
|
|
9510
9575
|
for (let value of [event.before, event.after]) {
|
|
9511
|
-
if (object7(value), value.present === !1 ? !keys4(value, "present") : value.present !== !0 || !keys4(value, "present,value")) return
|
|
9576
|
+
if (object7(value), value.present === !1 ? !keys4(value, "present") : value.present !== !0 || !keys4(value, "present,value")) return invalid13();
|
|
9512
9577
|
value.present && json3(value.value);
|
|
9513
9578
|
}
|
|
9514
|
-
} else return
|
|
9579
|
+
} else return invalid13();
|
|
9515
9580
|
let order = [event.kind === "delete" ? 0 : 1, event.ref, event.kind === "update" ? 1 : 0, event.kind === "update" ? event.field : ""];
|
|
9516
9581
|
if (previous) {
|
|
9517
9582
|
let index = order.findIndex((value, i) => value !== previous[i]);
|
|
9518
|
-
if (index === -1 || order[index] < previous[index]) return
|
|
9583
|
+
if (index === -1 || order[index] < previous[index]) return invalid13();
|
|
9519
9584
|
}
|
|
9520
9585
|
previous = order, apply(book, event);
|
|
9521
9586
|
}
|
|
9522
9587
|
let refs = /* @__PURE__ */ new Set();
|
|
9523
9588
|
for (let records of book.values()) for (let ref of records.keys()) {
|
|
9524
|
-
if (refs.has(ref)) return
|
|
9589
|
+
if (refs.has(ref)) return invalid13();
|
|
9525
9590
|
refs.add(ref);
|
|
9526
9591
|
}
|
|
9527
9592
|
}
|
|
9528
|
-
if (parent !== history.through) return
|
|
9593
|
+
if (parent !== history.through) return invalid13();
|
|
9529
9594
|
for (let [collection, records] of book) {
|
|
9530
9595
|
let expected = collections[collection].map((record4) => [record4.$ref, Object.fromEntries(history.fields[collection].fields.filter((field) => Object.hasOwn(record4, field)).map((field) => [field, record4[field]]))]);
|
|
9531
|
-
if (stable([...records].sort(([a], [b]) => a < b ? -1 : 1)) !== stable(expected)) return
|
|
9596
|
+
if (stable([...records].sort(([a], [b]) => a < b ? -1 : 1)) !== stable(expected)) return invalid13();
|
|
9532
9597
|
}
|
|
9533
9598
|
return history;
|
|
9534
9599
|
}
|
|
@@ -9555,33 +9620,33 @@ function readSnapshotHistory(history, input, operation2) {
|
|
|
9555
9620
|
};
|
|
9556
9621
|
}
|
|
9557
9622
|
|
|
9558
|
-
var snapshotCollection = (catalogue, ref) => catalogue.filter((c) => ref.startsWith(`${c.name}/`)).sort((a, b) => b.name.length - a.name.length)[0],
|
|
9623
|
+
var snapshotCollection = (catalogue, ref) => catalogue.filter((c) => ref.startsWith(`${c.name}/`)).sort((a, b) => b.name.length - a.name.length)[0], invalid14 = () => {
|
|
9559
9624
|
throw new DataOperationError("unavailable", !0);
|
|
9560
|
-
}, object8 = (value) => !value || typeof value != "object" || Array.isArray(value) ?
|
|
9625
|
+
}, object8 = (value) => !value || typeof value != "object" || Array.isArray(value) ? invalid14() : value;
|
|
9561
9626
|
function stable2(value) {
|
|
9562
9627
|
return Array.isArray(value) ? `[${value.map(stable2).join(",")}]` : value && typeof value == "object" ? `{${Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, entry]) => `${JSON.stringify(key)}:${stable2(entry)}`).join(",")}}` : JSON.stringify(value);
|
|
9563
9628
|
}
|
|
9564
9629
|
function schemaText(value) {
|
|
9565
|
-
if (typeof value == "string" && !dataText(value)) return
|
|
9630
|
+
if (typeof value == "string" && !dataText(value)) return invalid14();
|
|
9566
9631
|
if (value && typeof value == "object") for (let [key, entry] of Object.entries(value)) {
|
|
9567
|
-
if (!dataText(key)) return
|
|
9632
|
+
if (!dataText(key)) return invalid14();
|
|
9568
9633
|
schemaText(entry);
|
|
9569
9634
|
}
|
|
9570
9635
|
}
|
|
9571
9636
|
function validateSnapshotEnvelope(input, repository, name4, bodies = [], timelines = []) {
|
|
9572
9637
|
try {
|
|
9573
9638
|
let row = object8(input), legacy = row.format === "data-snapshot.v1";
|
|
9574
|
-
if (!["collections,format,name,repository,schemas,version", "collections,format,history,name,repository,schemas,version"].includes(Object.keys(row).sort().join(",")) || !legacy && row.format !== "data-snapshot.v2" || legacy && timelines.length > 0 || row.repository !== repository || row.name !== name4 || !dataVersion(row.version)) return
|
|
9639
|
+
if (!["collections,format,name,repository,schemas,version", "collections,format,history,name,repository,schemas,version"].includes(Object.keys(row).sort().join(",")) || !legacy && row.format !== "data-snapshot.v2" || legacy && timelines.length > 0 || row.repository !== repository || row.name !== name4 || !dataVersion(row.version)) return invalid14();
|
|
9575
9640
|
let schemas2 = object8(row.schemas), collections = object8(row.collections);
|
|
9576
9641
|
schemaText(schemas2);
|
|
9577
9642
|
let names = Object.keys(collections);
|
|
9578
|
-
for (let subset of [bodies, timelines]) if (new Set(subset).size !== subset.length || subset.some((name5) => !names.includes(name5))) return
|
|
9579
|
-
if (!names.length || names.join("\0") !== [...names].sort().join("\0") || Object.keys(schemas2).join("\0") !== names.join("\0")) return
|
|
9643
|
+
for (let subset of [bodies, timelines]) if (new Set(subset).size !== subset.length || subset.some((name5) => !names.includes(name5))) return invalid14();
|
|
9644
|
+
if (!names.length || names.join("\0") !== [...names].sort().join("\0") || Object.keys(schemas2).join("\0") !== names.join("\0")) return invalid14();
|
|
9580
9645
|
let catalogue = names.map((name5) => {
|
|
9581
9646
|
let schema2 = object8(schemas2[name5]);
|
|
9582
|
-
if (!validRecordRef(`${name5}/example`) || schema2.name !== name5 || typeof schema2.type != "string" || !/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(schema2.type) || schema2.description !== void 0 && !dataText(schema2.description) || Object.keys(schema2).some((key) => !["name", "type", "description", "display", "fields"].includes(key))) return
|
|
9647
|
+
if (!validRecordRef(`${name5}/example`) || schema2.name !== name5 || typeof schema2.type != "string" || !/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(schema2.type) || schema2.description !== void 0 && !dataText(schema2.description) || Object.keys(schema2).some((key) => !["name", "type", "description", "display", "fields"].includes(key))) return invalid14();
|
|
9583
9648
|
let definitions3 = fields2(schema2.fields, 0, !0);
|
|
9584
|
-
if (stable2(definitions3.map(publicField)) !== stable2(schema2.fields)) return
|
|
9649
|
+
if (stable2(definitions3.map(publicField)) !== stable2(schema2.fields)) return invalid14();
|
|
9585
9650
|
let display = parseRecordDisplay2(schema2.display, definitions3);
|
|
9586
9651
|
return { name: name5, schema: {
|
|
9587
9652
|
type: schema2.type,
|
|
@@ -9592,23 +9657,23 @@ function validateSnapshotEnvelope(input, repository, name4, bodies = [], timelin
|
|
|
9592
9657
|
}), types = /* @__PURE__ */ new Map();
|
|
9593
9658
|
for (let collection of catalogue) {
|
|
9594
9659
|
let records = collections[collection.name];
|
|
9595
|
-
if (!Array.isArray(records)) return
|
|
9660
|
+
if (!Array.isArray(records)) return invalid14();
|
|
9596
9661
|
let previous = "";
|
|
9597
9662
|
for (let record4 of records) {
|
|
9598
9663
|
let value = object8(record4);
|
|
9599
|
-
if (!validRecordRef(value.$ref) || snapshotCollection(catalogue, value.$ref)?.name !== collection.name || value.$ref <= previous || types.has(value.$ref) || typeof value.$version != "string" || !/^record-v1:[0-9a-f]{64}$/.test(value.$version)) return
|
|
9664
|
+
if (!validRecordRef(value.$ref) || snapshotCollection(catalogue, value.$ref)?.name !== collection.name || value.$ref <= previous || types.has(value.$ref) || typeof value.$version != "string" || !/^record-v1:[0-9a-f]{64}$/.test(value.$version)) return invalid14();
|
|
9600
9665
|
types.set(value.$ref, collection.schema.type), previous = value.$ref;
|
|
9601
9666
|
}
|
|
9602
9667
|
}
|
|
9603
9668
|
for (let collection of catalogue) for (let record4 of collections[collection.name]) {
|
|
9604
9669
|
let { $ref: _ref, $version: _version, $body, $signals, $timeline, ...values } = record4;
|
|
9605
9670
|
if (legacy) {
|
|
9606
|
-
if (Object.hasOwn(record4, "$signals") || Object.hasOwn(record4, "$timeline")) return
|
|
9671
|
+
if (Object.hasOwn(record4, "$signals") || Object.hasOwn(record4, "$timeline")) return invalid14();
|
|
9607
9672
|
} else if (captureRecordSignals($signals), timelines.includes(collection.name)) {
|
|
9608
|
-
if (!Array.isArray($timeline)) return
|
|
9673
|
+
if (!Array.isArray($timeline)) return invalid14();
|
|
9609
9674
|
$timeline.forEach((value) => captureTimeline(value));
|
|
9610
|
-
} else if (Object.hasOwn(record4, "$timeline")) return
|
|
9611
|
-
if (Object.hasOwn(record4, "$body") && (!bodies.includes(collection.name) || typeof $body != "string")) return
|
|
9675
|
+
} else if (Object.hasOwn(record4, "$timeline")) return invalid14();
|
|
9676
|
+
if (Object.hasOwn(record4, "$body") && (!bodies.includes(collection.name) || typeof $body != "string")) return invalid14();
|
|
9612
9677
|
validateRecordFields(values, collection.schema.fields, (ref, targets2) => types.get(ref) ?? targets2[0], !0);
|
|
9613
9678
|
}
|
|
9614
9679
|
let normalized = legacy ? Object.fromEntries(Object.entries(collections).map(([collection, records]) => [
|
|
@@ -9627,7 +9692,7 @@ function validateSnapshotEnvelope(input, repository, name4, bodies = [], timelin
|
|
|
9627
9692
|
...Object.hasOwn(row, "history") ? { history: validateSnapshotHistory(row.history, normalized, row.version) } : {}
|
|
9628
9693
|
};
|
|
9629
9694
|
} catch {
|
|
9630
|
-
return
|
|
9695
|
+
return invalid14();
|
|
9631
9696
|
}
|
|
9632
9697
|
}
|
|
9633
9698
|
|
|
@@ -9765,14 +9830,14 @@ function* evaluateRecordsQuery(query, catalogue, context, maxRecords, cloneValue
|
|
|
9765
9830
|
|
|
9766
9831
|
var snapshotAcquisitionType = "application/vnd.os.data-snapshot.v2+json", snapshotAcquisitionFormat = "data-snapshot-acquisition.v2", snapshotPairHeader = "Snapshot-Pair", validSnapshotPairToken = (value) => typeof value == "string" && /^snapshot-pair-v1:[0-9a-f]{64}$/.test(value), snapshotArtifactHeader = "Snapshot-Artifact", validSnapshotArtifactToken = (value) => typeof value == "string" && /^snapshot-artifact-v1:[0-9a-f]{64}$/.test(value), snapshotUpdatesProtocol = "os.data-snapshot.updates.v1", snapshotUpdatesCredentialPrefix = "os.member.", snapshotUpdateHint = "update";
|
|
9767
9832
|
|
|
9768
|
-
var
|
|
9833
|
+
var invalid15 = () => {
|
|
9769
9834
|
throw new DataOperationError("unavailable", !0);
|
|
9770
|
-
}, object9 = (v) => v && typeof v == "object" && !Array.isArray(v) ? v :
|
|
9835
|
+
}, object9 = (v) => v && typeof v == "object" && !Array.isArray(v) ? v : invalid15(), uuid5 = (v) => typeof v == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(v), time3 = (v) => typeof v == "string" && Number.isFinite(Date.parse(v)), recordVersion = (v) => typeof v == "string" && /^record-v1:[0-9a-f]{64}$/.test(v), keys5 = (v, allowed) => Object.keys(v).every((k) => allowed.includes(k));
|
|
9771
9836
|
function validateAcquisition(input, repository, name4) {
|
|
9772
9837
|
let row = object9(input), snapshot = object9(row.snapshot);
|
|
9773
|
-
if (Object.keys(row).sort().join(",") !== "changes,format,snapshot" || row.format !== snapshotAcquisitionFormat || !keys5(snapshot, ["id", "name", "refreshedAt", "repository", "version", "collections", "bodies", "timelines"]) || !uuid5(snapshot.id) || snapshot.repository !== repository || snapshot.name !== name4 || !dataVersion(snapshot.version) || !time3(snapshot.refreshedAt) || !Array.isArray(snapshot.collections) || !snapshot.collections.length || !snapshot.collections.every((c) => typeof c == "string" && validRecordRef(`${c}/example`)) || snapshot.collections.join("\0") !== [...new Set(snapshot.collections)].sort().join("\0") || !Array.isArray(row.changes)) return
|
|
9838
|
+
if (Object.keys(row).sort().join(",") !== "changes,format,snapshot" || row.format !== snapshotAcquisitionFormat || !keys5(snapshot, ["id", "name", "refreshedAt", "repository", "version", "collections", "bodies", "timelines"]) || !uuid5(snapshot.id) || snapshot.repository !== repository || snapshot.name !== name4 || !dataVersion(snapshot.version) || !time3(snapshot.refreshedAt) || !Array.isArray(snapshot.collections) || !snapshot.collections.length || !snapshot.collections.every((c) => typeof c == "string" && validRecordRef(`${c}/example`)) || snapshot.collections.join("\0") !== [...new Set(snapshot.collections)].sort().join("\0") || !Array.isArray(row.changes)) return invalid15();
|
|
9774
9839
|
let bodies = snapshot.bodies === void 0 ? [] : snapshot.bodies, timelines = snapshot.timelines === void 0 ? [] : snapshot.timelines;
|
|
9775
|
-
for (let subset of [bodies, timelines]) if (!Array.isArray(subset) || subset.some((c) => !snapshot.collections.includes(c)) || subset.join("\0") !== [...new Set(subset)].sort().join("\0")) return
|
|
9840
|
+
for (let subset of [bodies, timelines]) if (!Array.isArray(subset) || subset.some((c) => !snapshot.collections.includes(c)) || subset.join("\0") !== [...new Set(subset)].sort().join("\0")) return invalid15();
|
|
9776
9841
|
return {
|
|
9777
9842
|
snapshot: { ...snapshot, bodies, timelines },
|
|
9778
9843
|
changes: validateSnapshotChanges(row.changes, snapshot.collections)
|
|
@@ -9780,47 +9845,47 @@ function validateAcquisition(input, repository, name4) {
|
|
|
9780
9845
|
}
|
|
9781
9846
|
function validateSnapshotChanges(input, collections) {
|
|
9782
9847
|
try {
|
|
9783
|
-
if (!Array.isArray(input)) return
|
|
9848
|
+
if (!Array.isArray(input)) return invalid15();
|
|
9784
9849
|
let ids = /* @__PURE__ */ new Set(), unpublished = !1;
|
|
9785
9850
|
for (let value of input) {
|
|
9786
9851
|
let c = object9(value), effect = object9(c.effect);
|
|
9787
|
-
if (!keys5(c, ["id", "version", "ref", "recordVersion", "effect", "updatedAt", "person", "source", "publication"]) || !uuid5(c.id) || ids.has(c.id) || !dataVersion(c.version) || !validRecordRef(c.ref) || !collections.some((name4) => c.ref.startsWith(`${name4}/`)) || !recordVersion(c.recordVersion) || !time3(c.updatedAt)) return
|
|
9852
|
+
if (!keys5(c, ["id", "version", "ref", "recordVersion", "effect", "updatedAt", "person", "source", "publication"]) || !uuid5(c.id) || ids.has(c.id) || !dataVersion(c.version) || !validRecordRef(c.ref) || !collections.some((name4) => c.ref.startsWith(`${name4}/`)) || !recordVersion(c.recordVersion) || !time3(c.updatedAt)) return invalid15();
|
|
9788
9853
|
if (ids.add(c.id), c.person !== void 0) {
|
|
9789
9854
|
let person = object9(c.person);
|
|
9790
|
-
if (!keys5(person, ["id", "name", "email"]) || !uuid5(person.id) || person.name !== void 0 && !dataText(person.name) || person.email !== void 0 && !dataText(person.email)) return
|
|
9855
|
+
if (!keys5(person, ["id", "name", "email"]) || !uuid5(person.id) || person.name !== void 0 && !dataText(person.name) || person.email !== void 0 && !dataText(person.email)) return invalid15();
|
|
9791
9856
|
}
|
|
9792
9857
|
if (c.source !== void 0) {
|
|
9793
9858
|
let source2 = object9(c.source);
|
|
9794
|
-
if (Object.keys(source2).sort().join(",") !== "id,kind" || source2.kind !== "app" && source2.kind !== "routine" || !dataText(source2.id)) return
|
|
9859
|
+
if (Object.keys(source2).sort().join(",") !== "id,kind" || source2.kind !== "app" && source2.kind !== "routine" || !dataText(source2.id)) return invalid15();
|
|
9795
9860
|
}
|
|
9796
9861
|
if (c.publication !== void 0) {
|
|
9797
9862
|
let publication = object9(c.publication);
|
|
9798
|
-
if (unpublished || Object.keys(publication).sort().join(",") !== "commit,time" || typeof publication.commit != "string" || !/^[0-9a-f]{40}$/.test(publication.commit) || !time3(publication.time)) return
|
|
9863
|
+
if (unpublished || Object.keys(publication).sort().join(",") !== "commit,time" || typeof publication.commit != "string" || !/^[0-9a-f]{40}$/.test(publication.commit) || !time3(publication.time)) return invalid15();
|
|
9799
9864
|
} else unpublished = !0;
|
|
9800
9865
|
if (effect.kind === "set") {
|
|
9801
|
-
if (Object.keys(effect).sort().join(",") !== "field,kind,value" || !dataText(effect.field) || effect.field.startsWith("$") || ["id", "type", "__proto__", "constructor", "prototype"].includes(effect.field)) return
|
|
9866
|
+
if (Object.keys(effect).sort().join(",") !== "field,kind,value" || !dataText(effect.field) || effect.field.startsWith("$") || ["id", "type", "__proto__", "constructor", "prototype"].includes(effect.field)) return invalid15();
|
|
9802
9867
|
} else if (effect.kind === "link" || effect.kind === "unlink") {
|
|
9803
|
-
if (!keys5(effect, ["kind", "field", "refs", ...effect.kind === "link" ? ["remove"] : []]) || !dataText(effect.field) || effect.field.startsWith("$") || ["id", "type", "__proto__", "constructor", "prototype"].includes(effect.field) || !Array.isArray(effect.refs) || !effect.refs.length || effect.refs.length > 1e5 || effect.refs.some((ref) => !validRecordRef(ref)) || new Set(effect.refs).size !== effect.refs.length || effect.remove !== void 0 && (!Array.isArray(effect.remove) || !effect.remove.length || effect.remove.length > 1e5 || effect.remove.some((ref) => !validRecordRef(ref)) || new Set(effect.remove).size !== effect.remove.length)) return
|
|
9868
|
+
if (!keys5(effect, ["kind", "field", "refs", ...effect.kind === "link" ? ["remove"] : []]) || !dataText(effect.field) || effect.field.startsWith("$") || ["id", "type", "__proto__", "constructor", "prototype"].includes(effect.field) || !Array.isArray(effect.refs) || !effect.refs.length || effect.refs.length > 1e5 || effect.refs.some((ref) => !validRecordRef(ref)) || new Set(effect.refs).size !== effect.refs.length || effect.remove !== void 0 && (!Array.isArray(effect.remove) || !effect.remove.length || effect.remove.length > 1e5 || effect.remove.some((ref) => !validRecordRef(ref)) || new Set(effect.remove).size !== effect.remove.length)) return invalid15();
|
|
9804
9869
|
} else if (effect.kind === "signal") {
|
|
9805
|
-
if (Object.keys(effect).sort().join(",") !== "key,kind,value") return
|
|
9870
|
+
if (Object.keys(effect).sort().join(",") !== "key,kind,value") return invalid15();
|
|
9806
9871
|
let value2 = object9(effect.value);
|
|
9807
|
-
if (!keys5(value2, ["label", "status", "reason", "related", "asOf", "number"])) return
|
|
9872
|
+
if (!keys5(value2, ["label", "status", "reason", "related", "asOf", "number"])) return invalid15();
|
|
9808
9873
|
let { number, ...assessment } = value2;
|
|
9809
9874
|
captureSignal({ ...assessment, key: effect.key }), (c.publication || Object.hasOwn(value2, "number")) && captureRecordSignal({ ...value2, key: effect.key });
|
|
9810
9875
|
} else if (effect.kind === "timeline") {
|
|
9811
|
-
if (Object.keys(effect).sort().join(",") !== "entry,kind") return
|
|
9876
|
+
if (Object.keys(effect).sort().join(",") !== "entry,kind") return invalid15();
|
|
9812
9877
|
captureTimeline(effect.entry);
|
|
9813
9878
|
} else if (effect.kind === "create" || effect.kind === "delete") {
|
|
9814
|
-
if (!keys5(effect, ["fields", "kind", "signals", "timeline"])) return
|
|
9879
|
+
if (!keys5(effect, ["fields", "kind", "signals", "timeline"])) return invalid15();
|
|
9815
9880
|
if (object9(effect.fields), Object.hasOwn(effect, "signals") && captureRecordSignals(effect.signals), Object.hasOwn(effect, "timeline")) {
|
|
9816
|
-
if (!Array.isArray(effect.timeline)) return
|
|
9881
|
+
if (!Array.isArray(effect.timeline)) return invalid15();
|
|
9817
9882
|
effect.timeline.forEach((value2) => captureTimeline(value2));
|
|
9818
9883
|
}
|
|
9819
|
-
} else return
|
|
9884
|
+
} else return invalid15();
|
|
9820
9885
|
}
|
|
9821
9886
|
return input;
|
|
9822
9887
|
} catch {
|
|
9823
|
-
return
|
|
9888
|
+
return invalid15();
|
|
9824
9889
|
}
|
|
9825
9890
|
}
|
|
9826
9891
|
function materializeSnapshot(envelope, changes, version) {
|
|
@@ -9829,13 +9894,13 @@ function materializeSnapshot(envelope, changes, version) {
|
|
|
9829
9894
|
let rows = new Map(Object.values(envelope.collections).flat().map((r) => [r.$ref, structuredClone(r)]));
|
|
9830
9895
|
for (let c of changes) {
|
|
9831
9896
|
let schema2 = snapshotCollection(envelope.catalogue, c.ref);
|
|
9832
|
-
if (!schema2) return
|
|
9897
|
+
if (!schema2) return invalid15();
|
|
9833
9898
|
let effect = c.effect, definitions3 = "field" in effect ? schema2.schema.fields.filter((f) => f.name === effect.field) : schema2.schema.fields;
|
|
9834
|
-
if ("field" in effect && !definitions3.length) return
|
|
9899
|
+
if ("field" in effect && !definitions3.length) return invalid15();
|
|
9835
9900
|
let values;
|
|
9836
9901
|
if (effect.kind === "link" || effect.kind === "unlink") {
|
|
9837
9902
|
let field = definitions3[0];
|
|
9838
|
-
if (field.kind !== "link" || !field.many && effect.kind === "link" && effect.refs.length !== 1) return
|
|
9903
|
+
if (field.kind !== "link" || !field.many && effect.kind === "link" && effect.refs.length !== 1) return invalid15();
|
|
9839
9904
|
let targets2 = [...effect.refs, ...effect.kind === "link" ? effect.remove ?? [] : []];
|
|
9840
9905
|
for (let ref of targets2) validateRecordFields({ [effect.field]: field.many ? [ref] : ref }, definitions3, (_ref, allowed) => allowed[0], !0);
|
|
9841
9906
|
values = { [effect.field]: field.many ? effect.refs : effect.refs[0] };
|
|
@@ -9848,25 +9913,25 @@ function materializeSnapshot(envelope, changes, version) {
|
|
|
9848
9913
|
), !c.publication) continue;
|
|
9849
9914
|
let prior = rows.get(c.ref);
|
|
9850
9915
|
if (effect.kind === "set") {
|
|
9851
|
-
if (!prior) return
|
|
9916
|
+
if (!prior) return invalid15();
|
|
9852
9917
|
rows.set(c.ref, { ...prior, [effect.field]: effect.value, $version: c.recordVersion });
|
|
9853
9918
|
} else if (effect.kind === "link" || effect.kind === "unlink") {
|
|
9854
|
-
if (!prior) return
|
|
9919
|
+
if (!prior) return invalid15();
|
|
9855
9920
|
let field = definitions3[0], current2 = prior[effect.field], value = field.many ? effect.kind === "link" ? [.../* @__PURE__ */ new Set([...Array.isArray(current2) ? current2 : [], ...effect.refs])].filter((ref) => !effect.remove?.includes(String(ref))) : (Array.isArray(current2) ? current2 : []).filter((ref) => !effect.refs.includes(String(ref))) : effect.kind === "link" ? effect.remove?.includes(effect.refs[0]) ? null : effect.refs[0] : effect.refs.includes(String(current2)) ? null : current2;
|
|
9856
9921
|
rows.set(c.ref, { ...prior, [effect.field]: value, $version: c.recordVersion });
|
|
9857
9922
|
} else if (effect.kind === "signal") {
|
|
9858
|
-
if (!prior || !effect.value.number) return
|
|
9923
|
+
if (!prior || !effect.value.number) return invalid15();
|
|
9859
9924
|
let signal = captureRecordSignal({ ...effect.value, key: effect.key }), signals = captureRecordSignals(prior.$signals), index = signals.findIndex((row) => row.key === effect.key);
|
|
9860
9925
|
index < 0 ? signals.push(signal) : signals[index] = signal, rows.set(c.ref, { ...prior, $signals: captureRecordSignals(signals), $version: c.recordVersion });
|
|
9861
9926
|
} else if (effect.kind === "timeline") {
|
|
9862
|
-
if (!prior) return
|
|
9927
|
+
if (!prior) return invalid15();
|
|
9863
9928
|
rows.set(c.ref, {
|
|
9864
9929
|
...prior,
|
|
9865
9930
|
$version: c.recordVersion,
|
|
9866
9931
|
...envelope.timelineCollections.includes(schema2.name) ? { $timeline: [...prior.$timeline, effect.entry] } : {}
|
|
9867
9932
|
});
|
|
9868
9933
|
} else if (effect.kind === "create") {
|
|
9869
|
-
if (prior) return
|
|
9934
|
+
if (prior) return invalid15();
|
|
9870
9935
|
rows.set(c.ref, {
|
|
9871
9936
|
...effect.fields,
|
|
9872
9937
|
$ref: c.ref,
|
|
@@ -9875,7 +9940,7 @@ function materializeSnapshot(envelope, changes, version) {
|
|
|
9875
9940
|
...envelope.timelineCollections.includes(schema2.name) ? { $timeline: effect.timeline ?? [] } : {}
|
|
9876
9941
|
});
|
|
9877
9942
|
} else {
|
|
9878
|
-
if (!prior) return
|
|
9943
|
+
if (!prior) return invalid15();
|
|
9879
9944
|
rows.delete(c.ref);
|
|
9880
9945
|
}
|
|
9881
9946
|
}
|
|
@@ -9888,7 +9953,7 @@ function materializeSnapshot(envelope, changes, version) {
|
|
|
9888
9953
|
collections: Object.fromEntries(envelope.catalogue.map((c) => [c.name, [...rows.values()].filter((r) => snapshotCollection(envelope.catalogue, r.$ref)?.name === c.name).sort((a, b) => a.$ref < b.$ref ? -1 : 1)]))
|
|
9889
9954
|
}, envelope.repository, envelope.name, envelope.bodyCollections, envelope.timelineCollections), ...envelope.history ? { history: envelope.history } : {} };
|
|
9890
9955
|
} catch {
|
|
9891
|
-
return
|
|
9956
|
+
return invalid15();
|
|
9892
9957
|
}
|
|
9893
9958
|
}
|
|
9894
9959
|
|
|
@@ -9944,23 +10009,23 @@ function applySnapshotMutation(envelope, prior, mutation, installation) {
|
|
|
9944
10009
|
return { envelope, changes };
|
|
9945
10010
|
}
|
|
9946
10011
|
|
|
9947
|
-
var
|
|
10012
|
+
var invalid16 = () => {
|
|
9948
10013
|
throw new DataOperationError("unavailable", !0, void 0, "snapshot_cache");
|
|
9949
10014
|
};
|
|
9950
10015
|
function targets(value, definition, found) {
|
|
9951
10016
|
if (value != null) {
|
|
9952
10017
|
if (definition.many) {
|
|
9953
|
-
if (!Array.isArray(value)) return
|
|
10018
|
+
if (!Array.isArray(value)) return invalid16();
|
|
9954
10019
|
for (let item of value) targets(item, { ...definition, many: !1 }, found);
|
|
9955
10020
|
} else if (definition.kind === "link") {
|
|
9956
10021
|
let link = parseRecordLink(value);
|
|
9957
|
-
if (!link) return
|
|
10022
|
+
if (!link) return invalid16();
|
|
9958
10023
|
found.add(link.ref);
|
|
9959
10024
|
} else if (definition.kind === "object") {
|
|
9960
|
-
if (typeof value != "object" || Array.isArray(value)) return
|
|
10025
|
+
if (typeof value != "object" || Array.isArray(value)) return invalid16();
|
|
9961
10026
|
for (let field of definition.fields) targets(value[field.name], field, found);
|
|
9962
10027
|
} else if (definition.kind === "map") {
|
|
9963
|
-
if (typeof value != "object" || Array.isArray(value)) return
|
|
10028
|
+
if (typeof value != "object" || Array.isArray(value)) return invalid16();
|
|
9964
10029
|
for (let item of Object.values(value)) targets(item, definition.value, found);
|
|
9965
10030
|
}
|
|
9966
10031
|
}
|
|
@@ -10392,8 +10457,8 @@ function snapshotListeners(url, authority2, assertCurrent, invalidate, reconcile
|
|
|
10392
10457
|
}, Math.min(2147483647, Math.max(0, authority2.expiresAt - Date.now())));
|
|
10393
10458
|
}, later = () => {
|
|
10394
10459
|
retry = setTimeout(open, delay), delay = Math.min(3e4, delay * 2);
|
|
10395
|
-
}, reconnect = (
|
|
10396
|
-
session !== owned || !
|
|
10460
|
+
}, reconnect = (connection2) => {
|
|
10461
|
+
session !== owned || !connection2 || socket !== connection2 || (socket = void 0, connection2.close(), later());
|
|
10397
10462
|
}, refresh2 = () => {
|
|
10398
10463
|
dirty = !0, !running && (running = !0, (async () => {
|
|
10399
10464
|
try {
|
|
@@ -10422,15 +10487,15 @@ function snapshotListeners(url, authority2, assertCurrent, invalidate, reconcile
|
|
|
10422
10487
|
}
|
|
10423
10488
|
armExpiry();
|
|
10424
10489
|
try {
|
|
10425
|
-
let
|
|
10490
|
+
let connection2 = connect(url.replace(/^http/, "ws") + "/updates", [
|
|
10426
10491
|
snapshotUpdatesProtocol,
|
|
10427
10492
|
snapshotUpdatesCredentialPrefix + authority2.headers.authorization.slice(7)
|
|
10428
10493
|
]);
|
|
10429
|
-
socket =
|
|
10430
|
-
socket ===
|
|
10431
|
-
}),
|
|
10432
|
-
socket ===
|
|
10433
|
-
}),
|
|
10494
|
+
socket = connection2, connection2.addEventListener("open", () => {
|
|
10495
|
+
socket === connection2 && session === owned && refresh2();
|
|
10496
|
+
}), connection2.addEventListener("message", (event) => {
|
|
10497
|
+
socket === connection2 && session === owned && event.data === snapshotUpdateHint && refresh2();
|
|
10498
|
+
}), connection2.addEventListener("close", () => reconnect(connection2)), connection2.addEventListener("error", () => reconnect(connection2));
|
|
10434
10499
|
} catch {
|
|
10435
10500
|
session === owned && later();
|
|
10436
10501
|
}
|
|
@@ -10529,19 +10594,19 @@ function captureSelection(input) {
|
|
|
10529
10594
|
}
|
|
10530
10595
|
}
|
|
10531
10596
|
|
|
10532
|
-
var
|
|
10597
|
+
var invalid17 = () => {
|
|
10533
10598
|
throw new DataOperationError("invalid_query");
|
|
10534
10599
|
};
|
|
10535
10600
|
function captureSnapshotAll(query, options) {
|
|
10536
10601
|
let properties = dataProperties(options);
|
|
10537
|
-
return Object.keys(properties).some((key) => !["maxRecords", "body", "timeline"].includes(key)) || properties.body && properties.body.value !== !0 || properties.timeline && properties.timeline.value !== !0 ?
|
|
10602
|
+
return Object.keys(properties).some((key) => !["maxRecords", "body", "timeline"].includes(key)) || properties.body && properties.body.value !== !0 || properties.timeline && properties.timeline.value !== !0 ? invalid17() : { ...captureRecordsAll(query, { maxRecords: properties.maxRecords?.value }), body: properties.body?.value === !0, timeline: properties.timeline?.value === !0 };
|
|
10538
10603
|
}
|
|
10539
10604
|
var safeName = (value) => typeof value == "string" && /^[a-z0-9][a-z0-9._-]{0,127}$/.test(value) && !value.includes("..");
|
|
10540
10605
|
function createSnapshotInitializer(resolve = resolveSnapshotContext, open = openSnapshotStore, connect = (url, protocols) => new WebSocket(url, protocols)) {
|
|
10541
10606
|
let pending = /* @__PURE__ */ new WeakMap(), maintenance = /* @__PURE__ */ new WeakMap();
|
|
10542
10607
|
return async function(input) {
|
|
10543
10608
|
let properties = dataProperties(input), repository = properties.repository?.value, snapshot = properties.snapshot?.value;
|
|
10544
|
-
if (Object.keys(properties).sort().join(",") !== "repository,snapshot" || !safeName(repository) || !safeName(snapshot)) return
|
|
10609
|
+
if (Object.keys(properties).sort().join(",") !== "repository,snapshot" || !safeName(repository) || !safeName(snapshot)) return invalid17();
|
|
10545
10610
|
let authority2 = await resolve(), invalidated = !1, stopLive, assertCurrent = () => {
|
|
10546
10611
|
if (invalidated || authority2.signal.aborted || !authority2.isCurrent() || !authority2.refresh && authority2.expiresAt <= Date.now())
|
|
10547
10612
|
throw invalidated = !0, stopLive?.(), new DataOperationError("context_unavailable");
|
|
@@ -10713,7 +10778,7 @@ function createSnapshotInitializer(resolve = resolveSnapshotContext, open = open
|
|
|
10713
10778
|
let store;
|
|
10714
10779
|
try {
|
|
10715
10780
|
let selections = planIndexQuery(captured, pinned.catalogue, { allowUnknownTerminalRefs: !0 }), checkTimeline = (collection, selection2) => {
|
|
10716
|
-
if ((timeline || selection2.timeline) && !pinned.timelineCollections.includes(collection)) return
|
|
10781
|
+
if ((timeline || selection2.timeline) && !pinned.timelineCollections.includes(collection)) return invalid17();
|
|
10717
10782
|
for (let link of selection2.links) for (let [name4, nested] of link.targets) checkTimeline(name4, nested);
|
|
10718
10783
|
};
|
|
10719
10784
|
for (let { name: name4, selection: selection2 } of selections) checkTimeline(name4, selection2);
|
|
@@ -10798,7 +10863,7 @@ function createSnapshotInitializer(resolve = resolveSnapshotContext, open = open
|
|
|
10798
10863
|
return snapshotCollection(installation.catalogue, captured) ? writes.then(() => {
|
|
10799
10864
|
let pinned = installation;
|
|
10800
10865
|
return localRead(async (store) => {
|
|
10801
|
-
if (timeline && !pinned.timelineCollections.includes(snapshotCollection(pinned.catalogue, captured).name)) return
|
|
10866
|
+
if (timeline && !pinned.timelineCollections.includes(snapshotCollection(pinned.catalogue, captured).name)) return invalid17();
|
|
10802
10867
|
let record4 = await store.read(pinned, captured);
|
|
10803
10868
|
if (!record4) return record4;
|
|
10804
10869
|
let { $body, $timeline, ...structured } = record4;
|
|
@@ -10935,7 +11000,7 @@ var genericData = {
|
|
|
10935
11000
|
}
|
|
10936
11001
|
}, data = genericData;
|
|
10937
11002
|
|
|
10938
|
-
var MAX_BYTES = 16 * 1024 * 1024, PART_BYTES = 8 * 1024 * 1024, METADATA_BYTES = 4096, RESULT_BYTES = 16 * 1024, CONTROL_RESULT_BYTES = 128 * 1024, TIMEOUT_MS = 3e4, MAX_ACTIVE = 4, ATTEMPTS = 2, active = 0, waiters = [],
|
|
11003
|
+
var MAX_BYTES = 16 * 1024 * 1024, PART_BYTES = 8 * 1024 * 1024, METADATA_BYTES = 4096, RESULT_BYTES = 16 * 1024, CONTROL_RESULT_BYTES = 128 * 1024, TIMEOUT_MS = 3e4, MAX_ACTIVE = 4, ATTEMPTS = 2, active = 0, waiters = [], invalid18 = () => new FileOperationError("invalid_input", 400), unavailable4 = () => new FileOperationError("unavailable", 503, !0), failures = {
|
|
10939
11004
|
400: ["invalid_input", "unsupported_context"],
|
|
10940
11005
|
401: ["unauthenticated"],
|
|
10941
11006
|
403: ["access_denied"],
|
|
@@ -11091,7 +11156,7 @@ async function send(suffix, init2, descriptor, initial, parent) {
|
|
|
11091
11156
|
throw unavailable4();
|
|
11092
11157
|
}
|
|
11093
11158
|
function idPath(id5) {
|
|
11094
|
-
if (typeof id5 != "string" || !FILE_ID_PATTERN.test(id5)) throw
|
|
11159
|
+
if (typeof id5 != "string" || !FILE_ID_PATTERN.test(id5)) throw invalid18();
|
|
11095
11160
|
return `/${id5}`;
|
|
11096
11161
|
}
|
|
11097
11162
|
async function multipartCreate(input, metadata, exchange, release, upload, expectedSha256) {
|
|
@@ -11134,18 +11199,18 @@ async function multipartCreate(input, metadata, exchange, release, upload, expec
|
|
|
11134
11199
|
if (!chunk || offset === chunk.byteLength) {
|
|
11135
11200
|
chunk = void 0, offset = 0;
|
|
11136
11201
|
let value2 = await next();
|
|
11137
|
-
if (value2.done || !(value2.value instanceof Uint8Array) || (chunk = value2.value, chunk.byteLength > metadata.size - sent - filled)) throw
|
|
11202
|
+
if (value2.done || !(value2.value instanceof Uint8Array) || (chunk = value2.value, chunk.byteLength > metadata.size - sent - filled)) throw invalid18();
|
|
11138
11203
|
}
|
|
11139
11204
|
let take = Math.min(length - filled, chunk.byteLength - offset);
|
|
11140
11205
|
part.set(chunk.subarray(offset, offset + take), filled), filled += take, offset += take, offset === chunk.byteLength && (chunk = void 0, offset = 0);
|
|
11141
11206
|
}
|
|
11142
11207
|
}
|
|
11143
|
-
if (part.byteLength !== length) throw
|
|
11208
|
+
if (part.byteLength !== length) throw invalid18();
|
|
11144
11209
|
if (reader && sent + length === metadata.size)
|
|
11145
11210
|
for (lastProgress = Date.now(); ; ) {
|
|
11146
11211
|
let value2 = await next();
|
|
11147
11212
|
if (value2.done) break;
|
|
11148
|
-
if (!(value2.value instanceof Uint8Array) || value2.value.byteLength) throw
|
|
11213
|
+
if (!(value2.value instanceof Uint8Array) || value2.value.byteLength) throw invalid18();
|
|
11149
11214
|
}
|
|
11150
11215
|
let value = await request3((signal) => exchange(`${route}/part`, {
|
|
11151
11216
|
method: "POST",
|
|
@@ -11159,7 +11224,7 @@ async function multipartCreate(input, metadata, exchange, release, upload, expec
|
|
|
11159
11224
|
}
|
|
11160
11225
|
if (upload) for (let name4 of Object.keys(upload.file.enrichments)) {
|
|
11161
11226
|
let bytes = await request3(() => upload.enrichment(name4));
|
|
11162
|
-
if (bytes.byteLength !== upload.file.enrichments[name4].size || bytes.byteLength > MAX_BYTES) throw
|
|
11227
|
+
if (bytes.byteLength !== upload.file.enrichments[name4].size || bytes.byteLength > MAX_BYTES) throw invalid18();
|
|
11163
11228
|
await request3((signal) => exchange(`${route}/enrichments/${encodeURIComponent(name4)}`, {
|
|
11164
11229
|
method: "POST",
|
|
11165
11230
|
headers: { "content-type": "application/octet-stream", "x-os-transfer": ticket },
|
|
@@ -11201,7 +11266,7 @@ async function operation(work, initial, parent) {
|
|
|
11201
11266
|
function contentPath(id5, name4) {
|
|
11202
11267
|
let path = idPath(id5);
|
|
11203
11268
|
if (name4 === void 0) return `${path}/content`;
|
|
11204
|
-
if (!safeEnrichmentName(name4)) throw
|
|
11269
|
+
if (!safeEnrichmentName(name4)) throw invalid18();
|
|
11205
11270
|
return `${path}/enrichments/${encodeURIComponent(name4)}/content`;
|
|
11206
11271
|
}
|
|
11207
11272
|
async function read(id5, names) {
|
|
@@ -11210,12 +11275,12 @@ async function read(id5, names) {
|
|
|
11210
11275
|
let path = contentPath(id5, names);
|
|
11211
11276
|
return operation((context2, signal) => send(path, { method: "GET" }, !1, context2, signal), context);
|
|
11212
11277
|
}
|
|
11213
|
-
if (!Array.isArray(names)) throw
|
|
11278
|
+
if (!Array.isArray(names)) throw invalid18();
|
|
11214
11279
|
let distinct = [], seen = /* @__PURE__ */ new Set();
|
|
11215
11280
|
for (let name4 of names) {
|
|
11216
|
-
if (typeof name4 != "string" || !safeEnrichmentName(name4)) throw
|
|
11281
|
+
if (typeof name4 != "string" || !safeEnrichmentName(name4)) throw invalid18();
|
|
11217
11282
|
if (!seen.has(name4)) {
|
|
11218
|
-
if (seen.size === 16) throw
|
|
11283
|
+
if (seen.size === 16) throw invalid18();
|
|
11219
11284
|
seen.add(name4), distinct.push(name4);
|
|
11220
11285
|
}
|
|
11221
11286
|
}
|
|
@@ -11255,9 +11320,9 @@ var files = {
|
|
|
11255
11320
|
async create(input, options) {
|
|
11256
11321
|
let context = await resolveFilesContext();
|
|
11257
11322
|
if (!input || typeof input != "object" || Array.isArray(input) || Object.keys(input).some((key) => !["file", "size", "path", "name", "storage", "mediaType"].includes(key)) || options !== void 0 && (!options || typeof options != "object" || Array.isArray(options) || Object.keys(options).some((key) => key !== "requestKey")))
|
|
11258
|
-
throw
|
|
11323
|
+
throw invalid18();
|
|
11259
11324
|
let blob = input.file instanceof Blob, array3 = input.file instanceof Uint8Array, stream = input.file instanceof ReadableStream;
|
|
11260
|
-
if (!blob && !array3 && !stream) throw
|
|
11325
|
+
if (!blob && !array3 && !stream) throw invalid18();
|
|
11261
11326
|
let intrinsic = blob ? input.file.size : array3 ? input.file.byteLength : void 0;
|
|
11262
11327
|
if (intrinsic !== void 0 && input.size !== void 0 && input.size !== intrinsic)
|
|
11263
11328
|
throw !Number.isSafeInteger(input.size) || input.size < 0 ? new FileOperationError("invalid_input", 400, !1, { reason: "invalid_size" }) : new FileOperationError(
|
|
@@ -11278,7 +11343,7 @@ var files = {
|
|
|
11278
11343
|
}, FILE_ORIGINAL_MAX_BYTES);
|
|
11279
11344
|
if (!context.local && !context.localFiles && metadata.storage === "local") throw new FileOperationError("unsupported_context", 400);
|
|
11280
11345
|
let header = encodeURIComponent(JSON.stringify(metadata));
|
|
11281
|
-
if (new TextEncoder().encode(header).byteLength > METADATA_BYTES) throw
|
|
11346
|
+
if (new TextEncoder().encode(header).byteLength > METADATA_BYTES) throw invalid18();
|
|
11282
11347
|
let release = await acquireSlot(context.signal);
|
|
11283
11348
|
if (context.localFiles && !routineTransport() && metadata.size > MAX_BYTES)
|
|
11284
11349
|
try {
|
|
@@ -11329,7 +11394,7 @@ var files = {
|
|
|
11329
11394
|
},
|
|
11330
11395
|
async enrich(input) {
|
|
11331
11396
|
let context = await resolveFilesContext();
|
|
11332
|
-
if (!input || typeof input != "object" || Array.isArray(input) || Object.keys(input).some((key) => !["file", "name", "content", "mediaType", "replace"].includes(key)) || typeof input.content != "string" && !(input.content instanceof Uint8Array)) throw
|
|
11397
|
+
if (!input || typeof input != "object" || Array.isArray(input) || Object.keys(input).some((key) => !["file", "name", "content", "mediaType", "replace"].includes(key)) || typeof input.content != "string" && !(input.content instanceof Uint8Array)) throw invalid18();
|
|
11333
11398
|
let path = `${idPath(input.file)}/enrichments`;
|
|
11334
11399
|
if (typeof input.content == "string" ? input.content.length > MAX_BYTES : input.content.byteLength > MAX_BYTES)
|
|
11335
11400
|
throw new FileOperationError("request_too_large", 413);
|
|
@@ -11346,7 +11411,7 @@ var files = {
|
|
|
11346
11411
|
...input.mediaType === void 0 ? {} : { mediaType: input.mediaType },
|
|
11347
11412
|
...input.replace === void 0 ? {} : { replace: input.replace }
|
|
11348
11413
|
}, MAX_BYTES), header = encodeURIComponent(JSON.stringify(metadata));
|
|
11349
|
-
if (new TextEncoder().encode(header).byteLength > METADATA_BYTES) throw
|
|
11414
|
+
if (new TextEncoder().encode(header).byteLength > METADATA_BYTES) throw invalid18();
|
|
11350
11415
|
let result2 = await send(path, { method: "POST", headers: {
|
|
11351
11416
|
"content-type": "application/octet-stream",
|
|
11352
11417
|
"x-os-enrichment": header
|
|
@@ -11693,10 +11758,10 @@ async function reportLocalRoutineEffect(value) {
|
|
|
11693
11758
|
}
|
|
11694
11759
|
|
|
11695
11760
|
var local;
|
|
11696
|
-
async function localLease(
|
|
11761
|
+
async function localLease(identity4) {
|
|
11697
11762
|
let current2 = local;
|
|
11698
|
-
if (!current2 || !current2.declared.includes(
|
|
11699
|
-
let lease = current2.leases.find((value) => `${value.provider}/${value.name}` ===
|
|
11763
|
+
if (!current2 || !current2.declared.includes(identity4)) throw new Error("Connection unavailable");
|
|
11764
|
+
let lease = current2.leases.find((value) => `${value.provider}/${value.name}` === identity4);
|
|
11700
11765
|
if (lease)
|
|
11701
11766
|
try {
|
|
11702
11767
|
return parseConnectionLease(lease);
|
|
@@ -11706,25 +11771,25 @@ async function localLease(identity3) {
|
|
|
11706
11771
|
lease = void 0;
|
|
11707
11772
|
}
|
|
11708
11773
|
if (!lease && current2.acquire) {
|
|
11709
|
-
let acquiring = current2.acquiring.get(
|
|
11774
|
+
let acquiring = current2.acquiring.get(identity4);
|
|
11710
11775
|
acquiring || (acquiring = (async () => {
|
|
11711
|
-
let acquired = parseConnectionLease(await current2.acquire(
|
|
11712
|
-
if (local !== current2 || acquired.runId !== current2.runId || `${acquired.provider}/${acquired.name}` !==
|
|
11776
|
+
let acquired = parseConnectionLease(await current2.acquire(identity4));
|
|
11777
|
+
if (local !== current2 || acquired.runId !== current2.runId || `${acquired.provider}/${acquired.name}` !== identity4)
|
|
11713
11778
|
throw new Error("Connection unavailable");
|
|
11714
11779
|
return current2.leases.push(acquired), acquired;
|
|
11715
|
-
})(), current2.acquiring.set(
|
|
11716
|
-
current2.acquiring.get(
|
|
11780
|
+
})(), current2.acquiring.set(identity4, acquiring), acquiring.finally(() => {
|
|
11781
|
+
current2.acquiring.get(identity4) === acquiring && current2.acquiring.delete(identity4);
|
|
11717
11782
|
}).catch(() => {
|
|
11718
11783
|
})), lease = await acquiring;
|
|
11719
11784
|
}
|
|
11720
|
-
if (local !== current2 || !lease || lease.runId !== current2.runId || `${lease.provider}/${lease.name}` !==
|
|
11785
|
+
if (local !== current2 || !lease || lease.runId !== current2.runId || `${lease.provider}/${lease.name}` !== identity4)
|
|
11721
11786
|
throw new Error("Connection unavailable");
|
|
11722
11787
|
return parseConnectionLease(lease);
|
|
11723
11788
|
}
|
|
11724
|
-
function connectionFailure(
|
|
11789
|
+
function connectionFailure(identity4) {
|
|
11725
11790
|
let workspace = typeof process > "u" ? void 0 : process.env.OS_ROUTINE_WORKSPACE;
|
|
11726
11791
|
try {
|
|
11727
|
-
return new ConnectionOperationError(
|
|
11792
|
+
return new ConnectionOperationError(identity4, workspace);
|
|
11728
11793
|
} catch {
|
|
11729
11794
|
return new Error("Connection unavailable");
|
|
11730
11795
|
}
|
|
@@ -11735,8 +11800,8 @@ var airtable = /* @__PURE__ */ createConnections(async (name4, operation2, input
|
|
|
11735
11800
|
function runtimeConnections() {
|
|
11736
11801
|
return {
|
|
11737
11802
|
...airtable,
|
|
11738
|
-
async get(
|
|
11739
|
-
throw connectionFailure(
|
|
11803
|
+
async get(identity4) {
|
|
11804
|
+
throw connectionFailure(identity4);
|
|
11740
11805
|
}
|
|
11741
11806
|
};
|
|
11742
11807
|
}
|
|
@@ -11884,7 +11949,7 @@ var source = {
|
|
|
11884
11949
|
merge(existing, incoming) {
|
|
11885
11950
|
let merged = existing.map((location) => ({ ...location }));
|
|
11886
11951
|
for (let location of incoming) {
|
|
11887
|
-
let
|
|
11952
|
+
let identity4 = locationIdentity(location), index = identity4 === void 0 ? -1 : merged.findIndex((value) => locationIdentity(value) === identity4);
|
|
11888
11953
|
index < 0 ? merged.push({ ...location }) : merged[index] = { ...location };
|
|
11889
11954
|
}
|
|
11890
11955
|
return merged;
|
|
@@ -11957,15 +12022,15 @@ function subscribeInbox(resolve, authorize, onDirty, onState, rt = runtime, sign
|
|
|
11957
12022
|
if (setup.expiresAt <= rt.now()) throw new Error();
|
|
11958
12023
|
let url = new URL(setup.url);
|
|
11959
12024
|
url.searchParams.set("apikey", setup.key), url.searchParams.set("vsn", "1.0.0");
|
|
11960
|
-
let
|
|
11961
|
-
socket =
|
|
11962
|
-
let valid = () => active2 && current2() && started === generation && socket ===
|
|
11963
|
-
deadline = rt.later(reconnect, 15e3),
|
|
12025
|
+
let connection2 = rt.connect(url.href);
|
|
12026
|
+
socket = connection2;
|
|
12027
|
+
let valid = () => active2 && current2() && started === generation && socket === connection2, topic = `realtime:${setup.topic}`, join = String(++sequence), joined = !1, send3 = (event, payload, ref = String(++sequence), destination = topic) => connection2.send(JSON.stringify({ topic: destination, event, payload, ref }));
|
|
12028
|
+
deadline = rt.later(reconnect, 15e3), connection2.addEventListener("open", () => {
|
|
11964
12029
|
valid() && send3("phx_join", {
|
|
11965
12030
|
config: { private: !0, broadcast: { ack: !1, self: !1 }, presence: { enabled: !1 }, postgres_changes: [] },
|
|
11966
12031
|
access_token: setup.token
|
|
11967
12032
|
}, join);
|
|
11968
|
-
}),
|
|
12033
|
+
}), connection2.addEventListener("message", (event) => {
|
|
11969
12034
|
if (!valid() || typeof event.data != "string" || event.data.length > 8192) return;
|
|
11970
12035
|
let value;
|
|
11971
12036
|
try {
|
|
@@ -11995,9 +12060,9 @@ function subscribeInbox(resolve, authorize, onDirty, onState, rt = runtime, sign
|
|
|
11995
12060
|
}
|
|
11996
12061
|
else (value.event === "phx_error" || value.event === "phx_close" || value.event === "system" && value.payload?.status === "error") && reconnect();
|
|
11997
12062
|
}
|
|
11998
|
-
}),
|
|
12063
|
+
}), connection2.addEventListener("close", () => {
|
|
11999
12064
|
valid() && reconnect();
|
|
12000
|
-
}),
|
|
12065
|
+
}), connection2.addEventListener("error", () => {
|
|
12001
12066
|
valid() && reconnect();
|
|
12002
12067
|
});
|
|
12003
12068
|
} catch (error) {
|
|
@@ -12040,7 +12105,7 @@ async function limitedBody(request3, limit, timeoutMs, signal) {
|
|
|
12040
12105
|
expired = !0, reader.cancel().catch(() => {
|
|
12041
12106
|
});
|
|
12042
12107
|
}, timeoutMs);
|
|
12043
|
-
signal?.addEventListener("abort", abort, { once: !0 });
|
|
12108
|
+
signal?.addEventListener("abort", abort, { once: !0 }), signal?.aborted && abort();
|
|
12044
12109
|
let chunks = [], length = 0;
|
|
12045
12110
|
try {
|
|
12046
12111
|
for (; ; ) {
|
|
@@ -13334,7 +13399,7 @@ function summary2(value, key, context, id5) {
|
|
|
13334
13399
|
return fail8("execution_unavailable");
|
|
13335
13400
|
}
|
|
13336
13401
|
let run = value;
|
|
13337
|
-
return (!only(run, "id,routine,placement,status,createdAt,startedAt,finishedAt,steps,result,failure,local") || typeof run.id != "string" || !uuid6.test(run.id) || id5 !== void 0 && run.id !== id5 || run.routine !== key || run.placement !== "local" || !["queued", "running", "succeeded", "failed", "legacy"].includes(run.status) || !
|
|
13402
|
+
return (!only(run, "id,routine,placement,status,createdAt,startedAt,finishedAt,steps,result,failure,local") || typeof run.id != "string" || !uuid6.test(run.id) || id5 !== void 0 && run.id !== id5 || run.routine !== key || run.placement !== "local" || !["queued", "running", "succeeded", "failed", "legacy"].includes(run.status) || !timestamp2(run.createdAt) || !optionalTimes(run) || !Array.isArray(run.steps) || run.steps.length > 64 || run.steps.some((step) => !only(step, "id,title,status,startedAt,finishedAt,progress,summary,detailAvailable") || typeof step.detailAvailable != "boolean" || !validStep(step)) || new Set(run.steps.map((step) => step.id)).size !== run.steps.length || Object.hasOwn(run, "result") && (run.status !== "succeeded" || !bounded2(run.result)) || run.failure !== void 0 && (run.status !== "failed" || !validFailure(run.failure, run.steps, run)) || run.local !== void 0 && !validLocalActivity(run.local)) && fail8("execution_unavailable"), run;
|
|
13338
13403
|
}
|
|
13339
13404
|
function validFailure(value, steps, local2) {
|
|
13340
13405
|
try {
|
|
@@ -13343,16 +13408,16 @@ function validFailure(value, steps, local2) {
|
|
|
13343
13408
|
}
|
|
13344
13409
|
if (local2 && only(value, "message,code,detail") && value.code !== void 0)
|
|
13345
13410
|
try {
|
|
13346
|
-
let
|
|
13347
|
-
return value.code ===
|
|
13411
|
+
let detail2 = parseConnectionFailureDetail(value.detail), completedWork = steps.some((step) => step.status === "completed") || !!local2.local?.effects.some((effect) => effect.status === "completed") || !!local2.local?.data.some((repository) => repository.created.length || repository.updated.length || repository.deleted.length);
|
|
13412
|
+
return value.code === detail2.code && value.message === connectionRunFailureMessage(detail2, completedWork);
|
|
13348
13413
|
} catch {
|
|
13349
13414
|
}
|
|
13350
13415
|
if (!only(value, "message,code,step,sizeBytes,limitBytes,summaryBytes,dataBytes") || !message(value.message)) return !1;
|
|
13351
13416
|
if (value.code === void 0) return only(value, "message");
|
|
13352
13417
|
if (value.code !== "step_output_too_large") return !1;
|
|
13353
13418
|
try {
|
|
13354
|
-
let { code: _, message: message2, ...facts2 } = value,
|
|
13355
|
-
return message2 === routineStepOutputMessage(
|
|
13419
|
+
let { code: _, message: message2, ...facts2 } = value, detail2 = parseRoutineStepOutputDetail(facts2);
|
|
13420
|
+
return message2 === routineStepOutputMessage(detail2) && steps.some((step) => step.id === detail2.step && step.status === "failed");
|
|
13356
13421
|
} catch {
|
|
13357
13422
|
return !1;
|
|
13358
13423
|
}
|
|
@@ -13360,9 +13425,9 @@ function validFailure(value, steps, local2) {
|
|
|
13360
13425
|
function only(value, allowed) {
|
|
13361
13426
|
return !!value && typeof value == "object" && !Array.isArray(value) && Object.keys(value).every((key) => allowed.split(",").includes(key));
|
|
13362
13427
|
}
|
|
13363
|
-
var
|
|
13428
|
+
var timestamp2 = (value) => typeof value == "string" && value.length <= 32 && Number.isFinite(Date.parse(value)), message = (value) => typeof value == "string" && value.length > 0 && value.length <= 512, bounded2 = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 256 * 1024;
|
|
13364
13429
|
function optionalTimes(value) {
|
|
13365
|
-
return (value.startedAt === void 0 ||
|
|
13430
|
+
return (value.startedAt === void 0 || timestamp2(value.startedAt)) && (value.finishedAt === void 0 || timestamp2(value.finishedAt));
|
|
13366
13431
|
}
|
|
13367
13432
|
function validStep(step) {
|
|
13368
13433
|
return typeof step.id == "string" && identifier.test(step.id) && typeof step.title == "string" && step.title.length > 0 && step.title.length <= 256 && ["pending", "running", "completed", "failed", "skipped"].includes(step.status) && optionalTimes(step) && (step.progress === void 0 || only(step.progress, "completed,total") && Number.isSafeInteger(step.progress.completed) && Number.isSafeInteger(step.progress.total) && step.progress.completed > 0 && step.progress.completed <= step.progress.total) && (() => {
|
|
@@ -13427,7 +13492,7 @@ function unavailable6(key, reason) {
|
|
|
13427
13492
|
let descriptor = appDescriptors().find((item) => item.id === key);
|
|
13428
13493
|
return {
|
|
13429
13494
|
...structuredClone(descriptor),
|
|
13430
|
-
connections: descriptor.connections.map((
|
|
13495
|
+
connections: descriptor.connections.map((connection2) => ({ ...connection2, available: !1 })),
|
|
13431
13496
|
readiness: { state: "unavailable", reason, message: reason === "not_deployed" ? "Routine is not deployed." : "Routine capability unavailable." }
|
|
13432
13497
|
};
|
|
13433
13498
|
}
|