@conduit-client/service-bindings-lwc 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 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,302 @@
1
+ # @conduit-client/service-bindings-lwc
2
+
3
+ Conduit services for Lightning Web Components (LWC) bindings, providing wire adapter integration for commands.
4
+
5
+ ## Overview
6
+
7
+ This package provides specialized services for integrating Conduit data fetching with Lightning Web Components. It includes wire adapter services for creating LWC-compatible wire adapters from commands, with specialized support for GraphQL queries.
8
+
9
+ ## Key Features
10
+
11
+ - **Wire Adapter Support**: Service for creating LWC wire adapter constructors from commands
12
+ - **GraphQL Integration**: Specialized GraphQL wire adapter with query validation
13
+ - **JSON Schema Validation**: Configuration validation using JSON schemas
14
+ - **Subscribable Results**: Support for real-time data updates via subscriptions
15
+ - **Refresh Support**: Optional refresh functionality for updating wire data
16
+ - **Type Safety**: Full TypeScript support with proper type definitions
17
+
18
+ ## Module Structure
19
+
20
+ ### Core Services
21
+
22
+ #### `LWCWireBindingService`
23
+
24
+ Base wire adapter service for integrating commands with LWC wire adapters.
25
+
26
+ - Creates wire adapter constructors from commands
27
+ - Manages wire adapter lifecycle
28
+ - Handles configuration validation with JSON schemas
29
+ - Supports subscribable and refreshable results
30
+
31
+ #### `LWCGraphQLWireBindingService`
32
+
33
+ GraphQL-specific wire adapter service extending the base wire functionality.
34
+
35
+ - Validates GraphQL operations (queries only, no mutations/subscriptions)
36
+ - Maps GraphQL responses to LWC wire format
37
+ - Handles GraphQL errors appropriately
38
+ - Supports refresh functionality for GraphQL queries
39
+
40
+ ## Usage Examples
41
+
42
+ ### Basic Wire Adapter
43
+
44
+ First, create the wire adapter outside your component:
45
+
46
+ ```javascript
47
+ // userDataAdapter.js
48
+ import { buildLWCWireBindingsServiceDescriptor } from '@conduit-client/services/bindings-lwc/v1';
49
+
50
+ // Build the service
51
+ const { service: lwcWireBindingsService } = buildLWCWireBindingsServiceDescriptor();
52
+
53
+ // Define the JSON schema for your wire adapter configuration
54
+ const userDataSchema = {
55
+ type: 'object',
56
+ properties: {
57
+ userId: { type: 'string' },
58
+ },
59
+ required: ['userId'],
60
+ additionalProperties: false,
61
+ };
62
+
63
+ // Create a command factory
64
+ const getUserDataCommand = (config) => ({
65
+ execute: async () => {
66
+ // Fetch user data based on config.userId
67
+ const response = await fetch(`/api/users/${config.userId}`);
68
+ const data = await response.json();
69
+
70
+ return {
71
+ isOk: () => true,
72
+ value: {
73
+ data: data,
74
+ // Optional: Add subscription support
75
+ subscribe: (callback) => {
76
+ // Set up subscription logic
77
+ const interval = setInterval(() => {
78
+ // Fetch updated data and call callback
79
+ callback({ isOk: () => true, value: { data: updatedData } });
80
+ }, 5000);
81
+
82
+ // Return unsubscribe function
83
+ return () => clearInterval(interval);
84
+ },
85
+ },
86
+ };
87
+ },
88
+ });
89
+
90
+ // Bind the command to create a wire adapter constructor
91
+ export const getUserData = lwcWireBindingsService.bind(
92
+ getUserDataCommand,
93
+ userDataSchema,
94
+ false // Set to true to expose refresh function
95
+ );
96
+ ```
97
+
98
+ Then use it in your LWC component:
99
+
100
+ ```javascript
101
+ // MyComponent.js
102
+ import { LightningElement, wire } from 'lwc';
103
+ import { getUserData } from './userDataAdapter';
104
+
105
+ export default class MyComponent extends LightningElement {
106
+ userId = '123';
107
+
108
+ @wire(getUserData, { userId: '$userId' })
109
+ userData;
110
+
111
+ get formattedData() {
112
+ if (this.userData.data) {
113
+ return this.userData.data;
114
+ }
115
+ return undefined;
116
+ }
117
+
118
+ get error() {
119
+ return this.userData.error;
120
+ }
121
+ }
122
+ ```
123
+
124
+ ### GraphQL Wire Adapter
125
+
126
+ ```javascript
127
+ // graphqlAdapter.js
128
+ import { buildLWCGraphQLWireBindingsServiceDescriptor } from '@conduit-client/services/bindings-lwc/v1';
129
+ import { gql } from '@conduit-client/onestore-graphql-parser/v1';
130
+
131
+ // Build the GraphQL service
132
+ const { service: lwcGraphQLWireBindingsService } = buildLWCGraphQLWireBindingsServiceDescriptor();
133
+
134
+ // Create a GraphQL command factory
135
+ const getGraphQLCommand = (config) => ({
136
+ execute: async () => {
137
+ // Execute GraphQL query
138
+ const response = await fetch('/graphql', {
139
+ method: 'POST',
140
+ headers: { 'Content-Type': 'application/json' },
141
+ body: JSON.stringify({
142
+ query: config.query,
143
+ variables: config.variables,
144
+ operationName: config.operationName,
145
+ }),
146
+ });
147
+
148
+ const graphqlResponse = await response.json();
149
+
150
+ return {
151
+ isOk: () => !graphqlResponse.errors || graphqlResponse.errors.length === 0,
152
+ value: {
153
+ data: graphqlResponse,
154
+ subscribe: (callback) => {
155
+ // Set up GraphQL subscription if needed
156
+ return () => {}; // Return unsubscribe
157
+ },
158
+ },
159
+ };
160
+ },
161
+ });
162
+
163
+ // Bind to create a GraphQL wire adapter constructor
164
+ export const graphqlWire = lwcGraphQLWireBindingsService.bind(
165
+ getGraphQLCommand,
166
+ undefined, // Schema is handled internally for GraphQL
167
+ true // Enable refresh support
168
+ );
169
+ ```
170
+
171
+ Then use it in your LWC component:
172
+
173
+ ```javascript
174
+ // UserProfile.js
175
+ import { LightningElement, wire } from 'lwc';
176
+ import { graphqlWire } from './graphqlAdapter';
177
+ import { gql } from '@conduit-client/onestore-graphql-parser/v1';
178
+
179
+ const USER_QUERY = gql`
180
+ query GetUser($id: ID!) {
181
+ user(id: $id) {
182
+ name
183
+ email
184
+ }
185
+ }
186
+ `;
187
+
188
+ export default class UserProfile extends LightningElement {
189
+ userId = '123';
190
+
191
+ @wire(graphqlWire, {
192
+ query: USER_QUERY,
193
+ variables: '$variables',
194
+ operationName: 'GetUser',
195
+ })
196
+ userData;
197
+
198
+ get variables() {
199
+ return { id: this.userId };
200
+ }
201
+
202
+ get user() {
203
+ return this.userData.data?.user;
204
+ }
205
+
206
+ get errors() {
207
+ return this.userData.errors;
208
+ }
209
+
210
+ async handleRefresh() {
211
+ // If refresh is enabled, you can manually refresh
212
+ if (this.userData.refresh) {
213
+ await this.userData.refresh();
214
+ }
215
+ }
216
+ }
217
+ ```
218
+
219
+ ## API Reference
220
+
221
+ ### Service Descriptors
222
+
223
+ #### `buildLWCWireBindingsServiceDescriptor()`
224
+
225
+ Returns a service descriptor for creating LWC wire adapters.
226
+
227
+ ```typescript
228
+ const { service } = buildLWCWireBindingsServiceDescriptor();
229
+ ```
230
+
231
+ #### `buildLWCGraphQLWireBindingsServiceDescriptor()`
232
+
233
+ Returns a service descriptor for creating GraphQL-specific LWC wire adapters.
234
+
235
+ ```typescript
236
+ const { service } = buildLWCGraphQLWireBindingsServiceDescriptor();
237
+ ```
238
+
239
+ ### Service Methods
240
+
241
+ #### `bind(getCommand, schema?, exposeRefresh?)`
242
+
243
+ Binds a command factory to create a wire adapter constructor.
244
+
245
+ Parameters:
246
+
247
+ - `getCommand`: Function that returns a command object with an `execute` method
248
+ - `schema`: Optional JSON schema for configuration validation (required for base wire, optional for GraphQL)
249
+ - `exposeRefresh`: Optional boolean to expose refresh functionality (default: false)
250
+
251
+ Returns: A wire adapter constructor class that can be used with LWC's `@wire` decorator
252
+
253
+ ### Wire Adapter Constructor
254
+
255
+ The constructor returned by `bind` has the following interface:
256
+
257
+ ```typescript
258
+ class WireAdapterConstructor {
259
+ constructor(dataCallback: (result: WireAdapterResult) => void);
260
+ connect(): void;
261
+ disconnect(): void;
262
+ update(config: any): void;
263
+ }
264
+ ```
265
+
266
+ ### Wire Adapter Result
267
+
268
+ The data passed to the LWC component has this shape:
269
+
270
+ ```typescript
271
+ interface WireAdapterResult {
272
+ data?: any;
273
+ error?: Error;
274
+ refresh?: () => Promise<void>; // Only if exposeRefresh is true
275
+ }
276
+ ```
277
+
278
+ ### GraphQL-Specific Result
279
+
280
+ For GraphQL wire adapters, the result follows the GraphQL response format:
281
+
282
+ ```typescript
283
+ interface GraphQLWireResult {
284
+ data?: any;
285
+ errors?: Array<{
286
+ message: string;
287
+ locations?: Array<{ line: number; column: number }>;
288
+ }>;
289
+ refresh?: () => Promise<void>; // Only if exposeRefresh is true
290
+ }
291
+ ```
292
+
293
+ ### Command Interface
294
+
295
+ Commands must implement the interface from `@conduit-client/command-base`:
296
+
297
+ ## Dependencies
298
+
299
+ - `@conduit-client/utils`: Core utility functions
300
+ - `@conduit-client/bindings-utils`: Shared binding utilities
301
+ - `@conduit-client/jsonschema-validate`: JSON schema validation
302
+ - `@conduit-client/onestore-graphql-parser`: GraphQL parsing utilities
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ //# sourceMappingURL=index.js.map
@@ -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,19 @@
1
+ import { Result, SubscribableResult } from '@conduit-client/utils';
2
+ import { type GraphQLCommandError, type GraphQLResponse, type GraphQLCommand } from '@conduit-client/graphql-normalization/v1';
3
+ import { type JSONSchema } from '@conduit-client/jsonschema-validate';
4
+ import { type WireAdapterConstructor, type WireConfigValue, type WireContextValue } from '@conduit-client/lwc-types';
5
+ import { CommandWireAdapterConstructor, type GetCommand } from './utils';
6
+ export declare abstract class GraphQLCommandWireAdapterConstructor<Config extends WireConfigValue = WireConfigValue> extends CommandWireAdapterConstructor<GraphQLResponse, Config, GraphQLCommand> {
7
+ protected emit(result?: SubscribableResult<GraphQLResponse, GraphQLCommandError> | Result<GraphQLResponse, GraphQLCommandError> | undefined): void;
8
+ protected handleExecutionThrow(e: unknown): void;
9
+ update(config: Config, _context?: WireContextValue): void;
10
+ }
11
+ export declare class LWCGraphQLWireBindingsService {
12
+ bind<Config extends WireConfigValue = WireConfigValue>(getCommand: GetCommand<GraphQLResponse, GraphQLCommand>, configSchema?: JSONSchema, exposeRefresh?: boolean): WireAdapterConstructor<Config, GraphQLResponse, {}>;
13
+ }
14
+ export interface LWCGraphQLWireBindingsServiceDescriptor {
15
+ type: 'lwcGraphQLWireBindings';
16
+ version: string;
17
+ service: LWCGraphQLWireBindingsService;
18
+ }
19
+ export declare function buildServiceDescriptor(): LWCGraphQLWireBindingsServiceDescriptor;
@@ -0,0 +1,2 @@
1
+ export { buildServiceDescriptor as buildLWCWireBindingsServiceDescriptor } from './wire';
2
+ export { buildServiceDescriptor as buildLWCGraphQLWireBindingsServiceDescriptor } from './graphql-wire';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns a sanitized version of an object by recursively unwrapping the Proxies.
3
+ *
4
+ * All the data coming from LWC-land need to be sanitized first.
5
+ */
6
+ export default function sanitize<T extends object>(obj: T): T;
@@ -0,0 +1,41 @@
1
+ import { SubscribableResultCommand, ResultCommand, MaybeSubscribableResultCommand } from '@conduit-client/bindings-utils/v1';
2
+ import { type JSONSchema } from '@conduit-client/jsonschema-validate';
3
+ import { type WireAdapter, type WireConfigValue, type WireContextValue, type WireDataCallback } from '@conduit-client/lwc-types';
4
+ import { type SyncOrAsync, type Unsubscribe, type SubscribableResult, type CommandError, type Result } from '@conduit-client/utils';
5
+ import { type GraphQLResponse } from '@conduit-client/graphql-normalization/v1';
6
+ export type WireAdapterCompatibleCommand<Data, Error> = SubscribableResultCommand<Data, Error> | ResultCommand<Data, Error> | MaybeSubscribableResultCommand<Data, Error>;
7
+ export declare function isIncompleteConfigError(err: unknown): boolean;
8
+ export type GetCommand<Data, CommandType extends WireAdapterCompatibleCommand<Data, CommandError> = WireAdapterCompatibleCommand<Data, CommandError>> = () => CommandType;
9
+ /**
10
+ * Binds a Command to a LWC wire adapter.
11
+ * @see https://lwc.dev/guide/wire_adapter
12
+ */
13
+ export declare abstract class CommandWireAdapterConstructor<Data, Config extends WireConfigValue = WireConfigValue, CommandType extends WireAdapterCompatibleCommand<Data, CommandError> = WireAdapterCompatibleCommand<Data, CommandError>> implements WireAdapter {
14
+ protected callback: WireDataCallback;
15
+ connected: boolean;
16
+ config?: Config;
17
+ unsubscriber?: Unsubscribe;
18
+ exposeRefresh: boolean;
19
+ abstract configSchema?: JSONSchema;
20
+ abstract getCommand(): CommandType;
21
+ protected refresh?: () => SyncOrAsync<Result<void, unknown>>;
22
+ constructor(callback: WireDataCallback, sourceContext?: {
23
+ tagName?: string;
24
+ }, options?: {
25
+ skipEmptyEmit?: true;
26
+ });
27
+ connect(): void;
28
+ disconnect(): void;
29
+ update(config: Config, _context?: WireContextValue): void;
30
+ protected emit(result?: Result<Data, unknown> | SubscribableResult<Data, unknown>): void;
31
+ protected invokeAdapter(): void;
32
+ protected handleExecutionThrow(error: unknown): void;
33
+ protected unsubscribe(): void;
34
+ }
35
+ /**
36
+ * Maps a command failure (unknown or user-visible) into a GraphQLResponse suitable for consumers.
37
+ */
38
+ export declare function toGraphQLResponseFromFailure(failure: unknown): {
39
+ data: GraphQLResponse['data'];
40
+ errors: GraphQLResponse['errors'];
41
+ };
@@ -0,0 +1,12 @@
1
+ import { type JSONSchema } from '@conduit-client/jsonschema-validate';
2
+ import { type WireAdapterConstructor, type WireConfigValue } from '@conduit-client/lwc-types';
3
+ import { type GetCommand } from './utils';
4
+ export declare class LWCWireBindingsService {
5
+ bind<Data, Config extends WireConfigValue = WireConfigValue>(getCommand: GetCommand<Data>, configSchema?: JSONSchema, exposeRefresh?: boolean): WireAdapterConstructor<Config, Data, {}>;
6
+ }
7
+ export interface LWCWireBindingsServiceDescriptor {
8
+ type: 'lwcWireBindings';
9
+ version: string;
10
+ service: LWCWireBindingsService;
11
+ }
12
+ export declare function buildServiceDescriptor(): LWCWireBindingsServiceDescriptor;
@@ -0,0 +1,344 @@
1
+ /*!
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ import { emitError } from "@conduit-client/bindings-utils/v1";
7
+ import { assertIsValid, MissingRequiredPropertyError, JsonSchemaViolationError } from "@conduit-client/jsonschema-validate";
8
+ import { isSubscribableResult, deepFreeze, ok, isUserVisibleError, logError } from "@conduit-client/utils";
9
+ import { resolveAst, validateGraphQLOperations } from "@conduit-client/onestore-graphql-parser/v1";
10
+ class Sanitizer {
11
+ constructor(obj) {
12
+ this.obj = obj;
13
+ this.copy = {};
14
+ this.currentPath = {
15
+ key: "",
16
+ value: obj,
17
+ parent: null,
18
+ data: this.copy
19
+ };
20
+ }
21
+ sanitize() {
22
+ const sanitizer = this;
23
+ JSON.stringify(this.obj, function(key, value) {
24
+ if (key === "") {
25
+ return value;
26
+ }
27
+ const parent = this;
28
+ if (parent !== sanitizer.currentPath.value) {
29
+ sanitizer.exit(parent);
30
+ }
31
+ if (typeof value === "object" && value !== null) {
32
+ sanitizer.enter(key, value);
33
+ return value;
34
+ }
35
+ sanitizer.currentPath.data[key] = value;
36
+ return value;
37
+ });
38
+ return this.copy;
39
+ }
40
+ enter(key, value) {
41
+ const { currentPath: parentPath } = this;
42
+ const data = parentPath.data[key] = Array.isArray(value) ? [] : {};
43
+ this.currentPath = {
44
+ key,
45
+ value,
46
+ parent: parentPath,
47
+ data
48
+ };
49
+ }
50
+ exit(parent) {
51
+ while (this.currentPath.value !== parent) {
52
+ this.currentPath = this.currentPath.parent || this.currentPath;
53
+ }
54
+ }
55
+ }
56
+ function sanitize(obj) {
57
+ return new Sanitizer(obj).sanitize();
58
+ }
59
+ function isIncompleteConfigError(err) {
60
+ return err instanceof MissingRequiredPropertyError || err instanceof JsonSchemaViolationError && err.validationErrors.find(
61
+ (validationError) => validationError instanceof MissingRequiredPropertyError
62
+ ) !== void 0;
63
+ }
64
+ class CommandWireAdapterConstructor {
65
+ constructor(callback, sourceContext, options) {
66
+ this.callback = callback;
67
+ this.connected = false;
68
+ this.exposeRefresh = false;
69
+ if (!(options == null ? void 0 : options.skipEmptyEmit)) {
70
+ this.emit();
71
+ }
72
+ }
73
+ connect() {
74
+ this.connected = true;
75
+ this.invokeAdapter();
76
+ }
77
+ disconnect() {
78
+ this.unsubscribe();
79
+ this.connected = false;
80
+ }
81
+ update(config, _context) {
82
+ this.unsubscribe();
83
+ this.config = sanitize(config);
84
+ this.invokeAdapter();
85
+ }
86
+ emit(result) {
87
+ try {
88
+ if (result === void 0) {
89
+ this.callback({ data: void 0, error: void 0 });
90
+ } else {
91
+ const consumerEmittedRefresh = () => {
92
+ if (!this.refresh) {
93
+ return Promise.resolve();
94
+ }
95
+ return new Promise((resolve, reject) => {
96
+ if (!this.refresh) {
97
+ resolve();
98
+ return;
99
+ }
100
+ this.refresh().then((res) => {
101
+ if (res.isOk()) {
102
+ resolve();
103
+ } else {
104
+ reject(
105
+ new Error(
106
+ "Internal error in Lightning Data Service adapter occurred: Failed to refresh data"
107
+ )
108
+ );
109
+ }
110
+ });
111
+ });
112
+ };
113
+ let consumerEmittedData = {
114
+ data: void 0,
115
+ error: void 0
116
+ };
117
+ if (this.exposeRefresh && this.refresh) {
118
+ consumerEmittedData.refresh = consumerEmittedRefresh;
119
+ }
120
+ if (result.isErr()) {
121
+ if (isSubscribableResult(result)) {
122
+ consumerEmittedData.error = result.error.failure;
123
+ } else {
124
+ consumerEmittedData.error = result.error;
125
+ }
126
+ } else {
127
+ if (isSubscribableResult(result)) {
128
+ deepFreeze(result.value.data);
129
+ consumerEmittedData.data = result.value.data;
130
+ } else {
131
+ deepFreeze(result.value);
132
+ consumerEmittedData.data = result.value;
133
+ }
134
+ }
135
+ this.callback(consumerEmittedData);
136
+ }
137
+ } catch (e) {
138
+ this.handleExecutionThrow(e);
139
+ }
140
+ }
141
+ invokeAdapter() {
142
+ if (!this.connected || this.config === void 0) {
143
+ return;
144
+ }
145
+ if (this.configSchema) {
146
+ try {
147
+ assertIsValid(this.config, this.configSchema);
148
+ } catch (err) {
149
+ if (isIncompleteConfigError(err)) {
150
+ return;
151
+ }
152
+ throw err;
153
+ }
154
+ }
155
+ const initialConfig = this.config;
156
+ const command = this.getCommand();
157
+ try {
158
+ command.execute().then((result) => {
159
+ if (!this.connected || this.config !== initialConfig) {
160
+ return;
161
+ }
162
+ this.refresh = void 0;
163
+ if (result.isOk()) {
164
+ if (isSubscribableResult(result)) {
165
+ const value = result.value;
166
+ this.unsubscriber = value.subscribe((updatedResult) => {
167
+ if (!this.connected || this.config !== initialConfig) {
168
+ this.unsubscribe();
169
+ return;
170
+ }
171
+ this.emit(updatedResult);
172
+ });
173
+ this.refresh = value.refresh;
174
+ this.emit(ok(value.data));
175
+ } else {
176
+ this.emit(result);
177
+ }
178
+ } else {
179
+ if (isSubscribableResult(result)) {
180
+ const value = result.error;
181
+ this.unsubscriber = value.subscribe((updatedResult) => {
182
+ if (!this.connected || this.config !== initialConfig) {
183
+ this.unsubscribe();
184
+ return;
185
+ }
186
+ this.emit(updatedResult);
187
+ });
188
+ this.refresh = value.refresh;
189
+ this.emit(result);
190
+ } else {
191
+ this.unsubscriber = () => {
192
+ };
193
+ this.emit(result);
194
+ }
195
+ }
196
+ });
197
+ } catch (e) {
198
+ this.handleExecutionThrow(e);
199
+ }
200
+ }
201
+ handleExecutionThrow(error) {
202
+ emitError(this.callback, error);
203
+ }
204
+ unsubscribe() {
205
+ if (this.unsubscriber) {
206
+ this.unsubscriber();
207
+ delete this.unsubscriber;
208
+ }
209
+ }
210
+ }
211
+ function toGraphQLResponseFromFailure(failure) {
212
+ if (isUserVisibleError(failure)) {
213
+ return {
214
+ data: failure.data.data,
215
+ errors: failure.data.errors
216
+ };
217
+ }
218
+ logError(failure);
219
+ return {
220
+ data: void 0,
221
+ errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
222
+ };
223
+ }
224
+ class LWCWireBindingsService {
225
+ bind(getCommand, configSchema, exposeRefresh = false) {
226
+ return class extends CommandWireAdapterConstructor {
227
+ constructor() {
228
+ super(...arguments);
229
+ this.configSchema = configSchema;
230
+ this.exposeRefresh = exposeRefresh;
231
+ }
232
+ getCommand() {
233
+ return getCommand();
234
+ }
235
+ };
236
+ }
237
+ }
238
+ function buildServiceDescriptor$1() {
239
+ return {
240
+ type: "lwcWireBindings",
241
+ version: "1.0",
242
+ service: new LWCWireBindingsService()
243
+ };
244
+ }
245
+ class GraphQLCommandWireAdapterConstructor extends CommandWireAdapterConstructor {
246
+ emit(result) {
247
+ try {
248
+ if (result === void 0) {
249
+ this.callback({ data: void 0, errors: void 0 });
250
+ } else {
251
+ const consumerEmittedRefresh = () => {
252
+ if (!this.refresh) {
253
+ return Promise.resolve();
254
+ }
255
+ return new Promise((resolve, reject) => {
256
+ if (!this.refresh) {
257
+ resolve();
258
+ return;
259
+ }
260
+ this.refresh().then((res) => {
261
+ if (res.isOk()) {
262
+ resolve();
263
+ } else {
264
+ reject(
265
+ new Error(
266
+ "Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
267
+ )
268
+ );
269
+ }
270
+ });
271
+ });
272
+ };
273
+ let consumerEmittedData = {
274
+ data: void 0,
275
+ errors: void 0
276
+ };
277
+ if (this.exposeRefresh && this.refresh) {
278
+ consumerEmittedData.refresh = consumerEmittedRefresh;
279
+ }
280
+ if (result.isErr()) {
281
+ const failure = isSubscribableResult(result) ? result.error.failure : result.error;
282
+ const resp = toGraphQLResponseFromFailure(failure);
283
+ consumerEmittedData.data = resp.data;
284
+ consumerEmittedData.errors = resp.errors;
285
+ } else {
286
+ consumerEmittedData.data = result.value.data;
287
+ }
288
+ deepFreeze(consumerEmittedData);
289
+ this.callback(consumerEmittedData);
290
+ }
291
+ } catch (e) {
292
+ logError(e);
293
+ this.handleExecutionThrow(e);
294
+ }
295
+ }
296
+ handleExecutionThrow(e) {
297
+ logError(e);
298
+ this.callback({
299
+ data: void 0,
300
+ errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
301
+ });
302
+ }
303
+ update(config, _context) {
304
+ this.unsubscribe();
305
+ const resolvedQuery = resolveAst(config.query);
306
+ if (resolvedQuery) {
307
+ validateGraphQLOperations(
308
+ { query: resolvedQuery, operationName: config == null ? void 0 : config.operationName },
309
+ { acceptedOperations: ["query"] }
310
+ );
311
+ }
312
+ this.config = {
313
+ ...sanitize(config),
314
+ query: resolvedQuery
315
+ };
316
+ this.invokeAdapter();
317
+ }
318
+ }
319
+ class LWCGraphQLWireBindingsService {
320
+ bind(getCommand, configSchema, exposeRefresh = false) {
321
+ return class extends GraphQLCommandWireAdapterConstructor {
322
+ constructor() {
323
+ super(...arguments);
324
+ this.configSchema = configSchema;
325
+ this.exposeRefresh = exposeRefresh;
326
+ }
327
+ getCommand() {
328
+ return getCommand();
329
+ }
330
+ };
331
+ }
332
+ }
333
+ function buildServiceDescriptor() {
334
+ return {
335
+ type: "lwcGraphQLWireBindings",
336
+ version: "1.0",
337
+ service: new LWCGraphQLWireBindingsService()
338
+ };
339
+ }
340
+ export {
341
+ buildServiceDescriptor as buildLWCGraphQLWireBindingsServiceDescriptor,
342
+ buildServiceDescriptor$1 as buildLWCWireBindingsServiceDescriptor
343
+ };
344
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/v1/sanitize.ts","../../src/v1/utils.ts","../../src/v1/wire.ts","../../src/v1/graphql-wire.ts"],"sourcesContent":["interface CurrentPath {\n key: string;\n value: object;\n parent: CurrentPath | null;\n data: any;\n}\n\nclass Sanitizer<T extends object> {\n obj: T;\n copy: T;\n currentPath: CurrentPath;\n\n constructor(obj: T) {\n this.obj = obj;\n this.copy = {} as T;\n\n this.currentPath = {\n key: '',\n value: obj,\n parent: null,\n data: this.copy,\n };\n }\n\n sanitize(): T {\n const sanitizer = this;\n\n JSON.stringify(this.obj, function (key, value) {\n if (key === '') {\n return value;\n }\n\n const parent = this;\n if (parent !== sanitizer.currentPath.value) {\n sanitizer.exit(parent);\n }\n if (typeof value === 'object' && value !== null) {\n sanitizer.enter(key, value);\n return value;\n }\n sanitizer.currentPath.data[key] = value;\n\n return value;\n });\n\n return this.copy;\n }\n\n private enter(key: string, value: any) {\n const { currentPath: parentPath } = this;\n const data = (parentPath.data[key] = Array.isArray(value) ? [] : {});\n this.currentPath = {\n key,\n value,\n parent: parentPath,\n data,\n };\n }\n\n private exit(parent: any) {\n while (this.currentPath.value !== parent) {\n this.currentPath = this.currentPath.parent || this.currentPath;\n }\n }\n}\n\n/**\n * Returns a sanitized version of an object by recursively unwrapping the Proxies.\n *\n * All the data coming from LWC-land need to be sanitized first.\n */\nexport default function sanitize<T extends object>(obj: T): T {\n return new Sanitizer(obj).sanitize();\n}\n","import {\n SubscribableResultCommand,\n ResultCommand,\n MaybeSubscribableResultCommand,\n emitError,\n} from '@conduit-client/bindings-utils/v1';\nimport {\n assertIsValid,\n MissingRequiredPropertyError,\n type JSONSchema,\n JsonSchemaViolationError,\n} from '@conduit-client/jsonschema-validate';\nimport {\n type WireAdapter,\n type WireConfigValue,\n type WireContextValue,\n type WireDataCallback,\n} from '@conduit-client/lwc-types';\n\nimport {\n type SyncOrAsync,\n type Unsubscribe,\n type SubscribableResult,\n type CommandError,\n deepFreeze,\n type Result,\n ok,\n isSubscribableResult,\n logError,\n isUserVisibleError,\n} from '@conduit-client/utils';\nimport { type GraphQLResponse } from '@conduit-client/graphql-normalization/v1';\nimport sanitize from './sanitize';\n\nexport type WireAdapterCompatibleCommand<Data, Error> =\n | SubscribableResultCommand<Data, Error>\n | ResultCommand<Data, Error>\n | MaybeSubscribableResultCommand<Data, Error>;\n\nexport function isIncompleteConfigError(err: unknown): boolean {\n return (\n err instanceof MissingRequiredPropertyError ||\n (err instanceof JsonSchemaViolationError &&\n err.validationErrors.find(\n (validationError) => validationError instanceof MissingRequiredPropertyError\n ) !== undefined)\n );\n}\n\nexport type GetCommand<\n Data,\n CommandType extends WireAdapterCompatibleCommand<\n Data,\n CommandError\n > = WireAdapterCompatibleCommand<Data, CommandError>,\n> = () => CommandType;\n\n/**\n * Binds a Command to a LWC wire adapter.\n * @see https://lwc.dev/guide/wire_adapter\n */\nexport abstract class CommandWireAdapterConstructor<\n Data,\n Config extends WireConfigValue = WireConfigValue,\n CommandType extends WireAdapterCompatibleCommand<\n Data,\n CommandError\n > = WireAdapterCompatibleCommand<Data, CommandError>,\n> implements WireAdapter\n{\n connected = false;\n config?: Config;\n unsubscriber?: Unsubscribe;\n exposeRefresh = false;\n\n abstract configSchema?: JSONSchema;\n abstract getCommand(): CommandType;\n protected refresh?: () => SyncOrAsync<Result<void, unknown>>;\n\n constructor(\n protected callback: WireDataCallback,\n sourceContext?: {\n tagName?: string;\n },\n options?: {\n skipEmptyEmit?: true;\n }\n ) {\n if (!options?.skipEmptyEmit) {\n this.emit();\n }\n }\n\n connect(): void {\n this.connected = true;\n this.invokeAdapter();\n }\n\n disconnect(): void {\n this.unsubscribe();\n this.connected = false;\n }\n\n update(config: Config, _context?: WireContextValue): void {\n this.unsubscribe();\n this.config = sanitize<Config>(config);\n this.invokeAdapter();\n }\n\n protected emit(result?: Result<Data, unknown> | SubscribableResult<Data, unknown>) {\n try {\n if (result === undefined) {\n this.callback({ data: undefined, error: undefined });\n } else {\n const consumerEmittedRefresh = (): Promise<void> => {\n if (!this.refresh) {\n return Promise.resolve();\n }\n return new Promise((resolve, reject) => {\n if (!this.refresh) {\n resolve();\n return;\n }\n this.refresh().then((res) => {\n if (res.isOk()) {\n resolve();\n } else {\n reject(\n new Error(\n 'Internal error in Lightning Data Service adapter occurred: Failed to refresh data'\n )\n );\n }\n });\n });\n };\n\n let consumerEmittedData = {\n data: undefined,\n error: undefined,\n } as {\n data: Data | undefined;\n error: unknown | undefined;\n refresh?: () => Promise<void>;\n };\n\n if (this.exposeRefresh && this.refresh) {\n consumerEmittedData.refresh = consumerEmittedRefresh;\n }\n\n if (result.isErr()) {\n if (isSubscribableResult(result)) {\n consumerEmittedData.error = result.error.failure;\n } else {\n consumerEmittedData.error = result.error;\n }\n } else {\n if (isSubscribableResult(result)) {\n deepFreeze(result.value.data);\n consumerEmittedData.data = result.value.data;\n } else {\n deepFreeze(result.value);\n consumerEmittedData.data = result.value;\n }\n }\n\n this.callback(consumerEmittedData);\n }\n } catch (e) {\n this.handleExecutionThrow(e);\n }\n }\n\n protected invokeAdapter() {\n if (!this.connected || this.config === undefined) {\n return;\n }\n\n if (this.configSchema) {\n try {\n assertIsValid<unknown>(this.config, this.configSchema);\n } catch (err) {\n if (isIncompleteConfigError(err)) {\n // config is incomplete, wait for updated config\n return;\n }\n\n throw err;\n }\n }\n\n const initialConfig = this.config;\n const command = this.getCommand();\n\n try {\n command.execute().then((result) => {\n // config changed or component disconnected before result came back, ignore result\n if (!this.connected || this.config !== initialConfig) {\n return;\n }\n\n this.refresh = undefined;\n\n if (result.isOk()) {\n if (isSubscribableResult<Data, unknown>(result)) {\n const value = result.value;\n this.unsubscriber = value.subscribe((updatedResult) => {\n if (!this.connected || this.config !== initialConfig) {\n this.unsubscribe();\n return;\n }\n\n this.emit(updatedResult);\n });\n this.refresh = value.refresh;\n this.emit(ok(value.data));\n } else {\n this.emit(result);\n }\n } else {\n if (isSubscribableResult(result)) {\n const value = result.error;\n this.unsubscriber = value.subscribe((updatedResult) => {\n if (!this.connected || this.config !== initialConfig) {\n this.unsubscribe();\n return;\n }\n\n this.emit(updatedResult);\n });\n this.refresh = value.refresh;\n this.emit(result);\n } else {\n this.unsubscriber = () => {};\n this.emit(result);\n }\n }\n });\n } catch (e: unknown) {\n this.handleExecutionThrow(e);\n }\n }\n\n protected handleExecutionThrow(error: unknown) {\n emitError(this.callback, error);\n }\n\n protected unsubscribe() {\n if (this.unsubscriber) {\n this.unsubscriber();\n delete this.unsubscriber;\n }\n }\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 { type JSONSchema } from '@conduit-client/jsonschema-validate';\nimport { type WireAdapterConstructor, type WireConfigValue } from '@conduit-client/lwc-types';\nimport { CommandWireAdapterConstructor, type GetCommand } from './utils';\n\nexport class LWCWireBindingsService {\n bind<Data, Config extends WireConfigValue = WireConfigValue>(\n getCommand: GetCommand<Data>,\n configSchema?: JSONSchema,\n exposeRefresh = false\n ): WireAdapterConstructor<Config, Data, {}> {\n return class extends CommandWireAdapterConstructor<Data, Config> {\n configSchema = configSchema;\n exposeRefresh = exposeRefresh;\n getCommand() {\n return getCommand();\n }\n };\n }\n}\n\nexport interface LWCWireBindingsServiceDescriptor {\n type: 'lwcWireBindings';\n version: string;\n service: LWCWireBindingsService;\n}\n\nexport function buildServiceDescriptor(): LWCWireBindingsServiceDescriptor {\n return {\n type: 'lwcWireBindings',\n version: '1.0',\n service: new LWCWireBindingsService(),\n };\n}\n","import {\n Result,\n SubscribableResult,\n deepFreeze,\n isSubscribableResult,\n logError,\n} from '@conduit-client/utils';\nimport {\n type GraphQLCommandError,\n type GraphQLResponse,\n type GraphQLCommand,\n} from '@conduit-client/graphql-normalization/v1';\nimport { resolveAst, validateGraphQLOperations } from '@conduit-client/onestore-graphql-parser/v1';\nimport { type JSONSchema } from '@conduit-client/jsonschema-validate';\nimport {\n type WireAdapterConstructor,\n type WireConfigValue,\n type WireContextValue,\n} from '@conduit-client/lwc-types';\nimport {\n CommandWireAdapterConstructor,\n type GetCommand,\n toGraphQLResponseFromFailure,\n} from './utils';\nimport sanitize from './sanitize';\n\nexport abstract class GraphQLCommandWireAdapterConstructor<\n Config extends WireConfigValue = WireConfigValue,\n> extends CommandWireAdapterConstructor<GraphQLResponse, Config, GraphQLCommand> {\n protected emit(\n result?:\n | SubscribableResult<GraphQLResponse, GraphQLCommandError>\n | Result<GraphQLResponse, GraphQLCommandError>\n | undefined\n ): void {\n try {\n if (result === undefined) {\n this.callback({ data: undefined, errors: undefined });\n } else {\n const consumerEmittedRefresh = (): Promise<void> => {\n if (!this.refresh) {\n return Promise.resolve();\n }\n return new Promise((resolve, reject) => {\n if (!this.refresh) {\n resolve();\n return;\n }\n this.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 });\n };\n\n let consumerEmittedData = {\n data: undefined,\n errors: undefined,\n } as {\n data: GraphQLResponse | undefined;\n errors: unknown | undefined;\n refresh?: () => Promise<void>;\n };\n\n if (this.exposeRefresh && this.refresh) {\n consumerEmittedData.refresh = consumerEmittedRefresh;\n }\n\n if (result.isErr()) {\n const failure = isSubscribableResult(result)\n ? result.error.failure\n : result.error;\n const resp = toGraphQLResponseFromFailure(failure);\n consumerEmittedData.data = resp.data;\n consumerEmittedData.errors = resp.errors;\n } else {\n consumerEmittedData.data = result.value.data;\n }\n\n deepFreeze(consumerEmittedData);\n this.callback(consumerEmittedData);\n }\n } catch (e) {\n logError(e);\n this.handleExecutionThrow(e);\n }\n }\n\n protected handleExecutionThrow(e: unknown): void {\n logError(e);\n this.callback({\n data: undefined,\n errors: [{ message: 'Internal error in GraphQL adapter occurred', locations: [] }],\n } satisfies GraphQLResponse);\n }\n\n update(config: Config, _context?: WireContextValue): void {\n this.unsubscribe();\n\n const resolvedQuery = resolveAst(config.query);\n if (resolvedQuery) {\n // Validate the resolved query for operation types, considering operationName\n validateGraphQLOperations(\n { query: resolvedQuery, operationName: (config as any)?.operationName },\n { acceptedOperations: ['query'] }\n );\n }\n\n this.config = {\n ...sanitize<Config>(config),\n query: resolvedQuery,\n };\n this.invokeAdapter();\n }\n}\n\nexport class LWCGraphQLWireBindingsService {\n bind<Config extends WireConfigValue = WireConfigValue>(\n getCommand: GetCommand<GraphQLResponse, GraphQLCommand>,\n configSchema?: JSONSchema,\n exposeRefresh = false\n ): WireAdapterConstructor<Config, GraphQLResponse, {}> {\n return class extends GraphQLCommandWireAdapterConstructor<Config> {\n configSchema = configSchema;\n exposeRefresh = exposeRefresh;\n getCommand() {\n return getCommand();\n }\n };\n }\n}\n\nexport interface LWCGraphQLWireBindingsServiceDescriptor {\n type: 'lwcGraphQLWireBindings';\n version: string;\n service: LWCGraphQLWireBindingsService;\n}\n\nexport function buildServiceDescriptor(): LWCGraphQLWireBindingsServiceDescriptor {\n return {\n type: 'lwcGraphQLWireBindings',\n version: '1.0',\n service: new LWCGraphQLWireBindingsService(),\n };\n}\n"],"names":["buildServiceDescriptor"],"mappings":";;;;;;;;;AAOA,MAAM,UAA4B;AAAA,EAK9B,YAAY,KAAQ;AAChB,SAAK,MAAM;AACX,SAAK,OAAO,CAAA;AAEZ,SAAK,cAAc;AAAA,MACf,KAAK;AAAA,MACL,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,MAAM,KAAK;AAAA,IAAA;AAAA,EAEnB;AAAA,EAEA,WAAc;AACV,UAAM,YAAY;AAElB,SAAK,UAAU,KAAK,KAAK,SAAU,KAAK,OAAO;AAC3C,UAAI,QAAQ,IAAI;AACZ,eAAO;AAAA,MACX;AAEA,YAAM,SAAS;AACf,UAAI,WAAW,UAAU,YAAY,OAAO;AACxC,kBAAU,KAAK,MAAM;AAAA,MACzB;AACA,UAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC7C,kBAAU,MAAM,KAAK,KAAK;AAC1B,eAAO;AAAA,MACX;AACA,gBAAU,YAAY,KAAK,GAAG,IAAI;AAElC,aAAO;AAAA,IACX,CAAC;AAED,WAAO,KAAK;AAAA,EAChB;AAAA,EAEQ,MAAM,KAAa,OAAY;AACnC,UAAM,EAAE,aAAa,WAAA,IAAe;AACpC,UAAM,OAAQ,WAAW,KAAK,GAAG,IAAI,MAAM,QAAQ,KAAK,IAAI,CAAA,IAAK,CAAA;AACjE,SAAK,cAAc;AAAA,MACf;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,IAAA;AAAA,EAER;AAAA,EAEQ,KAAK,QAAa;AACtB,WAAO,KAAK,YAAY,UAAU,QAAQ;AACtC,WAAK,cAAc,KAAK,YAAY,UAAU,KAAK;AAAA,IACvD;AAAA,EACJ;AACJ;AAOA,SAAwB,SAA2B,KAAW;AAC1D,SAAO,IAAI,UAAU,GAAG,EAAE,SAAA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,IACJ,SAAS,GAAG;AACR,eAAS,CAAC;AACV,WAAK,qBAAqB,CAAC;AAAA,IAC/B;AAAA,EACJ;AAAA,EAEU,qBAAqB,GAAkB;AAC7C,aAAS,CAAC;AACV,SAAK,SAAS;AAAA,MACV,MAAM;AAAA,MACN,QAAQ,CAAC,EAAE,SAAS,8CAA8C,WAAW,CAAA,GAAI;AAAA,IAAA,CAC1D;AAAA,EAC/B;AAAA,EAEA,OAAO,QAAgB,UAAmC;AACtD,SAAK,YAAA;AAEL,UAAM,gBAAgB,WAAW,OAAO,KAAK;AAC7C,QAAI,eAAe;AAEf;AAAA,QACI,EAAE,OAAO,eAAe,eAAgB,iCAAgB,cAAA;AAAA,QACxD,EAAE,oBAAoB,CAAC,OAAO,EAAA;AAAA,MAAE;AAAA,IAExC;AAEA,SAAK,SAAS;AAAA,MACV,GAAG,SAAiB,MAAM;AAAA,MAC1B,OAAO;AAAA,IAAA;AAEX,SAAK,cAAA;AAAA,EACT;AACJ;AAEO,MAAM,8BAA8B;AAAA,EACvC,KACI,YACA,cACA,gBAAgB,OACmC;AACnD,WAAO,cAAc,qCAA6C;AAAA,MAA3D,cAAA;AAAA,cAAA,GAAA,SAAA;AACH,aAAA,eAAe;AACf,aAAA,gBAAgB;AAAA,MAAA;AAAA,MAChB,aAAa;AACT,eAAO,WAAA;AAAA,MACX;AAAA,IAAA;AAAA,EAER;AACJ;AAQO,SAAS,yBAAkE;AAC9E,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,IAAI,8BAAA;AAAA,EAA8B;AAEnD;"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@conduit-client/service-bindings-lwc",
3
+ "version": "2.1.0",
4
+ "private": false,
5
+ "description": "Conduit services for LWC 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-lwc"
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/jsonschema-validate": "2.1.0",
36
+ "@conduit-client/onestore-graphql-parser": "2.1.0",
37
+ "@conduit-client/utils": "2.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "@conduit-client/graphql-normalization": "2.1.0",
41
+ "@conduit-client/lwc-types": "2.1.0"
42
+ },
43
+ "volta": {
44
+ "extends": "../../../../package.json"
45
+ },
46
+ "size-limit": [
47
+ {
48
+ "path": "./dist/v1/index.js",
49
+ "limit": "1.9 kB"
50
+ }
51
+ ]
52
+ }