@oddington/sdk 0.1.69 → 0.1.71
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
CHANGED
|
@@ -715,8 +715,17 @@ expects the current enrichment's SHA-256 value. Reads return the successful Web
|
|
|
715
715
|
Response without consuming its body. Local transfer is bounded and buffered
|
|
716
716
|
before constructing that Response. Current workspace members can use every File in that workspace. A
|
|
717
717
|
routine's `files: "read"` permits get/read; `files: "read-write"` also permits
|
|
718
|
-
create/enrich/upload. References in Sources, Runs and Inbox items grant no
|
|
719
|
-
additional access.
|
|
718
|
+
create/update/enrich/upload/delete. References in Sources, Runs and Inbox items grant no
|
|
719
|
+
additional access.
|
|
720
|
+
|
|
721
|
+
`await files.delete(id)` permanently removes one registered File's original and
|
|
722
|
+
all enrichments. The File becomes unavailable when deletion begins; successful
|
|
723
|
+
completion confirms physical removal from its managed storage. Retry the same ID
|
|
724
|
+
after interruption, including after a lost success reply. Completed deletion is
|
|
725
|
+
idempotent. Unknown and foreign IDs return `not_found`; a hosted caller without
|
|
726
|
+
the required local bytes receives `local_only`. The caller decides that existing
|
|
727
|
+
references no longer need the File. Deletion does not discover or rewrite those
|
|
728
|
+
references, cascade, or provide trash/recovery.
|
|
720
729
|
|
|
721
730
|
`enrich` accepts a string encoded as UTF-8 or exact `Uint8Array` bytes, a safe
|
|
722
731
|
flat filename, and an optional MIME hint. OS verifies text/Markdown/JSON or
|
package/dist/browser.js
CHANGED
|
@@ -6755,6 +6755,80 @@ function dataTransportError(status, value) {
|
|
|
6755
6755
|
), row?.message, row?.detail);
|
|
6756
6756
|
}
|
|
6757
6757
|
|
|
6758
|
+
var identityPattern = /^(gmail|airtable|dropbox|outlook|sharepoint)\/([a-z0-9][a-z0-9-]{0,62})$/, workspacePattern = /^[a-z0-9][a-z0-9-]{0,62}$/, providerNames = {
|
|
6759
|
+
gmail: "Gmail",
|
|
6760
|
+
airtable: "Airtable",
|
|
6761
|
+
dropbox: "Dropbox",
|
|
6762
|
+
outlook: "Outlook",
|
|
6763
|
+
sharepoint: "SharePoint"
|
|
6764
|
+
};
|
|
6765
|
+
function parseConnectionFailureDetail(value) {
|
|
6766
|
+
if (!value || typeof value != "object" || Array.isArray(value)) throw new Error("Invalid Connection failure");
|
|
6767
|
+
let v = value;
|
|
6768
|
+
if (Object.keys(v).some((key) => !["identity", "workspace", "code", "stage", "retryable", "attempts", "elapsedMs", "status"].includes(key)) || typeof v.identity != "string" || !identityPattern.test(v.identity) || v.workspace !== void 0 && (typeof v.workspace != "string" || !workspacePattern.test(v.workspace)) || !["temporarily_unavailable", "attention_required", "invalid_response"].includes(v.code) || !["authorization", "provider", "finalization", "transport", "validation"].includes(v.stage) || v.retryable !== (v.code === "temporarily_unavailable") || !Number.isSafeInteger(v.attempts) || v.attempts < 0 || v.attempts > 3 || !Number.isSafeInteger(v.elapsedMs) || v.elapsedMs < 0 || Object.hasOwn(v, "status") && (!Number.isSafeInteger(v.status) || v.status < 100 || v.status > 599))
|
|
6769
|
+
throw new Error("Invalid Connection failure");
|
|
6770
|
+
return {
|
|
6771
|
+
identity: v.identity,
|
|
6772
|
+
...v.workspace === void 0 ? {} : { workspace: v.workspace },
|
|
6773
|
+
code: v.code,
|
|
6774
|
+
stage: v.stage,
|
|
6775
|
+
retryable: v.retryable,
|
|
6776
|
+
attempts: v.attempts,
|
|
6777
|
+
elapsedMs: v.elapsedMs,
|
|
6778
|
+
...Object.hasOwn(v, "status") ? { status: v.status } : {}
|
|
6779
|
+
};
|
|
6780
|
+
}
|
|
6781
|
+
function connectionFailureMessage(value) {
|
|
6782
|
+
let detail = parseConnectionFailureDetail(value), [, provider2, name2] = identityPattern.exec(detail.identity), duration = detail.elapsedMs < 1e3 ? `${detail.elapsedMs}ms` : `${(detail.elapsedMs / 1e3).toFixed(1)}s`, explanation = `OS couldn\u2019t grant this Run access to ${providerNames[provider2]} connection ${name2}.
|
|
6783
|
+
${detail.attempts} ${detail.attempts === 1 ? "attempt" : "attempts"} in ${duration}.
|
|
6784
|
+
|
|
6785
|
+
The routine received no provider access through this lease and made no provider business request through it.`;
|
|
6786
|
+
return detail.code !== "attention_required" ? explanation : detail.workspace ? `${explanation}
|
|
6787
|
+
|
|
6788
|
+
Check it with:
|
|
6789
|
+
os connection test --workspace ${detail.workspace} --connection ${detail.identity}` : `${explanation}
|
|
6790
|
+
|
|
6791
|
+
Check or reconnect this Connection.`;
|
|
6792
|
+
}
|
|
6793
|
+
function connectionRunFailureMessage(detail, completedWork = !1) {
|
|
6794
|
+
return connectionFailureMessage(detail) + `
|
|
6795
|
+
|
|
6796
|
+
The Run stopped safely.` + (completedWork ? `
|
|
6797
|
+
|
|
6798
|
+
Work completed before this failure was kept.` : "");
|
|
6799
|
+
}
|
|
6800
|
+
var ConnectionOperationError = class extends Error {
|
|
6801
|
+
detail;
|
|
6802
|
+
get code() {
|
|
6803
|
+
return this.detail.code;
|
|
6804
|
+
}
|
|
6805
|
+
get stage() {
|
|
6806
|
+
return this.detail.stage;
|
|
6807
|
+
}
|
|
6808
|
+
get retryable() {
|
|
6809
|
+
return this.detail.retryable;
|
|
6810
|
+
}
|
|
6811
|
+
get attempts() {
|
|
6812
|
+
return this.detail.attempts;
|
|
6813
|
+
}
|
|
6814
|
+
get elapsedMs() {
|
|
6815
|
+
return this.detail.elapsedMs;
|
|
6816
|
+
}
|
|
6817
|
+
get status() {
|
|
6818
|
+
return this.detail.status;
|
|
6819
|
+
}
|
|
6820
|
+
constructor(identity, workspace, facts2 = {
|
|
6821
|
+
code: "invalid_response",
|
|
6822
|
+
stage: "validation",
|
|
6823
|
+
retryable: !1,
|
|
6824
|
+
attempts: 0,
|
|
6825
|
+
elapsedMs: 0
|
|
6826
|
+
}) {
|
|
6827
|
+
let detail = parseConnectionFailureDetail({ ...facts2, identity, ...workspace === void 0 ? {} : { workspace } });
|
|
6828
|
+
super(connectionFailureMessage(detail)), this.name = "ConnectionOperationError", this.detail = detail;
|
|
6829
|
+
}
|
|
6830
|
+
};
|
|
6831
|
+
|
|
6758
6832
|
var installed, ended = !1;
|
|
6759
6833
|
function routineTransport() {
|
|
6760
6834
|
if (ended || installed && !installed.isCurrent()) throw new Error("Routine authority ended");
|
|
@@ -8786,7 +8860,11 @@ async function send(suffix, init2, descriptor, initial, parent) {
|
|
|
8786
8860
|
parseFileErrorDetail(error?.detail)
|
|
8787
8861
|
) : unavailable4();
|
|
8788
8862
|
}
|
|
8789
|
-
if (response2.status
|
|
8863
|
+
if (descriptor === "void" && response2.status === 204 && response2.body === null) {
|
|
8864
|
+
checkCurrent();
|
|
8865
|
+
return;
|
|
8866
|
+
}
|
|
8867
|
+
if (descriptor === "void" || response2.status !== 200)
|
|
8790
8868
|
throw response2.body?.cancel().catch(() => {
|
|
8791
8869
|
}), unavailable4();
|
|
8792
8870
|
try {
|
|
@@ -9077,6 +9155,10 @@ var files = {
|
|
|
9077
9155
|
return result2;
|
|
9078
9156
|
}, context);
|
|
9079
9157
|
},
|
|
9158
|
+
async delete(id3) {
|
|
9159
|
+
let path = idPath(id3);
|
|
9160
|
+
return operation((context, signal) => send(path, { method: "DELETE" }, "void", context, signal));
|
|
9161
|
+
},
|
|
9080
9162
|
async get(id3) {
|
|
9081
9163
|
return operation((context, signal) => send(idPath(id3), { method: "GET" }, !0, context, signal));
|
|
9082
9164
|
},
|
|
@@ -9394,38 +9476,6 @@ async function reportLocalRoutineEffect(value) {
|
|
|
9394
9476
|
await observer?.(value);
|
|
9395
9477
|
}
|
|
9396
9478
|
|
|
9397
|
-
var identityPattern = /^(gmail|airtable|dropbox|outlook|sharepoint)\/([a-z0-9][a-z0-9-]{0,62})$/, workspacePattern = /^[a-z0-9][a-z0-9-]{0,62}$/, providerNames = {
|
|
9398
|
-
gmail: "Gmail",
|
|
9399
|
-
airtable: "Airtable",
|
|
9400
|
-
dropbox: "Dropbox",
|
|
9401
|
-
outlook: "Outlook",
|
|
9402
|
-
sharepoint: "SharePoint"
|
|
9403
|
-
};
|
|
9404
|
-
function parseConnectionFailureDetail(value) {
|
|
9405
|
-
if (!value || typeof value != "object" || Array.isArray(value)) throw new Error("Invalid Connection failure");
|
|
9406
|
-
let detail = value;
|
|
9407
|
-
if (!["identity", "identity,workspace"].includes(Object.keys(detail).sort().join(",")) || typeof detail.identity != "string" || !identityPattern.test(detail.identity) || detail.workspace !== void 0 && (typeof detail.workspace != "string" || !workspacePattern.test(detail.workspace)))
|
|
9408
|
-
throw new Error("Invalid Connection failure");
|
|
9409
|
-
return { identity: detail.identity, ...detail.workspace === void 0 ? {} : { workspace: detail.workspace } };
|
|
9410
|
-
}
|
|
9411
|
-
function connectionFailureMessage(value) {
|
|
9412
|
-
let detail = parseConnectionFailureDetail(value), [, provider2, name2] = identityPattern.exec(detail.identity), first = `Couldn\u2019t use ${providerNames[provider2] ?? provider2} connection ${name2}.`;
|
|
9413
|
-
return detail.workspace ? `${first}
|
|
9414
|
-
|
|
9415
|
-
Check it with:
|
|
9416
|
-
os connection test --workspace ${detail.workspace} --connection ${detail.identity}` : `${first}
|
|
9417
|
-
|
|
9418
|
-
Check or reconnect this Connection, then try again.`;
|
|
9419
|
-
}
|
|
9420
|
-
var ConnectionOperationError = class extends Error {
|
|
9421
|
-
code = "unavailable";
|
|
9422
|
-
detail;
|
|
9423
|
-
constructor(identity, workspace) {
|
|
9424
|
-
let detail = parseConnectionFailureDetail({ identity, ...workspace === void 0 ? {} : { workspace } });
|
|
9425
|
-
super(connectionFailureMessage(detail)), this.name = "ConnectionOperationError", this.detail = detail;
|
|
9426
|
-
}
|
|
9427
|
-
};
|
|
9428
|
-
|
|
9429
9479
|
var local;
|
|
9430
9480
|
async function localLease(identity) {
|
|
9431
9481
|
let current2 = local;
|
|
@@ -11589,9 +11639,15 @@ function summary(value, key, context, id3) {
|
|
|
11589
11639
|
return fail7("execution_unavailable");
|
|
11590
11640
|
}
|
|
11591
11641
|
let run = value;
|
|
11592
|
-
return (!only(run, "id,routine,placement,status,createdAt,startedAt,finishedAt,steps,result,failure,local") || typeof run.id != "string" || !uuid3.test(run.id) || id3 !== void 0 && run.id !== id3 || run.routine !== key || run.placement !== "local" || !["queued", "running", "succeeded", "failed", "legacy"].includes(run.status) || !timestamp(run.createdAt) || !optionalTimes(run) || !Array.isArray(run.steps) || run.steps.length > 64 || run.steps.some((step) => !only(step, "id,title,status,startedAt,finishedAt,progress,summary,detailAvailable") || typeof step.detailAvailable != "boolean" || !validStep(step)) || new Set(run.steps.map((step) => step.id)).size !== run.steps.length || Object.hasOwn(run, "result") && (run.status !== "succeeded" || !bounded2(run.result)) || run.failure !== void 0 && (run.status !== "failed" || !validFailure(run.failure, run.steps)) || run.local !== void 0 && !validLocalActivity(run.local)) && fail7("execution_unavailable"), run;
|
|
11642
|
+
return (!only(run, "id,routine,placement,status,createdAt,startedAt,finishedAt,steps,result,failure,local") || typeof run.id != "string" || !uuid3.test(run.id) || id3 !== void 0 && run.id !== id3 || run.routine !== key || run.placement !== "local" || !["queued", "running", "succeeded", "failed", "legacy"].includes(run.status) || !timestamp(run.createdAt) || !optionalTimes(run) || !Array.isArray(run.steps) || run.steps.length > 64 || run.steps.some((step) => !only(step, "id,title,status,startedAt,finishedAt,progress,summary,detailAvailable") || typeof step.detailAvailable != "boolean" || !validStep(step)) || new Set(run.steps.map((step) => step.id)).size !== run.steps.length || Object.hasOwn(run, "result") && (run.status !== "succeeded" || !bounded2(run.result)) || run.failure !== void 0 && (run.status !== "failed" || !validFailure(run.failure, run.steps, run)) || run.local !== void 0 && !validLocalActivity(run.local)) && fail7("execution_unavailable"), run;
|
|
11593
11643
|
}
|
|
11594
|
-
function validFailure(value, steps) {
|
|
11644
|
+
function validFailure(value, steps, local2) {
|
|
11645
|
+
if (local2 && only(value, "message,code,detail") && value.code !== void 0)
|
|
11646
|
+
try {
|
|
11647
|
+
let detail = parseConnectionFailureDetail(value.detail), completedWork = steps.some((step) => step.status === "completed") || !!local2.local?.effects.some((effect) => effect.status === "completed") || !!local2.local?.data.some((repository) => repository.created.length || repository.updated.length || repository.deleted.length);
|
|
11648
|
+
return value.code === detail.code && value.message === connectionRunFailureMessage(detail, completedWork);
|
|
11649
|
+
} catch {
|
|
11650
|
+
}
|
|
11595
11651
|
if (!only(value, "message,code,step,sizeBytes,limitBytes,summaryBytes,dataBytes") || !message(value.message)) return !1;
|
|
11596
11652
|
if (value.code === void 0) return only(value, "message");
|
|
11597
11653
|
if (value.code !== "step_output_too_large") return !1;
|