@oddington/sdk 0.1.73 → 0.1.75
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/README.md +45 -0
- package/dist/browser.js +343 -233
- package/dist/index.js +4 -4
- package/dist/types/packages/sdk/src/public.d.ts +19 -3
- package/dist/types/shared/data-contract.d.ts +10 -1
- package/dist/types/shared/data-validation-message.d.ts +3 -2
- package/dist/types/shared/inbox-contract.d.ts +4 -0
- package/dist/types/shared/inbox-member-contract.d.ts +1 -1
- package/dist/types/shared/inbox-member-types.d.ts +5 -6
- package/dist/types/shared/record-display.d.ts +11 -0
- package/dist/types/shared/record-selection.d.ts +9 -14
- 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 invalid14 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|
2102
2102
|
if (Settings.throwOnInvalid)
|
|
2103
|
-
throw new InvalidDurationError(
|
|
2103
|
+
throw new InvalidDurationError(invalid14);
|
|
2104
2104
|
return new _Duration({
|
|
2105
|
-
invalid:
|
|
2105
|
+
invalid: invalid14
|
|
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 invalid14 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|
2373
2373
|
if (Settings.throwOnInvalid)
|
|
2374
|
-
throw new InvalidIntervalError(
|
|
2374
|
+
throw new InvalidIntervalError(invalid14);
|
|
2375
2375
|
return new _Interval({
|
|
2376
|
-
invalid:
|
|
2376
|
+
invalid: invalid14
|
|
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 invalid14 = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj);
|
|
3234
|
+
if (invalid14)
|
|
3235
|
+
return DateTime.invalid(invalid14);
|
|
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, invalid14 = 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 (!invalid14)
|
|
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), invalid14 = Number.isNaN(c.year) ? new Invalid("invalid input") : null, c = invalid14 ? null : c, o = invalid14 ? 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 = invalid14, 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), invalid14 = higherOrderInvalid || hasInvalidTimeData(normalized);
|
|
3353
|
+
if (invalid14)
|
|
3354
|
+
return _DateTime.invalid(invalid14);
|
|
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, invalid14] = parseFromTokens(localeToUse, text5, fmt);
|
|
3386
|
+
return invalid14 ? _DateTime.invalid(invalid14) : 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 invalid14 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|
3399
3399
|
if (Settings.throwOnInvalid)
|
|
3400
|
-
throw new InvalidDateTimeError(
|
|
3400
|
+
throw new InvalidDateTimeError(invalid14);
|
|
3401
3401
|
return new _DateTime({
|
|
3402
|
-
invalid:
|
|
3402
|
+
invalid: invalid14
|
|
3403
3403
|
});
|
|
3404
3404
|
}
|
|
3405
3405
|
static isDateTime(o) {
|
|
@@ -5039,40 +5039,40 @@ var FileOperationError = class extends Error {
|
|
|
5039
5039
|
};
|
|
5040
5040
|
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;
|
|
5041
5041
|
function parseFileDescriptor(value) {
|
|
5042
|
-
let
|
|
5042
|
+
let invalid14 = () => {
|
|
5043
5043
|
throw new FileOperationError("unavailable", 503, !0);
|
|
5044
5044
|
};
|
|
5045
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
5045
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid14();
|
|
5046
5046
|
let f = value;
|
|
5047
|
-
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
|
|
5047
|
+
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 invalid14();
|
|
5048
5048
|
for (let [name2, descriptor] of Object.entries(f.enrichments)) {
|
|
5049
|
-
if (!safeEnrichmentName(name2)) return
|
|
5049
|
+
if (!safeEnrichmentName(name2)) return invalid14();
|
|
5050
5050
|
parseEnrichmentDescriptor(descriptor);
|
|
5051
5051
|
}
|
|
5052
|
-
return new TextEncoder().encode(JSON.stringify(f)).byteLength > 16 * 1024 ?
|
|
5052
|
+
return new TextEncoder().encode(JSON.stringify(f)).byteLength > 16 * 1024 ? invalid14() : f;
|
|
5053
5053
|
}
|
|
5054
5054
|
function parseEnrichmentDescriptor(value) {
|
|
5055
|
-
let
|
|
5055
|
+
let invalid14 = () => {
|
|
5056
5056
|
throw new FileOperationError("unavailable", 503, !0);
|
|
5057
5057
|
};
|
|
5058
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
5058
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid14();
|
|
5059
5059
|
let d = value;
|
|
5060
|
-
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) ?
|
|
5060
|
+
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) ? invalid14() : d;
|
|
5061
5061
|
}
|
|
5062
5062
|
function safeEnrichmentName(value) {
|
|
5063
5063
|
return safeFileName(value) && !/^original(?:\.|$)/i.test(value);
|
|
5064
5064
|
}
|
|
5065
5065
|
function parseFileEnrichMetadata(value, maxBytes) {
|
|
5066
|
-
let
|
|
5066
|
+
let invalid14 = (reason = "invalid_metadata") => {
|
|
5067
5067
|
throw new FileOperationError("invalid_input", 400, !1, { reason });
|
|
5068
5068
|
};
|
|
5069
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
5069
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid14();
|
|
5070
5070
|
let d = value;
|
|
5071
|
-
if (Object.keys(d).some((key) => !["name", "size", "mediaType", "replace"].includes(key))) return
|
|
5072
|
-
if (!safeEnrichmentName(d.name)) return
|
|
5073
|
-
if (!Number.isSafeInteger(d.size) || d.size < 0) return
|
|
5074
|
-
if (d.mediaType !== void 0 && (typeof d.mediaType != "string" || d.mediaType.length > 255 || /[\u0000-\u001f\u007f]/.test(d.mediaType))) return
|
|
5075
|
-
if (d.replace !== void 0 && (typeof d.replace != "string" || !/^[0-9a-f]{64}$/.test(d.replace))) return
|
|
5071
|
+
if (Object.keys(d).some((key) => !["name", "size", "mediaType", "replace"].includes(key))) return invalid14();
|
|
5072
|
+
if (!safeEnrichmentName(d.name)) return invalid14("invalid_enrichment_name");
|
|
5073
|
+
if (!Number.isSafeInteger(d.size) || d.size < 0) return invalid14("invalid_size");
|
|
5074
|
+
if (d.mediaType !== void 0 && (typeof d.mediaType != "string" || d.mediaType.length > 255 || /[\u0000-\u001f\u007f]/.test(d.mediaType))) return invalid14("invalid_media_type");
|
|
5075
|
+
if (d.replace !== void 0 && (typeof d.replace != "string" || !/^[0-9a-f]{64}$/.test(d.replace))) return invalid14("invalid_replacement");
|
|
5076
5076
|
if (d.size > maxBytes) throw new FileOperationError(
|
|
5077
5077
|
"request_too_large",
|
|
5078
5078
|
413,
|
|
@@ -5105,42 +5105,42 @@ function isCanonicalOriginalMediaType(value) {
|
|
|
5105
5105
|
}
|
|
5106
5106
|
}
|
|
5107
5107
|
function parseFileUpdate(value) {
|
|
5108
|
-
let
|
|
5108
|
+
let invalid14 = (reason = "invalid_metadata") => {
|
|
5109
5109
|
throw new FileOperationError("invalid_input", 400, !1, { reason });
|
|
5110
5110
|
};
|
|
5111
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
5111
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid14();
|
|
5112
5112
|
let input = value, update = {};
|
|
5113
|
-
if (!Object.keys(input).length || Object.keys(input).some((key) => !["name", "path", "mediaType"].includes(key))) return
|
|
5113
|
+
if (!Object.keys(input).length || Object.keys(input).some((key) => !["name", "path", "mediaType"].includes(key))) return invalid14();
|
|
5114
5114
|
if (Object.hasOwn(input, "name")) {
|
|
5115
|
-
if (!safeFileName(input.name)) return
|
|
5115
|
+
if (!safeFileName(input.name)) return invalid14("invalid_name");
|
|
5116
5116
|
update.name = input.name;
|
|
5117
5117
|
}
|
|
5118
5118
|
if (Object.hasOwn(input, "path")) {
|
|
5119
|
-
if (!safeManagedFilePath(input.path)) return
|
|
5119
|
+
if (!safeManagedFilePath(input.path)) return invalid14("invalid_path");
|
|
5120
5120
|
update.path = input.path;
|
|
5121
5121
|
}
|
|
5122
5122
|
return Object.hasOwn(input, "mediaType") && (update.mediaType = declaredOriginalMediaType(input.mediaType)), update;
|
|
5123
5123
|
}
|
|
5124
5124
|
function parseFileCreateMetadata(value, maxBytes) {
|
|
5125
|
-
let
|
|
5125
|
+
let invalid14 = (reason = "invalid_metadata") => {
|
|
5126
5126
|
throw new FileOperationError("invalid_input", 400, !1, { reason });
|
|
5127
5127
|
};
|
|
5128
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
5128
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid14();
|
|
5129
5129
|
let input = value;
|
|
5130
|
-
if (Object.keys(input).some((key) => !["name", "path", "storage", "mediaType", "size", "requestKey"].includes(key))) return
|
|
5130
|
+
if (Object.keys(input).some((key) => !["name", "path", "storage", "mediaType", "size", "requestKey"].includes(key))) return invalid14();
|
|
5131
5131
|
let path = input.path === void 0 ? "Files" : input.path;
|
|
5132
|
-
if (!safeFileName(input.name)) return
|
|
5133
|
-
if (!safeManagedFilePath(path)) return
|
|
5134
|
-
if (input.storage !== void 0 && input.storage !== "remote" && input.storage !== "local") return
|
|
5132
|
+
if (!safeFileName(input.name)) return invalid14("invalid_name");
|
|
5133
|
+
if (!safeManagedFilePath(path)) return invalid14("invalid_path");
|
|
5134
|
+
if (input.storage !== void 0 && input.storage !== "remote" && input.storage !== "local") return invalid14("invalid_storage");
|
|
5135
5135
|
let mediaType = input.mediaType === void 0 ? "application/octet-stream" : declaredOriginalMediaType(input.mediaType);
|
|
5136
|
-
if (!Number.isSafeInteger(input.size) || input.size < 0) return
|
|
5136
|
+
if (!Number.isSafeInteger(input.size) || input.size < 0) return invalid14("invalid_size");
|
|
5137
5137
|
if (input.size > maxBytes) throw new FileOperationError(
|
|
5138
5138
|
"request_too_large",
|
|
5139
5139
|
413,
|
|
5140
5140
|
!1,
|
|
5141
5141
|
{ reason: "size_limit", limitBytes: maxBytes, receivedBytes: input.size }
|
|
5142
5142
|
);
|
|
5143
|
-
return typeof input.requestKey != "string" || input.requestKey.length < 1 || input.requestKey.length > 256 || input.requestKey !== input.requestKey.trim() || /[\u0000-\u001f\u007f]/.test(input.requestKey) ?
|
|
5143
|
+
return typeof input.requestKey != "string" || input.requestKey.length < 1 || input.requestKey.length > 256 || input.requestKey !== input.requestKey.trim() || /[\u0000-\u001f\u007f]/.test(input.requestKey) ? invalid14("invalid_request_key") : {
|
|
5144
5144
|
name: input.name,
|
|
5145
5145
|
path,
|
|
5146
5146
|
...input.storage ? { storage: input.storage } : {},
|
|
@@ -5492,6 +5492,13 @@ function publicationRequestKey(value) {
|
|
|
5492
5492
|
let options = object(value, "publication options");
|
|
5493
5493
|
return keys(options, ["requestKey"], "publication options"), id(options.requestKey, "publication request key");
|
|
5494
5494
|
}
|
|
5495
|
+
function digestPublicationRequest(value, options) {
|
|
5496
|
+
let source2 = object(value, "digest");
|
|
5497
|
+
return keys(source2, ["title", "description", "recipients", "views", "body", "notifyImmediately"], "digest"), {
|
|
5498
|
+
requestKey: publicationRequestKey(options),
|
|
5499
|
+
item: enforcePublicationSize(validatePublication({ ...source2, kind: "digest" }))
|
|
5500
|
+
};
|
|
5501
|
+
}
|
|
5495
5502
|
function createInboxPublisher(transport) {
|
|
5496
5503
|
return {
|
|
5497
5504
|
async publishAsk(value, options) {
|
|
@@ -5504,12 +5511,7 @@ function createInboxPublisher(transport) {
|
|
|
5504
5511
|
return id(result2.id, "published ask ID"), (!("revision" in result2) || !Number.isSafeInteger(result2.revision) || result2.revision !== 1) && fail("Initial ask publication must return revision 1"), { id: result2.id, revision: result2.revision };
|
|
5505
5512
|
},
|
|
5506
5513
|
async publishDigest(value, options) {
|
|
5507
|
-
let
|
|
5508
|
-
keys(source2, ["title", "description", "recipients", "views", "body", "notifyImmediately"], "digest");
|
|
5509
|
-
let result2 = await transport.publish({
|
|
5510
|
-
requestKey: publicationRequestKey(options),
|
|
5511
|
-
item: enforcePublicationSize(validatePublication({ ...source2, kind: "digest" }))
|
|
5512
|
-
});
|
|
5514
|
+
let result2 = await transport.publish(digestPublicationRequest(value, options));
|
|
5513
5515
|
return { id: id(result2.id, "published digest ID") };
|
|
5514
5516
|
},
|
|
5515
5517
|
async publishResolution(askId, value) {
|
|
@@ -5518,6 +5520,10 @@ function createInboxPublisher(transport) {
|
|
|
5518
5520
|
};
|
|
5519
5521
|
}
|
|
5520
5522
|
|
|
5523
|
+
var recordOptionCatalogueByteLimit = 7e6;
|
|
5524
|
+
function normalizeRecordOptionSearch(text5) {
|
|
5525
|
+
return text5.toLowerCase().replace(/\s+/gu, " ").trim();
|
|
5526
|
+
}
|
|
5521
5527
|
var RecordSelectionError = class extends InboxContractError {
|
|
5522
5528
|
constructor(problem, source2) {
|
|
5523
5529
|
let collection = `${source2.collection.repository}/${source2.collection.name}`, messages = {
|
|
@@ -5526,7 +5532,6 @@ var RecordSelectionError = class extends InboxContractError {
|
|
|
5526
5532
|
filter_fields_invalid: `The filters for ${collection} must use scalar schema fields and matching values. Check the Question\u2019s where fields.`,
|
|
5527
5533
|
ref_prefix_invalid: `The record reference prefix does not belong to ${collection}. Check refPrefix against the collection\u2019s record references.`,
|
|
5528
5534
|
suggestion_unavailable: `A suggested record is missing or isn\u2019t eligible for ${collection}. Update the suggestions and try again.`,
|
|
5529
|
-
selected_record_unavailable: `The selected record is no longer available in ${collection}. Search again and choose a current record.`,
|
|
5530
5535
|
label_unavailable: `A record in ${collection} has no value in the configured label fields. Update display.labelFields or the record.`
|
|
5531
5536
|
};
|
|
5532
5537
|
super(messages[problem]);
|
|
@@ -5537,6 +5542,10 @@ var RecordSelectionError = class extends InboxContractError {
|
|
|
5537
5542
|
};
|
|
5538
5543
|
|
|
5539
5544
|
var inboxPublicationRefusals = {
|
|
5545
|
+
"API clients can publish only Digests without Files Blocks": {
|
|
5546
|
+
error: "API clients can publish only Digests without Files Blocks",
|
|
5547
|
+
status: 403
|
|
5548
|
+
},
|
|
5540
5549
|
"Publication retry changed": {
|
|
5541
5550
|
error: "This request key was already used for different content. Use the original content or a new request key.",
|
|
5542
5551
|
status: 409
|
|
@@ -5784,7 +5793,6 @@ function safeInboxPublicationMessage(value) {
|
|
|
5784
5793
|
"filter_fields_invalid",
|
|
5785
5794
|
"ref_prefix_invalid",
|
|
5786
5795
|
"suggestion_unavailable",
|
|
5787
|
-
"selected_record_unavailable",
|
|
5788
5796
|
"label_unavailable"
|
|
5789
5797
|
])
|
|
5790
5798
|
if (new RecordSelectionError(problem, source2).message === message2) return message2;
|
|
@@ -6182,14 +6190,14 @@ var AIError = class extends Error {
|
|
|
6182
6190
|
code;
|
|
6183
6191
|
detail;
|
|
6184
6192
|
};
|
|
6185
|
-
function capture(value,
|
|
6193
|
+
function capture(value, invalid14, oversized, limit = ROUTINE_AI_VALUE_BYTES) {
|
|
6186
6194
|
try {
|
|
6187
6195
|
assertRoutineJson(value);
|
|
6188
6196
|
let encoded = JSON.stringify(value);
|
|
6189
6197
|
if (new TextEncoder().encode(encoded).byteLength > limit) throw new AIError(oversized);
|
|
6190
6198
|
return freezeRoutineMetadata(JSON.parse(encoded));
|
|
6191
6199
|
} catch (error) {
|
|
6192
|
-
throw error instanceof AIError ? error : new AIError(
|
|
6200
|
+
throw error instanceof AIError ? error : new AIError(invalid14);
|
|
6193
6201
|
}
|
|
6194
6202
|
}
|
|
6195
6203
|
function parseRoutineAIRequest(value) {
|
|
@@ -6254,12 +6262,12 @@ function acceptText(request3, text5) {
|
|
|
6254
6262
|
|
|
6255
6263
|
var ROUTINE_STEP_SUMMARY_BYTES = 256 * 1024, ROUTINE_STEP_OUTPUT_BYTES = 1024 * 1024;
|
|
6256
6264
|
function parseRoutineStepOutputDetail(value) {
|
|
6257
|
-
let
|
|
6265
|
+
let invalid14 = () => {
|
|
6258
6266
|
throw new AppRoutineContractError("invalid_value");
|
|
6259
6267
|
};
|
|
6260
6268
|
assertRoutineFields(value, ["step", "sizeBytes", "limitBytes", "summaryBytes", "dataBytes"]);
|
|
6261
6269
|
let { step, sizeBytes, limitBytes, summaryBytes, dataBytes } = value;
|
|
6262
|
-
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 ?
|
|
6270
|
+
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 ? invalid14() : freezeRoutineMetadata({ step, sizeBytes, limitBytes, summaryBytes, dataBytes });
|
|
6263
6271
|
}
|
|
6264
6272
|
function routineStepOutputMessage(value) {
|
|
6265
6273
|
let detail = parseRoutineStepOutputDetail(value), size = `${(detail.sizeBytes / (1024 * 1024)).toFixed(1)} MB`, bound = detail.limitBytes === ROUTINE_STEP_SUMMARY_BYTES ? `, including ${(detail.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.";
|
|
@@ -6273,9 +6281,9 @@ var RoutineStepOutputError = class extends Error {
|
|
|
6273
6281
|
super(routineStepOutputMessage(captured)), this.detail = captured, Object.freeze(this);
|
|
6274
6282
|
}
|
|
6275
6283
|
};
|
|
6276
|
-
function captureRoutineStepOutput(step,
|
|
6277
|
-
assertRoutineJson(
|
|
6278
|
-
let summaryJson = JSON.stringify(
|
|
6284
|
+
function captureRoutineStepOutput(step, summary3, data3) {
|
|
6285
|
+
assertRoutineJson(summary3), assertRoutineJson(data3);
|
|
6286
|
+
let summaryJson = JSON.stringify(summary3), dataJson = JSON.stringify(data3), summaryBytes = new TextEncoder().encode(summaryJson).byteLength, dataBytes = new TextEncoder().encode(dataJson).byteLength, sizeBytes = summaryBytes + dataBytes, limitBytes = summaryBytes > ROUTINE_STEP_SUMMARY_BYTES ? ROUTINE_STEP_SUMMARY_BYTES : ROUTINE_STEP_OUTPUT_BYTES;
|
|
6279
6287
|
if (summaryBytes > ROUTINE_STEP_SUMMARY_BYTES || sizeBytes > ROUTINE_STEP_OUTPUT_BYTES)
|
|
6280
6288
|
throw new RoutineStepOutputError({ step, sizeBytes, limitBytes, summaryBytes, dataBytes });
|
|
6281
6289
|
return freezeRoutineMetadata({ summary: JSON.parse(summaryJson), data: JSON.parse(dataJson) });
|
|
@@ -6510,8 +6518,8 @@ async function executeRoutineDefinition(definition, input, runtime) {
|
|
|
6510
6518
|
await runtime.step(id3, { status: "running" }), activeStep = id3;
|
|
6511
6519
|
let output = await steps[id3].run(saved, os2);
|
|
6512
6520
|
if (assertRoutineFields(output, ["summary", "data"]), !Object.hasOwn(output, "summary") || !Object.hasOwn(output, "data")) return invalid3();
|
|
6513
|
-
let { summary:
|
|
6514
|
-
return await runtime.step(id3, { status: "completed", summary:
|
|
6521
|
+
let { summary: summary3, data: data3 } = captureRoutineStepOutput(id3, output.summary, output.data);
|
|
6522
|
+
return await runtime.step(id3, { status: "completed", summary: summary3, data: data3 }), activeStep = void 0, freezeRoutineMetadata({ summary: summary3, data: data3 });
|
|
6515
6523
|
} catch (error) {
|
|
6516
6524
|
throw error instanceof RoutineStepOutputError && (outputFailure ??= error), broken = !0, activeStep = void 0, await runtime.step(id3, { status: "failed" }), error;
|
|
6517
6525
|
}
|
|
@@ -6632,7 +6640,26 @@ function safeRecordFieldMessage(value) {
|
|
|
6632
6640
|
let expected = parseExpectation(/\. (Expected .+) Check its definition in /.exec(value)?.[1]);
|
|
6633
6641
|
return fieldProblems.map((problem) => recordFieldMessage(parts[1], field, problem, schemaPath, expected)).find((message2) => message2 === value);
|
|
6634
6642
|
}
|
|
6643
|
+
function parsePublicationConflict(value) {
|
|
6644
|
+
if (!value || typeof value != "object" || Array.isArray(value)) throw new Error("Invalid publication conflict");
|
|
6645
|
+
let row = value;
|
|
6646
|
+
if (Object.keys(row).sort().join(",") !== "code,conflict,record" || row.code !== "publication_conflict" || !["record_version_changed", "record_missing", "create_identity_conflict", "filing_conflict", "schema_changed"].includes(String(row.conflict)) || typeof row.record != "string" || !validRecordRef(row.record)) throw new Error("Invalid publication conflict");
|
|
6647
|
+
return structuredClone(value);
|
|
6648
|
+
}
|
|
6635
6649
|
function dataValidationMessageFacts(error) {
|
|
6650
|
+
if (["invalid_change", "conflict"].includes(error.code) && error.detail && typeof error.detail == "object" && "code" in error.detail && error.detail.code === "publication_conflict")
|
|
6651
|
+
try {
|
|
6652
|
+
let detail = parsePublicationConflict(error.detail), descriptions = {
|
|
6653
|
+
record_version_changed: "changed after it was reviewed",
|
|
6654
|
+
record_missing: "is missing",
|
|
6655
|
+
create_identity_conflict: "already exists",
|
|
6656
|
+
filing_conflict: "has a conflicting filing path",
|
|
6657
|
+
schema_changed: "has an unavailable or incompatible schema"
|
|
6658
|
+
};
|
|
6659
|
+
return { detail, message: `Record "${detail.record}" ${descriptions[detail.conflict]}. No changes were saved.` };
|
|
6660
|
+
} catch {
|
|
6661
|
+
return {};
|
|
6662
|
+
}
|
|
6636
6663
|
if (error.code === "invalid_change") {
|
|
6637
6664
|
let detail = parseDataValidationDetail(error.detail);
|
|
6638
6665
|
if (detail) {
|
|
@@ -6662,22 +6689,24 @@ var localDataPath = (value, repository) => typeof value == "string" && value.len
|
|
|
6662
6689
|
return Object.keys(row).sort().join(",") === "action,path" && ["created", "updated", "deleted"].includes(String(row.action)) && localDataPath(row.path, repository);
|
|
6663
6690
|
};
|
|
6664
6691
|
function parseDataFailureDetail(value) {
|
|
6665
|
-
let
|
|
6692
|
+
let invalid14 = () => {
|
|
6666
6693
|
throw new Error("Invalid local Data failure detail");
|
|
6667
6694
|
};
|
|
6668
|
-
if (!value || typeof value != "object" || Array.isArray(value)) return
|
|
6695
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return invalid14();
|
|
6669
6696
|
let row = value;
|
|
6670
|
-
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
|
|
6697
|
+
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 invalid14();
|
|
6671
6698
|
let repository = row.repository;
|
|
6672
|
-
if (!row.cause || typeof row.cause != "object" || Array.isArray(row.cause)) return
|
|
6699
|
+
if (!row.cause || typeof row.cause != "object" || Array.isArray(row.cause)) return invalid14();
|
|
6673
6700
|
let cause = row.cause;
|
|
6674
|
-
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
|
|
6701
|
+
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 invalid14();
|
|
6675
6702
|
let files3 = row.files;
|
|
6676
|
-
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
|
|
6677
|
-
for (let key of ["savedOmitted", "notAttemptedOmitted"]) if (files3[key] !== void 0 && (!Number.isSafeInteger(files3[key]) || Number(files3[key]) < 1 || Number(files3[key]) > 1e4)) return
|
|
6678
|
-
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" ?
|
|
6703
|
+
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 invalid14();
|
|
6704
|
+
for (let key of ["savedOmitted", "notAttemptedOmitted"]) if (files3[key] !== void 0 && (!Number.isSafeInteger(files3[key]) || Number(files3[key]) < 1 || Number(files3[key]) > 1e4)) return invalid14();
|
|
6705
|
+
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" ? invalid14() : structuredClone(value);
|
|
6679
6706
|
}
|
|
6680
6707
|
function parseDataOperationDetail(value) {
|
|
6708
|
+
if (value && typeof value == "object" && !Array.isArray(value) && value.code === "publication_conflict")
|
|
6709
|
+
return parsePublicationConflict(value);
|
|
6681
6710
|
let validation = parseDataValidationDetail(value);
|
|
6682
6711
|
if (validation) return validation;
|
|
6683
6712
|
if (value && typeof value == "object" && !Array.isArray(value) && value.code === "record_limit_exceeded") {
|
|
@@ -6715,7 +6744,7 @@ function dataErrorMessage(code, effect) {
|
|
|
6715
6744
|
var DataOperationError = class extends Error {
|
|
6716
6745
|
constructor(code, retryable = !1, effect, component, detail) {
|
|
6717
6746
|
let parsed = detail === void 0 ? void 0 : parseDataOperationDetail(detail);
|
|
6718
|
-
if (parsed && ("reason" in parsed ? code !== "invalid_change" : parsed.code === "record_limit_exceeded" && code !== "capacity"))
|
|
6747
|
+
if (parsed && ("reason" in parsed ? code !== "invalid_change" : parsed.code === "publication_conflict" ? !["invalid_change", "conflict"].includes(code) : parsed.code === "record_limit_exceeded" && code !== "capacity"))
|
|
6719
6748
|
throw new Error("Invalid Data operation detail");
|
|
6720
6749
|
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));
|
|
6721
6750
|
this.code = code;
|
|
@@ -6818,21 +6847,21 @@ function captureRecordsQuery(query) {
|
|
|
6818
6847
|
return capture3(query);
|
|
6819
6848
|
}
|
|
6820
6849
|
function captureRecordsAll(query, options) {
|
|
6821
|
-
let
|
|
6850
|
+
let invalid14 = () => {
|
|
6822
6851
|
throw new DataOperationError("invalid_query");
|
|
6823
6852
|
};
|
|
6824
6853
|
try {
|
|
6825
6854
|
let properties = dataProperties(options), maxRecords = properties.maxRecords?.value;
|
|
6826
|
-
if (Object.keys(properties).join(",") !== "maxRecords" || !Number.isSafeInteger(maxRecords) || maxRecords < 1) return
|
|
6855
|
+
if (Object.keys(properties).join(",") !== "maxRecords" || !Number.isSafeInteger(maxRecords) || maxRecords < 1) return invalid14();
|
|
6827
6856
|
let detached = capture3(query), selections = dataProperties(detached);
|
|
6828
|
-
if (Object.keys(selections).length < 1 || Object.keys(selections).length > 16) return
|
|
6857
|
+
if (Object.keys(selections).length < 1 || Object.keys(selections).length > 16) return invalid14();
|
|
6829
6858
|
for (let selection2 of Object.values(selections)) {
|
|
6830
6859
|
let fields4 = dataProperties(selection2.value);
|
|
6831
|
-
if (fields4.$ && Object.hasOwn(dataProperties(fields4.$.value), "after")) return
|
|
6860
|
+
if (fields4.$ && Object.hasOwn(dataProperties(fields4.$.value), "after")) return invalid14();
|
|
6832
6861
|
}
|
|
6833
6862
|
return { query: detached, maxRecords };
|
|
6834
6863
|
} catch {
|
|
6835
|
-
return
|
|
6864
|
+
return invalid14();
|
|
6836
6865
|
}
|
|
6837
6866
|
}
|
|
6838
6867
|
|
|
@@ -7040,11 +7069,11 @@ function dataTransportError(status, value) {
|
|
|
7040
7069
|
detail = row?.detail === void 0 ? void 0 : parseDataOperationDetail(row.detail);
|
|
7041
7070
|
} catch {
|
|
7042
7071
|
}
|
|
7043
|
-
return detail && "reason" in detail && code !== "invalid_change" && (detail = void 0), explainDataValidation(new DataOperationError(
|
|
7072
|
+
return detail && ("reason" in detail && code !== "invalid_change" || "code" in detail && detail.code === "publication_conflict" && !["invalid_change", "conflict"].includes(code)) && (detail = void 0), explainDataValidation(new DataOperationError(
|
|
7044
7073
|
code,
|
|
7045
7074
|
typeof row?.retryable == "boolean" ? row.retryable : ["capacity", "unavailable", "apply_pending"].includes(code),
|
|
7046
7075
|
code === "conflict" ? "unapplied" : effect,
|
|
7047
|
-
code === "
|
|
7076
|
+
(["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,
|
|
7048
7077
|
detail
|
|
7049
7078
|
), row?.message, row?.detail);
|
|
7050
7079
|
}
|
|
@@ -7313,6 +7342,21 @@ function parseStoredRecordLink(value) {
|
|
|
7313
7342
|
return typeof value == "string" && value.startsWith("[[") && value.endsWith("]]") ? parseRecordLink(value.slice(2, -2)) : void 0;
|
|
7314
7343
|
}
|
|
7315
7344
|
|
|
7345
|
+
var NAME = /^[a-zA-Z][a-zA-Z0-9_-]*$/, invalid7 = (message2) => {
|
|
7346
|
+
throw new Error(message2);
|
|
7347
|
+
};
|
|
7348
|
+
function parseRecordDisplay(value, definitions2, fail8 = invalid7) {
|
|
7349
|
+
if (value === void 0) return;
|
|
7350
|
+
if (!value || typeof value != "object" || Array.isArray(value)) return fail8("Expected a field mapping");
|
|
7351
|
+
let row = value;
|
|
7352
|
+
if (Object.keys(row).some((key) => key !== "title") || !Object.hasOwn(row, "title") || !Array.isArray(row.title) || row.title.length < 1 || row.title.length > 2 || row.title.some((name2) => typeof name2 != "string" || !NAME.test(name2)) || new Set(row.title).size !== row.title.length) return fail8("Display title requires one or two distinct scalar fields");
|
|
7353
|
+
let title = row.title;
|
|
7354
|
+
return title.some((name2) => {
|
|
7355
|
+
let field = definitions2.find((candidate) => candidate.name === name2);
|
|
7356
|
+
return !field || field.many || ["link", "object", "map"].includes(field.kind);
|
|
7357
|
+
}) ? fail8("Display title requires one or two distinct scalar fields") : { title };
|
|
7358
|
+
}
|
|
7359
|
+
|
|
7316
7360
|
var RecordValidationError = class extends Error {
|
|
7317
7361
|
constructor(message2, path) {
|
|
7318
7362
|
super(message2);
|
|
@@ -7345,7 +7389,7 @@ function fieldExpectation(field) {
|
|
|
7345
7389
|
...field.kind === "date" && field.format ? { format: field.format } : {}
|
|
7346
7390
|
};
|
|
7347
7391
|
}
|
|
7348
|
-
var
|
|
7392
|
+
var NAME2 = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
|
7349
7393
|
function fail3(message2) {
|
|
7350
7394
|
throw new RecordValidationError(message2);
|
|
7351
7395
|
}
|
|
@@ -7358,6 +7402,9 @@ function object3(value) {
|
|
|
7358
7402
|
function keys2(row, allowed, required) {
|
|
7359
7403
|
(Object.keys(row).some((key) => !allowed.includes(key)) || required.some((key) => !Object.hasOwn(row, key))) && fail3("Unsupported or missing schema/record fields");
|
|
7360
7404
|
}
|
|
7405
|
+
function parseRecordDisplay2(value, definitions2) {
|
|
7406
|
+
return parseRecordDisplay(value, definitions2, fail3);
|
|
7407
|
+
}
|
|
7361
7408
|
function valueDefinition(value, depth, native, named = !1) {
|
|
7362
7409
|
depth > 8 && fail3("Invalid field definitions");
|
|
7363
7410
|
let row = { ...object3(value) };
|
|
@@ -7415,7 +7462,7 @@ function valueDefinition(value, depth, native, named = !1) {
|
|
|
7415
7462
|
let property = row.kind === "enum" ? "values" : "to";
|
|
7416
7463
|
check([property]);
|
|
7417
7464
|
let list2 = row.kind === "link" && typeof row.to == "string" ? [row.to] : row[property];
|
|
7418
|
-
return (!Array.isArray(list2) || !list2.length || list2.length > 1e5 || new Set(list2).size !== list2.length || list2.some((item) => typeof item != "string" || !item || row.kind === "link" && !
|
|
7465
|
+
return (!Array.isArray(list2) || !list2.length || list2.length > 1e5 || new Set(list2).size !== list2.length || list2.some((item) => typeof item != "string" || !item || row.kind === "link" && !NAME2.test(item))) && fail3("Invalid enum/link definition"), row.kind === "enum" ? { ...base, kind: "enum", values: list2 } : { ...base, kind: "link", to: list2 };
|
|
7419
7466
|
}
|
|
7420
7467
|
case "object":
|
|
7421
7468
|
return check(["fields"]), { ...base, kind: "object", fields: fields2(row.fields, depth + 1, native) };
|
|
@@ -7433,7 +7480,7 @@ function fields2(value, depth = 0, native = !1) {
|
|
|
7433
7480
|
let names = /* @__PURE__ */ new Set();
|
|
7434
7481
|
return value.map((definition) => {
|
|
7435
7482
|
let row = object3(definition);
|
|
7436
|
-
return (typeof row.name != "string" || !
|
|
7483
|
+
return (typeof row.name != "string" || !NAME2.test(row.name) || ["constructor", "prototype"].includes(row.name) || names.has(row.name)) && fail3("Invalid or duplicate field name"), names.add(row.name), { name: row.name, ...valueDefinition(row, depth, native, !0) };
|
|
7437
7484
|
});
|
|
7438
7485
|
}
|
|
7439
7486
|
function validateRecordFields(value, definitions2, resolveLink, canonical = !1) {
|
|
@@ -7532,6 +7579,16 @@ function publicDefinition(field) {
|
|
|
7532
7579
|
function publicField(field) {
|
|
7533
7580
|
return { ...publicDefinition(field), name: field.name };
|
|
7534
7581
|
}
|
|
7582
|
+
function summary({ name: name2, schema: schema2 }) {
|
|
7583
|
+
return { name: name2, type: schema2.type, ...schema2.description === void 0 ? {} : { description: schema2.description } };
|
|
7584
|
+
}
|
|
7585
|
+
function publicCollectionSchema(collection) {
|
|
7586
|
+
return {
|
|
7587
|
+
...summary(collection),
|
|
7588
|
+
...collection.schema.display ? { display: { title: [...collection.schema.display.title] } } : {},
|
|
7589
|
+
fields: collection.schema.fields.map(publicField)
|
|
7590
|
+
};
|
|
7591
|
+
}
|
|
7535
7592
|
function scalarField(name2, schema2) {
|
|
7536
7593
|
if (name2 === "$ref") return { name: name2, kind: "string", nullable: !1, many: !1 };
|
|
7537
7594
|
let field = schema2.fields.find((field2) => field2.name === name2);
|
|
@@ -7690,9 +7747,9 @@ function cursorPosition(value, binding, limit) {
|
|
|
7690
7747
|
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) ? fail4("incompatible cursor") : { position, ref };
|
|
7691
7748
|
}
|
|
7692
7749
|
|
|
7693
|
-
var
|
|
7750
|
+
var invalid8 = () => {
|
|
7694
7751
|
throw new DataOperationError("unavailable", !0);
|
|
7695
|
-
}, object4 = (value) => !value || typeof value != "object" || Array.isArray(value) ?
|
|
7752
|
+
}, object4 = (value) => !value || typeof value != "object" || Array.isArray(value) ? invalid8() : value, keys3 = (value, expected) => Object.keys(value).sort().join(",") === expected, hash = (value) => typeof value == "string" && /^[0-9a-f]{40}$/.test(value), time = (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);
|
|
7696
7753
|
function json(value) {
|
|
7697
7754
|
if (!(value === null || typeof value == "boolean" || typeof value == "number" && Number.isFinite(value) || dataText(value))) {
|
|
7698
7755
|
if (Array.isArray(value)) {
|
|
@@ -7700,7 +7757,7 @@ function json(value) {
|
|
|
7700
7757
|
return;
|
|
7701
7758
|
}
|
|
7702
7759
|
for (let [key, item] of Object.entries(object4(value))) {
|
|
7703
|
-
if (!dataText(key)) return
|
|
7760
|
+
if (!dataText(key)) return invalid8();
|
|
7704
7761
|
json(item);
|
|
7705
7762
|
}
|
|
7706
7763
|
}
|
|
@@ -7712,66 +7769,66 @@ var slot = (values, field) => Object.hasOwn(values, field) ? { present: !0, valu
|
|
|
7712
7769
|
function apply(book, event) {
|
|
7713
7770
|
let records = book.get(event.collection), prior = records.get(event.ref);
|
|
7714
7771
|
if (event.kind === "create") {
|
|
7715
|
-
if (prior) return
|
|
7772
|
+
if (prior) return invalid8();
|
|
7716
7773
|
records.set(event.ref, structuredClone(event.values));
|
|
7717
7774
|
} else if (event.kind === "delete") {
|
|
7718
|
-
if (!prior || stable(prior) !== stable(event.values)) return
|
|
7775
|
+
if (!prior || stable(prior) !== stable(event.values)) return invalid8();
|
|
7719
7776
|
records.delete(event.ref);
|
|
7720
7777
|
} else if (event.kind === "rename") {
|
|
7721
7778
|
let before = records.get(event.previousRef);
|
|
7722
|
-
if (!before || prior) return
|
|
7779
|
+
if (!before || prior) return invalid8();
|
|
7723
7780
|
records.delete(event.previousRef), records.set(event.ref, before);
|
|
7724
7781
|
} else if (event.kind === "update") {
|
|
7725
|
-
if (!prior || stable(slot(prior, event.field)) !== stable(event.before) || stable(event.before) === stable(event.after)) return
|
|
7782
|
+
if (!prior || stable(slot(prior, event.field)) !== stable(event.before) || stable(event.before) === stable(event.after)) return invalid8();
|
|
7726
7783
|
event.after.present ? Object.defineProperty(prior, event.field, { value: structuredClone(event.after.value), enumerable: !0, configurable: !0, writable: !0 }) : delete prior[event.field];
|
|
7727
7784
|
}
|
|
7728
7785
|
}
|
|
7729
7786
|
function validateSnapshotHistory(input, collections, version) {
|
|
7730
7787
|
let row = object4(input), selections = object4(row.fields);
|
|
7731
|
-
if (!keys3(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
|
|
7788
|
+
if (!keys3(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 invalid8();
|
|
7732
7789
|
let book = /* @__PURE__ */ new Map();
|
|
7733
7790
|
for (let [collection, selection2] of Object.entries(selections)) {
|
|
7734
7791
|
let selected = object4(selection2), fields4 = selected.fields;
|
|
7735
|
-
if (!Object.hasOwn(collections, collection) || !keys3(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
|
|
7792
|
+
if (!Object.hasOwn(collections, collection) || !keys3(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 invalid8();
|
|
7736
7793
|
book.set(collection, /* @__PURE__ */ new Map());
|
|
7737
7794
|
}
|
|
7738
7795
|
let history = row, seen = /* @__PURE__ */ new Set(), parent = null;
|
|
7739
7796
|
for (let group of history.commits) {
|
|
7740
|
-
if (!keys3(object4(group), "authoredAt,commit,committedAt,events,firstParent") || !hash(group.commit) || seen.has(group.commit) || group.firstParent !== parent || !time(group.authoredAt) || !time(group.committedAt) || !Array.isArray(group.events)) return
|
|
7797
|
+
if (!keys3(object4(group), "authoredAt,commit,committedAt,events,firstParent") || !hash(group.commit) || seen.has(group.commit) || group.firstParent !== parent || !time(group.authoredAt) || !time(group.committedAt) || !Array.isArray(group.events)) return invalid8();
|
|
7741
7798
|
seen.add(group.commit), parent = group.commit;
|
|
7742
7799
|
let previous, created = /* @__PURE__ */ new Set();
|
|
7743
7800
|
for (let event of group.events) {
|
|
7744
|
-
if (object4(event), !book.has(event.collection) || !validRecordRef(event.ref) || !event.ref.startsWith(`${event.collection}/`)) return
|
|
7801
|
+
if (object4(event), !book.has(event.collection) || !validRecordRef(event.ref) || !event.ref.startsWith(`${event.collection}/`)) return invalid8();
|
|
7745
7802
|
let fields4 = history.fields[event.collection].fields;
|
|
7746
7803
|
if (event.kind === "create" || event.kind === "delete") {
|
|
7747
|
-
if (!keys3(event, "collection,kind,ref,values") || Object.keys(object4(event.values)).some((field) => !fields4.includes(field))) return
|
|
7804
|
+
if (!keys3(event, "collection,kind,ref,values") || Object.keys(object4(event.values)).some((field) => !fields4.includes(field))) return invalid8();
|
|
7748
7805
|
json(event.values), event.kind === "create" && created.add(event.ref);
|
|
7749
7806
|
} else if (event.kind === "rename") {
|
|
7750
|
-
if (!keys3(event, "collection,kind,previousRef,ref") || !validRecordRef(event.previousRef) || !event.previousRef.startsWith(`${event.collection}/`) || event.previousRef === event.ref) return
|
|
7807
|
+
if (!keys3(event, "collection,kind,previousRef,ref") || !validRecordRef(event.previousRef) || !event.previousRef.startsWith(`${event.collection}/`) || event.previousRef === event.ref) return invalid8();
|
|
7751
7808
|
} else if (event.kind === "update") {
|
|
7752
|
-
if (!keys3(event, "after,before,collection,field,kind,ref") || !fields4.includes(event.field) || created.has(event.ref)) return
|
|
7809
|
+
if (!keys3(event, "after,before,collection,field,kind,ref") || !fields4.includes(event.field) || created.has(event.ref)) return invalid8();
|
|
7753
7810
|
for (let value of [event.before, event.after]) {
|
|
7754
|
-
if (object4(value), value.present === !1 ? !keys3(value, "present") : value.present !== !0 || !keys3(value, "present,value")) return
|
|
7811
|
+
if (object4(value), value.present === !1 ? !keys3(value, "present") : value.present !== !0 || !keys3(value, "present,value")) return invalid8();
|
|
7755
7812
|
value.present && json(value.value);
|
|
7756
7813
|
}
|
|
7757
|
-
} else return
|
|
7814
|
+
} else return invalid8();
|
|
7758
7815
|
let order = [event.kind === "delete" ? 0 : 1, event.ref, event.kind === "update" ? 1 : 0, event.kind === "update" ? event.field : ""];
|
|
7759
7816
|
if (previous) {
|
|
7760
7817
|
let index = order.findIndex((value, i) => value !== previous[i]);
|
|
7761
|
-
if (index === -1 || order[index] < previous[index]) return
|
|
7818
|
+
if (index === -1 || order[index] < previous[index]) return invalid8();
|
|
7762
7819
|
}
|
|
7763
7820
|
previous = order, apply(book, event);
|
|
7764
7821
|
}
|
|
7765
7822
|
let refs = /* @__PURE__ */ new Set();
|
|
7766
7823
|
for (let records of book.values()) for (let ref of records.keys()) {
|
|
7767
|
-
if (refs.has(ref)) return
|
|
7824
|
+
if (refs.has(ref)) return invalid8();
|
|
7768
7825
|
refs.add(ref);
|
|
7769
7826
|
}
|
|
7770
7827
|
}
|
|
7771
|
-
if (parent !== history.through) return
|
|
7828
|
+
if (parent !== history.through) return invalid8();
|
|
7772
7829
|
for (let [collection, records] of book) {
|
|
7773
7830
|
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]]))]);
|
|
7774
|
-
if (stable([...records].sort(([a], [b]) => a < b ? -1 : 1)) !== stable(expected)) return
|
|
7831
|
+
if (stable([...records].sort(([a], [b]) => a < b ? -1 : 1)) !== stable(expected)) return invalid8();
|
|
7775
7832
|
}
|
|
7776
7833
|
return history;
|
|
7777
7834
|
}
|
|
@@ -7798,57 +7855,60 @@ function readSnapshotHistory(history, input, operation2) {
|
|
|
7798
7855
|
};
|
|
7799
7856
|
}
|
|
7800
7857
|
|
|
7801
|
-
var snapshotCollection = (catalogue, ref) => catalogue.filter((c) => ref.startsWith(`${c.name}/`)).sort((a, b) => b.name.length - a.name.length)[0],
|
|
7858
|
+
var snapshotCollection = (catalogue, ref) => catalogue.filter((c) => ref.startsWith(`${c.name}/`)).sort((a, b) => b.name.length - a.name.length)[0], invalid9 = () => {
|
|
7802
7859
|
throw new DataOperationError("unavailable", !0);
|
|
7803
|
-
}, object5 = (value) => !value || typeof value != "object" || Array.isArray(value) ?
|
|
7860
|
+
}, object5 = (value) => !value || typeof value != "object" || Array.isArray(value) ? invalid9() : value;
|
|
7804
7861
|
function stable2(value) {
|
|
7805
7862
|
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);
|
|
7806
7863
|
}
|
|
7807
7864
|
function schemaText(value) {
|
|
7808
|
-
if (typeof value == "string" && !dataText(value)) return
|
|
7865
|
+
if (typeof value == "string" && !dataText(value)) return invalid9();
|
|
7809
7866
|
if (value && typeof value == "object") for (let [key, entry] of Object.entries(value)) {
|
|
7810
|
-
if (!dataText(key)) return
|
|
7867
|
+
if (!dataText(key)) return invalid9();
|
|
7811
7868
|
schemaText(entry);
|
|
7812
7869
|
}
|
|
7813
7870
|
}
|
|
7814
7871
|
function validateSnapshotEnvelope(input, repository, name2, bodies = [], timelines = []) {
|
|
7815
7872
|
try {
|
|
7816
7873
|
let row = object5(input), legacy = row.format === "data-snapshot.v1";
|
|
7817
|
-
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 !== name2 || !dataVersion(row.version)) return
|
|
7874
|
+
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 !== name2 || !dataVersion(row.version)) return invalid9();
|
|
7818
7875
|
let schemas2 = object5(row.schemas), collections = object5(row.collections);
|
|
7819
7876
|
schemaText(schemas2);
|
|
7820
7877
|
let names = Object.keys(collections);
|
|
7821
|
-
for (let subset of [bodies, timelines]) if (new Set(subset).size !== subset.length || subset.some((name3) => !names.includes(name3))) return
|
|
7822
|
-
if (!names.length || names.join("\0") !== [...names].sort().join("\0") || Object.keys(schemas2).join("\0") !== names.join("\0")) return
|
|
7878
|
+
for (let subset of [bodies, timelines]) if (new Set(subset).size !== subset.length || subset.some((name3) => !names.includes(name3))) return invalid9();
|
|
7879
|
+
if (!names.length || names.join("\0") !== [...names].sort().join("\0") || Object.keys(schemas2).join("\0") !== names.join("\0")) return invalid9();
|
|
7823
7880
|
let catalogue = names.map((name3) => {
|
|
7824
7881
|
let schema2 = object5(schemas2[name3]);
|
|
7825
|
-
if (!validRecordRef(`${name3}/example`) || schema2.name !== name3 || 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", "fields"].includes(key))) return
|
|
7882
|
+
if (!validRecordRef(`${name3}/example`) || schema2.name !== name3 || 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 invalid9();
|
|
7826
7883
|
let definitions2 = fields2(schema2.fields, 0, !0);
|
|
7827
|
-
|
|
7884
|
+
if (stable2(definitions2.map(publicField)) !== stable2(schema2.fields)) return invalid9();
|
|
7885
|
+
let display = parseRecordDisplay2(schema2.display, definitions2);
|
|
7886
|
+
return { name: name3, schema: {
|
|
7828
7887
|
type: schema2.type,
|
|
7829
7888
|
fields: definitions2,
|
|
7889
|
+
...display ? { display } : {},
|
|
7830
7890
|
...schema2.description === void 0 ? {} : { description: schema2.description }
|
|
7831
7891
|
} };
|
|
7832
7892
|
}), types = /* @__PURE__ */ new Map();
|
|
7833
7893
|
for (let collection of catalogue) {
|
|
7834
7894
|
let records = collections[collection.name];
|
|
7835
|
-
if (!Array.isArray(records)) return
|
|
7895
|
+
if (!Array.isArray(records)) return invalid9();
|
|
7836
7896
|
let previous = "";
|
|
7837
7897
|
for (let record4 of records) {
|
|
7838
7898
|
let value = object5(record4);
|
|
7839
|
-
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
|
|
7899
|
+
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 invalid9();
|
|
7840
7900
|
types.set(value.$ref, collection.schema.type), previous = value.$ref;
|
|
7841
7901
|
}
|
|
7842
7902
|
}
|
|
7843
7903
|
for (let collection of catalogue) for (let record4 of collections[collection.name]) {
|
|
7844
7904
|
let { $ref: _ref, $version: _version, $body, $signals, $timeline, ...values } = record4;
|
|
7845
7905
|
if (legacy) {
|
|
7846
|
-
if (Object.hasOwn(record4, "$signals") || Object.hasOwn(record4, "$timeline")) return
|
|
7906
|
+
if (Object.hasOwn(record4, "$signals") || Object.hasOwn(record4, "$timeline")) return invalid9();
|
|
7847
7907
|
} else if (captureRecordSignals($signals), timelines.includes(collection.name)) {
|
|
7848
|
-
if (!Array.isArray($timeline)) return
|
|
7908
|
+
if (!Array.isArray($timeline)) return invalid9();
|
|
7849
7909
|
$timeline.forEach((value) => captureTimeline(value));
|
|
7850
|
-
} else if (Object.hasOwn(record4, "$timeline")) return
|
|
7851
|
-
if (Object.hasOwn(record4, "$body") && (!bodies.includes(collection.name) || typeof $body != "string")) return
|
|
7910
|
+
} else if (Object.hasOwn(record4, "$timeline")) return invalid9();
|
|
7911
|
+
if (Object.hasOwn(record4, "$body") && (!bodies.includes(collection.name) || typeof $body != "string")) return invalid9();
|
|
7852
7912
|
validateRecordFields(values, collection.schema.fields, (ref, targets) => types.get(ref) ?? targets[0], !0);
|
|
7853
7913
|
}
|
|
7854
7914
|
let normalized = legacy ? Object.fromEntries(Object.entries(collections).map(([collection, records]) => [
|
|
@@ -7867,7 +7927,7 @@ function validateSnapshotEnvelope(input, repository, name2, bodies = [], timelin
|
|
|
7867
7927
|
...Object.hasOwn(row, "history") ? { history: validateSnapshotHistory(row.history, normalized, row.version) } : {}
|
|
7868
7928
|
};
|
|
7869
7929
|
} catch {
|
|
7870
|
-
return
|
|
7930
|
+
return invalid9();
|
|
7871
7931
|
}
|
|
7872
7932
|
}
|
|
7873
7933
|
|
|
@@ -7974,14 +8034,14 @@ function* evaluateRecordsQuery(query, catalogue, context, maxRecords, cloneValue
|
|
|
7974
8034
|
|
|
7975
8035
|
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";
|
|
7976
8036
|
|
|
7977
|
-
var
|
|
8037
|
+
var invalid10 = () => {
|
|
7978
8038
|
throw new DataOperationError("unavailable", !0);
|
|
7979
|
-
}, object6 = (v) => v && typeof v == "object" && !Array.isArray(v) ? v :
|
|
8039
|
+
}, object6 = (v) => v && typeof v == "object" && !Array.isArray(v) ? v : invalid10(), uuid = (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), time2 = (v) => typeof v == "string" && Number.isFinite(Date.parse(v)), recordVersion = (v) => typeof v == "string" && /^record-v1:[0-9a-f]{64}$/.test(v), keys4 = (v, allowed) => Object.keys(v).every((k) => allowed.includes(k));
|
|
7980
8040
|
function validateAcquisition(input, repository, name2) {
|
|
7981
8041
|
let row = object6(input), snapshot = object6(row.snapshot);
|
|
7982
|
-
if (Object.keys(row).sort().join(",") !== "changes,format,snapshot" || row.format !== snapshotAcquisitionFormat || !keys4(snapshot, ["id", "name", "refreshedAt", "repository", "version", "collections", "bodies", "timelines"]) || !uuid(snapshot.id) || snapshot.repository !== repository || snapshot.name !== name2 || !dataVersion(snapshot.version) || !time2(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
|
|
8042
|
+
if (Object.keys(row).sort().join(",") !== "changes,format,snapshot" || row.format !== snapshotAcquisitionFormat || !keys4(snapshot, ["id", "name", "refreshedAt", "repository", "version", "collections", "bodies", "timelines"]) || !uuid(snapshot.id) || snapshot.repository !== repository || snapshot.name !== name2 || !dataVersion(snapshot.version) || !time2(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 invalid10();
|
|
7983
8043
|
let bodies = snapshot.bodies === void 0 ? [] : snapshot.bodies, timelines = snapshot.timelines === void 0 ? [] : snapshot.timelines;
|
|
7984
|
-
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
|
|
8044
|
+
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 invalid10();
|
|
7985
8045
|
return {
|
|
7986
8046
|
snapshot: { ...snapshot, bodies, timelines },
|
|
7987
8047
|
changes: validateSnapshotChanges(row.changes, snapshot.collections)
|
|
@@ -7989,47 +8049,47 @@ function validateAcquisition(input, repository, name2) {
|
|
|
7989
8049
|
}
|
|
7990
8050
|
function validateSnapshotChanges(input, collections) {
|
|
7991
8051
|
try {
|
|
7992
|
-
if (!Array.isArray(input)) return
|
|
8052
|
+
if (!Array.isArray(input)) return invalid10();
|
|
7993
8053
|
let ids = /* @__PURE__ */ new Set(), unpublished = !1;
|
|
7994
8054
|
for (let value of input) {
|
|
7995
8055
|
let c = object6(value), effect = object6(c.effect);
|
|
7996
|
-
if (!keys4(c, ["id", "version", "ref", "recordVersion", "effect", "updatedAt", "person", "source", "publication"]) || !uuid(c.id) || ids.has(c.id) || !dataVersion(c.version) || !validRecordRef(c.ref) || !collections.some((name2) => c.ref.startsWith(`${name2}/`)) || !recordVersion(c.recordVersion) || !time2(c.updatedAt)) return
|
|
8056
|
+
if (!keys4(c, ["id", "version", "ref", "recordVersion", "effect", "updatedAt", "person", "source", "publication"]) || !uuid(c.id) || ids.has(c.id) || !dataVersion(c.version) || !validRecordRef(c.ref) || !collections.some((name2) => c.ref.startsWith(`${name2}/`)) || !recordVersion(c.recordVersion) || !time2(c.updatedAt)) return invalid10();
|
|
7997
8057
|
if (ids.add(c.id), c.person !== void 0) {
|
|
7998
8058
|
let person = object6(c.person);
|
|
7999
|
-
if (!keys4(person, ["id", "name", "email"]) || !uuid(person.id) || person.name !== void 0 && !dataText(person.name) || person.email !== void 0 && !dataText(person.email)) return
|
|
8059
|
+
if (!keys4(person, ["id", "name", "email"]) || !uuid(person.id) || person.name !== void 0 && !dataText(person.name) || person.email !== void 0 && !dataText(person.email)) return invalid10();
|
|
8000
8060
|
}
|
|
8001
8061
|
if (c.source !== void 0) {
|
|
8002
8062
|
let source2 = object6(c.source);
|
|
8003
|
-
if (Object.keys(source2).sort().join(",") !== "id,kind" || source2.kind !== "app" && source2.kind !== "routine" || !dataText(source2.id)) return
|
|
8063
|
+
if (Object.keys(source2).sort().join(",") !== "id,kind" || source2.kind !== "app" && source2.kind !== "routine" || !dataText(source2.id)) return invalid10();
|
|
8004
8064
|
}
|
|
8005
8065
|
if (c.publication !== void 0) {
|
|
8006
8066
|
let publication = object6(c.publication);
|
|
8007
|
-
if (unpublished || Object.keys(publication).sort().join(",") !== "commit,time" || typeof publication.commit != "string" || !/^[0-9a-f]{40}$/.test(publication.commit) || !time2(publication.time)) return
|
|
8067
|
+
if (unpublished || Object.keys(publication).sort().join(",") !== "commit,time" || typeof publication.commit != "string" || !/^[0-9a-f]{40}$/.test(publication.commit) || !time2(publication.time)) return invalid10();
|
|
8008
8068
|
} else unpublished = !0;
|
|
8009
8069
|
if (effect.kind === "set") {
|
|
8010
|
-
if (Object.keys(effect).sort().join(",") !== "field,kind,value" || !dataText(effect.field) || effect.field.startsWith("$") || ["id", "type", "__proto__", "constructor", "prototype"].includes(effect.field)) return
|
|
8070
|
+
if (Object.keys(effect).sort().join(",") !== "field,kind,value" || !dataText(effect.field) || effect.field.startsWith("$") || ["id", "type", "__proto__", "constructor", "prototype"].includes(effect.field)) return invalid10();
|
|
8011
8071
|
} else if (effect.kind === "link" || effect.kind === "unlink") {
|
|
8012
|
-
if (!keys4(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
|
|
8072
|
+
if (!keys4(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 invalid10();
|
|
8013
8073
|
} else if (effect.kind === "signal") {
|
|
8014
|
-
if (Object.keys(effect).sort().join(",") !== "key,kind,value") return
|
|
8074
|
+
if (Object.keys(effect).sort().join(",") !== "key,kind,value") return invalid10();
|
|
8015
8075
|
let value2 = object6(effect.value);
|
|
8016
|
-
if (!keys4(value2, ["label", "status", "reason", "related", "asOf", "number"])) return
|
|
8076
|
+
if (!keys4(value2, ["label", "status", "reason", "related", "asOf", "number"])) return invalid10();
|
|
8017
8077
|
let { number, ...assessment } = value2;
|
|
8018
8078
|
captureSignal({ ...assessment, key: effect.key }), (c.publication || Object.hasOwn(value2, "number")) && captureRecordSignal({ ...value2, key: effect.key });
|
|
8019
8079
|
} else if (effect.kind === "timeline") {
|
|
8020
|
-
if (Object.keys(effect).sort().join(",") !== "entry,kind") return
|
|
8080
|
+
if (Object.keys(effect).sort().join(",") !== "entry,kind") return invalid10();
|
|
8021
8081
|
captureTimeline(effect.entry);
|
|
8022
8082
|
} else if (effect.kind === "create" || effect.kind === "delete") {
|
|
8023
|
-
if (!keys4(effect, ["fields", "kind", "signals", "timeline"])) return
|
|
8083
|
+
if (!keys4(effect, ["fields", "kind", "signals", "timeline"])) return invalid10();
|
|
8024
8084
|
if (object6(effect.fields), Object.hasOwn(effect, "signals") && captureRecordSignals(effect.signals), Object.hasOwn(effect, "timeline")) {
|
|
8025
|
-
if (!Array.isArray(effect.timeline)) return
|
|
8085
|
+
if (!Array.isArray(effect.timeline)) return invalid10();
|
|
8026
8086
|
effect.timeline.forEach((value2) => captureTimeline(value2));
|
|
8027
8087
|
}
|
|
8028
|
-
} else return
|
|
8088
|
+
} else return invalid10();
|
|
8029
8089
|
}
|
|
8030
8090
|
return input;
|
|
8031
8091
|
} catch {
|
|
8032
|
-
return
|
|
8092
|
+
return invalid10();
|
|
8033
8093
|
}
|
|
8034
8094
|
}
|
|
8035
8095
|
function materializeSnapshot(envelope, changes, version) {
|
|
@@ -8038,13 +8098,13 @@ function materializeSnapshot(envelope, changes, version) {
|
|
|
8038
8098
|
let rows = new Map(Object.values(envelope.collections).flat().map((r) => [r.$ref, structuredClone(r)]));
|
|
8039
8099
|
for (let c of changes) {
|
|
8040
8100
|
let schema2 = snapshotCollection(envelope.catalogue, c.ref);
|
|
8041
|
-
if (!schema2) return
|
|
8101
|
+
if (!schema2) return invalid10();
|
|
8042
8102
|
let effect = c.effect, definitions2 = "field" in effect ? schema2.schema.fields.filter((f) => f.name === effect.field) : schema2.schema.fields;
|
|
8043
|
-
if ("field" in effect && !definitions2.length) return
|
|
8103
|
+
if ("field" in effect && !definitions2.length) return invalid10();
|
|
8044
8104
|
let values;
|
|
8045
8105
|
if (effect.kind === "link" || effect.kind === "unlink") {
|
|
8046
8106
|
let field = definitions2[0];
|
|
8047
|
-
if (field.kind !== "link" || !field.many && effect.kind === "link" && effect.refs.length !== 1) return
|
|
8107
|
+
if (field.kind !== "link" || !field.many && effect.kind === "link" && effect.refs.length !== 1) return invalid10();
|
|
8048
8108
|
let targets = [...effect.refs, ...effect.kind === "link" ? effect.remove ?? [] : []];
|
|
8049
8109
|
for (let ref of targets) validateRecordFields({ [effect.field]: field.many ? [ref] : ref }, definitions2, (_ref, allowed) => allowed[0], !0);
|
|
8050
8110
|
values = { [effect.field]: field.many ? effect.refs : effect.refs[0] };
|
|
@@ -8057,25 +8117,25 @@ function materializeSnapshot(envelope, changes, version) {
|
|
|
8057
8117
|
), !c.publication) continue;
|
|
8058
8118
|
let prior = rows.get(c.ref);
|
|
8059
8119
|
if (effect.kind === "set") {
|
|
8060
|
-
if (!prior) return
|
|
8120
|
+
if (!prior) return invalid10();
|
|
8061
8121
|
rows.set(c.ref, { ...prior, [effect.field]: effect.value, $version: c.recordVersion });
|
|
8062
8122
|
} else if (effect.kind === "link" || effect.kind === "unlink") {
|
|
8063
|
-
if (!prior) return
|
|
8123
|
+
if (!prior) return invalid10();
|
|
8064
8124
|
let field = definitions2[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;
|
|
8065
8125
|
rows.set(c.ref, { ...prior, [effect.field]: value, $version: c.recordVersion });
|
|
8066
8126
|
} else if (effect.kind === "signal") {
|
|
8067
|
-
if (!prior || !effect.value.number) return
|
|
8127
|
+
if (!prior || !effect.value.number) return invalid10();
|
|
8068
8128
|
let signal = captureRecordSignal({ ...effect.value, key: effect.key }), signals = captureRecordSignals(prior.$signals), index = signals.findIndex((row) => row.key === effect.key);
|
|
8069
8129
|
index < 0 ? signals.push(signal) : signals[index] = signal, rows.set(c.ref, { ...prior, $signals: captureRecordSignals(signals), $version: c.recordVersion });
|
|
8070
8130
|
} else if (effect.kind === "timeline") {
|
|
8071
|
-
if (!prior) return
|
|
8131
|
+
if (!prior) return invalid10();
|
|
8072
8132
|
rows.set(c.ref, {
|
|
8073
8133
|
...prior,
|
|
8074
8134
|
$version: c.recordVersion,
|
|
8075
8135
|
...envelope.timelineCollections.includes(schema2.name) ? { $timeline: [...prior.$timeline, effect.entry] } : {}
|
|
8076
8136
|
});
|
|
8077
8137
|
} else if (effect.kind === "create") {
|
|
8078
|
-
if (prior) return
|
|
8138
|
+
if (prior) return invalid10();
|
|
8079
8139
|
rows.set(c.ref, {
|
|
8080
8140
|
...effect.fields,
|
|
8081
8141
|
$ref: c.ref,
|
|
@@ -8084,7 +8144,7 @@ function materializeSnapshot(envelope, changes, version) {
|
|
|
8084
8144
|
...envelope.timelineCollections.includes(schema2.name) ? { $timeline: effect.timeline ?? [] } : {}
|
|
8085
8145
|
});
|
|
8086
8146
|
} else {
|
|
8087
|
-
if (!prior) return
|
|
8147
|
+
if (!prior) return invalid10();
|
|
8088
8148
|
rows.delete(c.ref);
|
|
8089
8149
|
}
|
|
8090
8150
|
}
|
|
@@ -8093,16 +8153,11 @@ function materializeSnapshot(envelope, changes, version) {
|
|
|
8093
8153
|
repository: envelope.repository,
|
|
8094
8154
|
name: envelope.name,
|
|
8095
8155
|
version,
|
|
8096
|
-
schemas: Object.fromEntries(envelope.catalogue.map((c) => [c.name,
|
|
8097
|
-
name: c.name,
|
|
8098
|
-
type: c.schema.type,
|
|
8099
|
-
...c.schema.description === void 0 ? {} : { description: c.schema.description },
|
|
8100
|
-
fields: c.schema.fields.map(publicField)
|
|
8101
|
-
}])),
|
|
8156
|
+
schemas: Object.fromEntries(envelope.catalogue.map((c) => [c.name, publicCollectionSchema(c)])),
|
|
8102
8157
|
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)]))
|
|
8103
8158
|
}, envelope.repository, envelope.name, envelope.bodyCollections, envelope.timelineCollections), ...envelope.history ? { history: envelope.history } : {} };
|
|
8104
8159
|
} catch {
|
|
8105
|
-
return
|
|
8160
|
+
return invalid10();
|
|
8106
8161
|
}
|
|
8107
8162
|
}
|
|
8108
8163
|
|
|
@@ -8144,12 +8199,7 @@ function applySnapshotMutation(envelope, prior, mutation, installation) {
|
|
|
8144
8199
|
repository: envelope.repository,
|
|
8145
8200
|
name: envelope.name,
|
|
8146
8201
|
version: `snapshot-${crypto.randomUUID()}`,
|
|
8147
|
-
schemas: Object.fromEntries(envelope.catalogue.map((c) => [c.name,
|
|
8148
|
-
name: c.name,
|
|
8149
|
-
type: c.schema.type,
|
|
8150
|
-
...c.schema.description === void 0 ? {} : { description: c.schema.description },
|
|
8151
|
-
fields: c.schema.fields.map(publicField)
|
|
8152
|
-
}])),
|
|
8202
|
+
schemas: Object.fromEntries(envelope.catalogue.map((c) => [c.name, publicCollectionSchema(c)])),
|
|
8153
8203
|
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)]))
|
|
8154
8204
|
}, envelope.repository, envelope.name, envelope.bodyCollections, envelope.timelineCollections), { envelope, changes };
|
|
8155
8205
|
}
|
|
@@ -8596,19 +8646,19 @@ function captureSelection(input) {
|
|
|
8596
8646
|
}
|
|
8597
8647
|
}
|
|
8598
8648
|
|
|
8599
|
-
var
|
|
8649
|
+
var invalid11 = () => {
|
|
8600
8650
|
throw new DataOperationError("invalid_query");
|
|
8601
8651
|
};
|
|
8602
8652
|
function captureSnapshotAll(query, options) {
|
|
8603
8653
|
let properties = dataProperties(options);
|
|
8604
|
-
return Object.keys(properties).some((key) => !["maxRecords", "body", "timeline"].includes(key)) || properties.body && properties.body.value !== !0 || properties.timeline && properties.timeline.value !== !0 ?
|
|
8654
|
+
return Object.keys(properties).some((key) => !["maxRecords", "body", "timeline"].includes(key)) || properties.body && properties.body.value !== !0 || properties.timeline && properties.timeline.value !== !0 ? invalid11() : { ...captureRecordsAll(query, { maxRecords: properties.maxRecords?.value }), body: properties.body?.value === !0, timeline: properties.timeline?.value === !0 };
|
|
8605
8655
|
}
|
|
8606
8656
|
var safeName = (value) => typeof value == "string" && /^[a-z0-9][a-z0-9._-]{0,127}$/.test(value) && !value.includes("..");
|
|
8607
8657
|
function createSnapshotInitializer(resolve = resolveSnapshotContext, open = openSnapshotStore, connect = (url, protocols) => new WebSocket(url, protocols)) {
|
|
8608
8658
|
let pending = /* @__PURE__ */ new WeakMap();
|
|
8609
8659
|
return async function(input) {
|
|
8610
8660
|
let properties = dataProperties(input), repository = properties.repository?.value, snapshot = properties.snapshot?.value;
|
|
8611
|
-
if (Object.keys(properties).sort().join(",") !== "repository,snapshot" || !safeName(repository) || !safeName(snapshot)) return
|
|
8661
|
+
if (Object.keys(properties).sort().join(",") !== "repository,snapshot" || !safeName(repository) || !safeName(snapshot)) return invalid11();
|
|
8612
8662
|
let authority2 = await resolve(), invalidated = !1, stopLive, assertCurrent = () => {
|
|
8613
8663
|
if (invalidated || authority2.signal.aborted || !authority2.isCurrent() || !authority2.refresh && authority2.expiresAt <= Date.now())
|
|
8614
8664
|
throw invalidated = !0, stopLive?.(), new DataOperationError("context_unavailable");
|
|
@@ -8766,7 +8816,7 @@ function createSnapshotInitializer(resolve = resolveSnapshotContext, open = open
|
|
|
8766
8816
|
let store;
|
|
8767
8817
|
try {
|
|
8768
8818
|
let selections = planIndexQuery(captured, pinned.catalogue), checkTimeline = (collection, selection2) => {
|
|
8769
|
-
if ((timeline || selection2.timeline) && !pinned.timelineCollections.includes(collection)) return
|
|
8819
|
+
if ((timeline || selection2.timeline) && !pinned.timelineCollections.includes(collection)) return invalid11();
|
|
8770
8820
|
for (let link of selection2.links) for (let [name2, nested] of link.targets) checkTimeline(name2, nested);
|
|
8771
8821
|
};
|
|
8772
8822
|
for (let { name: name2, selection: selection2 } of selections) checkTimeline(name2, selection2);
|
|
@@ -8844,7 +8894,7 @@ function createSnapshotInitializer(resolve = resolveSnapshotContext, open = open
|
|
|
8844
8894
|
return snapshotCollection(installation.catalogue, captured) ? writes.then(() => {
|
|
8845
8895
|
let pinned = installation;
|
|
8846
8896
|
return localRead(async (store) => {
|
|
8847
|
-
if (timeline && !pinned.timelineCollections.includes(snapshotCollection(pinned.catalogue, captured).name)) return
|
|
8897
|
+
if (timeline && !pinned.timelineCollections.includes(snapshotCollection(pinned.catalogue, captured).name)) return invalid11();
|
|
8848
8898
|
let record4 = await store.read(pinned, captured);
|
|
8849
8899
|
if (!record4) return record4;
|
|
8850
8900
|
let { $body, $timeline, ...structured } = record4;
|
|
@@ -9031,7 +9081,7 @@ async function hostedContent(url, init2, parent, upstream = fetch, check = async
|
|
|
9031
9081
|
}
|
|
9032
9082
|
}
|
|
9033
9083
|
|
|
9034
|
-
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 = [],
|
|
9084
|
+
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 = [], invalid12 = () => new FileOperationError("invalid_input", 400), unavailable4 = () => new FileOperationError("unavailable", 503, !0), failures = {
|
|
9035
9085
|
400: ["invalid_input", "unsupported_context"],
|
|
9036
9086
|
401: ["unauthenticated"],
|
|
9037
9087
|
403: ["access_denied"],
|
|
@@ -9187,7 +9237,7 @@ async function send(suffix, init2, descriptor, initial, parent) {
|
|
|
9187
9237
|
throw unavailable4();
|
|
9188
9238
|
}
|
|
9189
9239
|
function idPath(id3) {
|
|
9190
|
-
if (typeof id3 != "string" || !FILE_ID_PATTERN.test(id3)) throw
|
|
9240
|
+
if (typeof id3 != "string" || !FILE_ID_PATTERN.test(id3)) throw invalid12();
|
|
9191
9241
|
return `/${id3}`;
|
|
9192
9242
|
}
|
|
9193
9243
|
async function multipartCreate(input, metadata, exchange, release, upload, expectedSha256) {
|
|
@@ -9230,18 +9280,18 @@ async function multipartCreate(input, metadata, exchange, release, upload, expec
|
|
|
9230
9280
|
if (!chunk || offset === chunk.byteLength) {
|
|
9231
9281
|
chunk = void 0, offset = 0;
|
|
9232
9282
|
let value2 = await next();
|
|
9233
|
-
if (value2.done || !(value2.value instanceof Uint8Array) || (chunk = value2.value, chunk.byteLength > metadata.size - sent - filled)) throw
|
|
9283
|
+
if (value2.done || !(value2.value instanceof Uint8Array) || (chunk = value2.value, chunk.byteLength > metadata.size - sent - filled)) throw invalid12();
|
|
9234
9284
|
}
|
|
9235
9285
|
let take = Math.min(length - filled, chunk.byteLength - offset);
|
|
9236
9286
|
part.set(chunk.subarray(offset, offset + take), filled), filled += take, offset += take, offset === chunk.byteLength && (chunk = void 0, offset = 0);
|
|
9237
9287
|
}
|
|
9238
9288
|
}
|
|
9239
|
-
if (part.byteLength !== length) throw
|
|
9289
|
+
if (part.byteLength !== length) throw invalid12();
|
|
9240
9290
|
if (reader && sent + length === metadata.size)
|
|
9241
9291
|
for (lastProgress = Date.now(); ; ) {
|
|
9242
9292
|
let value2 = await next();
|
|
9243
9293
|
if (value2.done) break;
|
|
9244
|
-
if (!(value2.value instanceof Uint8Array) || value2.value.byteLength) throw
|
|
9294
|
+
if (!(value2.value instanceof Uint8Array) || value2.value.byteLength) throw invalid12();
|
|
9245
9295
|
}
|
|
9246
9296
|
let value = await request3((signal) => exchange(`${route}/part`, {
|
|
9247
9297
|
method: "POST",
|
|
@@ -9255,7 +9305,7 @@ async function multipartCreate(input, metadata, exchange, release, upload, expec
|
|
|
9255
9305
|
}
|
|
9256
9306
|
if (upload) for (let name2 of Object.keys(upload.file.enrichments)) {
|
|
9257
9307
|
let bytes = await request3(() => upload.enrichment(name2));
|
|
9258
|
-
if (bytes.byteLength !== upload.file.enrichments[name2].size || bytes.byteLength > MAX_BYTES) throw
|
|
9308
|
+
if (bytes.byteLength !== upload.file.enrichments[name2].size || bytes.byteLength > MAX_BYTES) throw invalid12();
|
|
9259
9309
|
await request3((signal) => exchange(`${route}/enrichments/${encodeURIComponent(name2)}`, {
|
|
9260
9310
|
method: "POST",
|
|
9261
9311
|
headers: { "content-type": "application/octet-stream", "x-os-transfer": ticket },
|
|
@@ -9297,7 +9347,7 @@ async function operation(work, initial, parent) {
|
|
|
9297
9347
|
function contentPath(id3, name2) {
|
|
9298
9348
|
let path = idPath(id3);
|
|
9299
9349
|
if (name2 === void 0) return `${path}/content`;
|
|
9300
|
-
if (!safeEnrichmentName(name2)) throw
|
|
9350
|
+
if (!safeEnrichmentName(name2)) throw invalid12();
|
|
9301
9351
|
return `${path}/enrichments/${encodeURIComponent(name2)}/content`;
|
|
9302
9352
|
}
|
|
9303
9353
|
async function read(id3, names) {
|
|
@@ -9306,12 +9356,12 @@ async function read(id3, names) {
|
|
|
9306
9356
|
let path = contentPath(id3, names);
|
|
9307
9357
|
return operation((context2, signal) => send(path, { method: "GET" }, !1, context2, signal), context);
|
|
9308
9358
|
}
|
|
9309
|
-
if (!Array.isArray(names)) throw
|
|
9359
|
+
if (!Array.isArray(names)) throw invalid12();
|
|
9310
9360
|
let distinct = [], seen = /* @__PURE__ */ new Set();
|
|
9311
9361
|
for (let name2 of names) {
|
|
9312
|
-
if (typeof name2 != "string" || !safeEnrichmentName(name2)) throw
|
|
9362
|
+
if (typeof name2 != "string" || !safeEnrichmentName(name2)) throw invalid12();
|
|
9313
9363
|
if (!seen.has(name2)) {
|
|
9314
|
-
if (seen.size === 16) throw
|
|
9364
|
+
if (seen.size === 16) throw invalid12();
|
|
9315
9365
|
seen.add(name2), distinct.push(name2);
|
|
9316
9366
|
}
|
|
9317
9367
|
}
|
|
@@ -9351,9 +9401,9 @@ var files = {
|
|
|
9351
9401
|
async create(input, options) {
|
|
9352
9402
|
let context = await resolveFilesContext();
|
|
9353
9403
|
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")))
|
|
9354
|
-
throw
|
|
9404
|
+
throw invalid12();
|
|
9355
9405
|
let blob = input.file instanceof Blob, array3 = input.file instanceof Uint8Array, stream = input.file instanceof ReadableStream;
|
|
9356
|
-
if (!blob && !array3 && !stream) throw
|
|
9406
|
+
if (!blob && !array3 && !stream) throw invalid12();
|
|
9357
9407
|
let intrinsic = blob ? input.file.size : array3 ? input.file.byteLength : void 0;
|
|
9358
9408
|
if (intrinsic !== void 0 && input.size !== void 0 && input.size !== intrinsic)
|
|
9359
9409
|
throw !Number.isSafeInteger(input.size) || input.size < 0 ? new FileOperationError("invalid_input", 400, !1, { reason: "invalid_size" }) : new FileOperationError(
|
|
@@ -9374,7 +9424,7 @@ var files = {
|
|
|
9374
9424
|
}, FILE_ORIGINAL_MAX_BYTES);
|
|
9375
9425
|
if (!context.local && !context.localFiles && metadata.storage === "local") throw new FileOperationError("unsupported_context", 400);
|
|
9376
9426
|
let header = encodeURIComponent(JSON.stringify(metadata));
|
|
9377
|
-
if (new TextEncoder().encode(header).byteLength > METADATA_BYTES) throw
|
|
9427
|
+
if (new TextEncoder().encode(header).byteLength > METADATA_BYTES) throw invalid12();
|
|
9378
9428
|
let release = await acquireSlot(context.signal);
|
|
9379
9429
|
if (context.localFiles && !routineTransport() && metadata.size > MAX_BYTES)
|
|
9380
9430
|
try {
|
|
@@ -9423,7 +9473,7 @@ var files = {
|
|
|
9423
9473
|
},
|
|
9424
9474
|
async enrich(input) {
|
|
9425
9475
|
let context = await resolveFilesContext();
|
|
9426
|
-
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
|
|
9476
|
+
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 invalid12();
|
|
9427
9477
|
let path = `${idPath(input.file)}/enrichments`;
|
|
9428
9478
|
if (typeof input.content == "string" ? input.content.length > MAX_BYTES : input.content.byteLength > MAX_BYTES)
|
|
9429
9479
|
throw new FileOperationError("request_too_large", 413);
|
|
@@ -9440,7 +9490,7 @@ var files = {
|
|
|
9440
9490
|
...input.mediaType === void 0 ? {} : { mediaType: input.mediaType },
|
|
9441
9491
|
...input.replace === void 0 ? {} : { replace: input.replace }
|
|
9442
9492
|
}, MAX_BYTES), header = encodeURIComponent(JSON.stringify(metadata));
|
|
9443
|
-
if (new TextEncoder().encode(header).byteLength > METADATA_BYTES) throw
|
|
9493
|
+
if (new TextEncoder().encode(header).byteLength > METADATA_BYTES) throw invalid12();
|
|
9444
9494
|
let result2 = await send(path, { method: "POST", headers: {
|
|
9445
9495
|
"content-type": "application/octet-stream",
|
|
9446
9496
|
"x-os-enrichment": header
|
|
@@ -9820,6 +9870,71 @@ function runtimeConnections() {
|
|
|
9820
9870
|
}
|
|
9821
9871
|
var connections = /* @__PURE__ */ runtimeConnections();
|
|
9822
9872
|
|
|
9873
|
+
function validApiToken(value) {
|
|
9874
|
+
return typeof value == "string" && /^os_api_[A-Za-z0-9_-]{43}$/.test(value);
|
|
9875
|
+
}
|
|
9876
|
+
|
|
9877
|
+
async function requestInboxPublication(operation2, request3, caller) {
|
|
9878
|
+
let attempt = () => {
|
|
9879
|
+
if (caller?.aborted) throw caller.reason;
|
|
9880
|
+
let timeout = AbortSignal.timeout(3e4);
|
|
9881
|
+
return request3(caller ? AbortSignal.any([caller, timeout]) : timeout);
|
|
9882
|
+
};
|
|
9883
|
+
if (operation2 !== "publish") return attempt();
|
|
9884
|
+
try {
|
|
9885
|
+
let response2 = await attempt();
|
|
9886
|
+
if (response2.status !== 408 && response2.status !== 429 && response2.status < 500) return response2;
|
|
9887
|
+
await response2.body?.cancel();
|
|
9888
|
+
} catch (error) {
|
|
9889
|
+
if (caller?.aborted) throw error;
|
|
9890
|
+
}
|
|
9891
|
+
if (caller?.aborted) throw caller.reason;
|
|
9892
|
+
return attempt();
|
|
9893
|
+
}
|
|
9894
|
+
|
|
9895
|
+
function createClient(options) {
|
|
9896
|
+
if (!options || typeof options != "object" || Array.isArray(options) || Object.keys(options).sort().join(",") !== "token,workspace" || typeof options.workspace != "string" || options.workspace.length > 63 || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(options.workspace) || ["auth", "www", "api", "os"].includes(options.workspace) || !validApiToken(options.token))
|
|
9897
|
+
throw new Error("Supply a valid workspace slug and explicit OS API token");
|
|
9898
|
+
let origin = `https://${options.workspace}.oddington.ai`, token = options.token;
|
|
9899
|
+
async function send3(operation2, request3) {
|
|
9900
|
+
if (request3.item.body?.some((block) => block.kind === "files"))
|
|
9901
|
+
throw new InboxPublicationError("API clients can publish only Digests without Files Blocks");
|
|
9902
|
+
let body = JSON.stringify(request3);
|
|
9903
|
+
try {
|
|
9904
|
+
let response2 = await requestInboxPublication(operation2, async (signal) => {
|
|
9905
|
+
let result3 = await fetch(`${origin}/api/inbox/${operation2}`, {
|
|
9906
|
+
method: "POST",
|
|
9907
|
+
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
9908
|
+
body,
|
|
9909
|
+
signal,
|
|
9910
|
+
redirect: "error",
|
|
9911
|
+
credentials: "omit",
|
|
9912
|
+
cache: "no-store"
|
|
9913
|
+
});
|
|
9914
|
+
if (result3.redirected || result3.status >= 300 && result3.status < 400) throw new InboxPublicationError(void 0);
|
|
9915
|
+
return result3;
|
|
9916
|
+
}), result2 = await response2.json();
|
|
9917
|
+
if (!response2.ok) throw new InboxPublicationError(result2?.error);
|
|
9918
|
+
if (!result2 || typeof result2 != "object" || Array.isArray(result2)) throw new InboxPublicationError(void 0);
|
|
9919
|
+
return result2;
|
|
9920
|
+
} catch (error) {
|
|
9921
|
+
throw error instanceof InboxPublicationError ? error : new InboxPublicationError(void 0);
|
|
9922
|
+
}
|
|
9923
|
+
}
|
|
9924
|
+
let publisher = createInboxPublisher({
|
|
9925
|
+
publish: (request3) => send3("publish", request3),
|
|
9926
|
+
async resolve() {
|
|
9927
|
+
throw new Error("API clients cannot resolve Asks");
|
|
9928
|
+
}
|
|
9929
|
+
});
|
|
9930
|
+
return { inbox: {
|
|
9931
|
+
async checkDigest(value, options2) {
|
|
9932
|
+
await send3("check", digestPublicationRequest(value, options2));
|
|
9933
|
+
},
|
|
9934
|
+
publishDigest: publisher.publishDigest
|
|
9935
|
+
} };
|
|
9936
|
+
}
|
|
9937
|
+
|
|
9823
9938
|
function locationIdentity(location) {
|
|
9824
9939
|
let coordinates = location.provider === "os" ? [location.file] : location.provider === "gmail" ? [location.connection, location.message, location.attachment] : location.provider === "dropbox" ? [location.connection, location.file] : location.provider === "outlook" ? [
|
|
9825
9940
|
location.connection,
|
|
@@ -9924,9 +10039,17 @@ var recordKey = ({ repository, ref }) => JSON.stringify([repository, ref]);
|
|
|
9924
10039
|
function parseInboxRecords(value) {
|
|
9925
10040
|
let result2 = serializable(value);
|
|
9926
10041
|
if (!result2 || Object.keys(result2).join() !== "records" || !Array.isArray(result2.records) || result2.records.length > 100) throw new Error("Invalid Record result");
|
|
9927
|
-
for (let entry of result2.records)
|
|
10042
|
+
for (let entry of result2.records) {
|
|
9928
10043
|
if (validateQualifiedRecordRef({ repository: entry.repository, ref: entry.ref }), Object.keys(entry).sort().join() !== "record,ref,repository,schema" || (entry.record === null ? entry.schema !== null : !entry.schema || entry.record.$ref !== entry.ref || typeof entry.record.$version != "string" || !Array.isArray(entry.schema.fields) || typeof entry.schema.name != "string"))
|
|
9929
10044
|
throw new Error("Invalid current Record");
|
|
10045
|
+
if (entry.schema)
|
|
10046
|
+
try {
|
|
10047
|
+
if (JSON.stringify(parseRecordDisplay(entry.schema.display, entry.schema.fields)) !== JSON.stringify(entry.schema.display))
|
|
10048
|
+
throw new Error("Invalid current Record");
|
|
10049
|
+
} catch {
|
|
10050
|
+
throw new Error("Invalid current Record");
|
|
10051
|
+
}
|
|
10052
|
+
}
|
|
9930
10053
|
if (new Set(result2.records.map(recordKey)).size !== result2.records.length) throw new Error("Duplicate current Record");
|
|
9931
10054
|
return result2;
|
|
9932
10055
|
}
|
|
@@ -9975,7 +10098,7 @@ function parseInboxUnavailableFailure(value, status) {
|
|
|
9975
10098
|
}
|
|
9976
10099
|
var INBOX_RESULT_BYTES = 8 * 1024 * 1024, INBOX_INPUT_BYTES = 8192, INBOX_LOCAL_INPUT_BYTES = 256 * 1024, INBOX_QUESTION_CONTRACT = "question-work-v1", INBOX_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
9977
10100
|
function isAppQuestionOperation(operation2) {
|
|
9978
|
-
return operation2 === "questions.list" || operation2 === "questions.answer" || operation2 === "questions.
|
|
10101
|
+
return operation2 === "questions.list" || operation2 === "questions.answer" || operation2 === "questions.listRecordOptions";
|
|
9979
10102
|
}
|
|
9980
10103
|
var operations = {
|
|
9981
10104
|
current: [],
|
|
@@ -9990,7 +10113,7 @@ var operations = {
|
|
|
9990
10113
|
"items.listRecipientCandidates": ["itemId"],
|
|
9991
10114
|
"items.addRecipient": ["itemId", "personId"],
|
|
9992
10115
|
"questions.answer": ["itemId", "revision", "questionId", "response", "submissionKey"],
|
|
9993
|
-
"questions.
|
|
10116
|
+
"questions.listRecordOptions": ["itemId", "revision", "questionId"]
|
|
9994
10117
|
};
|
|
9995
10118
|
function assert(value) {
|
|
9996
10119
|
if (!value) throw new Error("Invalid Inbox result");
|
|
@@ -10092,9 +10215,9 @@ function parseInboxRequest(value) {
|
|
|
10092
10215
|
throw new InboxOperationError(426, "client_update_required");
|
|
10093
10216
|
keys6(envelope, questionOperation ? ["contract", "input", "operation"] : ["input", "operation"]);
|
|
10094
10217
|
let input = { ...object8(envelope.input) }, required = operations[operation2];
|
|
10095
|
-
assert(required.every((key) => Object.hasOwn(input, key)) && Object.keys(input).every((key) => required.includes(key) || operation2 === "questions.answer" && key === "label" ||
|
|
10218
|
+
assert(required.every((key) => Object.hasOwn(input, key)) && Object.keys(input).every((key) => required.includes(key) || operation2 === "questions.answer" && key === "label" || (operation2 === "items.list" || operation2 === "questions.list") && key === "beforeNumber" || operation2 === "questions.list" && key === "routines")), operation2 === "questions.list" && (assert(Object.hasOwn(input, "routines")), assert(array2(input.routines).every(isAppRoutineName)));
|
|
10096
10219
|
for (let key of ["itemId", "personId", "fileId"]) key in input && assert(id2(input[key]));
|
|
10097
|
-
return "revision" in input && assert(integer(input.revision)), "beforeNumber" in input && assert(integer(input.beforeNumber)), "questionId" in input && assert(text4(input.questionId) && input.questionId === input.questionId.trim()), "submissionKey" in input && assert(text4(input.submissionKey) && input.submissionKey.length <= 128 && input.submissionKey === input.submissionKey.trim()), "title" in input && assert(text4(input.title)), "lifecycle" in input && assert(input.lifecycle === "open" || input.lifecycle === "closed"), "
|
|
10220
|
+
return "revision" in input && assert(integer(input.revision)), "beforeNumber" in input && assert(integer(input.beforeNumber)), "questionId" in input && assert(text4(input.questionId) && input.questionId === input.questionId.trim()), "submissionKey" in input && assert(text4(input.submissionKey) && input.submissionKey.length <= 128 && input.submissionKey === input.submissionKey.trim()), "title" in input && assert(text4(input.title)), "lifecycle" in input && assert(input.lifecycle === "open" || input.lifecycle === "closed"), "records" in input && (input.records = parseInboxRecordRefs(input.records)), "response" in input && response(input.response), "label" in input && assert(text4(input.label) && typeof input.response?.selection == "object"), assert(new TextEncoder().encode(JSON.stringify(envelope)).byteLength <= INBOX_INPUT_BYTES), "routines" in input && (input.routines = [...new Set(input.routines)]), { operation: operation2, input, ...isAppQuestionOperation(operation2) ? { contract: INBOX_QUESTION_CONTRACT } : {} };
|
|
10098
10221
|
} catch (error) {
|
|
10099
10222
|
throw error instanceof InboxOperationError ? error : new InboxOperationError(400, "invalid_input");
|
|
10100
10223
|
}
|
|
@@ -10108,7 +10231,7 @@ function parseInboxCurrent(value) {
|
|
|
10108
10231
|
}
|
|
10109
10232
|
function parseInboxItem(value) {
|
|
10110
10233
|
let item = object8(json2(value));
|
|
10111
|
-
return assert(id2(item.id) && id2(item.workspaceId) && integer(item.number) && integer(item.revision) && integer(item.activityVersion, 0) && ["ask", "digest"].includes(String(item.kind)) && ["open", "closed"].includes(String(item.lifecycle)) && text4(item.title) && text4(item.description, !0) && text4(item.author) && date(item.publishedAt) && optionalDate(item.seenAt) && optionalDate(item.digestReadAt)), item.outcome !== null && assert(text4(object8(item.outcome).outcome)), "canonicalRoutineId" in item && assert(item.canonicalRoutineId === null || isAppRoutineName(item.canonicalRoutineId)), item.kind === "ask" ? askMetadata(item) : assert(!("tags" in item) && !("recordRefs" in item)), array2(item.body).forEach(validateBlock), array2(item.views).forEach((value2) => {
|
|
10234
|
+
return assert(id2(item.id) && id2(item.workspaceId) && integer(item.number) && integer(item.revision) && integer(item.activityVersion, 0) && ["ask", "digest"].includes(String(item.kind)) && ["open", "closed"].includes(String(item.lifecycle)) && text4(item.title) && text4(item.description, !0) && text4(item.author) && date(item.publishedAt) && optionalDate(item.seenAt) && optionalDate(item.digestReadAt)), item.outcome !== null && assert(text4(object8(item.outcome).outcome)), "canonicalRoutineId" in item && assert(item.canonicalRoutineId === null || isAppRoutineName(item.canonicalRoutineId)), "apiClientId" in item && assert(item.apiClientId === null || id2(item.apiClientId) && item.kind === "digest"), item.kind === "ask" ? askMetadata(item) : assert(!("tags" in item) && !("recordRefs" in item)), array2(item.body).forEach(validateBlock), array2(item.views).forEach((value2) => {
|
|
10112
10235
|
let view = object8(value2);
|
|
10113
10236
|
assert(text4(view.id) && text4(view.view) && text4(view.implementation)), json2(view.input);
|
|
10114
10237
|
}), array2(item.people).forEach((value2) => {
|
|
@@ -10228,14 +10351,18 @@ function parseInboxResult(operation2, value) {
|
|
|
10228
10351
|
return assert(id2(addition.addedPersonId) && item.people.some((person) => person.id === addition.addedPersonId)), { ...addition, item };
|
|
10229
10352
|
}
|
|
10230
10353
|
if (operation2 === "questions.answer") return parseInboxAcceptance(value);
|
|
10231
|
-
if (operation2 === "questions.
|
|
10354
|
+
if (operation2 === "questions.listRecordOptions") {
|
|
10232
10355
|
let result2 = object8(value);
|
|
10233
|
-
|
|
10234
|
-
let
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10356
|
+
keys6(result2, ["recordType", "eligibleCount", "options"]), assert(text4(result2.recordType) && integer(result2.eligibleCount, 0));
|
|
10357
|
+
let options = array2(result2.options);
|
|
10358
|
+
assert(options.length === result2.eligibleCount);
|
|
10359
|
+
let refs = /* @__PURE__ */ new Set();
|
|
10360
|
+
return options.forEach((value2) => {
|
|
10361
|
+
let option = object8(value2);
|
|
10362
|
+
keys6(option, ["repository", "ref", "label", "searchText"]), recordReference({ repository: option.repository, ref: option.ref }), assert(text4(option.label) && option.searchText === normalizeRecordOptionSearch(option.label));
|
|
10363
|
+
let key = JSON.stringify([option.repository, option.ref]);
|
|
10364
|
+
assert(!refs.has(key)), refs.add(key);
|
|
10365
|
+
}), assert(new TextEncoder().encode(JSON.stringify(result2)).byteLength <= recordOptionCatalogueByteLimit), result2;
|
|
10239
10366
|
}
|
|
10240
10367
|
throw new Error("File content is not a JSON result");
|
|
10241
10368
|
}
|
|
@@ -10608,7 +10735,7 @@ function appContext(origin, active2, changed) {
|
|
|
10608
10735
|
}
|
|
10609
10736
|
}
|
|
10610
10737
|
async function requestInbox(operation2, input, signal) {
|
|
10611
|
-
if (!["questions.list", "questions.answer", "questions.
|
|
10738
|
+
if (!["questions.list", "questions.answer", "questions.listRecordOptions"].includes(operation2)) throw new Error("Inbox operation unavailable");
|
|
10612
10739
|
return requestChecked("inbox", { method: "POST", body: JSON.stringify({ contract: INBOX_QUESTION_CONTRACT, operation: operation2, input }), signal }, !0);
|
|
10613
10740
|
}
|
|
10614
10741
|
async function requestRoutine(key, suffix, init2 = {}) {
|
|
@@ -10963,7 +11090,7 @@ var inbox = {
|
|
|
10963
11090
|
} while (!0);
|
|
10964
11091
|
},
|
|
10965
11092
|
answer: async (input) => await send2("questions.answer", input),
|
|
10966
|
-
|
|
11093
|
+
listRecordOptions: async (input) => await send2("questions.listRecordOptions", input)
|
|
10967
11094
|
}
|
|
10968
11095
|
};
|
|
10969
11096
|
|
|
@@ -11643,7 +11770,7 @@ async function provider(configuration, guard) {
|
|
|
11643
11770
|
let { AuthClient } = await prepareProvider();
|
|
11644
11771
|
if (!guard.current(guard.revision())) throw new BrowserAuthError("stale");
|
|
11645
11772
|
let authorizationRequest, authorizationQueue = Promise.resolve(), storage = globalThis.localStorage, storageKey = `sb-${new URL(configuration.providerUrl).hostname.split(".")[0]}-auth-token`, listeners = /* @__PURE__ */ new Set(), instance;
|
|
11646
|
-
function
|
|
11773
|
+
function createClient2(clearing = !1) {
|
|
11647
11774
|
let provenance = /* @__PURE__ */ new Map(), revocation, removalRevision = clearing ? guard.revision() : void 0, lifetime = new AbortController(), alive = () => !lifetime.signal.aborted, client = new AuthClient({
|
|
11648
11775
|
url: `${configuration.providerUrl}/auth/v1`,
|
|
11649
11776
|
headers: { apikey: configuration.publishableKey, Authorization: `Bearer ${configuration.publishableKey}` },
|
|
@@ -11729,7 +11856,7 @@ async function provider(configuration, guard) {
|
|
|
11729
11856
|
lifetime.abort(), provenance.clear(), client.dispose();
|
|
11730
11857
|
} };
|
|
11731
11858
|
}
|
|
11732
|
-
let activeClient = () => (instance ??=
|
|
11859
|
+
let activeClient = () => (instance ??= createClient2()).client, retire = () => {
|
|
11733
11860
|
instance?.close(), instance = void 0;
|
|
11734
11861
|
};
|
|
11735
11862
|
activeClient();
|
|
@@ -11786,7 +11913,7 @@ async function provider(configuration, guard) {
|
|
|
11786
11913
|
}
|
|
11787
11914
|
retire();
|
|
11788
11915
|
let revision = guard.revision();
|
|
11789
|
-
instance =
|
|
11916
|
+
instance = createClient2(!0);
|
|
11790
11917
|
let client = instance.client, cleared = await instance.clearSession();
|
|
11791
11918
|
if (!guard.current(revision)) throw new BrowserAuthError("stale");
|
|
11792
11919
|
if (cleared.error) return cleared;
|
|
@@ -11826,11 +11953,11 @@ function routineRunHandle(operations2) {
|
|
|
11826
11953
|
});
|
|
11827
11954
|
}
|
|
11828
11955
|
|
|
11829
|
-
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}$/,
|
|
11956
|
+
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}$/, invalid13 = () => {
|
|
11830
11957
|
throw new Error("Run state unavailable");
|
|
11831
|
-
}, record3 = (value) => value && typeof value == "object" && !Array.isArray(value) ? value :
|
|
11958
|
+
}, record3 = (value) => value && typeof value == "object" && !Array.isArray(value) ? value : invalid13();
|
|
11832
11959
|
function time3(value) {
|
|
11833
|
-
return typeof value != "string" || value.length > 40 || !Number.isFinite(Date.parse(value)) ?
|
|
11960
|
+
return typeof value != "string" || value.length > 40 || !Number.isFinite(Date.parse(value)) ? invalid13() : value;
|
|
11834
11961
|
}
|
|
11835
11962
|
function times(value) {
|
|
11836
11963
|
return {
|
|
@@ -11839,16 +11966,16 @@ function times(value) {
|
|
|
11839
11966
|
};
|
|
11840
11967
|
}
|
|
11841
11968
|
function bounded(value) {
|
|
11842
|
-
return assertRoutineJson(value), new TextEncoder().encode(JSON.stringify(value)).byteLength > 256 * 1024 ?
|
|
11969
|
+
return assertRoutineJson(value), new TextEncoder().encode(JSON.stringify(value)).byteLength > 256 * 1024 ? invalid13() : value;
|
|
11843
11970
|
}
|
|
11844
11971
|
function progress(value) {
|
|
11845
11972
|
if (value === void 0) return {};
|
|
11846
11973
|
let v = record3(value);
|
|
11847
|
-
return Object.keys(v).sort().join(",") !== "completed,total" || !Number.isSafeInteger(v.completed) || !Number.isSafeInteger(v.total) || v.completed < 1 || v.completed > v.total ?
|
|
11974
|
+
return Object.keys(v).sort().join(",") !== "completed,total" || !Number.isSafeInteger(v.completed) || !Number.isSafeInteger(v.total) || v.completed < 1 || v.completed > v.total ? invalid13() : { progress: { completed: v.completed, total: v.total } };
|
|
11848
11975
|
}
|
|
11849
11976
|
function parseRunStep(value, expected) {
|
|
11850
11977
|
let v = record3(value);
|
|
11851
|
-
if (typeof v.id != "string" || !name.test(v.id) || expected !== void 0 && v.id !== expected || typeof v.title != "string" || !v.title.trim() || v.title.length > 256 || !["pending", "running", "completed", "failed", "skipped"].includes(v.status)) return
|
|
11978
|
+
if (typeof v.id != "string" || !name.test(v.id) || expected !== void 0 && v.id !== expected || typeof v.title != "string" || !v.title.trim() || v.title.length > 256 || !["pending", "running", "completed", "failed", "skipped"].includes(v.status)) return invalid13();
|
|
11852
11979
|
let output = captureRetainedStepOutput(v.id, {
|
|
11853
11980
|
...Object.hasOwn(v, "summary") ? { summary: v.summary } : {},
|
|
11854
11981
|
...Object.hasOwn(v, "data") ? { data: v.data } : {}
|
|
@@ -11865,23 +11992,23 @@ function parseRunStep(value, expected) {
|
|
|
11865
11992
|
}
|
|
11866
11993
|
function parseRemoteRun(value, expected = {}) {
|
|
11867
11994
|
let v = record3(value);
|
|
11868
|
-
if (typeof v.id != "string" || !uuid2.test(v.id) || expected.id !== void 0 && v.id !== expected.id || typeof v.routine != "string" || !name.test(v.routine) || expected.routine !== void 0 && v.routine !== expected.routine || v.placement !== "remote" || !["queued", "running", "succeeded", "failed"].includes(v.status) || !Array.isArray(v.steps) || v.steps.length > 64) return
|
|
11995
|
+
if (typeof v.id != "string" || !uuid2.test(v.id) || expected.id !== void 0 && v.id !== expected.id || typeof v.routine != "string" || !name.test(v.routine) || expected.routine !== void 0 && v.routine !== expected.routine || v.placement !== "remote" || !["queued", "running", "succeeded", "failed"].includes(v.status) || !Array.isArray(v.steps) || v.steps.length > 64) return invalid13();
|
|
11869
11996
|
let steps = v.steps.map((value2) => {
|
|
11870
11997
|
let step = record3(value2);
|
|
11871
|
-
return typeof step.detailAvailable != "boolean" || Object.hasOwn(step, "data") ?
|
|
11998
|
+
return typeof step.detailAvailable != "boolean" || Object.hasOwn(step, "data") ? invalid13() : { ...parseRunStep(step), detailAvailable: step.detailAvailable };
|
|
11872
11999
|
});
|
|
11873
|
-
if (new Set(steps.map((step) => step.id)).size !== steps.length) return
|
|
12000
|
+
if (new Set(steps.map((step) => step.id)).size !== steps.length) return invalid13();
|
|
11874
12001
|
let failure;
|
|
11875
12002
|
if (v.failure !== void 0) {
|
|
11876
12003
|
let f = record3(v.failure);
|
|
11877
|
-
if (v.status !== "failed" || typeof f.message != "string" || !f.message || f.message.length > 512) return
|
|
12004
|
+
if (v.status !== "failed" || typeof f.message != "string" || !f.message || f.message.length > 512) return invalid13();
|
|
11878
12005
|
if (f.code === "step_output_too_large") {
|
|
11879
12006
|
let { code, message: message2, ...facts2 } = f, detail = parseRoutineStepOutputDetail(facts2);
|
|
11880
|
-
if (!steps.some((step) => step.id === detail.step && step.status === "failed") || message2 !== routineStepOutputMessage(detail)) return
|
|
12007
|
+
if (!steps.some((step) => step.id === detail.step && step.status === "failed") || message2 !== routineStepOutputMessage(detail)) return invalid13();
|
|
11881
12008
|
failure = { code, message: message2, ...detail };
|
|
11882
12009
|
} else failure = { message: f.message };
|
|
11883
12010
|
}
|
|
11884
|
-
return Object.hasOwn(v, "result") && v.status !== "succeeded" ?
|
|
12011
|
+
return Object.hasOwn(v, "result") && v.status !== "succeeded" ? invalid13() : {
|
|
11885
12012
|
id: v.id,
|
|
11886
12013
|
routine: v.routine,
|
|
11887
12014
|
placement: "remote",
|
|
@@ -11963,7 +12090,7 @@ async function request2(key, suffix, init2, maximum = SUMMARY_BYTES, retained, r
|
|
|
11963
12090
|
clearTimeout(timeout);
|
|
11964
12091
|
}
|
|
11965
12092
|
}
|
|
11966
|
-
function
|
|
12093
|
+
function summary2(value, key, context, id3) {
|
|
11967
12094
|
if (context.kind !== "local")
|
|
11968
12095
|
try {
|
|
11969
12096
|
return (!only(value, "id,routine,placement,status,createdAt,startedAt,finishedAt,steps,result,failure") || !Array.isArray(value.steps) || value.steps.some((step) => !only(step, "id,title,status,startedAt,finishedAt,progress,summary,detailAvailable")) || value.failure !== void 0 && !validFailure(value.failure, value.steps)) && fail7("execution_unavailable"), parseRemoteRun(value, { routine: key, id: id3 });
|
|
@@ -12038,7 +12165,7 @@ function structure(value) {
|
|
|
12038
12165
|
}
|
|
12039
12166
|
function handle(key, id3, context) {
|
|
12040
12167
|
(!identifier.test(key) || !appDescriptors().some((item) => item.id === key)) && fail7("authority_unavailable"), (typeof id3 != "string" || !uuid3.test(id3)) && fail7("invalid_input");
|
|
12041
|
-
let read2 = async () =>
|
|
12168
|
+
let read2 = async () => summary2(await request2(key, `runs/${id3}`, void 0, SUMMARY_BYTES, context, !0), key, context, id3);
|
|
12042
12169
|
return routineRunHandle({
|
|
12043
12170
|
async current() {
|
|
12044
12171
|
return current(context), read2();
|
|
@@ -12101,14 +12228,14 @@ function appRoutineBinding(key) {
|
|
|
12101
12228
|
}
|
|
12102
12229
|
let context = await authority();
|
|
12103
12230
|
context.kind !== "local" && (encoded = JSON.stringify({ ...JSON.parse(encoded), startKey: crypto.randomUUID() }));
|
|
12104
|
-
let run =
|
|
12231
|
+
let run = summary2(await request2(key, "runs", { method: "POST", body: encoded }, SUMMARY_BYTES, context), key, context);
|
|
12105
12232
|
return handle(key, run.id, context);
|
|
12106
12233
|
},
|
|
12107
12234
|
runs: Object.freeze({
|
|
12108
12235
|
async list() {
|
|
12109
12236
|
let context = await authority(!0), value = await request2(key, "runs", void 0, 20 * SUMMARY_BYTES, context, !0);
|
|
12110
12237
|
if (!Array.isArray(value) || value.length > 20) return fail7("execution_unavailable");
|
|
12111
|
-
let runs = value.map((run) =>
|
|
12238
|
+
let runs = value.map((run) => summary2(run, key, context));
|
|
12112
12239
|
return new Set(runs.map((run) => run.id)).size !== runs.length && fail7("execution_unavailable"), runs;
|
|
12113
12240
|
},
|
|
12114
12241
|
async get(id3) {
|
|
@@ -12132,24 +12259,6 @@ var app = /* @__PURE__ */ Object.freeze({
|
|
|
12132
12259
|
})
|
|
12133
12260
|
});
|
|
12134
12261
|
|
|
12135
|
-
async function requestInboxPublication(operation2, request3, caller) {
|
|
12136
|
-
let attempt = () => {
|
|
12137
|
-
if (caller?.aborted) throw caller.reason;
|
|
12138
|
-
let timeout = AbortSignal.timeout(3e4);
|
|
12139
|
-
return request3(caller ? AbortSignal.any([caller, timeout]) : timeout);
|
|
12140
|
-
};
|
|
12141
|
-
if (operation2 !== "publish") return attempt();
|
|
12142
|
-
try {
|
|
12143
|
-
let response2 = await attempt();
|
|
12144
|
-
if (response2.status !== 408 && response2.status !== 429 && response2.status < 500) return response2;
|
|
12145
|
-
await response2.body?.cancel();
|
|
12146
|
-
} catch (error) {
|
|
12147
|
-
if (caller?.aborted) throw error;
|
|
12148
|
-
}
|
|
12149
|
-
if (caller?.aborted) throw caller.reason;
|
|
12150
|
-
return attempt();
|
|
12151
|
-
}
|
|
12152
|
-
|
|
12153
12262
|
function routinePublicationClient2(options = {}) {
|
|
12154
12263
|
let environment = {}, installed2 = options.request ? void 0 : routineTransport(), local2 = options.request ? void 0 : installed2?.request ?? void 0, workspace = installed2 ? "installed" : options.workspace ?? environment.OS_ROUTINE_WORKSPACE, capability = options.capability ?? (options.request ? void 0 : environment.OS_ROUTINE_RUN);
|
|
12155
12264
|
if (!workspace || !/^[a-z0-9][a-z0-9-]*$/.test(workspace) || capability !== void 0 && !/^[0-9a-f]{64}$/.test(capability))
|
|
@@ -12202,6 +12311,7 @@ export {
|
|
|
12202
12311
|
auth,
|
|
12203
12312
|
connections,
|
|
12204
12313
|
continueAsk,
|
|
12314
|
+
createClient,
|
|
12205
12315
|
data,
|
|
12206
12316
|
defineHandler,
|
|
12207
12317
|
defineResponse,
|