@myko/core 6.0.0 → 6.2.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 (63) hide show
  1. package/dist/client.d.ts +114 -2
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +354 -25
  4. package/dist/generated/AdjacencyPolicy.d.ts +2 -0
  5. package/dist/generated/AdjacencyPolicy.d.ts.map +1 -0
  6. package/dist/generated/AdjacencyPolicy.js +2 -0
  7. package/dist/generated/Direction.d.ts +2 -0
  8. package/dist/generated/Direction.d.ts.map +1 -0
  9. package/dist/generated/Direction.js +2 -0
  10. package/dist/generated/EdgeShapeKind.d.ts +2 -0
  11. package/dist/generated/EdgeShapeKind.d.ts.map +1 -0
  12. package/dist/generated/EdgeShapeKind.js +2 -0
  13. package/dist/generated/EndPosition.d.ts +2 -0
  14. package/dist/generated/EndPosition.d.ts.map +1 -0
  15. package/dist/generated/EndPosition.js +2 -0
  16. package/dist/generated/EndpointDeletePolicy.d.ts +2 -0
  17. package/dist/generated/EndpointDeletePolicy.d.ts.map +1 -0
  18. package/dist/generated/EndpointDeletePolicy.js +2 -0
  19. package/dist/generated/EntityRef.d.ts +8 -0
  20. package/dist/generated/EntityRef.d.ts.map +1 -0
  21. package/dist/generated/EntityRef.js +2 -0
  22. package/dist/generated/GraphPlanTelemetry.d.ts +16 -0
  23. package/dist/generated/GraphPlanTelemetry.d.ts.map +1 -0
  24. package/dist/generated/GraphPlanTelemetry.js +1 -0
  25. package/dist/generated/GraphSyncResult.d.ts +10 -0
  26. package/dist/generated/GraphSyncResult.d.ts.map +1 -0
  27. package/dist/generated/GraphSyncResult.js +2 -0
  28. package/dist/generated/MykoMessage.d.ts +4 -0
  29. package/dist/generated/MykoMessage.d.ts.map +1 -1
  30. package/dist/generated/PairPolicy.d.ts +2 -0
  31. package/dist/generated/PairPolicy.d.ts.map +1 -0
  32. package/dist/generated/PairPolicy.js +2 -0
  33. package/dist/generated/PairProjectionPolicy.d.ts +2 -0
  34. package/dist/generated/PairProjectionPolicy.d.ts.map +1 -0
  35. package/dist/generated/PairProjectionPolicy.js +2 -0
  36. package/dist/generated/QueryCursorWindow.d.ts +12 -0
  37. package/dist/generated/QueryCursorWindow.d.ts.map +1 -0
  38. package/dist/generated/QueryCursorWindow.js +2 -0
  39. package/dist/generated/QueryCursorWindowUpdate.d.ts +6 -0
  40. package/dist/generated/QueryCursorWindowUpdate.d.ts.map +1 -0
  41. package/dist/generated/QueryCursorWindowUpdate.js +1 -0
  42. package/dist/generated/SelfLoopPolicy.d.ts +2 -0
  43. package/dist/generated/SelfLoopPolicy.d.ts.map +1 -0
  44. package/dist/generated/SelfLoopPolicy.js +2 -0
  45. package/dist/generated/TraversalPath.d.ts +12 -0
  46. package/dist/generated/TraversalPath.d.ts.map +1 -0
  47. package/dist/generated/TraversalPath.js +1 -0
  48. package/dist/generated/TraversalResult.d.ts +7 -0
  49. package/dist/generated/TraversalResult.d.ts.map +1 -0
  50. package/dist/generated/TraversalResult.js +1 -0
  51. package/dist/generated/index.d.ts +152 -130
  52. package/dist/generated/index.d.ts.map +1 -1
  53. package/dist/generated/index.js +98 -95
  54. package/dist/graph-client.d.ts +128 -0
  55. package/dist/graph-client.d.ts.map +1 -0
  56. package/dist/graph-client.js +192 -0
  57. package/dist/index.d.ts +4 -2
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +2 -0
  60. package/dist/live-collection.d.ts +94 -0
  61. package/dist/live-collection.d.ts.map +1 -0
  62. package/dist/live-collection.js +302 -0
  63. package/package.json +5 -2
@@ -1,36 +1,8 @@
1
1
  // Auto-generated by type_gen - do not edit manually
2
+ // Graph schema and typed endpoint helpers
3
+ export const graphSchema = { categories: {}, memberships: [], edges: {} };
2
4
  export * from "./serde_json/JsonValue";
3
5
  // Query classes
