@ai-matrx/records 0.99.28 → 0.99.30

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 (66) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{client-B7LYr-aE.d.cts → client-B7KEs9hi.d.cts} +10 -0
  3. package/dist/{client-m4soDpHA.d.ts → client-Dthx26hr.d.ts} +10 -0
  4. package/dist/core/index.cjs +76 -10
  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 +76 -10
  9. package/dist/core/index.js.map +1 -1
  10. package/dist/data/index.cjs +12 -1
  11. package/dist/data/index.cjs.map +1 -1
  12. package/dist/data/index.d.cts +1 -1
  13. package/dist/data/index.d.ts +1 -1
  14. package/dist/data/index.js +12 -1
  15. package/dist/data/index.js.map +1 -1
  16. package/dist/{declareTable-D5Zs-SjU.d.ts → declareTable-CvBu5dTJ.d.ts} +1 -1
  17. package/dist/{declareTable-Bnrzv-Bg.d.cts → declareTable-enQs2N0E.d.cts} +1 -1
  18. package/dist/entity/index.cjs +1 -1
  19. package/dist/entity/index.cjs.map +1 -1
  20. package/dist/entity/index.d.cts +3 -3
  21. package/dist/entity/index.d.ts +3 -3
  22. package/dist/entity/index.js +1 -1
  23. package/dist/entity/index.js.map +1 -1
  24. package/dist/entity/react.cjs +1 -1
  25. package/dist/entity/react.cjs.map +1 -1
  26. package/dist/entity/react.js +1 -1
  27. package/dist/entity/react.js.map +1 -1
  28. package/dist/first-page/index.d.cts +2 -0
  29. package/dist/first-page/index.d.ts +2 -0
  30. package/dist/index.cjs +64 -9
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +29 -3
  33. package/dist/index.d.ts +29 -3
  34. package/dist/index.js +64 -9
  35. package/dist/index.js.map +1 -1
  36. package/dist/{port-DWHLj_Sa.d.ts → port-Bk7TG0aE.d.ts} +3 -3
  37. package/dist/{port-BbWB9Pgq.d.cts → port-rqQEGhew.d.cts} +3 -3
  38. package/dist/questions/index.d.cts +1 -1
  39. package/dist/questions/index.d.ts +1 -1
  40. package/dist/react/index.cjs +82 -128
  41. package/dist/react/index.cjs.map +1 -1
  42. package/dist/react/index.d.cts +37 -2
  43. package/dist/react/index.d.ts +37 -2
  44. package/dist/react/index.js +81 -127
  45. package/dist/react/index.js.map +1 -1
  46. package/dist/realtime/index.cjs +1 -1
  47. package/dist/realtime/index.cjs.map +1 -1
  48. package/dist/realtime/index.d.cts +4 -4
  49. package/dist/realtime/index.d.ts +4 -4
  50. package/dist/realtime/index.js +1 -1
  51. package/dist/realtime/index.js.map +1 -1
  52. package/dist/setup/index.cjs +15 -4
  53. package/dist/setup/index.cjs.map +1 -1
  54. package/dist/setup/index.d.cts +3 -3
  55. package/dist/setup/index.d.ts +3 -3
  56. package/dist/setup/index.js +15 -4
  57. package/dist/setup/index.js.map +1 -1
  58. package/dist/typed-table/index.cjs +16 -117
  59. package/dist/typed-table/index.cjs.map +1 -1
  60. package/dist/typed-table/index.d.cts +3 -4
  61. package/dist/typed-table/index.d.ts +3 -4
  62. package/dist/typed-table/index.js +15 -116
  63. package/dist/typed-table/index.js.map +1 -1
  64. package/dist/views/index.d.cts +1 -1
  65. package/dist/views/index.d.ts +1 -1
  66. package/package.json +7 -5
