@ai-matrx/records 0.87.31 → 0.92.0

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 (107) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +115 -0
  3. package/dist/{client-E0VQ0NPO.d.ts → client-DE9Mq6YX.d.cts} +8 -5
  4. package/dist/{client-C3ZZNfGH.d.cts → client-vJAb7g9r.d.ts} +8 -5
  5. package/dist/core/index.cjs +25 -7
  6. package/dist/core/index.cjs.map +1 -1
  7. package/dist/core/index.d.cts +23 -12
  8. package/dist/core/index.d.ts +23 -12
  9. package/dist/core/index.js +25 -7
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/data/index.cjs +19 -7
  12. package/dist/data/index.cjs.map +1 -1
  13. package/dist/data/index.d.cts +12 -142
  14. package/dist/data/index.d.ts +12 -142
  15. package/dist/data/index.js +19 -7
  16. package/dist/data/index.js.map +1 -1
  17. package/dist/{declareTable-BK3zufr7.d.cts → declareTable-Btg5bql1.d.cts} +4 -4
  18. package/dist/{declareTable-B12XybRp.d.ts → declareTable-JKt2q34d.d.ts} +4 -4
  19. package/dist/entity/index.cjs +984 -0
  20. package/dist/entity/index.cjs.map +1 -0
  21. package/dist/entity/index.d.cts +36 -0
  22. package/dist/entity/index.d.ts +36 -0
  23. package/dist/entity/index.js +964 -0
  24. package/dist/entity/index.js.map +1 -0
  25. package/dist/entity/react.cjs +1024 -0
  26. package/dist/entity/react.cjs.map +1 -0
  27. package/dist/entity/react.d.cts +511 -0
  28. package/dist/entity/react.d.ts +511 -0
  29. package/dist/entity/react.js +1015 -0
  30. package/dist/entity/react.js.map +1 -0
  31. package/dist/{field-BanTVGK2.d.cts → field-BJBnTyJ0.d.cts} +1 -1
  32. package/dist/{field-BPABOJ2Y.d.ts → field-Ti5iAxFr.d.ts} +1 -1
  33. package/dist/forms/index.cjs +984 -0
  34. package/dist/forms/index.cjs.map +1 -0
  35. package/dist/forms/index.d.cts +333 -0
  36. package/dist/forms/index.d.ts +333 -0
  37. package/dist/forms/index.js +961 -0
  38. package/dist/forms/index.js.map +1 -0
  39. package/dist/index.cjs +10 -1
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +11 -8
  42. package/dist/index.d.ts +11 -8
  43. package/dist/index.js +10 -1
  44. package/dist/index.js.map +1 -1
  45. package/dist/memory/index.d.cts +7 -6
  46. package/dist/memory/index.d.ts +7 -6
  47. package/dist/port-CPVBfDxS.d.cts +301 -0
  48. package/dist/port-D2i2o7Lg.d.ts +301 -0
  49. package/dist/portal-Db4CYyHe.d.ts +331 -0
  50. package/dist/portal-DfeY2Boy.d.cts +331 -0
  51. package/dist/{ports-TMWX-t9l.d.ts → ports-BWtxAnXh.d.ts} +2 -2
  52. package/dist/{ports-D8-iuY1P.d.cts → ports-DSU2RsR6.d.cts} +2 -2
  53. package/dist/react/index.cjs +55 -523
  54. package/dist/react/index.cjs.map +1 -1
  55. package/dist/react/index.d.cts +14 -1
  56. package/dist/react/index.d.ts +14 -1
  57. package/dist/react/index.js +52 -527
  58. package/dist/react/index.js.map +1 -1
  59. package/dist/realtime/index.d.cts +2 -2
  60. package/dist/realtime/index.d.ts +2 -2
  61. package/dist/{record-DpB2QgAZ.d.cts → record-BQi92d4-.d.cts} +7 -1
  62. package/dist/{record-DpB2QgAZ.d.ts → record-BQi92d4-.d.ts} +7 -1
  63. package/dist/relation-DMwkmzgN.d.cts +230 -0
  64. package/dist/relation-DlcqV_W5.d.ts +230 -0
  65. package/dist/rule-B8kR0l01.d.ts +250 -0
  66. package/dist/rule-BMViCLmW.d.cts +250 -0
  67. package/dist/search/index.cjs +283 -0
  68. package/dist/search/index.cjs.map +1 -0
  69. package/dist/search/index.d.cts +44 -0
  70. package/dist/search/index.d.ts +44 -0
  71. package/dist/search/index.js +260 -0
  72. package/dist/search/index.js.map +1 -0
  73. package/dist/setup/index.cjs +6854 -0
  74. package/dist/setup/index.cjs.map +1 -0
  75. package/dist/setup/index.d.cts +87 -0
  76. package/dist/setup/index.d.ts +87 -0
  77. package/dist/setup/index.js +6829 -0
  78. package/dist/setup/index.js.map +1 -0
  79. package/dist/{subscription-D7KQBHXN.d.ts → subscription-5CLN3Jug.d.ts} +3 -249
  80. package/dist/{subscription-BD9DnJxX.d.cts → subscription-D-VEzvyy.d.cts} +3 -249
  81. package/dist/{table-kind-BZu8mtND.d.cts → table-kind-CVp43g6h.d.ts} +3 -558
  82. package/dist/{table-kind-xKxTHtrV.d.ts → table-kind-Cm6PXkWx.d.cts} +3 -558
  83. package/dist/templates/index.d.cts +10 -9
  84. package/dist/templates/index.d.ts +10 -9
  85. package/dist/typed-table/index.cjs +19 -7
  86. package/dist/typed-table/index.cjs.map +1 -1
  87. package/dist/typed-table/index.d.cts +10 -7
  88. package/dist/typed-table/index.d.ts +10 -7
  89. package/dist/typed-table/index.js +19 -7
  90. package/dist/typed-table/index.js.map +1 -1
  91. package/dist/{types-CLP5H4Wk.d.cts → types-9Q5SHRDJ.d.cts} +2 -2
  92. package/dist/{types-DmPkWQic.d.ts → types-CfYy-vdV.d.ts} +2 -2
  93. package/dist/{types-C2uspRtf.d.cts → types-Cs2MyE3u.d.cts} +2 -2
  94. package/dist/{types-Dv61jStB.d.ts → types-DF-dxB_l.d.ts} +2 -2
  95. package/dist/types-DTEGaxso.d.cts +139 -0
  96. package/dist/types-Dji5SpFS.d.ts +139 -0
  97. package/dist/use-cases/index.d.cts +5 -5
  98. package/dist/use-cases/index.d.ts +5 -5
  99. package/dist/{validate-CWVToe1T.d.ts → validate-BydKd-Le.d.ts} +1 -1
  100. package/dist/{validate-DEB_mn4Y.d.cts → validate-CqJakTKk.d.cts} +1 -1
  101. package/dist/versions/index.cjs +375 -0
  102. package/dist/versions/index.cjs.map +1 -0
  103. package/dist/versions/index.d.cts +160 -0
  104. package/dist/versions/index.d.ts +160 -0
  105. package/dist/versions/index.js +353 -0
  106. package/dist/versions/index.js.map +1 -0
  107. package/package.json +62 -2
