@ontahi/react 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +12 -0
  4. package/dist/actions/fetch-operation-bridge-adapter.d.ts +10 -0
  5. package/dist/actions/fetch-operation-bridge-adapter.d.ts.map +1 -0
  6. package/dist/actions/fetch-operation-bridge-adapter.js +111 -0
  7. package/dist/actions/fetch-operation-bridge-adapter.js.map +1 -0
  8. package/dist/actions/index.d.ts +6 -0
  9. package/dist/actions/index.d.ts.map +1 -0
  10. package/dist/actions/index.js +6 -0
  11. package/dist/actions/index.js.map +1 -0
  12. package/dist/actions/operation-bridge-adapter.d.ts +7 -0
  13. package/dist/actions/operation-bridge-adapter.d.ts.map +1 -0
  14. package/dist/actions/operation-bridge-adapter.js +44 -0
  15. package/dist/actions/operation-bridge-adapter.js.map +1 -0
  16. package/dist/actions/operation-bridge.d.ts +69 -0
  17. package/dist/actions/operation-bridge.d.ts.map +1 -0
  18. package/dist/actions/operation-bridge.js +72 -0
  19. package/dist/actions/operation-bridge.js.map +1 -0
  20. package/dist/actions/react-query.d.ts +25 -0
  21. package/dist/actions/react-query.d.ts.map +1 -0
  22. package/dist/actions/react-query.js +71 -0
  23. package/dist/actions/react-query.js.map +1 -0
  24. package/dist/actions/use-action.d.ts +46 -0
  25. package/dist/actions/use-action.d.ts.map +1 -0
  26. package/dist/actions/use-action.js +112 -0
  27. package/dist/actions/use-action.js.map +1 -0
  28. package/dist/graph/context.d.ts +45 -0
  29. package/dist/graph/context.d.ts.map +1 -0
  30. package/dist/graph/context.js +103 -0
  31. package/dist/graph/context.js.map +1 -0
  32. package/dist/graph/executor.d.ts +41 -0
  33. package/dist/graph/executor.d.ts.map +1 -0
  34. package/dist/graph/executor.js +2 -0
  35. package/dist/graph/executor.js.map +1 -0
  36. package/dist/graph/graph-hooks.d.ts +6 -0
  37. package/dist/graph/graph-hooks.d.ts.map +1 -0
  38. package/dist/graph/graph-hooks.js +61 -0
  39. package/dist/graph/graph-hooks.js.map +1 -0
  40. package/dist/graph/index.d.ts +9 -0
  41. package/dist/graph/index.d.ts.map +1 -0
  42. package/dist/graph/index.js +10 -0
  43. package/dist/graph/index.js.map +1 -0
  44. package/dist/graph/operation-cache.d.ts +5 -0
  45. package/dist/graph/operation-cache.d.ts.map +1 -0
  46. package/dist/graph/operation-cache.js +17 -0
  47. package/dist/graph/operation-cache.js.map +1 -0
  48. package/dist/graph/operation-hooks.d.ts +20 -0
  49. package/dist/graph/operation-hooks.d.ts.map +1 -0
  50. package/dist/graph/operation-hooks.js +360 -0
  51. package/dist/graph/operation-hooks.js.map +1 -0
  52. package/dist/graph/operation-types.d.ts +113 -0
  53. package/dist/graph/operation-types.d.ts.map +1 -0
  54. package/dist/graph/operation-types.js +2 -0
  55. package/dist/graph/operation-types.js.map +1 -0
  56. package/dist/graph/reflected-entity-data-hooks.d.ts +8 -0
  57. package/dist/graph/reflected-entity-data-hooks.d.ts.map +1 -0
  58. package/dist/graph/reflected-entity-data-hooks.js +17 -0
  59. package/dist/graph/reflected-entity-data-hooks.js.map +1 -0
  60. package/dist/graph/reflected-operation-invoker.d.ts +12 -0
  61. package/dist/graph/reflected-operation-invoker.d.ts.map +1 -0
  62. package/dist/graph/reflected-operation-invoker.js +42 -0
  63. package/dist/graph/reflected-operation-invoker.js.map +1 -0
  64. package/dist/index.d.ts +2 -0
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.js +2 -0
  67. package/dist/index.js.map +1 -0
  68. package/package.json +80 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Ontahi
