@ontahi/react 0.1.0-alpha.4 → 0.1.0-alpha.5

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 (35) hide show
  1. package/README.md +80 -2
  2. package/dist/actions/operation-bridge.d.ts.map +1 -1
  3. package/dist/actions/operation-bridge.js +1 -1
  4. package/dist/actions/operation-bridge.js.map +1 -1
  5. package/dist/graph/context.d.ts +6 -1
  6. package/dist/graph/context.d.ts.map +1 -1
  7. package/dist/graph/context.js +16 -6
  8. package/dist/graph/context.js.map +1 -1
  9. package/dist/graph/executor.d.ts +10 -7
  10. package/dist/graph/executor.d.ts.map +1 -1
  11. package/dist/graph/executor.js.map +1 -1
  12. package/dist/graph/fetch-graph-client.d.ts +22 -0
  13. package/dist/graph/fetch-graph-client.d.ts.map +1 -0
  14. package/dist/graph/fetch-graph-client.js +43 -0
  15. package/dist/graph/fetch-graph-client.js.map +1 -0
  16. package/dist/graph/fetch-graph-read-executor.d.ts +8 -0
  17. package/dist/graph/fetch-graph-read-executor.d.ts.map +1 -0
  18. package/dist/graph/fetch-graph-read-executor.js +37 -0
  19. package/dist/graph/fetch-graph-read-executor.js.map +1 -0
  20. package/dist/graph/graph-hooks.d.ts +2 -2
  21. package/dist/graph/graph-hooks.d.ts.map +1 -1
  22. package/dist/graph/graph-hooks.js +39 -16
  23. package/dist/graph/graph-hooks.js.map +1 -1
  24. package/dist/graph/index.d.ts +2 -0
  25. package/dist/graph/index.d.ts.map +1 -1
  26. package/dist/graph/index.js +2 -0
  27. package/dist/graph/index.js.map +1 -1
  28. package/dist/graph/operation-hooks.d.ts +2 -1
  29. package/dist/graph/operation-hooks.d.ts.map +1 -1
  30. package/dist/graph/operation-hooks.js +31 -13
  31. package/dist/graph/operation-hooks.js.map +1 -1
  32. package/dist/graph/operation-types.d.ts +7 -1
  33. package/dist/graph/operation-types.d.ts.map +1 -1
  34. package/dist/graph/operation-types.js.map +1 -1
  35. package/package.json +2 -2
package/README.md CHANGED
@@ -5,8 +5,86 @@ Non-visual React integration for Ontahi applications.
5
5
  This package depends on `@ontahi/core`. It owns React hooks and bridge adapters that are generic to React clients:
6
6
 
7
7
  1. `@ontahi/react/actions`: action execution hooks, React Query integration, and operation bridge adapters.
8
- 2. `@ontahi/react/graph`: graph runtime provider, client cache hooks, and operation bridge adapter lookup hooks.
8
+ 2. `@ontahi/react/graph`: graph runtime provider, Query and Command hooks, Fetch graph-read execution,
9
+ client cache hooks, and operation bridge adapter lookup hooks.
9
10
 
10
11
  The generic action metadata and result protocol comes from `@ontahi/core/runtime/actions`; Next.js-specific transport remains in `@ontahi/runtime-nextjs`.
11
12
 
