@oddington/sdk 0.1.48 → 0.1.50

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
@@ -319,6 +319,11 @@ function validateRoutineSchemaValue(schema2, value, rejected) {
319
319
  check(schema2, value, "$");
320
320
  }
321
321
 
322
+ var RECORD_READ_INPUT_LIMIT = 1024 * 1024, RECORD_CAPTURE_OUTPUT_LIMIT = 25 * 1024 * 1024;
323
+ function validRecordRef(value) {
324
+ return typeof value == "string" && value.length <= 512 && /^[_a-zA-Z0-9][a-zA-Z0-9_-]*(\/[_a-zA-Z0-9][a-zA-Z0-9_-]*)+$/.test(value);
325
+ }
326
+
322
327
  function validDropboxRootPath(value) {
323
328
  return typeof value == "string" && value.length <= 2048 && value.startsWith("/") && !/[\\\x00-\x1f\x7f]/.test(value) && value.slice(1).split("/").every((segment) => segment.length > 0 && segment.trim() === segment && segment !== "." && segment !== "..");
324
329
  }
@@ -449,12 +454,9 @@ function validateInboxFile(value) {
449
454
  let size = natural(v.size, "file size");
450
455
  return size > FILE_ORIGINAL_MAX_BYTES && fail("File exceeds supported size"), { id: fileId, name: name2, mediaType, size, sha256: v.sha256 };
451
456
  }
