@oddington/sdk 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -691,8 +691,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
691
691
|
reject(e);
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
|
-
function step(
|
|
695
|
-
|
|
694
|
+
function step(result2) {
|
|
695
|
+
result2.done ? resolve(result2.value) : adopt(result2.value).then(fulfilled, rejected);
|
|
696
696
|
}
|
|
697
697
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
698
698
|
});
|
|
@@ -1332,19 +1332,19 @@ var require_common = __commonJS((exports) => {
|
|
|
1332
1332
|
}
|
|
1333
1333
|
},
|
|
1334
1334
|
flattenChunks: function(chunks) {
|
|
1335
|
-
var i2, l, len, pos, chunk,
|
|
1335
|
+
var i2, l, len, pos, chunk, result2;
|
|
1336
1336
|
len = 0;
|
|
1337
1337
|
for (i2 = 0, l = chunks.length;i2 < l; i2++) {
|
|
1338
1338
|
len += chunks[i2].length;
|
|
1339
1339
|
}
|
|
1340
|
-
|
|
1340
|
+
result2 = new Uint8Array(len);
|
|
1341
1341
|
pos = 0;
|
|
1342
1342
|
for (i2 = 0, l = chunks.length;i2 < l; i2++) {
|
|
1343
1343
|
chunk = chunks[i2];
|
|
1344
|
-
|
|
1344
|
+
result2.set(chunk, pos);
|
|
1345
1345
|
pos += chunk.length;
|
|
1346
1346
|
}
|
|
1347
|
-
return
|
|
1347
|
+
return result2;
|
|
1348
1348
|
}
|
|
1349
1349
|
};
|
|
1350
1350
|
var fnUntyped = {
|
|
@@ -3130,11 +3130,11 @@ var require_strings = __commonJS((exports) => {
|
|
|
3130
3130
|
return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));
|
|
3131
3131
|
}
|
|
3132
3132
|
}
|
|
3133
|
-
var
|
|
3133
|
+
var result2 = "";
|
|
3134
3134
|
for (var i2 = 0;i2 < len; i2++) {
|
|
3135
|
-
|
|
3135
|
+
result2 += String.fromCharCode(buf[i2]);
|
|
3136
3136
|
}
|
|
3137
|
-
return
|
|
3137
|
+
return result2;
|
|
3138
3138
|
}
|
|
3139
3139
|
exports.buf2binstring = function(buf) {
|
|
3140
3140
|
return buf2binstring(buf, buf.length);
|
|
@@ -5985,9 +5985,9 @@ var init_errors = __esm(() => {
|
|
|
5985
5985
|
}(Error);
|
|
5986
5986
|
CorruptPageTreeError = function(_super) {
|
|
5987
5987
|
__extends(CorruptPageTreeError2, _super);
|
|
5988
|
-
function CorruptPageTreeError2(targetIndex,
|
|
5988
|
+
function CorruptPageTreeError2(targetIndex, operation2) {
|
|
5989
5989
|
var _this = this;
|
|
5990
|
-
var msg = "Failed to " +
|
|
5990
|
+
var msg = "Failed to " + operation2 + " at targetIndex=" + targetIndex + " due to corrupt page tree: It is likely that one or more 'Count' entries are invalid";
|
|
5991
5991
|
_this = _super.call(this, msg) || this;
|
|
5992
5992
|
return _this;
|
|
5993
5993
|
}
|
|
@@ -7323,40 +7323,40 @@ var init_PDFContext = __esm(() => {
|
|
|
7323
7323
|
types[_i - 1] = arguments[_i];
|
|
7324
7324
|
}
|
|
7325
7325
|
var preservePDFNull = types.includes(PDFNull_default);
|
|
7326
|
-
var
|
|
7327
|
-
if (!
|
|
7326
|
+
var result2 = ref instanceof PDFRef_default ? this.indirectObjects.get(ref) : ref;
|
|
7327
|
+
if (!result2 || result2 === PDFNull_default && !preservePDFNull)
|
|
7328
7328
|
return;
|
|
7329
7329
|
for (var idx3 = 0, len2 = types.length;idx3 < len2; idx3++) {
|
|
7330
7330
|
var type = types[idx3];
|
|
7331
7331
|
if (type === PDFNull_default) {
|
|
7332
|
-
if (
|
|
7333
|
-
return
|
|
7332
|
+
if (result2 === PDFNull_default)
|
|
7333
|
+
return result2;
|
|
7334
7334
|
} else {
|
|
7335
|
-
if (
|
|
7336
|
-
return
|
|
7335
|
+
if (result2 instanceof type)
|
|
7336
|
+
return result2;
|
|
7337
7337
|
}
|
|
7338
7338
|
}
|
|
7339
|
-
throw new UnexpectedObjectTypeError(types,
|
|
7339
|
+
throw new UnexpectedObjectTypeError(types, result2);
|
|
7340
7340
|
};
|
|
7341
7341
|
PDFContext2.prototype.lookup = function(ref) {
|
|
7342
7342
|
var types = [];
|
|
7343
7343
|
for (var _i = 1;_i < arguments.length; _i++) {
|
|
7344
7344
|
types[_i - 1] = arguments[_i];
|
|
7345
7345
|
}
|
|
7346
|
-
var
|
|
7346
|
+
var result2 = ref instanceof PDFRef_default ? this.indirectObjects.get(ref) : ref;
|
|
7347
7347
|
if (types.length === 0)
|
|
7348
|
-
return
|
|
7348
|
+
return result2;
|
|
7349
7349
|
for (var idx3 = 0, len2 = types.length;idx3 < len2; idx3++) {
|
|
7350
7350
|
var type = types[idx3];
|
|
7351
7351
|
if (type === PDFNull_default) {
|
|
7352
|
-
if (
|
|
7353
|
-
return
|
|
7352
|
+
if (result2 === PDFNull_default)
|
|
7353
|
+
return result2;
|
|
7354
7354
|
} else {
|
|
7355
|
-
if (
|
|
7356
|
-
return
|
|
7355
|
+
if (result2 instanceof type)
|
|
7356
|
+
return result2;
|
|
7357
7357
|
}
|
|
7358
7358
|
}
|
|
7359
|
-
throw new UnexpectedObjectTypeError(types,
|
|
7359
|
+
throw new UnexpectedObjectTypeError(types, result2);
|
|
7360
7360
|
};
|
|
7361
7361
|
PDFContext2.prototype.getObjectRef = function(pdfObject) {
|
|
7362
7362
|
var entries = Array.from(this.indirectObjects.entries());
|
|
@@ -15922,13 +15922,13 @@ var cx = 0, cy = 0, px = 0, py = 0, sx = 0, sy = 0, parameters, parse = function
|
|
|
15922
15922
|
thArc -= 2 * Math.PI;
|
|
15923
15923
|
}
|
|
15924
15924
|
var segments = Math.ceil(Math.abs(thArc / (Math.PI * 0.5 + 0.001)));
|
|
15925
|
-
var
|
|
15925
|
+
var result2 = [];
|
|
15926
15926
|
for (var i3 = 0;i3 < segments; i3++) {
|
|
15927
15927
|
var th2 = th0 + i3 * thArc / segments;
|
|
15928
15928
|
var th3 = th0 + (i3 + 1) * thArc / segments;
|
|
15929
|
-
|
|
15929
|
+
result2[i3] = [xc, yc, th2, th3, rx, ry, sinTh, cosTh];
|
|
15930
15930
|
}
|
|
15931
|
-
return
|
|
15931
|
+
return result2;
|
|
15932
15932
|
}, segmentToBezier = function(cx1, cy1, th0, th1, rx, ry, sinTh, cosTh) {
|
|
15933
15933
|
var a00 = cosTh * rx;
|
|
15934
15934
|
var a01 = -sinTh * ry;
|
|
@@ -15942,7 +15942,7 @@ var cx = 0, cy = 0, px = 0, py = 0, sx = 0, sy = 0, parameters, parse = function
|
|
|
15942
15942
|
var y3 = cy1 + Math.sin(th1);
|
|
15943
15943
|
var x2 = x3 + t * Math.sin(th1);
|
|
15944
15944
|
var y2 = y3 - t * Math.cos(th1);
|
|
15945
|
-
var
|
|
15945
|
+
var result2 = [
|
|
15946
15946
|
a00 * x1 + a01 * y1,
|
|
15947
15947
|
a10 * x1 + a11 * y1,
|
|
15948
15948
|
a00 * x2 + a01 * y2,
|
|
@@ -15950,7 +15950,7 @@ var cx = 0, cy = 0, px = 0, py = 0, sx = 0, sy = 0, parameters, parse = function
|
|
|
15950
15950
|
a00 * x3 + a01 * y3,
|
|
15951
15951
|
a10 * x3 + a11 * y3
|
|
15952
15952
|
];
|
|
15953
|
-
return
|
|
15953
|
+
return result2;
|
|
15954
15954
|
}, svgPathToOperators = function(path) {
|
|
15955
15955
|
return apply(parse(path));
|
|
15956
15956
|
};
|
|
@@ -21329,9 +21329,22 @@ function validateRecordDelete(value) {
|
|
|
21329
21329
|
}
|
|
21330
21330
|
function validateRecordChange(value) {
|
|
21331
21331
|
const input = serializable(value);
|
|
21332
|
-
if (Array.isArray(input
|
|
21333
|
-
|
|
21334
|
-
|
|
21332
|
+
if (!input || Array.isArray(input) || typeof input !== "object" || Object.keys(input).sort().join(",") !== "records,repository" || !validRepositoryAlias(input.repository) || !Array.isArray(input.records) || !input.records.length || input.records.length > 1e4 || new Set(input.records.map((record) => record?.ref)).size !== input.records.length || new TextEncoder().encode(JSON.stringify(input)).byteLength > RECORD_WRITE_INPUT_LIMIT)
|
|
21333
|
+
throw new InboxContractError("Invalid record change batch");
|
|
21334
|
+
const writes = [], deletes = [];
|
|
21335
|
+
for (const record of input.records) {
|
|
21336
|
+
if (!record || typeof record !== "object" || Array.isArray(record))
|
|
21337
|
+
throw new InboxContractError("Invalid record change");
|
|
21338
|
+
if ("set" in record || "fields" in record)
|
|
21339
|
+
writes.push(record);
|
|
21340
|
+
else
|
|
21341
|
+
deletes.push(record);
|
|
21342
|
+
}
|
|
21343
|
+
if (writes.length)
|
|
21344
|
+
validateRecordWrite({ repository: input.repository, records: writes });
|
|
21345
|
+
if (deletes.length)
|
|
21346
|
+
validateRecordDelete({ repository: input.repository, records: deletes });
|
|
21347
|
+
return structuredClone(input);
|
|
21335
21348
|
}
|
|
21336
21349
|
function validateRoutineRecordWrite(value) {
|
|
21337
21350
|
const body = serializable(value);
|
|
@@ -21684,14 +21697,254 @@ var connections = createConnections(async (name, operation, input) => {
|
|
|
21684
21697
|
class DataOperationError extends Error {
|
|
21685
21698
|
code;
|
|
21686
21699
|
retryable;
|
|
21687
|
-
|
|
21700
|
+
effect;
|
|
21701
|
+
component;
|
|
21702
|
+
constructor(code, retryable = false, effect, component) {
|
|
21688
21703
|
super(`Data operation failed: ${code}`);
|
|
21689
21704
|
this.code = code;
|
|
21690
21705
|
this.retryable = retryable;
|
|
21706
|
+
this.effect = effect;
|
|
21707
|
+
this.component = component;
|
|
21691
21708
|
this.name = "DataOperationError";
|
|
21692
21709
|
}
|
|
21693
21710
|
}
|
|
21694
21711
|
|
|
21712
|
+
// ../../shared/data-envelope.ts
|
|
21713
|
+
var DATA_REQUEST_LIMIT = 256 * 1024;
|
|
21714
|
+
var invalidChange = () => {
|
|
21715
|
+
throw new DataOperationError("invalid_change", false, "unapplied");
|
|
21716
|
+
};
|
|
21717
|
+
function mapping(value) {
|
|
21718
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
21719
|
+
return invalidChange();
|
|
21720
|
+
if (Reflect.ownKeys(value).some((key) => typeof key !== "string" || !Object.getOwnPropertyDescriptor(value, key)?.enumerable || !Object.hasOwn(Object.getOwnPropertyDescriptor(value, key), "value")))
|
|
21721
|
+
return invalidChange();
|
|
21722
|
+
return value;
|
|
21723
|
+
}
|
|
21724
|
+
function captureValue(value, ancestors = new Set, depth = 0) {
|
|
21725
|
+
if (value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))
|
|
21726
|
+
return value;
|
|
21727
|
+
if (!value || typeof value !== "object" || ancestors.has(value) || depth > 32)
|
|
21728
|
+
return invalidChange();
|
|
21729
|
+
ancestors.add(value);
|
|
21730
|
+
try {
|
|
21731
|
+
if (Array.isArray(value)) {
|
|
21732
|
+
if (value.length > 1e5 || Object.keys(value).length !== value.length || Object.getOwnPropertySymbols(value).length)
|
|
21733
|
+
return invalidChange();
|
|
21734
|
+
return Array.from(value, (item) => captureValue(item, ancestors, depth + 1));
|
|
21735
|
+
}
|
|
21736
|
+
return Object.fromEntries(Object.entries(mapping(value)).map(([key, item]) => {
|
|
21737
|
+
if (["__proto__", "constructor", "prototype"].includes(key))
|
|
21738
|
+
return invalidChange();
|
|
21739
|
+
return [key, captureValue(item, ancestors, depth + 1)];
|
|
21740
|
+
}));
|
|
21741
|
+
} finally {
|
|
21742
|
+
ancestors.delete(value);
|
|
21743
|
+
}
|
|
21744
|
+
}
|
|
21745
|
+
function captureDataDelete(record2) {
|
|
21746
|
+
const identity = mapping(record2);
|
|
21747
|
+
if (!validRecordRef(identity.$ref) || typeof identity.$version !== "string" || !identity.$version.length || identity.$version.length > 512)
|
|
21748
|
+
return invalidChange();
|
|
21749
|
+
return { ref: identity.$ref, expectedVersion: identity.$version };
|
|
21750
|
+
}
|
|
21751
|
+
function captureDataUpdate(record2, set) {
|
|
21752
|
+
const identity = captureDataDelete(record2), fields3 = mapping(set);
|
|
21753
|
+
if (!Object.keys(fields3).length || Object.keys(fields3).some((key) => key.startsWith("$") || ["id", "type"].includes(key)))
|
|
21754
|
+
return invalidChange();
|
|
21755
|
+
return { ...identity, set: captureValue(fields3) };
|
|
21756
|
+
}
|
|
21757
|
+
function captureDataUpdates(value, allowEmpty = false) {
|
|
21758
|
+
if (!Array.isArray(value) || !allowEmpty && !value.length || value.length > 1e4)
|
|
21759
|
+
return invalidChange();
|
|
21760
|
+
const updates = value.map((item) => {
|
|
21761
|
+
const row = mapping(item);
|
|
21762
|
+
if (Object.keys(row).sort().join(",") !== "expectedVersion,ref,set")
|
|
21763
|
+
return invalidChange();
|
|
21764
|
+
return captureDataUpdate({ $ref: row.ref, $version: row.expectedVersion }, row.set);
|
|
21765
|
+
});
|
|
21766
|
+
if (new Set(updates.map((update) => update.ref)).size !== updates.length)
|
|
21767
|
+
return invalidChange();
|
|
21768
|
+
return updates;
|
|
21769
|
+
}
|
|
21770
|
+
function captureDataCreate(value) {
|
|
21771
|
+
const row = mapping(value);
|
|
21772
|
+
if (!validRecordRef(row.$ref) || Object.keys(row).some((key) => key.startsWith("$") && !["$ref", "$filing"].includes(key)))
|
|
21773
|
+
return invalidChange();
|
|
21774
|
+
const { $ref: ref, $filing, ...fields3 } = row;
|
|
21775
|
+
let filing;
|
|
21776
|
+
if ($filing !== undefined) {
|
|
21777
|
+
const components = mapping($filing);
|
|
21778
|
+
if (Object.entries(components).some(([name, value2]) => !/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(name) || ["constructor", "prototype"].includes(name) || typeof value2 !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(value2)))
|
|
21779
|
+
return invalidChange();
|
|
21780
|
+
filing = { ...components };
|
|
21781
|
+
}
|
|
21782
|
+
return { ref, fields: captureValue(fields3), ...filing ? { filing } : {} };
|
|
21783
|
+
}
|
|
21784
|
+
function captureDataChanges(updatesValue, createsValue = [], deletesValue = []) {
|
|
21785
|
+
const updates = captureDataUpdates(updatesValue, true);
|
|
21786
|
+
if (!Array.isArray(createsValue) || createsValue.length > 1e4)
|
|
21787
|
+
return invalidChange();
|
|
21788
|
+
const creates = createsValue.map((item) => {
|
|
21789
|
+
const row = mapping(item);
|
|
21790
|
+
if (Object.keys(row).some((key) => !["ref", "fields", "filing"].includes(key)) || !Object.hasOwn(row, "ref") || !Object.hasOwn(row, "fields"))
|
|
21791
|
+
return invalidChange();
|
|
21792
|
+
const fields3 = mapping(row.fields);
|
|
21793
|
+
if (Object.keys(fields3).some((key) => key.startsWith("$")))
|
|
21794
|
+
return invalidChange();
|
|
21795
|
+
return captureDataCreate({ ...fields3, $ref: row.ref, ...Object.hasOwn(row, "filing") ? { $filing: row.filing } : {} });
|
|
21796
|
+
});
|
|
21797
|
+
if (!Array.isArray(deletesValue) || deletesValue.length > 1e4)
|
|
21798
|
+
return invalidChange();
|
|
21799
|
+
const deletes = deletesValue.map((item) => {
|
|
21800
|
+
const row = mapping(item);
|
|
21801
|
+
if (Object.keys(row).sort().join(",") !== "expectedVersion,ref")
|
|
21802
|
+
return invalidChange();
|
|
21803
|
+
return captureDataDelete({ $ref: row.ref, $version: row.expectedVersion });
|
|
21804
|
+
});
|
|
21805
|
+
const refs = [...updates, ...creates, ...deletes].map((item) => item.ref);
|
|
21806
|
+
if (!refs.length || refs.length > 1e4 || new Set(refs).size !== refs.length)
|
|
21807
|
+
return invalidChange();
|
|
21808
|
+
return { updates, creates, deletes };
|
|
21809
|
+
}
|
|
21810
|
+
function checkDataRequestSize(input) {
|
|
21811
|
+
if (new TextEncoder().encode(JSON.stringify(input)).byteLength > DATA_REQUEST_LIMIT)
|
|
21812
|
+
throw new DataOperationError("request_too_large", false, "unapplied");
|
|
21813
|
+
}
|
|
21814
|
+
function dataTransportError(status, value) {
|
|
21815
|
+
const failures = {
|
|
21816
|
+
400: ["invalid_query", "invalid_change"],
|
|
21817
|
+
401: ["unauthenticated"],
|
|
21818
|
+
403: ["access_denied"],
|
|
21819
|
+
409: ["conflict", "publication_pending"],
|
|
21820
|
+
413: ["request_too_large"],
|
|
21821
|
+
429: ["capacity"],
|
|
21822
|
+
503: ["unavailable", "publication_pending"]
|
|
21823
|
+
};
|
|
21824
|
+
const error = value && typeof value === "object" && "error" in value ? value.error : undefined;
|
|
21825
|
+
const row = error && typeof error === "object" ? error : undefined;
|
|
21826
|
+
const code = failures[status]?.find((allowed) => allowed === row?.code) ?? "unavailable";
|
|
21827
|
+
const effect = ["unapplied", "uncertain", "applied"].includes(String(row?.effect)) ? row.effect : undefined;
|
|
21828
|
+
return new DataOperationError(code, ["capacity", "unavailable", "publication_pending"].includes(code), code === "conflict" ? "unapplied" : effect, code === "invalid_change" && typeof row?.component === "string" && /^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/.test(row.component) ? row.component : undefined);
|
|
21829
|
+
}
|
|
21830
|
+
|
|
21831
|
+
// ../../shared/files-contract.ts
|
|
21832
|
+
class FileOperationError extends Error {
|
|
21833
|
+
code;
|
|
21834
|
+
status;
|
|
21835
|
+
retryable;
|
|
21836
|
+
constructor(code, status, retryable = false) {
|
|
21837
|
+
super(code);
|
|
21838
|
+
this.code = code;
|
|
21839
|
+
this.status = status;
|
|
21840
|
+
this.retryable = retryable;
|
|
21841
|
+
}
|
|
21842
|
+
}
|
|
21843
|
+
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}$/;
|
|
21844
|
+
function parseFileDescriptor(value) {
|
|
21845
|
+
const invalid = () => {
|
|
21846
|
+
throw new FileOperationError("unavailable", 503, true);
|
|
21847
|
+
};
|
|
21848
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
21849
|
+
return invalid();
|
|
21850
|
+
const f = value;
|
|
21851
|
+
if (Object.keys(f).sort().join(",") !== "details,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 > 16 * 1024 * 1024 || typeof f.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(f.sha256) || !f.enrichments || typeof f.enrichments !== "object" || Array.isArray(f.enrichments) || !f.details || typeof f.details !== "object" || Array.isArray(f.details))
|
|
21852
|
+
return invalid();
|
|
21853
|
+
const d = f.details;
|
|
21854
|
+
if (d.kind === "other") {
|
|
21855
|
+
if (Object.keys(d).length !== 1 || f.mediaType !== "application/octet-stream")
|
|
21856
|
+
return invalid();
|
|
21857
|
+
} else if (d.kind === "csv") {
|
|
21858
|
+
if (Object.keys(d).sort().join(",") !== "dataRows,delimiter,encoding,headerRow,kind" || f.mediaType !== "text/csv" || !["utf-8", "windows-1252"].includes(d.encoding) || ![",", ";", "\t"].includes(d.delimiter) || !Number.isSafeInteger(d.headerRow) || d.headerRow < 1 || !Number.isSafeInteger(d.dataRows) || d.dataRows < 0)
|
|
21859
|
+
return invalid();
|
|
21860
|
+
} else
|
|
21861
|
+
return invalid();
|
|
21862
|
+
for (const [name, descriptor] of Object.entries(f.enrichments)) {
|
|
21863
|
+
if (!safeEnrichmentName(name))
|
|
21864
|
+
return invalid();
|
|
21865
|
+
parseEnrichmentDescriptor(descriptor);
|
|
21866
|
+
}
|
|
21867
|
+
if (new TextEncoder().encode(JSON.stringify(f)).byteLength > 16 * 1024)
|
|
21868
|
+
return invalid();
|
|
21869
|
+
return f;
|
|
21870
|
+
}
|
|
21871
|
+
function parseEnrichmentDescriptor(value) {
|
|
21872
|
+
const invalid = () => {
|
|
21873
|
+
throw new FileOperationError("unavailable", 503, true);
|
|
21874
|
+
};
|
|
21875
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
21876
|
+
return invalid();
|
|
21877
|
+
const d = value;
|
|
21878
|
+
if (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))
|
|
21879
|
+
return invalid();
|
|
21880
|
+
return d;
|
|
21881
|
+
}
|
|
21882
|
+
function safeEnrichmentName(value) {
|
|
21883
|
+
return safeFileName(value) && !/^original(?:\.|$)/i.test(value);
|
|
21884
|
+
}
|
|
21885
|
+
function parseFileEnrichMetadata(value, maxBytes) {
|
|
21886
|
+
const invalid = () => {
|
|
21887
|
+
throw new FileOperationError("invalid_input", 400);
|
|
21888
|
+
};
|
|
21889
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
21890
|
+
return invalid();
|
|
21891
|
+
const d = value;
|
|
21892
|
+
if (Object.keys(d).some((key) => !["name", "size", "mediaType", "replace"].includes(key)) || !safeEnrichmentName(d.name) || !Number.isSafeInteger(d.size) || d.size < 0 || d.mediaType !== undefined && (typeof d.mediaType !== "string" || d.mediaType.length > 255 || /[\u0000-\u001f\u007f]/.test(d.mediaType)) || d.replace !== undefined && (typeof d.replace !== "string" || !/^[0-9a-f]{64}$/.test(d.replace)))
|
|
21893
|
+
return invalid();
|
|
21894
|
+
if (d.size > maxBytes)
|
|
21895
|
+
throw new FileOperationError("request_too_large", 413);
|
|
21896
|
+
return d;
|
|
21897
|
+
}
|
|
21898
|
+
function safeFileName(value) {
|
|
21899
|
+
return typeof value === "string" && value.length > 0 && value.length <= 255 && value === value.trim() && value !== "." && value !== ".." && !/[\u0000-\u001f\u007f-\u009f/\\:*?"<>|]/u.test(value) && !/[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/.test(value) && !/[. ]$/.test(value) && !/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(value);
|
|
21900
|
+
}
|
|
21901
|
+
function safeFilePath(value) {
|
|
21902
|
+
return typeof value === "string" && value.length <= 1024 && value.split("/").every(safeFileName);
|
|
21903
|
+
}
|
|
21904
|
+
function parseFileCreateMetadata(value, maxBytes) {
|
|
21905
|
+
const invalid = () => {
|
|
21906
|
+
throw new FileOperationError("invalid_input", 400);
|
|
21907
|
+
};
|
|
21908
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
21909
|
+
return invalid();
|
|
21910
|
+
const input = value;
|
|
21911
|
+
if (Object.keys(input).some((key) => !["name", "path", "storage", "csv", "size", "requestKey"].includes(key)))
|
|
21912
|
+
return invalid();
|
|
21913
|
+
const path = input.path === undefined ? "Files" : input.path;
|
|
21914
|
+
if (!safeFileName(input.name) || !safeFilePath(path))
|
|
21915
|
+
return invalid();
|
|
21916
|
+
if (input.storage !== undefined && input.storage !== "remote" && input.storage !== "local")
|
|
21917
|
+
return invalid();
|
|
21918
|
+
if (!Number.isSafeInteger(input.size) || input.size < 0)
|
|
21919
|
+
return invalid();
|
|
21920
|
+
if (input.size > maxBytes)
|
|
21921
|
+
throw new FileOperationError("request_too_large", 413);
|
|
21922
|
+
if (typeof input.requestKey !== "string" || input.requestKey.length < 1 || input.requestKey.length > 256 || input.requestKey !== input.requestKey.trim() || /[\u0000-\u001f\u007f]/.test(input.requestKey))
|
|
21923
|
+
return invalid();
|
|
21924
|
+
let csv;
|
|
21925
|
+
if (input.csv !== undefined) {
|
|
21926
|
+
if (!input.csv || typeof input.csv !== "object" || Array.isArray(input.csv))
|
|
21927
|
+
return invalid();
|
|
21928
|
+
const hints = input.csv;
|
|
21929
|
+
if (Object.keys(hints).some((key) => !["encoding", "delimiter", "headerRow"].includes(key)))
|
|
21930
|
+
return invalid();
|
|
21931
|
+
const encoding = hints.encoding === undefined ? "utf-8" : hints.encoding;
|
|
21932
|
+
const delimiter = hints.delimiter === undefined ? "," : hints.delimiter;
|
|
21933
|
+
const headerRow = hints.headerRow === undefined ? 1 : hints.headerRow;
|
|
21934
|
+
if (encoding !== "utf-8" && encoding !== "windows-1252" || ![",", ";", "\t"].includes(delimiter) || !Number.isSafeInteger(headerRow) || headerRow < 1 || headerRow > 1e5)
|
|
21935
|
+
return invalid();
|
|
21936
|
+
csv = { encoding, delimiter, headerRow };
|
|
21937
|
+
}
|
|
21938
|
+
return {
|
|
21939
|
+
name: input.name,
|
|
21940
|
+
path,
|
|
21941
|
+
...input.storage ? { storage: input.storage } : {},
|
|
21942
|
+
...csv ? { csv } : {},
|
|
21943
|
+
size: input.size,
|
|
21944
|
+
requestKey: input.requestKey
|
|
21945
|
+
};
|
|
21946
|
+
}
|
|
21947
|
+
|
|
21695
21948
|
// ../../shared/os-origin.ts
|
|
21696
21949
|
var DEFAULT_ORIGIN = "https://auth.oddington.ai";
|
|
21697
21950
|
function oddingtonOrigin(environment = process.env) {
|
|
@@ -21703,14 +21956,21 @@ function oddingtonOrigin(environment = process.env) {
|
|
|
21703
21956
|
}
|
|
21704
21957
|
|
|
21705
21958
|
// src/routine-local-transport.ts
|
|
21706
|
-
|
|
21707
|
-
|
|
21708
|
-
|
|
21709
|
-
|
|
21710
|
-
|
|
21711
|
-
|
|
21712
|
-
|
|
21713
|
-
|
|
21959
|
+
function privateRoutineRequest(environment = typeof process === "undefined" ? {} : process.env) {
|
|
21960
|
+
const prepared = ["ODDINGTON_ROUTINE_LOCAL", "ODDINGTON_ROUTINE_LOCAL_SOCKET", "ODDINGTON_ROUTINE_LOCAL_TOKEN"].some((key) => environment[key] !== undefined);
|
|
21961
|
+
const managed = ["ODDINGTON_FILES_SOCKET", "ODDINGTON_FILES_TOKEN"].some((key) => environment[key] !== undefined);
|
|
21962
|
+
if (!prepared && !managed)
|
|
21963
|
+
return;
|
|
21964
|
+
const socket = prepared ? environment.ODDINGTON_ROUTINE_LOCAL_SOCKET : environment.ODDINGTON_FILES_SOCKET;
|
|
21965
|
+
const token = prepared ? environment.ODDINGTON_ROUTINE_LOCAL_TOKEN : environment.ODDINGTON_FILES_TOKEN;
|
|
21966
|
+
const request = localRoutineRequest(prepared ? environment : {
|
|
21967
|
+
ODDINGTON_ROUTINE_LOCAL: "1",
|
|
21968
|
+
ODDINGTON_ROUTINE_LOCAL_SOCKET: socket,
|
|
21969
|
+
ODDINGTON_ROUTINE_LOCAL_TOKEN: token
|
|
21970
|
+
});
|
|
21971
|
+
const isCurrent = () => prepared ? environment.ODDINGTON_ROUTINE_LOCAL === "1" && environment.ODDINGTON_ROUTINE_LOCAL_SOCKET === socket && environment.ODDINGTON_ROUTINE_LOCAL_TOKEN === token : environment.ODDINGTON_FILES_SOCKET === socket && environment.ODDINGTON_FILES_TOKEN === token;
|
|
21972
|
+
return { request, isCurrent, identity: `private:${socket}` };
|
|
21973
|
+
}
|
|
21714
21974
|
function localRoutineRequest(environment = typeof process === "undefined" ? {} : process.env) {
|
|
21715
21975
|
const {
|
|
21716
21976
|
ODDINGTON_ROUTINE_LOCAL: mode,
|
|
@@ -21720,11 +21980,11 @@ function localRoutineRequest(environment = typeof process === "undefined" ? {} :
|
|
|
21720
21980
|
if (mode === undefined && socket === undefined && token === undefined)
|
|
21721
21981
|
return;
|
|
21722
21982
|
if (mode !== "1" || !socket || !token || !/^[0-9a-f]{64}$/.test(token))
|
|
21723
|
-
throw new Error("
|
|
21983
|
+
throw new Error("Preparation transport unavailable; nothing can publish");
|
|
21724
21984
|
const tcp = /^tcp:\/\/127\.0\.0\.1:([1-9][0-9]{0,4})$/.exec(socket);
|
|
21725
21985
|
const endpoint = tcp && tcp[0] === socket && Number(tcp[1]) <= 65535 ? { hostname: "127.0.0.1", port: Number(tcp[1]) } : socket.startsWith("/") && !socket.startsWith("//") && !socket.includes("\x00") ? { socketPath: socket } : undefined;
|
|
21726
21986
|
if (!endpoint)
|
|
21727
|
-
throw new Error("
|
|
21987
|
+
throw new Error("Preparation transport unavailable; nothing can publish");
|
|
21728
21988
|
return async (operation, input) => {
|
|
21729
21989
|
const { request } = await import("node:http");
|
|
21730
21990
|
return await new Promise((resolve, reject) => {
|
|
@@ -21735,7 +21995,7 @@ function localRoutineRequest(environment = typeof process === "undefined" ? {} :
|
|
|
21735
21995
|
headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
|
|
21736
21996
|
timeout: 120000
|
|
21737
21997
|
}, (response) => {
|
|
21738
|
-
const
|
|
21998
|
+
const bytes = Buffer.alloc(33554432);
|
|
21739
21999
|
let size = 0;
|
|
21740
22000
|
response.on("data", (chunk) => {
|
|
21741
22001
|
size += chunk.length;
|
|
@@ -21743,19 +22003,37 @@ function localRoutineRequest(environment = typeof process === "undefined" ? {} :
|
|
|
21743
22003
|
response.destroy();
|
|
21744
22004
|
reject(new Error("Local result exceeds supported size"));
|
|
21745
22005
|
} else
|
|
21746
|
-
|
|
22006
|
+
bytes.set(chunk, size - chunk.length);
|
|
21747
22007
|
});
|
|
21748
22008
|
response.on("error", reject);
|
|
21749
22009
|
response.on("end", () => {
|
|
21750
22010
|
try {
|
|
21751
|
-
const result = JSON.parse(
|
|
22011
|
+
const result = JSON.parse(bytes.subarray(0, size).toString());
|
|
21752
22012
|
if (response.statusCode !== 200) {
|
|
22013
|
+
if (operation === "files/request") {
|
|
22014
|
+
const error = result.error;
|
|
22015
|
+
const status = response.statusCode ?? 503;
|
|
22016
|
+
const codes = [
|
|
22017
|
+
"invalid_input",
|
|
22018
|
+
"unsupported_context",
|
|
22019
|
+
"unauthenticated",
|
|
22020
|
+
"access_denied",
|
|
22021
|
+
"request_too_large",
|
|
22022
|
+
"conflict",
|
|
22023
|
+
"local_only",
|
|
22024
|
+
"integrity",
|
|
22025
|
+
"unavailable",
|
|
22026
|
+
"capacity",
|
|
22027
|
+
"method_not_allowed"
|
|
22028
|
+
];
|
|
22029
|
+
if (error?.code && codes.includes(error.code))
|
|
22030
|
+
throw new FileOperationError(error.code, status, error.code === "capacity" || error.code === "unavailable");
|
|
22031
|
+
throw new FileOperationError("unavailable", 503, true);
|
|
22032
|
+
}
|
|
21753
22033
|
if (operation === "data/query") {
|
|
21754
|
-
|
|
21755
|
-
const code = dataFailures[response.statusCode ?? 0]?.find((allowed) => allowed === received) ?? "unavailable";
|
|
21756
|
-
throw new DataOperationError(code, code === "capacity" || code === "unavailable");
|
|
22034
|
+
throw dataTransportError(response.statusCode ?? 0, result);
|
|
21757
22035
|
}
|
|
21758
|
-
throw new Error(typeof result.error === "string" ? result.error : "
|
|
22036
|
+
throw new Error(typeof result.error === "string" ? result.error : "Preparation failed");
|
|
21759
22037
|
}
|
|
21760
22038
|
resolve(result);
|
|
21761
22039
|
} catch (error) {
|
|
@@ -21763,8 +22041,8 @@ function localRoutineRequest(environment = typeof process === "undefined" ? {} :
|
|
|
21763
22041
|
}
|
|
21764
22042
|
});
|
|
21765
22043
|
});
|
|
21766
|
-
call.on("error", () => reject(new Error("
|
|
21767
|
-
call.on("timeout", () => call.destroy(new Error("
|
|
22044
|
+
call.on("error", () => reject(new Error("Preparation transport unavailable; nothing was published")));
|
|
22045
|
+
call.on("timeout", () => call.destroy(new Error("Preparation timed out")));
|
|
21768
22046
|
call.end(JSON.stringify(input));
|
|
21769
22047
|
});
|
|
21770
22048
|
};
|
|
@@ -21784,6 +22062,9 @@ async function resolveDataContext() {
|
|
|
21784
22062
|
const local = localRoutineRequest();
|
|
21785
22063
|
if (local)
|
|
21786
22064
|
return { local };
|
|
22065
|
+
const managed = privateRoutineRequest();
|
|
22066
|
+
if (managed)
|
|
22067
|
+
return { local: managed.request };
|
|
21787
22068
|
const host = memberContext;
|
|
21788
22069
|
if (host !== undefined) {
|
|
21789
22070
|
const context = await host();
|
|
@@ -21799,6 +22080,41 @@ async function resolveDataContext() {
|
|
|
21799
22080
|
throw new DataOperationError("context_unavailable");
|
|
21800
22081
|
}
|
|
21801
22082
|
}
|
|
22083
|
+
async function resolveFilesContext() {
|
|
22084
|
+
try {
|
|
22085
|
+
const environment = typeof process === "undefined" ? {} : process.env;
|
|
22086
|
+
const local = privateRoutineRequest(environment);
|
|
22087
|
+
if (local)
|
|
22088
|
+
return {
|
|
22089
|
+
url: local.identity,
|
|
22090
|
+
headers: {},
|
|
22091
|
+
isCurrent: local.isCurrent,
|
|
22092
|
+
local: local.request
|
|
22093
|
+
};
|
|
22094
|
+
const host = memberContext;
|
|
22095
|
+
if (host) {
|
|
22096
|
+
const context = await host();
|
|
22097
|
+
if (!Number.isFinite(context.expiresAt) || context.expiresAt <= Date.now() || typeof context.accessToken !== "string" || !/^[^\s]{1,8192}$/.test(context.accessToken))
|
|
22098
|
+
throw new Error;
|
|
22099
|
+
return {
|
|
22100
|
+
...filesContext(context.workspace, context.endpoint, { authorization: `Bearer ${context.accessToken}` }),
|
|
22101
|
+
isCurrent: context.isCurrent,
|
|
22102
|
+
local: undefined
|
|
22103
|
+
};
|
|
22104
|
+
}
|
|
22105
|
+
if (!/^[0-9a-f]{64}$/.test(environment.ODDINGTON_ROUTINE_RUN ?? ""))
|
|
22106
|
+
throw new Error;
|
|
22107
|
+
const workspace = environment.ODDINGTON_ROUTINE_WORKSPACE;
|
|
22108
|
+
return { ...filesContext(workspace, `https://${workspace}.oddington.ai`, { "x-oddington-run": environment.ODDINGTON_ROUTINE_RUN }), local: undefined };
|
|
22109
|
+
} catch {
|
|
22110
|
+
throw new FileOperationError("unsupported_context", 400);
|
|
22111
|
+
}
|
|
22112
|
+
}
|
|
22113
|
+
function filesContext(workspace, endpoint, headers) {
|
|
22114
|
+
if (!workspace || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(workspace) || workspace.length > 63 || ["auth", "www", "api", "os"].includes(workspace) || endpoint !== `https://${workspace}.oddington.ai`)
|
|
22115
|
+
throw new Error;
|
|
22116
|
+
return { url: `${endpoint}/api/files`, headers: { ...headers, "x-oddington-workspace": workspace }, isCurrent: () => true };
|
|
22117
|
+
}
|
|
21802
22118
|
function checked(workspace, endpoint, headers) {
|
|
21803
22119
|
if (!workspace || !/^[a-z0-9][a-z0-9-]{0,127}$/.test(workspace))
|
|
21804
22120
|
throw new Error;
|
|
@@ -21809,19 +22125,12 @@ function checked(workspace, endpoint, headers) {
|
|
|
21809
22125
|
}
|
|
21810
22126
|
|
|
21811
22127
|
// src/data.ts
|
|
21812
|
-
var failures = {
|
|
21813
|
-
400: ["invalid_query"],
|
|
21814
|
-
401: ["unauthenticated"],
|
|
21815
|
-
403: ["access_denied"],
|
|
21816
|
-
413: ["request_too_large"],
|
|
21817
|
-
429: ["capacity"],
|
|
21818
|
-
503: ["unavailable"]
|
|
21819
|
-
};
|
|
21820
22128
|
var data = {
|
|
21821
22129
|
repository(repository) {
|
|
21822
22130
|
async function send(input) {
|
|
21823
22131
|
const context = await resolveDataContext();
|
|
21824
22132
|
try {
|
|
22133
|
+
checkDataRequestSize({ repository, ...input });
|
|
21825
22134
|
if ("local" in context)
|
|
21826
22135
|
return await context.local("data/query", { repository, ...input });
|
|
21827
22136
|
const response = await fetch(context.url, {
|
|
@@ -21833,12 +22142,7 @@ var data = {
|
|
|
21833
22142
|
});
|
|
21834
22143
|
const result = await response.json();
|
|
21835
22144
|
if (!response.ok) {
|
|
21836
|
-
|
|
21837
|
-
const received = error && typeof error === "object" && "code" in error ? error.code : undefined;
|
|
21838
|
-
const code = failures[response.status]?.find((allowed) => allowed === received);
|
|
21839
|
-
if (code)
|
|
21840
|
-
throw new DataOperationError(code, code === "capacity" || code === "unavailable");
|
|
21841
|
-
throw new DataOperationError("unavailable", true);
|
|
22145
|
+
throw dataTransportError(response.status, result);
|
|
21842
22146
|
}
|
|
21843
22147
|
return result;
|
|
21844
22148
|
} catch (error) {
|
|
@@ -21852,10 +22156,425 @@ var data = {
|
|
|
21852
22156
|
list: () => send({ operation: "collections.list" }),
|
|
21853
22157
|
schema: (name) => send({ operation: "collections.schema", name })
|
|
21854
22158
|
},
|
|
21855
|
-
records: { select: (query) => send({ operation: "records.select", query }) }
|
|
22159
|
+
records: { select: (query) => send({ operation: "records.select", query }) },
|
|
22160
|
+
changes() {
|
|
22161
|
+
let updates = [], creates = [], deletes = [], publicationId;
|
|
22162
|
+
let pending, confirmed;
|
|
22163
|
+
const snapshot = () => {
|
|
22164
|
+
const captured = captureDataChanges(updates, creates, deletes);
|
|
22165
|
+
const input = {
|
|
22166
|
+
updates: captured.updates,
|
|
22167
|
+
...captured.creates.length ? { creates: captured.creates } : {},
|
|
22168
|
+
...captured.deletes.length ? { deletes: captured.deletes } : {}
|
|
22169
|
+
};
|
|
22170
|
+
checkDataRequestSize({
|
|
22171
|
+
repository,
|
|
22172
|
+
operation: "changes.publish",
|
|
22173
|
+
...input,
|
|
22174
|
+
publicationId: publicationId ?? "00000000-0000-4000-8000-000000000000"
|
|
22175
|
+
});
|
|
22176
|
+
return input;
|
|
22177
|
+
};
|
|
22178
|
+
return {
|
|
22179
|
+
create(record2) {
|
|
22180
|
+
if (publicationId)
|
|
22181
|
+
throw new DataOperationError("invalid_change", false, "unapplied");
|
|
22182
|
+
const next = [...creates, captureDataCreate(record2)];
|
|
22183
|
+
captureDataChanges(updates, next, deletes);
|
|
22184
|
+
checkDataRequestSize({
|
|
22185
|
+
repository,
|
|
22186
|
+
operation: "changes.publish",
|
|
22187
|
+
updates,
|
|
22188
|
+
creates: next,
|
|
22189
|
+
...deletes.length ? { deletes } : {},
|
|
22190
|
+
publicationId: "00000000-0000-4000-8000-000000000000"
|
|
22191
|
+
});
|
|
22192
|
+
creates = next;
|
|
22193
|
+
},
|
|
22194
|
+
update(record2, set) {
|
|
22195
|
+
if (publicationId)
|
|
22196
|
+
throw new DataOperationError("invalid_change", false, "unapplied");
|
|
22197
|
+
const next = [...updates, captureDataUpdate(record2, set)];
|
|
22198
|
+
captureDataChanges(next, creates, deletes);
|
|
22199
|
+
checkDataRequestSize({
|
|
22200
|
+
repository,
|
|
22201
|
+
operation: "changes.publish",
|
|
22202
|
+
updates: next,
|
|
22203
|
+
...creates.length ? { creates } : {},
|
|
22204
|
+
...deletes.length ? { deletes } : {},
|
|
22205
|
+
publicationId: "00000000-0000-4000-8000-000000000000"
|
|
22206
|
+
});
|
|
22207
|
+
updates = next;
|
|
22208
|
+
},
|
|
22209
|
+
delete(record2) {
|
|
22210
|
+
if (publicationId)
|
|
22211
|
+
throw new DataOperationError("invalid_change", false, "unapplied");
|
|
22212
|
+
const next = [...deletes, captureDataDelete(record2)];
|
|
22213
|
+
captureDataChanges(updates, creates, next);
|
|
22214
|
+
checkDataRequestSize({
|
|
22215
|
+
repository,
|
|
22216
|
+
operation: "changes.publish",
|
|
22217
|
+
updates,
|
|
22218
|
+
deletes: next,
|
|
22219
|
+
...creates.length ? { creates } : {},
|
|
22220
|
+
publicationId: "00000000-0000-4000-8000-000000000000"
|
|
22221
|
+
});
|
|
22222
|
+
deletes = next;
|
|
22223
|
+
},
|
|
22224
|
+
async validate() {
|
|
22225
|
+
await send({ operation: "changes.validate", ...snapshot() });
|
|
22226
|
+
},
|
|
22227
|
+
publish() {
|
|
22228
|
+
if (confirmed)
|
|
22229
|
+
return Promise.resolve(structuredClone(confirmed));
|
|
22230
|
+
if (!pending) {
|
|
22231
|
+
let captured;
|
|
22232
|
+
try {
|
|
22233
|
+
captured = snapshot();
|
|
22234
|
+
} catch (error) {
|
|
22235
|
+
return Promise.reject(error);
|
|
22236
|
+
}
|
|
22237
|
+
publicationId ??= crypto.randomUUID();
|
|
22238
|
+
pending = send({ operation: "changes.publish", ...captured, publicationId }).then((result) => {
|
|
22239
|
+
confirmed = structuredClone(result);
|
|
22240
|
+
return result;
|
|
22241
|
+
}).catch((error) => {
|
|
22242
|
+
if (error instanceof DataOperationError)
|
|
22243
|
+
throw new DataOperationError(error.code, error.retryable, error.effect ?? (["unavailable", "publication_pending"].includes(error.code) ? "uncertain" : "unapplied"), error.component);
|
|
22244
|
+
throw new DataOperationError("unavailable", true, "uncertain");
|
|
22245
|
+
}).finally(() => {
|
|
22246
|
+
pending = undefined;
|
|
22247
|
+
});
|
|
22248
|
+
}
|
|
22249
|
+
return pending.then((result) => structuredClone(result));
|
|
22250
|
+
}
|
|
22251
|
+
};
|
|
22252
|
+
}
|
|
21856
22253
|
};
|
|
21857
22254
|
}
|
|
21858
22255
|
};
|
|
22256
|
+
// src/files.ts
|
|
22257
|
+
var MAX_BYTES = 16 * 1024 * 1024;
|
|
22258
|
+
var METADATA_BYTES = 4096;
|
|
22259
|
+
var RESULT_BYTES = 16 * 1024;
|
|
22260
|
+
var TIMEOUT_MS = 30000;
|
|
22261
|
+
var MAX_ACTIVE = 4;
|
|
22262
|
+
var ATTEMPTS = 2;
|
|
22263
|
+
var active = 0;
|
|
22264
|
+
var invalid = () => new FileOperationError("invalid_input", 400);
|
|
22265
|
+
var unavailable = () => new FileOperationError("unavailable", 503, true);
|
|
22266
|
+
var failures = {
|
|
22267
|
+
400: ["invalid_input", "unsupported_context"],
|
|
22268
|
+
401: ["unauthenticated"],
|
|
22269
|
+
403: ["access_denied"],
|
|
22270
|
+
405: ["method_not_allowed"],
|
|
22271
|
+
409: ["conflict", "local_only"],
|
|
22272
|
+
413: ["request_too_large"],
|
|
22273
|
+
429: ["capacity"],
|
|
22274
|
+
503: ["integrity", "unavailable"]
|
|
22275
|
+
};
|
|
22276
|
+
async function boundedBytes(stream, limit) {
|
|
22277
|
+
if (!stream)
|
|
22278
|
+
return new Uint8Array;
|
|
22279
|
+
const reader = stream.getReader();
|
|
22280
|
+
const bytes = new Uint8Array(limit);
|
|
22281
|
+
let size = 0;
|
|
22282
|
+
try {
|
|
22283
|
+
for (;; ) {
|
|
22284
|
+
const { done, value } = await reader.read();
|
|
22285
|
+
if (done)
|
|
22286
|
+
break;
|
|
22287
|
+
if (!(value instanceof Uint8Array))
|
|
22288
|
+
throw invalid();
|
|
22289
|
+
size += value.byteLength;
|
|
22290
|
+
if (size > limit)
|
|
22291
|
+
throw new FileOperationError("request_too_large", 413);
|
|
22292
|
+
bytes.set(value, size - value.byteLength);
|
|
22293
|
+
}
|
|
22294
|
+
} finally {
|
|
22295
|
+
reader.releaseLock();
|
|
22296
|
+
}
|
|
22297
|
+
return bytes.slice(0, size);
|
|
22298
|
+
}
|
|
22299
|
+
async function timed(work, parent) {
|
|
22300
|
+
const controller = new AbortController;
|
|
22301
|
+
let timer;
|
|
22302
|
+
let abort;
|
|
22303
|
+
const expiry = new Promise((_, reject) => {
|
|
22304
|
+
abort = () => {
|
|
22305
|
+
controller.abort();
|
|
22306
|
+
reject(unavailable());
|
|
22307
|
+
};
|
|
22308
|
+
timer = setTimeout(abort, TIMEOUT_MS);
|
|
22309
|
+
parent?.addEventListener("abort", abort, { once: true });
|
|
22310
|
+
if (parent?.aborted)
|
|
22311
|
+
abort();
|
|
22312
|
+
});
|
|
22313
|
+
try {
|
|
22314
|
+
return await Promise.race([work(controller.signal), expiry]);
|
|
22315
|
+
} finally {
|
|
22316
|
+
clearTimeout(timer);
|
|
22317
|
+
parent?.removeEventListener("abort", abort);
|
|
22318
|
+
}
|
|
22319
|
+
}
|
|
22320
|
+
async function result(response) {
|
|
22321
|
+
try {
|
|
22322
|
+
const bytes = await boundedBytes(response.body, RESULT_BYTES);
|
|
22323
|
+
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
22324
|
+
} catch {
|
|
22325
|
+
throw unavailable();
|
|
22326
|
+
}
|
|
22327
|
+
}
|
|
22328
|
+
async function send(suffix, init, descriptor, initial, parent) {
|
|
22329
|
+
const original = initial;
|
|
22330
|
+
const checkCurrent = () => {
|
|
22331
|
+
if (parent?.aborted)
|
|
22332
|
+
throw unavailable();
|
|
22333
|
+
if (!original.isCurrent())
|
|
22334
|
+
throw new FileOperationError("unsupported_context", 400);
|
|
22335
|
+
};
|
|
22336
|
+
for (let attempt = 0;attempt < ATTEMPTS; attempt++) {
|
|
22337
|
+
checkCurrent();
|
|
22338
|
+
const context = await resolveFilesContext();
|
|
22339
|
+
checkCurrent();
|
|
22340
|
+
if (context.url !== original.url)
|
|
22341
|
+
throw new FileOperationError("unsupported_context", 400);
|
|
22342
|
+
try {
|
|
22343
|
+
return await (async () => {
|
|
22344
|
+
const response = context.local ? await (async () => {
|
|
22345
|
+
const body = init.body instanceof ArrayBuffer ? new Uint8Array(init.body) : undefined;
|
|
22346
|
+
let binary = "";
|
|
22347
|
+
if (body)
|
|
22348
|
+
for (let offset = 0;offset < body.length; offset += 8192)
|
|
22349
|
+
binary += String.fromCharCode(...body.subarray(offset, offset + 8192));
|
|
22350
|
+
const value2 = await context.local("files/request", {
|
|
22351
|
+
suffix,
|
|
22352
|
+
method: init.method,
|
|
22353
|
+
headers: Object.fromEntries(new Headers(init.headers)),
|
|
22354
|
+
...body ? { bytes: btoa(binary) } : {}
|
|
22355
|
+
});
|
|
22356
|
+
if (value2.bytes !== undefined) {
|
|
22357
|
+
if (value2.bytes.length > Math.ceil(MAX_BYTES / 3) * 4)
|
|
22358
|
+
throw unavailable();
|
|
22359
|
+
const data2 = atob(value2.bytes);
|
|
22360
|
+
return new Response(Uint8Array.from(data2, (c) => c.charCodeAt(0)), { status: value2.status, headers: value2.headers });
|
|
22361
|
+
}
|
|
22362
|
+
return Response.json(value2.json, { status: value2.status, headers: value2.headers });
|
|
22363
|
+
})() : await fetch(`${context.url}${suffix}`, {
|
|
22364
|
+
...init,
|
|
22365
|
+
signal: parent,
|
|
22366
|
+
headers: { ...context.headers, ...init.headers },
|
|
22367
|
+
redirect: "error",
|
|
22368
|
+
cache: "no-store"
|
|
22369
|
+
});
|
|
22370
|
+
if (!response.ok) {
|
|
22371
|
+
const value2 = await result(response);
|
|
22372
|
+
const error = value2 && typeof value2 === "object" && "error" in value2 ? value2.error : undefined;
|
|
22373
|
+
const received = error && typeof error === "object" && "code" in error ? error.code : undefined;
|
|
22374
|
+
const code = failures[response.status]?.find((code2) => code2 === received);
|
|
22375
|
+
throw code ? new FileOperationError(code, response.status, code === "capacity" || code === "unavailable") : unavailable();
|
|
22376
|
+
}
|
|
22377
|
+
if (response.status !== 200) {
|
|
22378
|
+
response.body?.cancel().catch(() => {});
|
|
22379
|
+
throw unavailable();
|
|
22380
|
+
}
|
|
22381
|
+
try {
|
|
22382
|
+
checkCurrent();
|
|
22383
|
+
} catch (error) {
|
|
22384
|
+
response.body?.cancel().catch(() => {});
|
|
22385
|
+
throw error;
|
|
22386
|
+
}
|
|
22387
|
+
if (!descriptor)
|
|
22388
|
+
return response;
|
|
22389
|
+
const value = await result(response);
|
|
22390
|
+
let parsed;
|
|
22391
|
+
if (descriptor === "enrichment") {
|
|
22392
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
22393
|
+
throw unavailable();
|
|
22394
|
+
const { name, ...metadata } = value;
|
|
22395
|
+
if (!safeEnrichmentName(name))
|
|
22396
|
+
throw unavailable();
|
|
22397
|
+
parsed = { name, ...parseEnrichmentDescriptor(metadata) };
|
|
22398
|
+
} else
|
|
22399
|
+
parsed = parseFileDescriptor(value);
|
|
22400
|
+
checkCurrent();
|
|
22401
|
+
return parsed;
|
|
22402
|
+
})();
|
|
22403
|
+
} catch (error) {
|
|
22404
|
+
const failure = error instanceof FileOperationError ? error : unavailable();
|
|
22405
|
+
if (!failure.retryable || attempt + 1 === ATTEMPTS)
|
|
22406
|
+
throw failure;
|
|
22407
|
+
}
|
|
22408
|
+
}
|
|
22409
|
+
throw unavailable();
|
|
22410
|
+
}
|
|
22411
|
+
function idPath(id2) {
|
|
22412
|
+
if (typeof id2 !== "string" || !FILE_ID_PATTERN.test(id2))
|
|
22413
|
+
throw invalid();
|
|
22414
|
+
return `/${id2}`;
|
|
22415
|
+
}
|
|
22416
|
+
async function operation(work, initial, parent) {
|
|
22417
|
+
const context = initial ?? await resolveFilesContext();
|
|
22418
|
+
if (active >= MAX_ACTIVE)
|
|
22419
|
+
throw new FileOperationError("capacity", 429, true);
|
|
22420
|
+
active++;
|
|
22421
|
+
return timed(async (signal) => {
|
|
22422
|
+
try {
|
|
22423
|
+
return await work(context, signal);
|
|
22424
|
+
} finally {
|
|
22425
|
+
active--;
|
|
22426
|
+
}
|
|
22427
|
+
}, parent).catch((error) => {
|
|
22428
|
+
throw error instanceof FileOperationError ? error : unavailable();
|
|
22429
|
+
});
|
|
22430
|
+
}
|
|
22431
|
+
function contentPath(id2, name) {
|
|
22432
|
+
const path = idPath(id2);
|
|
22433
|
+
if (name === undefined)
|
|
22434
|
+
return `${path}/content`;
|
|
22435
|
+
if (!safeEnrichmentName(name))
|
|
22436
|
+
throw invalid();
|
|
22437
|
+
return `${path}/enrichments/${encodeURIComponent(name)}/content`;
|
|
22438
|
+
}
|
|
22439
|
+
async function read(id2, names) {
|
|
22440
|
+
const context = await resolveFilesContext();
|
|
22441
|
+
idPath(id2);
|
|
22442
|
+
if (names === undefined || typeof names === "string") {
|
|
22443
|
+
const path = contentPath(id2, names);
|
|
22444
|
+
return operation((context2, signal) => send(path, { method: "GET" }, false, context2, signal), context);
|
|
22445
|
+
}
|
|
22446
|
+
if (!Array.isArray(names))
|
|
22447
|
+
throw invalid();
|
|
22448
|
+
const distinct = [];
|
|
22449
|
+
const seen = new Set;
|
|
22450
|
+
for (const name of names) {
|
|
22451
|
+
if (typeof name !== "string" || !safeEnrichmentName(name))
|
|
22452
|
+
throw invalid();
|
|
22453
|
+
if (seen.has(name))
|
|
22454
|
+
continue;
|
|
22455
|
+
if (seen.size === 16)
|
|
22456
|
+
throw invalid();
|
|
22457
|
+
seen.add(name);
|
|
22458
|
+
distinct.push(name);
|
|
22459
|
+
}
|
|
22460
|
+
const paths = distinct.map((name) => contentPath(id2, name));
|
|
22461
|
+
return timed(async (parent) => {
|
|
22462
|
+
const responses = {};
|
|
22463
|
+
try {
|
|
22464
|
+
for (let i = 0;i < paths.length; i++) {
|
|
22465
|
+
const response = await operation((context2, signal) => send(paths[i], { method: "GET" }, false, context2, signal), context, parent);
|
|
22466
|
+
Object.defineProperty(responses, distinct[i], { value: response, enumerable: true });
|
|
22467
|
+
}
|
|
22468
|
+
if (!context.isCurrent())
|
|
22469
|
+
throw new FileOperationError("unsupported_context", 400);
|
|
22470
|
+
return responses;
|
|
22471
|
+
} catch (error) {
|
|
22472
|
+
for (const response of Object.values(responses))
|
|
22473
|
+
response.body?.cancel().catch(() => {});
|
|
22474
|
+
throw error;
|
|
22475
|
+
}
|
|
22476
|
+
});
|
|
22477
|
+
}
|
|
22478
|
+
var files = {
|
|
22479
|
+
async upload(id2) {
|
|
22480
|
+
return operation(async (context, signal) => {
|
|
22481
|
+
const file = await send(`${idPath(id2)}/upload`, { method: "POST" }, true, context, signal);
|
|
22482
|
+
if (file.id !== id2)
|
|
22483
|
+
throw unavailable();
|
|
22484
|
+
return file;
|
|
22485
|
+
});
|
|
22486
|
+
},
|
|
22487
|
+
async create(input, options) {
|
|
22488
|
+
const context = await resolveFilesContext();
|
|
22489
|
+
if (!input || typeof input !== "object" || Array.isArray(input) || Object.keys(input).some((key) => !["file", "size", "path", "name", "storage", "csv"].includes(key)) || options !== undefined && (!options || typeof options !== "object" || Array.isArray(options) || Object.keys(options).some((key) => key !== "requestKey")))
|
|
22490
|
+
throw invalid();
|
|
22491
|
+
const blob = input.file instanceof Blob;
|
|
22492
|
+
const array2 = input.file instanceof Uint8Array;
|
|
22493
|
+
const stream = input.file instanceof ReadableStream;
|
|
22494
|
+
if (!blob && !array2 && !stream)
|
|
22495
|
+
throw invalid();
|
|
22496
|
+
const intrinsic = blob ? input.file.size : array2 ? input.file.byteLength : undefined;
|
|
22497
|
+
if (intrinsic !== undefined && input.size !== undefined && input.size !== intrinsic)
|
|
22498
|
+
throw invalid();
|
|
22499
|
+
let name = input.name;
|
|
22500
|
+
if (name === undefined && blob && "name" in input.file && typeof input.file.name === "string") {
|
|
22501
|
+
name = typeof globalThis.File !== "undefined" && input.file instanceof globalThis.File ? input.file.name : input.file.name.split(/[\\/]/).at(-1);
|
|
22502
|
+
}
|
|
22503
|
+
const metadata = parseFileCreateMetadata({
|
|
22504
|
+
name,
|
|
22505
|
+
size: intrinsic ?? input.size,
|
|
22506
|
+
path: input.path,
|
|
22507
|
+
storage: input.storage,
|
|
22508
|
+
csv: input.csv,
|
|
22509
|
+
requestKey: options?.requestKey === undefined ? crypto.randomUUID() : options.requestKey
|
|
22510
|
+
}, MAX_BYTES);
|
|
22511
|
+
if (!context.local && metadata.storage === "local")
|
|
22512
|
+
throw new FileOperationError("unsupported_context", 400);
|
|
22513
|
+
const header = encodeURIComponent(JSON.stringify(metadata));
|
|
22514
|
+
if (new TextEncoder().encode(header).byteLength > METADATA_BYTES)
|
|
22515
|
+
throw invalid();
|
|
22516
|
+
if (active >= MAX_ACTIVE)
|
|
22517
|
+
throw new FileOperationError("capacity", 429, true);
|
|
22518
|
+
active++;
|
|
22519
|
+
return timed(async (signal) => {
|
|
22520
|
+
try {
|
|
22521
|
+
const bytes = array2 ? input.file.slice() : await boundedBytes(blob ? input.file.stream() : input.file, metadata.size);
|
|
22522
|
+
if (bytes.byteLength !== metadata.size)
|
|
22523
|
+
throw invalid();
|
|
22524
|
+
if (signal.aborted)
|
|
22525
|
+
throw unavailable();
|
|
22526
|
+
return await send("", {
|
|
22527
|
+
method: "POST",
|
|
22528
|
+
headers: { "content-type": "application/octet-stream", "x-oddington-file": header },
|
|
22529
|
+
body: bytes.buffer
|
|
22530
|
+
}, true, context, signal);
|
|
22531
|
+
} finally {
|
|
22532
|
+
active--;
|
|
22533
|
+
}
|
|
22534
|
+
}).catch((error) => {
|
|
22535
|
+
throw error instanceof FileOperationError ? error : unavailable();
|
|
22536
|
+
});
|
|
22537
|
+
},
|
|
22538
|
+
async enrich(input) {
|
|
22539
|
+
const context = await resolveFilesContext();
|
|
22540
|
+
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))
|
|
22541
|
+
throw invalid();
|
|
22542
|
+
const path = `${idPath(input.file)}/enrichments`;
|
|
22543
|
+
if (typeof input.content === "string" ? input.content.length > MAX_BYTES : input.content.byteLength > MAX_BYTES)
|
|
22544
|
+
throw new FileOperationError("request_too_large", 413);
|
|
22545
|
+
return operation(async (context2, signal) => {
|
|
22546
|
+
let bytes;
|
|
22547
|
+
if (typeof input.content === "string") {
|
|
22548
|
+
const buffer = new Uint8Array(Math.min(MAX_BYTES, input.content.length * 3));
|
|
22549
|
+
const encoded = new TextEncoder().encodeInto(input.content, buffer);
|
|
22550
|
+
if (encoded.read !== input.content.length)
|
|
22551
|
+
throw new FileOperationError("request_too_large", 413);
|
|
22552
|
+
bytes = buffer.slice(0, encoded.written);
|
|
22553
|
+
} else
|
|
22554
|
+
bytes = input.content.slice();
|
|
22555
|
+
const metadata = parseFileEnrichMetadata({
|
|
22556
|
+
name: input.name,
|
|
22557
|
+
size: bytes.byteLength,
|
|
22558
|
+
...input.mediaType === undefined ? {} : { mediaType: input.mediaType },
|
|
22559
|
+
...input.replace === undefined ? {} : { replace: input.replace }
|
|
22560
|
+
}, MAX_BYTES);
|
|
22561
|
+
const header = encodeURIComponent(JSON.stringify(metadata));
|
|
22562
|
+
if (new TextEncoder().encode(header).byteLength > METADATA_BYTES)
|
|
22563
|
+
throw invalid();
|
|
22564
|
+
const result2 = await send(path, { method: "POST", headers: {
|
|
22565
|
+
"content-type": "application/octet-stream",
|
|
22566
|
+
"x-oddington-enrichment": header
|
|
22567
|
+
}, body: bytes.buffer }, "enrichment", context2, signal);
|
|
22568
|
+
if (result2.name !== metadata.name)
|
|
22569
|
+
throw unavailable();
|
|
22570
|
+
return result2;
|
|
22571
|
+
}, context);
|
|
22572
|
+
},
|
|
22573
|
+
async get(id2) {
|
|
22574
|
+
return operation((context, signal) => send(idPath(id2), { method: "GET" }, true, context, signal));
|
|
22575
|
+
},
|
|
22576
|
+
read
|
|
22577
|
+
};
|
|
21859
22578
|
// src/os.ts
|
|
21860
22579
|
var installedDispose;
|
|
21861
22580
|
function init({ auth }) {
|
|
@@ -21870,7 +22589,7 @@ function init({ auth }) {
|
|
|
21870
22589
|
workspace = slug;
|
|
21871
22590
|
}
|
|
21872
22591
|
} catch {}
|
|
21873
|
-
let
|
|
22592
|
+
let active2 = true;
|
|
21874
22593
|
let revision = 0;
|
|
21875
22594
|
let person;
|
|
21876
22595
|
const { data: { subscription } } = auth.onAuthStateChange((event, session) => {
|
|
@@ -21880,11 +22599,11 @@ function init({ auth }) {
|
|
|
21880
22599
|
person = next;
|
|
21881
22600
|
});
|
|
21882
22601
|
const resolve = async () => {
|
|
21883
|
-
if (!
|
|
22602
|
+
if (!active2 || !endpoint || !workspace)
|
|
21884
22603
|
throw new Error("Hosted Data context unavailable.");
|
|
21885
22604
|
const started = revision;
|
|
21886
22605
|
const { data: { session }, error } = await auth.getSession();
|
|
21887
|
-
if (!
|
|
22606
|
+
if (!active2 || started !== revision || error || !session || person !== undefined && person !== session.user.id) {
|
|
21888
22607
|
throw new Error("Hosted Data context unavailable.");
|
|
21889
22608
|
}
|
|
21890
22609
|
const expiresAt = (session.expires_at ?? 0) * 1000;
|
|
@@ -21892,13 +22611,19 @@ function init({ auth }) {
|
|
|
21892
22611
|
throw new Error("Hosted Data context unavailable.");
|
|
21893
22612
|
}
|
|
21894
22613
|
person = session.user.id;
|
|
21895
|
-
return {
|
|
22614
|
+
return {
|
|
22615
|
+
workspace,
|
|
22616
|
+
endpoint,
|
|
22617
|
+
accessToken: session.access_token,
|
|
22618
|
+
expiresAt,
|
|
22619
|
+
isCurrent: () => active2 && revision === started && person === session.user.id
|
|
22620
|
+
};
|
|
21896
22621
|
};
|
|
21897
22622
|
const uninstall = installMemberContext(resolve);
|
|
21898
22623
|
const dispose = () => {
|
|
21899
|
-
if (!
|
|
22624
|
+
if (!active2)
|
|
21900
22625
|
return;
|
|
21901
|
-
|
|
22626
|
+
active2 = false;
|
|
21902
22627
|
revision++;
|
|
21903
22628
|
subscription.unsubscribe();
|
|
21904
22629
|
uninstall();
|
|
@@ -21932,31 +22657,31 @@ function routinePublicationClient(options = {}) {
|
|
|
21932
22657
|
} : async () => {
|
|
21933
22658
|
throw new Error("Member publication requires a host-supplied request");
|
|
21934
22659
|
});
|
|
21935
|
-
async function
|
|
22660
|
+
async function send2(operation2, body) {
|
|
21936
22661
|
if (local)
|
|
21937
|
-
return await local(
|
|
21938
|
-
const response = await request(`/api/cli/workspaces/${workspace}/inbox/${
|
|
22662
|
+
return await local(operation2, body);
|
|
22663
|
+
const response = await request(`/api/cli/workspaces/${workspace}/inbox/${operation2}`, {
|
|
21939
22664
|
method: "POST",
|
|
21940
22665
|
headers: { "content-type": "application/json", ...headers },
|
|
21941
22666
|
body: JSON.stringify(body)
|
|
21942
22667
|
});
|
|
21943
|
-
const
|
|
21944
|
-
if (!response.ok &&
|
|
21945
|
-
throw new RoutineRecordWriteError(
|
|
22668
|
+
const result2 = await response.json();
|
|
22669
|
+
if (!response.ok && operation2 === "records/update")
|
|
22670
|
+
throw new RoutineRecordWriteError(result2.error ?? "Could not confirm routine preparation", result2.effect ?? "uncertain");
|
|
21946
22671
|
if (!response.ok)
|
|
21947
|
-
throw new Error(
|
|
21948
|
-
return
|
|
22672
|
+
throw new Error(result2.error ?? "Could not confirm routine publication");
|
|
22673
|
+
return result2;
|
|
21949
22674
|
}
|
|
21950
22675
|
const transport = {
|
|
21951
22676
|
async publish(body) {
|
|
21952
|
-
return await
|
|
22677
|
+
return await send2("publish", body);
|
|
21953
22678
|
},
|
|
21954
22679
|
async resolve(body) {
|
|
21955
|
-
await
|
|
22680
|
+
await send2("resolve", body);
|
|
21956
22681
|
}
|
|
21957
22682
|
};
|
|
21958
22683
|
async function readRecords(input) {
|
|
21959
|
-
return await
|
|
22684
|
+
return await send2("records/read", validateRecordRead(input));
|
|
21960
22685
|
}
|
|
21961
22686
|
return {
|
|
21962
22687
|
...createInboxPublisher(transport),
|
|
@@ -21966,17 +22691,17 @@ function routinePublicationClient(options = {}) {
|
|
|
21966
22691
|
async writeRecords(input, options2) {
|
|
21967
22692
|
if (!capability)
|
|
21968
22693
|
throw new Error("A trusted routine launch is required");
|
|
21969
|
-
return await
|
|
22694
|
+
return await send2("records/update", validateRoutineRecordWrite({ input, requestKey: options2?.requestKey }));
|
|
21970
22695
|
},
|
|
21971
22696
|
async updateRecords(input, options2) {
|
|
21972
22697
|
if (!capability)
|
|
21973
22698
|
throw new Error("A trusted routine launch is required");
|
|
21974
|
-
return await
|
|
22699
|
+
return await send2("records/update", validateRoutineRecordWrite({ input: validateRecordUpdate(input), requestKey: options2?.requestKey }));
|
|
21975
22700
|
},
|
|
21976
22701
|
async deleteRecords(input, options2) {
|
|
21977
22702
|
if (!capability)
|
|
21978
22703
|
throw new Error("A trusted routine launch is required");
|
|
21979
|
-
return await
|
|
22704
|
+
return await send2("records/update", validateRoutineRecordWrite({ input: validateRecordDelete(input), requestKey: options2?.requestKey }));
|
|
21980
22705
|
}
|
|
21981
22706
|
},
|
|
21982
22707
|
files: {
|
|
@@ -21998,14 +22723,14 @@ function routinePublicationClient(options = {}) {
|
|
|
21998
22723
|
},
|
|
21999
22724
|
body: Uint8Array.from(bytes).buffer
|
|
22000
22725
|
});
|
|
22001
|
-
const
|
|
22726
|
+
const result2 = await response.json();
|
|
22002
22727
|
if (!response.ok)
|
|
22003
|
-
throw new Error(
|
|
22004
|
-
return await verifyInboxFile(bytes, validateInboxFile(
|
|
22728
|
+
throw new Error(result2.error ?? "Could not retain file");
|
|
22729
|
+
return await verifyInboxFile(bytes, validateInboxFile(result2));
|
|
22005
22730
|
}
|
|
22006
22731
|
},
|
|
22007
22732
|
async check(body) {
|
|
22008
|
-
await
|
|
22733
|
+
await send2("check", { requestKey: body.requestKey, item: validatePublication(body.item) });
|
|
22009
22734
|
}
|
|
22010
22735
|
};
|
|
22011
22736
|
}
|
|
@@ -22019,6 +22744,7 @@ export {
|
|
|
22019
22744
|
recordBlock,
|
|
22020
22745
|
question,
|
|
22021
22746
|
os,
|
|
22747
|
+
files,
|
|
22022
22748
|
fileBlock,
|
|
22023
22749
|
defineHandler,
|
|
22024
22750
|
data,
|
|
@@ -22027,6 +22753,7 @@ export {
|
|
|
22027
22753
|
asksBlock,
|
|
22028
22754
|
RoutineRecordWriteError,
|
|
22029
22755
|
InboxContractError,
|
|
22756
|
+
FileOperationError,
|
|
22030
22757
|
DataOperationError,
|
|
22031
22758
|
AirtableOperationError
|
|
22032
22759
|
};
|