2
+ Copyright 2026 Javier Fernandes
3
+
4
+ This product includes software developed for the Ontahi project.
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @ontahi/react
2
+
3
+ Non-visual React integration for Ontahi applications.
4
+
5
+ This package depends on `@ontahi/core`. It owns React hooks and bridge adapters that are generic to React clients:
6
+
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.
9
+
10
+ The generic action metadata and result protocol comes from `@ontahi/core/runtime/actions`; Next.js-specific transport remains in `@ontahi/runtime-nextjs`.
11
+
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.
@@ -0,0 +1,10 @@
1
+ import type { ReflectedOperationInvoker } from '@ontahi/core/data-graph';
2
+ import type * as OperationBridge from './operation-bridge.js';
3
+ export type FetchOperationBridgeOptions = {
4
+ mountPath?: string;
5
+ endpoint?: string;
6
+ taskEndpoint?: string;
7
+ };
8
+ export declare const createFetchReflectedOperationInvoker: (options?: FetchOperationBridgeOptions) => ReflectedOperationInvoker;
9
+ export declare const createFetchOperationBridgeAdapter: (options?: FetchOperationBridgeOptions) => OperationBridge.AnyOperationBridgeAdapter;
10
+ //# sourceMappingURL=fetch-operation-bridge-adapter.d.ts.map
@@ -0,0 +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;AAiBjC,OAAO,KAAK,KAAK,eAAe,MAAM,uBAAuB,CAAC;AAI9D,MAAM,MAAM,2BAA2B,GAAG;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AA4GF,eAAO,MAAM,oCAAoC,GAC/C,UAAS,2BAAgC,KACxC,yBAoBF,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAC5C,UAAS,2BAAgC,KACxC,eAAe,CAAC,yBA+ClB,CAAC"}
@@ -0,0 +1,111 @@
1
+ 'use client';
2
+ import { isOperationInvocationProtocolResponse, } from '@ontahi/core/runtime/operation-invocation';
3
+ import { useMemo } from 'react';
4
+ import { attachOperationBridgeActionRuntime, toOperationInvocationResult, unwrapOperationInvocationValue, } from './operation-bridge.js';
5
+ import { useServerMutation, useServerQuery } from './react-query.js';
6
+ const DEFAULT_ENDPOINT = '/api/data-graph/domain-operations';
7
+ const normalizeMountPath = (value) => {
8
+ const path = value.startsWith('/') ? value : `/${value}`;
9
+ return path === '/' ? '' : path.replace(/\/+$/, '');
10
+ };
11
+ const mountedEndpoint = (mountPath, endpoint) => `${normalizeMountPath(mountPath)}/${endpoint}`;
12
+ const operationEndpoint = (options) => options.endpoint ??
13
+ (options.mountPath ? mountedEndpoint(options.mountPath, 'operations') : DEFAULT_ENDPOINT);
14
+ const operationTaskEndpoint = (options) => options.taskEndpoint ??
15
+ (options.mountPath ? mountedEndpoint(options.mountPath, 'operations/tasks') : undefined);
16
+ const fetchTaskSnapshot = async (endpoint, ref) => {
17
+ const response = await fetch(`${endpoint}/${encodeURIComponent(ref.taskId)}/${encodeURIComponent(ref.runId)}`, { credentials: 'same-origin' });
18
+ const payload = await response.json().catch(() => null);
19
+ if (!response.ok || typeof payload !== 'object' || payload === null) {
20
+ throw new Error(`Task snapshot request failed with status ${response.status}.`);
21
+ }
22
+ return payload;
23
+ };
24
+ const attachFetchBridgeRuntime = (operation, action) => attachOperationBridgeActionRuntime(operation, action, {
25
+ requiresAuth: operation.authority !== 'server' ? false : operation.exposure !== 'bridge',
26
+ });
27
+ const postBridgeRequest = async (endpoint, request) => {
28
+ const response = await fetch(endpoint, {
29
+ method: 'POST',
30
+ headers: {
31
+ 'content-type': 'application/json',
32
+ },
33
+ credentials: 'same-origin',
34
+ body: JSON.stringify(request),
35
+ });
36
+ const payload = await response.json().catch(() => null);
37
+ if (!isOperationInvocationProtocolResponse(payload)) {
38
+ return {
39
+ serverError: response.ok
40
+ ? 'Graph bridge returned an invalid response.'
41
+ : `Graph bridge request failed with status ${response.status}.`,
42
+ };
43
+ }
44
+ if (payload.kind === 'protocol-error') {
45
+ return { serverError: payload.error.message };
46
+ }
47
+ if (request.kind === 'invoke' && payload.kind === 'invocation-result') {
48
+ return { data: payload.result };
49
+ }
50
+ if (request.kind === 'check-permission' && payload.kind === 'permission-result') {
51
+ return { data: payload.result };
52
+ }
53
+ return { serverError: 'Graph bridge returned an invalid response.' };
54
+ };
55
+ const createFetchBridgeAction = (endpoint, operation) => attachFetchBridgeRuntime(operation, (input) => postBridgeRequest(endpoint, {
56
+ kind: 'invoke',
57
+ operationId: operation.id,
58
+ input,
59
+ }));
60
+ const createFetchPermissionAction = (endpoint, operation) => (input) => postBridgeRequest(endpoint, {
61
+ kind: 'check-permission',
62
+ operationId: operation.id,
63
+ input,
64
+ });
65
+ export const createFetchReflectedOperationInvoker = (options = {}) => {
66
+ const endpoint = operationEndpoint(options);
67
+ return {
68
+ canInvokeOperation: operation => operation.kind === undefined
69
+ ? operation.exposure === undefined || operation.exposure === 'bridge'
70
+ : operation.kind !== 'graph' && operation.exposure === 'bridge',
71
+ invokeOperation: async ({ input, operationId, }) => toOperationInvocationResult(await postBridgeRequest(endpoint, {
72
+ kind: 'invoke',
73
+ operationId,
74
+ input,
75
+ })),
76
+ };
77
+ };
78
+ export const createFetchOperationBridgeAdapter = (options = {}) => {
79
+ const endpoint = operationEndpoint(options);
80
+ const taskEndpoint = operationTaskEndpoint(options);
81
+ const buildRuntimeAction = (operation) => createFetchBridgeAction(endpoint, operation);
82
+ return {
83
+ name: 'fetch',
84
+ ...(taskEndpoint
85
+ ? {
86
+ getTaskSnapshot: (ref) => fetchTaskSnapshot(taskEndpoint, ref),
87
+ }
88
+ : {}),
89
+ useBridgeAction: operation => useMemo(() => buildRuntimeAction(operation), [operation]),
90
+ useBridgeMutation: (operation, options) => {
91
+ const action = useMemo(() => buildRuntimeAction(operation), [operation]);
92
+ return useServerMutation(action, options);
93
+ },
94
+ useBridgeQuery: (operation, args) => {
95
+ const action = useMemo(() => buildRuntimeAction(operation), [operation]);
96
+ return useServerQuery({
97
+ action: action,
98
+ input: args.input,
99
+ key: args.key,
100
+ select: unwrapOperationInvocationValue,
101
+ });
102
+ },
103
+ usePermission: (operation, input, args) => useServerQuery({
104
+ enabled: args?.enabled,
105
+ action: createFetchPermissionAction(endpoint, operation),
106
+ input,
107
+ key: args?.queryKey ?? ['graph-permission', operation.id, input],
108
+ }),
109
+ };
110
+ };
111
+ //# sourceMappingURL=fetch-operation-bridge-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-operation-bridge-adapter.js","sourceRoot":"","sources":["../../src/actions/fetch-operation-bridge-adapter.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAWb,OAAO,EACL,qCAAqC,GAEtC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EACL,kCAAkC,EAClC,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASrE,MAAM,gBAAgB,GAAG,mCAAmC,CAAC;AAE7D,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,OAAO,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,C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AAE,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 type {\n OperationInvocationResult,\n TaskRunIdentity,\n TaskSnapshot,\n} 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 taskEndpoint?: 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 operationTaskEndpoint = (options: FetchOperationBridgeOptions) =>\n options.taskEndpoint ??\n (options.mountPath ? mountedEndpoint(options.mountPath, 'operations/tasks') : undefined);\n\nconst fetchTaskSnapshot = async <TResult>(\n endpoint: string,\n ref: TaskRunIdentity,\n): Promise<TaskSnapshot<TResult>> => {\n const response = await fetch(\n `${endpoint}/${encodeURIComponent(ref.taskId)}/${encodeURIComponent(ref.runId)}`,\n { credentials: 'same-origin' },\n );\n const payload: unknown = await response.json().catch(() => null);\n\n if (!response.ok || typeof payload !== 'object' || payload === null) {\n throw new Error(`Task snapshot request failed with status ${response.status}.`);\n }\n\n return payload as TaskSnapshot<TResult>;\n};\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 }),\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\n return {\n canInvokeOperation: operation =>\n operation.kind === undefined\n ? operation.exposure === undefined || operation.exposure === 'bridge'\n : operation.kind !== 'graph' && operation.exposure === 'bridge',\n invokeOperation: async <TInput = unknown, TData = unknown>({\n input,\n operationId,\n }: ReflectedOperationInvocation<TInput>) =>\n toOperationInvocationResult<TData>(\n await postBridgeRequest<OperationInvocationResult<TData>>(endpoint, {\n kind: 'invoke',\n operationId,\n input,\n }),\n ),\n };\n};\n\nexport const createFetchOperationBridgeAdapter = (\n options: FetchOperationBridgeOptions = {},\n): OperationBridge.AnyOperationBridgeAdapter => {\n const endpoint = operationEndpoint(options);\n const taskEndpoint = operationTaskEndpoint(options);\n const buildRuntimeAction = <TInput, TData>(\n operation: OperationBridge.BridgedOperationLike<TInput, TData>,\n ) => createFetchBridgeAction(endpoint, operation);\n\n return {\n name: 'fetch',\n ...(taskEndpoint\n ? {\n getTaskSnapshot: (ref: TaskRunIdentity) => fetchTaskSnapshot(taskEndpoint, ref),\n }\n : {}),\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"]}
@@ -0,0 +1,6 @@
1
+ export * from './use-action.js';
2
+ export * from './react-query.js';
3
+ export * from './operation-bridge.js';
4
+ export * from './operation-bridge-adapter.js';
5
+ export * from './fetch-operation-bridge-adapter.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './use-action.js';
2
+ export * from './react-query.js';
3
+ export * from './operation-bridge.js';
4
+ export * from './operation-bridge-adapter.js';
5
+ export * from './fetch-operation-bridge-adapter.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC","sourcesContent":["export * from './use-action.js';\nexport * from './react-query.js';\nexport * from './operation-bridge.js';\nexport * from './operation-bridge-adapter.js';\nexport * from './fetch-operation-bridge-adapter.js';\n"]}
@@ -0,0 +1,7 @@
1
+ import type { TaskRunIdentity, TaskSnapshot } from '@ontahi/core/runtime/contracts';
2
+ import { type AnyOperationBridgeAdapter, type CheckDomainOperationPermissionBridgeAction, type RunDomainOperationBridgeAction } from './operation-bridge.js';
3
+ export declare const createNextActionOperationBridgeAdapter: (bridgeAction: RunDomainOperationBridgeAction, options?: {
4
+ checkPermissionAction?: CheckDomainOperationPermissionBridgeAction;
5
+ getTaskSnapshot?: <TResult = unknown>(ref: TaskRunIdentity) => Promise<TaskSnapshot<TResult>>;
6
+ }) => AnyOperationBridgeAdapter;
7
+ //# sourceMappingURL=operation-bridge-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-bridge-adapter.d.ts","sourceRoot":"","sources":["../../src/actions/operation-bridge-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGpF,OAAO,EAIL,KAAK,yBAAyB,EAE9B,KAAK,0CAA0C,EAE/C,KAAK,8BAA8B,EACpC,MAAM,uBAAuB,CAAC;AAuB/B,eAAO,MAAM,sCAAsC,GACjD,cAAc,8BAA8B,EAC5C,UAAU;IACR,qBAAqB,CAAC,EAAE,0CAA0C,CAAC;IACnE,eAAe,CAAC,EAAE,CAAC,OAAO,GAAG,OAAO,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;CAC/F,KACA,yBA+CF,CAAC"}
@@ -0,0 +1,44 @@
1
+ 'use client';
2
+ import { useMemo } from 'react';
3
+ import { attachOperationBridgeActionRuntime, createDomainOperationBridgeAction, unwrapOperationInvocationValue, } from './operation-bridge.js';
4
+ import { useServerMutation, useServerQuery } from './react-query.js';
5
+ const attachNextActionBridgeRuntime = (operation, action) => attachOperationBridgeActionRuntime(operation, action, {
6
+ requiresAuth: operation.authority !== 'server' ? false : operation.exposure !== 'bridge',
7
+ });
8
+ const createRuntimeBridgeAction = (bridgeAction, operation) => attachNextActionBridgeRuntime(operation, createDomainOperationBridgeAction(bridgeAction, operation.id));
9
+ export const createNextActionOperationBridgeAdapter = (bridgeAction, options) => {
10
+ const buildRuntimeAction = (operation) => createRuntimeBridgeAction(bridgeAction, operation);
11
+ return {
12
+ name: 'next-action',
13
+ getTaskSnapshot: options?.getTaskSnapshot,
14
+ useBridgeAction: operation => useMemo(() => buildRuntimeAction(operation), [operation]),
15
+ useBridgeMutation: (operation, options) => {
16
+ const action = useMemo(() => buildRuntimeAction(operation), [operation]);
17
+ return useServerMutation(action, options);
18
+ },
19
+ useBridgeQuery: (operation, args) => {
20
+ const action = useMemo(() => buildRuntimeAction(operation), [operation]);
21
+ return useServerQuery({
22
+ action: action,
23
+ input: args.input,
24
+ key: args.key,
25
+ select: unwrapOperationInvocationValue,
26
+ });
27
+ },
28
+ usePermission: (operation, input, args) => useServerQuery({
29
+ enabled: args?.enabled,
30
+ action: async (_input) => {
31
+ if (!options?.checkPermissionAction) {
32
+ throw new Error('No operation permission bridge action registered.');
33
+ }
34
+ return options.checkPermissionAction({
35
+ operationId: operation.id,
36
+ input,
37
+ });
38
+ },
39
+ input: undefined,
40
+ key: args?.queryKey ?? ['graph-permission', operation.id, input],
41
+ }),
42
+ };
43
+ };
44
+ //# sourceMappingURL=operation-bridge-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-bridge-adapter.js","sourceRoot":"","sources":["../../src/actions/operation-bridge-adapter.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EACL,kCAAkC,EAClC,iCAAiC,EACjC,8BAA8B,GAM/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,6BAA6B,GAAG,CACpC,SAA8C,EAC9C,MAA4C,EAC5C,EAA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C,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,KAAK,EAAE,MAAiB,EAAE,EAAE;gBAClC,IAAI,CAAC,OAAO,EAAE,qBAAqB,EAAE,CAAC;oBACpC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;gBACvE,CAAC;gBAED,OAAO,OAAO,CAAC,qBAAqB,CAAC;oBACnC,WAAW,EAAE,SAAS,CAAC,EAAE;oBACzB,KAAK;iBACN,CAAC,CAAC;YACL,CAAC;YACD,KAAK,EAAE,SAAS;YAChB,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 { TaskRunIdentity, TaskSnapshot } from '@ontahi/core/runtime/contracts';\nimport { useMemo } from 'react';\n\nimport {\n attachOperationBridgeActionRuntime,\n createDomainOperationBridgeAction,\n unwrapOperationInvocationValue,\n type AnyOperationBridgeAdapter,\n type BridgedOperationLike,\n type CheckDomainOperationPermissionBridgeAction,\n type OperationBridgeAction,\n type RunDomainOperationBridgeAction,\n} from './operation-bridge.js';\nimport { useServerMutation, useServerQuery } from './react-query.js';\n\nconst attachNextActionBridgeRuntime = <TInput, TData>(\n operation: BridgedOperationLike<TInput, TData>,\n action: OperationBridgeAction<TInput, TData>,\n) =>\n attachOperationBridgeActionRuntime(operation, action, {\n requiresAuth: operation.authority !== 'server' ? false : operation.exposure !== 'bridge',\n });\n\nconst createRuntimeBridgeAction = <TInput, TData>(\n bridgeAction: RunDomainOperationBridgeAction,\n operation: BridgedOperationLike<TInput, TData>,\n): OperationBridgeAction<TInput, TData> =>\n attachNextActionBridgeRuntime(\n operation,\n createDomainOperationBridgeAction(bridgeAction, operation.id) as OperationBridgeAction<\n TInput,\n TData\n >,\n ) as OperationBridgeAction<TInput, TData>;\n\nexport const createNextActionOperationBridgeAdapter = (\n bridgeAction: RunDomainOperationBridgeAction,\n options?: {\n checkPermissionAction?: CheckDomainOperationPermissionBridgeAction;\n getTaskSnapshot?: <TResult = unknown>(ref: TaskRunIdentity) => Promise<TaskSnapshot<TResult>>;\n },\n): AnyOperationBridgeAdapter => {\n const buildRuntimeAction = <TInput, TData>(operation: BridgedOperationLike<TInput, TData>) =>\n createRuntimeBridgeAction(bridgeAction, operation);\n\n return {\n name: 'next-action',\n getTaskSnapshot: options?.getTaskSnapshot,\n useBridgeAction: operation =>\n useMemo(\n () => buildRuntimeAction(operation) as OperationBridgeAction<any, any>,\n [operation],\n ) as OperationBridgeAction<any, any>,\n useBridgeMutation: (operation, options) => {\n const action = useMemo(() => buildRuntimeAction(operation), [operation]);\n\n return useServerMutation(\n action as OperationBridgeAction<unknown, unknown>,\n options as Parameters<typeof useServerMutation<OperationBridgeAction<unknown, unknown>>>[1],\n ) as ReturnType<typeof useServerMutation<OperationBridgeAction<any, any>>>;\n },\n useBridgeQuery: (operation, args) => {\n const action = useMemo(() => buildRuntimeAction(operation), [operation]);\n\n return useServerQuery({\n action: action as 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: async (_input: undefined) => {\n if (!options?.checkPermissionAction) {\n throw new Error('No operation permission bridge action registered.');\n }\n\n return options.checkPermissionAction({\n operationId: operation.id,\n input,\n });\n },\n input: undefined,\n key: args?.queryKey ?? ['graph-permission', operation.id, input],\n }),\n };\n};\n"]}
@@ -0,0 +1,69 @@
1
+ import type { ClientDomainOperationDeclaration } from '@ontahi/core/data-graph';
2
+ import { type ActionQueryKey } from '@ontahi/core/runtime/actions';
3
+ import type { OperationInvocationResult, TaskRunIdentity, TaskSnapshot } from '@ontahi/core/runtime/contracts';
4
+ import type { QueryKey, UseQueryResult } from '@tanstack/react-query';
5
+ import type { ActionResultLike, UseActionOptions, UseActionResult } from './use-action.js';
6
+ export type { OperationInvocationResult };
7
+ export type OperationBridgeActionResult<TData> = Omit<ActionResultLike, 'data'> & {
8
+ data?: TData;
9
+ };
10
+ export type OperationBridgeAction<TInput, TData> = (input: TInput) => Promise<OperationBridgeActionResult<OperationInvocationResult<TData>>>;
11
+ export type OperationInvocationFailure<TFailure = unknown> = Exclude<OperationInvocationResult<unknown, TFailure>, {
12
+ ok: true;
13
+ }>;
14
+ export declare class OperationInvocationResultError<TFailure = unknown> extends Error {
15
+ readonly result: OperationInvocationFailure<TFailure>;
16
+ readonly name = "OperationInvocationResultError";
17
+ constructor(result: OperationInvocationFailure<TFailure>);
18
+ }
19
+ export declare const isOperationInvocationResult: <TData = unknown, TFailure = unknown>(value: unknown) => value is OperationInvocationResult<TData, TFailure>;
20
+ export declare const operationBridgeErrored: (message: string) => OperationInvocationResult;
21
+ export declare const toOperationInvocationResult: <TData>(result: OperationBridgeActionResult<OperationInvocationResult<TData>>) => OperationInvocationResult<TData>;
22
+ export declare const unwrapOperationInvocationValue: <TData>(result: OperationInvocationResult<TData>) => TData;
23
+ export type BridgedOperationLike<TInput, TData> = ClientDomainOperationDeclaration<TInput, TData> & {
24
+ id: string;
25
+ entityName: string;
26
+ name: string;
27
+ };
28
+ export type RunDomainOperationBridgeAction = (input: {
29
+ operationId: string;
30
+ input: unknown;
31
+ }) => Promise<ActionResultLike>;
32
+ export type GraphPermission = {
33
+ allowed: true;
34
+ } | {
35
+ allowed: false;
36
+ reason: string;
37
+ message: string;
38
+ };
39
+ export type CheckDomainOperationPermissionBridgeAction = (input: {
40
+ operationId: string;
41
+ input: unknown;
42
+ }) => Promise<OperationBridgeActionResult<GraphPermission>>;
43
+ export type OperationBridgeAdapter<TAdapterName extends string = string> = {
44
+ name: TAdapterName;
45
+ getTaskSnapshot?: <TResult = unknown>(ref: TaskRunIdentity) => Promise<TaskSnapshot<TResult>>;
46
+ useBridgeAction: <TInput, TData>(operation: BridgedOperationLike<TInput, TData>) => OperationBridgeAction<TInput, TData>;
47
+ useBridgeMutation: <TInput, TData>(operation: BridgedOperationLike<TInput, TData>, options?: UseActionOptions<OperationBridgeAction<TInput, TData>> & {
48
+ invalidateOnSuccess?: boolean;
49
+ }) => UseActionResult<OperationBridgeAction<TInput, TData>>;
50
+ useBridgeQuery: <TInput, TData>(operation: BridgedOperationLike<TInput, TData>, args: {
51
+ input: TInput;
52
+ key: QueryKey;
53
+ }) => UseQueryResult<TData, Error>;
54
+ usePermission: <TInput, TData>(operation: BridgedOperationLike<TInput, TData>, input: TInput, options?: {
55
+ enabled?: boolean;
56
+ queryKey?: QueryKey;
57
+ }) => UseQueryResult<GraphPermission, Error>;
58
+ };
59
+ export type AnyOperationBridgeAdapter = OperationBridgeAdapter<string>;
60
+ export declare const resolveOperationBridgeQuerySpec: <TInput, TData>(operation: BridgedOperationLike<TInput, TData>) => readonly [string, string, ...unknown[]];
61
+ export declare const resolveOperationBridgeQueryKey: <TInput, TData>(operation: BridgedOperationLike<TInput, TData>, input: TInput) => ActionQueryKey;
62
+ export declare const resolveOperationBridgeInvalidationQueryKeys: <TInput, TData>(operation: BridgedOperationLike<TInput, TData>, input: TInput) => ActionQueryKey[];
63
+ export declare const createDomainOperationBridgeAction: <TInput, TData>(bridgeAction: RunDomainOperationBridgeAction, operationId: string) => OperationBridgeAction<TInput, TData>;
64
+ export declare const attachOperationBridgeActionRuntime: <TInput, TData>(operation: BridgedOperationLike<TInput, TData>, action: OperationBridgeAction<TInput, TData>, options: {
65
+ requiresAuth: boolean;
66
+ }) => ((input: unknown) => Promise<OperationBridgeActionResult<OperationInvocationResult<TData>>>) & {
67
+ __actionRuntime: import("@ontahi/core/runtime/actions").ActionRuntimeMetadata<unknown, unknown>;
68
+ };
69
+ //# sourceMappingURL=operation-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-bridge.d.ts","sourceRoot":"","sources":["../../src/actions/operation-bridge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gCAAgC,EAAmB,MAAM,yBAAyB,CAAC;AAEjG,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;IAG/D,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC,QAAQ,CAAC;IAFjE,QAAQ,CAAC,IAAI,oCAAoC;gBAE5B,MAAM,EAAE,0BAA0B,CAAC,QAAQ,CAAC;CAGlE;AAKD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AE,KAAK,EAC3D,WAAW,oBAAoB,CAAC,MAAM,EAAE,KAAK,CAAC,4CACwC,CAAC;AAczF,eAAO,MAAM,8BAA8B,GAAI,MAAM,EAAE,KAAK,EAC1D,WAAW,oBAAoB,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9C,OAAO,MAAM,KACZ,cAUF,CAAC;AAEF,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,aAAa,MAAM,KAClB,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAKwC,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"}
@@ -0,0 +1,72 @@
1
+ 'use client';
2
+ import { normalizeEntityRefQueryInput } from '@ontahi/core/data-graph';
3
+ import { attachActionRuntime, getActionErrorMessage, hasActionError, } from '@ontahi/core/runtime/actions';
4
+ export class OperationInvocationResultError extends Error {
5
+ constructor(result) {
6
+ super(result.message);
7
+ this.result = result;
8
+ this.name = 'OperationInvocationResultError';
9
+ }
10
+ }
11
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
12
+ export const isOperationInvocationResult = (value) => isRecord(value) && typeof value.ok === 'boolean' && typeof value.kind === 'string';
13
+ export const operationBridgeErrored = (message) => ({
14
+ ok: false,
15
+ kind: 'errored',
16
+ executed: 'unknown',
17
+ message,
18
+ });
19
+ export const toOperationInvocationResult = (result) => {
20
+ if (hasActionError(result)) {
21
+ return operationBridgeErrored(getActionErrorMessage(result));
22
+ }
23
+ if (isOperationInvocationResult(result.data)) {
24
+ return result.data;
25
+ }
26
+ if ('data' in result) {
27
+ return {
28
+ ok: true,
29
+ kind: 'success',
30
+ value: result.data,
31
+ };
32
+ }
33
+ return operationBridgeErrored('Graph operation bridge returned an invalid response.');
34
+ };
35
+ export const unwrapOperationInvocationValue = (result) => {
36
+ if (result.ok) {
37
+ return result.value;
38
+ }
39
+ throw new OperationInvocationResultError(result);
40
+ };
41
+ export const resolveOperationBridgeQuerySpec = (operation) => [operation.entityName, operation.name, ...(operation.bridge?.query ?? [])];
42
+ const resolveOperationBridgeQueryKeySegment = (segment, operation, input) => typeof segment === 'function'
43
+ ? segment(input, {
44
+ input,
45
+ operation,
46
+ })
47
+ : segment;
48
+ export const resolveOperationBridgeQueryKey = (operation, input) => {
49
+ const queryInput = normalizeEntityRefQueryInput(input, operation.inputRefs);
50
+ return [
51
+ operation.entityName,
52
+ operation.name,
53
+ ...(operation.bridge?.query?.map(segment => resolveOperationBridgeQueryKeySegment(segment, operation, queryInput)) ?? []),
54
+ ];
55
+ };
56
+ export const resolveOperationBridgeInvalidationQueryKeys = (operation, input) => {
57
+ const queryInput = normalizeEntityRefQueryInput(input, operation.inputRefs);
58
+ return (operation.bridge?.invalidate?.map(querySpec => querySpec.map(segment => resolveOperationBridgeQueryKeySegment(segment, operation, queryInput))) ?? []);
59
+ };
60
+ export const createDomainOperationBridgeAction = (bridgeAction, operationId) => (input) => bridgeAction({
61
+ operationId,
62
+ input,
63
+ });
64
+ export const attachOperationBridgeActionRuntime = (operation, action, options) => attachActionRuntime(action, {
65
+ feature: operation.entityName,
66
+ actionName: operation.name,
67
+ requiresAuth: options.requiresAuth,
68
+ queryKeyPrefix: [operation.entityName, operation.name],
69
+ getQueryKey: input => resolveOperationBridgeQueryKey(operation, input),
70
+ getAffectedQueryKeys: ({ input }) => resolveOperationBridgeInvalidationQueryKeys(operation, input),
71
+ });
72
+ //# sourceMappingURL=operation-bridge.js.map