@oddington/sdk 0.1.70 → 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/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");
@@ -9402,38 +9476,6 @@ async function reportLocalRoutineEffect(value) {
9402
9476
  await observer?.(value);
9403
9477
  }
9404
9478
 
9405
- 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 = {
9406
- gmail: "Gmail",
9407
- airtable: "Airtable",
9408
- dropbox: "Dropbox",
9409
- outlook: "Outlook",
9410
- sharepoint: "SharePoint"
9411
- };
9412
- function parseConnectionFailureDetail(value) {
9413
- if (!value || typeof value != "object" || Array.isArray(value)) throw new Error("Invalid Connection failure");
9414
- let detail = value;
9415
- 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)))
9416
- throw new Error("Invalid Connection failure");
9417
- return { identity: detail.identity, ...detail.workspace === void 0 ? {} : { workspace: detail.workspace } };
9418
- }
9419
- function connectionFailureMessage(value) {
9420
- let detail = parseConnectionFailureDetail(value), [, provider2, name2] = identityPattern.exec(detail.identity), first = `Couldn\u2019t use ${providerNames[provider2] ?? provider2} connection ${name2}.`;
9421
- return detail.workspace ? `${first}
9422
-
9423
- Check it with:
9424
- os connection test --workspace ${detail.workspace} --connection ${detail.identity}` : `${first}
9425
-
9426
- Check or reconnect this Connection, then try again.`;
9427
- }
9428
- var ConnectionOperationError = class extends Error {
9429
- code = "unavailable";
9430
- detail;
9431
- constructor(identity, workspace) {
9432
- let detail = parseConnectionFailureDetail({ identity, ...workspace === void 0 ? {} : { workspace } });
9433
- super(connectionFailureMessage(detail)), this.name = "ConnectionOperationError", this.detail = detail;
9434
- }
9435
- };
9436
-
9437
9479
  var local;
9438
9480
  async function localLease(identity) {
9439
9481
  let current2 = local;
@@ -11597,9 +11639,15 @@ function summary(value, key, context, id3) {
11597
11639
  return fail7("execution_unavailable");
11598
11640
  }
11599
11641
  let run = value;
11600
- 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;
11601
11643
  }
11602
- 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
+ }
11603
11651
  if (!only(value, "message,code,step,sizeBytes,limitBytes,summaryBytes,dataBytes") || !message(value.message)) return !1;
11604
11652
  if (value.code === void 0) return only(value, "message");
11605
11653
  if (value.code !== "step_output_too_large") return !1;