@ontahi/react 1.0.0-alpha.11 → 1.0.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -5
- package/dist/actions/fetch-operation-bridge-adapter.d.ts +10 -3
- package/dist/actions/fetch-operation-bridge-adapter.d.ts.map +1 -1
- package/dist/actions/fetch-operation-bridge-adapter.js +92 -29
- package/dist/actions/fetch-operation-bridge-adapter.js.map +1 -1
- package/dist/actions/operation-bridge.d.ts +2 -0
- package/dist/actions/operation-bridge.d.ts.map +1 -1
- package/dist/actions/operation-bridge.js.map +1 -1
- package/dist/graph/canonical-request-invalidation.d.ts +14 -0
- package/dist/graph/canonical-request-invalidation.d.ts.map +1 -0
- package/dist/graph/canonical-request-invalidation.js +42 -0
- package/dist/graph/canonical-request-invalidation.js.map +1 -0
- package/dist/graph/context.d.ts +10 -3
- package/dist/graph/context.d.ts.map +1 -1
- package/dist/graph/context.js +39 -4
- package/dist/graph/context.js.map +1 -1
- package/dist/graph/executor.d.ts +19 -1
- package/dist/graph/executor.d.ts.map +1 -1
- package/dist/graph/executor.js.map +1 -1
- package/dist/graph/fetch-graph-client.d.ts +20 -4
- package/dist/graph/fetch-graph-client.d.ts.map +1 -1
- package/dist/graph/fetch-graph-client.js +87 -17
- package/dist/graph/fetch-graph-client.js.map +1 -1
- package/dist/graph/fetch-graph-runtime.d.ts +9 -4
- package/dist/graph/fetch-graph-runtime.d.ts.map +1 -1
- package/dist/graph/fetch-graph-runtime.js +83 -6
- package/dist/graph/fetch-graph-runtime.js.map +1 -1
- package/dist/graph/fetch-runtime-transport.d.ts +4 -4
- package/dist/graph/fetch-runtime-transport.d.ts.map +1 -1
- package/dist/graph/fetch-runtime-transport.js +11 -14
- package/dist/graph/fetch-runtime-transport.js.map +1 -1
- package/dist/graph/graph-hooks.d.ts +3 -1
- package/dist/graph/graph-hooks.d.ts.map +1 -1
- package/dist/graph/graph-hooks.js +167 -40
- package/dist/graph/graph-hooks.js.map +1 -1
- package/dist/graph/index.d.ts +5 -0
- package/dist/graph/index.d.ts.map +1 -1
- package/dist/graph/index.js +5 -0
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/model-command-hooks.d.ts +2 -0
- package/dist/graph/model-command-hooks.d.ts.map +1 -0
- package/dist/graph/model-command-hooks.js +9 -0
- package/dist/graph/model-command-hooks.js.map +1 -0
- package/dist/graph/operation-hooks.d.ts +4 -2
- package/dist/graph/operation-hooks.d.ts.map +1 -1
- package/dist/graph/operation-hooks.js +95 -11
- package/dist/graph/operation-hooks.js.map +1 -1
- package/dist/graph/operation-types.d.ts +5 -1
- package/dist/graph/operation-types.d.ts.map +1 -1
- package/dist/graph/operation-types.js.map +1 -1
- package/dist/graph/runtime-graph-client.d.ts +13 -0
- package/dist/graph/runtime-graph-client.d.ts.map +1 -0
- package/dist/graph/runtime-graph-client.js +35 -0
- package/dist/graph/runtime-graph-client.js.map +1 -0
- package/dist/graph/semantic-invalidation.d.ts +27 -0
- package/dist/graph/semantic-invalidation.d.ts.map +1 -0
- package/dist/graph/semantic-invalidation.js +55 -0
- package/dist/graph/semantic-invalidation.js.map +1 -0
- package/dist/graph/websocket-runtime-transport.d.ts +32 -0
- package/dist/graph/websocket-runtime-transport.d.ts.map +1 -0
- package/dist/graph/websocket-runtime-transport.js +605 -0
- package/dist/graph/websocket-runtime-transport.js.map +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -46,13 +46,15 @@ const openTodos = TodoItem.all()
|
|
|
46
46
|
</OntahiGraphProvider>;
|
|
47
47
|
|
|
48
48
|
const todos = useGraphQuery(openTodos);
|
|
49
|
+
const liveTodos = useGraphQuery(openTodos, { observation: 'live' });
|
|
49
50
|
const total = useGraphQuery(openTodos.count());
|
|
50
51
|
const first = useGraphQuery(openTodos.first());
|
|
51
52
|
```
|
|
52
53
|
|
|
53
|
-
`OntahiGraphProvider` installs a conventional same-origin Fetch client by default.
|
|
54
|
-
|
|
55
|
-
Runtime
|
|
54
|
+
`OntahiGraphProvider` installs a conventional same-origin Fetch client by default. Operation
|
|
55
|
+
invocation and permission, Graph Read, Graph Command, and Durable Operation inspection all use one
|
|
56
|
+
Runtime Transport at `POST /runtime`. Reflected Explorer data remains outside the registered
|
|
57
|
+
Runtime Protocol families at `/explorer/entities` and `/explorer/related-entities`. These
|
|
56
58
|
capabilities are lazy: declaring the provider does not issue a request until the application uses
|
|
57
59
|
one of them.
|
|
58
60
|
|
|
@@ -61,6 +63,41 @@ configured client with `client={createFetchGraphClient(...)}`, or set `client={f
|
|
|
61
63
|
explicit provider. Server routes, read policies, and authorization remain opt-in and authoritative;
|
|
62
64
|
the default removes client wiring, not the server security boundary.
|
|
63
65
|
|
|
66
|
+
Contextual Selection reads (for example `Book.by(...).parts.chapters.toQuery()`) negotiate Graph
|
|
67
|
+
Read v2 through the same transport before execution, with the same request options/credentials.
|
|
68
|
+
The server must use supporting storage and grant each outgoing `selectionRelations` hop. Discovery
|
|
69
|
+
does not authorize the read or fetch source IDs; missing support fails explicitly without fallback.
|
|
70
|
+
Plain reads remain v1 with no discovery round trip. Contextual observation is not supported yet.
|
|
71
|
+
|
|
72
|
+
Classified reads lower to the canonical base Entity before reaching these providers. Use
|
|
73
|
+
`useGraphQuery(Chapter.all().many())` (or a runtime-bound variant's `.many()`) and the usual scalar
|
|
74
|
+
intents. Base and sibling variant reads have distinct membership keys under the same base-Entity
|
|
75
|
+
prefix, so host-triggered `invalidateQueries({ queryKey: [ContentNode.name] })` refetches all of them.
|
|
76
|
+
`useGraphQuery(query, { observation: 'live' })` explicitly selects the same complete-snapshot
|
|
77
|
+
observation lifecycle as the bound Query's `observe()`. The first snapshot is the initial React
|
|
78
|
+
Query value; the hook does not issue a duplicate one-shot read. Later snapshots replace that value
|
|
79
|
+
and pass through the same Graph Client Cache reconciliation as ordinary reads. Unmounting or
|
|
80
|
+
changing the query identity aborts the observation. Scalar terminal intents remain one-shot.
|
|
81
|
+
|
|
82
|
+
Live observation is opt-in. Ordinary `useGraphQuery(query)` retains one-shot execution plus
|
|
83
|
+
semantic mutation invalidation. An active live Query is not redundantly invalidated after a
|
|
84
|
+
mutation because its runtime observation already receives the committed revision. Contextual
|
|
85
|
+
Selection observation is not supported yet. Live and one-shot evaluations use distinct internal
|
|
86
|
+
React Query keys, including when the application supplies the same custom key, so both lifecycles
|
|
87
|
+
may consume one authored Query simultaneously.
|
|
88
|
+
|
|
89
|
+
With an observation-capable Runtime Transport, `client.graph.bindVariantSelection(Chapter.all())`
|
|
90
|
+
supports `.exec().observe()`. Complete snapshots recalculate membership, ordering and limits;
|
|
91
|
+
the Runtime Graph client reconciles them through base Entity identity. Leaving a variant is not
|
|
92
|
+
deleting its base record. Removing an Entity from a snapshot does not globally evict it: the host
|
|
93
|
+
still owns confirmed-delete invalidation, cache scoping and lifetime. A simultaneously observed
|
|
94
|
+
base Query can update the shared cached record when its classification changes.
|
|
95
|
+
|
|
96
|
+
Cancelling an observation now aborts its transport signal before waiting for the iterator to close,
|
|
97
|
+
releasing idle subscriptions without affecting other readers. Transports must honor that signal.
|
|
98
|
+
These contracts have an in-process receiver/in-memory provider/React integration proof; they do
|
|
99
|
+
not yet establish a variant mutation lifecycle or live SQL change-feed support.
|
|
100
|
+
|
|
64
101
|
The same client supports fluent execution outside React hooks:
|
|
65
102
|
|
|
66
103
|
```ts
|
|
@@ -87,6 +124,14 @@ logout, service identity, tenant, or workspace changes. An explicit `queryKey` r
|
|
|
87
124
|
for lower-level reads that cannot be encoded by the graph-read protocol, and the legacy explicit
|
|
88
125
|
`mode` API remains compatible.
|
|
89
126
|
|
|
127
|
+
Successful `useGraphQuery` reads and refetches also populate the provider's `clientCache`.
|
|
128
|
+
Selected entity identities, including nested relations described by the View, are reconciled into
|
|
129
|
+
canonical records; the output is stored under the query key. Singular reads retain their singular
|
|
130
|
+
shape, and count/exists outputs remain scalars. Failed reads do not write cache entries. The hook
|
|
131
|
+
continues returning the executor's result through React Query; this does not turn direct executor
|
|
132
|
+
calls or optimistic component state into cache writes. A row disappearing from a filtered result
|
|
133
|
+
does not imply that its canonical entity was deleted.
|
|
134
|
+
|
|
90
135
|
First-class Operation invocations bind render-owned input without losing the declaration form:
|
|
91
136
|
|
|
92
137
|
```ts
|
|
@@ -100,6 +145,51 @@ await completeVisible.executeAsync();
|
|
|
100
145
|
The bound invocation always uses the latest render input. Passing the Operation declaration itself
|
|
101
146
|
keeps the lower-level reusable mutation form, where each execution supplies its input.
|
|
102
147
|
|
|
148
|
+
`OntahiGraphProvider` consumes committed semantic metadata from every execution exchange on its
|
|
149
|
+
Runtime Transport. Every cached `useGraphQuery` retains its canonical `GraphReadRequest` in React
|
|
150
|
+
Query metadata; after commit, Ontahí compares those Reads with the bounded
|
|
151
|
+
`CommittedMutationSet` and refetches every possible overlap. A provably disjoint Read remains
|
|
152
|
+
current, while an unsupported shape refreshes conservatively. This applies equally to hooks,
|
|
153
|
+
Devtools Console executions, and other clients using the provider's transport.
|
|
154
|
+
|
|
155
|
+
Entity create, update, and delete use the same path as Relationship and ordered Commands:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const updateTodo = useEntityMutationCommand(
|
|
159
|
+
({ todo, completed }: { todo: EntityRef; completed: boolean }) =>
|
|
160
|
+
mutateEntity(TodoItemSchema).update(todo, { completed }),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
await updateTodo.mutateAsync({ todo, completed: true });
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Applications do not name query keys, forward mutation callbacks, or call `refetch()` after a
|
|
167
|
+
successful semantic mutation.
|
|
168
|
+
`useGraphCommand`, `useEntityMutationCommand`, `useManyToManyRelationshipCommand`,
|
|
169
|
+
`useOrderedRelationshipCommand`, Operation hooks, and terminal durable Operation hooks all consume
|
|
170
|
+
the same metadata. Existing `invalidateQueryKeys`, `bridge.invalidate`, and
|
|
171
|
+
`useCanonicalRequestInvalidation` remain compatibility escape hatches for older receivers that do
|
|
172
|
+
not return committed mutations; they are not required by the normal Runtime Protocol path.
|
|
173
|
+
|
|
174
|
+
Model Commands use the same transport and invalidation path without application wiring:
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
const modelCommand = useModelCommand();
|
|
178
|
+
|
|
179
|
+
const outcome = await modelCommand.submit({ text: 'Complete every item in Inbox' });
|
|
180
|
+
if (outcome.ok && outcome.value.status === 'pending') {
|
|
181
|
+
await modelCommand.respond(outcome.value.run, {
|
|
182
|
+
interactionId: outcome.value.interaction.id,
|
|
183
|
+
optionId: selectedOption,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
`useModelCommand()` observes started Operations and resumes durable interactions. Terminal
|
|
189
|
+
inspection uses the same execution exchange, so its committed effects refresh active reads through
|
|
190
|
+
the provider. The UI owns conversation presentation and input state, not transport orchestration or
|
|
191
|
+
cache invalidation.
|
|
192
|
+
|
|
103
193
|
Durable Operations use the same invocation bridge to start a run, then observe its lifecycle
|
|
104
194
|
through Runtime Transport:
|
|
105
195
|
|
|
@@ -110,6 +200,10 @@ await completeAll.executeAsync();
|
|
|
110
200
|
// completeAll.status/progress/finalValue follow the accepted run.
|
|
111
201
|
```
|
|
112
202
|
|
|
203
|
+
A pending typed Interaction is a distinct `waiting` lifecycle state. The hook exposes
|
|
204
|
+
`isWaiting` separately from `isRunning`, keeps the run observation active, and continues to report
|
|
205
|
+
`isExecuting` until the run completes, fails, or is cancelled.
|
|
206
|
+
|
|
113
207
|
The hook consumes an asynchronous snapshot sequence and does not choose polling or push. The
|
|
114
208
|
conventional Fetch Runtime Transport implements that sequence with versioned
|
|
115
209
|
`durable.operation.inspect` requests and owns the polling cadence:
|
|
@@ -123,11 +217,66 @@ const client = createFetchGraphClient({
|
|
|
123
217
|
});
|
|
124
218
|
```
|
|
125
219
|
|
|
126
|
-
|
|
127
|
-
|
|
220
|
+
The endpoint, Fetch implementation, credentials, headers, per-call request initialization, abort
|
|
221
|
+
signal, and request-id generator configured there serve every common request/response family.
|
|
222
|
+
For a WebSocket host, compose the same graph client around the push-capable transport:
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
const runtimeTransport = createWebSocketRuntimeTransport({ url: 'wss://app.example/runtime' });
|
|
226
|
+
const client = createRuntimeGraphClient({
|
|
227
|
+
application: clientApplication,
|
|
228
|
+
runtimeTransport,
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
`clientApplication` is emitted by `@ontahi/codegen`. Retaining it on the client lets integrations
|
|
233
|
+
inside `OntahiGraphProvider`, including Devtools, discover the same browser-safe Entity and
|
|
234
|
+
Operation catalog without repeating it in component props. The provider likewise exposes its
|
|
235
|
+
resolved identity, cache, and transport as one client-session context.
|
|
236
|
+
|
|
237
|
+
The transport opens one lazy session, correlates concurrent Runtime Protocol requests, and sends
|
|
238
|
+
one Durable observation control frame per run. Sequenced snapshots are pushed over that socket;
|
|
239
|
+
the browser does not issue repeated `inspect` requests. Aborting the hook sends an unsubscribe and
|
|
240
|
+
releases both sides. A disconnected observation fails and is not silently resumed; a later request
|
|
241
|
+
may open a new connection, but the application or a future resume contract must explicitly
|
|
242
|
+
re-establish observation. `useDurableOperation` itself is unchanged.
|
|
243
|
+
|
|
244
|
+
An application may compose Fetch and WebSocket behind its own `RuntimeTransport` and route each
|
|
245
|
+
request from `request.family`; it can select the Durable observer independently. Operation bridge
|
|
246
|
+
inputs backed by a Graph schema are converted to their portable Selection AST before strict
|
|
247
|
+
Runtime Protocol validation, so the same `useOperation(Entity.domain.operation)` authoring works
|
|
248
|
+
through either transport. The Todo example includes an interactive per-family routing lab.
|
|
249
|
+
|
|
250
|
+
Legacy family routes are opt-in migration surfaces:
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
const client = createFetchGraphClient({
|
|
254
|
+
runtimeTransport: { endpoint: '/runtime' },
|
|
255
|
+
compatibility: {
|
|
256
|
+
operation: { endpoint: '/operations' },
|
|
257
|
+
graphRead: { endpoint: '/graph/reads' },
|
|
258
|
+
graphCommand: { endpoint: '/graph/commands' },
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
An entry in `compatibility` selects that family’s legacy body and endpoint; every unlisted family
|
|
264
|
+
stays on Runtime Transport. It takes precedence over the deprecated `operations.endpoint`,
|
|
265
|
+
`operations.mountPath`, `graphRead.endpoint`, and `graphRead.commandEndpoint` aliases. Selection is
|
|
266
|
+
deterministic before transmission. A common request is never retried against a legacy endpoint
|
|
267
|
+
after a network or server failure, because replaying an Operation or Command could duplicate its
|
|
268
|
+
effect.
|
|
128
269
|
|
|
129
270
|
The Fetch executor sends only canonical graph-read and graph-Command requests. Credentials and
|
|
130
271
|
other trusted request state remain in Fetch initialization and are never embedded in a Query AST or
|
|
131
272
|
Command. The executor supports policy-bounded Relationship Commands and identity-scoped Entity
|
|
132
273
|
Mutation Commands; `useGraphExecutorCapability()` lets optional reflective UI discover whether the
|
|
133
274
|
host installed that execution surface without making it mandatory for read-only hosts.
|
|
275
|
+
|
|
276
|
+
`useEntityMutationCommand` executes create, update, and delete Commands and invalidates overlapping
|
|
277
|
+
Graph Reads from their committed semantic metadata. `useOrderedRelationshipCommand` executes
|
|
278
|
+
`move`/`before`/`after`/`prepend`/`append` commands through
|
|
279
|
+
the same Fetch or WebSocket Runtime Transport. Its result includes an exact `moved` delta, while a
|
|
280
|
+
stale exact-neighborhood precondition follows the command's fail-or-skip policy. Optimistic UI may
|
|
281
|
+
project the requested order temporarily; the hook refreshes possibly affected Reads after the
|
|
282
|
+
authority commits the command.
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { ReflectedOperationInvoker } from '@ontahi/core/data-graph';
|
|
2
|
+
import { type RuntimeTransport } from '@ontahi/core/runtime/protocol';
|
|
2
3
|
import type * as OperationBridge from './operation-bridge.js';
|
|
3
|
-
export type FetchOperationBridgeOptions = {
|
|
4
|
+
export type FetchOperationBridgeOptions<TTransportOptions = undefined> = {
|
|
5
|
+
/** @deprecated Select the legacy Operation route through createFetchGraphClient compatibility. */
|
|
4
6
|
mountPath?: string;
|
|
7
|
+
/** @deprecated Select the legacy Operation route through createFetchGraphClient compatibility. */
|
|
5
8
|
endpoint?: string;
|
|
9
|
+
fetch?: typeof globalThis.fetch;
|
|
10
|
+
requestInit?: (options?: TTransportOptions) => Omit<RequestInit, 'body' | 'method'>;
|
|
11
|
+
runtimeTransport?: RuntimeTransport<TTransportOptions>;
|
|
12
|
+
requestId?: () => string;
|
|
6
13
|
};
|
|
7
|
-
export declare const createFetchReflectedOperationInvoker: (options?: FetchOperationBridgeOptions) => ReflectedOperationInvoker;
|
|
8
|
-
export declare const createFetchOperationBridgeAdapter: (options?: FetchOperationBridgeOptions) => OperationBridge.AnyOperationBridgeAdapter;
|
|
14
|
+
export declare const createFetchReflectedOperationInvoker: <TTransportOptions = undefined>(options?: FetchOperationBridgeOptions<TTransportOptions>) => ReflectedOperationInvoker;
|
|
15
|
+
export declare const createFetchOperationBridgeAdapter: <TTransportOptions = undefined>(options?: FetchOperationBridgeOptions<TTransportOptions>) => OperationBridge.AnyOperationBridgeAdapter;
|
|
9
16
|
//# sourceMappingURL=fetch-operation-bridge-adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-operation-bridge-adapter.d.ts","sourceRoot":"","sources":["../../src/actions/fetch-operation-bridge-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch-operation-bridge-adapter.d.ts","sourceRoot":"","sources":["../../src/actions/fetch-operation-bridge-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,+BAA+B,CAAC;AAUvC,OAAO,KAAK,KAAK,eAAe,MAAM,uBAAuB,CAAC;AAI9D,MAAM,MAAM,2BAA2B,CAAC,iBAAiB,GAAG,SAAS,IAAI;IACvE,kGAAkG;IAClG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC;IACpF,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACvD,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC;CAC1B,CAAC;AAyKF,eAAO,MAAM,oCAAoC,GAAI,iBAAiB,GAAG,SAAS,EAChF,UAAS,2BAA2B,CAAC,iBAAiB,CAAM,KAC3D,yBAoCF,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAAI,iBAAiB,GAAG,SAAS,EAC7E,UAAS,2BAA2B,CAAC,iBAAiB,CAAM,KAC3D,eAAe,CAAC,yBAyClB,CAAC"}
|
|
@@ -1,61 +1,124 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { resolveOperationExecutionAffordance } from '@ontahi/core/data-graph';
|
|
2
|
+
import { normalizeGraphSchemaClientInput, resolveOperationExecutionAffordance, } from '@ontahi/core/data-graph';
|
|
3
3
|
import { isOperationInvocationProtocolResponse, } from '@ontahi/core/runtime/operation-invocation';
|
|
4
|
+
import { createRuntimeProtocolExchange, createRuntimeProtocolExecutionExchange, toOperationProtocolRequest, } from '@ontahi/core/runtime/protocol';
|
|
4
5
|
import { useMemo } from 'react';
|
|
6
|
+
import { createFetchRuntimeTransport } from '../graph/fetch-runtime-transport.js';
|
|
5
7
|
import { attachOperationBridgeActionRuntime, toOperationInvocationResult, unwrapOperationInvocationValue, } from './operation-bridge.js';
|
|
6
8
|
import { useServerMutation, useServerQuery } from './react-query.js';
|
|
7
|
-
const DEFAULT_ENDPOINT = '/api/data-graph/domain-operations';
|
|
8
9
|
const normalizeMountPath = (value) => {
|
|
9
10
|
const path = value.startsWith('/') ? value : `/${value}`;
|
|
10
|
-
|
|
11
|
+
let end = path.length;
|
|
12
|
+
while (end > 0 && path.charCodeAt(end - 1) === 47)
|
|
13
|
+
end -= 1;
|
|
14
|
+
return path.slice(0, end);
|
|
11
15
|
};
|
|
12
16
|
const mountedEndpoint = (mountPath, endpoint) => `${normalizeMountPath(mountPath)}/${endpoint}`;
|
|
13
17
|
const operationEndpoint = (options) => options.endpoint ??
|
|
14
|
-
(options.mountPath ? mountedEndpoint(options.mountPath, 'operations') :
|
|
18
|
+
(options.mountPath ? mountedEndpoint(options.mountPath, 'operations') : undefined);
|
|
15
19
|
const attachFetchBridgeRuntime = (operation, action) => attachOperationBridgeActionRuntime(operation, action, {
|
|
16
20
|
requiresAuth: operation.authority !== 'server' ? false : operation.exposure !== 'bridge',
|
|
17
21
|
});
|
|
18
|
-
const
|
|
19
|
-
const
|
|
22
|
+
const postLegacyBridgeRequest = async (endpoint, request, fetchRequest, requestInit) => {
|
|
23
|
+
const init = requestInit?.() ?? {};
|
|
24
|
+
const headers = new Headers(init.headers);
|
|
25
|
+
if (!headers.has('content-type'))
|
|
26
|
+
headers.set('content-type', 'application/json');
|
|
27
|
+
const response = await fetchRequest(endpoint, {
|
|
28
|
+
...init,
|
|
20
29
|
method: 'POST',
|
|
21
|
-
headers
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
credentials: 'same-origin',
|
|
30
|
+
headers,
|
|
31
|
+
credentials: init.credentials ?? 'same-origin',
|
|
25
32
|
body: JSON.stringify(request),
|
|
26
33
|
});
|
|
27
34
|
const payload = await response.json().catch(() => null);
|
|
28
|
-
if (!isOperationInvocationProtocolResponse(payload)) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
if (!response.ok && !isOperationInvocationProtocolResponse(payload)) {
|
|
36
|
+
throw new Error(`Graph bridge request failed with status ${response.status}.`);
|
|
37
|
+
}
|
|
38
|
+
return { body: payload };
|
|
39
|
+
};
|
|
40
|
+
const createOperationRequest = (options) => {
|
|
41
|
+
const endpoint = operationEndpoint(options);
|
|
42
|
+
if (endpoint) {
|
|
43
|
+
return request => postLegacyBridgeRequest(endpoint, request, options.fetch ?? globalThis.fetch, options.requestInit);
|
|
44
|
+
}
|
|
45
|
+
const transport = options.runtimeTransport ??
|
|
46
|
+
createFetchRuntimeTransport({
|
|
47
|
+
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
48
|
+
...(options.requestInit ? { requestInit: options.requestInit } : {}),
|
|
49
|
+
});
|
|
50
|
+
const exchange = createRuntimeProtocolExchange({
|
|
51
|
+
transport,
|
|
52
|
+
requestId: options.requestId,
|
|
53
|
+
});
|
|
54
|
+
const executionExchange = createRuntimeProtocolExecutionExchange({
|
|
55
|
+
transport,
|
|
56
|
+
requestId: options.requestId,
|
|
57
|
+
});
|
|
58
|
+
return async (request) => request.kind === 'invoke'
|
|
59
|
+
? executionExchange({
|
|
60
|
+
family: 'operation',
|
|
61
|
+
body: toOperationProtocolRequest(request),
|
|
62
|
+
})
|
|
63
|
+
: {
|
|
64
|
+
body: await exchange({
|
|
65
|
+
family: 'operation',
|
|
66
|
+
body: toOperationProtocolRequest(request),
|
|
67
|
+
}),
|
|
33
68
|
};
|
|
69
|
+
};
|
|
70
|
+
const errorMessage = (error) => error instanceof Error ? error.message : 'Graph bridge request failed.';
|
|
71
|
+
const postBridgeRequest = async (requestOperation, request) => {
|
|
72
|
+
let execution;
|
|
73
|
+
try {
|
|
74
|
+
execution = await requestOperation(request);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return { serverError: errorMessage(error) };
|
|
78
|
+
}
|
|
79
|
+
const payload = execution.body;
|
|
80
|
+
const executionMetadata = execution.metadata;
|
|
81
|
+
if (!isOperationInvocationProtocolResponse(payload)) {
|
|
82
|
+
return { serverError: 'Graph bridge returned an invalid response.' };
|
|
34
83
|
}
|
|
35
84
|
if (payload.kind === 'protocol-error') {
|
|
36
85
|
return { serverError: payload.error.message };
|
|
37
86
|
}
|
|
38
87
|
if (request.kind === 'invoke' && payload.kind === 'invocation-result') {
|
|
39
|
-
return {
|
|
88
|
+
return {
|
|
89
|
+
data: payload.result,
|
|
90
|
+
...(executionMetadata ? { executionMetadata } : {}),
|
|
91
|
+
};
|
|
40
92
|
}
|
|
41
93
|
if (request.kind === 'check-permission' && payload.kind === 'permission-result') {
|
|
42
94
|
return { data: payload.result };
|
|
43
95
|
}
|
|
44
96
|
return { serverError: 'Graph bridge returned an invalid response.' };
|
|
45
97
|
};
|
|
46
|
-
const createFetchBridgeAction = (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
98
|
+
const createFetchBridgeAction = (requestOperation, operation) => attachFetchBridgeRuntime(operation, (input) => {
|
|
99
|
+
const portableInput = operation.input
|
|
100
|
+
? normalizeGraphSchemaClientInput(operation.input, input, {
|
|
101
|
+
bindSelection: selection => selection.toAst(),
|
|
102
|
+
})
|
|
103
|
+
: input;
|
|
104
|
+
return postBridgeRequest(requestOperation, {
|
|
105
|
+
kind: 'invoke',
|
|
106
|
+
operationId: operation.id,
|
|
107
|
+
input: portableInput,
|
|
108
|
+
...(operation.view ? { view: operation.view } : {}),
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
const createFetchPermissionAction = (requestOperation, operation) => (input) => postBridgeRequest(requestOperation, {
|
|
53
112
|
kind: 'check-permission',
|
|
54
113
|
operationId: operation.id,
|
|
55
|
-
input
|
|
114
|
+
input: operation.input
|
|
115
|
+
? normalizeGraphSchemaClientInput(operation.input, input, {
|
|
116
|
+
bindSelection: selection => selection.toAst(),
|
|
117
|
+
})
|
|
118
|
+
: input,
|
|
56
119
|
});
|
|
57
120
|
export const createFetchReflectedOperationInvoker = (options = {}) => {
|
|
58
|
-
const
|
|
121
|
+
const requestOperation = createOperationRequest(options);
|
|
59
122
|
const canInvokeOperation = operation => operation.kind === undefined
|
|
60
123
|
? operation.exposure === undefined || operation.exposure === 'bridge'
|
|
61
124
|
: operation.kind !== 'graph' && operation.exposure === 'bridge';
|
|
@@ -71,7 +134,7 @@ export const createFetchReflectedOperationInvoker = (options = {}) => {
|
|
|
71
134
|
}
|
|
72
135
|
: {}),
|
|
73
136
|
}),
|
|
74
|
-
invokeOperation: async ({ input, operationId, view, }) => toOperationInvocationResult(await postBridgeRequest(
|
|
137
|
+
invokeOperation: async ({ input, operationId, view, }) => toOperationInvocationResult(await postBridgeRequest(requestOperation, {
|
|
75
138
|
kind: 'invoke',
|
|
76
139
|
operationId,
|
|
77
140
|
input,
|
|
@@ -80,8 +143,8 @@ export const createFetchReflectedOperationInvoker = (options = {}) => {
|
|
|
80
143
|
};
|
|
81
144
|
};
|
|
82
145
|
export const createFetchOperationBridgeAdapter = (options = {}) => {
|
|
83
|
-
const
|
|
84
|
-
const buildRuntimeAction = (operation) => createFetchBridgeAction(
|
|
146
|
+
const requestOperation = createOperationRequest(options);
|
|
147
|
+
const buildRuntimeAction = (operation) => createFetchBridgeAction(requestOperation, operation);
|
|
85
148
|
return {
|
|
86
149
|
name: 'fetch',
|
|
87
150
|
useBridgeAction: operation => useMemo(() => buildRuntimeAction(operation), [operation]),
|
|
@@ -100,7 +163,7 @@ export const createFetchOperationBridgeAdapter = (options = {}) => {
|
|
|
100
163
|
},
|
|
101
164
|
usePermission: (operation, input, args) => useServerQuery({
|
|
102
165
|
enabled: args?.enabled,
|
|
103
|
-
action: createFetchPermissionAction(
|
|
166
|
+
action: createFetchPermissionAction(requestOperation, operation),
|
|
104
167
|
input,
|
|
105
168
|
key: args?.queryKey ?? ['graph-permission', operation.id, input],
|
|
106
169
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-operation-bridge-adapter.js","sourceRoot":"","sources":["../../src/actions/fetch-operation-bridge-adapter.ts"],"names":[],"mappings":"AAAA,Y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iE;gBACzE,KAAK,EAAE,IAAI,CAAC,KAAgB;gBAC5B,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,MAAM,EAAE,8BAA8B;aACvC,CAAQ,CAAC;QACZ,CAAC;QACD,aAAa,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACxC,cAAc,CAAC;YACb,OAAO,EAAE,IAAI,EAAE,OAAO;YACtB,MAAM,EAAE,2BAA2B,CAAC,QAAQ,EAAE,SAAS,CAAC;YACxD,KAAK;YACL,GAAG,EAAE,IAAI,EAAE,QAAQ,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,CAAC;SACjE,CAAC;KACL,CAAC;AACJ,CAAC,CAAC","sourcesContent":["'use client';\n\nimport type {\n ReflectedOperationInvocation,\n ReflectedOperationInvoker,\n} from '@ontahi/core/data-graph';\nimport { resolveOperationExecutionAffordance } from '@ontahi/core/data-graph';\nimport type { OperationInvocationResult } from '@ontahi/core/runtime/contracts';\nimport {\n isOperationInvocationProtocolResponse,\n type OperationInvocationRequest,\n} from '@ontahi/core/runtime/operation-invocation';\nimport { useMemo } from 'react';\n\nimport {\n attachOperationBridgeActionRuntime,\n toOperationInvocationResult,\n unwrapOperationInvocationValue,\n} from './operation-bridge.js';\nimport type * as OperationBridge from './operation-bridge.js';\nimport { useServerMutation, useServerQuery } from './react-query.js';\nimport type { ActionResultLike } from './use-action.js';\n\nexport type FetchOperationBridgeOptions = {\n mountPath?: string;\n endpoint?: string;\n};\n\nconst DEFAULT_ENDPOINT = '/api/data-graph/domain-operations';\n\nconst normalizeMountPath = (value: string) => {\n const path = value.startsWith('/') ? value : `/${value}`;\n return path === '/' ? '' : path.replace(/\\/+$/, '');\n};\n\nconst mountedEndpoint = (mountPath: string, endpoint: string) =>\n `${normalizeMountPath(mountPath)}/${endpoint}`;\n\nconst operationEndpoint = (options: FetchOperationBridgeOptions) =>\n options.endpoint ??\n (options.mountPath ? mountedEndpoint(options.mountPath, 'operations') : DEFAULT_ENDPOINT);\n\nconst attachFetchBridgeRuntime = <TInput, TData>(\n operation: OperationBridge.BridgedOperationLike<TInput, TData>,\n action: OperationBridge.OperationBridgeAction<TInput, TData>,\n) =>\n attachOperationBridgeActionRuntime(operation, action, {\n requiresAuth: operation.authority !== 'server' ? false : operation.exposure !== 'bridge',\n });\n\nconst postBridgeRequest = async <TData>(\n endpoint: string,\n request: OperationInvocationRequest,\n): Promise<ActionResultLike & { data?: TData }> => {\n const response = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n },\n credentials: 'same-origin',\n body: JSON.stringify(request),\n });\n const payload: unknown = await response.json().catch(() => null);\n\n if (!isOperationInvocationProtocolResponse(payload)) {\n return {\n serverError: response.ok\n ? 'Graph bridge returned an invalid response.'\n : `Graph bridge request failed with status ${response.status}.`,\n };\n }\n\n if (payload.kind === 'protocol-error') {\n return { serverError: payload.error.message };\n }\n\n if (request.kind === 'invoke' && payload.kind === 'invocation-result') {\n return { data: payload.result as TData };\n }\n\n if (request.kind === 'check-permission' && payload.kind === 'permission-result') {\n return { data: payload.result as TData };\n }\n\n return { serverError: 'Graph bridge returned an invalid response.' };\n};\n\nconst createFetchBridgeAction = <TInput, TData>(\n endpoint: string,\n operation: OperationBridge.BridgedOperationLike<TInput, TData>,\n): OperationBridge.OperationBridgeAction<TInput, TData> =>\n attachFetchBridgeRuntime(operation, (input: TInput) =>\n postBridgeRequest<OperationInvocationResult<TData>>(endpoint, {\n kind: 'invoke',\n operationId: operation.id,\n input,\n ...(operation.view ? { view: operation.view } : {}),\n }),\n ) as OperationBridge.OperationBridgeAction<TInput, TData>;\n\nconst createFetchPermissionAction =\n <TInput, TData>(\n endpoint: string,\n operation: OperationBridge.BridgedOperationLike<TInput, TData>,\n ): ((\n input: TInput,\n ) => Promise<OperationBridge.OperationBridgeActionResult<OperationBridge.GraphPermission>>) =>\n (input: TInput) =>\n postBridgeRequest<OperationBridge.GraphPermission>(endpoint, {\n kind: 'check-permission',\n operationId: operation.id,\n input,\n });\n\nexport const createFetchReflectedOperationInvoker = (\n options: FetchOperationBridgeOptions = {},\n): ReflectedOperationInvoker => {\n const endpoint = operationEndpoint(options);\n const canInvokeOperation: NonNullable<\n ReflectedOperationInvoker['canInvokeOperation']\n > = operation =>\n operation.kind === undefined\n ? operation.exposure === undefined || operation.exposure === 'bridge'\n : operation.kind !== 'graph' && operation.exposure === 'bridge';\n\n return {\n canInvokeOperation,\n getOperationExecutionAffordance: operation =>\n resolveOperationExecutionAffordance(operation, {\n ...(canInvokeOperation(operation)\n ? {\n bridge: {\n authority: operation.authority ?? 'server',\n bridge: 'fetch',\n },\n }\n : {}),\n }),\n invokeOperation: async <TInput = unknown, TData = unknown>({\n input,\n operationId,\n view,\n }: ReflectedOperationInvocation<TInput>) =>\n toOperationInvocationResult<TData>(\n await postBridgeRequest<OperationInvocationResult<TData>>(endpoint, {\n kind: 'invoke',\n operationId,\n input,\n ...(view ? { view } : {}),\n }),\n ),\n };\n};\n\nexport const createFetchOperationBridgeAdapter = (\n options: FetchOperationBridgeOptions = {},\n): OperationBridge.AnyOperationBridgeAdapter => {\n const endpoint = operationEndpoint(options);\n const buildRuntimeAction = <TInput, TData>(\n operation: OperationBridge.BridgedOperationLike<TInput, TData>,\n ) => createFetchBridgeAction(endpoint, operation);\n\n return {\n name: 'fetch',\n useBridgeAction: operation =>\n useMemo(\n () => buildRuntimeAction(operation) as OperationBridge.OperationBridgeAction<any, any>,\n [operation],\n ) as OperationBridge.OperationBridgeAction<any, any>,\n useBridgeMutation: (operation, options) => {\n const action = useMemo(() => buildRuntimeAction(operation), [operation]);\n\n return useServerMutation(\n action as OperationBridge.OperationBridgeAction<unknown, unknown>,\n options as Parameters<\n typeof useServerMutation<OperationBridge.OperationBridgeAction<unknown, unknown>>\n >[1],\n ) as ReturnType<typeof useServerMutation<OperationBridge.OperationBridgeAction<any, any>>>;\n },\n useBridgeQuery: (operation, args) => {\n const action = useMemo(() => buildRuntimeAction(operation), [operation]);\n\n return useServerQuery({\n action: action as OperationBridge.OperationBridgeAction<unknown, unknown>,\n input: args.input as unknown,\n key: args.key,\n select: unwrapOperationInvocationValue,\n }) as any;\n },\n usePermission: (operation, input, args) =>\n useServerQuery({\n enabled: args?.enabled,\n action: createFetchPermissionAction(endpoint, operation),\n input,\n key: args?.queryKey ?? ['graph-permission', operation.id, input],\n }),\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"fetch-operation-bridge-adapter.js","sourceRoot":"","sources":["../../src/actions/fetch-operation-bridge-adapter.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAMb,OAAO,EACL,+BAA+B,EAC/B,mCAAmC,GACpC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,qCAAqC,GAEtC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,6BAA6B,EAC7B,sCAAsC,EACtC,0BAA0B,GAG3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,OAAO,EACL,kCAAkC,EAClC,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC;IACzD,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;IACtB,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE;QAAE,GAAG,IAAI,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,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,CAAC,kBAAkB,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,CAAC;SACjE,CAAC;KACL,CAAC;AACJ,CAAC,CAAC","sourcesContent":["'use client';\n\nimport type {\n ReflectedOperationInvocation,\n ReflectedOperationInvoker,\n} from '@ontahi/core/data-graph';\nimport {\n normalizeGraphSchemaClientInput,\n resolveOperationExecutionAffordance,\n} from '@ontahi/core/data-graph';\nimport type { OperationInvocationResult } from '@ontahi/core/runtime/contracts';\nimport {\n isOperationInvocationProtocolResponse,\n type OperationInvocationRequest,\n} from '@ontahi/core/runtime/operation-invocation';\nimport {\n createRuntimeProtocolExchange,\n createRuntimeProtocolExecutionExchange,\n toOperationProtocolRequest,\n type RuntimeProtocolExecutionExchangeResult,\n type RuntimeTransport,\n} from '@ontahi/core/runtime/protocol';\nimport { useMemo } from 'react';\n\nimport { createFetchRuntimeTransport } from '../graph/fetch-runtime-transport.js';\n\nimport {\n attachOperationBridgeActionRuntime,\n toOperationInvocationResult,\n unwrapOperationInvocationValue,\n} from './operation-bridge.js';\nimport type * as OperationBridge from './operation-bridge.js';\nimport { useServerMutation, useServerQuery } from './react-query.js';\nimport type { ActionResultLike } from './use-action.js';\n\nexport type FetchOperationBridgeOptions<TTransportOptions = undefined> = {\n /** @deprecated Select the legacy Operation route through createFetchGraphClient compatibility. */\n mountPath?: string;\n /** @deprecated Select the legacy Operation route through createFetchGraphClient compatibility. */\n endpoint?: string;\n fetch?: typeof globalThis.fetch;\n requestInit?: (options?: TTransportOptions) => Omit<RequestInit, 'body' | 'method'>;\n runtimeTransport?: RuntimeTransport<TTransportOptions>;\n requestId?: () => string;\n};\n\nconst normalizeMountPath = (value: string) => {\n const path = value.startsWith('/') ? value : `/${value}`;\n let end = path.length;\n while (end > 0 && path.charCodeAt(end - 1) === 47) end -= 1;\n return path.slice(0, end);\n};\n\nconst mountedEndpoint = (mountPath: string, endpoint: string) =>\n `${normalizeMountPath(mountPath)}/${endpoint}`;\n\nconst operationEndpoint = <TTransportOptions>(\n options: FetchOperationBridgeOptions<TTransportOptions>,\n) =>\n options.endpoint ??\n (options.mountPath ? mountedEndpoint(options.mountPath, 'operations') : undefined);\n\nconst attachFetchBridgeRuntime = <TInput, TData>(\n operation: OperationBridge.BridgedOperationLike<TInput, TData>,\n action: OperationBridge.OperationBridgeAction<TInput, TData>,\n) =>\n attachOperationBridgeActionRuntime(operation, action, {\n requiresAuth: operation.authority !== 'server' ? false : operation.exposure !== 'bridge',\n });\n\ntype OperationRequest = (\n request: OperationInvocationRequest,\n) => Promise<RuntimeProtocolExecutionExchangeResult>;\n\nconst postLegacyBridgeRequest = async <TTransportOptions>(\n endpoint: string,\n request: OperationInvocationRequest,\n fetchRequest: typeof globalThis.fetch,\n requestInit: ((options?: TTransportOptions) => Omit<RequestInit, 'body' | 'method'>) | undefined,\n): Promise<RuntimeProtocolExecutionExchangeResult> => {\n const init = requestInit?.() ?? {};\n const headers = new Headers(init.headers);\n if (!headers.has('content-type')) headers.set('content-type', 'application/json');\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 const payload: unknown = await response.json().catch(() => null);\n if (!response.ok && !isOperationInvocationProtocolResponse(payload)) {\n throw new Error(`Graph bridge request failed with status ${response.status}.`);\n }\n return { body: payload };\n};\n\nconst createOperationRequest = <TTransportOptions>(\n options: FetchOperationBridgeOptions<TTransportOptions>,\n): OperationRequest => {\n const endpoint = operationEndpoint(options);\n if (endpoint) {\n return request =>\n postLegacyBridgeRequest(\n endpoint,\n request,\n options.fetch ?? globalThis.fetch,\n options.requestInit,\n );\n }\n\n const transport =\n options.runtimeTransport ??\n createFetchRuntimeTransport<TTransportOptions>({\n ...(options.fetch ? { fetch: options.fetch } : {}),\n ...(options.requestInit ? { requestInit: options.requestInit } : {}),\n });\n const exchange = createRuntimeProtocolExchange({\n transport,\n requestId: options.requestId,\n });\n const executionExchange = createRuntimeProtocolExecutionExchange({\n transport,\n requestId: options.requestId,\n });\n return async request =>\n request.kind === 'invoke'\n ? executionExchange({\n family: 'operation',\n body: toOperationProtocolRequest(request),\n })\n : {\n body: await exchange({\n family: 'operation',\n body: toOperationProtocolRequest(request),\n }),\n };\n};\n\nconst errorMessage = (error: unknown) =>\n error instanceof Error ? error.message : 'Graph bridge request failed.';\n\nconst postBridgeRequest = async <TData>(\n requestOperation: OperationRequest,\n request: OperationInvocationRequest,\n): Promise<ActionResultLike & { data?: TData }> => {\n let execution: RuntimeProtocolExecutionExchangeResult;\n try {\n execution = await requestOperation(request);\n } catch (error) {\n return { serverError: errorMessage(error) };\n }\n const payload = execution.body;\n const executionMetadata = execution.metadata;\n\n if (!isOperationInvocationProtocolResponse(payload)) {\n return { serverError: 'Graph bridge returned an invalid response.' };\n }\n\n if (payload.kind === 'protocol-error') {\n return { serverError: payload.error.message };\n }\n\n if (request.kind === 'invoke' && payload.kind === 'invocation-result') {\n return {\n data: payload.result as TData,\n ...(executionMetadata ? { executionMetadata } : {}),\n };\n }\n\n if (request.kind === 'check-permission' && payload.kind === 'permission-result') {\n return { data: payload.result as TData };\n }\n\n return { serverError: 'Graph bridge returned an invalid response.' };\n};\n\nconst createFetchBridgeAction = <TInput, TData>(\n requestOperation: OperationRequest,\n operation: OperationBridge.BridgedOperationLike<TInput, TData>,\n): OperationBridge.OperationBridgeAction<TInput, TData> =>\n attachFetchBridgeRuntime(operation, (input: TInput) => {\n const portableInput = operation.input\n ? normalizeGraphSchemaClientInput(operation.input, input, {\n bindSelection: selection => selection.toAst(),\n })\n : input;\n return postBridgeRequest<OperationInvocationResult<TData>>(requestOperation, {\n kind: 'invoke',\n operationId: operation.id,\n input: portableInput,\n ...(operation.view ? { view: operation.view } : {}),\n });\n }) as OperationBridge.OperationBridgeAction<TInput, TData>;\n\nconst createFetchPermissionAction =\n <TInput, TData>(\n requestOperation: OperationRequest,\n operation: OperationBridge.BridgedOperationLike<TInput, TData>,\n ): ((\n input: TInput,\n ) => Promise<OperationBridge.OperationBridgeActionResult<OperationBridge.GraphPermission>>) =>\n (input: TInput) =>\n postBridgeRequest<OperationBridge.GraphPermission>(requestOperation, {\n kind: 'check-permission',\n operationId: operation.id,\n input: operation.input\n ? normalizeGraphSchemaClientInput(operation.input, input, {\n bindSelection: selection => selection.toAst(),\n })\n : input,\n });\n\nexport const createFetchReflectedOperationInvoker = <TTransportOptions = undefined>(\n options: FetchOperationBridgeOptions<TTransportOptions> = {},\n): ReflectedOperationInvoker => {\n const requestOperation = createOperationRequest(options);\n const canInvokeOperation: NonNullable<\n ReflectedOperationInvoker['canInvokeOperation']\n > = operation =>\n operation.kind === undefined\n ? operation.exposure === undefined || operation.exposure === 'bridge'\n : operation.kind !== 'graph' && operation.exposure === 'bridge';\n\n return {\n canInvokeOperation,\n getOperationExecutionAffordance: operation =>\n resolveOperationExecutionAffordance(operation, {\n ...(canInvokeOperation(operation)\n ? {\n bridge: {\n authority: operation.authority ?? 'server',\n bridge: 'fetch',\n },\n }\n : {}),\n }),\n invokeOperation: async <TInput = unknown, TData = unknown>({\n input,\n operationId,\n view,\n }: ReflectedOperationInvocation<TInput>) =>\n toOperationInvocationResult<TData>(\n await postBridgeRequest<OperationInvocationResult<TData>>(requestOperation, {\n kind: 'invoke',\n operationId,\n input,\n ...(view ? { view } : {}),\n }),\n ),\n };\n};\n\nexport const createFetchOperationBridgeAdapter = <TTransportOptions = undefined>(\n options: FetchOperationBridgeOptions<TTransportOptions> = {},\n): OperationBridge.AnyOperationBridgeAdapter => {\n const requestOperation = createOperationRequest(options);\n const buildRuntimeAction = <TInput, TData>(\n operation: OperationBridge.BridgedOperationLike<TInput, TData>,\n ) => createFetchBridgeAction(requestOperation, operation);\n\n return {\n name: 'fetch',\n useBridgeAction: operation =>\n useMemo(\n () => buildRuntimeAction(operation) as OperationBridge.OperationBridgeAction<any, any>,\n [operation],\n ) as OperationBridge.OperationBridgeAction<any, any>,\n useBridgeMutation: (operation, options) => {\n const action = useMemo(() => buildRuntimeAction(operation), [operation]);\n\n return useServerMutation(\n action as OperationBridge.OperationBridgeAction<unknown, unknown>,\n options as Parameters<\n typeof useServerMutation<OperationBridge.OperationBridgeAction<unknown, unknown>>\n >[1],\n ) as ReturnType<typeof useServerMutation<OperationBridge.OperationBridgeAction<any, any>>>;\n },\n useBridgeQuery: (operation, args) => {\n const action = useMemo(() => buildRuntimeAction(operation), [operation]);\n\n return useServerQuery({\n action: action as OperationBridge.OperationBridgeAction<unknown, unknown>,\n input: args.input as unknown,\n key: args.key,\n select: unwrapOperationInvocationValue,\n }) as any;\n },\n usePermission: (operation, input, args) =>\n useServerQuery({\n enabled: args?.enabled,\n action: createFetchPermissionAction(requestOperation, operation),\n input,\n key: args?.queryKey ?? ['graph-permission', operation.id, input],\n }),\n };\n};\n"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ClientDomainOperationDeclaration, EntityViewAst } from '@ontahi/core/data-graph';
|
|
2
2
|
import { type ActionQueryKey } from '@ontahi/core/runtime/actions';
|
|
3
3
|
import type { OperationInvocationResult } from '@ontahi/core/runtime/contracts';
|
|
4
|
+
import type { RuntimeProtocolExecutionMetadata } from '@ontahi/core/runtime/protocol';
|
|
4
5
|
import type { QueryKey, UseQueryResult } from '@tanstack/react-query';
|
|
5
6
|
import type { ActionResultLike, UseActionOptions, UseActionResult } from './use-action.js';
|
|
6
7
|
export type { OperationInvocationResult };
|
|
7
8
|
export type OperationBridgeActionResult<TData> = Omit<ActionResultLike, 'data'> & {
|
|
8
9
|
data?: TData;
|
|
10
|
+
executionMetadata?: RuntimeProtocolExecutionMetadata;
|
|
9
11
|
};
|
|
10
12
|
export type OperationBridgeAction<TInput, TData> = (input: TInput) => Promise<OperationBridgeActionResult<OperationInvocationResult<TData>>>;
|
|
11
13
|
export type OperationInvocationFailure<TFailure = unknown> = Exclude<OperationInvocationResult<unknown, TFailure>, {
|
|
@@ -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;AACjC,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;
|
|
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;AACjC,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AAEtF,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;IACb,iBAAiB,CAAC,EAAE,gCAAgC,CAAC;CACtD,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;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;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 {\n attachActionRuntime,\n getActionErrorMessage,\n hasActionError,\n type ActionQueryKey,\n} from '@ontahi/core/runtime/actions';\nimport type { OperationInvocationResult } 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 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 return [\n operation.entityName,\n operation.name,\n ...(operation.view ? [operation.view] : []),\n ...(operation.bridge?.query?.map(segment =>\n resolveOperationBridgeQueryKeySegment(segment, operation, input),\n ) ?? []),\n ];\n};\n\nexport const resolveOperationBridgeInvalidationQueryKeys = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n input: TInput,\n): ActionQueryKey[] => {\n return (\n operation.bridge?.invalidate?.map(querySpec =>\n querySpec.map(segment => resolveOperationBridgeQueryKeySegment(segment, operation, input)),\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,EACL,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,GAEf,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAqBrD,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,QAAQ,EAAE,CAAC;YAC7B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE;gBACnC,YAAY,EAAE,IAAI;gBAClB,KAAK,EAAE,MAAM,CAAC,OAAO;aACtB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;YAC1D,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;CACF;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,KAAc,EACuC,EAAE,CACvD,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,EAAE,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,I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kCAAkC,GAAG,CAChD,SAA8C,EAC9C,MAA4C,EAC5C,OAEC,EACD,EAAE,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 {\n attachActionRuntime,\n getActionErrorMessage,\n hasActionError,\n type ActionQueryKey,\n} from '@ontahi/core/runtime/actions';\nimport type { OperationInvocationResult } from '@ontahi/core/runtime/contracts';\nimport type { RuntimeProtocolExecutionMetadata } from '@ontahi/core/runtime/protocol';\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 executionMetadata?: RuntimeProtocolExecutionMetadata;\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 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 return [\n operation.entityName,\n operation.name,\n ...(operation.view ? [operation.view] : []),\n ...(operation.bridge?.query?.map(segment =>\n resolveOperationBridgeQueryKeySegment(segment, operation, input),\n ) ?? []),\n ];\n};\n\nexport const resolveOperationBridgeInvalidationQueryKeys = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n input: TInput,\n): ActionQueryKey[] => {\n return (\n operation.bridge?.invalidate?.map(querySpec =>\n querySpec.map(segment => resolveOperationBridgeQueryKeySegment(segment, operation, input)),\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"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ModelCommandCanonicalRequest } from '@ontahi/core/runtime/protocol';
|
|
2
|
+
import { type QueryClient, type QueryKey } from '@tanstack/react-query';
|
|
3
|
+
import { type BridgedOperationLike } from '../actions/index.js';
|
|
4
|
+
export type CanonicalRequestInvalidation = {
|
|
5
|
+
readonly kind: 'read' | 'graph-command' | 'operation';
|
|
6
|
+
readonly queryKeys: readonly QueryKey[];
|
|
7
|
+
};
|
|
8
|
+
export declare const invalidateCanonicalRequest: (queryClient: QueryClient, request: ModelCommandCanonicalRequest, operations: ReadonlyMap<string, BridgedOperationLike<any, any>>) => Promise<CanonicalRequestInvalidation>;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Compatibility fallback for receivers without committed mutation metadata. Prefer
|
|
11
|
+
* semantic mutation hooks or `invalidateSemanticGraphReads` with Runtime Protocol metadata.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useCanonicalRequestInvalidation: (operations: readonly BridgedOperationLike<any, any>[]) => (request: ModelCommandCanonicalRequest) => Promise<CanonicalRequestInvalidation>;
|
|
14
|
+
//# sourceMappingURL=canonical-request-invalidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-request-invalidation.d.ts","sourceRoot":"","sources":["../../src/graph/canonical-request-invalidation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAkB,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGxF,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,4BAA4B,GAAG;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,WAAW,CAAC;IACtD,QAAQ,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;CACzC,CAAC;AAYF,eAAO,MAAM,0BAA0B,GACrC,aAAa,WAAW,EACxB,SAAS,4BAA4B,EACrC,YAAY,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAC9D,OAAO,CAAC,4BAA4B,CAmBtC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,+BAA+B,GAC1C,YAAY,SAAS,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,eASzC,4BAA4B,0CAIzC,CAAC"}
|