@ai-matrx/records 0.97.5 → 0.97.6

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{client-C6_v0Jnq.d.ts → client-B1PjSTav.d.ts} +1 -1
  3. package/dist/{client-BSe721CI.d.cts → client-ijtYioVl.d.cts} +1 -1
  4. package/dist/core/index.cjs +53 -1
  5. package/dist/core/index.cjs.map +1 -1
  6. package/dist/core/index.d.cts +3 -3
  7. package/dist/core/index.d.ts +3 -3
  8. package/dist/core/index.js +53 -1
  9. package/dist/core/index.js.map +1 -1
  10. package/dist/data/index.cjs +53 -1
  11. package/dist/data/index.cjs.map +1 -1
  12. package/dist/data/index.d.cts +2 -2
  13. package/dist/data/index.d.ts +2 -2
  14. package/dist/data/index.js +53 -1
  15. package/dist/data/index.js.map +1 -1
  16. package/dist/{declareTable-B6ps9KX8.d.cts → declareTable-BE423RBb.d.cts} +1 -1
  17. package/dist/{declareTable-C_ZguQb4.d.ts → declareTable-W3aD-9fQ.d.ts} +1 -1
  18. package/dist/{doors-DEvCdeYB.d.cts → doors-Bopr9YVf.d.cts} +52 -5
  19. package/dist/{doors-DnHM_tkC.d.ts → doors-DfHUqP7j.d.ts} +52 -5
  20. package/dist/questions/index.d.cts +2 -2
  21. package/dist/questions/index.d.ts +2 -2
  22. package/dist/react/index.cjs +53 -1
  23. package/dist/react/index.cjs.map +1 -1
  24. package/dist/react/index.d.cts +32 -4
  25. package/dist/react/index.d.ts +32 -4
  26. package/dist/react/index.js +53 -1
  27. package/dist/react/index.js.map +1 -1
  28. package/dist/scopes/index.cjs +53 -1
  29. package/dist/scopes/index.cjs.map +1 -1
  30. package/dist/scopes/index.d.cts +2 -2
  31. package/dist/scopes/index.d.ts +2 -2
  32. package/dist/scopes/index.js +53 -1
  33. package/dist/scopes/index.js.map +1 -1
  34. package/dist/setup/index.cjs +53 -1
  35. package/dist/setup/index.cjs.map +1 -1
  36. package/dist/setup/index.d.cts +2 -2
  37. package/dist/setup/index.d.ts +2 -2
  38. package/dist/setup/index.js +53 -1
  39. package/dist/setup/index.js.map +1 -1
  40. package/dist/typed-table/index.cjs +53 -1
  41. package/dist/typed-table/index.cjs.map +1 -1
  42. package/dist/typed-table/index.d.cts +3 -3
  43. package/dist/typed-table/index.d.ts +3 -3
  44. package/dist/typed-table/index.js +53 -1
  45. package/dist/typed-table/index.js.map +1 -1
  46. package/dist/views/index.d.cts +2 -2
  47. package/dist/views/index.d.ts +2 -2
  48. package/package.json +2 -2
@@ -12388,9 +12388,35 @@ interface ScopePage {
12388
12388
  total: number;
12389
12389
  next_offset: number | null;
12390
12390
  }
