@ai-matrx/records 0.60.7 → 0.60.9

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.
@@ -2549,6 +2549,18 @@ interface NewFieldSpec {
2549
2549
  * `recordUpsert` finds a record by must carry it.
2550
2550
  */
2551
2551
  unique?: boolean;
2552
+ /**
2553
+ * An EXISTING choice list's Table — the column uses those very option records instead of making a
2554
+ * new list (a drafts table copying its source table's column keeps the same choices). Sent as
2555
+ * `config.options_table_id`.
2556
+ */
2557
+ optionsTableId?: Uuid;
2558
+ /**
2559
+ * Anything else `custom.field_declare` accepts, passed through verbatim and applied LAST (a stored
2560
+ * Field document copied key for key, `format`, `sensitivity`, `via` / `pick` / `agg` / `of`, …).
2561
+ * The store judges every key; a word it does not take is refused by name.
2562
+ */
2563
+ declaration?: Partial<NewFieldDeclaration> & Record<string, unknown>;
2552
2564
  }
2553
2565
  interface NewTableSpec {
2554
2566
  name: string;
@@ -2559,6 +2571,24 @@ interface NewTableSpec {
2559
2571
  /** The Field whose value is the record's title (REC-2). Defaults to the first Field. */
2560
2572
  titleField?: string;
2561
2573
  fields?: NewFieldSpec[];
2574
+ /**
2575
+ * `ensureTable` only: put a NEW table in this existing Home (one the caller may change, in this
2576
+ * organization) instead of making a Home for it. A table that already exists stays where it is.
2577
+ */
2578
+ homeId?: Uuid;
2579
+ /** SC-1 placement: the app (one of its features) keeps this table, not the organization. */
2580
+ keptByTheApp?: boolean;
2581
+ /**
2582
+ * WHICH feature keeps it, one lower-case word (`agent_output`, `context`, …). `ensureTable` finds a
2583
+ * table by slug AND this word: a person's table of the same slug is a different table.
2584
+ */
2585
+ keptFor?: string;
2586
+ /** The content kind whose outputs this table holds. */
2587
+ kind?: string;
2588
+ /** A drafts table: the Table its records are drafts of. */
2589
+ draftsFor?: Uuid;
2590
+ /** A drafts table: that Table's stamp when the drafts table last matched it. */
2591
+ draftsStamp?: string;
2562
2592
  }
2563
2593
  /**
2564
2594
  * What `ensureTable` answers: `declareTable`'s answer, plus whether this call MADE the table and
@@ -2549,6 +2549,18 @@ interface NewFieldSpec {
2549
2549
  * `recordUpsert` finds a record by must carry it.
2550
2550
  */
2551
2551
  unique?: boolean;
2552
+ /**
2553
+ * An EXISTING choice list's Table — the column uses those very option records instead of making a
2554
+ * new list (a drafts table copying its source table's column keeps the same choices). Sent as
2555
+ * `config.options_table_id`.
2556
+ */
2557
+ optionsTableId?: Uuid;
2558
+ /**
2559
+ * Anything else `custom.field_declare` accepts, passed through verbatim and applied LAST (a stored
2560
+ * Field document copied key for key, `format`, `sensitivity`, `via` / `pick` / `agg` / `of`, …).
2561
+ * The store judges every key; a word it does not take is refused by name.
2562
+ */
2563
+ declaration?: Partial<NewFieldDeclaration> & Record<string, unknown>;
2552
2564
  }
2553
2565
  interface NewTableSpec {
2554
2566
  name: string;
@@ -2559,6 +2571,24 @@ interface NewTableSpec {
2559
2571
  /** The Field whose value is the record's title (REC-2). Defaults to the first Field. */
2560
2572
  titleField?: string;
2561
2573
  fields?: NewFieldSpec[];
2574
+ /**
2575
+ * `ensureTable` only: put a NEW table in this existing Home (one the caller may change, in this
2576
+ * organization) instead of making a Home for it. A table that already exists stays where it is.
2577
+ */
2578
+ homeId?: Uuid;
2579
+ /** SC-1 placement: the app (one of its features) keeps this table, not the organization. */
2580
+ keptByTheApp?: boolean;
2581
+ /**
2582
+ * WHICH feature keeps it, one lower-case word (`agent_output`, `context`, …). `ensureTable` finds a
2583
+ * table by slug AND this word: a person's table of the same slug is a different table.
2584
+ */
2585
+ keptFor?: string;
2586
+ /** The content kind whose outputs this table holds. */
2587
+ kind?: string;
2588
+ /** A drafts table: the Table its records are drafts of. */
2589
+ draftsFor?: Uuid;
2590
+ /** A drafts table: that Table's stamp when the drafts table last matched it. */
2591
+ draftsStamp?: string;
2562
2592
  }
2563
2593
  /**
2564
2594
  * What `ensureTable` answers: `declareTable`'s answer, plus whether this call MADE the table and
@@ -44264,7 +44264,9 @@ function fieldDeclarationFor(field) {
44264
44264
  ...field.unit ? { unit: field.unit } : {},
44265
44265
  ...field.kind ? { kind: field.kind } : {},
44266
44266
  ...field.allowedTypes ? { allowed_types: field.allowedTypes } : {},
44267
- ...field.unique ? { rules: [{ kind: "unique" }] } : {}
44267
+ ...field.unique ? { rules: [{ kind: "unique" }] } : {},
44268
+ ...field.optionsTableId ? { config: { ...field.config ?? {}, options_table_id: field.optionsTableId } } : {},
44269
+ ...field.declaration ?? {}
44268
44270
  };
44269
44271
  }
44270
44272
  function tableSpecFor(spec, fields, slug) {
@@ -44284,14 +44286,23 @@ function tableSpecFor(spec, fields, slug) {
44284
44286
  // AGT-1: a table a person made is agent-writable by declaration; the
44285
44287
  // organization turns it off, never this package.
44286
44288
  agent_writable: true,
44287
- default_sort: [{ field: titleField, direction: "asc" }]
44289
+ default_sort: [{ field: titleField, direction: "asc" }],
44290
+ ...spec.keptByTheApp !== void 0 ? { kept_by_the_app: spec.keptByTheApp } : {},
44291
+ ...spec.keptFor ? { kept_for: spec.keptFor } : {},
44292
+ ...spec.kind ? { kind: spec.kind } : {},
44293
+ ...spec.draftsFor ? { drafts_for: spec.draftsFor } : {},
44294
+ ...spec.draftsStamp ? { drafts_stamp: spec.draftsStamp } : {}
44288
44295
  };
44289
44296
  }
44290
44297
  async function ensureTable(client, spec) {
44291
44298
  const fields = spec.fields && spec.fields.length > 0 ? spec.fields : DEFAULT_FIELDS;
44292
44299
  const slug = spec.slug ?? tokenFor(spec.name);
44293
44300
  const ensured = await client.tableEnsure({
44294
- spec: { ...tableSpecFor(spec, fields, slug), fields: fields.map(fieldDeclarationFor) }
44301
+ spec: {
44302
+ ...tableSpecFor(spec, fields, slug),
44303
+ ...spec.homeId ? { home_id: spec.homeId } : {},
44304
+ fields: fields.map(fieldDeclarationFor)
44305
+ }
44295
44306
  });
44296
44307
  if (!ensured.ok) return ensured;
44297
44308
  return {