4
- export class GetClientsByQuery {
5
- static queryId = "GetClientsByQuery";
6
- static queryItemType = "Client";
7
- queryId = "GetClientsByQuery";
8
- queryItemType = "Client";
9
- query;
10
- constructor(args) {
11
- this.query = args;
12
- }
13
- }
14
- export class GetClientsByIds {
15
- static queryId = "GetClientsByIds";
16
- static queryItemType = "Client";
17
- queryId = "GetClientsByIds";
18
- queryItemType = "Client";
19
- query;
20
- constructor(args) {
21
- this.query = args;
22
- }
23
- }
24
- export class GetAllClients {
25
- static queryId = "GetAllClients";
26
- static queryItemType = "Client";
27
- queryId = "GetAllClients";
28
- queryItemType = "Client";
29
- query;
30
- constructor(args) {
31
- this.query = args;
32
- }
33
- }
34
6
  export class GetServersByQuery {
35
7
  static queryId = "GetServersByQuery";
36
8
  static queryItemType = "Server";
@@ -81,59 +53,81 @@ export class GetConnectedServer {
81
53
  this.query = args;
82
54
  }
83
55
  }
84
- // View classes
85
- // Report classes
86
- export class EntitySearch {
87
- static reportId = "EntitySearch";
88
- reportId = "EntitySearch";
89
- report;
56
+ export class GetClientsByQuery {
57
+ static queryId = "GetClientsByQuery";
58
+ static queryItemType = "Client";
59
+ queryId = "GetClientsByQuery";
60
+ queryItemType = "Client";
61
+ query;
90
62
  constructor(args) {
91
- this.report = args;
63
+ this.query = args;
92
64
  }
93
65
  }
94
- export class ExportEntityTree {
95
- static reportId = "ExportEntityTree";
96
- reportId = "ExportEntityTree";
66
+ export class GetClientsByIds {
67
+ static queryId = "GetClientsByIds";
68
+ static queryItemType = "Client";
69
+ queryId = "GetClientsByIds";
70
+ queryItemType = "Client";
71
+ query;
72
+ constructor(args) {
73
+ this.query = args;
74
+ }
75
+ }
76
+ export class GetAllClients {
77
+ static queryId = "GetAllClients";
78
+ static queryItemType = "Client";
79
+ queryId = "GetAllClients";
80
+ queryItemType = "Client";
81
+ query;
82
+ constructor(args) {
83
+ this.query = args;
84
+ }
85
+ }
86
+ // View classes
87
+ // Report classes
88
+ export class CountAllServers {
89
+ static reportId = "CountAllServers";
90
+ reportId = "CountAllServers";
97
91
  report;
98
92
  constructor(args) {
99
93
  this.report = args;
100
94
  }
101
95
  }
102
- export class CountAllClients {
103
- static reportId = "CountAllClients";
104
- reportId = "CountAllClients";
96
+ export class GetServerById {
97
+ static reportId = "GetServerById";
98
+ reportId = "GetServerById";
105
99
  report;
106
100
  constructor(args) {
107
101
  this.report = args;
108
102
  }
109
103
  }
110
- export class GetClientById {
111
- static reportId = "GetClientById";
112
- reportId = "GetClientById";
104
+ export class CountServers {
105
+ static reportId = "CountServers";
106
+ reportId = "CountServers";
113
107
  report;
114
108
  constructor(args) {
115
109
  this.report = args;
116
110
  }
117
111
  }
118
- export class CountClients {
119
- static reportId = "CountClients";
120
- reportId = "CountClients";
112
+ export class SearchServer {
113
+ static reportId = "SearchServer";
114
+ reportId = "SearchServer";
121
115
  report;
122
116
  constructor(args) {
123
117
  this.report = args;
124
118
  }
125
119
  }
126
- export class WindbackStatus {
127
- static reportId = "WindbackStatus";
128
- reportId = "WindbackStatus";
120
+ export class ServerStats {
121
+ static reportId = "ServerStats";
122
+ reportId = "ServerStats";
129
123
  report;
130
124
  constructor(args) {
131
125
  this.report = args;
132
126
  }
133
127
  }
134
- export class ClientStatus {
135
- static reportId = "ClientStatus";
136
- reportId = "ClientStatus";
128
+ export class ExportEntityTree {
129
+ static reportId = "ExportEntityTree";
130
+ reportId = "ExportEntityTree";
137
131
  report;
138
132
  constructor(args) {
139
133
  this.report = args;
@@ -219,106 +213,114 @@ export class GetPersistHealth {
219
213
  this.report = args;
220
214
  }
221
215
  }
222
- export class CountAllServers {
223
- static reportId = "CountAllServers";
224
- reportId = "CountAllServers";
216
+ export class CountAllClients {
217
+ static reportId = "CountAllClients";
218
+ reportId = "CountAllClients";
225
219
  report;
226
220
  constructor(args) {
227
221
  this.report = args;
228
222
  }
229
223
  }
230
- export class GetServerById {
231
- static reportId = "GetServerById";
232
- reportId = "GetServerById";
224
+ export class GetClientById {
225
+ static reportId = "GetClientById";
226
+ reportId = "GetClientById";
233
227
  report;
234
228
  constructor(args) {
235
229
  this.report = args;
236
230
  }
237
231
  }
238
- export class CountServers {
239
- static reportId = "CountServers";
240
- reportId = "CountServers";
232
+ export class CountClients {
233
+ static reportId = "CountClients";
234
+ reportId = "CountClients";
241
235
  report;
242
236
  constructor(args) {
243
237
  this.report = args;
244
238
  }
245
239
  }
246
- export class SearchServer {
247
- static reportId = "SearchServer";
248
- reportId = "SearchServer";
240
+ export class WindbackStatus {
241
+ static reportId = "WindbackStatus";
242
+ reportId = "WindbackStatus";
249
243
  report;
250
244
  constructor(args) {
251
245
  this.report = args;
252
246
  }
253
247
  }
254
- export class ServerStats {
255
- static reportId = "ServerStats";
256
- reportId = "ServerStats";
248
+ export class ClientStatus {
249
+ static reportId = "ClientStatus";
250
+ reportId = "ClientStatus";
251
+ report;
252
+ constructor(args) {
253
+ this.report = args;
254
+ }
255
+ }
256
+ export class EntitySearch {
257
+ static reportId = "EntitySearch";
258
+ reportId = "EntitySearch";
257
259
  report;
258
260
  constructor(args) {
259
261
  this.report = args;
260
262
  }
261
263
  }
262
264
  // Command classes
263
- export class DeleteClient {
264
- static commandId = "DeleteClient";
265
- commandId = "DeleteClient";
265
+ export class DeleteServer {
266
+ static commandId = "DeleteServer";
267
+ commandId = "DeleteServer";
266
268
  command;
267
269
  constructor(args) {
268
270
  this.command = args;
269
271
  }
270
272
  }
271
- export class SetClientWindbackTime {
272
- static commandId = "SetClientWindbackTime";
273
- commandId = "SetClientWindbackTime";
273
+ export class DeleteServers {
274
+ static commandId = "DeleteServers";
275
+ commandId = "DeleteServers";
274
276
  command;
275
277
  constructor(args) {
276
278
  this.command = args;
277
279
  }
278
280
  }
279
- export class ClearClientWindbackTime {
280
- static commandId = "ClearClientWindbackTime";
281
- commandId = "ClearClientWindbackTime";
281
+ export class SetLogLevel {
282
+ static commandId = "SetLogLevel";
283
+ commandId = "SetLogLevel";
282
284
  command;
283
285
  constructor(args) {
284
286
  this.command = args;
285
287
  }
286
288
  }
287
- export class DeleteClients {
288
- static commandId = "DeleteClients";
289
- commandId = "DeleteClients";
289
+ export class ImportItems {
290
+ static commandId = "ImportItems";
291
+ commandId = "ImportItems";
290
292
  command;
291
293
  constructor(args) {
292
294
  this.command = args;
293
295
  }
294
296
  }
295
- export class SetLogLevel {
296
- static commandId = "SetLogLevel";
297
- commandId = "SetLogLevel";
297
+ export class DeleteClient {
298
+ static commandId = "DeleteClient";
299
+ commandId = "DeleteClient";
298
300
  command;
299
301
  constructor(args) {
300
302
  this.command = args;
301
303
  }
302
304
  }
303
- export class ImportItems {
304
- static commandId = "ImportItems";
305
- commandId = "ImportItems";
305
+ export class SetClientWindbackTime {
306
+ static commandId = "SetClientWindbackTime";
307
+ commandId = "SetClientWindbackTime";
306
308
  command;
307
309
  constructor(args) {
308
310
  this.command = args;
309
311
  }
310
312
  }
311
- export class DeleteServer {
312
- static commandId = "DeleteServer";
313
- commandId = "DeleteServer";
313
+ export class ClearClientWindbackTime {
314
+ static commandId = "ClearClientWindbackTime";
315
+ commandId = "ClearClientWindbackTime";
314
316
  command;
315
317
  constructor(args) {
316
318
  this.command = args;
317
319
  }
318
320
  }
319
- export class DeleteServers {
320
- static commandId = "DeleteServers";
321
- commandId = "DeleteServers";
321
+ export class DeleteClients {
322
+ static commandId = "DeleteClients";
323
+ commandId = "DeleteClients";
322
324
  command;
323
325
  constructor(args) {
324
326
  this.command = args;
@@ -326,8 +328,8 @@ export class DeleteServers {
326
328
  }
327
329
  // Item constructors
328
330
  export const items = {
329
- Client: (args) => ({ item: args, itemType: "Client" }),
330
331
  Server: (args) => ({ item: args, itemType: "Server" }),
332
+ Client: (args) => ({ item: args, itemType: "Client" }),
331
333
  };
332
334
  // Message events
333
335
  export const MykoEvent = {
@@ -348,6 +350,7 @@ export const MykoEvent = {
348
350
  ViewCancel: "ws:m:view-cancel",
349
351
  ViewResponse: "ws:m:view-response",
350
352
  View: "ws:m:view",
353
+ QueryCursorWindow: "ws:m:query-cursor-window",
351
354
  QueryWindow: "ws:m:query-window",
352
355
  QueryCancel: "ws:m:query-cancel",
353
356
  QueryResponse: "ws:m:query-response",
@@ -0,0 +1,128 @@
1
+ import { type Observable } from 'rxjs';
2
+ import type { Command, CommandOptions, CommandResult, MykoClient, Query, QuerySelectionOptions, QueryCursorPageInfo, QueryCursorWindow, QueryWindow, QueryWindowInfo, QueryWatchOptions, Report, ReportResult } from './client.js';
3
+ import { type LiveCollection, LiveIndex } from './live-collection.js';
4
+ type MethodResult<G, K extends PropertyKey> = K extends keyof G ? G[K] extends (...args: never[]) => infer R ? R : never : never;
5
+ type MethodArgs<G, K extends PropertyKey> = K extends keyof G ? G[K] extends (...args: infer A) => unknown ? A : never : never;
6
+ type MethodFirstArg<G, K extends PropertyKey> = MethodArgs<G, K> extends [
7
+ infer A,
8
+ ...unknown[]
9
+ ] ? A : never;
10
+ type MethodSecondArg<G, K extends PropertyKey> = MethodArgs<G, K> extends [
11
+ unknown,
12
+ infer B,
13
+ ...unknown[]
14
+ ] ? B : never;
15
+ type MethodThirdArg<G, K extends PropertyKey> = MethodArgs<G, K> extends [
16
+ unknown,
17
+ unknown,
18
+ infer C,
19
+ ...unknown[]
20
+ ] ? C : never;
21
+ type QueryEntity<Q> = Q extends Query<infer T> ? T extends {
22
+ id: string;
23
+ } ? T : never : never;
24
+ type QueryState<Q> = Observable<LiveCollection<QueryEntity<Q>>>;
25
+ type QueryIndexState<Q, K> = Observable<LiveIndex<K, QueryEntity<Q>>>;
26
+ type SelectQueryState<Q> = <S>(select: (state: LiveCollection<QueryEntity<Q>>) => S, options?: QuerySelectionOptions<S>) => Observable<S>;
27
+ type QueryItemState<Q> = Observable<QueryEntity<Q> | undefined>;
28
+ /** Mutable bounded graph query backed by the ordinary query-window protocol. */
29
+ export type WindowedGraphQuery<Q> = {
30
+ tx: string;
31
+ results$: Observable<QueryEntity<Q>[]>;
32
+ windowInfo$: Observable<QueryWindowInfo>;
33
+ setWindow: (window: QueryWindow | null) => void;
34
+ };
35
+ export type CursorGraphQuery<Q> = {
36
+ tx: string;
37
+ results$: Observable<QueryEntity<Q>[]>;
38
+ pageInfo$: Observable<QueryCursorPageInfo>;
39
+ setWindow: (window: QueryCursorWindow) => void;
40
+ firstPage: () => void;
41
+ };
42
+ /** One edge paired with the currently-live entity at its opposite endpoint. */
43
+ export type LiveConnection<Edge, Entity> = {
44
+ edge: Edge;
45
+ entity: Entity;
46
+ };
47
+ export type GraphDescriptorSchema = {
48
+ pairProjection: 'intersectAdjacency' | 'eager';
49
+ aAdjacency: 'demandDriven' | 'eager';
50
+ bAdjacency: 'demandDriven' | 'eager';
51
+ };
52
+ /** Static execution strategy derived from the generated graph schema. */
53
+ export type GraphQueryPlan = {
54
+ readonly strategy: 'eagerEndpoint' | 'eagerPair' | 'adjacencyFilter' | 'demandDrivenScan' | 'unknown';
55
+ readonly initialization: 'indexLookup' | 'canonicalScan' | 'unknown';
56
+ readonly liveUpdates: 'routed' | 'unknown';
57
+ readonly windowing: 'pushdown' | 'materialized' | 'unknown';
58
+ readonly reason: string;
59
+ };
60
+ type ReportState<R> = R extends Report<unknown> ? Observable<ReportResult<R>> : never;
61
+ type CommandPromise<C> = C extends Command<unknown> ? Promise<CommandResult<C>> : never;
62
+ type RelatedScope<G, EdgeKey extends PropertyKey, K extends PropertyKey, Name extends string> = K extends keyof G ? {
63
+ [P in Name]: (options?: QueryWatchOptions) => QueryState<MethodResult<G, K>>;
64
+ } & {
65
+ [P in 'connections']: (relatedId: (edge: QueryEntity<MethodResult<G, EdgeKey>>) => string, options?: QueryWatchOptions) => Observable<ReadonlyArray<LiveConnection<QueryEntity<MethodResult<G, EdgeKey>>, QueryEntity<MethodResult<G, K>>>>>;
66
+ } & {
67
+ [P in `${Name}Windowed`]: (window: QueryWindow) => WindowedGraphQuery<MethodResult<G, K>>;
68
+ } & {
69
+ [P in `select${Capitalize<Name>}`]: SelectQueryState<MethodResult<G, K>>;
70
+ } & {
71
+ [P in Name extends 'targets' ? 'target' : 'source']: (id: string, options?: QueryWatchOptions) => QueryItemState<MethodResult<G, K>>;
72
+ } & {
73
+ [P in Name extends 'targets' ? 'hasTarget' : 'hasSource']: (id: string, options?: QueryWatchOptions) => Observable<boolean>;
74
+ } : object;
75
+ type SyncScope<G, K extends PropertyKey> = K extends keyof G ? MethodArgs<G, K> extends [unknown, infer Edges] ? {
76
+ sync: (edges: Edges, options?: CommandOptions) => CommandPromise<MethodResult<G, K>>;
77
+ } : MethodArgs<G, K> extends [unknown, infer Scope, infer Edges] ? {
78
+ sync: (edges: Edges, scope: Scope, options?: CommandOptions) => CommandPromise<MethodResult<G, K>>;
79
+ } : object : object;
80
+ type EndpointScope<G, EdgeKey extends PropertyKey, ExactIdsKey extends PropertyKey, RelatedKey extends PropertyKey, RelatedName extends string, CountKey extends PropertyKey, TraversalKey extends PropertyKey, SyncKey extends PropertyKey> = {
81
+ readonly plan: GraphQueryPlan;
82
+ edges: (options?: QueryWatchOptions) => QueryState<MethodResult<G, EdgeKey>>;
83
+ selectEdges: SelectQueryState<MethodResult<G, EdgeKey>>;
84
+ edge: (id: string, options?: QueryWatchOptions) => QueryItemState<MethodResult<G, EdgeKey>>;
85
+ hasEdge: (id: string, options?: QueryWatchOptions) => Observable<boolean>;
86
+ edgesWindowed: (window: QueryWindow) => WindowedGraphQuery<MethodResult<G, EdgeKey>>;
87
+ edgesCursor: (limit: number) => CursorGraphQuery<MethodResult<G, EdgeKey>>;
88
+ edgesBy: <K>(keyOf: (edge: QueryEntity<MethodResult<G, EdgeKey>>) => K, options?: QueryWatchOptions) => QueryIndexState<MethodResult<G, EdgeKey>, K>;
89
+ } & (ExactIdsKey extends keyof G ? {
90
+ edgesByIds: (ids: MethodSecondArg<G, ExactIdsKey>, options?: QueryWatchOptions) => QueryState<MethodResult<G, ExactIdsKey>>;
91
+ } : object) & (CountKey extends keyof G ? {
92
+ count: () => ReportState<MethodResult<G, CountKey>>;
93
+ } : object) & (TraversalKey extends keyof G ? {
94
+ traverse: (options: MethodSecondArg<G, TraversalKey>) => ReportState<MethodResult<G, TraversalKey>>;
95
+ } : object) & SyncScope<G, SyncKey> & RelatedScope<G, EdgeKey, RelatedKey, RelatedName>;
96
+ type BetweenScope<G> = {
97
+ readonly plan: GraphQueryPlan;
98
+ edges: (options?: QueryWatchOptions) => QueryState<MethodResult<G, 'between'>>;
99
+ selectEdges: SelectQueryState<MethodResult<G, 'between'>>;
100
+ edge: (id: string, options?: QueryWatchOptions) => QueryItemState<MethodResult<G, 'between'>>;
101
+ hasEdge: (id: string, options?: QueryWatchOptions) => Observable<boolean>;
102
+ edgesWindowed: (window: QueryWindow) => WindowedGraphQuery<MethodResult<G, 'between'>>;
103
+ edgesCursor: (limit: number) => CursorGraphQuery<MethodResult<G, 'between'>>;
104
+ count: () => ReportState<MethodResult<G, 'countBetween'>>;
105
+ exists: () => ReportState<MethodResult<G, 'existsBetween'>>;
106
+ } & ('betweenIds' extends keyof G ? {
107
+ edgesByIds: (ids: MethodThirdArg<G, 'betweenIds'>, options?: QueryWatchOptions) => QueryState<MethodResult<G, 'betweenIds'>>;
108
+ } : object);
109
+ type BatchScopes<G> = 'fromMany' extends keyof G ? {
110
+ fromMany: (endpoints: MethodFirstArg<G, 'fromMany'>) => EndpointScope<G, 'fromMany', never, 'targetsFromMany', 'targets', never, never, never>;
111
+ toMany: (endpoints: MethodFirstArg<G, 'toMany'>) => EndpointScope<G, 'toMany', never, 'sourcesToMany', 'sources', never, never, never>;
112
+ } : object;
113
+ /** Client-bound facade over one generated `*Graph` descriptor. */
114
+ export type BoundGraph<G> = {
115
+ readonly schema: GraphDescriptorSchema | null;
116
+ from: (endpoint: MethodFirstArg<G, 'from'>) => EndpointScope<G, 'from', 'fromIds', 'targetsFrom', 'targets', 'countFrom', 'traverseFrom', 'syncFrom'>;
117
+ to: (endpoint: MethodFirstArg<G, 'to'>) => EndpointScope<G, 'to', 'toIds', 'sourcesTo', 'sources', 'countTo', 'traverseTo', 'syncTo'>;
118
+ between: (a: MethodFirstArg<G, 'between'>, b: MethodArgs<G, 'between'> extends [unknown, infer B, ...unknown[]] ? B : never) => BetweenScope<G>;
119
+ connect: (edge: MethodFirstArg<G, 'connect'>, options?: CommandOptions) => CommandPromise<MethodResult<G, 'connect'>>;
120
+ connectMany: (edges: MethodFirstArg<G, 'connectMany'>, options?: CommandOptions) => CommandPromise<MethodResult<G, 'connectMany'>>;
121
+ ensure: (edge: MethodFirstArg<G, 'ensure'>, options?: CommandOptions) => CommandPromise<MethodResult<G, 'ensure'>>;
122
+ disconnect: (id: MethodFirstArg<G, 'disconnect'>, options?: CommandOptions) => CommandPromise<MethodResult<G, 'disconnect'>>;
123
+ disconnectMany: (ids: MethodFirstArg<G, 'disconnectMany'>, options?: CommandOptions) => CommandPromise<MethodResult<G, 'disconnectMany'>>;
124
+ } & BatchScopes<G>;
125
+ /** Bind generated graph query/report/command factories to a client instance. */
126
+ export declare function bindGraph<G extends object>(client: MykoClient, graph: G): BoundGraph<G>;
127
+ export {};
128
+ //# sourceMappingURL=graph-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-client.d.ts","sourceRoot":"","sources":["../src/graph-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAE1D,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,KAAK,EACL,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,YAAY,EACb,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,KAAK,cAAc,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAErE,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,MAAM,CAAC,GAC3D,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,MAAM,CAAC,GACxC,CAAC,GACD,KAAK,GACP,KAAK,CAAA;AAET,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,MAAM,CAA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CAAC,CAAC,EAAE,gBAAgB,CAAC,EACxC,OAAO,CAAC,EAAE,cAAc,KACrB,cAAc,CAAC,YAAY,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAA;CACvD,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;AA0FlB,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EACxC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,CAAC,GACP,UAAU,CAAC,CAAC,CAAC,CAsRf"}
@@ -0,0 +1,192 @@
1
+ import { combineLatest, map } from 'rxjs';
2
+ import { LiveIndex } from './live-collection.js';
3
+ function descriptorSchema(graph) {
4
+ const schema = graph.$schema;
5
+ if (!schema || typeof schema !== 'object')
6
+ return null;
7
+ const candidate = schema;
8
+ if ((candidate.pairProjection !== 'intersectAdjacency' &&
9
+ candidate.pairProjection !== 'eager') ||
10
+ (candidate.aAdjacency !== 'demandDriven' &&
11
+ candidate.aAdjacency !== 'eager') ||
12
+ (candidate.bAdjacency !== 'demandDriven' &&
13
+ candidate.bAdjacency !== 'eager')) {
14
+ return null;
15
+ }
16
+ return candidate;
17
+ }
18
+ function endpointPlan(schema, position) {
19
+ if (!schema) {
20
+ return {
21
+ strategy: 'unknown',
22
+ initialization: 'unknown',
23
+ liveUpdates: 'unknown',
24
+ windowing: 'unknown',
25
+ reason: 'This graph descriptor predates generated schema metadata.',
26
+ };
27
+ }
28
+ const adjacency = position === 'a' ? schema.aAdjacency : schema.bAdjacency;
29
+ if (adjacency === 'eager') {
30
+ return {
31
+ strategy: 'eagerEndpoint',
32
+ initialization: 'indexLookup',
33
+ liveUpdates: 'routed',
34
+ windowing: 'pushdown',
35
+ reason: `Endpoint ${position.toUpperCase()} has an eager adjacency projection.`,
36
+ };
37
+ }
38
+ return {
39
+ strategy: 'demandDrivenScan',
40
+ initialization: 'canonicalScan',
41
+ liveUpdates: 'routed',
42
+ windowing: 'materialized',
43
+ reason: `Endpoint ${position.toUpperCase()} is demand-driven; initialization scans canonical edges.`,
44
+ };
45
+ }
46
+ function pairPlan(schema) {
47
+ if (!schema)
48
+ return endpointPlan(null, 'a');
49
+ if (schema.pairProjection === 'eager') {
50
+ return {
51
+ strategy: 'eagerPair',
52
+ initialization: 'indexLookup',
53
+ liveUpdates: 'routed',
54
+ windowing: 'pushdown',
55
+ reason: 'Exact endpoint pairs have an eager pair projection.',
56
+ };
57
+ }
58
+ if (schema.aAdjacency === 'eager' || schema.bAdjacency === 'eager') {
59
+ return {
60
+ strategy: 'adjacencyFilter',
61
+ initialization: 'indexLookup',
62
+ liveUpdates: 'routed',
63
+ windowing: 'materialized',
64
+ reason: 'Exact pairs filter the available eager endpoint adjacency.',
65
+ };
66
+ }
67
+ return {
68
+ strategy: 'demandDrivenScan',
69
+ initialization: 'canonicalScan',
70
+ liveUpdates: 'routed',
71
+ windowing: 'materialized',
72
+ reason: 'Exact pairs have no eager projection; initialization scans canonical edges.',
73
+ };
74
+ }
75
+ function factory(graph, key) {
76
+ const candidate = graph[key];
77
+ if (typeof candidate !== 'function') {
78
+ throw new TypeError(`Graph helper '${key}' is not available`);
79
+ }
80
+ return candidate;
81
+ }
82
+ /** Bind generated graph query/report/command factories to a client instance. */
83
+ export function bindGraph(client, graph) {
84
+ const schema = descriptorSchema(graph);
85
+ const plans = Object.freeze({
86
+ a: Object.freeze(endpointPlan(schema, 'a')),
87
+ b: Object.freeze(endpointPlan(schema, 'b')),
88
+ pair: Object.freeze(pairPlan(schema)),
89
+ });
90
+ const queryState = (key, args, options) => client.watchQueryState(factory(graph, key)(...args), options);
91
+ const reportState = (key, args) => client.watchReport(factory(graph, key)(...args));
92
+ const querySelection = (key, args, select, options) => client.watchQuerySelection(factory(graph, key)(...args), select, options);
93
+ const queryItem = (key, args, id, options) => client.watchQueryItem(factory(graph, key)(...args), id, options);
94
+ const queryHas = (key, args, id, options) => client.watchQueryHas(factory(graph, key)(...args), id, options);
95
+ const command = (key, args, options) => client.sendCommand(factory(graph, key)(...args), options);
96
+ const windowed = (key, args, window) => client.watchQueryWindowed(factory(graph, key)(...args), { window });
97
+ const cursor = (key, args, limit) => client.watchQueryCursor(factory(graph, key)(...args), limit);
98
+ const queryIndex = (key, args, keyOf, options) => {
99
+ const index = new LiveIndex(keyOf);
100
+ return queryState(key, args, options).pipe(map((state) => index.update(state)));
101
+ };
102
+ const endpoint = (edgeKey, exactEdgeKey, exactIdsKey, relatedKey, relatedName, countKey, traversalKey, syncKey, args, plan) => {
103
+ const exactEdgeQuery = (id) => exactEdgeKey && exactEdgeKey in graph
104
+ ? { key: exactEdgeKey, args: [...args, id] }
105
+ : { key: edgeKey, args };
106
+ const scope = {
107
+ plan,
108
+ edges: (options) => queryState(edgeKey, args, options),
109
+ selectEdges: (select, options) => querySelection(edgeKey, args, select, options),
110
+ edge: (id, options) => {
111
+ const exact = exactEdgeQuery(id);
112
+ return queryItem(exact.key, exact.args, id, options);
113
+ },
114
+ hasEdge: (id, options) => {
115
+ const exact = exactEdgeQuery(id);
116
+ return queryHas(exact.key, exact.args, id, options);
117
+ },
118
+ edgesWindowed: (window) => windowed(edgeKey, args, window),
119
+ edgesCursor: (limit) => cursor(edgeKey, args, limit),
120
+ edgesBy: (keyOf, options) => queryIndex(edgeKey, args, keyOf, options),
121
+ };
122
+ if (exactIdsKey && exactIdsKey in graph) {
123
+ scope.edgesByIds = (ids, options) => queryState(exactIdsKey, [...args, ids], options);
124
+ }
125
+ if (relatedKey in graph) {
126
+ const capitalizedName = relatedName === 'targets' ? 'Targets' : 'Sources';
127
+ const singularName = relatedName === 'targets' ? 'target' : 'source';
128
+ scope[relatedName] = (options) => queryState(relatedKey, args, options);
129
+ scope[`select${capitalizedName}`] = (select, options) => querySelection(relatedKey, args, select, options);
130
+ scope[singularName] = (id, options) => queryItem(relatedKey, args, id, options);
131
+ scope[`has${capitalizedName.slice(0, -1)}`] = (id, options) => queryHas(relatedKey, args, id, options);
132
+ scope[`${relatedName}Windowed`] = (window) => windowed(relatedKey, args, window);
133
+ scope.connections = (relatedId, options) => combineLatest([
134
+ queryState(edgeKey, args, options),
135
+ queryState(relatedKey, args, options),
136
+ ]).pipe(map(([edges, entities]) => edges.toArray().flatMap((edge) => {
137
+ const entity = entities.get(relatedId(edge));
138
+ return entity ? [{ edge, entity }] : [];
139
+ })));
140
+ }
141
+ if (countKey) {
142
+ scope.count = () => reportState(countKey, args);
143
+ }
144
+ if (traversalKey && traversalKey in graph) {
145
+ scope.traverse = (options) => reportState(traversalKey, [...args, options]);
146
+ }
147
+ if (syncKey && syncKey in graph) {
148
+ scope.sync = (edges, scopeOrOptions, maybeOptions) => {
149
+ const syncFactory = factory(graph, syncKey);
150
+ return syncFactory.length === 2
151
+ ? command(syncKey, [args[0], edges], scopeOrOptions)
152
+ : command(syncKey, [args[0], scopeOrOptions, edges], maybeOptions);
153
+ };
154
+ }
155
+ return scope;
156
+ };
157
+ const bound = {
158
+ schema,
159
+ from: (value) => endpoint('from', 'fromId', 'fromIds', 'targetsFrom', 'targets', 'countFrom', 'traverseFrom', 'syncFrom', [value], plans.a),
160
+ to: (value) => endpoint('to', 'toId', 'toIds', 'sourcesTo', 'sources', 'countTo', 'traverseTo', 'syncTo', [value], plans.b),
161
+ between: (a, b) => ({
162
+ plan: plans.pair,
163
+ edges: (options) => queryState('between', [a, b], options),
164
+ selectEdges: (select, options) => querySelection('between', [a, b], select, options),
165
+ edge: (id, options) => 'betweenId' in graph
166
+ ? queryItem('betweenId', [a, b, id], id, options)
167
+ : queryItem('between', [a, b], id, options),
168
+ hasEdge: (id, options) => 'betweenId' in graph
169
+ ? queryHas('betweenId', [a, b, id], id, options)
170
+ : queryHas('between', [a, b], id, options),
171
+ edgesWindowed: (window) => windowed('between', [a, b], window),
172
+ edgesCursor: (limit) => cursor('between', [a, b], limit),
173
+ count: () => reportState('countBetween', [a, b]),
174
+ exists: () => reportState('existsBetween', [a, b]),
175
+ ...('betweenIds' in graph
176
+ ? {
177
+ edgesByIds: (ids, options) => queryState('betweenIds', [a, b, ids], options),
178
+ }
179
+ : {}),
180
+ }),
181
+ connect: (edge, options) => command('connect', [edge], options),
182
+ connectMany: (edges, options) => command('connectMany', [edges], options),
183
+ ensure: (edge, options) => command('ensure', [edge], options),
184
+ disconnect: (id, options) => command('disconnect', [id], options),
185
+ disconnectMany: (ids, options) => command('disconnectMany', [ids], options),
186
+ };
187
+ if ('fromMany' in graph) {
188
+ bound.fromMany = (values) => endpoint('fromMany', null, null, 'targetsFromMany', 'targets', null, null, null, [values], plans.a);
189
+ bound.toMany = (values) => endpoint('toMany', null, null, 'sourcesToMany', 'sources', null, null, null, [values], plans.b);
190
+ }
191
+ return bound;
192
+ }