@conduit-client/service-bindings-imperative 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +27 -0
- package/README.md +350 -0
- package/dist/main/index.js +6 -0
- package/dist/main/index.js.map +1 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/v1/__tests__/default-invoker.spec.d.ts +1 -0
- package/dist/types/v1/__tests__/graphql-invoker.spec.d.ts +1 -0
- package/dist/types/v1/__tests__/graphql-legacy-invoker.spec.d.ts +1 -0
- package/dist/types/v1/__tests__/graphql-mutation-invoker.spec.d.ts +1 -0
- package/dist/types/v1/__tests__/legacy-invoker.spec.d.ts +1 -0
- package/dist/types/v1/__tests__/query-invoker.spec.d.ts +1 -0
- package/dist/types/v1/__tests__/subscribable-invoker.spec.d.ts +1 -0
- package/dist/types/v1/__tests__/utils.d.ts +7 -0
- package/dist/types/v1/__tests__/utils.spec.d.ts +1 -0
- package/dist/types/v1/index.d.ts +7 -0
- package/dist/types/v1/invokers/default-invoker.d.ts +11 -0
- package/dist/types/v1/invokers/graphql-invoker.d.ts +17 -0
- package/dist/types/v1/invokers/graphql-legacy-invoker.d.ts +25 -0
- package/dist/types/v1/invokers/graphql-mutation-invoker.d.ts +19 -0
- package/dist/types/v1/invokers/legacy-invoker.d.ts +31 -0
- package/dist/types/v1/invokers/query-invoker.d.ts +15 -0
- package/dist/types/v1/invokers/subscribable-invoker.d.ts +30 -0
- package/dist/types/v1/utils.d.ts +54 -0
- package/dist/v1/index.js +419 -0
- package/dist/v1/index.js.map +1 -0
- package/package.json +52 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
*Attorney/Client Privileged + Confidential*
|
|
2
|
+
|
|
3
|
+
Terms of Use for Public Code (Non-OSS)
|
|
4
|
+
|
|
5
|
+
*NOTE:* Before publishing code under this license/these Terms of Use, please review https://salesforce.quip.com/WFfvAMKB18AL and confirm that you’ve completed all prerequisites described therein. *These Terms of Use may not be used or modified without input from IP and Product Legal.*
|
|
6
|
+
|
|
7
|
+
*Terms of Use*
|
|
8
|
+
|
|
9
|
+
Copyright 2022 Salesforce, Inc. All rights reserved.
|
|
10
|
+
|
|
11
|
+
These Terms of Use govern the download, installation, and/or use of this software provided by Salesforce, Inc. (“Salesforce”) (the “Software”), were last updated on April 15, 2022, ** and constitute a legally binding agreement between you and Salesforce. If you do not agree to these Terms of Use, do not install or use the Software.
|
|
12
|
+
|
|
13
|
+
Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute the Software and derivative works subject to these Terms. These Terms shall be included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
Subject to the limited rights expressly granted hereunder, Salesforce reserves all rights, title, and interest in and to all intellectual property subsisting in the Software. No rights are granted to you hereunder other than as expressly set forth herein. Users residing in countries on the United States Office of Foreign Assets Control sanction list, or which are otherwise subject to a US export embargo, may not use the Software.
|
|
16
|
+
|
|
17
|
+
Implementation of the Software may require development work, for which you are responsible. The Software may contain bugs, errors and incompatibilities and is made available on an AS IS basis without support, updates, or service level commitments.
|
|
18
|
+
|
|
19
|
+
Salesforce reserves the right at any time to modify, suspend, or discontinue, the Software (or any part thereof) with or without notice. You agree that Salesforce shall not be liable to you or to any third party for any modification, suspension, or discontinuance.
|
|
20
|
+
|
|
21
|
+
You agree to defend Salesforce against any claim, demand, suit or proceeding made or brought against Salesforce by a third party arising out of or accruing from (a) your use of the Software, and (b) any application you develop with the Software that infringes any copyright, trademark, trade secret, trade dress, patent, or other intellectual property right of any person or defames any person or violates their rights of publicity or privacy (each a “Claim Against Salesforce”), and will indemnify Salesforce from any damages, attorney fees, and costs finally awarded against Salesforce as a result of, or for any amounts paid by Salesforce under a settlement approved by you in writing of, a Claim Against Salesforce, provided Salesforce (x) promptly gives you written notice of the Claim Against Salesforce, (y) gives you sole control of the defense and settlement of the Claim Against Salesforce (except that you may not settle any Claim Against Salesforce unless it unconditionally releases Salesforce of all liability), and (z) gives you all reasonable assistance, at your expense.
|
|
22
|
+
|
|
23
|
+
WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA, OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
24
|
+
|
|
25
|
+
These Terms of Use shall be governed exclusively by the internal laws of the State of California, without regard to its conflicts of laws rules. Each party hereby consents to the exclusive jurisdiction of the state and federal courts located in San Francisco County, California to adjudicate any dispute arising out of or relating to these Terms of Use and the download, installation, and/or use of the Software. Except as expressly stated herein, these Terms of Use constitute the entire agreement between the parties, and supersede all prior and contemporaneous agreements, proposals, or representations, written or oral, concerning their subject matter. No modification, amendment, or waiver of any provision of these Terms of Use shall be effective unless it is by an update to these Terms of Use that Salesforce makes available, or is in writing and signed by the party against whom the modification, amendment, or waiver is to be asserted.
|
|
26
|
+
|
|
27
|
+
_*Data Privacy*_: Salesforce may collect, process, and store device, system, and other information related to your use of the Software. This information includes, but is not limited to, IP address, user metrics, and other data (“Usage Data”). Salesforce may use Usage Data for analytics, product development, and marketing purposes. You acknowledge that files generated in conjunction with the Software may contain sensitive or confidential data, and you are solely responsible for anonymizing and protecting such data.
|
package/README.md
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
# @conduit-client/service-bindings-imperative
|
|
2
|
+
|
|
3
|
+
Conduit services for imperative bindings, providing flexible data invocation strategies and patterns.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides imperative data fetching and mutation services for the Conduit ecosystem. It offers multiple invoker strategies to handle different data fetching patterns including GraphQL, legacy systems, and subscribable data streams. It then wraps these in services to be used as needed within an environment.
|
|
8
|
+
|
|
9
|
+
## Key Features
|
|
10
|
+
|
|
11
|
+
- **Multiple Invoker Strategies**: Support for various data fetching patterns
|
|
12
|
+
- **GraphQL Support**: Full GraphQL query and mutation support
|
|
13
|
+
- **Legacy System Integration**: Backward compatibility with legacy APIs
|
|
14
|
+
- **Subscribable Data**: Real-time data subscriptions and updates
|
|
15
|
+
- **Flexible Architecture**: Pluggable invoker system for custom implementations
|
|
16
|
+
|
|
17
|
+
## Service Types
|
|
18
|
+
|
|
19
|
+
### Available Services
|
|
20
|
+
|
|
21
|
+
#### `DefaultImperativeBindingsService`
|
|
22
|
+
|
|
23
|
+
Standard invoker for general-purpose data fetching.
|
|
24
|
+
|
|
25
|
+
- Handles standard REST API calls
|
|
26
|
+
- Provides error handling and retry logic
|
|
27
|
+
- Can be used for subscribable and non-subscribable results
|
|
28
|
+
|
|
29
|
+
#### `QueryImperativeBindingsService`
|
|
30
|
+
|
|
31
|
+
Specialized invoker for query operations.
|
|
32
|
+
|
|
33
|
+
- Supports all properties of the default invoker
|
|
34
|
+
|
|
35
|
+
#### `GraphQLImperativeBindingsService`
|
|
36
|
+
|
|
37
|
+
GraphQL-specific invoker for modern GraphQL APIs.
|
|
38
|
+
|
|
39
|
+
- Executes GraphQL queries
|
|
40
|
+
- Handles GraphQL errors
|
|
41
|
+
- Supports variables and fragments
|
|
42
|
+
|
|
43
|
+
#### `GraphQLMutationBindingsService`
|
|
44
|
+
|
|
45
|
+
Dedicated invoker for GraphQL mutations.
|
|
46
|
+
|
|
47
|
+
- Executes GraphQL mutations
|
|
48
|
+
- Handles optimistic updates
|
|
49
|
+
- Manages mutation side effects
|
|
50
|
+
|
|
51
|
+
#### `GraphQLLegacyImperativeBindingsService`
|
|
52
|
+
|
|
53
|
+
Bridge invoker for legacy GraphQL implementations.
|
|
54
|
+
|
|
55
|
+
- Backward compatibility with older GraphQL systems
|
|
56
|
+
- Handles legacy response formats
|
|
57
|
+
|
|
58
|
+
#### `LegacyImperativeBindingsService`
|
|
59
|
+
|
|
60
|
+
Compatibility invoker for legacy systems.
|
|
61
|
+
|
|
62
|
+
- Supports older REST APIs
|
|
63
|
+
|
|
64
|
+
#### `SubscribableImperativeBindingsService`
|
|
65
|
+
|
|
66
|
+
Real-time data subscription invoker.
|
|
67
|
+
|
|
68
|
+
- Specific to subscribable results
|
|
69
|
+
|
|
70
|
+
## Usage Examples
|
|
71
|
+
|
|
72
|
+
### Basic Data Fetching
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { buildDefaultImperativeBindingsServiceDescriptor } from '@conduit-client/services/bindings-imperative/v1';
|
|
76
|
+
|
|
77
|
+
// Build the service
|
|
78
|
+
const { service: defaultImperativeBindingsService } =
|
|
79
|
+
buildDefaultImperativeBindingsServiceDescriptor();
|
|
80
|
+
|
|
81
|
+
// Create a command that returns data
|
|
82
|
+
const getCommand = () => ({
|
|
83
|
+
execute: () =>
|
|
84
|
+
Promise.resolve({
|
|
85
|
+
isOk: () => true,
|
|
86
|
+
value: {
|
|
87
|
+
data: { foo: 'bar' },
|
|
88
|
+
subscribe: (callback) => {
|
|
89
|
+
// Optional subscription logic
|
|
90
|
+
return () => {}; // Return unsubscribe function
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Bind the command to the service
|
|
97
|
+
const invoker = defaultImperativeBindingsService.bind(getCommand);
|
|
98
|
+
|
|
99
|
+
// Execute and get the result
|
|
100
|
+
const result = await invoker({ required: 'param' });
|
|
101
|
+
console.log(result); // { foo: 'bar' }
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### GraphQL Query
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { buildGraphQLImperativeBindingsServiceDescriptor } from '@conduit-client/services/bindings-imperative/v1';
|
|
108
|
+
|
|
109
|
+
// Build the service
|
|
110
|
+
const { service: graphQLImperativeBindingsService } =
|
|
111
|
+
buildGraphQLImperativeBindingsServiceDescriptor();
|
|
112
|
+
|
|
113
|
+
// Create a GraphQL command
|
|
114
|
+
const getGraphQLCommand = () => ({
|
|
115
|
+
execute: () =>
|
|
116
|
+
Promise.resolve({
|
|
117
|
+
isOk: () => true,
|
|
118
|
+
value: {
|
|
119
|
+
data: {
|
|
120
|
+
data: { user: { id: '1', name: 'John' } },
|
|
121
|
+
errors: [],
|
|
122
|
+
},
|
|
123
|
+
subscribe: (callback) => {
|
|
124
|
+
// Handle GraphQL subscriptions
|
|
125
|
+
return () => {};
|
|
126
|
+
},
|
|
127
|
+
refresh: async () => {
|
|
128
|
+
// Optional refresh logic
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Bind with refresh support
|
|
135
|
+
const invoker = graphQLImperativeBindingsService.bind(getGraphQLCommand, true);
|
|
136
|
+
|
|
137
|
+
// Execute GraphQL query
|
|
138
|
+
const result = await invoker('query { user { id name } }', { id: '123' });
|
|
139
|
+
console.log(result.data); // { user: { id: '1', name: 'John' } }
|
|
140
|
+
console.log(result.errors); // undefined or array of errors
|
|
141
|
+
console.log(result.subscribe); // Subscription function
|
|
142
|
+
console.log(result.refresh); // Refresh function (if enabled)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### GraphQL Mutation
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { buildGraphQLMutationBindingsServiceDescriptor } from '@conduit-client/services/bindings-imperative/v1';
|
|
149
|
+
|
|
150
|
+
// Build the service
|
|
151
|
+
const { service: graphQLMutationBindingsService } = buildGraphQLMutationBindingsServiceDescriptor();
|
|
152
|
+
|
|
153
|
+
// Create a mutation command
|
|
154
|
+
const getMutationCommand = () => ({
|
|
155
|
+
execute: (overrides) => {
|
|
156
|
+
// Note: Mutations automatically use no-cache
|
|
157
|
+
console.log(overrides.cacheControlConfig); // { type: 'no-cache' }
|
|
158
|
+
return Promise.resolve({
|
|
159
|
+
isOk: () => true,
|
|
160
|
+
value: {
|
|
161
|
+
data: {
|
|
162
|
+
data: { doThing: { id: '123' } },
|
|
163
|
+
errors: [],
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Bind the command
|
|
171
|
+
const invoker = graphQLMutationBindingsService.bind(getMutationCommand);
|
|
172
|
+
|
|
173
|
+
// Execute mutation
|
|
174
|
+
const result = await invoker({
|
|
175
|
+
query: 'mutation DoThing { doThing { id } }',
|
|
176
|
+
variables: {
|
|
177
|
+
/* variables */
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
console.log(result); // { data: { doThing: { id: '123' } }, errors: [] }
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Subscribable Data
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import { buildSubscribableImperativeBindingsServiceDescriptor } from '@conduit-client/services/bindings-imperative/v1';
|
|
187
|
+
|
|
188
|
+
// Build the service
|
|
189
|
+
const { service: subscribableImperativeBindingsService } =
|
|
190
|
+
buildSubscribableImperativeBindingsServiceDescriptor();
|
|
191
|
+
|
|
192
|
+
// Create a subscribable command
|
|
193
|
+
const getSubscribableCommand = () => ({
|
|
194
|
+
execute: () =>
|
|
195
|
+
Promise.resolve({
|
|
196
|
+
isOk: () => true,
|
|
197
|
+
value: {
|
|
198
|
+
data: { foo: 'bar' },
|
|
199
|
+
subscribe: (callback) => {
|
|
200
|
+
// Set up subscription
|
|
201
|
+
const interval = setInterval(() => {
|
|
202
|
+
callback({
|
|
203
|
+
isOk: () => true,
|
|
204
|
+
value: { data: { foo: 'updated' } },
|
|
205
|
+
});
|
|
206
|
+
}, 1000);
|
|
207
|
+
|
|
208
|
+
// Return unsubscribe function
|
|
209
|
+
return () => clearInterval(interval);
|
|
210
|
+
},
|
|
211
|
+
refresh: async () => {
|
|
212
|
+
// Optional refresh logic
|
|
213
|
+
return { isOk: () => true, value: undefined };
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
}),
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Bind with refresh support
|
|
220
|
+
const invoker = subscribableImperativeBindingsService.bind(getSubscribableCommand, true);
|
|
221
|
+
|
|
222
|
+
// Get subscribable result
|
|
223
|
+
const result = await invoker({ required: 'param' });
|
|
224
|
+
console.log(result.data); // { foo: 'bar' }
|
|
225
|
+
|
|
226
|
+
// Subscribe to updates
|
|
227
|
+
const unsubscribe = result.subscribe((update) => {
|
|
228
|
+
console.log('Updated:', update);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// Refresh data
|
|
232
|
+
if (result.refresh) {
|
|
233
|
+
await result.refresh();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Later: unsubscribe
|
|
237
|
+
unsubscribe();
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Legacy System Integration
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import { buildLegacyImperativeBindingsServiceDescriptor } from '@conduit-client/services/bindings-imperative/v1';
|
|
244
|
+
|
|
245
|
+
// Build the service
|
|
246
|
+
const { service: legacyImperativeBindingsService } =
|
|
247
|
+
buildLegacyImperativeBindingsServiceDescriptor();
|
|
248
|
+
|
|
249
|
+
// Create a legacy command
|
|
250
|
+
const getLegacyCommand = () => ({
|
|
251
|
+
execute: (overrides) => {
|
|
252
|
+
// Handle cache policy if provided
|
|
253
|
+
const cachePolicy = overrides?.cacheControlConfig;
|
|
254
|
+
|
|
255
|
+
return Promise.resolve({
|
|
256
|
+
isOk: () => true,
|
|
257
|
+
value: {
|
|
258
|
+
data: { foo: 'legacy data' },
|
|
259
|
+
subscribe: (callback) => {
|
|
260
|
+
// Legacy subscription pattern
|
|
261
|
+
return () => {};
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// Bind the command
|
|
269
|
+
const legacyAdapter = legacyImperativeBindingsService.bind(getLegacyCommand);
|
|
270
|
+
|
|
271
|
+
// Use legacy invoke pattern
|
|
272
|
+
legacyAdapter.invoke(
|
|
273
|
+
{ test: 'param' },
|
|
274
|
+
{ cachePolicy: { type: 'no-cache' } }, // Optional request context
|
|
275
|
+
(result) => {
|
|
276
|
+
console.log(result); // { data: { foo: 'legacy data' }, error: undefined }
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
// Use legacy subscribe pattern
|
|
281
|
+
const unsubscribe = legacyAdapter.subscribe({ test: 'param' }, {}, (result) => {
|
|
282
|
+
console.log('Updated:', result);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// Later: unsubscribe
|
|
286
|
+
unsubscribe();
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Query Service
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
import { buildQueryImperativeBindingsServiceDescriptor } from '@conduit-client/services/bindings-imperative/v1';
|
|
293
|
+
|
|
294
|
+
// Build the service
|
|
295
|
+
const { service: queryImperativeBindingsService } = buildQueryImperativeBindingsServiceDescriptor();
|
|
296
|
+
|
|
297
|
+
// Create a query command
|
|
298
|
+
const getQueryCommand = () => ({
|
|
299
|
+
execute: () =>
|
|
300
|
+
Promise.resolve({
|
|
301
|
+
isOk: () => true,
|
|
302
|
+
value: { message: 'query result' },
|
|
303
|
+
}),
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// Bind the command
|
|
307
|
+
const invoker = queryImperativeBindingsService.bind(getQueryCommand);
|
|
308
|
+
|
|
309
|
+
// Execute query
|
|
310
|
+
const result = await invoker('queryParam', 42);
|
|
311
|
+
console.log(result); // { data: { message: 'query result' } }
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## API Reference
|
|
315
|
+
|
|
316
|
+
### Service Descriptors
|
|
317
|
+
|
|
318
|
+
Each service type is exported as a service descriptor builder function:
|
|
319
|
+
|
|
320
|
+
- `buildDefaultImperativeBindingsServiceDescriptor()` - Returns default service descriptor
|
|
321
|
+
- `buildQueryImperativeBindingsServiceDescriptor()` - Returns query service descriptor
|
|
322
|
+
- `buildSubscribableImperativeBindingsServiceDescriptor()` - Returns subscribable service descriptor
|
|
323
|
+
- `buildLegacyImperativeBindingsServiceDescriptor()` - Returns legacy service descriptor
|
|
324
|
+
- `buildGraphQLImperativeBindingsServiceDescriptor()` - Returns GraphQL service descriptor
|
|
325
|
+
- `buildGraphQLLegacyImperativeBindingsServiceDescriptor()` - Returns GraphQL legacy service descriptor
|
|
326
|
+
- `buildGraphQLMutationBindingsServiceDescriptor()` - Returns GraphQL mutation service descriptor
|
|
327
|
+
|
|
328
|
+
### Service Methods
|
|
329
|
+
|
|
330
|
+
Each service provides a `bind` method:
|
|
331
|
+
|
|
332
|
+
#### `bind<TParams extends unknown[]>(getCommand: CommandFactory, exposeRefresh?: boolean): Invoker`
|
|
333
|
+
|
|
334
|
+
Binds a command factory to the service and returns an invoker function.
|
|
335
|
+
|
|
336
|
+
- `getCommand`: A function that returns a command object with an `execute` method
|
|
337
|
+
- `exposeRefresh`: Optional boolean to enable refresh functionality (for subscribable services)
|
|
338
|
+
- Returns: An invoker function that accepts parameters and returns a promise
|
|
339
|
+
|
|
340
|
+
### Command Interface
|
|
341
|
+
|
|
342
|
+
Commands must implement the interface from `@conduit-client/command-base`
|
|
343
|
+
|
|
344
|
+
## Dependencies
|
|
345
|
+
|
|
346
|
+
- `@conduit-client/utils`: Core utility functions
|
|
347
|
+
- `@conduit-client/bindings-utils`: Shared binding utilities
|
|
348
|
+
- `@conduit-client/jsonschema-validate`: JSON schema validation
|
|
349
|
+
- `@conduit-client/command-base`: Base command interfaces
|
|
350
|
+
- `@conduit-client/onestore-graphql-parser`: GraphQL parsing utilities
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Command } from '@conduit-client/command-base/v1';
|
|
2
|
+
import { SyncOrAsync, Result, SubscribableResult } from '@conduit-client/utils';
|
|
3
|
+
export declare function buildCommand<Data>(data: Data): Command<SyncOrAsync<Result<Data, unknown>>>;
|
|
4
|
+
export declare function buildFailingCommand(): Command<SyncOrAsync<SubscribableResult<any, Error>>>;
|
|
5
|
+
export declare function buildSubscribableCommand<Data>(data: Data): Command<SyncOrAsync<SubscribableResult<Data, Error>>>;
|
|
6
|
+
export declare function buildRefreshableCommand<Data>(data: Data): Command<SyncOrAsync<SubscribableResult<Data, Error>>>;
|
|
7
|
+
export declare function buildErrorRefreshableCommand<Data>(data: Data): Command<SyncOrAsync<SubscribableResult<Data, Error>>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { buildServiceDescriptor as buildDefaultImperativeBindingsServiceDescriptor } from './invokers/default-invoker';
|
|
2
|
+
export { buildServiceDescriptor as buildQueryImperativeBindingsServiceDescriptor } from './invokers/query-invoker';
|
|
3
|
+
export { buildServiceDescriptor as buildSubscribableImperativeBindingsServiceDescriptor } from './invokers/subscribable-invoker';
|
|
4
|
+
export { buildServiceDescriptor as buildLegacyImperativeBindingsServiceDescriptor } from './invokers/legacy-invoker';
|
|
5
|
+
export { buildServiceDescriptor as buildGraphQLImperativeBindingsServiceDescriptor } from './invokers/graphql-invoker';
|
|
6
|
+
export { buildServiceDescriptor as buildGraphQLLegacyImperativeBindingsServiceDescriptor } from './invokers/graphql-legacy-invoker';
|
|
7
|
+
export { buildServiceDescriptor as buildGraphQLMutationBindingsServiceDescriptor } from './invokers/graphql-mutation-invoker';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ImperativeCommand, GetCommand } from '../utils';
|
|
2
|
+
export type DefaultImperativeResult<Data> = PromiseLike<Data>;
|
|
3
|
+
export declare class DefaultImperativeBindingsService {
|
|
4
|
+
bind<Params extends Array<any>, Data>(getCommand: GetCommand<Params, ImperativeCommand<Data>>): (...params: Params) => DefaultImperativeResult<Data>;
|
|
5
|
+
}
|
|
6
|
+
export interface DefaultImperativeBindingsServiceDescriptor {
|
|
7
|
+
type: 'defaultImperativeBindings';
|
|
8
|
+
version: string;
|
|
9
|
+
service: DefaultImperativeBindingsService;
|
|
10
|
+
}
|
|
11
|
+
export declare function buildServiceDescriptor(): DefaultImperativeBindingsServiceDescriptor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Callback, type SubscribableResult } from '@conduit-client/utils';
|
|
2
|
+
import { type GraphQLCommandError, type GraphQLResponse, type GraphQLCommand } from '@conduit-client/graphql-normalization/v1';
|
|
3
|
+
import { GetCommand } from '../utils';
|
|
4
|
+
export type SubscribableRefreshableGraphQLImperativeResult = GraphQLResponse & {
|
|
5
|
+
subscribe?: (cb: Callback<any>) => void;
|
|
6
|
+
refresh?: () => PromiseLike<void>;
|
|
7
|
+
};
|
|
8
|
+
export declare class GraphQLImperativeBindingsService {
|
|
9
|
+
bind<Params extends Array<any>>(getCommand: GetCommand<Params, GraphQLCommand>, exposeRefresh?: boolean): (...params: Params) => PromiseLike<SubscribableRefreshableGraphQLImperativeResult>;
|
|
10
|
+
transformResult<Data extends GraphQLResponse<Record<string, any>>>(result: SubscribableResult<Data, GraphQLCommandError>, exposeRefresh?: boolean): SubscribableRefreshableGraphQLImperativeResult;
|
|
11
|
+
}
|
|
12
|
+
export interface GraphQLImperativeBindingsServiceDescriptor {
|
|
13
|
+
type: 'graphQLImperativeBindings';
|
|
14
|
+
version: string;
|
|
15
|
+
service: GraphQLImperativeBindingsService;
|
|
16
|
+
}
|
|
17
|
+
export declare function buildServiceDescriptor(): GraphQLImperativeBindingsServiceDescriptor;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Unsubscribe } from '@conduit-client/utils';
|
|
2
|
+
import { JSONSchema } from '@conduit-client/jsonschema-validate';
|
|
3
|
+
import { type GraphQLResponse, type GraphQLCommand } from '@conduit-client/graphql-normalization/v1';
|
|
4
|
+
import type { Command } from '@conduit-client/command-base/v1';
|
|
5
|
+
import { type LegacyExecuteOverrides } from '../utils';
|
|
6
|
+
type LegacyGraphQLImperativeAdapterInvokeType<Config> = (config: Config, context: unknown, callback: (result: GraphQLResponse) => void) => void;
|
|
7
|
+
type LegacyGraphQLImperativeAdapterSubscribeType<Config> = (config: Config, context: unknown, callback: (result: GraphQLResponse) => void) => Unsubscribe;
|
|
8
|
+
export type LegacyGraphQLImperativeShape<Config> = {
|
|
9
|
+
invoke: LegacyGraphQLImperativeAdapterInvokeType<Config>;
|
|
10
|
+
subscribe: LegacyGraphQLImperativeAdapterSubscribeType<Config>;
|
|
11
|
+
};
|
|
12
|
+
export type GetGraphQLLegacyCommand<Config> = (options: {
|
|
13
|
+
config: Config;
|
|
14
|
+
assertIsValid: <T>(data: unknown, schema: JSONSchema) => asserts data is T;
|
|
15
|
+
}) => Command<ReturnType<GraphQLCommand['execute']>, [LegacyExecuteOverrides?]>;
|
|
16
|
+
export declare class GraphQLLegacyImperativeBindingsService {
|
|
17
|
+
bind<Config>(getCommand: GetGraphQLLegacyCommand<Config>): LegacyGraphQLImperativeShape<Config>;
|
|
18
|
+
}
|
|
19
|
+
export interface GraphQLLegacyImperativeBindingsServiceDescriptor {
|
|
20
|
+
type: 'graphQLLegacyImperativeBindings';
|
|
21
|
+
version: string;
|
|
22
|
+
service: GraphQLLegacyImperativeBindingsService;
|
|
23
|
+
}
|
|
24
|
+
export declare function buildServiceDescriptor(): GraphQLLegacyImperativeBindingsServiceDescriptor;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { JSONSchema } from '@conduit-client/jsonschema-validate';
|
|
2
|
+
import { type GraphQLResponse, type GraphQLCommand } from '@conduit-client/graphql-normalization/v1';
|
|
3
|
+
import type { Command } from '@conduit-client/command-base/v1';
|
|
4
|
+
import { type LegacyExecuteOverrides } from '../utils';
|
|
5
|
+
export type GraphQLMutationResult = Promise<GraphQLResponse>;
|
|
6
|
+
type GetGraphQLCommand<Params> = (options: {
|
|
7
|
+
params: Params;
|
|
8
|
+
assertIsValid: <T>(data: unknown, schema: JSONSchema) => asserts data is T;
|
|
9
|
+
}) => Command<ReturnType<GraphQLCommand['execute']>, [LegacyExecuteOverrides?]>;
|
|
10
|
+
export declare class GraphQLMutationBindingsService {
|
|
11
|
+
bind<Params extends Array<any>>(getCommand: GetGraphQLCommand<Params>): (...params: Params) => GraphQLMutationResult;
|
|
12
|
+
}
|
|
13
|
+
export interface GraphQLMutationBindingsServiceDescriptor {
|
|
14
|
+
type: 'graphQLMutationBindings';
|
|
15
|
+
version: string;
|
|
16
|
+
service: GraphQLMutationBindingsService;
|
|
17
|
+
}
|
|
18
|
+
export declare function buildServiceDescriptor(): GraphQLMutationBindingsServiceDescriptor;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Unsubscribe } from '@conduit-client/utils';
|
|
2
|
+
import { JSONSchema } from '@conduit-client/jsonschema-validate';
|
|
3
|
+
import { LegacyExecuteOverrides } from '../utils';
|
|
4
|
+
import { SubscribableResultCommand } from '@conduit-client/bindings-utils/v1';
|
|
5
|
+
type LegacyImperativeCallbackResult<Data> = {
|
|
6
|
+
data: Data;
|
|
7
|
+
error: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
data: undefined;
|
|
10
|
+
error: Error;
|
|
11
|
+
};
|
|
12
|
+
type LegacyImperativeAdapterInvokeType<Config, Data> = (config: Config, context: unknown, callback: (result: LegacyImperativeCallbackResult<Data>) => void) => void;
|
|
13
|
+
type LegacyImperativeAdapterSubscribeType<Config, Data> = (config: Config, context: unknown, callback: (result: LegacyImperativeCallbackResult<Data>) => void) => Unsubscribe;
|
|
14
|
+
export type LegacyImperativeShape<Config, Data> = {
|
|
15
|
+
invoke: LegacyImperativeAdapterInvokeType<Config, Data>;
|
|
16
|
+
subscribe: LegacyImperativeAdapterSubscribeType<Config, Data>;
|
|
17
|
+
};
|
|
18
|
+
export type GetLegacyCommand<Config, Data> = (options: {
|
|
19
|
+
config: Config;
|
|
20
|
+
assertIsValid: <T>(data: unknown, schema: JSONSchema) => asserts data is T;
|
|
21
|
+
}) => SubscribableResultCommand<Data, unknown, [LegacyExecuteOverrides?]>;
|
|
22
|
+
export declare class LegacyImperativeBindingsService {
|
|
23
|
+
bind<Config, Data>(getCommand: GetLegacyCommand<Config, Data>): LegacyImperativeShape<Config, Data>;
|
|
24
|
+
}
|
|
25
|
+
export interface LegacyImperativeBindingsServiceDescriptor {
|
|
26
|
+
type: 'legacyImperativeBindings';
|
|
27
|
+
version: string;
|
|
28
|
+
service: LegacyImperativeBindingsService;
|
|
29
|
+
}
|
|
30
|
+
export declare function buildServiceDescriptor(): LegacyImperativeBindingsServiceDescriptor;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GetCommand, ImperativeCommand } from '../utils';
|
|
2
|
+
type QueryResult<Data> = {
|
|
3
|
+
data: Data;
|
|
4
|
+
};
|
|
5
|
+
export type QueryImperativeResult<Data> = PromiseLike<QueryResult<Data>>;
|
|
6
|
+
export declare class QueryImperativeBindingsService {
|
|
7
|
+
bind<Params extends Array<any>, Data>(getCommand: GetCommand<Params, ImperativeCommand<Data>>): (...params: Params) => QueryImperativeResult<Data>;
|
|
8
|
+
}
|
|
9
|
+
export interface QueryImperativeBindingsServiceDescriptor {
|
|
10
|
+
type: 'queryImperativeBindings';
|
|
11
|
+
version: string;
|
|
12
|
+
service: QueryImperativeBindingsService;
|
|
13
|
+
}
|
|
14
|
+
export declare function buildServiceDescriptor(): QueryImperativeBindingsServiceDescriptor;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Callback } from '@conduit-client/utils';
|
|
2
|
+
import { type ResultOrSubscribableResult } from '@conduit-client/bindings-utils/v1';
|
|
3
|
+
import { GetCommand, ImperativeCommand } from '../utils';
|
|
4
|
+
export type SubscribableImperativeResult<Data> = {
|
|
5
|
+
data: Data;
|
|
6
|
+
subscribe: (cb: Callback<any>) => void;
|
|
7
|
+
};
|
|
8
|
+
export type SubscribableRefreshableImperativeResult<Data> = {
|
|
9
|
+
data: Data;
|
|
10
|
+
subscribe: (cb: Callback<any>) => void;
|
|
11
|
+
refresh: () => PromiseLike<void>;
|
|
12
|
+
};
|
|
13
|
+
export type MaybeRefreshableSubscribableImperativeResult<Data> = SubscribableImperativeResult<Data> | SubscribableRefreshableImperativeResult<Data>;
|
|
14
|
+
export declare class SubscribableImperativeBindingsService {
|
|
15
|
+
bind<Params extends Array<any>, Data>(getCommand: GetCommand<Params, ImperativeCommand<Data>>, exposeRefresh?: boolean): (...params: Params) => PromiseLike<MaybeRefreshableSubscribableImperativeResult<Data>>;
|
|
16
|
+
transformResult<Data>(result: ResultOrSubscribableResult<Data>, exposeRefresh?: boolean): {
|
|
17
|
+
data: Data;
|
|
18
|
+
subscribe: (cb: Callback<any>) => void;
|
|
19
|
+
} | {
|
|
20
|
+
refresh: () => PromiseLike<undefined>;
|
|
21
|
+
data: Data;
|
|
22
|
+
subscribe: (cb: Callback<any>) => void;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface SubscribableImperativeBindingsServiceDescriptor {
|
|
26
|
+
type: 'subscribableImperativeBindings';
|
|
27
|
+
version: string;
|
|
28
|
+
service: SubscribableImperativeBindingsService;
|
|
29
|
+
}
|
|
30
|
+
export declare function buildServiceDescriptor(): SubscribableImperativeBindingsServiceDescriptor;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type JSONSchema } from '@conduit-client/jsonschema-validate';
|
|
2
|
+
import { SubscribableResultCommand, ResultCommand, MaybeSubscribableResultCommand, ResultOrSubscribableResult } from '@conduit-client/bindings-utils/v1';
|
|
3
|
+
import type { GraphQLCommandError, GraphQLResponse } from '@conduit-client/graphql-normalization/v1';
|
|
4
|
+
import { Result } from '@conduit-client/utils';
|
|
5
|
+
export type ImperativeCommand<Data> = SubscribableResultCommand<Data> | ResultCommand<Data> | MaybeSubscribableResultCommand<Data>;
|
|
6
|
+
export type GetCommand<Params extends Array<any>, CommandType> = (options: {
|
|
7
|
+
params: Params;
|
|
8
|
+
assertIsValid: <T>(data: unknown, schema: JSONSchema) => asserts data is T;
|
|
9
|
+
}) => CommandType;
|
|
10
|
+
export declare function buildBaseImperativeInvoker<Params extends Array<any>, Data, InvokerResult = Data, CommandType extends ImperativeCommand<Data> = ImperativeCommand<Data>, CommandResult extends ResultOrSubscribableResult<Data> = ResultOrSubscribableResult<Data>>(getCommand: GetCommand<Params, CommandType>, transformResult: (result: CommandResult) => InvokerResult): (...params: Params) => PromiseLike<InvokerResult>;
|
|
11
|
+
export declare const supportedCachePolicyTypes: readonly ["no-cache", "only-if-cached"];
|
|
12
|
+
export type SupportedCachePolicyType = (typeof supportedCachePolicyTypes)[number];
|
|
13
|
+
export type CachePolicy = {
|
|
14
|
+
cachePolicy: {
|
|
15
|
+
type: SupportedCachePolicyType;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Type guard for legacy requestContext objects used with imperative-legacy bindings.
|
|
20
|
+
*
|
|
21
|
+
* When this function returns true, it indicates the caller requested a supported
|
|
22
|
+
* cache policy override. Currently the only supported policy is `no-cache`.
|
|
23
|
+
*
|
|
24
|
+
* This helper is intentionally low-level; prefer using
|
|
25
|
+
* {@link getOverridesForLegacyRequestContext} at call sites to construct the
|
|
26
|
+
* proper `execute` overrides for Commands.
|
|
27
|
+
*/
|
|
28
|
+
export declare function requestContextIsSupportedCachePolicy(requestContext: unknown): requestContext is CachePolicy;
|
|
29
|
+
export type LegacyExecuteOverrides = {
|
|
30
|
+
cacheControlConfig?: {
|
|
31
|
+
type: SupportedCachePolicyType;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Builds the `execute` overrides for legacy imperative invokers based on the
|
|
36
|
+
* provided requestContext. Encapsulates all hard-coded knowledge of supported
|
|
37
|
+
* cache policies for legacy adapters.
|
|
38
|
+
*
|
|
39
|
+
* - If {@link requestContextIsSupportedCachePolicy} matches `no-cache`, returns
|
|
40
|
+
* `{ cacheControlConfig: { type: 'no-cache' } }`.
|
|
41
|
+
* - Otherwise returns `{}`.
|
|
42
|
+
*
|
|
43
|
+
* Use this in `buildAsyncImperativeLegacyInvoker` and GraphQL legacy invokers
|
|
44
|
+
* to centralize override behavior.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getOverridesForLegacyRequestContext(requestContext: unknown): LegacyExecuteOverrides;
|
|
47
|
+
export declare function handleEmit(res: Result<GraphQLResponse<Record<string, any>>, GraphQLCommandError>, callback: (result: GraphQLResponse) => void): void;
|
|
48
|
+
/**
|
|
49
|
+
* Maps a command failure (unknown or user-visible) into a GraphQLResponse suitable for consumers.
|
|
50
|
+
*/
|
|
51
|
+
export declare function toGraphQLResponseFromFailure(failure: unknown): {
|
|
52
|
+
data: GraphQLResponse['data'];
|
|
53
|
+
errors: GraphQLResponse['errors'];
|
|
54
|
+
};
|
package/dist/v1/index.js
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
import { isUserVisibleError, logError, deepFreeze, isSubscribableResult, toError } from "@conduit-client/utils";
|
|
7
|
+
import { assertIsValid } from "@conduit-client/jsonschema-validate";
|
|
8
|
+
import { throwUserlandError, emitError } from "@conduit-client/bindings-utils/v1";
|
|
9
|
+
import { wrapConfigAndVerify } from "@conduit-client/onestore-graphql-parser/v1";
|
|
10
|
+
function buildBaseImperativeInvoker(getCommand, transformResult) {
|
|
11
|
+
return async (...params) => {
|
|
12
|
+
const command = getCommand({ params, assertIsValid });
|
|
13
|
+
try {
|
|
14
|
+
return command.execute().then((result) => transformResult(result));
|
|
15
|
+
} catch (error) {
|
|
16
|
+
throwUserlandError(error);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const supportedCachePolicyTypes = ["no-cache", "only-if-cached"];
|
|
21
|
+
function requestContextIsSupportedCachePolicy(requestContext) {
|
|
22
|
+
return typeof requestContext === "object" && requestContext !== null && "cachePolicy" in requestContext && typeof requestContext.cachePolicy === "object" && requestContext.cachePolicy !== null && "type" in requestContext.cachePolicy && typeof requestContext.cachePolicy.type === "string" && supportedCachePolicyTypes.includes(
|
|
23
|
+
requestContext.cachePolicy.type
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
function getOverridesForLegacyRequestContext(requestContext) {
|
|
27
|
+
if (requestContextIsSupportedCachePolicy(requestContext)) {
|
|
28
|
+
return { cacheControlConfig: { type: requestContext.cachePolicy.type } };
|
|
29
|
+
}
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
function handleEmit(res, callback) {
|
|
33
|
+
const consumerEmittedData = {
|
|
34
|
+
data: void 0,
|
|
35
|
+
errors: void 0
|
|
36
|
+
};
|
|
37
|
+
if (res.isOk()) {
|
|
38
|
+
consumerEmittedData.data = res.value.data;
|
|
39
|
+
} else {
|
|
40
|
+
const { data, errors } = toGraphQLResponseFromFailure(res.error);
|
|
41
|
+
consumerEmittedData.data = data;
|
|
42
|
+
consumerEmittedData.errors = errors;
|
|
43
|
+
}
|
|
44
|
+
callback(consumerEmittedData);
|
|
45
|
+
}
|
|
46
|
+
function toGraphQLResponseFromFailure(failure) {
|
|
47
|
+
if (isUserVisibleError(failure)) {
|
|
48
|
+
return {
|
|
49
|
+
data: failure.data.data,
|
|
50
|
+
errors: failure.data.errors
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
logError(failure);
|
|
54
|
+
return {
|
|
55
|
+
data: void 0,
|
|
56
|
+
errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
class DefaultImperativeBindingsService {
|
|
60
|
+
bind(getCommand) {
|
|
61
|
+
return buildBaseImperativeInvoker(getCommand, (result) => {
|
|
62
|
+
if (result.isOk()) {
|
|
63
|
+
deepFreeze(result.value);
|
|
64
|
+
return isSubscribableResult(result) ? result.value.data : result.value;
|
|
65
|
+
}
|
|
66
|
+
throw toError(isSubscribableResult(result) ? result.error.failure : result.error);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function buildServiceDescriptor$6() {
|
|
71
|
+
return {
|
|
72
|
+
type: "defaultImperativeBindings",
|
|
73
|
+
version: "1.0",
|
|
74
|
+
service: new DefaultImperativeBindingsService()
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
class QueryImperativeBindingsService {
|
|
78
|
+
bind(getCommand) {
|
|
79
|
+
return buildBaseImperativeInvoker(getCommand, (result) => {
|
|
80
|
+
if (result.isOk()) {
|
|
81
|
+
deepFreeze(result.value);
|
|
82
|
+
return isSubscribableResult(result) ? { data: result.value.data } : { data: result.value };
|
|
83
|
+
}
|
|
84
|
+
throw toError(isSubscribableResult(result) ? result.error.failure : result.error);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function buildServiceDescriptor$5() {
|
|
89
|
+
return {
|
|
90
|
+
type: "queryImperativeBindings",
|
|
91
|
+
version: "1.0",
|
|
92
|
+
service: new QueryImperativeBindingsService()
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
class SubscribableImperativeBindingsService {
|
|
96
|
+
bind(getCommand, exposeRefresh = false) {
|
|
97
|
+
return buildBaseImperativeInvoker(getCommand, (result) => this.transformResult(result, exposeRefresh));
|
|
98
|
+
}
|
|
99
|
+
transformResult(result, exposeRefresh = false) {
|
|
100
|
+
if (!isSubscribableResult(result)) {
|
|
101
|
+
console.error(
|
|
102
|
+
"Non-subscribable result encountered - please use correct operation type"
|
|
103
|
+
);
|
|
104
|
+
throw new Error("Internal error in Lightning Data Service adapter occurred");
|
|
105
|
+
}
|
|
106
|
+
if (result.isOk()) {
|
|
107
|
+
deepFreeze(result.value.data);
|
|
108
|
+
const api = {
|
|
109
|
+
data: result.value.data,
|
|
110
|
+
subscribe: (cb) => {
|
|
111
|
+
result.value.subscribe((result2) => {
|
|
112
|
+
if (result2.isErr()) {
|
|
113
|
+
return cb({ data: void 0, error: toError(result2.error) });
|
|
114
|
+
}
|
|
115
|
+
return cb({ data: result2.value, error: void 0 });
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
if (exposeRefresh) {
|
|
120
|
+
return {
|
|
121
|
+
...api,
|
|
122
|
+
refresh: () => {
|
|
123
|
+
return result.value.refresh().then((res) => {
|
|
124
|
+
if (res.isOk()) {
|
|
125
|
+
return void 0;
|
|
126
|
+
}
|
|
127
|
+
throw res.error;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
} else {
|
|
132
|
+
return api;
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
throw toError(result.error.failure);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function buildServiceDescriptor$4() {
|
|
140
|
+
return {
|
|
141
|
+
type: "subscribableImperativeBindings",
|
|
142
|
+
version: "1.0",
|
|
143
|
+
service: new SubscribableImperativeBindingsService()
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
class LegacyImperativeBindingsService {
|
|
147
|
+
bind(getCommand) {
|
|
148
|
+
const invoke = async (config, requestContext, callback) => {
|
|
149
|
+
const command = getCommand({ config, assertIsValid });
|
|
150
|
+
try {
|
|
151
|
+
const overrides = getOverridesForLegacyRequestContext(requestContext);
|
|
152
|
+
const result = await command.execute(overrides);
|
|
153
|
+
if (result.isOk()) {
|
|
154
|
+
deepFreeze(result.value);
|
|
155
|
+
callback({ data: result.value.data, error: void 0 });
|
|
156
|
+
} else {
|
|
157
|
+
callback({ data: void 0, error: toError(result.error.failure) });
|
|
158
|
+
}
|
|
159
|
+
} catch (error) {
|
|
160
|
+
emitError(callback, error);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const subscribe = (config, requestContext, callback) => {
|
|
164
|
+
const command = getCommand({ config, assertIsValid });
|
|
165
|
+
let unsubscribe = () => {
|
|
166
|
+
};
|
|
167
|
+
try {
|
|
168
|
+
const overrides = getOverridesForLegacyRequestContext(requestContext);
|
|
169
|
+
command.execute(overrides).then(
|
|
170
|
+
(result) => {
|
|
171
|
+
if (!result.isOk()) {
|
|
172
|
+
callback({ data: void 0, error: toError(result.error.failure) });
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
unsubscribe = result.value.subscribe((res) => {
|
|
176
|
+
if (res.isOk()) {
|
|
177
|
+
callback({ data: res.value, error: void 0 });
|
|
178
|
+
} else {
|
|
179
|
+
callback({ data: void 0, error: toError(res.error) });
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
callback({ data: result.value.data, error: void 0 });
|
|
183
|
+
},
|
|
184
|
+
(e) => {
|
|
185
|
+
emitError(callback, e);
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
} catch (e) {
|
|
189
|
+
emitError(callback, e);
|
|
190
|
+
}
|
|
191
|
+
return () => {
|
|
192
|
+
unsubscribe();
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
return { invoke, subscribe };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function buildServiceDescriptor$3() {
|
|
199
|
+
return {
|
|
200
|
+
type: "legacyImperativeBindings",
|
|
201
|
+
version: "1.0",
|
|
202
|
+
service: new LegacyImperativeBindingsService()
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
class GraphQLImperativeBindingsService {
|
|
206
|
+
bind(getCommand, exposeRefresh = false) {
|
|
207
|
+
return async (...params) => {
|
|
208
|
+
try {
|
|
209
|
+
if (params.length) {
|
|
210
|
+
params[0] = wrapConfigAndVerify(params[0]);
|
|
211
|
+
}
|
|
212
|
+
return await buildBaseImperativeInvoker(getCommand, (result) => this.transformResult(result, exposeRefresh))(...params);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
logError(error);
|
|
215
|
+
return {
|
|
216
|
+
data: void 0,
|
|
217
|
+
errors: [
|
|
218
|
+
{ message: "Internal error in GraphQL adapter occurred", locations: [] }
|
|
219
|
+
]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
transformResult(result, exposeRefresh = false) {
|
|
225
|
+
const consumerEmittedData = {
|
|
226
|
+
data: void 0,
|
|
227
|
+
errors: void 0
|
|
228
|
+
};
|
|
229
|
+
if (result.isOk()) {
|
|
230
|
+
deepFreeze(result.value);
|
|
231
|
+
consumerEmittedData.data = result.value.data.data;
|
|
232
|
+
consumerEmittedData.subscribe = (cb) => {
|
|
233
|
+
result.value.subscribe((res) => {
|
|
234
|
+
const consumerEmittedData2 = {
|
|
235
|
+
data: void 0,
|
|
236
|
+
errors: void 0
|
|
237
|
+
};
|
|
238
|
+
if (res.isOk()) {
|
|
239
|
+
consumerEmittedData2.data = res.value.data;
|
|
240
|
+
} else {
|
|
241
|
+
if (isUserVisibleError(res.error)) {
|
|
242
|
+
consumerEmittedData2.data = res.error.data.data;
|
|
243
|
+
consumerEmittedData2.errors = res.error.data.errors;
|
|
244
|
+
} else {
|
|
245
|
+
logError(res.error);
|
|
246
|
+
consumerEmittedData2.errors = [
|
|
247
|
+
{
|
|
248
|
+
message: "Internal error in GraphQL adapter occurred",
|
|
249
|
+
locations: []
|
|
250
|
+
}
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
cb(consumerEmittedData2);
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
if (exposeRefresh) {
|
|
258
|
+
consumerEmittedData.refresh = () => {
|
|
259
|
+
return new Promise((resolve, reject) => {
|
|
260
|
+
try {
|
|
261
|
+
result.value.refresh().then((res) => {
|
|
262
|
+
if (res.isOk()) {
|
|
263
|
+
resolve();
|
|
264
|
+
} else {
|
|
265
|
+
reject(
|
|
266
|
+
new Error(
|
|
267
|
+
"Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
|
|
268
|
+
)
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
} catch (error) {
|
|
273
|
+
logError(error);
|
|
274
|
+
reject(
|
|
275
|
+
new Error(
|
|
276
|
+
"Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
|
|
277
|
+
)
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
const resp = toGraphQLResponseFromFailure(result.error.failure);
|
|
285
|
+
consumerEmittedData.data = resp.data;
|
|
286
|
+
consumerEmittedData.errors = resp.errors;
|
|
287
|
+
}
|
|
288
|
+
return consumerEmittedData;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function buildServiceDescriptor$2() {
|
|
292
|
+
return {
|
|
293
|
+
type: "graphQLImperativeBindings",
|
|
294
|
+
version: "1.0",
|
|
295
|
+
service: new GraphQLImperativeBindingsService()
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
class GraphQLLegacyImperativeBindingsService {
|
|
299
|
+
bind(getCommand) {
|
|
300
|
+
const invoke = async (config, requestContext, callback) => {
|
|
301
|
+
config = wrapConfigAndVerify(config);
|
|
302
|
+
const command = getCommand({ config, assertIsValid });
|
|
303
|
+
try {
|
|
304
|
+
const overrides = getOverridesForLegacyRequestContext(requestContext);
|
|
305
|
+
const result = await command.execute(overrides);
|
|
306
|
+
const consumerEmittedData = {
|
|
307
|
+
data: void 0,
|
|
308
|
+
errors: void 0
|
|
309
|
+
};
|
|
310
|
+
if (result.isOk()) {
|
|
311
|
+
deepFreeze(result.value);
|
|
312
|
+
consumerEmittedData.data = result.value.data.data;
|
|
313
|
+
} else {
|
|
314
|
+
const { data, errors } = toGraphQLResponseFromFailure(result.error.failure);
|
|
315
|
+
consumerEmittedData.data = data;
|
|
316
|
+
consumerEmittedData.errors = errors;
|
|
317
|
+
}
|
|
318
|
+
callback(consumerEmittedData);
|
|
319
|
+
} catch (error) {
|
|
320
|
+
logError(error);
|
|
321
|
+
callback({
|
|
322
|
+
data: void 0,
|
|
323
|
+
errors: [
|
|
324
|
+
{ message: "Internal error in GraphQL adapter occurred", locations: [] }
|
|
325
|
+
]
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const subscribe = (config, requestContext, callback) => {
|
|
330
|
+
config = wrapConfigAndVerify(config);
|
|
331
|
+
const command = getCommand({ config, assertIsValid });
|
|
332
|
+
let unsubscribe = () => {
|
|
333
|
+
};
|
|
334
|
+
const overrides = getOverridesForLegacyRequestContext(requestContext);
|
|
335
|
+
command.execute(overrides).then((result) => {
|
|
336
|
+
const consumerEmittedData = {
|
|
337
|
+
data: void 0,
|
|
338
|
+
errors: void 0
|
|
339
|
+
};
|
|
340
|
+
if (result.isOk()) {
|
|
341
|
+
deepFreeze(result.value);
|
|
342
|
+
consumerEmittedData.data = result.value.data.data;
|
|
343
|
+
unsubscribe = result.value.subscribe(
|
|
344
|
+
(res) => {
|
|
345
|
+
handleEmit(res, callback);
|
|
346
|
+
}
|
|
347
|
+
);
|
|
348
|
+
} else {
|
|
349
|
+
const { data, errors } = toGraphQLResponseFromFailure(result.error.failure);
|
|
350
|
+
consumerEmittedData.data = data;
|
|
351
|
+
consumerEmittedData.errors = errors;
|
|
352
|
+
unsubscribe = result.error.subscribe(
|
|
353
|
+
(res) => {
|
|
354
|
+
handleEmit(res, callback);
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
callback(consumerEmittedData);
|
|
359
|
+
});
|
|
360
|
+
return () => {
|
|
361
|
+
unsubscribe();
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
return { invoke, subscribe };
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function buildServiceDescriptor$1() {
|
|
368
|
+
return {
|
|
369
|
+
type: "graphQLLegacyImperativeBindings",
|
|
370
|
+
version: "1.0",
|
|
371
|
+
service: new GraphQLLegacyImperativeBindingsService()
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
class GraphQLMutationBindingsService {
|
|
375
|
+
bind(getCommand) {
|
|
376
|
+
return async (...params) => {
|
|
377
|
+
try {
|
|
378
|
+
if (params.length) {
|
|
379
|
+
params[0] = wrapConfigAndVerify(params[0], {
|
|
380
|
+
acceptedOperations: ["mutation"]
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
const command = getCommand({ params, assertIsValid });
|
|
384
|
+
const result = await command.execute({ cacheControlConfig: { type: "no-cache" } });
|
|
385
|
+
if (result.isOk()) {
|
|
386
|
+
deepFreeze(result.value);
|
|
387
|
+
return result.value.data;
|
|
388
|
+
} else {
|
|
389
|
+
return toGraphQLResponseFromFailure(result.error.failure);
|
|
390
|
+
}
|
|
391
|
+
} catch (error) {
|
|
392
|
+
logError(error);
|
|
393
|
+
return {
|
|
394
|
+
data: void 0,
|
|
395
|
+
errors: [
|
|
396
|
+
{ message: "Internal error in GraphQL adapter occurred", locations: [] }
|
|
397
|
+
]
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function buildServiceDescriptor() {
|
|
404
|
+
return {
|
|
405
|
+
type: "graphQLMutationBindings",
|
|
406
|
+
version: "1.0",
|
|
407
|
+
service: new GraphQLMutationBindingsService()
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
export {
|
|
411
|
+
buildServiceDescriptor$6 as buildDefaultImperativeBindingsServiceDescriptor,
|
|
412
|
+
buildServiceDescriptor$2 as buildGraphQLImperativeBindingsServiceDescriptor,
|
|
413
|
+
buildServiceDescriptor$1 as buildGraphQLLegacyImperativeBindingsServiceDescriptor,
|
|
414
|
+
buildServiceDescriptor as buildGraphQLMutationBindingsServiceDescriptor,
|
|
415
|
+
buildServiceDescriptor$3 as buildLegacyImperativeBindingsServiceDescriptor,
|
|
416
|
+
buildServiceDescriptor$5 as buildQueryImperativeBindingsServiceDescriptor,
|
|
417
|
+
buildServiceDescriptor$4 as buildSubscribableImperativeBindingsServiceDescriptor
|
|
418
|
+
};
|
|
419
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/v1/utils.ts","../../src/v1/invokers/default-invoker.ts","../../src/v1/invokers/query-invoker.ts","../../src/v1/invokers/subscribable-invoker.ts","../../src/v1/invokers/legacy-invoker.ts","../../src/v1/invokers/graphql-invoker.ts","../../src/v1/invokers/graphql-legacy-invoker.ts","../../src/v1/invokers/graphql-mutation-invoker.ts"],"sourcesContent":["import { assertIsValid, type JSONSchema } from '@conduit-client/jsonschema-validate';\nimport {\n SubscribableResultCommand,\n ResultCommand,\n MaybeSubscribableResultCommand,\n ResultOrSubscribableResult,\n throwUserlandError,\n} from '@conduit-client/bindings-utils/v1';\nimport type {\n GraphQLCommandError,\n GraphQLResponse,\n} from '@conduit-client/graphql-normalization/v1';\nimport { Result, isUserVisibleError, logError } from '@conduit-client/utils';\n\nexport type ImperativeCommand<Data> =\n | SubscribableResultCommand<Data>\n | ResultCommand<Data>\n | MaybeSubscribableResultCommand<Data>;\n\nexport type GetCommand<Params extends Array<any>, CommandType> = (options: {\n params: Params;\n // utility to validate data against a JSONSchema\n assertIsValid: <T>(data: unknown, schema: JSONSchema) => asserts data is T;\n}) => CommandType;\n\nexport function buildBaseImperativeInvoker<\n Params extends Array<any>,\n Data,\n InvokerResult = Data,\n CommandType extends ImperativeCommand<Data> = ImperativeCommand<Data>,\n CommandResult extends ResultOrSubscribableResult<Data> = ResultOrSubscribableResult<Data>,\n>(\n getCommand: GetCommand<Params, CommandType>,\n transformResult: (result: CommandResult) => InvokerResult\n): (...params: Params) => PromiseLike<InvokerResult> {\n return async (...params: Params) => {\n const command = getCommand({ params, assertIsValid });\n try {\n return command.execute().then((result) => transformResult(result as CommandResult));\n } catch (error) {\n throwUserlandError(error);\n }\n };\n}\n\nexport const supportedCachePolicyTypes = ['no-cache', 'only-if-cached'] as const;\nexport type SupportedCachePolicyType = (typeof supportedCachePolicyTypes)[number];\n\nexport type CachePolicy = {\n cachePolicy: {\n type: SupportedCachePolicyType;\n };\n};\n\n/**\n * Type guard for legacy requestContext objects used with imperative-legacy bindings.\n *\n * When this function returns true, it indicates the caller requested a supported\n * cache policy override. Currently the only supported policy is `no-cache`.\n *\n * This helper is intentionally low-level; prefer using\n * {@link getOverridesForLegacyRequestContext} at call sites to construct the\n * proper `execute` overrides for Commands.\n */\nexport function requestContextIsSupportedCachePolicy(\n requestContext: unknown\n): requestContext is CachePolicy {\n return (\n typeof requestContext === 'object' &&\n requestContext !== null &&\n 'cachePolicy' in requestContext &&\n typeof requestContext.cachePolicy === 'object' &&\n requestContext.cachePolicy !== null &&\n 'type' in requestContext.cachePolicy &&\n typeof requestContext.cachePolicy.type === 'string' &&\n supportedCachePolicyTypes.includes(\n requestContext.cachePolicy.type as SupportedCachePolicyType\n )\n );\n}\n\nexport type LegacyExecuteOverrides = {\n cacheControlConfig?: { type: SupportedCachePolicyType };\n};\n\n/**\n * Builds the `execute` overrides for legacy imperative invokers based on the\n * provided requestContext. Encapsulates all hard-coded knowledge of supported\n * cache policies for legacy adapters.\n *\n * - If {@link requestContextIsSupportedCachePolicy} matches `no-cache`, returns\n * `{ cacheControlConfig: { type: 'no-cache' } }`.\n * - Otherwise returns `{}`.\n *\n * Use this in `buildAsyncImperativeLegacyInvoker` and GraphQL legacy invokers\n * to centralize override behavior.\n */\nexport function getOverridesForLegacyRequestContext(\n requestContext: unknown\n): LegacyExecuteOverrides {\n if (requestContextIsSupportedCachePolicy(requestContext)) {\n return { cacheControlConfig: { type: requestContext.cachePolicy.type } };\n }\n return {};\n}\n\nexport function handleEmit(\n res: Result<GraphQLResponse<Record<string, any>>, GraphQLCommandError>,\n callback: (result: GraphQLResponse) => void\n) {\n const consumerEmittedData = {\n data: undefined,\n errors: undefined,\n } as {\n data: GraphQLResponse | undefined;\n errors: any | undefined;\n };\n if (res.isOk()) {\n consumerEmittedData.data = res.value.data;\n } else {\n const { data, errors } = toGraphQLResponseFromFailure(res.error);\n consumerEmittedData.data = data;\n consumerEmittedData.errors = errors;\n }\n callback(consumerEmittedData);\n}\n\n/**\n * Maps a command failure (unknown or user-visible) into a GraphQLResponse suitable for consumers.\n */\nexport function toGraphQLResponseFromFailure(failure: unknown): {\n data: GraphQLResponse['data'];\n errors: GraphQLResponse['errors'];\n} {\n if (isUserVisibleError<GraphQLResponse>(failure)) {\n return {\n data: failure.data.data,\n errors: failure.data.errors,\n };\n }\n logError(failure);\n return {\n data: undefined,\n errors: [{ message: 'Internal error in GraphQL adapter occurred', locations: [] }],\n };\n}\n","import { isSubscribableResult, deepFreeze, toError } from '@conduit-client/utils';\nimport { buildBaseImperativeInvoker, ImperativeCommand, GetCommand } from '../utils';\n\nexport type DefaultImperativeResult<Data> = PromiseLike<Data>;\nexport class DefaultImperativeBindingsService {\n bind<Params extends Array<any>, Data>(\n getCommand: GetCommand<Params, ImperativeCommand<Data>>\n ): (...params: Params) => DefaultImperativeResult<Data> {\n return buildBaseImperativeInvoker<Params, Data>(getCommand, (result) => {\n if (result.isOk()) {\n deepFreeze(result.value);\n // For subscribable results processed by this invoker, only return data\n return isSubscribableResult(result) ? result.value.data : result.value;\n }\n\n throw toError(isSubscribableResult(result) ? result.error.failure : result.error);\n });\n }\n}\nexport interface DefaultImperativeBindingsServiceDescriptor {\n type: 'defaultImperativeBindings';\n version: string;\n service: DefaultImperativeBindingsService;\n}\n\nexport function buildServiceDescriptor(): DefaultImperativeBindingsServiceDescriptor {\n return {\n type: 'defaultImperativeBindings',\n version: '1.0',\n service: new DefaultImperativeBindingsService(),\n };\n}\n","import { deepFreeze, isSubscribableResult, toError } from '@conduit-client/utils';\nimport { buildBaseImperativeInvoker, GetCommand, ImperativeCommand } from '../utils';\n\ntype QueryResult<Data> = { data: Data };\nexport type QueryImperativeResult<Data> = PromiseLike<QueryResult<Data>>;\n\nexport class QueryImperativeBindingsService {\n bind<Params extends Array<any>, Data>(\n getCommand: GetCommand<Params, ImperativeCommand<Data>>\n ): (...params: Params) => QueryImperativeResult<Data> {\n return buildBaseImperativeInvoker<Params, Data, QueryResult<Data>>(getCommand, (result) => {\n if (result.isOk()) {\n deepFreeze(result.value);\n return isSubscribableResult(result)\n ? { data: result.value.data }\n : { data: result.value };\n }\n\n throw toError(isSubscribableResult(result) ? result.error.failure : result.error);\n });\n }\n}\n\nexport interface QueryImperativeBindingsServiceDescriptor {\n type: 'queryImperativeBindings';\n version: string;\n service: QueryImperativeBindingsService;\n}\n\nexport function buildServiceDescriptor(): QueryImperativeBindingsServiceDescriptor {\n return {\n type: 'queryImperativeBindings',\n version: '1.0',\n service: new QueryImperativeBindingsService(),\n };\n}\n","import { Callback, deepFreeze, isSubscribableResult, toError } from '@conduit-client/utils';\nimport { type ResultOrSubscribableResult } from '@conduit-client/bindings-utils/v1';\nimport { buildBaseImperativeInvoker, GetCommand, ImperativeCommand } from '../utils';\n\nexport type SubscribableImperativeResult<Data> = {\n data: Data;\n subscribe: (cb: Callback<any>) => void;\n};\n\nexport type SubscribableRefreshableImperativeResult<Data> = {\n data: Data;\n subscribe: (cb: Callback<any>) => void;\n refresh: () => PromiseLike<void>;\n};\n\nexport type MaybeRefreshableSubscribableImperativeResult<Data> =\n | SubscribableImperativeResult<Data>\n | SubscribableRefreshableImperativeResult<Data>;\n\nexport class SubscribableImperativeBindingsService {\n bind<Params extends Array<any>, Data>(\n getCommand: GetCommand<Params, ImperativeCommand<Data>>,\n exposeRefresh = false\n ): (...params: Params) => PromiseLike<MaybeRefreshableSubscribableImperativeResult<Data>> {\n return buildBaseImperativeInvoker<\n Params,\n Data,\n MaybeRefreshableSubscribableImperativeResult<Data>\n >(getCommand, (result) => this.transformResult(result, exposeRefresh));\n }\n\n transformResult<Data>(result: ResultOrSubscribableResult<Data>, exposeRefresh = false) {\n if (!isSubscribableResult(result)) {\n console.error(\n 'Non-subscribable result encountered - please use correct operation type'\n );\n throw new Error('Internal error in Lightning Data Service adapter occurred');\n }\n if (result.isOk()) {\n deepFreeze(result.value.data);\n\n const api = {\n data: result.value.data,\n subscribe: (cb: Callback<any>) => {\n result.value.subscribe((result) => {\n if (result.isErr()) {\n return cb({ data: undefined, error: toError(result.error) });\n }\n\n return cb({ data: result.value, error: undefined });\n });\n },\n };\n\n if (exposeRefresh) {\n return {\n ...api,\n refresh: () => {\n return result.value.refresh().then((res) => {\n if (res.isOk()) {\n return undefined;\n }\n throw res.error;\n });\n },\n };\n } else {\n return api;\n }\n } else {\n throw toError(result.error.failure);\n }\n }\n}\n\nexport interface SubscribableImperativeBindingsServiceDescriptor {\n type: 'subscribableImperativeBindings';\n version: string;\n service: SubscribableImperativeBindingsService;\n}\n\nexport function buildServiceDescriptor(): SubscribableImperativeBindingsServiceDescriptor {\n return {\n type: 'subscribableImperativeBindings',\n version: '1.0',\n service: new SubscribableImperativeBindingsService(),\n };\n}\n","import { Result, deepFreeze, toError, Unsubscribe } from '@conduit-client/utils';\nimport { JSONSchema, assertIsValid } from '@conduit-client/jsonschema-validate';\nimport { LegacyExecuteOverrides, getOverridesForLegacyRequestContext } from '../utils';\nimport { emitError, SubscribableResultCommand } from '@conduit-client/bindings-utils/v1';\n\ntype LegacyImperativeCallbackResult<Data> =\n | { data: Data; error: undefined }\n | { data: undefined; error: Error };\n\ntype LegacyImperativeAdapterInvokeType<Config, Data> = (\n config: Config,\n context: unknown,\n callback: (result: LegacyImperativeCallbackResult<Data>) => void\n) => void;\n\ntype LegacyImperativeAdapterSubscribeType<Config, Data> = (\n config: Config,\n context: unknown,\n callback: (result: LegacyImperativeCallbackResult<Data>) => void\n) => Unsubscribe;\n\nexport type LegacyImperativeShape<Config, Data> = {\n invoke: LegacyImperativeAdapterInvokeType<Config, Data>;\n subscribe: LegacyImperativeAdapterSubscribeType<Config, Data>;\n};\n\nexport type GetLegacyCommand<Config, Data> = (options: {\n config: Config;\n assertIsValid: <T>(data: unknown, schema: JSONSchema) => asserts data is T;\n}) => SubscribableResultCommand<Data, unknown, [LegacyExecuteOverrides?]>;\n\nexport class LegacyImperativeBindingsService {\n bind<Config, Data>(\n getCommand: GetLegacyCommand<Config, Data>\n ): LegacyImperativeShape<Config, Data> {\n const invoke: LegacyImperativeAdapterInvokeType<Config, Data> = async (\n config: Config,\n requestContext: unknown,\n callback: (result: LegacyImperativeCallbackResult<Data>) => void\n ) => {\n const command = getCommand({ config, assertIsValid });\n\n try {\n const overrides = getOverridesForLegacyRequestContext(requestContext);\n const result = await command.execute(overrides);\n if (result.isOk()) {\n deepFreeze(result.value);\n callback({ data: result.value.data, error: undefined });\n } else {\n callback({ data: undefined, error: toError(result.error.failure) });\n }\n } catch (error) {\n emitError(callback, error);\n }\n };\n\n const subscribe: LegacyImperativeAdapterSubscribeType<Config, Data> = (\n config: Config,\n requestContext: unknown,\n callback: (result: LegacyImperativeCallbackResult<Data>) => void\n ) => {\n const command = getCommand({ config, assertIsValid });\n\n let unsubscribe: Unsubscribe = () => {};\n\n try {\n const overrides = getOverridesForLegacyRequestContext(requestContext);\n command.execute(overrides).then(\n (result: Awaited<ReturnType<typeof command.execute>>) => {\n if (!result.isOk()) {\n callback({ data: undefined, error: toError(result.error.failure) });\n return;\n }\n\n unsubscribe = result.value.subscribe((res: Result<Data, unknown>) => {\n if (res.isOk()) {\n callback({ data: res.value, error: undefined });\n } else {\n callback({ data: undefined, error: toError(res.error) });\n }\n });\n\n callback({ data: result.value.data, error: undefined });\n },\n (e: unknown) => {\n emitError(callback, e);\n }\n );\n } catch (e) {\n emitError(callback, e);\n }\n\n return () => {\n unsubscribe();\n };\n };\n\n return { invoke, subscribe };\n }\n}\n\nexport interface LegacyImperativeBindingsServiceDescriptor {\n type: 'legacyImperativeBindings';\n version: string;\n service: LegacyImperativeBindingsService;\n}\n\nexport function buildServiceDescriptor(): LegacyImperativeBindingsServiceDescriptor {\n return {\n type: 'legacyImperativeBindings',\n version: '1.0',\n service: new LegacyImperativeBindingsService(),\n };\n}\n","import {\n deepFreeze,\n type Callback,\n type SubscribableResult,\n logError,\n isUserVisibleError,\n} from '@conduit-client/utils';\nimport {\n type GraphQLCommandError,\n type GraphQLResponse,\n type GraphQLCommand,\n} from '@conduit-client/graphql-normalization/v1';\nimport { wrapConfigAndVerify } from '@conduit-client/onestore-graphql-parser/v1';\nimport { buildBaseImperativeInvoker, GetCommand, toGraphQLResponseFromFailure } from '../utils';\n\nexport type SubscribableRefreshableGraphQLImperativeResult = GraphQLResponse & {\n subscribe?: (cb: Callback<any>) => void;\n refresh?: () => PromiseLike<void>;\n};\n\nexport class GraphQLImperativeBindingsService {\n bind<Params extends Array<any>>(\n getCommand: GetCommand<Params, GraphQLCommand>,\n exposeRefresh = false\n ): (...params: Params) => PromiseLike<SubscribableRefreshableGraphQLImperativeResult> {\n return async (...params: Params) => {\n try {\n if (params.length) {\n params[0] = wrapConfigAndVerify(params[0]);\n }\n return await buildBaseImperativeInvoker<\n Params,\n GraphQLResponse<Record<string, any>>,\n SubscribableRefreshableGraphQLImperativeResult,\n GraphQLCommand,\n SubscribableResult<GraphQLResponse<Record<string, any>>, GraphQLCommandError>\n >(getCommand, (result) => this.transformResult(result, exposeRefresh))(...params);\n } catch (error) {\n logError(error);\n return {\n data: undefined,\n errors: [\n { message: 'Internal error in GraphQL adapter occurred', locations: [] },\n ],\n };\n }\n };\n }\n\n transformResult<Data extends GraphQLResponse<Record<string, any>>>(\n result: SubscribableResult<Data, GraphQLCommandError>,\n exposeRefresh = false\n ): SubscribableRefreshableGraphQLImperativeResult {\n const consumerEmittedData = {\n data: undefined,\n errors: undefined,\n } as {\n data: GraphQLResponse | undefined;\n errors: any | undefined;\n subscribe: (cb: Callback<any>) => void;\n refresh: () => PromiseLike<void>;\n };\n\n if (result.isOk()) {\n deepFreeze(result.value);\n consumerEmittedData.data = result.value.data.data;\n consumerEmittedData.subscribe = (cb: Callback<any>) => {\n result.value.subscribe((res) => {\n const consumerEmittedData = {\n data: undefined,\n errors: undefined,\n } as {\n data: GraphQLResponse | undefined;\n errors: any | undefined;\n };\n if (res.isOk()) {\n consumerEmittedData.data = res.value.data;\n } else {\n if (isUserVisibleError<GraphQLResponse>(res.error)) {\n consumerEmittedData.data = res.error.data.data;\n consumerEmittedData.errors = res.error.data.errors;\n } else {\n logError(res.error);\n consumerEmittedData.errors = [\n {\n message: 'Internal error in GraphQL adapter occurred',\n locations: [],\n },\n ];\n }\n }\n cb(consumerEmittedData);\n });\n };\n if (exposeRefresh) {\n consumerEmittedData.refresh = () => {\n return new Promise((resolve, reject) => {\n try {\n result.value.refresh().then((res) => {\n if (res.isOk()) {\n resolve();\n } else {\n reject(\n new Error(\n 'Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data'\n )\n );\n }\n });\n } catch (error) {\n logError(error);\n reject(\n new Error(\n 'Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data'\n )\n );\n }\n });\n };\n }\n } else {\n const resp = toGraphQLResponseFromFailure(result.error.failure);\n consumerEmittedData.data = resp.data;\n consumerEmittedData.errors = resp.errors;\n }\n\n return consumerEmittedData;\n }\n}\n\nexport interface GraphQLImperativeBindingsServiceDescriptor {\n type: 'graphQLImperativeBindings';\n version: string;\n service: GraphQLImperativeBindingsService;\n}\n\nexport function buildServiceDescriptor(): GraphQLImperativeBindingsServiceDescriptor {\n return {\n type: 'graphQLImperativeBindings',\n version: '1.0',\n service: new GraphQLImperativeBindingsService(),\n };\n}\n","import { deepFreeze, Result, Unsubscribe, logError } from '@conduit-client/utils';\nimport { JSONSchema, assertIsValid } from '@conduit-client/jsonschema-validate';\nimport {\n type GraphQLCommandError,\n type GraphQLResponse,\n type GraphQLCommand,\n} from '@conduit-client/graphql-normalization/v1';\nimport { wrapConfigAndVerify } from '@conduit-client/onestore-graphql-parser/v1';\nimport type { Command } from '@conduit-client/command-base/v1';\nimport { getOverridesForLegacyRequestContext, handleEmit } from '../utils';\nimport { type LegacyExecuteOverrides, toGraphQLResponseFromFailure } from '../utils';\n\ntype LegacyGraphQLImperativeAdapterInvokeType<Config> = (\n config: Config,\n context: unknown,\n callback: (result: GraphQLResponse) => void\n) => void;\n\ntype LegacyGraphQLImperativeAdapterSubscribeType<Config> = (\n config: Config,\n context: unknown,\n callback: (result: GraphQLResponse) => void\n) => Unsubscribe;\n\nexport type LegacyGraphQLImperativeShape<Config> = {\n invoke: LegacyGraphQLImperativeAdapterInvokeType<Config>;\n subscribe: LegacyGraphQLImperativeAdapterSubscribeType<Config>;\n};\n\nexport type GetGraphQLLegacyCommand<Config> = (options: {\n config: Config;\n assertIsValid: <T>(data: unknown, schema: JSONSchema) => asserts data is T;\n}) => Command<ReturnType<GraphQLCommand['execute']>, [LegacyExecuteOverrides?]>;\n\nexport class GraphQLLegacyImperativeBindingsService {\n bind<Config>(\n getCommand: GetGraphQLLegacyCommand<Config>\n ): LegacyGraphQLImperativeShape<Config> {\n const invoke: LegacyGraphQLImperativeAdapterInvokeType<Config> = async (\n config: Config,\n requestContext: unknown,\n callback: (result: GraphQLResponse) => void\n ) => {\n config = wrapConfigAndVerify(config);\n const command = getCommand({ config, assertIsValid });\n\n try {\n const overrides = getOverridesForLegacyRequestContext(requestContext);\n const result: Awaited<ReturnType<typeof command.execute>> =\n await command.execute(overrides);\n\n const consumerEmittedData = {\n data: undefined,\n errors: undefined,\n } as {\n data: GraphQLResponse | undefined;\n errors: any | undefined;\n };\n\n if (result.isOk()) {\n deepFreeze(result.value);\n consumerEmittedData.data = result.value.data.data;\n } else {\n const { data, errors } = toGraphQLResponseFromFailure(result.error.failure);\n consumerEmittedData.data = data;\n consumerEmittedData.errors = errors;\n }\n\n callback(consumerEmittedData);\n } catch (error) {\n logError(error);\n callback({\n data: undefined,\n errors: [\n { message: 'Internal error in GraphQL adapter occurred', locations: [] },\n ],\n } satisfies GraphQLResponse);\n }\n };\n\n const subscribe: LegacyGraphQLImperativeAdapterSubscribeType<Config> = (\n config: Config,\n requestContext: unknown,\n callback: (result: GraphQLResponse) => void\n ) => {\n config = wrapConfigAndVerify(config);\n const command = getCommand({ config, assertIsValid });\n\n let unsubscribe: Unsubscribe = () => {};\n\n const overrides = getOverridesForLegacyRequestContext(requestContext);\n command\n .execute(overrides)\n .then((result: Awaited<ReturnType<typeof command.execute>>) => {\n const consumerEmittedData = {\n data: undefined,\n errors: undefined,\n } as {\n data: GraphQLResponse | undefined;\n errors: any | undefined;\n };\n\n if (result.isOk()) {\n deepFreeze(result.value);\n consumerEmittedData.data = result.value.data.data;\n unsubscribe = result.value.subscribe(\n (\n res: Result<\n GraphQLResponse<Record<string, any>>,\n GraphQLCommandError\n >\n ) => {\n handleEmit(res, callback);\n }\n );\n } else {\n const { data, errors } = toGraphQLResponseFromFailure(result.error.failure);\n consumerEmittedData.data = data;\n consumerEmittedData.errors = errors;\n unsubscribe = result.error.subscribe(\n (\n res: Result<\n GraphQLResponse<Record<string, any>>,\n GraphQLCommandError\n >\n ) => {\n handleEmit(res, callback);\n }\n );\n }\n\n callback(consumerEmittedData);\n });\n\n return () => {\n unsubscribe();\n };\n };\n\n return { invoke, subscribe };\n }\n}\n\nexport interface GraphQLLegacyImperativeBindingsServiceDescriptor {\n type: 'graphQLLegacyImperativeBindings';\n version: string;\n service: GraphQLLegacyImperativeBindingsService;\n}\n\nexport function buildServiceDescriptor(): GraphQLLegacyImperativeBindingsServiceDescriptor {\n return {\n type: 'graphQLLegacyImperativeBindings',\n version: '1.0',\n service: new GraphQLLegacyImperativeBindingsService(),\n };\n}\n","import { deepFreeze, logError } from '@conduit-client/utils';\nimport { JSONSchema, assertIsValid } from '@conduit-client/jsonschema-validate';\nimport {\n type GraphQLResponse,\n type GraphQLCommand,\n} from '@conduit-client/graphql-normalization/v1';\nimport { wrapConfigAndVerify } from '@conduit-client/onestore-graphql-parser/v1';\nimport type { Command } from '@conduit-client/command-base/v1';\nimport { type LegacyExecuteOverrides, toGraphQLResponseFromFailure } from '../utils';\n\nexport type GraphQLMutationResult = Promise<GraphQLResponse>;\ntype GetGraphQLCommand<Params> = (options: {\n params: Params;\n assertIsValid: <T>(data: unknown, schema: JSONSchema) => asserts data is T;\n}) => Command<ReturnType<GraphQLCommand['execute']>, [LegacyExecuteOverrides?]>;\n\nexport class GraphQLMutationBindingsService {\n bind<Params extends Array<any>>(\n getCommand: GetGraphQLCommand<Params>\n ): (...params: Params) => GraphQLMutationResult {\n return async (...params: Params) => {\n try {\n if (params.length) {\n params[0] = wrapConfigAndVerify(params[0], {\n acceptedOperations: ['mutation'],\n });\n }\n const command = getCommand({ params, assertIsValid });\n const result = await command.execute({ cacheControlConfig: { type: 'no-cache' } });\n\n if (result.isOk()) {\n deepFreeze(result.value);\n return result.value.data;\n } else {\n return toGraphQLResponseFromFailure(result.error.failure);\n }\n } catch (error) {\n logError(error);\n return {\n data: undefined,\n errors: [\n { message: 'Internal error in GraphQL adapter occurred', locations: [] },\n ],\n } satisfies GraphQLResponse;\n }\n };\n }\n}\n\nexport interface GraphQLMutationBindingsServiceDescriptor {\n type: 'graphQLMutationBindings';\n version: string;\n service: GraphQLMutationBindingsService;\n}\n\nexport function buildServiceDescriptor(): GraphQLMutationBindingsServiceDescriptor {\n return {\n type: 'graphQLMutationBindings',\n version: '1.0',\n service: new GraphQLMutationBindingsService(),\n };\n}\n"],"names":["buildServiceDescriptor","result","consumerEmittedData"],"mappings":";;;;;;;;;AAyBO,SAAS,2BAOZ,YACA,iBACiD;AACjD,SAAO,UAAU,WAAmB;AAChC,UAAM,UAAU,WAAW,EAAE,QAAQ,eAAe;AACpD,QAAI;AACA,aAAO,QAAQ,UAAU,KAAK,CAAC,WAAW,gBAAgB,MAAuB,CAAC;AAAA,IACtF,SAAS,OAAO;AACZ,yBAAmB,KAAK;AAAA,IAC5B;AAAA,EACJ;AACJ;AAEO,MAAM,4BAA4B,CAAC,YAAY,gBAAgB;AAmB/D,SAAS,qCACZ,gBAC6B;AAC7B,SACI,OAAO,mBAAmB,YAC1B,mBAAmB,QACnB,iBAAiB,kBACjB,OAAO,eAAe,gBAAgB,YACtC,eAAe,gBAAgB,QAC/B,UAAU,eAAe,eACzB,OAAO,eAAe,YAAY,SAAS,YAC3C,0BAA0B;AAAA,IACtB,eAAe,YAAY;AAAA,EAAA;AAGvC;AAkBO,SAAS,oCACZ,gBACsB;AACtB,MAAI,qCAAqC,cAAc,GAAG;AACtD,WAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,YAAY,OAAK;AAAA,EACzE;AACA,SAAO,CAAA;AACX;AAEO,SAAS,WACZ,KACA,UACF;AACE,QAAM,sBAAsB;AAAA,IACxB,MAAM;AAAA,IACN,QAAQ;AAAA,EAAA;AAKZ,MAAI,IAAI,QAAQ;AACZ,wBAAoB,OAAO,IAAI,MAAM;AAAA,EACzC,OAAO;AACH,UAAM,EAAE,MAAM,OAAA,IAAW,6BAA6B,IAAI,KAAK;AAC/D,wBAAoB,OAAO;AAC3B,wBAAoB,SAAS;AAAA,EACjC;AACA,WAAS,mBAAmB;AAChC;AAKO,SAAS,6BAA6B,SAG3C;AACE,MAAI,mBAAoC,OAAO,GAAG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A,IACN,SAAS;AAAA,IACT,SAAS,IAAI,uCAAA;AAAA,EAAuC;AAE5D;AC3IO,MAAM,+BAA+B;AAAA,EACxC,KACI,YAC4C;AAC5C,WAAO,UAAU,WAAmB;AAChC,UAAI;AACA,YAAI,OAAO,QAAQ;AACf,iBAAO,CAAC,IAAI,oBAAoB,OAAO,CAAC,GAAG;AAAA,YACvC,oBAAoB,CAAC,UAAU;AAAA,UAAA,CAClC;AAAA,QACL;AACA,cAAM,UAAU,WAAW,EAAE,QAAQ,eAAe;AACpD,cAAM,SAAS,MAAM,QAAQ,QAAQ,EAAE,oBAAoB,EAAE,MAAM,WAAA,GAAc;AAEjF,YAAI,OAAO,QAAQ;AACf,qBAAW,OAAO,KAAK;AACvB,iBAAO,OAAO,MAAM;AAAA,QACxB,OAAO;AACH,iBAAO,6BAA6B,OAAO,MAAM,OAAO;AAAA,QAC5D;AAAA,MACJ,SAAS,OAAO;AACZ,iBAAS,KAAK;AACd,eAAO;AAAA,UACH,MAAM;AAAA,UACN,QAAQ;AAAA,YACJ,EAAE,SAAS,8CAA8C,WAAW,CAAA,EAAC;AAAA,UAAE;AAAA,QAC3E;AAAA,MAER;AAAA,IACJ;AAAA,EACJ;AACJ;AAQO,SAAS,yBAAmE;AAC/E,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,IAAI,+BAAA;AAAA,EAA+B;AAEpD;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@conduit-client/service-bindings-imperative",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Conduit services for imperative bindings",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/salesforce-experience-platform-emu/onestore.git",
|
|
10
|
+
"directory": "packages/@conduit-client/services/bindings-imperative"
|
|
11
|
+
},
|
|
12
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
13
|
+
"exports": {
|
|
14
|
+
"./v1": {
|
|
15
|
+
"import": "./dist/v1/index.js",
|
|
16
|
+
"types": "./dist/types/v1/index.d.ts",
|
|
17
|
+
"require": "./dist/v1/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/main/index.js",
|
|
21
|
+
"module": "./dist/main/index.js",
|
|
22
|
+
"types": "./dist/main/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "vite build && tsc --build --emitDeclarationOnly",
|
|
28
|
+
"clean": "rm -rf dist",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:size": "size-limit",
|
|
31
|
+
"watch": "npm run build --watch"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@conduit-client/bindings-utils": "2.1.0",
|
|
35
|
+
"@conduit-client/command-base": "2.1.0",
|
|
36
|
+
"@conduit-client/jsonschema-validate": "2.1.0",
|
|
37
|
+
"@conduit-client/onestore-graphql-parser": "2.1.0",
|
|
38
|
+
"@conduit-client/utils": "2.1.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@conduit-client/graphql-normalization": "2.1.0"
|
|
42
|
+
},
|
|
43
|
+
"volta": {
|
|
44
|
+
"extends": "../../../../package.json"
|
|
45
|
+
},
|
|
46
|
+
"size-limit": [
|
|
47
|
+
{
|
|
48
|
+
"path": "./dist/v1/index.js",
|
|
49
|
+
"limit": "2.1 kB"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|