@@ -0,0 +1,87 @@
1
+ import { RealtimeManager } from '@ai-matrx/realtime';
2
+ import { R as RecordsClient } from '../client-DE9Mq6YX.cjs';
3
+ import { C as CreateEntityDataPortOptions, E as EntityDataPort } from '../port-CPVBfDxS.cjs';
4
+ import { a as RecordsConfig, b as RecordsErrorSink, c as RecordsDataSource, d as RecordsChangeSink } from '../ports-DSU2RsR6.cjs';
5
+ import { U as Uuid, R as RecordsResult } from '../record-BQi92d4-.cjs';
6
+ import { RecordSearchRequest, RecordSearchHit, listStoreRecordCandidates } from '../search/index.cjs';
7
+ import '../table-kind-Cm6PXkWx.cjs';
8
+ import '../field-BJBnTyJ0.cjs';
9
+ import '../subscription-D-VEzvyy.cjs';
10
+ import '../rule-BMViCLmW.cjs';
11
+ import '../relation-DMwkmzgN.cjs';
12
+ import '../portal-DfeY2Boy.cjs';
13
+ import '../types-DTEGaxso.cjs';
14
+
15
+ /** A signed-in database identity: the client every door and live change rides, and who it is. */
16
+ interface RecordsSession {
17
+ /** A supabase-js client (or anything shaped like one) carrying the identity's access token. */
18
+ supabase: object;
19
+ /** The identity's user id, when known (the live-change echo test and the client's own mirror use it). */
20
+ userId?: Uuid;
21
+ }
22
+ /** How setup signs in. Session today; an organization API key later — same port. */
23
+ interface RecordsAuthPort {
24
+ readonly kind: "session" | "api_key";
25
+ session(): Promise<RecordsSession>;
26
+ }
27
+ /** A supabase-js client that already carries a signed-in person (browser sign-in, `signInWithPassword`, SSR cookies). */
28
+ declare function sessionAuth(supabase: object, userId?: Uuid): RecordsAuthPort;
29
+ interface CreateRecordsOptions<TAssociations = never> {
30
+ auth: RecordsAuthPort;
31
+ /**
32
+ * Where new things are saved and which organization a write runs in. `null` = no writes, reads across
33
+ * all. A function receives every organization the identity belongs to and answers the host's choice.
34
+ */
35
+ organizationId: Uuid | null | ((organizationIds: readonly Uuid[]) => Uuid | null);
36
+ /** Who is acting. Default: the signed-in person (`user`). An agent acting for a person names `on_behalf_of`. */
37
+ actor?: RecordsConfig["actor"];
38
+ /**
39
+ * Live changes. Default `true`: one realtime manager over the session's client. Pass your own
40
+ * `RealtimeManager` to share a socket, or `false` for none (`watch` then says so and returns a no-op).
41
+ */
42
+ live?: boolean | RealtimeManager;
43
+ /**
44
+ * Platform-record aliases (`{ contacts: { kind: "entity", token: "party" } }`) for `entities`. Optional.
45
+ */
46
+ entityAliases?: CreateEntityDataPortOptions["aliases"];
47
+ /** The associations store (`@ai-matrx/associations/core` `createAssociationsStore`) bound by the host; handed back as-is. */
48
+ associations?: TAssociations;
49
+ onError?: RecordsErrorSink;
50
+ }
51
+ interface RecordsSetup<TAssociations = never> {
52
+ /** How this setup signed in. */
53
+ readonly authKind: RecordsAuthPort["kind"];
54
+ /** The signed-in identity's user id, when known. */
55
+ readonly userId: Uuid | undefined;
56
+ /** Every organization the identity belongs to (reads span them; the host filters visibly). */
57
+ readonly organizationIds: readonly Uuid[];
58
+ /** Where this setup's writes go (the host's choice), or null. */
59
+ readonly organizationId: Uuid | null;
60
+ /** The typed client over the store's doors: tables, records, versions, archive and restore, views, forms… */
61
+ readonly records: RecordsClient;
62
+ /** The data source the doors ride — hand it to any other section (`records/forms`, `records/search`). */
63
+ readonly dataSource: RecordsDataSource;
64
+ /** Platform records (contacts, projects, tasks) through the same port shape custom tables use. */
65
+ readonly entities: EntityDataPort;
66
+ /** The live-changes manager, or null when `live: false`. */
67
+ readonly realtime: RealtimeManager | null;
68
+ /** Search every table the identity can see (never narrowed by `organizationId`). */
69
+ search(request: RecordSearchRequest): Promise<RecordsResult<RecordSearchHit[]>>;
70
+ /** Candidates for a "link a record" picker. */
71
+ recordCandidates(args: {
72
+ search?: string;
73
+ limit?: number;
74
+ }): ReturnType<typeof listStoreRecordCandidates>;
75
+ /**
76
+ * Watch one table's records (other people's changes; this setup's own writes are dropped). `records(ids)`
77
+ * names the changed records (`null` = re-read the page); `shape()` = the table's columns moved.
78
+ */
79
+ watch(tableId: Uuid, sink: Partial<RecordsChangeSink>, organizationId?: Uuid): () => void;
80
+ /** The associations store the host bound, if any. */
81
+ readonly associations: TAssociations | undefined;
82
+ /** Close live channels (a Node script calls this before it exits). */
83
+ close(): void;
84
+ }
85
+ declare function createRecords<TAssociations = never>(options: CreateRecordsOptions<TAssociations>): Promise<RecordsSetup<TAssociations>>;
86
+
87
+ export { type CreateRecordsOptions, type RecordsAuthPort, type RecordsSession, type RecordsSetup, createRecords, sessionAuth };
@@ -0,0 +1,87 @@
1
+ import { RealtimeManager } from '@ai-matrx/realtime';
2
+ import { R as RecordsClient } from '../client-vJAb7g9r.js';
3
+ import { C as CreateEntityDataPortOptions, E as EntityDataPort } from '../port-D2i2o7Lg.js';
4
+ import { a as RecordsConfig, b as RecordsErrorSink, c as RecordsDataSource, d as RecordsChangeSink } from '../ports-BWtxAnXh.js';
5
+ import { U as Uuid, R as RecordsResult } from '../record-BQi92d4-.js';
6
+ import { RecordSearchRequest, RecordSearchHit, listStoreRecordCandidates } from '../search/index.js';
7
+ import '../table-kind-CVp43g6h.js';
8
+ import '../field-Ti5iAxFr.js';
9
+ import '../subscription-5CLN3Jug.js';
10
+ import '../rule-B8kR0l01.js';
11
+ import '../relation-DlcqV_W5.js';
12
+ import '../portal-Db4CYyHe.js';
13
+ import '../types-Dji5SpFS.js';
14
+
15
+ /** A signed-in database identity: the client every door and live change rides, and who it is. */
16
+ interface RecordsSession {
17
+ /** A supabase-js client (or anything shaped like one) carrying the identity's access token. */
18
+ supabase: object;
19
+ /** The identity's user id, when known (the live-change echo test and the client's own mirror use it). */
20
+ userId?: Uuid;
21
+ }
22
+ /** How setup signs in. Session today; an organization API key later — same port. */
23
+ interface RecordsAuthPort {
24
+ readonly kind: "session" | "api_key";
25
+ session(): Promise<RecordsSession>;
26
+ }
27
+ /** A supabase-js client that already carries a signed-in person (browser sign-in, `signInWithPassword`, SSR cookies). */
28
+ declare function sessionAuth(supabase: object, userId?: Uuid): RecordsAuthPort;
29
+ interface CreateRecordsOptions<TAssociations = never> {
30
+ auth: RecordsAuthPort;
31
+ /**
32
+ * Where new things are saved and which organization a write runs in. `null` = no writes, reads across
33
+ * all. A function receives every organization the identity belongs to and answers the host's choice.
34
+ */
35
+ organizationId: Uuid | null | ((organizationIds: readonly Uuid[]) => Uuid | null);
36
+ /** Who is acting. Default: the signed-in person (`user`). An agent acting for a person names `on_behalf_of`. */
37
+ actor?: RecordsConfig["actor"];
38
+ /**
39
+ * Live changes. Default `true`: one realtime manager over the session's client. Pass your own
40
+ * `RealtimeManager` to share a socket, or `false` for none (`watch` then says so and returns a no-op).
41
+ */
42
+ live?: boolean | RealtimeManager;
43
+ /**
44
+ * Platform-record aliases (`{ contacts: { kind: "entity", token: "party" } }`) for `entities`. Optional.
45
+ */
46
+ entityAliases?: CreateEntityDataPortOptions["aliases"];
47
+ /** The associations store (`@ai-matrx/associations/core` `createAssociationsStore`) bound by the host; handed back as-is. */
48
+ associations?: TAssociations;
49
+ onError?: RecordsErrorSink;
50
+ }
51
+ interface RecordsSetup<TAssociations = never> {
52
+ /** How this setup signed in. */
53
+ readonly authKind: RecordsAuthPort["kind"];
54
+ /** The signed-in identity's user id, when known. */
55
+ readonly userId: Uuid | undefined;
56
+ /** Every organization the identity belongs to (reads span them; the host filters visibly). */
57
+ readonly organizationIds: readonly Uuid[];
58
+ /** Where this setup's writes go (the host's choice), or null. */
59
+ readonly organizationId: Uuid | null;
60
+ /** The typed client over the store's doors: tables, records, versions, archive and restore, views, forms… */
61
+ readonly records: RecordsClient;
62
+ /** The data source the doors ride — hand it to any other section (`records/forms`, `records/search`). */
63
+ readonly dataSource: RecordsDataSource;
64
+ /** Platform records (contacts, projects, tasks) through the same port shape custom tables use. */
65
+ readonly entities: EntityDataPort;
66
+ /** The live-changes manager, or null when `live: false`. */
67
+ readonly realtime: RealtimeManager | null;
68
+ /** Search every table the identity can see (never narrowed by `organizationId`). */
69
+ search(request: RecordSearchRequest): Promise<RecordsResult<RecordSearchHit[]>>;
70
+ /** Candidates for a "link a record" picker. */
71
+ recordCandidates(args: {
72
+ search?: string;
73
+ limit?: number;
74
+ }): ReturnType<typeof listStoreRecordCandidates>;
75
+ /**
76
+ * Watch one table's records (other people's changes; this setup's own writes are dropped). `records(ids)`
77
+ * names the changed records (`null` = re-read the page); `shape()` = the table's columns moved.
78
+ */
79
+ watch(tableId: Uuid, sink: Partial<RecordsChangeSink>, organizationId?: Uuid): () => void;
80
+ /** The associations store the host bound, if any. */
81
+ readonly associations: TAssociations | undefined;
82
+ /** Close live channels (a Node script calls this before it exits). */
83
+ close(): void;
84
+ }
85
+ declare function createRecords<TAssociations = never>(options: CreateRecordsOptions<TAssociations>): Promise<RecordsSetup<TAssociations>>;
86
+
87
+ export { type CreateRecordsOptions, type RecordsAuthPort, type RecordsSession, type RecordsSetup, createRecords, sessionAuth };