@oddington/sdk 0.1.48 → 0.1.49

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
@@ -1018,6 +1018,23 @@ completed Data writes as ordinary uncommitted files for review, even after later
1018
1018
  failure. Inbox publication has no Record methods;
1019
1019
  managed Response handlers retain their separately injected repository capability.
1020
1020
 
1021
+ Record presentation uses qualified current identities:
1022
+
1023
+ ```ts
1024
+ body: [
1025
+ recordBlock({ label: 'Transaction', record: { repository: 'general', ref: 'transactions/one' } }),
1026
+ recordsBlock({ label: 'Accounts', records: [
1027
+ { repository: 'general', ref: 'accounts/one' },
1028
+ { repository: 'general', ref: 'accounts/two' },
1029
+ ] }),
1030
+ ]
1031
+ ```
1032
+
1033
+ Inbox reads current values and schemas through its authorized member boundary.
1034
+ Blocks cannot supply copied fields, titles, versions or registered common View
1035
+ names. Missing Records stay unavailable without disabling the Ask. Handler write
1036
+ guards remain private handler input; immutable review evidence uses prose or Files.
1037
+
1021
1038
  Hosts publishing as a member supply the existing `request` option:
1022
1039
 
1023
1040
  ```ts
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,8 +1584,8 @@ 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
+ let identity = captureDataDelete(record4), input = mapping(set), { $body, ...fields3 } = input, body = Object.hasOwn(input, "$body");
1588
+ return body && !validRecordBody($body) || !Object.keys(fields3).length && !body || Object.keys(fields3).some((key) => key.startsWith("$") || ["id", "type"].includes(key)) ? invalidChange() : { ...identity, set: captureValue(fields3), ...body ? { body: $body } : {} };
1623
1589
  }
1624
1590
  function captureIdentities(value, update, allowEmpty = !0) {
1625
1591
  if (!Array.isArray(value) || !allowEmpty && !value.length || value.length > 1e4) return invalidChange();
@@ -1638,7 +1604,7 @@ function captureDataCreate(value) {
1638
1604
  let row = mapping(value);
1639
1605
  if (!validRecordRef(row.$ref) || Object.keys(row).some((key) => key.startsWith("$") && !["$ref", "$filing", "$body"].includes(key)))
1640
1606
  return invalidChange();
1641
- let { $ref: ref, $filing, $body, ...fields5 } = row, body = Object.hasOwn(row, "$body");
1607
+ let { $ref: ref, $filing, $body, ...fields3 } = row, body = Object.hasOwn(row, "$body");
1642
1608
  if (body && !validRecordBody($body)) return invalidChange();
1643
1609
  let filing;
1644
1610
  if ($filing !== void 0) {
@@ -1647,7 +1613,7 @@ function captureDataCreate(value) {
1647
1613
  return invalidChange();
1648
1614
  filing = { ...components };
1649
1615
  }
1650
- return { ref, fields: captureValue(fields5), ...filing ? { filing } : {}, ...body ? { body: $body } : {} };
1616
+ return { ref, fields: captureValue(fields3), ...filing ? { filing } : {}, ...body ? { body: $body } : {} };
1651
1617
  }
1652
1618
  function captureDataChanges(updatesValue, createsValue = [], deletesValue = []) {
1653
1619
  let updates = captureDataUpdates(updatesValue, !0);
@@ -1655,9 +1621,9 @@ function captureDataChanges(updatesValue, createsValue = [], deletesValue = [])
1655
1621
  let creates = createsValue.map((item) => {
1656
1622
  let row = mapping(item);
1657
1623
  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,
1624
+ let fields3 = mapping(row.fields);
1625
+ return Object.keys(fields3).some((key) => key.startsWith("$")) ? invalidChange() : captureDataCreate({
1626
+ ...fields3,
1661
1627
  $ref: row.ref,
1662
1628
  ...Object.hasOwn(row, "filing") ? { $filing: row.filing } : {},
1663
1629
  ...Object.hasOwn(row, "body") ? { $body: row.body } : {}
@@ -1841,7 +1807,7 @@ function recordPagination(queryRecords) {
1841
1807
  var genericData = {
1842
1808
  repository(repository) {
1843
1809
  async function send3(input) {
1844
- let context = await resolveDataContext(), envelope = { repository, ...input }, changing = "operation" in input && ["changes.validate", "changes.apply"].includes(String(input.operation));
1810
+ let context = await resolveDataContext(), envelope = { repository, ...input }, changing = "operation" in input && ["changes.validate", "changes.apply", "changes.publish"].includes(String(input.operation));
1845
1811
  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
1812
  try {
1847
1813
  let response2 = await fetch(context.url, {
@@ -1876,7 +1842,7 @@ var genericData = {
1876
1842
  search: async (query, options) => send3({ operation: "records.search", ...captureRecordsSearchInput(query, options) })
1877
1843
  },
1878
1844
  changes() {
1879
- let updates = [], creates = [], deletes = [], applyId, pending, confirmed, assertMutable = () => {
1845
+ let updates = [], creates = [], deletes = [], applyId, method, pending, confirmed, assertMutable = () => {
1880
1846
  if (applyId) throw new DataOperationError("invalid_change", !1, "unapplied");
1881
1847
  }, snapshot = (nextUpdates = updates, nextCreates = creates, nextDeletes = deletes) => {
1882
1848
  let { updates: updates2, creates: creates2, deletes: deletes2 } = captureDataChanges(nextUpdates, nextCreates, nextDeletes), input = { updates: updates2, ...creates2.length ? { creates: creates2 } : {}, ...deletes2.length ? { deletes: deletes2 } : {} };
@@ -1886,6 +1852,29 @@ var genericData = {
1886
1852
  ...input,
1887
1853
  applyId: applyId ?? "00000000-0000-4000-8000-000000000000"
1888
1854
  }, LOCAL_DATA_CHANGE_REQUEST_LIMIT), input;
1855
+ }, write = (operation2) => {
1856
+ if (method && method !== operation2) return Promise.reject(new DataOperationError("invalid_change", !1, "unapplied"));
1857
+ if (confirmed) return Promise.resolve(structuredClone(confirmed));
1858
+ if (!pending) {
1859
+ let captured;
1860
+ try {
1861
+ captured = snapshot();
1862
+ } catch (error) {
1863
+ return Promise.reject(error);
1864
+ }
1865
+ method = operation2, applyId ??= routineTransport()?.key("data") ?? crypto.randomUUID(), pending = send3({ operation: operation2, ...captured, applyId }).then((result2) => (confirmed = structuredClone(result2), result2)).catch((error) => {
1866
+ throw error instanceof DataOperationError ? explainDataValidation(new DataOperationError(
1867
+ error.code,
1868
+ error.retryable,
1869
+ error.effect ?? (["unavailable", "apply_pending"].includes(error.code) ? "uncertain" : "unapplied"),
1870
+ error.component,
1871
+ error.detail
1872
+ ), error.message, error.detail) : new DataOperationError("unavailable", !0, "uncertain");
1873
+ }).finally(() => {
1874
+ pending = void 0;
1875
+ });
1876
+ }
1877
+ return pending.then((result2) => structuredClone(result2));
1889
1878
  };
1890
1879
  return {
1891
1880
  create(record4) {
@@ -1906,29 +1895,8 @@ var genericData = {
1906
1895
  async validate() {
1907
1896
  await send3({ operation: "changes.validate", ...snapshot() });
1908
1897
  },
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
- }
1898
+ apply: () => write("changes.apply"),
1899
+ publish: () => write("changes.publish")
1932
1900
  };
1933
1901
  }
1934
1902
  };
@@ -2509,7 +2477,7 @@ function keys2(v, allowed, required = allowed) {
2509
2477
  function text3(v) {
2510
2478
  return typeof v == "string" && v.length > 0 && v.length <= 1024;
2511
2479
  }
2512
- function fields3(v, nonempty = !1) {
2480
+ function fields2(v, nonempty = !1) {
2513
2481
  let result2 = object3(v);
2514
2482
  (nonempty && !Object.keys(result2).length || Object.keys(result2).some((k) => !text3(k))) && fail2("Invalid Airtable fields");
2515
2483
  try {
@@ -2520,7 +2488,7 @@ function fields3(v, nonempty = !1) {
2520
2488
  }
2521
2489
  function record2(v) {
2522
2490
  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) };
2491
+ 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
2492
  }
2525
2493
  function equal(a, b) {
2526
2494
  if (a === b) return !0;
@@ -2636,10 +2604,10 @@ async function executeAirtableOperation(authority2, operation2, raw, options = {
2636
2604
  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
2605
  let kind = operation2.slice(8), ids = /* @__PURE__ */ new Set(), records = input.records.map((value) => {
2638
2606
  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) };
2607
+ if (keys2(r, kind === "create" ? ["fields"] : kind === "update" ? ["id", "expected", "set"] : ["id", "expected"]), kind === "create") return { fields: fields2(r.fields, !0) };
2640
2608
  (!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 } : {} };
2609
+ let set = kind === "update" ? fields2(r.set, !0) : void 0;
2610
+ 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
2611
  });
2644
2612
  for (let r of records) {
2645
2613
  if (!("id" in r)) continue;
@@ -2891,37 +2859,49 @@ var source = {
2891
2859
  }
2892
2860
  };
2893
2861
 
2862
+ function parseInboxRecordRefs(value) {
2863
+ let refs = serializable(value);
2864
+ if (!Array.isArray(refs) || !refs.length || refs.length > 100) throw new Error("Invalid Record read");
2865
+ let result2 = refs.map(validateQualifiedRecordRef);
2866
+ if (new Set(result2.map(recordKey)).size !== result2.length) throw new Error("Duplicate Record reference");
2867
+ return result2;
2868
+ }
2869
+ var recordKey = ({ repository, ref }) => JSON.stringify([repository, ref]);
2870
+ function parseInboxRecords(value) {
2871
+ let result2 = serializable(value);
2872
+ if (!result2 || Object.keys(result2).join() !== "records" || !Array.isArray(result2.records) || result2.records.length > 100) throw new Error("Invalid Record result");
2873
+ for (let entry of result2.records)
2874
+ 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"))
2875
+ throw new Error("Invalid current Record");
2876
+ if (new Set(result2.records.map(recordKey)).size !== result2.records.length) throw new Error("Duplicate current Record");
2877
+ return result2;
2878
+ }
2879
+
2894
2880
  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");
2881
+ constructor(status, reason) {
2882
+ 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
2883
  this.status = status;
2898
2884
  this.reason = reason;
2899
- this.requirementsRepository = requirementsRepository;
2900
2885
  }
2901
2886
  status;
2902
2887
  reason;
2903
- requirementsRepository;
2904
2888
  };
2905
2889
  function parseQuestionAvailability(value, available = !1) {
2906
2890
  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)), {});
2891
+ return keys3(state, ["unavailableReason"], []), "unavailableReason" in state ? (assert(!available && state.unavailableReason === "handler_unavailable"), { unavailableReason: state.unavailableReason }) : {};
2911
2892
  }
2912
2893
  function questionAvailability(value, available = !1) {
2913
2894
  return parseQuestionAvailability({
2914
- ..."unavailableReason" in value ? { unavailableReason: value.unavailableReason } : {},
2915
- ..."requirementsRepository" in value ? { requirementsRepository: value.requirementsRepository } : {}
2895
+ ..."unavailableReason" in value ? { unavailableReason: value.unavailableReason } : {}
2916
2896
  }, available);
2917
2897
  }
2918
2898
  function parseInboxUnavailableFailure(value, status) {
2919
2899
  try {
2920
2900
  if (status !== 503) return;
2921
2901
  let envelope = object4(value);
2922
- keys3(envelope, ["error", "unavailableReason", "requirementsRepository"], ["error", "unavailableReason"]), assert(text4(envelope.error));
2902
+ keys3(envelope, ["error", "unavailableReason"], ["error", "unavailableReason"]), assert(text4(envelope.error));
2923
2903
  let state = questionAvailability(envelope);
2924
- return new InboxOperationError(503, state.unavailableReason, state.requirementsRepository);
2904
+ return new InboxOperationError(503, state.unavailableReason);
2925
2905
  } catch {
2926
2906
  return;
2927
2907
  }
@@ -2935,6 +2915,7 @@ var operations = {
2935
2915
  "items.list": [],
2936
2916
  "questions.list": [],
2937
2917
  "items.read": ["itemId"],
2918
+ "items.readRecords": ["itemId", "records"],
2938
2919
  "items.see": ["itemId"],
2939
2920
  "items.markDigestRead": ["itemId"],
2940
2921
  "items.rename": ["itemId", "revision", "title"],
@@ -3031,48 +3012,6 @@ function responseDefinition(value) {
3031
3012
  });
3032
3013
  assert(suggestions.length <= 8 && new Set(refs).size === refs.length);
3033
3014
  }
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
3015
  function response(value) {
3077
3016
  let answer = object4(value);
3078
3017
  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 +3021,9 @@ function parseInboxRequest(value) {
3082
3021
  let envelope = object4(value);
3083
3022
  assert(Object.keys(envelope).sort().join(",") === "input,operation"), assert(typeof envelope.operation == "string" && Object.hasOwn(operations, envelope.operation));
3084
3023
  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)));
3024
+ 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
3025
  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 };
3026
+ 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
3027
  } catch {
3089
3028
  throw new InboxOperationError(400, "invalid_input");
3090
3029
  }
@@ -3098,7 +3037,7 @@ function parseInboxCurrent(value) {
3098
3037
  }
3099
3038
  function parseInboxItem(value) {
3100
3039
  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) => {
3040
+ 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
3041
  let view = object4(value2);
3103
3042
  assert(text4(view.id) && text4(view.view) && text4(view.implementation)), json(view.input);
3104
3043
  }), array2(item.people).forEach((value2) => {
@@ -3106,7 +3045,7 @@ function parseInboxItem(value) {
3106
3045
  assert(id2(person.id) && text4(person.name));
3107
3046
  }), array2(item.questions).forEach((value2) => {
3108
3047
  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) {
3048
+ 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
3049
  let accepted = object4(question2.acceptedResponse);
3111
3050
  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
3051
  }
@@ -3139,7 +3078,7 @@ function parseAnswerableQuestion(value) {
3139
3078
  let entry = object4(json(value));
3140
3079
  keys3(
3141
3080
  entry,
3142
- ["itemId", "number", "revision", "title", "inboxUrl", "questionId", "routine", "prompt", "response", "answerable", "tags", "recordRefs", "instructions", "unavailableReason", "requirementsRepository"],
3081
+ ["itemId", "number", "revision", "title", "inboxUrl", "questionId", "routine", "prompt", "response", "answerable", "tags", "recordRefs", "instructions", "unavailableReason"],
3143
3082
  ["itemId", "number", "revision", "title", "inboxUrl", "questionId", "routine", "prompt", "response", "answerable"]
3144
3083
  ), assert(id2(entry.itemId) && integer(entry.number) && integer(entry.revision) && text4(entry.title) && text4(entry.inboxUrl));
3145
3084
  let link = new URL(entry.inboxUrl), slug = link.hostname.slice(0, -13);
@@ -3169,6 +3108,7 @@ function parseInboxResult(operation2, value) {
3169
3108
  let questions = array2(page.questions).map(parseAnswerableQuestion);
3170
3109
  return assert(page.nextBeforeNumber === null || integer(page.nextBeforeNumber)), { questions, nextBeforeNumber: page.nextBeforeNumber };
3171
3110
  }
3111
+ if (operation2 === "items.readRecords") return parseInboxRecords(value);
3172
3112
  if (operation2 === "items.read") return parseInboxItem(value);
3173
3113
  if (operation2 === "items.list") {
3174
3114
  let page = object4(value), items = array2(page.items).map(parseInboxItem);
@@ -3760,8 +3700,7 @@ async function send2(operation2, input, resolved) {
3760
3700
  );
3761
3701
  if (response2.status !== 200) throw unavailable3();
3762
3702
  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;
3703
+ return check2(), parsed;
3765
3704
  } catch (error) {
3766
3705
  throw check2(), error instanceof InboxOperationError ? error : unavailable3();
3767
3706
  }
@@ -3819,7 +3758,7 @@ async function send2(operation2, input, resolved) {
3819
3758
  if (check(), operation2 === "current" && parsed.workspace.slug !== context.workspace) throw unavailable3();
3820
3759
  if ("itemId" in envelope.input) {
3821
3760
  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();
3761
+ 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
3762
  }
3824
3763
  return parsed;
3825
3764
  } catch (error) {
@@ -3855,6 +3794,7 @@ var inbox = {
3855
3794
  beforeNumber = page.nextBeforeNumber;
3856
3795
  } while (!0);
3857
3796
  },
3797
+ readRecords: async (input) => await send2("items.readRecords", input),
3858
3798
  read: async (itemId) => await send2("items.read", { itemId }),
3859
3799
  see: async (itemId) => {
3860
3800
  await send2("items.see", { itemId });
@@ -4761,7 +4701,7 @@ function validStep(step) {
4761
4701
  }
4762
4702
  function validLocalActivity(value) {
4763
4703
  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 || (() => {
4704
+ 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
4705
  try {
4766
4706
  return parseDataFailureDetail(item.failure), !0;
4767
4707
  } catch {
@@ -4963,7 +4903,6 @@ export {
4963
4903
  question,
4964
4904
  recordBlock,
4965
4905
  recordsBlock,
4966
- requireRecords,
4967
4906
  resolveAsk,
4968
4907
  respond,
4969
4908
  richTextBlock,