452
- function fields2(value) {
453
- let result2 = array(value, "selected fields").map((entry) => {
454
- let field = object(entry, "field");
455
- return keys(field, ["label", "value"], "field"), { label: text(field.label, "field label"), value: text(field.value, "field value") };
456
- });
457
- return new Set(result2.map((field) => field.label)).size !== result2.length && fail("Duplicate field label"), result2;
457
+ function validateQualifiedRecordRef(value) {
458
+ let r = object(value, "Record reference");
459
+ return keys(r, ["repository", "ref"], "Record reference"), (!validDataRepositoryName(r.repository) || !validRecordRef(r.ref)) && fail("Invalid qualified Record reference"), { repository: r.repository, ref: r.ref };
458
460
  }
459
461
  function validateBlock(value) {
460
462
  let b = object(serializable(value), "Block");
@@ -465,32 +467,14 @@ function validateBlock(value) {
465
467
  let asks = distinctIds(b.asks, "Ask IDs");
466
468
  return asks.some((ask) => !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(ask)) && fail("Invalid Ask ID"), { kind: "asks", problem: text(b.problem, "problem"), asks };
467
469
  }
468
- ["record", "records", "files"].includes(b.kind) || fail("Unknown Block kind"), keys(b, ["kind", "label", "initiallyExpanded", ...b.kind === "record" ? ["record", "view"] : b.kind === "records" ? ["records", "view"] : ["files"]], "Block");
470
+ ["record", "records", "files"].includes(b.kind) || fail("Unknown Block kind"), keys(b, ["kind", "label", "initiallyExpanded", ...b.kind === "record" ? ["record"] : b.kind === "records" ? ["records"] : ["files"]], "Block");
469
471
  let label = text(b.label, "Block label");
470
472
  b.initiallyExpanded !== void 0 && typeof b.initiallyExpanded != "boolean" && fail("Invalid initiallyExpanded");
471
- let expanded = b.initiallyExpanded === void 0 ? {} : { initiallyExpanded: b.initiallyExpanded }, target = b.view === void 0 ? {} : { view: id(b.view, "View target") };
472
- if (b.kind === "record") {
473
- let r = object(b.record, "presented record");
474
- return keys(r, ["ref", "title", "fields"], "presented record"), {
475
- kind: "record",
476
- label,
477
- ...target,
478
- ...expanded,
479
- record: { ref: id(r.ref, "record reference"), title: text(r.title, "record title"), fields: fields2(r.fields) }
480
- };
481
- }
473
+ let expanded = b.initiallyExpanded === void 0 ? {} : { initiallyExpanded: b.initiallyExpanded };
474
+ if (b.kind === "record") return { kind: "record", label, record: validateQualifiedRecordRef(b.record), ...expanded };
482
475
  if (b.kind === "records") {
483
- let records = array(b.records, "records").map((entry) => {
484
- let r = object(entry, "record summary");
485
- return keys(r, ["ref", "title", "description", "facts", "view"], "record summary"), {
486
- ref: id(r.ref, "record reference"),
487
- title: text(r.title, "record title"),
488
- ...r.description === void 0 ? {} : { description: text(r.description, "record description") },
489
- ...r.facts === void 0 ? {} : { facts: fields2(r.facts) },
490
- ...r.view === void 0 ? {} : { view: id(r.view, "row View target") }
491
- };
492
- });
493
- return (!records.length || new Set(records.map((r) => r.ref)).size !== records.length) && fail("Empty or duplicate records"), { kind: "records", label, records, ...target, ...expanded };
476
+ let records = array(b.records, "records").map(validateQualifiedRecordRef);
477
+ return (!records.length || new Set(records.map((r) => JSON.stringify([r.repository, r.ref]))).size !== records.length) && fail("Empty or duplicate records"), { kind: "records", label, records, ...expanded };
494
478
  }
495
479
  let files3 = array(b.files, "files").map(validateInboxFile);
496
480
  return (!files3.length || new Set(files3.map((file2) => file2.id)).size !== files3.length) && fail("Empty or duplicate files"), { kind: "files", label, files: files3, ...expanded };
@@ -621,26 +605,9 @@ function defineHandler(value) {
621
605
  function respond(handler, input) {
622
606
  return defineHandler(handler), handlerReference({ id: handler.id, input });
623
607
  }
624
- function recordRequirements(value) {
625
- let source2 = object(value, "Record requirements");
626
- keys(source2, ["repository", "records"], "Record requirements"), validDataRepositoryName(source2.repository) || fail("Invalid requirements repository");
627
- let repository = source2.repository, records = array(source2.records, "required Records").map((entry) => {
628
- let row = object(entry, "required Record");
629
- keys(row, ["ref", "version"], "required Record");
630
- let { ref } = validateRecordReference({ repository, ref: row.ref });
631
- return (typeof row.version != "string" || !row.version.length || row.version.length > 512) && fail("Invalid required Record version"), { ref, version: row.version };
632
- });
633
- return new Set(records.map((record4) => record4.ref)).size !== records.length && fail("Duplicate required Record"), { repository, records };
634
- }
635
- function requireRecords(repository, records) {
636
- return recordRequirements({ repository, records: array(records, "required Records").map((entry) => {
637
- let record4 = object(entry, "Data Record");
638
- return { ref: record4.$ref, version: record4.$version };
639
- }) });
640
- }
641
608
  function question(value) {
642
609
  let source2 = object(value, "question");
643
- keys(source2, ["id", "to", "allowedResponders", "prompt", "instructions", "response", "handler", "requirements"], "question");
610
+ keys(source2, ["id", "to", "allowedResponders", "prompt", "instructions", "response", "handler"], "question");
644
611
  let to = personReference(source2.to, "question assignee"), allowedResponders = source2.allowedResponders === void 0 ? [to] : distinctPeople(source2.allowedResponders, "allowed responders");
645
612
  return allowedResponders.includes(to) || fail("Allowed responders must include the assignee"), {
646
613
  id: id(source2.id, "question ID"),
@@ -649,8 +616,7 @@ function question(value) {
649
616
  prompt: text(source2.prompt, "question prompt"),
650
617
  ...source2.instructions === void 0 ? {} : { instructions: text(source2.instructions, "instructions") },
651
618
  response: validateResponseDefinition(source2.response),
652
- ...Object.hasOwn(source2, "handler") ? { handler: handlerReference(source2.handler) } : {},
653
- ...Object.hasOwn(source2, "requirements") ? { requirements: recordRequirements(source2.requirements) } : {}
619
+ ...Object.hasOwn(source2, "handler") ? { handler: handlerReference(source2.handler) } : {}
654
620
  };
655
621
  }
656
622
  function presentation(source2) {
@@ -660,10 +626,6 @@ function presentation(source2) {
660
626
  });
661
627
  new Set(views.map((view) => view.id)).size !== views.length && fail("Duplicate view ID");
662
628
  let body = source2.body === void 0 ? [] : array(source2.body, "body").map(validateBlock);
663
- for (let block2 of body) {
664
- let targets = block2.kind === "record" ? [block2.view] : block2.kind === "records" ? [block2.view, ...block2.records.map((record4) => record4.view)] : [];
665
- for (let target of targets) target !== void 0 && !views.some((view) => view.id === target) && fail(`Unknown Block View target: ${target}`);
666
- }
667
629
  return { title: text(source2.title, "title"), description: text(source2.description, "description"), views, body };
668
630
  }
669
631
  function validatePublication(value) {
@@ -678,13 +640,13 @@ function validatePublication(value) {
678
640
  "notifyImmediately",
679
641
  ...source2.kind === "ask" ? ["questions", "tags", "recordRefs"] : []
680
642
  ], "publication"), source2.notifyImmediately !== void 0 && typeof source2.notifyImmediately != "boolean" && fail("notifyImmediately must be a boolean");
681
- let itemPresentation = { ...presentation(source2), ...source2.notifyImmediately === void 0 ? {} : { notifyImmediately: source2.notifyImmediately } }, linkedAsks = (itemPresentation.body ?? []).flatMap((block2) => block2.kind === "asks" ? block2.asks : []);
643
+ let itemPresentation = { ...presentation(source2), ...source2.notifyImmediately === void 0 ? {} : { notifyImmediately: source2.notifyImmediately } }, linkedAsks = (itemPresentation.body ?? []).flatMap((block) => block.kind === "asks" ? block.asks : []);
682
644
  if (new Set(linkedAsks).size !== linkedAsks.length && fail("Ask belongs to more than one problem"), source2.kind === "digest") return {
683
645
  kind: "digest",
684
646
  ...itemPresentation,
685
647
  recipients: distinctPeople(source2.recipients, "digest recipients")
686
648
  };
687
- itemPresentation.body?.some((block2) => block2.kind === "asks") && fail("Asks Blocks belong to Digests");
649
+ itemPresentation.body?.some((block) => block.kind === "asks") && fail("Asks Blocks belong to Digests");
688
650
  let questions = array(source2.questions === void 0 ? [] : source2.questions, "questions").map((value2) => question(value2));
689
651
  new Set(questions.map((entry) => entry.id)).size !== questions.length && fail("Duplicate question ID");
690
652
  let extra = source2.recipients === void 0 ? [] : distinctPeople(source2.recipients, "recipients", !1);
@@ -765,7 +727,7 @@ function createInboxPublisher(transport) {
765
727
  var ROUTINE_DECLARATION_SCHEMA = "https://schemas.oddington.ai/routine/v1.json", ROUTINE_SOURCE_LIMITS = { files: 2e4, bytes: 256 * 1024 * 1024, declarationBytes: 64 * 1024 };
766
728
  var invalid = (field) => {
767
729
  throw new Error(`Invalid routine declaration: ${field}`);
768
- }, object2 = (value, fields5, field) => ((!value || typeof value != "object" || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null || Reflect.ownKeys(value).some((key) => typeof key != "string" || !fields5.includes(key) || !Object.getOwnPropertyDescriptor(value, key).enumerable || !Object.hasOwn(Object.getOwnPropertyDescriptor(value, key), "value"))) && invalid(field), value), routineAlias = (value) => typeof value == "string" && /^[a-z][a-z0-9-]{0,62}$/.test(value), list = (value, field, allowed, qualified = !1) => value === void 0 ? [] : ((!Array.isArray(value) || value.length > 64 || value.some((item) => !(routineAlias(item) || qualified && typeof item == "string" && item.split("/").length === 2 && item.split("/").every(routineAlias)) || allowed && !allowed.includes(item)) || new Set(value).size !== value.length) && invalid(field), [...value].sort());
730
+ }, object2 = (value, fields3, field) => ((!value || typeof value != "object" || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null || Reflect.ownKeys(value).some((key) => typeof key != "string" || !fields3.includes(key) || !Object.getOwnPropertyDescriptor(value, key).enumerable || !Object.hasOwn(Object.getOwnPropertyDescriptor(value, key), "value"))) && invalid(field), value), routineAlias = (value) => typeof value == "string" && /^[a-z][a-z0-9-]{0,62}$/.test(value), list = (value, field, allowed, qualified = !1) => value === void 0 ? [] : ((!Array.isArray(value) || value.length > 64 || value.some((item) => !(routineAlias(item) || qualified && typeof item == "string" && item.split("/").length === 2 && item.split("/").every(routineAlias)) || allowed && !allowed.includes(item)) || new Set(value).size !== value.length) && invalid(field), [...value].sort());
769
731
  function routineAssetPattern(value) {
770
732
  return typeof value == "string" && value.length <= 512 && !value.startsWith("/") && !value.includes("\\") && !value.includes(":") && value.split("/").every((part) => !!part && part !== "." && part !== ".." && /^[a-zA-Z0-9_.*-]+$/.test(part));
771
733
  }
@@ -1321,11 +1283,6 @@ async function executeRoutineDefinition(definition, input, runtime) {
1321
1283
  if (result2 !== void 0) return invalid3();
1322
1284
  }
1323
1285
 
1324
- var RECORD_READ_INPUT_LIMIT = 1024 * 1024, RECORD_CAPTURE_OUTPUT_LIMIT = 25 * 1024 * 1024;
1325
- function validRecordRef(value) {
1326
- return typeof value == "string" && value.length <= 512 && /^[_a-zA-Z0-9][a-zA-Z0-9_-]*(\/[_a-zA-Z0-9][a-zA-Z0-9_-]*)+$/.test(value);
1327
- }
1328
-
1329
1286
  var fieldProblems = ["unknown", "missing", "invalid", "source_schema"], reasons = {
1330
1287
  unknown: "unknown_field",
1331
1288
  missing: "missing_field",
@@ -1431,6 +1388,9 @@ function explainDataValidation(error, message2, detail) {
1431
1388
  return Object.assign(error, dataValidationMessageFacts({ code: error.code, message: typeof message2 == "string" ? message2 : "", detail })), error;
1432
1389
  }
1433
1390
 
1391
+ function dataPublicationFailureMessage(detail) {
1392
+ return detail.preflight === "dirty_repository" ? `Data repository ${detail.repository} has existing changes. No Record files were changed. Use os data push ${detail.repository} or stash those Data changes with Git, then run the routine again.` : (detail.state === "commit" ? `Data commit ${detail.commit} remains in your checkout; its push is unconfirmed.` : detail.state === "files" ? "Your Record files were applied, but Git could not create their commit." : "Data publication needs Git preparation. No Record files were changed.") + ` Review git status and your branch and destination, then use os data push ${detail.repository}. Do not rerun the routine to recover this publication.`;
1393
+ }
1434
1394
  var localDataPath = (value, repository) => typeof value == "string" && value.length <= 1024 && value.startsWith(`${repository}/`) && !value.includes("\\") && !/[\x00-\x1f\x7f]/.test(value) && value.split("/").every((part) => !!part && part !== "." && part !== ".."), localDataFile = (value, repository) => {
1435
1395
  if (!value || typeof value != "object" || Array.isArray(value)) return !1;
1436
1396
  let row = value;
@@ -1461,6 +1421,12 @@ function parseDataOperationDetail(value) {
1461
1421
  throw new Error("Invalid Data operation detail");
1462
1422
  return structuredClone(value);
1463
1423
  }
1424
+ if (value && typeof value == "object" && !Array.isArray(value) && value.code === "local_data_publication_failed") {
1425
+ let row = value;
1426
+ if (Object.keys(row).sort().join(",") !== (row.state === "commit" ? "code,commit,repository,state" : Object.hasOwn(row, "preflight") ? "code,preflight,repository,state" : "code,repository,state") || Object.hasOwn(row, "preflight") && (row.state !== "unapplied" || row.preflight !== "dirty_repository") || typeof row.repository != "string" || !/^[a-z0-9][a-z0-9._-]{0,127}$/.test(row.repository) || row.repository.includes("..") || !["unapplied", "files", "commit"].includes(String(row.state)) || row.state === "commit" && (typeof row.commit != "string" || !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(row.commit)))
1427
+ throw new Error("Invalid Data publication detail");
1428
+ return structuredClone(value);
1429
+ }
1464
1430
  return parseDataFailureDetail(value);
1465
1431
  }
1466
1432
  function dataRecordLimitMessage(detail) {
@@ -1472,7 +1438,7 @@ var DataOperationError = class extends Error {
1472
1438
  let parsed = detail === void 0 ? void 0 : parseDataOperationDetail(detail);
1473
1439
  if (parsed && ("reason" in parsed ? code !== "invalid_change" : parsed.code === "record_limit_exceeded" && code !== "capacity"))
1474
1440
  throw new Error("Invalid Data operation detail");
1475
- super(code === "capacity" && parsed && "code" in parsed && parsed.code === "record_limit_exceeded" ? dataRecordLimitMessage(parsed) : `Data operation failed: ${code}`);
1441
+ 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) : `Data operation failed: ${code}`);
1476
1442
  this.code = code;
1477
1443
  this.retryable = retryable;
1478
1444
  this.effect = effect;
@@ -1579,8 +1545,8 @@ function captureRecordsAll(query, options) {
1579
1545
  let detached = capture3(query), selections = dataProperties(detached);
1580
1546
  if (Object.keys(selections).length < 1 || Object.keys(selections).length > 16) return invalid9();
1581
1547
  for (let selection2 of Object.values(selections)) {
1582
- let fields5 = dataProperties(selection2.value);
1583
- if (fields5.$ && Object.hasOwn(dataProperties(fields5.$.value), "after")) return invalid9();
1548
+ let fields3 = dataProperties(selection2.value);
1549
+ if (fields3.$ && Object.hasOwn(dataProperties(fields3.$.value), "after")) return invalid9();
1584
1550
  }
1585
1551
  return { query: detached, maxRecords };
1586
1552
  } catch {
@@ -1618,16 +1584,20 @@ function captureDataDelete(record4) {
1618
1584
  return !validRecordRef(identity.$ref) || typeof identity.$version != "string" || !identity.$version.length || identity.$version.length > 512 ? invalidChange() : { ref: identity.$ref, expectedVersion: identity.$version };
1619
1585
  }
1620
1586
  function captureDataUpdate(record4, set) {
1621
- let identity = captureDataDelete(record4), input = mapping(set), { $body, ...fields5 } = input, body = Object.hasOwn(input, "$body");
1622
- return body && !validRecordBody($body) || !Object.keys(fields5).length && !body || Object.keys(fields5).some((key) => key.startsWith("$") || ["id", "type"].includes(key)) ? invalidChange() : { ...identity, set: captureValue(fields5), ...body ? { body: $body } : {} };
1587
+ if (!validRecordRef(record4)) return invalidChange();
1588
+ let input = mapping(set), { $body, ...fields3 } = input, body = Object.hasOwn(input, "$body");
1589
+ return body && !validRecordBody($body) || !Object.keys(fields3).length && !body || Object.keys(fields3).some((key) => key.startsWith("$") || ["id", "type"].includes(key)) ? invalidChange() : { ref: record4, set: captureValue(fields3), ...body ? { body: $body } : {} };
1623
1590
  }
1624
1591
  function captureIdentities(value, update, allowEmpty = !0) {
1625
1592
  if (!Array.isArray(value) || !allowEmpty && !value.length || value.length > 1e4) return invalidChange();
1626
1593
  let captured = value.map((item) => {
1627
1594
  let row = mapping(item);
1628
- if (Object.keys(row).filter((key) => !update || key !== "body").sort().join(",") !== (update ? "expectedVersion,ref,set" : "expectedVersion,ref")) return invalidChange();
1595
+ if (Object.keys(row).filter((key) => !update || !["body", "expectedVersion"].includes(key)).sort().join(",") !== (update ? "ref,set" : "expectedVersion,ref")) return invalidChange();
1629
1596
  let identity = { $ref: row.ref, $version: row.expectedVersion };
1630
- return update && Object.keys(mapping(row.set)).some((key) => key.startsWith("$")) ? invalidChange() : update ? captureDataUpdate(identity, { ...mapping(row.set), ...Object.hasOwn(row, "body") ? { $body: row.body } : {} }) : captureDataDelete(identity);
1597
+ if (update && Object.keys(mapping(row.set)).some((key) => key.startsWith("$"))) return invalidChange();
1598
+ if (!update) return captureDataDelete(identity);
1599
+ let captured2 = captureDataUpdate(row.ref, { ...mapping(row.set), ...Object.hasOwn(row, "body") ? { $body: row.body } : {} });
1600
+ return Object.hasOwn(row, "expectedVersion") ? { ...captured2, expectedVersion: captureDataDelete(identity).expectedVersion } : captured2;
1631
1601
  });
1632
1602
  return new Set(captured.map((item) => item.ref)).size !== captured.length ? invalidChange() : captured;
1633
1603
  }
@@ -1638,7 +1608,7 @@ function captureDataCreate(value) {
1638
1608
  let row = mapping(value);
1639
1609
  if (!validRecordRef(row.$ref) || Object.keys(row).some((key) => key.startsWith("$") && !["$ref", "$filing", "$body"].includes(key)))
1640
1610
  return invalidChange();
1641
- let { $ref: ref, $filing, $body, ...fields5 } = row, body = Object.hasOwn(row, "$body");
1611
+ let { $ref: ref, $filing, $body, ...fields3 } = row, body = Object.hasOwn(row, "$body");
1642
1612
  if (body && !validRecordBody($body)) return invalidChange();
1643
1613
  let filing;
1644
1614
  if ($filing !== void 0) {
@@ -1647,7 +1617,7 @@ function captureDataCreate(value) {
1647
1617
  return invalidChange();
1648
1618
  filing = { ...components };
1649
1619
  }
1650
- return { ref, fields: captureValue(fields5), ...filing ? { filing } : {}, ...body ? { body: $body } : {} };
1620
+ return { ref, fields: captureValue(fields3), ...filing ? { filing } : {}, ...body ? { body: $body } : {} };
1651
1621
  }
1652
1622
  function captureDataChanges(updatesValue, createsValue = [], deletesValue = []) {
1653
1623
  let updates = captureDataUpdates(updatesValue, !0);
@@ -1655,9 +1625,9 @@ function captureDataChanges(updatesValue, createsValue = [], deletesValue = [])
1655
1625
  let creates = createsValue.map((item) => {
1656
1626
  let row = mapping(item);
1657
1627
  if (Object.keys(row).some((key) => !["ref", "fields", "filing", "body"].includes(key)) || !Object.hasOwn(row, "ref") || !Object.hasOwn(row, "fields")) return invalidChange();
1658
- let fields5 = mapping(row.fields);
1659
- return Object.keys(fields5).some((key) => key.startsWith("$")) ? invalidChange() : captureDataCreate({
1660
- ...fields5,
1628
+ let fields3 = mapping(row.fields);
1629
+ return Object.keys(fields3).some((key) => key.startsWith("$")) ? invalidChange() : captureDataCreate({
1630
+ ...fields3,
1661
1631
  $ref: row.ref,
1662
1632
  ...Object.hasOwn(row, "filing") ? { $filing: row.filing } : {},
1663
1633
  ...Object.hasOwn(row, "body") ? { $body: row.body } : {}
@@ -1841,7 +1811,7 @@ function recordPagination(queryRecords) {
1841
1811
  var genericData = {
1842
1812
  repository(repository) {
1843
1813
  async function send3(input) {
1844
- let context = await resolveDataContext(), envelope = { repository, ...input }, changing = "operation" in input && ["changes.validate", "changes.apply"].includes(String(input.operation));
1814
+ let context = await resolveDataContext(), envelope = { repository, ...input }, changing = "operation" in input && ["changes.validate", "changes.apply", "changes.publish"].includes(String(input.operation));
1845
1815
  if (checkDataRequestSize(envelope, "local" in context && changing ? LOCAL_DATA_CHANGE_REQUEST_LIMIT : DATA_REQUEST_LIMIT), "local" in context) return await context.local("data/query", envelope);
1846
1816
  try {
1847
1817
  let response2 = await fetch(context.url, {
@@ -1876,7 +1846,7 @@ var genericData = {
1876
1846
  search: async (query, options) => send3({ operation: "records.search", ...captureRecordsSearchInput(query, options) })
1877
1847
  },
1878
1848
  changes() {
1879
- let updates = [], creates = [], deletes = [], applyId, pending, confirmed, assertMutable = () => {
1849
+ let updates = [], creates = [], deletes = [], applyId, method, pending, confirmed, assertMutable = () => {
1880
1850
  if (applyId) throw new DataOperationError("invalid_change", !1, "unapplied");
1881
1851
  }, snapshot = (nextUpdates = updates, nextCreates = creates, nextDeletes = deletes) => {
1882
1852
  let { updates: updates2, creates: creates2, deletes: deletes2 } = captureDataChanges(nextUpdates, nextCreates, nextDeletes), input = { updates: updates2, ...creates2.length ? { creates: creates2 } : {}, ...deletes2.length ? { deletes: deletes2 } : {} };
@@ -1886,6 +1856,29 @@ var genericData = {
1886
1856
  ...input,
1887
1857
  applyId: applyId ?? "00000000-0000-4000-8000-000000000000"
1888
1858
  }, LOCAL_DATA_CHANGE_REQUEST_LIMIT), input;
1859
+ }, write = (operation2) => {
1860
+ if (method && method !== operation2) return Promise.reject(new DataOperationError("invalid_change", !1, "unapplied"));
1861
+ if (confirmed) return Promise.resolve(structuredClone(confirmed));
1862
+ if (!pending) {
1863
+ let captured;
1864
+ try {
1865
+ captured = snapshot();
1866
+ } catch (error) {
1867
+ return Promise.reject(error);
1868
+ }
1869
+ method = operation2, applyId ??= routineTransport()?.key("data") ?? crypto.randomUUID(), pending = send3({ operation: operation2, ...captured, applyId }).then((result2) => (confirmed = structuredClone(result2), result2)).catch((error) => {
1870
+ throw error instanceof DataOperationError ? explainDataValidation(new DataOperationError(
1871
+ error.code,
1872
+ error.retryable,
1873
+ error.effect ?? (["unavailable", "apply_pending"].includes(error.code) ? "uncertain" : "unapplied"),
1874
+ error.component,
1875
+ error.detail
1876
+ ), error.message, error.detail) : new DataOperationError("unavailable", !0, "uncertain");
1877
+ }).finally(() => {
1878
+ pending = void 0;
1879
+ });
1880
+ }
1881
+ return pending.then((result2) => structuredClone(result2));
1889
1882
  };
1890
1883
  return {
1891
1884
  create(record4) {
@@ -1906,29 +1899,8 @@ var genericData = {
1906
1899
  async validate() {
1907
1900
  await send3({ operation: "changes.validate", ...snapshot() });
1908
1901
  },
1909
- apply() {
1910
- if (confirmed) return Promise.resolve(structuredClone(confirmed));
1911
- if (!pending) {
1912
- let captured;
1913
- try {
1914
- captured = snapshot();
1915
- } catch (error) {
1916
- return Promise.reject(error);
1917
- }
1918
- applyId ??= routineTransport()?.key("data") ?? crypto.randomUUID(), pending = send3({ operation: "changes.apply", ...captured, applyId }).then((result2) => (confirmed = structuredClone(result2), result2)).catch((error) => {
1919
- throw error instanceof DataOperationError ? explainDataValidation(new DataOperationError(
1920
- error.code,
1921
- error.retryable,
1922
- error.effect ?? (["unavailable", "apply_pending"].includes(error.code) ? "uncertain" : "unapplied"),
1923
- error.component,
1924
- error.detail
1925
- ), error.message, error.detail) : new DataOperationError("unavailable", !0, "uncertain");
1926
- }).finally(() => {
1927
- pending = void 0;
1928
- });
1929
- }
1930
- return pending.then((result2) => structuredClone(result2));
1931
- }
1902
+ apply: () => write("changes.apply"),
1903
+ publish: () => write("changes.publish")
1932
1904
  };
1933
1905
  }
1934
1906
  };
@@ -2509,7 +2481,7 @@ function keys2(v, allowed, required = allowed) {
2509
2481
  function text3(v) {
2510
2482
  return typeof v == "string" && v.length > 0 && v.length <= 1024;
2511
2483
  }
2512
- function fields3(v, nonempty = !1) {
2484
+ function fields2(v, nonempty = !1) {
2513
2485
  let result2 = object3(v);
2514
2486
  (nonempty && !Object.keys(result2).length || Object.keys(result2).some((k) => !text3(k))) && fail2("Invalid Airtable fields");
2515
2487
  try {
@@ -2520,7 +2492,7 @@ function fields3(v, nonempty = !1) {
2520
2492
  }
2521
2493
  function record2(v) {
2522
2494
  let r = object3(v);
2523
- return (!recordId(r.id) || r.createdTime !== void 0 && (typeof r.createdTime != "string" || !Number.isFinite(Date.parse(r.createdTime)))) && fail2("Malformed Airtable record"), { id: r.id, ...r.createdTime === void 0 ? {} : { createdTime: r.createdTime }, fields: fields3(r.fields) };
2495
+ return (!recordId(r.id) || r.createdTime !== void 0 && (typeof r.createdTime != "string" || !Number.isFinite(Date.parse(r.createdTime)))) && fail2("Malformed Airtable record"), { id: r.id, ...r.createdTime === void 0 ? {} : { createdTime: r.createdTime }, fields: fields2(r.fields) };
2524
2496
  }
2525
2497
  function equal(a, b) {
2526
2498
  if (a === b) return !0;
@@ -2636,10 +2608,10 @@ async function executeAirtableOperation(authority2, operation2, raw, options = {
2636
2608
  mutation || fail2("Unsupported Airtable operation"), keys2(input, ["table", "records"]), (!Array.isArray(input.records) || !input.records.length || input.records.length > 10) && fail2("Invalid Airtable batch");
2637
2609
  let kind = operation2.slice(8), ids = /* @__PURE__ */ new Set(), records = input.records.map((value) => {
2638
2610
  let r = object3(value);
2639
- if (keys2(r, kind === "create" ? ["fields"] : kind === "update" ? ["id", "expected", "set"] : ["id", "expected"]), kind === "create") return { fields: fields3(r.fields, !0) };
2611
+ if (keys2(r, kind === "create" ? ["fields"] : kind === "update" ? ["id", "expected", "set"] : ["id", "expected"]), kind === "create") return { fields: fields2(r.fields, !0) };
2640
2612
  (!recordId(r.id) || ids.has(r.id)) && fail2("Invalid Airtable batch record ID"), ids.add(r.id);
2641
- let set = kind === "update" ? fields3(r.set, !0) : void 0;
2642
- return set && Object.values(set).some((value2) => value2 === null) && fail2("Airtable guard null cannot be an update value"), { id: r.id, expected: fields3(r.expected), ...set ? { set } : {} };
2613
+ let set = kind === "update" ? fields2(r.set, !0) : void 0;
2614
+ return set && Object.values(set).some((value2) => value2 === null) && fail2("Airtable guard null cannot be an update value"), { id: r.id, expected: fields2(r.expected), ...set ? { set } : {} };
2643
2615
  });
2644
2616
  for (let r of records) {
2645
2617
  if (!("id" in r)) continue;
@@ -2891,37 +2863,49 @@ var source = {
2891
2863
  }
2892
2864
  };
2893
2865
 
2866
+ function parseInboxRecordRefs(value) {
2867
+ let refs = serializable(value);
2868
+ if (!Array.isArray(refs) || !refs.length || refs.length > 100) throw new Error("Invalid Record read");
2869
+ let result2 = refs.map(validateQualifiedRecordRef);
2870
+ if (new Set(result2.map(recordKey)).size !== result2.length) throw new Error("Duplicate Record reference");
2871
+ return result2;
2872
+ }
2873
+ var recordKey = ({ repository, ref }) => JSON.stringify([repository, ref]);
2874
+ function parseInboxRecords(value) {
2875
+ let result2 = serializable(value);
2876
+ if (!result2 || Object.keys(result2).join() !== "records" || !Array.isArray(result2.records) || result2.records.length > 100) throw new Error("Invalid Record result");
2877
+ for (let entry of result2.records)
2878
+ 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"))
2879
+ throw new Error("Invalid current Record");
2880
+ if (new Set(result2.records.map(recordKey)).size !== result2.records.length) throw new Error("Duplicate current Record");
2881
+ return result2;
2882
+ }
2883
+
2894
2884
  var InboxOperationError = class extends Error {
2895
- constructor(status, reason, requirementsRepository) {
2896
- super(reason === "records_need_attention" ? "Records need to be pushed or reviewed." : reason === "records_unavailable" ? "Records temporarily unavailable. Try again shortly." : reason === "handler_unavailable" ? "Deploy the routine that owns this question\u2019s response handler." : reason === "conflict" ? "This question already has an accepted answer" : reason === "unavailable" ? "Inbox request unavailable. Retry the same action." : reason === "invalid_input" ? "Invalid Inbox request" : "Inbox access unavailable");
2885
+ constructor(status, reason) {
2886
+ super(reason === "handler_unavailable" ? "Deploy the routine that owns this question\u2019s response handler." : reason === "conflict" ? "This question already has an accepted answer" : reason === "unavailable" ? "Inbox request unavailable. Retry the same action." : reason === "invalid_input" ? "Invalid Inbox request" : "Inbox access unavailable");
2897
2887
  this.status = status;
2898
2888
  this.reason = reason;
2899
- this.requirementsRepository = requirementsRepository;
2900
2889
  }
2901
2890
  status;
2902
2891
  reason;
2903
- requirementsRepository;
2904
2892
  };
2905
2893
  function parseQuestionAvailability(value, available = !1) {
2906
2894
  let state = object4(value);
2907
- return keys3(state, ["unavailableReason", "requirementsRepository"], []), "unavailableReason" in state ? (assert(!available && typeof state.unavailableReason == "string" && ["handler_unavailable", "records_need_attention", "records_unavailable"].includes(String(state.unavailableReason))), state.unavailableReason === "records_need_attention" ? assert(validDataRepositoryName(state.requirementsRepository)) : assert(!("requirementsRepository" in state)), {
2908
- unavailableReason: state.unavailableReason,
2909
- ...state.unavailableReason === "records_need_attention" ? { requirementsRepository: state.requirementsRepository } : {}
2910
- }) : (assert(!("requirementsRepository" in state)), {});
2895
+ return keys3(state, ["unavailableReason"], []), "unavailableReason" in state ? (assert(!available && state.unavailableReason === "handler_unavailable"), { unavailableReason: state.unavailableReason }) : {};
2911
2896
  }
2912
2897
  function questionAvailability(value, available = !1) {
2913
2898
  return parseQuestionAvailability({
2914
- ..."unavailableReason" in value ? { unavailableReason: value.unavailableReason } : {},
2915
- ..."requirementsRepository" in value ? { requirementsRepository: value.requirementsRepository } : {}
2899
+ ..."unavailableReason" in value ? { unavailableReason: value.unavailableReason } : {}
2916
2900
  }, available);
2917
2901
  }
2918
2902
  function parseInboxUnavailableFailure(value, status) {
2919
2903
  try {
2920
2904
  if (status !== 503) return;
2921
2905
  let envelope = object4(value);
2922
- keys3(envelope, ["error", "unavailableReason", "requirementsRepository"], ["error", "unavailableReason"]), assert(text4(envelope.error));
2906
+ keys3(envelope, ["error", "unavailableReason"], ["error", "unavailableReason"]), assert(text4(envelope.error));
2923
2907
  let state = questionAvailability(envelope);
2924
- return new InboxOperationError(503, state.unavailableReason, state.requirementsRepository);
2908
+ return new InboxOperationError(503, state.unavailableReason);
2925
2909
  } catch {
2926
2910
  return;
2927
2911
  }
@@ -2935,6 +2919,7 @@ var operations = {
2935
2919
  "items.list": [],
2936
2920
  "questions.list": [],
2937
2921
  "items.read": ["itemId"],
2922
+ "items.readRecords": ["itemId", "records"],
2938
2923
  "items.see": ["itemId"],
2939
2924
  "items.markDigestRead": ["itemId"],
2940
2925
  "items.rename": ["itemId", "revision", "title"],
@@ -3031,48 +3016,6 @@ function responseDefinition(value) {
3031
3016
  });
3032
3017
  assert(suggestions.length <= 8 && new Set(refs).size === refs.length);
3033
3018
  }
3034
- function inboxFile(value) {
3035
- validateInboxFile(value);
3036
- }
3037
- function fields4(value) {
3038
- let labels = array2(value).map((value2) => {
3039
- let field = object4(value2);
3040
- return keys3(field, ["label", "value"]), assert(text4(field.label) && text4(field.value)), field.label;
3041
- });
3042
- assert(new Set(labels).size === labels.length);
3043
- }
3044
- function block(value) {
3045
- let entry = object4(value);
3046
- if (entry.kind === "rich-text") {
3047
- keys3(entry, ["kind", "markdown"]), assert(text4(entry.markdown));
3048
- return;
3049
- }
3050
- if (entry.kind === "asks") {
3051
- keys3(entry, ["kind", "problem", "asks"]);
3052
- let asks = array2(entry.asks);
3053
- assert(text4(entry.problem) && asks.length > 0 && asks.every(id2) && new Set(asks).size === asks.length);
3054
- return;
3055
- }
3056
- if (assert(["record", "records", "files"].includes(String(entry.kind))), keys3(
3057
- entry,
3058
- ["kind", "label", "initiallyExpanded", ...entry.kind === "record" ? ["record", "view"] : entry.kind === "records" ? ["records", "view"] : ["files"]],
3059
- ["kind", "label", entry.kind === "record" ? "record" : entry.kind === "records" ? "records" : "files"]
3060
- ), assert(text4(entry.label) && (!("initiallyExpanded" in entry) || typeof entry.initiallyExpanded == "boolean") && (!("view" in entry) || text4(entry.view) && entry.view === entry.view.trim())), entry.kind === "record") {
3061
- let record4 = object4(entry.record);
3062
- keys3(record4, ["ref", "title", "fields"]), assert(text4(record4.ref) && record4.ref === record4.ref.trim() && text4(record4.title)), fields4(record4.fields);
3063
- return;
3064
- }
3065
- if (entry.kind === "records") {
3066
- let records = array2(entry.records), refs = records.map((value2) => {
3067
- let record4 = object4(value2);
3068
- return keys3(record4, ["ref", "title", "description", "facts", "view"], ["ref", "title"]), assert(text4(record4.ref) && record4.ref === record4.ref.trim() && text4(record4.title)), "description" in record4 && assert(text4(record4.description)), "facts" in record4 && fields4(record4.facts), "view" in record4 && assert(text4(record4.view) && record4.view === record4.view.trim()), record4.ref;
3069
- });
3070
- assert(records.length > 0 && new Set(refs).size === refs.length);
3071
- return;
3072
- }
3073
- let files3 = array2(entry.files);
3074
- files3.forEach(inboxFile), assert(files3.length > 0 && new Set(files3.map((value2) => object4(value2).id)).size === files3.length);
3075
- }
3076
3019
  function response(value) {
3077
3020
  let answer = object4(value);
3078
3021
  return assert(Object.keys(answer).every((key) => ["selection", "note"].includes(key))), typeof answer.selection == "string" ? assert(text4(answer.selection) && answer.selection === answer.selection.trim()) : recordReference(answer.selection), Object.hasOwn(answer, "note") && assert(text4(answer.note)), answer;
@@ -3082,9 +3025,9 @@ function parseInboxRequest(value) {
3082
3025
  let envelope = object4(value);
3083
3026
  assert(Object.keys(envelope).sort().join(",") === "input,operation"), assert(typeof envelope.operation == "string" && Object.hasOwn(operations, envelope.operation));
3084
3027
  let operation2 = envelope.operation, input = { ...object4(envelope.input) }, required = operations[operation2];
3085
- assert(required.every((key) => Object.hasOwn(input, key)) && Object.keys(input).every((key) => required.includes(key) || operation2 === "questions.searchRecords" && key === "selected" || (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)));
3028
+ assert(required.every((key) => Object.hasOwn(input, key)) && Object.keys(input).every((key) => required.includes(key) || operation2 === "questions.answer" && key === "label" || operation2 === "questions.searchRecords" && key === "selected" || (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)));
3086
3029
  for (let key of ["itemId", "personId", "fileId"]) key in input && assert(id2(input[key]));
3087
- 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()), "title" in input && assert(text4(input.title)), "lifecycle" in input && assert(input.lifecycle === "open" || input.lifecycle === "closed"), "query" in input && assert(text4(input.query, !0) && input.query.length <= 256), "selected" in input && recordReference(input.selected), "response" in input && response(input.response), assert(new TextEncoder().encode(JSON.stringify(envelope)).byteLength <= INBOX_INPUT_BYTES), "routines" in input && (input.routines = [...new Set(input.routines)]), { operation: operation2, input };
3030
+ 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()), "title" in input && assert(text4(input.title)), "lifecycle" in input && assert(input.lifecycle === "open" || input.lifecycle === "closed"), "query" in input && assert(text4(input.query, !0) && input.query.length <= 256), "records" in input && (input.records = parseInboxRecordRefs(input.records)), "selected" in input && recordReference(input.selected), "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 };
3088
3031
  } catch {
3089
3032
  throw new InboxOperationError(400, "invalid_input");
3090
3033
  }
@@ -3098,7 +3041,7 @@ function parseInboxCurrent(value) {
3098
3041
  }
3099
3042
  function parseInboxItem(value) {
3100
3043
  let item = object4(json(value));
3101
- 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(object4(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(block), array2(item.views).forEach((value2) => {
3044
+ 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(object4(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) => {
3102
3045
  let view = object4(value2);
3103
3046
  assert(text4(view.id) && text4(view.view) && text4(view.implementation)), json(view.input);
3104
3047
  }), array2(item.people).forEach((value2) => {
@@ -3106,7 +3049,7 @@ function parseInboxItem(value) {
3106
3049
  assert(id2(person.id) && text4(person.name));
3107
3050
  }), array2(item.questions).forEach((value2) => {
3108
3051
  let question2 = object4(value2);
3109
- if (assert(text4(question2.id) && id2(question2.to) && text4(question2.prompt) && (question2.instructions === null || text4(question2.instructions, !0)) && typeof question2.available == "boolean"), questionAvailability(question2, question2.available), assert(!("requirements" in question2) && !("handler" in question2)), responseDefinition(question2.response), assert(array2(question2.allowedResponders).every(id2)), question2.acceptedResponse !== null) {
3052
+ if (assert(text4(question2.id) && id2(question2.to) && text4(question2.prompt) && (question2.instructions === null || text4(question2.instructions, !0)) && typeof question2.available == "boolean"), questionAvailability(question2, question2.available), assert(!("requirements" in question2) && !("requirementsRepository" in question2) && !("handler" in question2)), responseDefinition(question2.response), assert(array2(question2.allowedResponders).every(id2)), question2.acceptedResponse !== null) {
3110
3053
  let accepted = object4(question2.acceptedResponse);
3111
3054
  assert(id2(accepted.id) && id2(accepted.userId) && date(accepted.acceptedAt)), response(accepted.response), accepted.label === null ? delete accepted.label : "label" in accepted && assert(text4(accepted.label)), "acceptanceOrder" in accepted && assert(integer(accepted.acceptanceOrder));
3112
3055
  }
@@ -3139,7 +3082,7 @@ function parseAnswerableQuestion(value) {
3139
3082
  let entry = object4(json(value));
3140
3083
  keys3(
3141
3084
  entry,
3142
- ["itemId", "number", "revision", "title", "inboxUrl", "questionId", "routine", "prompt", "response", "answerable", "tags", "recordRefs", "instructions", "unavailableReason", "requirementsRepository"],
3085
+ ["itemId", "number", "revision", "title", "inboxUrl", "questionId", "routine", "prompt", "response", "answerable", "tags", "recordRefs", "instructions", "unavailableReason"],
3143
3086
  ["itemId", "number", "revision", "title", "inboxUrl", "questionId", "routine", "prompt", "response", "answerable"]
3144
3087
  ), assert(id2(entry.itemId) && integer(entry.number) && integer(entry.revision) && text4(entry.title) && text4(entry.inboxUrl));
3145
3088
  let link = new URL(entry.inboxUrl), slug = link.hostname.slice(0, -13);
@@ -3169,6 +3112,7 @@ function parseInboxResult(operation2, value) {
3169
3112
  let questions = array2(page.questions).map(parseAnswerableQuestion);
3170
3113
  return assert(page.nextBeforeNumber === null || integer(page.nextBeforeNumber)), { questions, nextBeforeNumber: page.nextBeforeNumber };
3171
3114
  }
3115
+ if (operation2 === "items.readRecords") return parseInboxRecords(value);
3172
3116
  if (operation2 === "items.read") return parseInboxItem(value);
3173
3117
  if (operation2 === "items.list") {
3174
3118
  let page = object4(value), items = array2(page.items).map(parseInboxItem);
@@ -3760,8 +3704,7 @@ async function send2(operation2, input, resolved) {
3760
3704
  );
3761
3705
  if (response2.status !== 200) throw unavailable3();
3762
3706
  let parsed = parseInboxResult(operation2, value);
3763
- if (check2(), operation2 === "questions.answer" && typeof envelope.input.response.selection == "object" && !parsed.label?.trim()) throw unavailable3();
3764
- return parsed;
3707
+ return check2(), parsed;
3765
3708
  } catch (error) {
3766
3709
  throw check2(), error instanceof InboxOperationError ? error : unavailable3();
3767
3710
  }
@@ -3819,7 +3762,7 @@ async function send2(operation2, input, resolved) {
3819
3762
  if (check(), operation2 === "current" && parsed.workspace.slug !== context.workspace) throw unavailable3();
3820
3763
  if ("itemId" in envelope.input) {
3821
3764
  let item = operation2 === "items.read" ? parsed : operation2 === "items.rename" || operation2 === "items.setLifecycle" || operation2 === "items.addRecipient" ? parsed.item : void 0;
3822
- if (item && (item.id !== envelope.input.itemId || "revision" in envelope.input && item.revision !== envelope.input.revision) || operation2 === "items.addRecipient" && parsed.addedPersonId !== envelope.input.personId || operation2 === "questions.answer" && typeof envelope.input.response.selection == "object" && !parsed.label?.trim()) throw unavailable3();
3765
+ if (item && (item.id !== envelope.input.itemId || "revision" in envelope.input && item.revision !== envelope.input.revision) || operation2 === "items.addRecipient" && parsed.addedPersonId !== envelope.input.personId) throw unavailable3();
3823
3766
  }
3824
3767
  return parsed;
3825
3768
  } catch (error) {
@@ -3855,6 +3798,7 @@ var inbox = {
3855
3798
  beforeNumber = page.nextBeforeNumber;
3856
3799
  } while (!0);
3857
3800
  },
3801
+ readRecords: async (input) => await send2("items.readRecords", input),
3858
3802
  read: async (itemId) => await send2("items.read", { itemId }),
3859
3803
  see: async (itemId) => {
3860
3804
  await send2("items.see", { itemId });
@@ -4761,7 +4705,7 @@ function validStep(step) {
4761
4705
  }
4762
4706
  function validLocalActivity(value) {
4763
4707
  let paths = (value2) => Array.isArray(value2) && value2.every((path) => typeof path == "string" && path.length > 0 && path.length <= 4096 && !path.startsWith("/") && !path.includes("\\") && !path.split("/").some((part) => !part || part === "." || part === "..") && !/[\x00-\x1f\x7f]/.test(path));
4764
- return value && only(value, "data,effects,git") && bounded2(value) && Array.isArray(value.data) && Array.isArray(value.effects) && value.data.every((item) => only(item, "repository,created,updated,deleted,failures,failure") && typeof item.repository == "string" && identifier.test(item.repository) && paths(item.created) && paths(item.updated) && paths(item.deleted) && (item.failures === void 0 || Array.isArray(item.failures) && item.failures.every((code) => typeof code == "string" && dataErrorCodes.has(code))) && (item.failure === void 0 || (() => {
4708
+ return value && only(value, "data,effects,git") && bounded2(value) && Array.isArray(value.data) && Array.isArray(value.effects) && value.data.every((item) => only(item, "repository,created,updated,deleted,failures,failure,publications") && typeof item.repository == "string" && identifier.test(item.repository) && (item.publications === void 0 || Array.isArray(item.publications) && item.publications.every((fact) => only(fact, "state,commit") && ["files", "commit", "published"].includes(fact.state) && (fact.state === "files" ? fact.commit === void 0 : typeof fact.commit == "string" && /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(fact.commit)))) && paths(item.created) && paths(item.updated) && paths(item.deleted) && (item.failures === void 0 || Array.isArray(item.failures) && item.failures.every((code) => typeof code == "string" && dataErrorCodes.has(code))) && (item.failure === void 0 || (() => {
4765
4709
  try {
4766
4710
  return parseDataFailureDetail(item.failure), !0;
4767
4711
  } catch {
@@ -4963,7 +4907,6 @@ export {
4963
4907
  question,
4964
4908
  recordBlock,
4965
4909
  recordsBlock,
4966
- requireRecords,
4967
4910
  resolveAsk,
4968
4911
  respond,
4969
4912
  richTextBlock,