12391
- /** A System Context item (`context.system_context_item`), as `custom.context_system_items` answers it. */
12392
- interface SystemContextItem {
12393
- [key: string]: unknown;
12391
+ /** What a System Context item is: a curated fact, an ambient fact of the moment, or a dataset. */
12392
+ type SystemContextItemClass = "curated" | "ambient" | "dataset" | (string & {});
12393
+ /**
12394
+ * A System Context item (`custom.context_system_items`), as a `ContextField` of the
12395
+ * `SYSTEM_CONTEXT_TYPE_ID` pseudo-type, plus its class.
12396
+ */
12397
+ interface SystemContextField extends ContextField {
12398
+ item_class: SystemContextItemClass | null;
12399
+ }
12400
+ /** One column of a table template. */
12401
+ interface TableTemplateField {
12402
+ field_name: string;
12403
+ display_name: string;
12404
+ data_type: string;
12405
+ field_order: number;
12406
+ is_required: boolean;
12407
+ }
12408
+ /**
12409
+ * A table template (a `custom.template` of kind `table`) a scope's dataset field may lock its
12410
+ * table's columns to: the organization's own or a platform one, as `custom.table_templates` answers it.
12411
+ */
12412
+ interface TableTemplate {
12413
+ id: Uuid;
12414
+ organization_id: Uuid | null;
12415
+ name: string;
12416
+ description: string;
12417
+ version: number;
12418
+ is_platform: boolean;
12419
+ fields: TableTemplateField[];
12394
12420
  }
12395
12421
  /** One scope template of the gallery, as `custom.context_templates` answers it. */
12396
12422
  interface ScopeTemplate {
@@ -12491,7 +12517,9 @@ interface ScopeDoors {
12491
12517
  /** Of these scope ids, the ones that are ARCHIVED scopes of this type. */
12492
12518
  archivedScopesOfType(organizationId: Uuid, scopeTypeId: Uuid, wanted: ReadonlySet<Uuid>): Promise<RecordsResult<ArchivedScope[]>>;
12493
12519
  /** The System Context items (not scopes: the platform's own ambient context). */
12494
- systemItems(): Promise<RecordsResult<SystemContextItem[]>>;
12520
+ systemItems(): Promise<RecordsResult<SystemContextField[]>>;
12521
+ /** The table templates an organization's scope dataset fields may use (its own and the platform's). */
12522
+ tableTemplates(organizationId: Uuid): Promise<RecordsResult<TableTemplate[]>>;
12495
12523
  /** The scope templates of the gallery. */
12496
12524
  templates(): Promise<RecordsResult<ScopeTemplate[]>>;
12497
12525
  /** A new scope type in `organizationId`. */
@@ -12388,9 +12388,35 @@ interface ScopePage {
12388
12388
  total: number;
12389
12389
  next_offset: number | null;
12390
12390
  }
12391
- /** A System Context item (`context.system_context_item`), as `custom.context_system_items` answers it. */
12392
- interface SystemContextItem {
12393
- [key: string]: unknown;
12391
+ /** What a System Context item is: a curated fact, an ambient fact of the moment, or a dataset. */
12392
+ type SystemContextItemClass = "curated" | "ambient" | "dataset" | (string & {});
12393
+ /**
12394
+ * A System Context item (`custom.context_system_items`), as a `ContextField` of the
12395
+ * `SYSTEM_CONTEXT_TYPE_ID` pseudo-type, plus its class.
12396
+ */
12397
+ interface SystemContextField extends ContextField {
12398
+ item_class: SystemContextItemClass | null;
12399
+ }
12400
+ /** One column of a table template. */
12401
+ interface TableTemplateField {
12402
+ field_name: string;
12403
+ display_name: string;
12404
+ data_type: string;
12405
+ field_order: number;
12406
+ is_required: boolean;
12407
+ }
12408
+ /**
12409
+ * A table template (a `custom.template` of kind `table`) a scope's dataset field may lock its
12410
+ * table's columns to: the organization's own or a platform one, as `custom.table_templates` answers it.
12411
+ */
12412
+ interface TableTemplate {
12413
+ id: Uuid;
12414
+ organization_id: Uuid | null;
12415
+ name: string;
12416
+ description: string;
12417
+ version: number;
12418
+ is_platform: boolean;
12419
+ fields: TableTemplateField[];
12394
12420
  }
12395
12421
  /** One scope template of the gallery, as `custom.context_templates` answers it. */
12396
12422
  interface ScopeTemplate {
@@ -12491,7 +12517,9 @@ interface ScopeDoors {
12491
12517
  /** Of these scope ids, the ones that are ARCHIVED scopes of this type. */
12492
12518
  archivedScopesOfType(organizationId: Uuid, scopeTypeId: Uuid, wanted: ReadonlySet<Uuid>): Promise<RecordsResult<ArchivedScope[]>>;
12493
12519
  /** The System Context items (not scopes: the platform's own ambient context). */
12494
- systemItems(): Promise<RecordsResult<SystemContextItem[]>>;
12520
+ systemItems(): Promise<RecordsResult<SystemContextField[]>>;
12521
+ /** The table templates an organization's scope dataset fields may use (its own and the platform's). */
12522
+ tableTemplates(organizationId: Uuid): Promise<RecordsResult<TableTemplate[]>>;
12495
12523
  /** The scope templates of the gallery. */
12496
12524
  templates(): Promise<RecordsResult<ScopeTemplate[]>>;
12497
12525
  /** A new scope type in `organizationId`. */
@@ -564,6 +564,9 @@ function rememberedOpCount() {
564
564
  return defaultOpLedger.size;
565
565
  }
566
566
 
567
+ // src/scopes/types.ts
568
+ var SYSTEM_CONTEXT_TYPE_ID = "__system__";
569
+
567
570
  // src/scopes/codec.ts
568
571
  var str = (v, fallback = "") => typeof v === "string" ? v : fallback;
569
572
  var strOrNull = (v) => typeof v === "string" ? v : null;
@@ -735,6 +738,51 @@ var SENSITIVITY_TO_DOOR = {
735
738
  confidential: "restricted",
736
739
  restricted: "privileged"
737
740
  };
741
+ var SENSITIVITY_FROM_DOOR = {
742
+ public: "public",
743
+ internal: "internal",
744
+ restricted: "confidential",
745
+ privileged: "restricted"
746
+ };
747
+ function systemContextFieldFromStore(row, index) {
748
+ const key = str(row.key);
749
+ const kind = str(row.value_type, "string");
750
+ return {
751
+ id: str(row.id),
752
+ scope_type_id: SYSTEM_CONTEXT_TYPE_ID,
753
+ organization_id: "",
754
+ key,
755
+ label: str(row.display_name, key),
756
+ description: str(row.description),
757
+ kind: KINDS.has(kind) ? kind : "string",
758
+ type: "system",
759
+ multi: kind === "array",
760
+ format: null,
761
+ config: {},
762
+ relation_target: null,
763
+ sort: typeof row.sort_order === "number" ? row.sort_order : index,
764
+ context_policy: "include",
765
+ // The system table keeps the old sensitivity words (`restricted`/`privileged`), like the write doors.
766
+ sensitivity: SENSITIVITY_FROM_DOOR[str(row.sensitivity)] ?? "public",
767
+ source: "system",
768
+ status: "active",
769
+ status_note: null,
770
+ category: null,
771
+ tags: [],
772
+ max_items: 0,
773
+ custom_component: null,
774
+ reference_source: null,
775
+ allowed_scope_type_ids: null,
776
+ allowed_reference_types: null,
777
+ review_interval_days: null,
778
+ depends_on: [],
779
+ version: 0,
780
+ created_by: null,
781
+ created_at: "",
782
+ updated_at: "",
783
+ item_class: strOrNull(row.item_class)
784
+ };
785
+ }
738
786
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
739
787
  function referencesOf(row) {
740
788
  const v = row.value;
@@ -1069,7 +1117,11 @@ function createScopeDoors(call) {
1069
1117
  },
1070
1118
  async systemItems() {
1071
1119
  const res = await call("context_system_items", {}, "scopes.systemItems");
1072
- return res.ok ? { ok: true, data: res.data ?? [] } : res;
1120
+ return res.ok ? { ok: true, data: (res.data ?? []).map(systemContextFieldFromStore) } : res;
1121
+ },
1122
+ async tableTemplates(organizationId) {
1123
+ const res = await call("table_templates", { p_org_id: organizationId }, "scopes.tableTemplates");
1124
+ return res.ok ? { ok: true, data: Array.isArray(res.data) ? res.data : [] } : res;
1073
1125
  },
1074
1126
  async templates() {
1075
1127
  const res = await call("context_templates", {}, "scopes.templates");