@@ -53,7 +53,6 @@ __export(typed_table_exports, {
53
53
  readersMatch: () => readersMatch,
54
54
  removeAppRow: () => removeAppRow,
55
55
  rowFromDocument: () => rowFromDocument,
56
- sha256Hex: () => sha256Hex,
57
56
  storeTable: () => storeTable,
58
57
  updateTableRow: () => updateTableRow,
59
58
  upsertAppRow: () => upsertAppRow,
@@ -61,6 +60,9 @@ __export(typed_table_exports, {
61
60
  });
62
61
  module.exports = __toCommonJS(typed_table_exports);
63
62
 
63
+ // src/typed-table/define.ts
64
+ var import_sha256 = require("@ai-matrx/kit/sha256");
65
+
64
66
  // src/typed-table/graduate.ts
65
67
  var import_uuid = require("@ai-matrx/kit/uuid");
66
68
  var TO_CUSTOM_FIELDS = "custom_fields";
@@ -326,7 +328,7 @@ function defineTypedTable(input) {
326
328
  fields: { ...input.fields },
327
329
  specs,
328
330
  canonicalSpec,
329
- specHash: sha256Hex(canonicalSpec),
331
+ specHash: (0, import_sha256.sha256Hex)(canonicalSpec),
330
332
  graduatedTo: input.graduatedTo ? { token: input.graduatedTo.token, map: { ...input.graduatedTo.map } } : null,
331
333
  confidential: input.confidential ? {
332
334
  readers: input.confidential.readers.map((r) => ({ field: r.field, level: r.level, ...r.when ? { when: { ...r.when } } : {} })),
@@ -335,120 +337,6 @@ function defineTypedTable(input) {
335
337
  } : null
336
338
  });
337
339
  }
338
- var K256 = new Uint32Array([
339
- 1116352408,
340
- 1899447441,
341
- 3049323471,
342
- 3921009573,
343
- 961987163,
344
- 1508970993,
345
- 2453635748,
346
- 2870763221,
347
- 3624381080,
348
- 310598401,
349
- 607225278,
350
- 1426881987,
351
- 1925078388,
352
- 2162078206,
353
- 2614888103,
354
- 3248222580,
355
- 3835390401,
356
- 4022224774,
357
- 264347078,
358
- 604807628,
359
- 770255983,
360
- 1249150122,
361
- 1555081692,
362
- 1996064986,
363
- 2554220882,
364
- 2821834349,
365
- 2952996808,
366
- 3210313671,
367
- 3336571891,
368
- 3584528711,
369
- 113926993,
370
- 338241895,
371
- 666307205,
372
- 773529912,
373
- 1294757372,
374
- 1396182291,
375
- 1695183700,
376
- 1986661051,
377
- 2177026350,
378
- 2456956037,
379
- 2730485921,
380
- 2820302411,
381
- 3259730800,
382
- 3345764771,
383
- 3516065817,
384
- 3600352804,
385
- 4094571909,
386
- 275423344,
387
- 430227734,
388
- 506948616,
389
- 659060556,
390
- 883997877,
391
- 958139571,
392
- 1322822218,
393
- 1537002063,
394
- 1747873779,
395
- 1955562222,
396
- 2024104815,
397
- 2227730452,
398
- 2361852424,
399
- 2428436474,
400
- 2756734187,
401
- 3204031479,
402
- 3329325298
403
- ]);
404
- function sha256Hex(text2) {
405
- const bytes = new TextEncoder().encode(text2);
406
- const bitLength = bytes.length * 8;
407
- const padded = new Uint8Array(bytes.length + 9 + 63 >> 6 << 6);
408
- padded.set(bytes);
409
- padded[bytes.length] = 128;
410
- const view = new DataView(padded.buffer);
411
- view.setUint32(padded.length - 8, Math.floor(bitLength / 4294967296));
412
- view.setUint32(padded.length - 4, bitLength >>> 0);
413
- const h = new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
414
- const w = new Uint32Array(64);
415
- const rotr = (x, n) => x >>> n | x << 32 - n;
416
- for (let off = 0; off < padded.length; off += 64) {
417
- for (let i = 0; i < 16; i++) w[i] = view.getUint32(off + i * 4);
418
- for (let i = 16; i < 64; i++) {
419
- const a2 = w[i - 15], b2 = w[i - 2];
420
- const s0 = rotr(a2, 7) ^ rotr(a2, 18) ^ a2 >>> 3;
421
- const s1 = rotr(b2, 17) ^ rotr(b2, 19) ^ b2 >>> 10;
422
- w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
423
- }
424
- let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f2 = h[5], g = h[6], hh = h[7];
425
- for (let i = 0; i < 64; i++) {
426
- const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
427
- const ch = e & f2 ^ ~e & g;
428
- const t1 = hh + S1 + ch + K256[i] + w[i] >>> 0;
429
- const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
430
- const maj = a & b ^ a & c ^ b & c;
431
- const t2 = S0 + maj >>> 0;
432
- hh = g;
433
- g = f2;
434
- f2 = e;
435
- e = d + t1 >>> 0;
436
- d = c;
437
- c = b;
438
- b = a;
439
- a = t1 + t2 >>> 0;
440
- }
441
- h[0] = h[0] + a >>> 0;
442
- h[1] = h[1] + b >>> 0;
443
- h[2] = h[2] + c >>> 0;
444
- h[3] = h[3] + d >>> 0;
445
- h[4] = h[4] + e >>> 0;
446
- h[5] = h[5] + f2 >>> 0;
447
- h[6] = h[6] + g >>> 0;
448
- h[7] = h[7] + hh >>> 0;
449
- }
450
- return Array.from(h, (x) => x.toString(16).padStart(8, "0")).join("");
451
- }
452
340
 
453
341
  // src/core/primedBundle.ts
454
342
  var PRIMED_TTL_MS = 15e3;
@@ -4230,6 +4118,15 @@ function createRecordsClient(given) {
4230
4118
  }
4231
4119
  return result;
4232
4120
  },
4121
+ async recordReparent({ record_id, parent_id }) {
4122
+ const result = await callDoor(
4123
+ DOORS.recordReparent,
4124
+ { p_organization_id: org, p_record_id: record_id, p_parent_id: parent_id },
4125
+ "recordReparent"
4126
+ );
4127
+ if (result.ok) announceRecordChanged(record_id);
4128
+ return result;
4129
+ },
4233
4130
  async recordRestore({ record_id }) {
4234
4131
  const result = await callDoor(
4235
4132
  DOORS.recordRestore,
@@ -4777,7 +4674,9 @@ function createRecordsClient(given) {
4777
4674
  }
4778
4675
  const tables = read.map((row) => {
4779
4676
  const { document } = unfold(row.document);
4780
- return { ...document, id: row.id, organization_id: org };
4677
+ const doc = document;
4678
+ const home = typeof doc.home_id === "string" ? doc.home_id : typeof doc.parent_id === "string" ? doc.parent_id : null;
4679
+ return { ...doc, home_id: home, id: row.id, organization_id: org };
4781
4680
  });
4782
4681
  tables.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
4783
4682
  return ok(tables);