@ai-matrx/entity-data 0.3.43 → 0.4.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.
- package/CHANGELOG.md +15 -0
- package/README.md +6 -50
- package/dist/core/index.cjs +2 -376
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +1 -27
- package/dist/core/index.d.ts +1 -27
- package/dist/core/index.js +2 -374
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +2 -716
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -6
- package/dist/index.d.ts +1 -6
- package/dist/index.js +2 -714
- package/dist/index.js.map +1 -1
- package/dist/port/index.cjs +2 -568
- package/dist/port/index.cjs.map +1 -1
- package/dist/port/index.d.cts +1 -70
- package/dist/port/index.d.ts +1 -70
- package/dist/port/index.js +2 -566
- package/dist/port/index.js.map +1 -1
- package/dist/react/index.cjs +2 -754
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -235
- package/dist/react/index.d.ts +1 -235
- package/dist/react/index.js +1 -761
- package/dist/react/index.js.map +1 -1
- package/package.json +6 -7
- package/dist/realtime-DL-bfUFj.d.cts +0 -244
- package/dist/realtime-DL-bfUFj.d.ts +0 -244
package/dist/react/index.d.ts
CHANGED
|
@@ -1,235 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
import { DataScope, DataRead, DataRows, DataMutations } from '@ai-matrx/records/data/react';
|
|
5
|
-
export { DataMutations, DataRead, DataRows } from '@ai-matrx/records/data/react';
|
|
6
|
-
import { Lane, Uuid, HostDataPort, Column, Query, Row } from '@ai-matrx/records/data';
|
|
7
|
-
import { RecordsResult, Uuid as Uuid$1 } from '@ai-matrx/records';
|
|
8
|
-
|
|
9
|
-
/** One row exactly as `platform.entity_list_scoped` / `entity_get` answer it. */
|
|
10
|
-
interface EntityWireRow {
|
|
11
|
-
id: Uuid;
|
|
12
|
-
version: number;
|
|
13
|
-
organization_id: Uuid;
|
|
14
|
-
/** The row's own organization's custom fields, already masked by the store (a hidden field is null). */
|
|
15
|
-
_custom?: Record<string, unknown>;
|
|
16
|
-
/** The token's own columns; link columns are `EntityWireRef[]`. */
|
|
17
|
-
[column: string]: unknown;
|
|
18
|
-
}
|
|
19
|
-
interface EntitySortApplied {
|
|
20
|
-
column: string;
|
|
21
|
-
dir: "asc" | "desc";
|
|
22
|
-
nulls: "first" | "last";
|
|
23
|
-
}
|
|
24
|
-
interface EntityListAnswer {
|
|
25
|
-
rows: EntityWireRow[];
|
|
26
|
-
/** null when not asked for. */
|
|
27
|
-
total: number | null;
|
|
28
|
-
/** The total stopped at the store's count cap; `total` is then a floor, not a count. */
|
|
29
|
-
total_is_capped: boolean;
|
|
30
|
-
page_size: number;
|
|
31
|
-
/** The keyset cursor of the next page; opaque. */
|
|
32
|
-
next_after: string | null;
|
|
33
|
-
has_more: boolean;
|
|
34
|
-
sort_applied: EntitySortApplied[];
|
|
35
|
-
/** Sort columns the door could not use (it keeps one key today). Said back, never hidden. */
|
|
36
|
-
sort_ignored: string[];
|
|
37
|
-
feed_cursor: null;
|
|
38
|
-
}
|
|
39
|
-
interface EntityGetAnswer {
|
|
40
|
-
rows: EntityWireRow[];
|
|
41
|
-
/** Ids that are not there or that this person cannot open. */
|
|
42
|
-
missing: Uuid[];
|
|
43
|
-
feed_cursor: null;
|
|
44
|
-
}
|
|
45
|
-
interface EntityColumnWire {
|
|
46
|
-
key: string;
|
|
47
|
-
label: string;
|
|
48
|
-
type: string;
|
|
49
|
-
origin: "platform" | "custom";
|
|
50
|
-
required: boolean;
|
|
51
|
-
readOnly: boolean;
|
|
52
|
-
linksTo?: string[];
|
|
53
|
-
choices?: string[];
|
|
54
|
-
/** Custom columns only. */
|
|
55
|
-
field_id?: Uuid;
|
|
56
|
-
organization?: string;
|
|
57
|
-
organization_id?: Uuid;
|
|
58
|
-
}
|
|
59
|
-
interface EntityColumnsAnswer {
|
|
60
|
-
label: string;
|
|
61
|
-
token: string;
|
|
62
|
-
columns: EntityColumnWire[];
|
|
63
|
-
can_create: boolean;
|
|
64
|
-
can_update: boolean;
|
|
65
|
-
/** The type's landing lane (`platform.entity_default_list_scope`). */
|
|
66
|
-
default_scope: Lane;
|
|
67
|
-
}
|
|
68
|
-
/** One filter predicate as the door reads it (CONTRACT §3.2). */
|
|
69
|
-
interface EntityWirePredicate {
|
|
70
|
-
column: string;
|
|
71
|
-
op: string;
|
|
72
|
-
value?: unknown;
|
|
73
|
-
values?: unknown[];
|
|
74
|
-
negated?: boolean;
|
|
75
|
-
}
|
|
76
|
-
interface EntityWireSort {
|
|
77
|
-
column: string;
|
|
78
|
-
dir: "asc" | "desc";
|
|
79
|
-
nulls: "last";
|
|
80
|
-
}
|
|
81
|
-
interface EntityWireQuery {
|
|
82
|
-
/** Absent = the type's own landing lane. `organization_id` narrows any lane and never locks it. */
|
|
83
|
-
scope?: {
|
|
84
|
-
kind?: Lane;
|
|
85
|
-
organization_id?: Uuid;
|
|
86
|
-
};
|
|
87
|
-
filter?: {
|
|
88
|
-
all: EntityWirePredicate[];
|
|
89
|
-
};
|
|
90
|
-
search?: string;
|
|
91
|
-
sort?: EntityWireSort[];
|
|
92
|
-
pageSize?: number;
|
|
93
|
-
}
|
|
94
|
-
/** What every write door answers (`entity_insert` / `entity_update` / `entity_archive` / `entity_unarchive`). */
|
|
95
|
-
interface EntityWriteAnswer {
|
|
96
|
-
status: string;
|
|
97
|
-
/** The rows as the read door now reads them, each with its NEW `version`. */
|
|
98
|
-
rows: EntityWireRow[];
|
|
99
|
-
validation: unknown[];
|
|
100
|
-
feed_cursor: null;
|
|
101
|
-
/** Archive and restore say what they did, in the store's words (trash words on these types). */
|
|
102
|
-
message?: string;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/** What a write takes beyond its arguments: the op id minted for it (`mintOpId`). */
|
|
106
|
-
interface EntityWriteOptions {
|
|
107
|
-
opId?: string;
|
|
108
|
-
}
|
|
109
|
-
interface EntityListRequest extends EntityWireQuery {
|
|
110
|
-
token: string;
|
|
111
|
-
/** Keyset cursor from the previous answer's `next_after`. */
|
|
112
|
-
after?: string | null;
|
|
113
|
-
/** Ask the door to skip the count. Default: counted. */
|
|
114
|
-
withTotal?: boolean;
|
|
115
|
-
archived?: "active" | "archived" | "all";
|
|
116
|
-
}
|
|
117
|
-
interface EntityClient {
|
|
118
|
-
list(request: EntityListRequest): Promise<RecordsResult<EntityListAnswer>>;
|
|
119
|
-
get(request: {
|
|
120
|
-
token: string;
|
|
121
|
-
ids: readonly Uuid$1[];
|
|
122
|
-
}): Promise<RecordsResult<EntityGetAnswer>>;
|
|
123
|
-
/** `organizationId` null reads the custom fields of every organization the person belongs to. */
|
|
124
|
-
columns(request: {
|
|
125
|
-
token: string;
|
|
126
|
-
organizationId?: Uuid$1 | null;
|
|
127
|
-
}): Promise<RecordsResult<EntityColumnsAnswer>>;
|
|
128
|
-
/** One `entity_data` knob as `platform.knob_resolve` answers it for an organization (live updates read three). */
|
|
129
|
-
knob(request: {
|
|
130
|
-
key: string;
|
|
131
|
-
organizationId?: Uuid$1 | null;
|
|
132
|
-
}): Promise<RecordsResult<unknown>>;
|
|
133
|
-
/** `platform.entity_insert`: rows into the organization the host names (never guessed). */
|
|
134
|
-
insert(request: {
|
|
135
|
-
token: string;
|
|
136
|
-
organizationId: Uuid$1;
|
|
137
|
-
rows: readonly Record<string, unknown>[];
|
|
138
|
-
} & EntityWriteOptions): Promise<RecordsResult<EntityWriteAnswer>>;
|
|
139
|
-
/** `platform.entity_update`: one row, refused as stale (`MX001`) unless `baseVersion` is still current. */
|
|
140
|
-
update(request: {
|
|
141
|
-
token: string;
|
|
142
|
-
id: Uuid$1;
|
|
143
|
-
baseVersion: number;
|
|
144
|
-
patch: Record<string, unknown>;
|
|
145
|
-
} & EntityWriteOptions): Promise<RecordsResult<EntityWriteAnswer>>;
|
|
146
|
-
/** `platform.entity_archive` (on these types, the trash). */
|
|
147
|
-
archive(request: {
|
|
148
|
-
token: string;
|
|
149
|
-
ids: readonly Uuid$1[];
|
|
150
|
-
} & EntityWriteOptions): Promise<RecordsResult<EntityWriteAnswer>>;
|
|
151
|
-
/** `platform.entity_unarchive`. */
|
|
152
|
-
unarchive(request: {
|
|
153
|
-
token: string;
|
|
154
|
-
ids: readonly Uuid$1[];
|
|
155
|
-
} & EntityWriteOptions): Promise<RecordsResult<EntityWriteAnswer>>;
|
|
156
|
-
/** The organizations the person belongs to, as row security counts them (`iam.my_orgs()`: archived ones closed). */
|
|
157
|
-
memberOrganizations(): Promise<RecordsResult<Uuid$1[]>>;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
interface EntityNoticeSink {
|
|
161
|
-
/** `ids` to re-read, or `null` to re-read everything this reader shows. */
|
|
162
|
-
rows(ids: string[] | null): void;
|
|
163
|
-
}
|
|
164
|
-
interface EntityRealtime {
|
|
165
|
-
/** Hear `token` across `organizationIds`; the sink gets one coalesced call per burst. Returns the stop. */
|
|
166
|
-
subscribe(target: {
|
|
167
|
-
token: string;
|
|
168
|
-
organizationIds: readonly string[];
|
|
169
|
-
}, sink: EntityNoticeSink): () => void;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** A type as the person may use it: its name and whether she may add or change rows (`entity_columns`' own answer). */
|
|
173
|
-
interface EntityTypeFacts {
|
|
174
|
-
token: string;
|
|
175
|
-
label: string;
|
|
176
|
-
canCreate: boolean;
|
|
177
|
-
canUpdate: boolean;
|
|
178
|
-
}
|
|
179
|
-
/** The host's entity port: the DataPort, plus `describe` for a token-first screen that has no `sources()` entry. */
|
|
180
|
-
interface EntityDataPort extends HostDataPort {
|
|
181
|
-
/** The type behind an alias, from the same one `entity_columns` read `columns()` uses. */
|
|
182
|
-
describe(alias: string): Promise<RecordsResult<EntityTypeFacts>>;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/** The cache prefix of the one entity port: `["@ai-matrx/records","data","entity-data",<token>,…]`. */
|
|
186
|
-
declare const ENTITY_PORT_KEY = "entity-data";
|
|
187
|
-
interface EntityDataProviderProps {
|
|
188
|
-
/** The supabase-js client carrying the signed-in person's session (or a records data seam). */
|
|
189
|
-
dataSource?: unknown;
|
|
190
|
-
/** … or an entity client already built. Give one of the two. */
|
|
191
|
-
client?: EntityClient;
|
|
192
|
-
/**
|
|
193
|
-
* Where a NEW row is saved and which organization's topic is joined first: the host's active
|
|
194
|
-
* organization, never guessed. `null` while none is chosen — `create` is then refused
|
|
195
|
-
* `organization_required` and nothing is sent. Lists never narrow by it.
|
|
196
|
-
*/
|
|
197
|
-
activeOrganizationId: Uuid | null;
|
|
198
|
-
/**
|
|
199
|
-
* Live notices. Left out: the app's ambient realtime manager (`createEntityRealtime()`), never a socket
|
|
200
|
-
* of our own. `false`: not live (the console says so once).
|
|
201
|
-
*/
|
|
202
|
-
realtime?: EntityRealtime | false;
|
|
203
|
-
/** A second, separate cache (tests, two seats on one page). Default `entity-data`. */
|
|
204
|
-
portKey?: string;
|
|
205
|
-
children?: ReactNode;
|
|
206
|
-
}
|
|
207
|
-
/** The engine's scope over the one entity port. */
|
|
208
|
-
interface EntityScope extends DataScope {
|
|
209
|
-
port: EntityDataPort;
|
|
210
|
-
}
|
|
211
|
-
declare function EntityDataProvider({ dataSource, client, activeOrganizationId, realtime, portKey, children }: EntityDataProviderProps): react.FunctionComponentElement<react.ProviderProps<EntityScope | null>> | react.FunctionComponentElement<_tanstack_react_query.QueryClientProviderProps>;
|
|
212
|
-
/** The entity port's scope when an `EntityDataProvider` is mounted above, else null (a host component deciding whether to mount one). */
|
|
213
|
-
declare function useOptionalEntityScope(): EntityScope | null;
|
|
214
|
-
/** The entity port's scope, or a loud failure naming what to mount. */
|
|
215
|
-
declare function useEntityScope(): EntityScope;
|
|
216
|
-
/** One type's list: keyset pages, `loadMore`, `newer`, live. `query.org` is a filter, never a lock. */
|
|
217
|
-
declare function useEntityList(token: string, query?: Query): DataRows;
|
|
218
|
-
/** One type's columns: platform columns and the organizations' custom fields, with `origin`. */
|
|
219
|
-
declare function useEntityColumns(token: string): DataRead<Column[]>;
|
|
220
|
-
/**
|
|
221
|
-
* The type itself: its name and whether this person may add or change rows. Read from the same
|
|
222
|
-
* `entity_columns` answer the columns come from (one request per type), cached under the type's own
|
|
223
|
-
* key, so a shape notice refreshes it with the columns.
|
|
224
|
-
*/
|
|
225
|
-
declare function useEntityType(token: string): DataRead<EntityTypeFacts>;
|
|
226
|
-
/** One row by id (drawn at once from a loaded page, confirmed by the read). */
|
|
227
|
-
declare function useEntityRow(token: string, id: Uuid | null): DataRead<Row | null>;
|
|
228
|
-
/**
|
|
229
|
-
* Writes for one type, optimistic with rollback: `create` (into the active organization), `update` (with
|
|
230
|
-
* the `_version` the person saw), `archive` / `restore`. Each answers `RecordsResult`; a refusal carries
|
|
231
|
-
* the store's sentence verbatim.
|
|
232
|
-
*/
|
|
233
|
-
declare function useEntityWrite(token: string): DataMutations;
|
|
234
|
-
|
|
235
|
-
export { ENTITY_PORT_KEY, EntityDataProvider, type EntityDataProviderProps, type EntityScope, type EntityTypeFacts, useEntityColumns, useEntityList, useEntityRow, useEntityScope, useEntityType, useEntityWrite, useOptionalEntityScope };
|
|
1
|
+
export * from '@ai-matrx/records/entity/react';
|