12
- BookOps-specific graph declarations, domain entities, runtime assembly, and application policy stay in the host application. Reusable reflective UI lives in `@ontahi/explorer-react`; BookOps contributes only host routes, access control, theme/auth composition, and app-specific UI enrichments.
13
+ Application-specific graph declarations, domain entities, runtime assembly, and policy stay in the
14
+ host application. Reusable reflective UI lives in `@ontahi/explorer-react`; hosts contribute their
15
+ own routes, access control, theme/auth composition, and application-specific UI enrichments.
16
+
17
+ Start with the end-to-end [Application Data Access](../../docs/application-data-access.md) guide for
18
+ the recommended server, codegen, and React composition. This README is the package-level reference.
19
+
20
+ Projectable Operations keep population on the server and shape in the caller:
21
+
22
+ ```ts
23
+ const TripList = Trip.view('TripList', { id: true, driver: { name: true } });
24
+ const operation = Trip.domain.available.as(TripList);
25
+ const result = useOperationQuery(operation, input);
26
+ ```
27
+
28
+ React cache identity includes the transported View AST. The View remains client-owned and does not
29
+ need a server registry entry.
30
+
31
+ Caller-authored Queries can use the remote graph-read protocol directly:
32
+
33
+ ```tsx
34
+ const TodoListItem = TodoItem.view('TodoListItem', { id: true, title: true });
35
+ const openTodos = TodoItem.all()
36
+ .where(todo => todo.completed.eq(false))
37
+ .as(TodoListItem);
38
+
39
+ <OntahiGraphProvider
40
+ runtime={{ name: 'browser' }}
41
+ identity={{ principal: session.principal ?? null, cacheScope: session.workspaceId }}
42
+ >
43
+ <TodoApp />
44
+ </OntahiGraphProvider>;
45
+
46
+ const todos = useGraphQuery(openTodos);
47
+ const total = useGraphQuery(openTodos.count());
48
+ const first = useGraphQuery(openTodos.first());
49
+ ```
50
+
51
+ `OntahiGraphProvider` installs a conventional same-origin Fetch client by default. It connects
52
+ graph reads to `/graph/reads`, Operations and task snapshots to `/operations`, and reflected
53
+ Explorer data to `/explorer/entities`. These capabilities are lazy: declaring the provider does
54
+ not issue a request until the application uses one of them.
55
+
56
+ Hosts can replace any individual capability through the existing provider props, install a
57
+ configured client with `client={createFetchGraphClient(...)}`, or set `client={false}` for a fully
58
+ explicit provider. Server routes, read policies, and authorization remain opt-in and authoritative;
59
+ the default removes client wiring, not the server security boundary.
60
+
61
+ Generated client Entities expose portable `all()` and `where(...)` Query entry points. A Query
62
+ returns many rows by default; terminal `first()`, `one()`, `count()`, and `exists()` expressions
63
+ make the result contract explicit and let `useGraphQuery` select the executor method. `one()` is
64
+ strict cardinality, while `first()` may return `null`.
65
+
66
+ For transport-safe Queries, React derives a canonical key from the Entity, Selection, View,
67
+ ordering, limit, cardinality, and read intent. The key is also partitioned by the provider's
68
+ `ExecutionIdentity`. `principal` and optional JSON-safe `cacheScope` describe distributed client
69
+ state; they are not credentials and are never trusted for server authorization. The authoritative
70
+ runtime still derives its Principal from the request. Hosts should change identity when login,
71
+ logout, service identity, tenant, or workspace changes. An explicit `queryKey` remains available
72
+ for lower-level reads that cannot be encoded by the graph-read protocol, and the legacy explicit
73
+ `mode` API remains compatible.
74
+
75
+ First-class Operation invocations bind render-owned input without losing the declaration form:
76
+
77
+ ```ts
78
+ const createTodo = useOperation(TodoItem.domain.create);
79
+ const completeVisible = useOperation(TodoItem.domain.complete({ todos: visibleTodos }));
80
+
81
+ await createTodo.executeAsync(newTodo);
82
+ await completeVisible.executeAsync();
83
+ ```
84
+
85
+ The bound invocation always uses the latest render input. Passing the Operation declaration itself
86
+ keeps the lower-level reusable mutation form, where each execution supplies its input.
87
+
88
+ The Fetch executor sends only the canonical graph-read request. Credentials and other trusted
89
+ request state remain in Fetch initialization and are never embedded in the Query AST. Remote
90
+ Commands remain unsupported until the graph Command protocol and its policy boundary are defined.
@@ -1 +1 @@
1
- {"version":3,"file":"operation-bridge.d.ts","sourceRoot":"","sources":["../../src/actions/operation-bridge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gCAAgC,EAChC,aAAa,EAEd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EACf,YAAY,EACb,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE3F,YAAY,EAAE,yBAAyB,EAAE,CAAC;AAE1C,MAAM,MAAM,2BAA2B,CAAC,KAAK,IAAI,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAAG;IAChF,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,MAAM,EAAE,KAAK,IAAI,CACjD,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,2BAA2B,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE5E,MAAM,MAAM,0BAA0B,CAAC,QAAQ,GAAG,OAAO,IAAI,OAAO,CAClE,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC5C;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CACb,CAAC;AAEF,qBAAa,8BAA8B,CAAC,QAAQ,GAAG,OAAO,CAAE,SAAQ,KAAK;IAI/D,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC,QAAQ,CAAC;IAHjE,QAAQ,CAAC,IAAI,oCAAoC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F,eAAO,MAAM,2CAA2C,GAAI,MAAM,EAAE,KAAK,EACvE,WAAW,oBAAoB,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9C,OAAO,MAAM,KACZ,cAAc,EAUhB,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAC3C,MAAM,EAAE,KAAK,EACZ,cAAc,8BAA8B,EAC5C,WAAW,oBAAoB,CAAC,MAAM,EAAE,KAAK,CAAC,KAC7C,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAMwC,CAAC;AAEjF,eAAO,MAAM,kCAAkC,GAAI,MAAM,EAAE,KAAK,EAC9D,WAAW,oBAAoB,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9C,QAAQ,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,EAC5C,SAAS;IACP,YAAY,EAAE,OAAO,CAAC;CACvB;;CAUC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import { normalizeEntityRefQueryInput } from '@ontahi/core/data-graph';
3
3
  import { attachActionRuntime, getActionErrorMessage, hasActionError, } from '@ontahi/core/runtime/actions';
4
+ import { isRecord } from '@ontahi/core/value/object';
4
5
  export class OperationInvocationResultError extends Error {
5
6
  constructor(result) {
6
7
  super(result.message);
@@ -22,7 +23,6 @@ export class OperationInvocationResultError extends Error {
22
23
  };
23
24
  }
24
25
  }
25
- const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
26
26
  export const isOperationInvocationResult = (value) => isRecord(value) && typeof value.ok === 'boolean' && typeof value.kind === 'string';
27
27
  export const operationBridgeErrored = (message) => ({
28
28
  ok: false,
@@ -1 +1 @@
1
- {"version":3,"file":"operation-bridge.js","sourceRoot":"","sources":["../../src/actions/operation-bridge.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAOb,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,GAEf,MAAM,8BAA8B,CAAC;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AAE,CACF,mBAAmB,CAAC,MAAM,EAAE;IAC1B,OAAO,EAAE,SAAS,CAAC,UAAU;IAC7B,UAAU,EAAE,SAAS,CAAC,IAAI;IAC1B,YAAY,EAAE,OAAO,CAAC,YAAY;IAClC,cAAc,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,CAAU;IAC/D,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,8BAA8B,CAAC,SAAS,EAAE,KAAe,CAAC;IAChF,oBAAoB,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAClC,2CAA2C,CAAC,SAAS,EAAE,KAAe,CAAC;CAC1E,CAAC,CAAC","sourcesContent":["'use client';\n\nimport type {\n ClientDomainOperationDeclaration,\n EntityViewAst,\n QueryKeySegment,\n} from '@ontahi/core/data-graph';\nimport { normalizeEntityRefQueryInput } from '@ontahi/core/data-graph';\nimport {\n attachActionRuntime,\n getActionErrorMessage,\n hasActionError,\n type ActionQueryKey,\n} from '@ontahi/core/runtime/actions';\nimport type {\n OperationInvocationResult,\n TaskRunIdentity,\n TaskSnapshot,\n} from '@ontahi/core/runtime/contracts';\nimport type { QueryKey, UseQueryResult } from '@tanstack/react-query';\n\nimport type { ActionResultLike, UseActionOptions, UseActionResult } from './use-action.js';\n\nexport type { OperationInvocationResult };\n\nexport type OperationBridgeActionResult<TData> = Omit<ActionResultLike, 'data'> & {\n data?: TData;\n};\n\nexport type OperationBridgeAction<TInput, TData> = (\n input: TInput,\n) => Promise<OperationBridgeActionResult<OperationInvocationResult<TData>>>;\n\nexport type OperationInvocationFailure<TFailure = unknown> = Exclude<\n OperationInvocationResult<unknown, TFailure>,\n { ok: true }\n>;\n\nexport class OperationInvocationResultError<TFailure = unknown> extends Error {\n readonly name = 'OperationInvocationResultError';\n declare readonly cause?: unknown;\n\n constructor(readonly result: OperationInvocationFailure<TFailure>) {\n super(result.message);\n if (result.kind === 'failed') {\n Object.defineProperty(this, 'cause', {\n configurable: true,\n value: result.failure,\n });\n }\n }\n\n toJSON() {\n return {\n name: this.name,\n message: this.message,\n ...(this.cause === undefined ? {} : { cause: this.cause }),\n result: this.result,\n };\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport const isOperationInvocationResult = <TData = unknown, TFailure = unknown>(\n value: unknown,\n): value is OperationInvocationResult<TData, TFailure> =>\n isRecord(value) && typeof value.ok === 'boolean' && typeof value.kind === 'string';\n\nexport const operationBridgeErrored = (message: string): OperationInvocationResult => ({\n ok: false,\n kind: 'errored',\n executed: 'unknown',\n message,\n});\n\nexport const toOperationInvocationResult = <TData>(\n result: OperationBridgeActionResult<OperationInvocationResult<TData>>,\n): OperationInvocationResult<TData> => {\n if (hasActionError(result)) {\n return operationBridgeErrored(\n getActionErrorMessage(result),\n ) as OperationInvocationResult<TData>;\n }\n\n if (isOperationInvocationResult<TData>(result.data)) {\n return result.data;\n }\n\n if ('data' in result) {\n return {\n ok: true,\n kind: 'success',\n value: result.data as TData,\n };\n }\n\n return operationBridgeErrored(\n 'Graph operation bridge returned an invalid response.',\n ) as OperationInvocationResult<TData>;\n};\n\nexport const unwrapOperationInvocationValue = <TData>(\n result: OperationInvocationResult<TData>,\n): TData => {\n if (result.ok) {\n return result.value;\n }\n\n throw new OperationInvocationResultError(result);\n};\n\nexport type BridgedOperationLike<TInput, TData> = ClientDomainOperationDeclaration<\n TInput,\n TData\n> & {\n id: string;\n entityName: string;\n name: string;\n view?: EntityViewAst;\n};\n\nexport type RunDomainOperationBridgeAction = (input: {\n operationId: string;\n input: unknown;\n view?: EntityViewAst;\n}) => Promise<ActionResultLike>;\n\nexport type GraphPermission =\n | {\n allowed: true;\n }\n | {\n allowed: false;\n reason: string;\n message: string;\n };\n\nexport type CheckDomainOperationPermissionBridgeAction = (input: {\n operationId: string;\n input: unknown;\n}) => Promise<OperationBridgeActionResult<GraphPermission>>;\n\nexport type OperationBridgeAdapter<TAdapterName extends string = string> = {\n name: TAdapterName;\n getTaskSnapshot?: <TResult = unknown>(ref: TaskRunIdentity) => Promise<TaskSnapshot<TResult>>;\n useBridgeAction: <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n ) => OperationBridgeAction<TInput, TData>;\n useBridgeMutation: <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n options?: UseActionOptions<OperationBridgeAction<TInput, TData>> & {\n invalidateOnSuccess?: boolean;\n },\n ) => UseActionResult<OperationBridgeAction<TInput, TData>>;\n useBridgeQuery: <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n args: {\n input: TInput;\n key: QueryKey;\n },\n ) => UseQueryResult<TData, Error>;\n usePermission: <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n input: TInput,\n options?: {\n enabled?: boolean;\n queryKey?: QueryKey;\n },\n ) => UseQueryResult<GraphPermission, Error>;\n};\n\nexport type AnyOperationBridgeAdapter = OperationBridgeAdapter<string>;\n\nexport const resolveOperationBridgeQuerySpec = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n) => [operation.entityName, operation.name, ...(operation.bridge?.query ?? [])] as const;\n\nconst resolveOperationBridgeQueryKeySegment = <TInput, TData>(\n segment: QueryKeySegment<TInput>,\n operation: BridgedOperationLike<TInput, TData>,\n input: TInput,\n) =>\n typeof segment === 'function'\n ? segment(input, {\n input,\n operation,\n })\n : segment;\n\nexport const resolveOperationBridgeQueryKey = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n input: TInput,\n): ActionQueryKey => {\n const queryInput = normalizeEntityRefQueryInput(input, operation.inputRefs);\n\n return [\n operation.entityName,\n operation.name,\n ...(operation.view ? [operation.view] : []),\n ...(operation.bridge?.query?.map(segment =>\n resolveOperationBridgeQueryKeySegment(segment, operation, queryInput),\n ) ?? []),\n ];\n};\n\nexport const resolveOperationBridgeInvalidationQueryKeys = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n input: TInput,\n): ActionQueryKey[] => {\n const queryInput = normalizeEntityRefQueryInput(input, operation.inputRefs);\n\n return (\n operation.bridge?.invalidate?.map(querySpec =>\n querySpec.map(segment =>\n resolveOperationBridgeQueryKeySegment(segment, operation, queryInput),\n ),\n ) ?? []\n );\n};\n\nexport const createDomainOperationBridgeAction =\n <TInput, TData>(\n bridgeAction: RunDomainOperationBridgeAction,\n operation: BridgedOperationLike<TInput, TData>,\n ): OperationBridgeAction<TInput, TData> =>\n (input: TInput) =>\n bridgeAction({\n operationId: operation.id,\n input,\n ...(operation.view ? { view: operation.view } : {}),\n }) as Promise<OperationBridgeActionResult<OperationInvocationResult<TData>>>;\n\nexport const attachOperationBridgeActionRuntime = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n action: OperationBridgeAction<TInput, TData>,\n options: {\n requiresAuth: boolean;\n },\n) =>\n attachActionRuntime(action, {\n feature: operation.entityName,\n actionName: operation.name,\n requiresAuth: options.requiresAuth,\n queryKeyPrefix: [operation.entityName, operation.name] as const,\n getQueryKey: input => resolveOperationBridgeQueryKey(operation, input as TInput),\n getAffectedQueryKeys: ({ input }) =>\n resolveOperationBridgeInvalidationQueryKeys(operation, input as TInput),\n });\n"]}
1
+ {"version":3,"file":"operation-bridge.js","sourceRoot":"","sources":["../../src/actions/operation-bridge.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAOb,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,GAEf,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAoBrD,MAAM,OAAO,8BAAmD,SAAQ,KAAK;IAI3E,YAAqB,MAA4C;QAC/D,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QADH,WAAM,GAAN,MAAM,CAAsC;QAHxD,SAAI,GAAG,gCAAgC,CAAC;QAK/C,IAAI,MAAM,CAAC,IAAI,KAAK,QA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,SAAS,EAAE,KAAe,CAAC;CAC1E,CAAC,CAAC","sourcesContent":["'use client';\n\nimport type {\n ClientDomainOperationDeclaration,\n EntityViewAst,\n QueryKeySegment,\n} from '@ontahi/core/data-graph';\nimport { normalizeEntityRefQueryInput } from '@ontahi/core/data-graph';\nimport {\n attachActionRuntime,\n getActionErrorMessage,\n hasActionError,\n type ActionQueryKey,\n} from '@ontahi/core/runtime/actions';\nimport type {\n OperationInvocationResult,\n TaskRunIdentity,\n TaskSnapshot,\n} from '@ontahi/core/runtime/contracts';\nimport { isRecord } from '@ontahi/core/value/object';\nimport type { QueryKey, UseQueryResult } from '@tanstack/react-query';\n\nimport type { ActionResultLike, UseActionOptions, UseActionResult } from './use-action.js';\n\nexport type { OperationInvocationResult };\n\nexport type OperationBridgeActionResult<TData> = Omit<ActionResultLike, 'data'> & {\n data?: TData;\n};\n\nexport type OperationBridgeAction<TInput, TData> = (\n input: TInput,\n) => Promise<OperationBridgeActionResult<OperationInvocationResult<TData>>>;\n\nexport type OperationInvocationFailure<TFailure = unknown> = Exclude<\n OperationInvocationResult<unknown, TFailure>,\n { ok: true }\n>;\n\nexport class OperationInvocationResultError<TFailure = unknown> extends Error {\n readonly name = 'OperationInvocationResultError';\n declare readonly cause?: unknown;\n\n constructor(readonly result: OperationInvocationFailure<TFailure>) {\n super(result.message);\n if (result.kind === 'failed') {\n Object.defineProperty(this, 'cause', {\n configurable: true,\n value: result.failure,\n });\n }\n }\n\n toJSON() {\n return {\n name: this.name,\n message: this.message,\n ...(this.cause === undefined ? {} : { cause: this.cause }),\n result: this.result,\n };\n }\n}\n\nexport const isOperationInvocationResult = <TData = unknown, TFailure = unknown>(\n value: unknown,\n): value is OperationInvocationResult<TData, TFailure> =>\n isRecord(value) && typeof value.ok === 'boolean' && typeof value.kind === 'string';\n\nexport const operationBridgeErrored = (message: string): OperationInvocationResult => ({\n ok: false,\n kind: 'errored',\n executed: 'unknown',\n message,\n});\n\nexport const toOperationInvocationResult = <TData>(\n result: OperationBridgeActionResult<OperationInvocationResult<TData>>,\n): OperationInvocationResult<TData> => {\n if (hasActionError(result)) {\n return operationBridgeErrored(\n getActionErrorMessage(result),\n ) as OperationInvocationResult<TData>;\n }\n\n if (isOperationInvocationResult<TData>(result.data)) {\n return result.data;\n }\n\n if ('data' in result) {\n return {\n ok: true,\n kind: 'success',\n value: result.data as TData,\n };\n }\n\n return operationBridgeErrored(\n 'Graph operation bridge returned an invalid response.',\n ) as OperationInvocationResult<TData>;\n};\n\nexport const unwrapOperationInvocationValue = <TData>(\n result: OperationInvocationResult<TData>,\n): TData => {\n if (result.ok) {\n return result.value;\n }\n\n throw new OperationInvocationResultError(result);\n};\n\nexport type BridgedOperationLike<TInput, TData> = ClientDomainOperationDeclaration<\n TInput,\n TData\n> & {\n id: string;\n entityName: string;\n name: string;\n view?: EntityViewAst;\n};\n\nexport type RunDomainOperationBridgeAction = (input: {\n operationId: string;\n input: unknown;\n view?: EntityViewAst;\n}) => Promise<ActionResultLike>;\n\nexport type GraphPermission =\n | {\n allowed: true;\n }\n | {\n allowed: false;\n reason: string;\n message: string;\n };\n\nexport type CheckDomainOperationPermissionBridgeAction = (input: {\n operationId: string;\n input: unknown;\n}) => Promise<OperationBridgeActionResult<GraphPermission>>;\n\nexport type OperationBridgeAdapter<TAdapterName extends string = string> = {\n name: TAdapterName;\n getTaskSnapshot?: <TResult = unknown>(ref: TaskRunIdentity) => Promise<TaskSnapshot<TResult>>;\n useBridgeAction: <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n ) => OperationBridgeAction<TInput, TData>;\n useBridgeMutation: <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n options?: UseActionOptions<OperationBridgeAction<TInput, TData>> & {\n invalidateOnSuccess?: boolean;\n },\n ) => UseActionResult<OperationBridgeAction<TInput, TData>>;\n useBridgeQuery: <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n args: {\n input: TInput;\n key: QueryKey;\n },\n ) => UseQueryResult<TData, Error>;\n usePermission: <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n input: TInput,\n options?: {\n enabled?: boolean;\n queryKey?: QueryKey;\n },\n ) => UseQueryResult<GraphPermission, Error>;\n};\n\nexport type AnyOperationBridgeAdapter = OperationBridgeAdapter<string>;\n\nexport const resolveOperationBridgeQuerySpec = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n) => [operation.entityName, operation.name, ...(operation.bridge?.query ?? [])] as const;\n\nconst resolveOperationBridgeQueryKeySegment = <TInput, TData>(\n segment: QueryKeySegment<TInput>,\n operation: BridgedOperationLike<TInput, TData>,\n input: TInput,\n) =>\n typeof segment === 'function'\n ? segment(input, {\n input,\n operation,\n })\n : segment;\n\nexport const resolveOperationBridgeQueryKey = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n input: TInput,\n): ActionQueryKey => {\n const queryInput = normalizeEntityRefQueryInput(input, operation.inputRefs);\n\n return [\n operation.entityName,\n operation.name,\n ...(operation.view ? [operation.view] : []),\n ...(operation.bridge?.query?.map(segment =>\n resolveOperationBridgeQueryKeySegment(segment, operation, queryInput),\n ) ?? []),\n ];\n};\n\nexport const resolveOperationBridgeInvalidationQueryKeys = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n input: TInput,\n): ActionQueryKey[] => {\n const queryInput = normalizeEntityRefQueryInput(input, operation.inputRefs);\n\n return (\n operation.bridge?.invalidate?.map(querySpec =>\n querySpec.map(segment =>\n resolveOperationBridgeQueryKeySegment(segment, operation, queryInput),\n ),\n ) ?? []\n );\n};\n\nexport const createDomainOperationBridgeAction =\n <TInput, TData>(\n bridgeAction: RunDomainOperationBridgeAction,\n operation: BridgedOperationLike<TInput, TData>,\n ): OperationBridgeAction<TInput, TData> =>\n (input: TInput) =>\n bridgeAction({\n operationId: operation.id,\n input,\n ...(operation.view ? { view: operation.view } : {}),\n }) as Promise<OperationBridgeActionResult<OperationInvocationResult<TData>>>;\n\nexport const attachOperationBridgeActionRuntime = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n action: OperationBridgeAction<TInput, TData>,\n options: {\n requiresAuth: boolean;\n },\n) =>\n attachActionRuntime(action, {\n feature: operation.entityName,\n actionName: operation.name,\n requiresAuth: options.requiresAuth,\n queryKeyPrefix: [operation.entityName, operation.name] as const,\n getQueryKey: input => resolveOperationBridgeQueryKey(operation, input as TInput),\n getAffectedQueryKeys: ({ input }) =>\n resolveOperationBridgeInvalidationQueryKeys(operation, input as TInput),\n });\n"]}
@@ -1,19 +1,24 @@
1
1
  import { type GraphClientCache, type ReflectedEntityDataReader, type ReflectedOperationDescriptor, type ReflectedOperationInvoker } from '@ontahi/core/data-graph';
2
+ import { type ExecutionIdentity } from '@ontahi/core/runtime/identity';
2
3
  import { type ReactNode } from 'react';
3
4
  import type { AnyOperationBridgeAdapter } from '../actions/index.js';
4
5
  import type { ReactGraphExecutor } from './executor.js';
6
+ import { type OntahiGraphClient } from './fetch-graph-client.js';
5
7
  import { type ReflectedGraphOperationLike } from './reflected-operation-invoker.js';
6
8
  export type OntahiGraphProviderProps<TGraphRuntime = unknown, TReadOptions = unknown, TCommandOptions = TReadOptions> = {
7
9
  children: ReactNode;
8
10
  runtime: TGraphRuntime;
9
11
  graphExecutor?: ReactGraphExecutor<TReadOptions, TCommandOptions>;
12
+ client?: OntahiGraphClient<TReadOptions, TCommandOptions> | false;
10
13
  operationBridgeAdapters?: AnyOperationBridgeAdapter[];
11
14
  reflectedEntityDataReader?: ReflectedEntityDataReader;
12
15
  reflectedOperationInvoker?: ReflectedOperationInvoker;
13
16
  reflectedGraphOperations?: readonly ReflectedGraphOperationLike[];
14
17
  clientCache?: GraphClientCache;
18
+ identity?: ExecutionIdentity;
15
19
  };
16
- export declare function OntahiGraphProvider<TGraphRuntime = unknown, TReadOptions = unknown, TCommandOptions = TReadOptions>({ children, runtime, graphExecutor, operationBridgeAdapters, reflectedEntityDataReader, reflectedOperationInvoker, reflectedGraphOperations, clientCache, }: OntahiGraphProviderProps<TGraphRuntime, TReadOptions, TCommandOptions>): import("react/jsx-runtime").JSX.Element;
20
+ export declare function OntahiGraphProvider<TGraphRuntime = unknown, TReadOptions = unknown, TCommandOptions = TReadOptions>({ children, runtime, graphExecutor, client, operationBridgeAdapters, reflectedEntityDataReader, reflectedOperationInvoker, reflectedGraphOperations, clientCache, identity, }: OntahiGraphProviderProps<TGraphRuntime, TReadOptions, TCommandOptions>): import("react/jsx-runtime").JSX.Element;
21
+ export declare const useExecutionIdentity: () => ExecutionIdentity;
17
22
  export declare function useGraphRuntime<TGraphRuntime = unknown>(): TGraphRuntime;
18
23
  export declare function useGraphExecutor<TReadOptions = unknown, TCommandOptions = TReadOptions>(): ReactGraphExecutor<TReadOptions, TCommandOptions>;
19
24
  export declare function useGraphClientCache(): {
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/graph/context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC/B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,kCAAkC,CAAC;AAa1C,MAAM,MAAM,wBAAwB,CAClC,aAAa,GAAG,OAAO,EACvB,YAAY,GAAG,OAAO,EACtB,eAAe,GAAG,YAAY,IAC5B;IACF,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;IACvB,aAAa,CAAC,EAAE,kBAAkB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IAClE,uBAAuB,CAAC,EAAE,yBAAyB,EAAE,CAAC;IACtD,yBAAyB,CAAC,EAA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AAa,EAAE,YAAY,EAAE,eAAe,CAAC,2CA+CxE;AAED,eAAO,MAAM,oBAAoB,yBAA6C,CAAC;AAE/E,wBAAgB,eAAe,CAAC,aAAa,GAAG,OAAO,KAOnC,aAAa,CAChC;AAED,wBAAgB,gBAAgB,CAAC,YAAY,GAAG,OAAO,EAAE,eAAe,GAAG,YAAY,KAS7D,kBAAkB,CAAC,YAAY,EAAE,eAAe,CAAC,CAC1E;AAED,wBAAgB,mBAAmB;;;;;;;;;;;;;;EAQlC;AAED,wBAAgB,2BAA2B,+DAM1C;AAED,eAAO,MAAM,0BAA0B,GAAI,aAAa,gBAAgB,WAKrE,CAAC;AAEJ,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,6BAc5D;AAED,wBAAgB,gCAAgC,8BAc/C;AAED,wBAAgB,4BAA4B,YAG3C;AAED,wBAAgB,4BAA4B,8BAU3C;AAED,wBAAgB,+BAA+B,YAE9C;AAED,wBAAgB,4BAA4B,8BAU3C;AAED,wBAAgB,+BAA+B,YAE9C;AAED,wBAAgB,4BAA4B,gBAI5B,4BAA4B,aAI3C;AAED,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,28 +1,38 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { createGraphClientCache, } from '@ontahi/core/data-graph';
4
+ import { anonymousExecutionIdentity } from '@ontahi/core/runtime/identity';
4
5
  import { createContext, useCallback, useContext, useMemo, useState, useSyncExternalStore, } from 'react';
6
+ import { createFetchGraphClient } from './fetch-graph-client.js';
5
7
  import { createReflectedOperationInvoker, } from './reflected-operation-invoker.js';
6
8
  const noReflectedGraphOperations = [];
7
9
  const GraphRuntimeContext = createContext(null);
10
+ const ExecutionIdentityContext = createContext(anonymousExecutionIdentity);
8
11
  const GraphExecutorContext = createContext(null);
9
12
  const GraphClientCacheContext = createContext(null);
10
13
  const OperationBridgeAdaptersContext = createContext(null);
11
14
  const ReflectedEntityDataReaderContext = createContext(null);
12
15
  const ReflectedOperationInvokerContext = createContext(null);
13
- export function OntahiGraphProvider({ children, runtime, graphExecutor, operationBridgeAdapters = [], reflectedEntityDataReader, reflectedOperationInvoker, reflectedGraphOperations = noReflectedGraphOperations, clientCache, }) {
16
+ export function OntahiGraphProvider({ children, runtime, graphExecutor, client, operationBridgeAdapters, reflectedEntityDataReader, reflectedOperationInvoker, reflectedGraphOperations = noReflectedGraphOperations, clientCache, identity = anonymousExecutionIdentity, }) {
17
+ const [defaultGraphClient] = useState(() => createFetchGraphClient());
14
18
  const [defaultClientCache] = useState(() => createGraphClientCache());
19
+ const graphClient = client === false ? undefined : (client ?? defaultGraphClient);
20
+ const resolvedGraphExecutor = graphExecutor ?? graphClient?.graphExecutor;
21
+ const resolvedOperationBridgeAdapters = operationBridgeAdapters ?? graphClient?.operationBridgeAdapters ?? [];
22
+ const resolvedReflectedEntityDataReader = reflectedEntityDataReader ?? graphClient?.reflectedEntityDataReader;
23
+ const configuredReflectedOperationInvoker = reflectedOperationInvoker ?? graphClient?.reflectedOperationInvoker;
15
24
  const graphClientCache = clientCache ?? defaultClientCache;
16
- const bridgeAdapterMap = useMemo(() => new Map(operationBridgeAdapters.map(adapter => [adapter.name, adapter])), [operationBridgeAdapters]);
25
+ const bridgeAdapterMap = useMemo(() => new Map(resolvedOperationBridgeAdapters.map(adapter => [adapter.name, adapter])), [resolvedOperationBridgeAdapters]);
17
26
  const resolvedReflectedOperationInvoker = useMemo(() => reflectedGraphOperations.length > 0
18
27
  ? createReflectedOperationInvoker({
19
- fallback: reflectedOperationInvoker,
20
- graphExecutor,
28
+ fallback: configuredReflectedOperationInvoker,
29
+ graphExecutor: resolvedGraphExecutor,
21
30
  graphOperations: reflectedGraphOperations,
22
31
  })
23
- : (reflectedOperationInvoker ?? null), [graphExecutor, reflectedGraphOperations, reflectedOperationInvoker]);
24
- return (_jsx(ReflectedOperationInvokerContext.Provider, { value: resolvedReflectedOperationInvoker, children: _jsx(ReflectedEntityDataReaderContext.Provider, { value: reflectedEntityDataReader ?? null, children: _jsx(OperationBridgeAdaptersContext.Provider, { value: bridgeAdapterMap, children: _jsx(GraphClientCacheContext.Provider, { value: graphClientCache, children: _jsx(GraphExecutorContext.Provider, { value: graphExecutor ?? null, children: _jsx(GraphRuntimeContext.Provider, { value: runtime, children: children }) }) }) }) }) }));
32
+ : (configuredReflectedOperationInvoker ?? null), [configuredReflectedOperationInvoker, reflectedGraphOperations, resolvedGraphExecutor]);
33
+ return (_jsx(ExecutionIdentityContext.Provider, { value: identity, children: _jsx(ReflectedOperationInvokerContext.Provider, { value: resolvedReflectedOperationInvoker, children: _jsx(ReflectedEntityDataReaderContext.Provider, { value: resolvedReflectedEntityDataReader ?? null, children: _jsx(OperationBridgeAdaptersContext.Provider, { value: bridgeAdapterMap, children: _jsx(GraphClientCacheContext.Provider, { value: graphClientCache, children: _jsx(GraphExecutorContext.Provider, { value: resolvedGraphExecutor ?? null, children: _jsx(GraphRuntimeContext.Provider, { value: runtime, children: children }) }) }) }) }) }) }));
25
34
  }
35
+ export const useExecutionIdentity = () => useContext(ExecutionIdentityContext);
26
36
  export function useGraphRuntime() {
27
37
  const runtime = useContext(GraphRuntimeContext);
28
38
  if (runtime === null) {
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/graph/context.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,sBAAsB,GAKvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,OAAO,EACP,QAAQ,EACR,oBAAoB,GAErB,MAAM,OAAO,CAAC;AAKf,OAAO,EACL,+BAA+B,GAEhC,MAAM,kCAAkC,CAAC;AAE1C,MAAM,0BAA0B,GAA2C,EAAE,CAAC;AAE9E,MAAM,mBAAmB,GAAG,aAAa,CAAiB,IAAI,CAAC,CAAC;AAChE,MAAM,oBAAoB,GAAG,aAAa,CAAsC,IAAI,CAAC,CAAC;AACtF,MAAM,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AAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,OAAO,UAAU,CAAC,gCAAgC,CAAC,KAAK,IAAI,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,gCAAgC,CAAC,CAAC;IAE7D,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,OAAO,UAAU,CAAC,gCAAgC,CAAC,KAAK,IAAI,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,gCAAgC,CAAC,CAAC;IAE7D,OAAO,WAAW,CAChB,CAAC,SAAuC,EAAE,EAAE,CAC1C,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,CAAC,EACvE,CAAC,OAAO,CAAC,CACV,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport {\n createGraphClientCache,\n type GraphClientCache,\n type ReflectedEntityDataReader,\n type ReflectedOperationDescriptor,\n type ReflectedOperationInvoker,\n} from '@ontahi/core/data-graph';\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\n\nimport type { AnyOperationBridgeAdapter } from '../actions/index.js';\n\nimport type { ReactGraphExecutor } from './executor.js';\nimport {\n createReflectedOperationInvoker,\n type ReflectedGraphOperationLike,\n} from './reflected-operation-invoker.js';\n\nconst noReflectedGraphOperations: readonly ReflectedGraphOperationLike[] = [];\n\nconst GraphRuntimeContext = createContext<unknown | null>(null);\nconst GraphExecutorContext = createContext<ReactGraphExecutor<any, any> | null>(null);\nconst GraphClientCacheContext = createContext<GraphClientCache | null>(null);\nconst OperationBridgeAdaptersContext = createContext<Map<string, AnyOperationBridgeAdapter> | null>(\n null,\n);\nconst ReflectedEntityDataReaderContext = createContext<ReflectedEntityDataReader | null>(null);\nconst ReflectedOperationInvokerContext = createContext<ReflectedOperationInvoker | null>(null);\n\nexport type OntahiGraphProviderProps<\n TGraphRuntime = unknown,\n TReadOptions = unknown,\n TCommandOptions = TReadOptions,\n> = {\n children: ReactNode;\n runtime: TGraphRuntime;\n graphExecutor?: ReactGraphExecutor<TReadOptions, TCommandOptions>;\n operationBridgeAdapters?: AnyOperationBridgeAdapter[];\n reflectedEntityDataReader?: ReflectedEntityDataReader;\n reflectedOperationInvoker?: ReflectedOperationInvoker;\n reflectedGraphOperations?: readonly ReflectedGraphOperationLike[];\n clientCache?: GraphClientCache;\n};\n\nexport function OntahiGraphProvider<\n TGraphRuntime = unknown,\n TReadOptions = unknown,\n TCommandOptions = TReadOptions,\n>({\n children,\n runtime,\n graphExecutor,\n operationBridgeAdapters = [],\n reflectedEntityDataReader,\n reflectedOperationInvoker,\n reflectedGraphOperations = noReflectedGraphOperations,\n clientCache,\n}: OntahiGraphProviderProps<TGraphRuntime, TReadOptions, TCommandOptions>) {\n const [defaultClientCache] = useState(() => createGraphClientCache());\n const graphClientCache = clientCache ?? defaultClientCache;\n const bridgeAdapterMap = useMemo(\n () => new Map(operationBridgeAdapters.map(adapter => [adapter.name, adapter])),\n [operationBridgeAdapters],\n );\n const resolvedReflectedOperationInvoker = useMemo(\n () =>\n reflectedGraphOperations.length > 0\n ? createReflectedOperationInvoker({\n fallback: reflectedOperationInvoker,\n graphExecutor,\n graphOperations: reflectedGraphOperations,\n })\n : (reflectedOperationInvoker ?? null),\n [graphExecutor, reflectedGraphOperations, reflectedOperationInvoker],\n );\n\n return (\n <ReflectedOperationInvokerContext.Provider value={resolvedReflectedOperationInvoker}>\n <ReflectedEntityDataReaderContext.Provider value={reflectedEntityDataReader ?? null}>\n <OperationBridgeAdaptersContext.Provider value={bridgeAdapterMap}>\n <GraphClientCacheContext.Provider value={graphClientCache}>\n <GraphExecutorContext.Provider value={graphExecutor ?? null}>\n <GraphRuntimeContext.Provider value={runtime}>\n {children}\n </GraphRuntimeContext.Provider>\n </GraphExecutorContext.Provider>\n </GraphClientCacheContext.Provider>\n </OperationBridgeAdaptersContext.Provider>\n </ReflectedEntityDataReaderContext.Provider>\n </ReflectedOperationInvokerContext.Provider>\n );\n}\n\nexport function useGraphRuntime<TGraphRuntime = unknown>() {\n const runtime = useContext(GraphRuntimeContext);\n\n if (runtime === null) {\n throw new Error('useGraphRuntime must be used within an OntahiGraphProvider');\n }\n\n return runtime as TGraphRuntime;\n}\n\nexport function useGraphExecutor<TReadOptions = unknown, TCommandOptions = TReadOptions>() {\n const graphExecutor = useContext(GraphExecutorContext);\n\n if (graphExecutor === null) {\n throw new Error(\n 'useGraphExecutor must be used within an OntahiGraphProvider with graphExecutor',\n );\n }\n\n return graphExecutor as ReactGraphExecutor<TReadOptions, TCommandOptions>;\n}\n\nexport function useGraphClientCache() {\n const clientCache = useContext(GraphClientCacheContext);\n\n if (clientCache === null) {\n throw new Error('useGraphClientCache must be used within an OntahiGraphProvider');\n }\n\n return clientCache;\n}\n\nexport function useGraphClientCacheSnapshot() {\n const clientCache = useGraphClientCache();\n\n useGraphClientCacheVersion(clientCache);\n\n return clientCache.inspect();\n}\n\nexport const useGraphClientCacheVersion = (clientCache: GraphClientCache) =>\n useSyncExternalStore(\n clientCache.subscribe,\n () => clientCache.inspect().version,\n () => clientCache.inspect().version,\n );\n\nexport function useOperationBridgeAdapter(adapterName: string) {\n const adapters = useContext(OperationBridgeAdaptersContext);\n\n if (adapters === null) {\n throw new Error('useOperationBridgeAdapter must be used within an OntahiGraphProvider');\n }\n\n const adapter = adapters.get(adapterName);\n\n if (!adapter) {\n throw new Error(`No operation bridge adapter registered for \"${adapterName}\"`);\n }\n\n return adapter;\n}\n\nexport function useDefaultOperationBridgeAdapter() {\n const adapters = useContext(OperationBridgeAdaptersContext);\n\n if (adapters === null) {\n throw new Error('useDefaultOperationBridgeAdapter must be used within an OntahiGraphProvider');\n }\n\n const [adapter] = adapters.values();\n\n if (!adapter) {\n throw new Error('No operation bridge adapter registered.');\n }\n\n return adapter;\n}\n\nexport function useHasOperationBridgeRuntime() {\n const adapters = useContext(OperationBridgeAdaptersContext);\n return adapters !== null && adapters.size > 0;\n}\n\nexport function useReflectedEntityDataReader() {\n const reader = useContext(ReflectedEntityDataReaderContext);\n\n if (reader === null) {\n throw new Error(\n 'useReflectedEntityDataReader must be used within an OntahiGraphProvider with reflectedEntityDataReader',\n );\n }\n\n return reader;\n}\n\nexport function useHasReflectedEntityDataReader() {\n return useContext(ReflectedEntityDataReaderContext) !== null;\n}\n\nexport function useReflectedOperationInvoker() {\n const invoker = useContext(ReflectedOperationInvokerContext);\n\n if (invoker === null) {\n throw new Error(\n 'useReflectedOperationInvoker must be used within an OntahiGraphProvider with reflectedOperationInvoker',\n );\n }\n\n return invoker;\n}\n\nexport function useHasReflectedOperationInvoker() {\n return useContext(ReflectedOperationInvokerContext) !== null;\n}\n\nexport function useReflectedOperationSupport() {\n const invoker = useContext(ReflectedOperationInvokerContext);\n\n return useCallback(\n (operation: ReflectedOperationDescriptor) =>\n Boolean(invoker && (invoker.canInvokeOperation?.(operation) ?? true)),\n [invoker],\n );\n}\n\nexport type { GraphClientCache };\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/graph/context.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,sBAAsB,GAKvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,0BAA0B,EAA0B,MAAM,+BAA+B,CAAC;AACnG,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,OAAO,EACP,QAAQ,EACR,oBAAoB,GAErB,MAAM,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,IAAI,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,gCAAgC,CAAC,CAAC;IAE7D,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,OAAO,UAAU,CAAC,gCAAgC,CAAC,KAAK,IAAI,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,gCAAgC,CAAC,CAAC;IAE7D,OAAO,WAAW,CAChB,CAAC,SAAuC,EAAE,EAAE,CAC1C,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,CAAC,EACvE,CAAC,OAAO,CAAC,CACV,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport {\n createGraphClientCache,\n type GraphClientCache,\n type ReflectedEntityDataReader,\n type ReflectedOperationDescriptor,\n type ReflectedOperationInvoker,\n} from '@ontahi/core/data-graph';\nimport { anonymousExecutionIdentity, type ExecutionIdentity } from '@ontahi/core/runtime/identity';\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\n\nimport type { AnyOperationBridgeAdapter } from '../actions/index.js';\n\nimport type { ReactGraphExecutor } from './executor.js';\nimport { createFetchGraphClient, type OntahiGraphClient } from './fetch-graph-client.js';\nimport {\n createReflectedOperationInvoker,\n type ReflectedGraphOperationLike,\n} from './reflected-operation-invoker.js';\n\nconst noReflectedGraphOperations: readonly ReflectedGraphOperationLike[] = [];\n\nconst GraphRuntimeContext = createContext<unknown | null>(null);\nconst ExecutionIdentityContext = createContext<ExecutionIdentity>(anonymousExecutionIdentity);\nconst GraphExecutorContext = createContext<ReactGraphExecutor<any, any> | null>(null);\nconst GraphClientCacheContext = createContext<GraphClientCache | null>(null);\nconst OperationBridgeAdaptersContext = createContext<Map<string, AnyOperationBridgeAdapter> | null>(\n null,\n);\nconst ReflectedEntityDataReaderContext = createContext<ReflectedEntityDataReader | null>(null);\nconst ReflectedOperationInvokerContext = createContext<ReflectedOperationInvoker | null>(null);\n\nexport type OntahiGraphProviderProps<\n TGraphRuntime = unknown,\n TReadOptions = unknown,\n TCommandOptions = TReadOptions,\n> = {\n children: ReactNode;\n runtime: TGraphRuntime;\n graphExecutor?: ReactGraphExecutor<TReadOptions, TCommandOptions>;\n client?: OntahiGraphClient<TReadOptions, TCommandOptions> | false;\n operationBridgeAdapters?: AnyOperationBridgeAdapter[];\n reflectedEntityDataReader?: ReflectedEntityDataReader;\n reflectedOperationInvoker?: ReflectedOperationInvoker;\n reflectedGraphOperations?: readonly ReflectedGraphOperationLike[];\n clientCache?: GraphClientCache;\n identity?: ExecutionIdentity;\n};\n\nexport function OntahiGraphProvider<\n TGraphRuntime = unknown,\n TReadOptions = unknown,\n TCommandOptions = TReadOptions,\n>({\n children,\n runtime,\n graphExecutor,\n client,\n operationBridgeAdapters,\n reflectedEntityDataReader,\n reflectedOperationInvoker,\n reflectedGraphOperations = noReflectedGraphOperations,\n clientCache,\n identity = anonymousExecutionIdentity,\n}: OntahiGraphProviderProps<TGraphRuntime, TReadOptions, TCommandOptions>) {\n const [defaultGraphClient] = useState(() => createFetchGraphClient());\n const [defaultClientCache] = useState(() => createGraphClientCache());\n const graphClient = client === false ? undefined : (client ?? defaultGraphClient);\n const resolvedGraphExecutor = graphExecutor ?? graphClient?.graphExecutor;\n const resolvedOperationBridgeAdapters =\n operationBridgeAdapters ?? graphClient?.operationBridgeAdapters ?? [];\n const resolvedReflectedEntityDataReader =\n reflectedEntityDataReader ?? graphClient?.reflectedEntityDataReader;\n const configuredReflectedOperationInvoker =\n reflectedOperationInvoker ?? graphClient?.reflectedOperationInvoker;\n const graphClientCache = clientCache ?? defaultClientCache;\n const bridgeAdapterMap = useMemo(\n () => new Map(resolvedOperationBridgeAdapters.map(adapter => [adapter.name, adapter])),\n [resolvedOperationBridgeAdapters],\n );\n const resolvedReflectedOperationInvoker = useMemo(\n () =>\n reflectedGraphOperations.length > 0\n ? createReflectedOperationInvoker({\n fallback: configuredReflectedOperationInvoker,\n graphExecutor: resolvedGraphExecutor,\n graphOperations: reflectedGraphOperations,\n })\n : (configuredReflectedOperationInvoker ?? null),\n [configuredReflectedOperationInvoker, reflectedGraphOperations, resolvedGraphExecutor],\n );\n\n return (\n <ExecutionIdentityContext.Provider value={identity}>\n <ReflectedOperationInvokerContext.Provider value={resolvedReflectedOperationInvoker}>\n <ReflectedEntityDataReaderContext.Provider\n value={resolvedReflectedEntityDataReader ?? null}\n >\n <OperationBridgeAdaptersContext.Provider value={bridgeAdapterMap}>\n <GraphClientCacheContext.Provider value={graphClientCache}>\n <GraphExecutorContext.Provider value={resolvedGraphExecutor ?? null}>\n <GraphRuntimeContext.Provider value={runtime}>\n {children}\n </GraphRuntimeContext.Provider>\n </GraphExecutorContext.Provider>\n </GraphClientCacheContext.Provider>\n </OperationBridgeAdaptersContext.Provider>\n </ReflectedEntityDataReaderContext.Provider>\n </ReflectedOperationInvokerContext.Provider>\n </ExecutionIdentityContext.Provider>\n );\n}\n\nexport const useExecutionIdentity = () => useContext(ExecutionIdentityContext);\n\nexport function useGraphRuntime<TGraphRuntime = unknown>() {\n const runtime = useContext(GraphRuntimeContext);\n\n if (runtime === null) {\n throw new Error('useGraphRuntime must be used within an OntahiGraphProvider');\n }\n\n return runtime as TGraphRuntime;\n}\n\nexport function useGraphExecutor<TReadOptions = unknown, TCommandOptions = TReadOptions>() {\n const graphExecutor = useContext(GraphExecutorContext);\n\n if (graphExecutor === null) {\n throw new Error(\n 'useGraphExecutor must be used within an OntahiGraphProvider with graphExecutor',\n );\n }\n\n return graphExecutor as ReactGraphExecutor<TReadOptions, TCommandOptions>;\n}\n\nexport function useGraphClientCache() {\n const clientCache = useContext(GraphClientCacheContext);\n\n if (clientCache === null) {\n throw new Error('useGraphClientCache must be used within an OntahiGraphProvider');\n }\n\n return clientCache;\n}\n\nexport function useGraphClientCacheSnapshot() {\n const clientCache = useGraphClientCache();\n\n useGraphClientCacheVersion(clientCache);\n\n return clientCache.inspect();\n}\n\nexport const useGraphClientCacheVersion = (clientCache: GraphClientCache) =>\n useSyncExternalStore(\n clientCache.subscribe,\n () => clientCache.inspect().version,\n () => clientCache.inspect().version,\n );\n\nexport function useOperationBridgeAdapter(adapterName: string) {\n const adapters = useContext(OperationBridgeAdaptersContext);\n\n if (adapters === null) {\n throw new Error('useOperationBridgeAdapter must be used within an OntahiGraphProvider');\n }\n\n const adapter = adapters.get(adapterName);\n\n if (!adapter) {\n throw new Error(`No operation bridge adapter registered for \"${adapterName}\"`);\n }\n\n return adapter;\n}\n\nexport function useDefaultOperationBridgeAdapter() {\n const adapters = useContext(OperationBridgeAdaptersContext);\n\n if (adapters === null) {\n throw new Error('useDefaultOperationBridgeAdapter must be used within an OntahiGraphProvider');\n }\n\n const [adapter] = adapters.values();\n\n if (!adapter) {\n throw new Error('No operation bridge adapter registered.');\n }\n\n return adapter;\n}\n\nexport function useHasOperationBridgeRuntime() {\n const adapters = useContext(OperationBridgeAdaptersContext);\n return adapters !== null && adapters.size > 0;\n}\n\nexport function useReflectedEntityDataReader() {\n const reader = useContext(ReflectedEntityDataReaderContext);\n\n if (reader === null) {\n throw new Error(\n 'useReflectedEntityDataReader must be used within an OntahiGraphProvider with reflectedEntityDataReader',\n );\n }\n\n return reader;\n}\n\nexport function useHasReflectedEntityDataReader() {\n return useContext(ReflectedEntityDataReaderContext) !== null;\n}\n\nexport function useReflectedOperationInvoker() {\n const invoker = useContext(ReflectedOperationInvokerContext);\n\n if (invoker === null) {\n throw new Error(\n 'useReflectedOperationInvoker must be used within an OntahiGraphProvider with reflectedOperationInvoker',\n );\n }\n\n return invoker;\n}\n\nexport function useHasReflectedOperationInvoker() {\n return useContext(ReflectedOperationInvokerContext) !== null;\n}\n\nexport function useReflectedOperationSupport() {\n const invoker = useContext(ReflectedOperationInvokerContext);\n\n return useCallback(\n (operation: ReflectedOperationDescriptor) =>\n Boolean(invoker && (invoker.canInvokeOperation?.(operation) ?? true)),\n [invoker],\n );\n}\n\nexport type { GraphClientCache };\n"]}
@@ -1,4 +1,4 @@
1
- import type { GraphCommandSpec, GraphOperationDeclaration, GraphSchemaLike, InferGraphSchemaClientInput, QueryOrView, QuerySpec } from '@ontahi/core/data-graph';
1
+ import type { GraphCommandSpec, GraphOperationDeclaration, GraphReadExpression, GraphReadIntent, GraphSchemaLike, InferGraphSchemaClientInput, QueryOrView, QuerySpec } from '@ontahi/core/data-graph';
2
2
  import type { QueryKey, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
3
3
  export interface ReactGraphExecutor<TReadOptions = unknown, TCommandOptions = TReadOptions> {
4
4
  get<TParams, TResult>(read: QueryOrView<TParams, TResult>, params: TParams, options?: TReadOptions): Promise<TResult | null>;
@@ -9,13 +9,15 @@ export interface ReactGraphExecutor<TReadOptions = unknown, TCommandOptions = TR
9
9
  export type BuildableRead<TResult> = {
10
10
  build: () => QuerySpec<any, TResult>;
11
11
  };
12
- export type GraphReadSource<TResult = unknown> = QueryOrView<any, TResult> | BuildableRead<TResult>;
13
- export type ReadParams<TRead> = TRead extends QueryOrView<infer TParams, any> ? TParams : undefined;
14
- export type ReadResult<TRead> = TRead extends QueryOrView<any, infer TResult> ? TResult : TRead extends BuildableRead<infer TResult> ? TResult : never;
12
+ type PlainGraphReadSource<TResult> = QueryOrView<any, TResult> | BuildableRead<TResult>;
13
+ export type GraphReadSource<TResult = unknown> = PlainGraphReadSource<TResult> | GraphReadExpression<PlainGraphReadSource<TResult>, GraphReadIntent, TResult>;
14
+ export type ReadParams<TRead> = TRead extends GraphReadExpression<infer TSource, any, any> ? ReadParams<TSource> : TRead extends QueryOrView<infer TParams, any> ? TParams : undefined;
15
+ export type ReadResult<TRead> = TRead extends GraphReadExpression<any, any, infer TResult> ? TResult : TRead extends QueryOrView<any, infer TResult> ? TResult : TRead extends BuildableRead<infer TResult> ? TResult : never;
15
16
  export type GraphQueryMode = 'get' | 'run' | 'count' | 'exists';
16
- export type GraphQueryData<TRead, TMode extends GraphQueryMode> = TMode extends 'get' ? ReadResult<TRead> | null : TMode extends 'run' ? ReadResult<TRead>[] : TMode extends 'count' ? number : boolean;
17
- export type GraphQueryOptions<TRead, TMode extends GraphQueryMode, TReadOptions = unknown> = Omit<UseQueryOptions<GraphQueryData<TRead, TMode>, Error, GraphQueryData<TRead, TMode>, QueryKey>, 'queryKey' | 'queryFn'> & {
18
- mode: TMode;
17
+ type GraphReadIntentData<TRead, TIntent extends GraphReadIntent> = TIntent extends 'count' ? number : TIntent extends 'exists' ? boolean : TIntent extends 'one' ? ReadResult<TRead> : ReadResult<TRead> | null;
18
+ export type GraphQueryData<TRead, TMode extends GraphQueryMode = 'run'> = TRead extends GraphReadExpression<any, infer TIntent, any> ? GraphReadIntentData<TRead, TIntent> : TMode extends 'get' ? ReadResult<TRead> | null : TMode extends 'run' ? ReadResult<TRead>[] : TMode extends 'count' ? number : boolean;
19
+ export type GraphQueryOptions<TRead, TMode extends GraphQueryMode = 'run', TReadOptions = unknown> = Omit<UseQueryOptions<GraphQueryData<TRead, TMode>, Error, GraphQueryData<TRead, TMode>, QueryKey>, 'queryKey' | 'queryFn'> & {
20
+ mode?: TRead extends GraphReadExpression<any, any, any> ? never : TMode;
19
21
  params?: ReadParams<TRead>;
20
22
  queryKey?: QueryKey;
21
23
  runtimeOptions?: TReadOptions;
@@ -38,4 +40,5 @@ export type GraphCommandHookOptions<TResult, TVariables, TContext, TCommandOptio
38
40
  runtimeOptions?: TCommandOptions;
39
41
  invalidateQueryKeys?: QueryKey[];
40
42
  };
43
+ export {};
41
44
  //# sourceMappingURL=executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","s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C,GACG,2BAA2B,CAAC,OAAO,CAAC,GACpC,UAAU,SAAS,yBAAyB,CAAC,MAAM,MAAM,EAAE,GAAG,CAAC,GAC7D,MAAM,GACN,KAAK,CAAC;AAEZ,MAAM,MAAM,oBAAoB,CAAC,UAAU,IAAI,UAAU,SAAS;IAChE,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,WAAW,CAAC,MAAM,OAAO,CAAC,CAAC;CACrD,GACG,OAAO,GACP,KAAK,CAAC;AAEV,MAAM,MAAM,uBAAuB,CACjC,OAAO,EACP,UAAU,EACV,QAAQ,EACR,eAAe,GAAG,OAAO,IACvB,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,GAAG;IACjF,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,mBAAmB,CAAC,EAAE,QAAQ,EAAE,CAAC;CAClC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/graph/executor.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n GraphCommandSpec,\n GraphOperationDeclaration,\n GraphSchemaLike,\n InferGraphSchemaClientInput,\n QueryOrView,\n QuerySpec,\n} from '@ontahi/core/data-graph';\nimport type { QueryKey, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';\n\nexport interface ReactGraphExecutor<TReadOptions = unknown, TCommandOptions = TReadOptions> {\n get<TParams, TResult>(\n read: QueryOrView<TParams, TResult>,\n params: TParams,\n options?: TReadOptions,\n ): Promise<TResult | null>;\n run<TParams, TResult>(\n read: QueryOrView<TParams, TResult>,\n params: TParams,\n options?: TReadOptions,\n ): Promise<TResult[]>;\n count<TParams, TResult>(\n read: QueryOrView<TParams, TResult>,\n params: TParams,\n options?: TReadOptions,\n ): Promise<number>;\n runCommand<TResult = void>(\n command: GraphCommandSpec<any, any, TResult>,\n options?: TCommandOptions,\n ): Promise<TResult>;\n}\n\nexport type BuildableRead<TResult> = {\n build: () => QuerySpec<any, TResult>;\n};\n\nexport type GraphReadSource<TResult = unknown> = QueryOrView<any, TResult> | BuildableRead<TResult>;\n\nexport type ReadParams<TRead> = TRead extends QueryOrView<infer TParams, any> ? TParams : undefined;\n\nexport type ReadResult<TRead> =\n TRead extends QueryOrView<any, infer TResult>\n ? TResult\n : TRead extends BuildableRead<infer TResult>\n ? TResult\n : never;\n\nexport type GraphQueryMode = 'get' | 'run' | 'count' | 'exists';\n\nexport type GraphQueryData<TRead, TMode extends GraphQueryMode> = TMode extends 'get'\n ? ReadResult<TRead> | null\n : TMode extends 'run'\n ? ReadResult<TRead>[]\n : TMode extends 'count'\n ? number\n : boolean;\n\nexport type GraphQueryOptions<TRead, TMode extends GraphQueryMode, TReadOptions = unknown> = Omit<\n UseQueryOptions<GraphQueryData<TRead, TMode>, Error, GraphQueryData<TRead, TMode>, QueryKey>,\n 'queryKey' | 'queryFn'\n> & {\n mode: TMode;\n params?: ReadParams<TRead>;\n queryKey?: QueryKey;\n runtimeOptions?: TReadOptions;\n};\n\nexport type CommandLike<TResult> =\n | GraphCommandSpec<any, any, TResult>\n | {\n build: () => GraphCommandSpec<any, any, TResult>;\n };\n\nexport type GraphCommandBuilder<TVariables, TResult> = (\n variables: TVariables,\n) => CommandLike<TResult>;\n\nexport type GraphOperationLike<TVariables, TResult> = GraphOperationDeclaration<\n TVariables,\n CommandLike<TResult>\n> & {\n id: string;\n};\n\nexport type GraphOperationClientInput<TOperation> = TOperation extends {\n input: infer TSchema extends GraphSchemaLike;\n}\n ? InferGraphSchemaClientInput<TSchema>\n : TOperation extends GraphOperationDeclaration<infer TInput, any>\n ? TInput\n : never;\n\nexport type GraphOperationResult<TOperation> = TOperation extends {\n run: (...args: any[]) => CommandLike<infer TResult>;\n}\n ? TResult\n : never;\n\nexport type GraphCommandHookOptions<\n TResult,\n TVariables,\n TContext,\n TCommandOptions = unknown,\n> = Omit<UseMutationOptions<TResult, Error, TVariables, TContext>, 'mutationFn'> & {\n mutationKey?: QueryKey;\n runtimeOptions?: TCommandOptions;\n invalidateQueryKeys?: QueryKey[];\n};\n"]}
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/graph/executor.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n GraphCommandSpec,\n GraphOperationDeclaration,\n GraphReadExpression,\n GraphReadIntent,\n GraphSchemaLike,\n InferGraphSchemaClientInput,\n QueryOrView,\n QuerySpec,\n} from '@ontahi/core/data-graph';\nimport type { QueryKey, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';\n\nexport interface ReactGraphExecutor<TReadOptions = unknown, TCommandOptions = TReadOptions> {\n get<TParams, TResult>(\n read: QueryOrView<TParams, TResult>,\n params: TParams,\n options?: TReadOptions,\n ): Promise<TResult | null>;\n run<TParams, TResult>(\n read: QueryOrView<TParams, TResult>,\n params: TParams,\n options?: TReadOptions,\n ): Promise<TResult[]>;\n count<TParams, TResult>(\n read: QueryOrView<TParams, TResult>,\n params: TParams,\n options?: TReadOptions,\n ): Promise<number>;\n runCommand<TResult = void>(\n command: GraphCommandSpec<any, any, TResult>,\n options?: TCommandOptions,\n ): Promise<TResult>;\n}\n\nexport type BuildableRead<TResult> = {\n build: () => QuerySpec<any, TResult>;\n};\n\ntype PlainGraphReadSource<TResult> = QueryOrView<any, TResult> | BuildableRead<TResult>;\n\nexport type GraphReadSource<TResult = unknown> =\n | PlainGraphReadSource<TResult>\n | GraphReadExpression<PlainGraphReadSource<TResult>, GraphReadIntent, TResult>;\n\nexport type ReadParams<TRead> =\n TRead extends GraphReadExpression<infer TSource, any, any>\n ? ReadParams<TSource>\n : TRead extends QueryOrView<infer TParams, any>\n ? TParams\n : undefined;\n\nexport type ReadResult<TRead> =\n TRead extends GraphReadExpression<any, any, infer TResult>\n ? TResult\n : TRead extends QueryOrView<any, infer TResult>\n ? TResult\n : TRead extends BuildableRead<infer TResult>\n ? TResult\n : never;\n\nexport type GraphQueryMode = 'get' | 'run' | 'count' | 'exists';\n\ntype GraphReadIntentData<TRead, TIntent extends GraphReadIntent> = TIntent extends 'count'\n ? number\n : TIntent extends 'exists'\n ? boolean\n : TIntent extends 'one'\n ? ReadResult<TRead>\n : ReadResult<TRead> | null;\n\nexport type GraphQueryData<TRead, TMode extends GraphQueryMode = 'run'> =\n TRead extends GraphReadExpression<any, infer TIntent, any>\n ? GraphReadIntentData<TRead, TIntent>\n : TMode extends 'get'\n ? ReadResult<TRead> | null\n : TMode extends 'run'\n ? ReadResult<TRead>[]\n : TMode extends 'count'\n ? number\n : boolean;\n\nexport type GraphQueryOptions<\n TRead,\n TMode extends GraphQueryMode = 'run',\n TReadOptions = unknown,\n> = Omit<\n UseQueryOptions<GraphQueryData<TRead, TMode>, Error, GraphQueryData<TRead, TMode>, QueryKey>,\n 'queryKey' | 'queryFn'\n> & {\n mode?: TRead extends GraphReadExpression<any, any, any> ? never : TMode;\n params?: ReadParams<TRead>;\n queryKey?: QueryKey;\n runtimeOptions?: TReadOptions;\n};\n\nexport type CommandLike<TResult> =\n | GraphCommandSpec<any, any, TResult>\n | {\n build: () => GraphCommandSpec<any, any, TResult>;\n };\n\nexport type GraphCommandBuilder<TVariables, TResult> = (\n variables: TVariables,\n) => CommandLike<TResult>;\n\nexport type GraphOperationLike<TVariables, TResult> = GraphOperationDeclaration<\n TVariables,\n CommandLike<TResult>\n> & {\n id: string;\n};\n\nexport type GraphOperationClientInput<TOperation> = TOperation extends {\n input: infer TSchema extends GraphSchemaLike;\n}\n ? InferGraphSchemaClientInput<TSchema>\n : TOperation extends GraphOperationDeclaration<infer TInput, any>\n ? TInput\n : never;\n\nexport type GraphOperationResult<TOperation> = TOperation extends {\n run: (...args: any[]) => CommandLike<infer TResult>;\n}\n ? TResult\n : never;\n\nexport type GraphCommandHookOptions<\n TResult,\n TVariables,\n TContext,\n TCommandOptions = unknown,\n> = Omit<UseMutationOptions<TResult, Error, TVariables, TContext>, 'mutationFn'> & {\n mutationKey?: QueryKey;\n runtimeOptions?: TCommandOptions;\n invalidateQueryKeys?: QueryKey[];\n};\n"]}
@@ -0,0 +1,22 @@
1
+ import type { ReflectedEntityDataReader, ReflectedOperationInvoker } from '@ontahi/core/data-graph';
2
+ import { type AnyOperationBridgeAdapter, type FetchOperationBridgeOptions } from '../actions/index.js';
3
+ import type { ReactGraphExecutor } from './executor.js';
4
+ import { type FetchGraphReadExecutorOptions } from './fetch-graph-read-executor.js';
5
+ export type FetchReflectedEntityDataReaderOptions = {
6
+ endpoint?: string;
7
+ fetch?: typeof globalThis.fetch;
8
+ };
9
+ export type OntahiGraphClient<TReadOptions = unknown, TCommandOptions = TReadOptions> = {
10
+ graphExecutor?: ReactGraphExecutor<TReadOptions, TCommandOptions>;
11
+ operationBridgeAdapters?: AnyOperationBridgeAdapter[];
12
+ reflectedEntityDataReader?: ReflectedEntityDataReader;
13
+ reflectedOperationInvoker?: ReflectedOperationInvoker;
14
+ };
15
+ export type FetchGraphClientOptions<TOptions = undefined> = {
16
+ graphRead?: false | FetchGraphReadExecutorOptions<TOptions>;
17
+ operations?: false | FetchOperationBridgeOptions;
18
+ reflectedEntityData?: false | FetchReflectedEntityDataReaderOptions;
19
+ };
20
+ export declare const createFetchReflectedEntityDataReader: ({ endpoint, fetch: fetchRequest, }?: FetchReflectedEntityDataReaderOptions) => ReflectedEntityDataReader;
21
+ export declare const createFetchGraphClient: <TOptions = undefined>({ graphRead, operations, reflectedEntityData, }?: FetchGraphClientOptions<TOptions>) => OntahiGraphClient<TOptions, TOptions>;
22
+ //# sourceMappingURL=fetch-graph-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-graph-client.d.ts","sourceRoot":"","sources":["../../src/graph/fetch-graph-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yBAAyB,EAEzB,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAGL,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EACjC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,gCAAgC,CAAC;AAExC,MAAM,MAAM,qCAAqC,GAAG;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,YAAY,GAAG,OAAO,EAAE,eAAe,GAAG,YAAY,IAAI;IACtF,aAAa,CAAC,EAAE,kBAAkB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IAClE,uBAAuB,CAAC,EAAE,yBAAyB,EAAE,CAAC;IACtD,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;IACtD,yBAAyB,CAAC,EAAE,yBAAyB,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,uBAAuB,CAAC,QAAQ,GAAG,SAAS,IAAI;IAC1D,SAAS,CAAC,EAAE,KAAK,GAAG,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IAC5D,UAAU,CAAC,EAAE,KAAK,GAAG,2BAA2B,CAAC;IACjD,mBAAmB,CAAC,EAAE,KAAK,GAAG,qCAAqC,CAAC;CACrE,CAAC;AAiBF,eAAO,MAAM,oCAAoC,GAAI,qCAGlD,qCAA0C,KAAG,yBAe9C,CAAC;AAEH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,GAAG,SAAS,EAAE,kDAI1D,uBAAuB,CAAC,QAAQ,CAAM,KAAG,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAgB/E,CAAC"}
@@ -0,0 +1,43 @@
1
+ 'use client';
2
+ import { createFetchOperationBridgeAdapter, createFetchReflectedOperationInvoker, } from '../actions/index.js';
3
+ import { createFetchGraphReadExecutor, } from './fetch-graph-read-executor.js';
4
+ const DEFAULT_OPERATIONS_ENDPOINT = '/operations';
5
+ const DEFAULT_TASKS_ENDPOINT = '/operations/tasks';
6
+ const DEFAULT_REFLECTED_ENTITY_DATA_ENDPOINT = '/explorer/entities';
7
+ const conventionalOperationOptions = (options) => options.mountPath === undefined
8
+ ? {
9
+ endpoint: DEFAULT_OPERATIONS_ENDPOINT,
10
+ taskEndpoint: DEFAULT_TASKS_ENDPOINT,
11
+ ...options,
12
+ }
13
+ : options;
14
+ export const createFetchReflectedEntityDataReader = ({ endpoint = DEFAULT_REFLECTED_ENTITY_DATA_ENDPOINT, fetch: fetchRequest = globalThis.fetch, } = {}) => ({
15
+ readEntityData: async (query) => {
16
+ const response = await fetchRequest(endpoint, {
17
+ method: 'POST',
18
+ headers: { 'content-type': 'application/json' },
19
+ credentials: 'same-origin',
20
+ body: JSON.stringify(query),
21
+ });
22
+ if (!response.ok) {
23
+ throw new Error(`Reflected entity data request failed with status ${response.status}.`);
24
+ }
25
+ return response.json();
26
+ },
27
+ });
28
+ export const createFetchGraphClient = ({ graphRead = {}, operations = {}, reflectedEntityData = {}, } = {}) => {
29
+ const operationOptions = operations === false ? undefined : conventionalOperationOptions(operations);
30
+ return {
31
+ ...(graphRead === false ? {} : { graphExecutor: createFetchGraphReadExecutor(graphRead) }),
32
+ ...(operationOptions
33
+ ? {
34
+ operationBridgeAdapters: [createFetchOperationBridgeAdapter(operationOptions)],
35
+ reflectedOperationInvoker: createFetchReflectedOperationInvoker(operationOptions),
36
+ }
37
+ : {}),
38
+ ...(reflectedEntityData === false
39
+ ? {}
40
+ : { reflectedEntityDataReader: createFetchReflectedEntityDataReader(reflectedEntityData) }),
41
+ };
42
+ };
43
+ //# sourceMappingURL=fetch-graph-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-graph-client.js","sourceRoot":"","sources":["../../src/graph/fetch-graph-client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAQb,OAAO,EACL,iCAAiC,EACjC,oCAAoC,GAGrC,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL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S,CAAC,CAAC,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC;IAE9E,OAAO;QACL,GAAG,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,4BAA4B,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1F,GAAG,CAAC,gBAAgB;YAClB,CAAC,CAAC;gBACE,uBAAuB,EAAE,CAAC,iCAAiC,CAAC,gBAAgB,CAAC,CAAC;gBAC9E,yBAAyB,EAAE,oCAAoC,CAAC,gBAAgB,CAAC;aAClF;YACH,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,mBAAmB,KAAK,KAAK;YAC/B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,yBAAyB,EAAE,oCAAoC,CAAC,mBAAmB,CAAC,EAAE,CAAC;KAC9F,CAAC;AACJ,CAAC,CAAC","sourcesContent":["'use client';\n\nimport type {\n ReflectedEntityDataReader,\n ReflectedEntityDataResult,\n ReflectedOperationInvoker,\n} from '@ontahi/core/data-graph';\n\nimport {\n createFetchOperationBridgeAdapter,\n createFetchReflectedOperationInvoker,\n type AnyOperationBridgeAdapter,\n type FetchOperationBridgeOptions,\n} from '../actions/index.js';\n\nimport type { ReactGraphExecutor } from './executor.js';\nimport {\n createFetchGraphReadExecutor,\n type FetchGraphReadExecutorOptions,\n} from './fetch-graph-read-executor.js';\n\nexport type FetchReflectedEntityDataReaderOptions = {\n endpoint?: string;\n fetch?: typeof globalThis.fetch;\n};\n\nexport type OntahiGraphClient<TReadOptions = unknown, TCommandOptions = TReadOptions> = {\n graphExecutor?: ReactGraphExecutor<TReadOptions, TCommandOptions>;\n operationBridgeAdapters?: AnyOperationBridgeAdapter[];\n reflectedEntityDataReader?: ReflectedEntityDataReader;\n reflectedOperationInvoker?: ReflectedOperationInvoker;\n};\n\nexport type FetchGraphClientOptions<TOptions = undefined> = {\n graphRead?: false | FetchGraphReadExecutorOptions<TOptions>;\n operations?: false | FetchOperationBridgeOptions;\n reflectedEntityData?: false | FetchReflectedEntityDataReaderOptions;\n};\n\nconst DEFAULT_OPERATIONS_ENDPOINT = '/operations';\nconst DEFAULT_TASKS_ENDPOINT = '/operations/tasks';\nconst DEFAULT_REFLECTED_ENTITY_DATA_ENDPOINT = '/explorer/entities';\n\nconst conventionalOperationOptions = (\n options: FetchOperationBridgeOptions,\n): FetchOperationBridgeOptions =>\n options.mountPath === undefined\n ? {\n endpoint: DEFAULT_OPERATIONS_ENDPOINT,\n taskEndpoint: DEFAULT_TASKS_ENDPOINT,\n ...options,\n }\n : options;\n\nexport const createFetchReflectedEntityDataReader = ({\n endpoint = DEFAULT_REFLECTED_ENTITY_DATA_ENDPOINT,\n fetch: fetchRequest = globalThis.fetch,\n}: FetchReflectedEntityDataReaderOptions = {}): ReflectedEntityDataReader => ({\n readEntityData: async query => {\n const response = await fetchRequest(endpoint, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n credentials: 'same-origin',\n body: JSON.stringify(query),\n });\n\n if (!response.ok) {\n throw new Error(`Reflected entity data request failed with status ${response.status}.`);\n }\n\n return response.json() as Promise<ReflectedEntityDataResult>;\n },\n});\n\nexport const createFetchGraphClient = <TOptions = undefined>({\n graphRead = {},\n operations = {},\n reflectedEntityData = {},\n}: FetchGraphClientOptions<TOptions> = {}): OntahiGraphClient<TOptions, TOptions> => {\n const operationOptions =\n operations === false ? undefined : conventionalOperationOptions(operations);\n\n return {\n ...(graphRead === false ? {} : { graphExecutor: createFetchGraphReadExecutor(graphRead) }),\n ...(operationOptions\n ? {\n operationBridgeAdapters: [createFetchOperationBridgeAdapter(operationOptions)],\n reflectedOperationInvoker: createFetchReflectedOperationInvoker(operationOptions),\n }\n : {}),\n ...(reflectedEntityData === false\n ? {}\n : { reflectedEntityDataReader: createFetchReflectedEntityDataReader(reflectedEntityData) }),\n };\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import type { ReactGraphExecutor } from './executor.js';
2
+ export type FetchGraphReadExecutorOptions<TOptions = undefined> = {
3
+ endpoint?: string;
4
+ fetch?: typeof globalThis.fetch;
5
+ requestInit?: (options?: TOptions) => Omit<RequestInit, 'body' | 'method'>;
6
+ };
7
+ export declare const createFetchGraphReadExecutor: <TOptions = undefined>({ endpoint, fetch: fetchRequest, requestInit, }?: FetchGraphReadExecutorOptions<TOptions>) => ReactGraphExecutor<TOptions, TOptions>;
8
+ //# sourceMappingURL=fetch-graph-read-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-graph-read-executor.d.ts","sourceRoot":"","sources":["../../src/graph/fetch-graph-read-executor.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD,MAAM,MAAM,6BAA6B,CAAC,QAAQ,GAAG,SAAS,IAAI;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC;CAC5E,CAAC;AAIF,eAAO,MAAM,4BAA4B,GAAI,QAAQ,GAAG,SAAS,EAAE,kDAIhE,6BAA6B,CAAC,QAAQ,CAAM,KAAG,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAgCtF,CAAC"}
@@ -0,0 +1,37 @@
1
+ 'use client';
2
+ import { createRemoteDataGraphRuntime, isGraphReadProtocolError, } from '@ontahi/core/data-graph';
3
+ import { runBrowserEffect } from '@ontahi/core/runtime/browser';
4
+ const DEFAULT_GRAPH_READ_ENDPOINT = '/graph/reads';
5
+ export const createFetchGraphReadExecutor = ({ endpoint = DEFAULT_GRAPH_READ_ENDPOINT, fetch: fetchRequest = globalThis.fetch, requestInit, } = {}) => {
6
+ const transport = async (request, options) => {
7
+ const init = requestInit?.(options) ?? {};
8
+ const headers = new Headers(init.headers);
9
+ if (!headers.has('content-type'))
10
+ headers.set('content-type', 'application/json');
11
+ const response = await fetchRequest(endpoint, {
12
+ ...init,
13
+ method: 'POST',
14
+ headers,
15
+ credentials: init.credentials ?? 'same-origin',
16
+ body: JSON.stringify(request),
17
+ });
18
+ try {
19
+ const payload = await response.json();
20
+ if (!response.ok && !isGraphReadProtocolError(payload)) {
21
+ throw new Error(`Graph read request failed with status ${response.status}.`);
22
+ }
23
+ return payload;
24
+ }
25
+ catch {
26
+ throw new Error(`Graph read request failed with status ${response.status}.`);
27
+ }
28
+ };
29
+ const runtime = createRemoteDataGraphRuntime({ transport });
30
+ return {
31
+ get: (read, params, options) => runBrowserEffect(runtime.get(read, params, options)),
32
+ run: (read, params, options) => runBrowserEffect(runtime.run(read, params, options)),
33
+ count: (read, params, options) => runBrowserEffect(runtime.count(read, params, options)),
34
+ runCommand: (command, options) => runBrowserEffect(runtime.runCommand(command, options)),
35
+ };
36
+ };
37
+ //# sourceMappingURL=fetch-graph-read-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-graph-read-executor.js","sourceRoot":"","sources":["../../src/graph/fetch-graph-read-executor.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,GAEzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAUhE,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAEnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAuB,EACjE,QAAQ,GAAG,2BAA2B,EACtC,KAAK,EAAE,YAAY,GAAG,UAAU,CAAC,KAAK,EACtC,WAAW,MACgC,EAAE,EAA0C,EAAE;IACzF,MAAM,SAAS,GAAuC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;QAC/E,MAAM,IAAI,GAAG,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1C,MAAM,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,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACxF,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KACzF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["'use client';\n\nimport {\n createRemoteDataGraphRuntime,\n isGraphReadProtocolError,\n type RemoteGraphReadTransport,\n} from '@ontahi/core/data-graph';\nimport { runBrowserEffect } from '@ontahi/core/runtime/browser';\n\nimport type { ReactGraphExecutor } from './executor.js';\n\nexport type FetchGraphReadExecutorOptions<TOptions = undefined> = {\n endpoint?: string;\n fetch?: typeof globalThis.fetch;\n requestInit?: (options?: TOptions) => Omit<RequestInit, 'body' | 'method'>;\n};\n\nconst DEFAULT_GRAPH_READ_ENDPOINT = '/graph/reads';\n\nexport const createFetchGraphReadExecutor = <TOptions = undefined>({\n endpoint = DEFAULT_GRAPH_READ_ENDPOINT,\n fetch: fetchRequest = globalThis.fetch,\n requestInit,\n}: FetchGraphReadExecutorOptions<TOptions> = {}): ReactGraphExecutor<TOptions, TOptions> => {\n const transport: RemoteGraphReadTransport<TOptions> = async (request, options) => {\n const init = requestInit?.(options) ?? {};\n const headers = new Headers(init.headers);\n if (!headers.has('content-type')) headers.set('content-type', 'application/json');\n\n const response = await fetchRequest(endpoint, {\n ...init,\n method: 'POST',\n headers,\n credentials: init.credentials ?? 'same-origin',\n body: JSON.stringify(request),\n });\n\n try {\n const payload: unknown = await response.json();\n if (!response.ok && !isGraphReadProtocolError(payload)) {\n throw new Error(`Graph read request failed with status ${response.status}.`);\n }\n return payload;\n } catch {\n throw new Error(`Graph read request failed with status ${response.status}.`);\n }\n };\n const runtime = createRemoteDataGraphRuntime({ transport });\n\n return {\n get: (read, params, options) => runBrowserEffect(runtime.get(read, params, options)),\n run: (read, params, options) => runBrowserEffect(runtime.run(read, params, options)),\n count: (read, params, options) => runBrowserEffect(runtime.count(read, params, options)),\n runCommand: (command, options) => runBrowserEffect(runtime.runCommand(command, options)),\n };\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  import { type UseMutationResult, type UseQueryResult } from '@tanstack/react-query';
2
- import type { GraphCommandBuilder, GraphCommandHookOptions, GraphOperationLike, GraphOperationClientInput, GraphOperationResult, GraphQueryData, GraphQueryMode, GraphQueryOptions, GraphReadSource, ReadResult } from './executor.js';
3
- export declare function useGraphQuery<TRead, TMode extends GraphQueryMode, TReadOptions = unknown, TCommandOptions = TReadOptions>(read: GraphReadSource<ReadResult<TRead>>, options: GraphQueryOptions<TRead, TMode, TReadOptions>): UseQueryResult<GraphQueryData<TRead, TMode>, Error>;
2
+ import type { GraphCommandBuilder, GraphCommandHookOptions, GraphOperationLike, GraphOperationClientInput, GraphOperationResult, GraphQueryData, GraphQueryMode, GraphQueryOptions, GraphReadSource } from './executor.js';
3
+ export declare function useGraphQuery<TRead extends GraphReadSource<any>, TMode extends GraphQueryMode = 'run', TReadOptions = unknown, TCommandOptions = TReadOptions>(read: TRead, options?: GraphQueryOptions<TRead, TMode, TReadOptions>): UseQueryResult<GraphQueryData<TRead, TMode>, Error>;
4
4
  export declare function useGraphCommand<TVariables, TResult = void, TContext = unknown, TReadOptions = unknown, TCommandOptions = TReadOptions>(buildCommand: GraphCommandBuilder<TVariables, TResult>, options?: GraphCommandHookOptions<TResult, TVariables, TContext, TCommandOptions>): UseMutationResult<TResult, Error, TVariables, TContext>;
5
5
  export declare function useGraphOperation<TOperation extends GraphOperationLike<any, any>, TContext = unknown, TReadOptions = unknown, TCommandOptions = TReadOptions>(operation: TOperation, options?: GraphCommandHookOptions<GraphOperationResult<TOperation>, GraphOperationClientInput<TOperation>, TContext, TCommandOptions>): UseMutationResult<GraphOperationResult<TOperation>, Error, GraphOperationClientInput<TOperation>, TContext>;
6
6
  //# source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