@crossworks/content-core 0.712.11 → 0.712.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossworks/content-core",
3
- "version": "0.712.11",
3
+ "version": "0.712.21",
4
4
  "description": "Browser-safe content logic — markdown, blocks, pages, tables, formulas — shared by the server and any client. Zero server deps by design: nothing here may reach @mantle/db, node-only APIs, or the network (the jackdaw-repo-split P0 boundary).",
5
5
  "type": "module",
6
6
  "exports": {
@@ -38,7 +38,7 @@
38
38
  "./tree": "./src/tree.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@mantle/client-types": "npm:@crossworks/client-types@0.712.11",
41
+ "@mantle/client-types": "npm:@crossworks/client-types@0.712.21",
42
42
  "marked": "^18.1.2",
43
43
  "mathjs": "15.2.0"
44
44
  },
@@ -656,6 +656,14 @@ export function projectGrantedGroups(raw: unknown): Record<string, string[]> | u
656
656
  return rows.length ? Object.fromEntries(rows) : undefined;
657
657
  }
658
658
 
659
+ /** The keys of the seeded Recall maps (recallMapsSeeded): non-empty
660
+ * strings, each once; anything else is dropped. */
661
+ export function projectSeededKeys(raw: unknown): string[] | undefined {
662
+ if (!Array.isArray(raw)) return undefined;
663
+ const keys = [...new Set(raw.filter((s): s is string => typeof s === 'string' && s !== ''))];
664
+ return keys.length ? keys : undefined;
665
+ }
666
+
659
667
  /** The house style a NEW brain starts with (Settings, Profile). Seeded only when
660
668
  * a profile row is first created, so an owner who edits or clears it keeps
661
669
  * their choice. The dash characters are escapes so the source holds none. */
@@ -209,17 +209,27 @@ export function tableDocFromGrid(input: GridInput): TableDoc {
209
209
  name: c.name?.trim() || 'Column',
210
210
  type: COLUMN_TYPES.includes(c.type as ColumnType) ? (c.type as ColumnType) : 'text',
211
211
  }));
212
- const rows: Row[] = input.rows.map((values) => {
213
- const cells: Record<string, CellValue> = {};
214
- columns.forEach((col, i) => {
215
- const v = coerceCell(values[i] ?? null, storageType(col));
216
- if (v !== null) cells[col.id] = v;
217
- });
218
- return { id: randomUUID(), cells };
219
- });
212
+ const rows: Row[] = input.rows.map((values) => rowFromGrid(columns, values));
220
213
  return { columns, rows, aggregates: {}, views: [] };
221
214
  }
222
215
 
216
+ /** One grid row as a table row, as tableDocFromGrid makes it: a stable id
217
+ * (a random UUID unless the caller gives one), each cell coerced to its
218
+ * column's type. A file database's rows read as
219
+ * they come take this one at a time (packages/content file-database.ts). */
220
+ export function rowFromGrid(
221
+ columns: readonly Column[],
222
+ values: readonly (string | number | boolean | null)[],
223
+ id: string = randomUUID(),
224
+ ): Row {
225
+ const cells: Record<string, CellValue> = {};
226
+ columns.forEach((col, i) => {
227
+ const v = coerceCell(values[i] ?? null, storageType(col));
228
+ if (v !== null) cells[col.id] = v;
229
+ });
230
+ return { id, cells };
231
+ }
232
+
223
233
  /** Coerce an unknown/partial value into a well-formed TableDoc. Tolerant of
224
234
  * legacy / hand-authored shapes — missing arrays become empty, every column
225
235
  * and row gets a stable id, and cells are pruned to known columns. Returns the