@luvio/lwc-luvio 0.98.0 → 0.99.2
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/dist/es/es2018/LWCGraphQLLuvioWireAdapter.d.ts +48 -0
- package/dist/es/es2018/LWCLuvioWireAdapter.d.ts +3 -2
- package/dist/es/es2018/lwcluvio.js +105 -4
- package/dist/es/es2018/main.d.ts +4 -1
- package/dist/es/es2018/utils/SnapshotState.d.ts +1 -1
- package/dist/es/es2018/utils/constants.d.ts +1 -0
- package/dist/umd/es2018/LWCGraphQLLuvioWireAdapter.d.ts +48 -0
- package/dist/umd/es2018/LWCLuvioWireAdapter.d.ts +3 -2
- package/dist/umd/es2018/lwcluvio.js +105 -3
- package/dist/umd/es2018/main.d.ts +4 -1
- package/dist/umd/es2018/utils/SnapshotState.d.ts +1 -1
- package/dist/umd/es2018/utils/constants.d.ts +1 -0
- package/dist/umd/es5/LWCGraphQLLuvioWireAdapter.d.ts +48 -0
- package/dist/umd/es5/LWCLuvioWireAdapter.d.ts +3 -2
- package/dist/umd/es5/lwcluvio.js +116 -4
- package/dist/umd/es5/main.d.ts +4 -1
- package/dist/umd/es5/utils/SnapshotState.d.ts +1 -1
- package/dist/umd/es5/utils/constants.d.ts +1 -0
- package/package.json +31 -26
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
+
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { AstResolver } from '@luvio/graphql-parser';
|
|
4
|
+
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
5
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
6
|
+
export declare type GraphQLError = {
|
|
7
|
+
message: string;
|
|
8
|
+
locations?: Array<{
|
|
9
|
+
line: number;
|
|
10
|
+
column: number;
|
|
11
|
+
}>;
|
|
12
|
+
path?: Array<string | number>;
|
|
13
|
+
extensions?: Record<string, any>;
|
|
14
|
+
};
|
|
15
|
+
export declare type GraphQLUserInput = {
|
|
16
|
+
query: object;
|
|
17
|
+
variables?: Record<string, string | number | boolean>;
|
|
18
|
+
operationName?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare type GraphQLResponse = {
|
|
21
|
+
data: any;
|
|
22
|
+
errors?: GraphQLError[];
|
|
23
|
+
} | {
|
|
24
|
+
errors: GraphQLError[];
|
|
25
|
+
};
|
|
26
|
+
export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
27
|
+
astResolver: AstResolver;
|
|
28
|
+
constructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver, callback: DataCallback);
|
|
29
|
+
update(config: WireConfigValue, _context?: WireContextValue): void;
|
|
30
|
+
/**
|
|
31
|
+
* Emits new values to the callback.
|
|
32
|
+
*
|
|
33
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
34
|
+
*/
|
|
35
|
+
protected emit(snapshot?: EmittableSnapshot<GraphQLResponse>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
38
|
+
*/
|
|
39
|
+
protected callAdapter(): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
43
|
+
*
|
|
44
|
+
* @param adapter Adapter
|
|
45
|
+
* @param name name to assign to the generated constructor
|
|
46
|
+
* @param luvio Luvio
|
|
47
|
+
*/
|
|
48
|
+
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver): WireAdapterConstructor;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Adapter, Luvio, Unsubscribe } from '@luvio/engine';
|
|
2
2
|
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
3
4
|
export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
4
5
|
adapter: Adapter<unknown, unknown>;
|
|
5
6
|
name: string;
|
|
@@ -32,14 +33,14 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
32
33
|
/**
|
|
33
34
|
* Calls the adapter if config has been set and the component is connected.
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
+
protected callAdapter(): void;
|
|
36
37
|
protected processAdapterResponse(snapshotOrPromise: ReturnType<Adapter<unknown, unknown>>): void;
|
|
37
38
|
/**
|
|
38
39
|
* Emits new values to the callback.
|
|
39
40
|
*
|
|
40
41
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
protected emit(snapshot?: EmittableSnapshot): void;
|
|
43
44
|
/**
|
|
44
45
|
* Subscribes this wire adapter to future changes to the specified snapshot. Any changes
|
|
45
46
|
* to the snapshot will be automatically emitted to the component.
|
|
@@ -4,7 +4,8 @@ import { unwrap } from 'lwc';
|
|
|
4
4
|
const REFRESH_ADAPTER_EVENT = 'refresh-adapter-event';
|
|
5
5
|
const ADAPTER_UNFULFILLED_ERROR = 'adapter-unfulfilled-error';
|
|
6
6
|
const USERLAND_PROVISION_ERROR_MESSAGE = "LWC component's @wire target property or method threw an error during value provisioning. Original error:";
|
|
7
|
-
const ADAPTER_SNAPSHOT_REJECTED_MESSAGE = 'Luvio wire adapter Promise<Snapshot> rejected. Original error:';
|
|
7
|
+
const ADAPTER_SNAPSHOT_REJECTED_MESSAGE = 'Luvio wire adapter Promise<Snapshot> rejected. Original error:';
|
|
8
|
+
const USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE = 'Use `gql` parser to parse your "query" string';
|
|
8
9
|
|
|
9
10
|
// map of emitted object -> [ adapter name, snapshot ]; snapshot is only undefined for the
|
|
10
11
|
// initially-emitted { data: undefined, error: undefined } value
|
|
@@ -35,7 +36,7 @@ function isUnfulfilledSnapshot(snapshot) {
|
|
|
35
36
|
*
|
|
36
37
|
* @param snapshot Snapshot
|
|
37
38
|
*/
|
|
38
|
-
function snapshotToPayload(snapshot) {
|
|
39
|
+
function snapshotToPayload$1(snapshot) {
|
|
39
40
|
if (snapshot === undefined) {
|
|
40
41
|
return {
|
|
41
42
|
data: undefined,
|
|
@@ -291,7 +292,7 @@ class LWCLuvioWireAdapter {
|
|
|
291
292
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
292
293
|
*/
|
|
293
294
|
emit(snapshot) {
|
|
294
|
-
const payload = snapshotToPayload(snapshot);
|
|
295
|
+
const payload = snapshotToPayload$1(snapshot);
|
|
295
296
|
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
296
297
|
try {
|
|
297
298
|
this.callback(payload);
|
|
@@ -405,4 +406,104 @@ function createInfiniteScrollingWireAdapterConstructor(adapter, name, luvio) {
|
|
|
405
406
|
return constructor;
|
|
406
407
|
}
|
|
407
408
|
|
|
408
|
-
|
|
409
|
+
function snapshotToPayload(snapshot) {
|
|
410
|
+
if (snapshot === undefined) {
|
|
411
|
+
return {
|
|
412
|
+
data: undefined,
|
|
413
|
+
errors: undefined,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
if (isErrorSnapshot(snapshot)) {
|
|
417
|
+
return {
|
|
418
|
+
data: undefined,
|
|
419
|
+
errors: [snapshot.error],
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
// fulfilled or stale
|
|
423
|
+
const payload = {};
|
|
424
|
+
if ('data' in snapshot.data && snapshot.data.data !== undefined) {
|
|
425
|
+
payload.data = snapshot.data.data;
|
|
426
|
+
}
|
|
427
|
+
if (snapshot.data.errors !== undefined) {
|
|
428
|
+
payload.errors = snapshot.data.errors;
|
|
429
|
+
}
|
|
430
|
+
return payload;
|
|
431
|
+
}
|
|
432
|
+
class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
433
|
+
constructor(adapter, name, luvio, astResolver, callback) {
|
|
434
|
+
super(adapter, name, luvio, callback);
|
|
435
|
+
this.astResolver = astResolver;
|
|
436
|
+
}
|
|
437
|
+
update(config, _context) {
|
|
438
|
+
this.unsubscribe();
|
|
439
|
+
// graphql query AST is passed by reference
|
|
440
|
+
// sanitizing it makes a copy and we lose that reference
|
|
441
|
+
this.config = {
|
|
442
|
+
...sanitize(config),
|
|
443
|
+
query: config.query,
|
|
444
|
+
};
|
|
445
|
+
this.callAdapter();
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Emits new values to the callback.
|
|
449
|
+
*
|
|
450
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
451
|
+
*/
|
|
452
|
+
emit(snapshot) {
|
|
453
|
+
const payload = snapshotToPayload(snapshot);
|
|
454
|
+
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
455
|
+
try {
|
|
456
|
+
this.callback(payload);
|
|
457
|
+
}
|
|
458
|
+
catch (error) {
|
|
459
|
+
if (error instanceof Error) {
|
|
460
|
+
throwAnnotatedError(error, USERLAND_PROVISION_ERROR_MESSAGE);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
466
|
+
*/
|
|
467
|
+
callAdapter() {
|
|
468
|
+
if (!this.connected || this.config === undefined) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
const query = this.config.query;
|
|
472
|
+
// gql returns null for invalid queries
|
|
473
|
+
if (query === null) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
const ast = this.astResolver(query);
|
|
477
|
+
if (ast === undefined) {
|
|
478
|
+
// this should only happen if the user didn't parse the query
|
|
479
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
480
|
+
throw new Error(USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE);
|
|
481
|
+
}
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const snapshotOrPromise = this.adapter({
|
|
485
|
+
...this.config,
|
|
486
|
+
query: ast,
|
|
487
|
+
});
|
|
488
|
+
this.processAdapterResponse(snapshotOrPromise);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
493
|
+
*
|
|
494
|
+
* @param adapter Adapter
|
|
495
|
+
* @param name name to assign to the generated constructor
|
|
496
|
+
* @param luvio Luvio
|
|
497
|
+
*/
|
|
498
|
+
function createGraphQLWireAdapterConstructor(adapter, name, luvio, astResolver) {
|
|
499
|
+
const constructor = function (callback) {
|
|
500
|
+
const delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback);
|
|
501
|
+
this.connect = () => delegate.connect();
|
|
502
|
+
this.disconnect = () => delegate.disconnect();
|
|
503
|
+
this.update = (config, context) => delegate.update(config, context);
|
|
504
|
+
};
|
|
505
|
+
Object.defineProperty(constructor, 'name', { value: name });
|
|
506
|
+
return constructor;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export { ADAPTER_UNFULFILLED_ERROR, REFRESH_ADAPTER_EVENT, bindWireRefresh, createGraphQLWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createWireAdapterConstructor, refreshData };
|
package/dist/es/es2018/main.d.ts
CHANGED
|
@@ -2,4 +2,7 @@ import { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR } from './utils/consta
|
|
|
2
2
|
import { bindWireRefresh, refreshData } from './LWCLuvioBindings';
|
|
3
3
|
import { createWireAdapterConstructor } from './LWCLuvioWireAdapter';
|
|
4
4
|
import { createInfiniteScrollingWireAdapterConstructor } from './LWCInfiniteScrollingLuvioWireAdapter';
|
|
5
|
-
|
|
5
|
+
import { createGraphQLWireAdapterConstructor } from './LWCGraphQLLuvioWireAdapter';
|
|
6
|
+
import type { GraphQLError, GraphQLResponse } from './LWCGraphQLLuvioWireAdapter';
|
|
7
|
+
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, bindWireRefresh, refreshData, REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, };
|
|
8
|
+
export type { GraphQLError, GraphQLResponse };
|
|
@@ -3,7 +3,7 @@ export declare function isErrorSnapshot(snapshot: Snapshot<unknown, unknown>): s
|
|
|
3
3
|
export declare function isFulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is FulfilledSnapshot<unknown, unknown>;
|
|
4
4
|
export declare function isStaleSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is StaleSnapshot<unknown, unknown>;
|
|
5
5
|
export declare function isUnfulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is UnfulfilledSnapshot<unknown, unknown>;
|
|
6
|
-
export declare type EmittableSnapshot = FulfilledSnapshot<
|
|
6
|
+
export declare type EmittableSnapshot<T = unknown> = FulfilledSnapshot<T> | StaleSnapshot<T> | ErrorSnapshot;
|
|
7
7
|
/**
|
|
8
8
|
* Transform a Snapshot into a payload suitable for passing to a DataCallback.
|
|
9
9
|
*
|
|
@@ -2,3 +2,4 @@ export declare const REFRESH_ADAPTER_EVENT = "refresh-adapter-event";
|
|
|
2
2
|
export declare const ADAPTER_UNFULFILLED_ERROR = "adapter-unfulfilled-error";
|
|
3
3
|
export declare const USERLAND_PROVISION_ERROR_MESSAGE = "LWC component's @wire target property or method threw an error during value provisioning. Original error:";
|
|
4
4
|
export declare const ADAPTER_SNAPSHOT_REJECTED_MESSAGE = "Luvio wire adapter Promise<Snapshot> rejected. Original error:";
|
|
5
|
+
export declare const USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE = "Use `gql` parser to parse your \"query\" string";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
+
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { AstResolver } from '@luvio/graphql-parser';
|
|
4
|
+
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
5
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
6
|
+
export declare type GraphQLError = {
|
|
7
|
+
message: string;
|
|
8
|
+
locations?: Array<{
|
|
9
|
+
line: number;
|
|
10
|
+
column: number;
|
|
11
|
+
}>;
|
|
12
|
+
path?: Array<string | number>;
|
|
13
|
+
extensions?: Record<string, any>;
|
|
14
|
+
};
|
|
15
|
+
export declare type GraphQLUserInput = {
|
|
16
|
+
query: object;
|
|
17
|
+
variables?: Record<string, string | number | boolean>;
|
|
18
|
+
operationName?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare type GraphQLResponse = {
|
|
21
|
+
data: any;
|
|
22
|
+
errors?: GraphQLError[];
|
|
23
|
+
} | {
|
|
24
|
+
errors: GraphQLError[];
|
|
25
|
+
};
|
|
26
|
+
export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
27
|
+
astResolver: AstResolver;
|
|
28
|
+
constructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver, callback: DataCallback);
|
|
29
|
+
update(config: WireConfigValue, _context?: WireContextValue): void;
|
|
30
|
+
/**
|
|
31
|
+
* Emits new values to the callback.
|
|
32
|
+
*
|
|
33
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
34
|
+
*/
|
|
35
|
+
protected emit(snapshot?: EmittableSnapshot<GraphQLResponse>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
38
|
+
*/
|
|
39
|
+
protected callAdapter(): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
43
|
+
*
|
|
44
|
+
* @param adapter Adapter
|
|
45
|
+
* @param name name to assign to the generated constructor
|
|
46
|
+
* @param luvio Luvio
|
|
47
|
+
*/
|
|
48
|
+
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver): WireAdapterConstructor;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Adapter, Luvio, Unsubscribe } from '@luvio/engine';
|
|
2
2
|
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
3
4
|
export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
4
5
|
adapter: Adapter<unknown, unknown>;
|
|
5
6
|
name: string;
|
|
@@ -32,14 +33,14 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
32
33
|
/**
|
|
33
34
|
* Calls the adapter if config has been set and the component is connected.
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
+
protected callAdapter(): void;
|
|
36
37
|
protected processAdapterResponse(snapshotOrPromise: ReturnType<Adapter<unknown, unknown>>): void;
|
|
37
38
|
/**
|
|
38
39
|
* Emits new values to the callback.
|
|
39
40
|
*
|
|
40
41
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
protected emit(snapshot?: EmittableSnapshot): void;
|
|
43
44
|
/**
|
|
44
45
|
* Subscribes this wire adapter to future changes to the specified snapshot. Any changes
|
|
45
46
|
* to the snapshot will be automatically emitted to the component.
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
const REFRESH_ADAPTER_EVENT = 'refresh-adapter-event';
|
|
9
9
|
const ADAPTER_UNFULFILLED_ERROR = 'adapter-unfulfilled-error';
|
|
10
10
|
const USERLAND_PROVISION_ERROR_MESSAGE = "LWC component's @wire target property or method threw an error during value provisioning. Original error:";
|
|
11
|
-
const ADAPTER_SNAPSHOT_REJECTED_MESSAGE = 'Luvio wire adapter Promise<Snapshot> rejected. Original error:';
|
|
11
|
+
const ADAPTER_SNAPSHOT_REJECTED_MESSAGE = 'Luvio wire adapter Promise<Snapshot> rejected. Original error:';
|
|
12
|
+
const USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE = 'Use `gql` parser to parse your "query" string';
|
|
12
13
|
|
|
13
14
|
// map of emitted object -> [ adapter name, snapshot ]; snapshot is only undefined for the
|
|
14
15
|
// initially-emitted { data: undefined, error: undefined } value
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
*
|
|
40
41
|
* @param snapshot Snapshot
|
|
41
42
|
*/
|
|
42
|
-
function snapshotToPayload(snapshot) {
|
|
43
|
+
function snapshotToPayload$1(snapshot) {
|
|
43
44
|
if (snapshot === undefined) {
|
|
44
45
|
return {
|
|
45
46
|
data: undefined,
|
|
@@ -295,7 +296,7 @@
|
|
|
295
296
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
296
297
|
*/
|
|
297
298
|
emit(snapshot) {
|
|
298
|
-
const payload = snapshotToPayload(snapshot);
|
|
299
|
+
const payload = snapshotToPayload$1(snapshot);
|
|
299
300
|
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
300
301
|
try {
|
|
301
302
|
this.callback(payload);
|
|
@@ -409,9 +410,110 @@
|
|
|
409
410
|
return constructor;
|
|
410
411
|
}
|
|
411
412
|
|
|
413
|
+
function snapshotToPayload(snapshot) {
|
|
414
|
+
if (snapshot === undefined) {
|
|
415
|
+
return {
|
|
416
|
+
data: undefined,
|
|
417
|
+
errors: undefined,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
if (isErrorSnapshot(snapshot)) {
|
|
421
|
+
return {
|
|
422
|
+
data: undefined,
|
|
423
|
+
errors: [snapshot.error],
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
// fulfilled or stale
|
|
427
|
+
const payload = {};
|
|
428
|
+
if ('data' in snapshot.data && snapshot.data.data !== undefined) {
|
|
429
|
+
payload.data = snapshot.data.data;
|
|
430
|
+
}
|
|
431
|
+
if (snapshot.data.errors !== undefined) {
|
|
432
|
+
payload.errors = snapshot.data.errors;
|
|
433
|
+
}
|
|
434
|
+
return payload;
|
|
435
|
+
}
|
|
436
|
+
class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
437
|
+
constructor(adapter, name, luvio, astResolver, callback) {
|
|
438
|
+
super(adapter, name, luvio, callback);
|
|
439
|
+
this.astResolver = astResolver;
|
|
440
|
+
}
|
|
441
|
+
update(config, _context) {
|
|
442
|
+
this.unsubscribe();
|
|
443
|
+
// graphql query AST is passed by reference
|
|
444
|
+
// sanitizing it makes a copy and we lose that reference
|
|
445
|
+
this.config = {
|
|
446
|
+
...sanitize(config),
|
|
447
|
+
query: config.query,
|
|
448
|
+
};
|
|
449
|
+
this.callAdapter();
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Emits new values to the callback.
|
|
453
|
+
*
|
|
454
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
455
|
+
*/
|
|
456
|
+
emit(snapshot) {
|
|
457
|
+
const payload = snapshotToPayload(snapshot);
|
|
458
|
+
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
459
|
+
try {
|
|
460
|
+
this.callback(payload);
|
|
461
|
+
}
|
|
462
|
+
catch (error) {
|
|
463
|
+
if (error instanceof Error) {
|
|
464
|
+
throwAnnotatedError(error, USERLAND_PROVISION_ERROR_MESSAGE);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
470
|
+
*/
|
|
471
|
+
callAdapter() {
|
|
472
|
+
if (!this.connected || this.config === undefined) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
const query = this.config.query;
|
|
476
|
+
// gql returns null for invalid queries
|
|
477
|
+
if (query === null) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
const ast = this.astResolver(query);
|
|
481
|
+
if (ast === undefined) {
|
|
482
|
+
// this should only happen if the user didn't parse the query
|
|
483
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
484
|
+
throw new Error(USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE);
|
|
485
|
+
}
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const snapshotOrPromise = this.adapter({
|
|
489
|
+
...this.config,
|
|
490
|
+
query: ast,
|
|
491
|
+
});
|
|
492
|
+
this.processAdapterResponse(snapshotOrPromise);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
497
|
+
*
|
|
498
|
+
* @param adapter Adapter
|
|
499
|
+
* @param name name to assign to the generated constructor
|
|
500
|
+
* @param luvio Luvio
|
|
501
|
+
*/
|
|
502
|
+
function createGraphQLWireAdapterConstructor(adapter, name, luvio, astResolver) {
|
|
503
|
+
const constructor = function (callback) {
|
|
504
|
+
const delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback);
|
|
505
|
+
this.connect = () => delegate.connect();
|
|
506
|
+
this.disconnect = () => delegate.disconnect();
|
|
507
|
+
this.update = (config, context) => delegate.update(config, context);
|
|
508
|
+
};
|
|
509
|
+
Object.defineProperty(constructor, 'name', { value: name });
|
|
510
|
+
return constructor;
|
|
511
|
+
}
|
|
512
|
+
|
|
412
513
|
exports.ADAPTER_UNFULFILLED_ERROR = ADAPTER_UNFULFILLED_ERROR;
|
|
413
514
|
exports.REFRESH_ADAPTER_EVENT = REFRESH_ADAPTER_EVENT;
|
|
414
515
|
exports.bindWireRefresh = bindWireRefresh;
|
|
516
|
+
exports.createGraphQLWireAdapterConstructor = createGraphQLWireAdapterConstructor;
|
|
415
517
|
exports.createInfiniteScrollingWireAdapterConstructor = createInfiniteScrollingWireAdapterConstructor;
|
|
416
518
|
exports.createWireAdapterConstructor = createWireAdapterConstructor;
|
|
417
519
|
exports.refreshData = refreshData;
|
|
@@ -2,4 +2,7 @@ import { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR } from './utils/consta
|
|
|
2
2
|
import { bindWireRefresh, refreshData } from './LWCLuvioBindings';
|
|
3
3
|
import { createWireAdapterConstructor } from './LWCLuvioWireAdapter';
|
|
4
4
|
import { createInfiniteScrollingWireAdapterConstructor } from './LWCInfiniteScrollingLuvioWireAdapter';
|
|
5
|
-
|
|
5
|
+
import { createGraphQLWireAdapterConstructor } from './LWCGraphQLLuvioWireAdapter';
|
|
6
|
+
import type { GraphQLError, GraphQLResponse } from './LWCGraphQLLuvioWireAdapter';
|
|
7
|
+
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, bindWireRefresh, refreshData, REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, };
|
|
8
|
+
export type { GraphQLError, GraphQLResponse };
|
|
@@ -3,7 +3,7 @@ export declare function isErrorSnapshot(snapshot: Snapshot<unknown, unknown>): s
|
|
|
3
3
|
export declare function isFulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is FulfilledSnapshot<unknown, unknown>;
|
|
4
4
|
export declare function isStaleSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is StaleSnapshot<unknown, unknown>;
|
|
5
5
|
export declare function isUnfulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is UnfulfilledSnapshot<unknown, unknown>;
|
|
6
|
-
export declare type EmittableSnapshot = FulfilledSnapshot<
|
|
6
|
+
export declare type EmittableSnapshot<T = unknown> = FulfilledSnapshot<T> | StaleSnapshot<T> | ErrorSnapshot;
|
|
7
7
|
/**
|
|
8
8
|
* Transform a Snapshot into a payload suitable for passing to a DataCallback.
|
|
9
9
|
*
|
|
@@ -2,3 +2,4 @@ export declare const REFRESH_ADAPTER_EVENT = "refresh-adapter-event";
|
|
|
2
2
|
export declare const ADAPTER_UNFULFILLED_ERROR = "adapter-unfulfilled-error";
|
|
3
3
|
export declare const USERLAND_PROVISION_ERROR_MESSAGE = "LWC component's @wire target property or method threw an error during value provisioning. Original error:";
|
|
4
4
|
export declare const ADAPTER_SNAPSHOT_REJECTED_MESSAGE = "Luvio wire adapter Promise<Snapshot> rejected. Original error:";
|
|
5
|
+
export declare const USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE = "Use `gql` parser to parse your \"query\" string";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
+
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { AstResolver } from '@luvio/graphql-parser';
|
|
4
|
+
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
5
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
6
|
+
export declare type GraphQLError = {
|
|
7
|
+
message: string;
|
|
8
|
+
locations?: Array<{
|
|
9
|
+
line: number;
|
|
10
|
+
column: number;
|
|
11
|
+
}>;
|
|
12
|
+
path?: Array<string | number>;
|
|
13
|
+
extensions?: Record<string, any>;
|
|
14
|
+
};
|
|
15
|
+
export declare type GraphQLUserInput = {
|
|
16
|
+
query: object;
|
|
17
|
+
variables?: Record<string, string | number | boolean>;
|
|
18
|
+
operationName?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare type GraphQLResponse = {
|
|
21
|
+
data: any;
|
|
22
|
+
errors?: GraphQLError[];
|
|
23
|
+
} | {
|
|
24
|
+
errors: GraphQLError[];
|
|
25
|
+
};
|
|
26
|
+
export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
27
|
+
astResolver: AstResolver;
|
|
28
|
+
constructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver, callback: DataCallback);
|
|
29
|
+
update(config: WireConfigValue, _context?: WireContextValue): void;
|
|
30
|
+
/**
|
|
31
|
+
* Emits new values to the callback.
|
|
32
|
+
*
|
|
33
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
34
|
+
*/
|
|
35
|
+
protected emit(snapshot?: EmittableSnapshot<GraphQLResponse>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
38
|
+
*/
|
|
39
|
+
protected callAdapter(): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
43
|
+
*
|
|
44
|
+
* @param adapter Adapter
|
|
45
|
+
* @param name name to assign to the generated constructor
|
|
46
|
+
* @param luvio Luvio
|
|
47
|
+
*/
|
|
48
|
+
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver): WireAdapterConstructor;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Adapter, Luvio, Unsubscribe } from '@luvio/engine';
|
|
2
2
|
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
3
4
|
export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
4
5
|
adapter: Adapter<unknown, unknown>;
|
|
5
6
|
name: string;
|
|
@@ -32,14 +33,14 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
32
33
|
/**
|
|
33
34
|
* Calls the adapter if config has been set and the component is connected.
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
+
protected callAdapter(): void;
|
|
36
37
|
protected processAdapterResponse(snapshotOrPromise: ReturnType<Adapter<unknown, unknown>>): void;
|
|
37
38
|
/**
|
|
38
39
|
* Emits new values to the callback.
|
|
39
40
|
*
|
|
40
41
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
protected emit(snapshot?: EmittableSnapshot): void;
|
|
43
44
|
/**
|
|
44
45
|
* Subscribes this wire adapter to future changes to the specified snapshot. Any changes
|
|
45
46
|
* to the snapshot will be automatically emitted to the component.
|
package/dist/umd/es5/lwcluvio.js
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
var REFRESH_ADAPTER_EVENT = 'refresh-adapter-event';
|
|
9
9
|
var ADAPTER_UNFULFILLED_ERROR = 'adapter-unfulfilled-error';
|
|
10
10
|
var USERLAND_PROVISION_ERROR_MESSAGE = "LWC component's @wire target property or method threw an error during value provisioning. Original error:";
|
|
11
|
-
var ADAPTER_SNAPSHOT_REJECTED_MESSAGE = 'Luvio wire adapter Promise<Snapshot> rejected. Original error:';
|
|
11
|
+
var ADAPTER_SNAPSHOT_REJECTED_MESSAGE = 'Luvio wire adapter Promise<Snapshot> rejected. Original error:';
|
|
12
|
+
var USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE = 'Use `gql` parser to parse your "query" string';
|
|
12
13
|
|
|
13
14
|
// map of emitted object -> [ adapter name, snapshot ]; snapshot is only undefined for the
|
|
14
15
|
// initially-emitted { data: undefined, error: undefined } value
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
*
|
|
40
41
|
* @param snapshot Snapshot
|
|
41
42
|
*/
|
|
42
|
-
function snapshotToPayload(snapshot) {
|
|
43
|
+
function snapshotToPayload$1(snapshot) {
|
|
43
44
|
if (snapshot === undefined) {
|
|
44
45
|
return {
|
|
45
46
|
data: undefined,
|
|
@@ -301,7 +302,7 @@
|
|
|
301
302
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
302
303
|
*/
|
|
303
304
|
LWCLuvioWireAdapter.prototype.emit = function (snapshot) {
|
|
304
|
-
var payload = snapshotToPayload(snapshot);
|
|
305
|
+
var payload = snapshotToPayload$1(snapshot);
|
|
305
306
|
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
306
307
|
try {
|
|
307
308
|
this.callback(payload);
|
|
@@ -388,7 +389,18 @@
|
|
|
388
389
|
extendStatics(d, b);
|
|
389
390
|
function __() { this.constructor = d; }
|
|
390
391
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
391
|
-
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
var __assign = function() {
|
|
395
|
+
__assign = Object.assign || function __assign(t) {
|
|
396
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
397
|
+
s = arguments[i];
|
|
398
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
399
|
+
}
|
|
400
|
+
return t;
|
|
401
|
+
};
|
|
402
|
+
return __assign.apply(this, arguments);
|
|
403
|
+
};
|
|
392
404
|
|
|
393
405
|
var LWCInfinteScrollingLuvioWireAdapter = /** @class */ (function (_super) {
|
|
394
406
|
__extends(LWCInfinteScrollingLuvioWireAdapter, _super);
|
|
@@ -456,9 +468,109 @@
|
|
|
456
468
|
return constructor;
|
|
457
469
|
}
|
|
458
470
|
|
|
471
|
+
function snapshotToPayload(snapshot) {
|
|
472
|
+
if (snapshot === undefined) {
|
|
473
|
+
return {
|
|
474
|
+
data: undefined,
|
|
475
|
+
errors: undefined,
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
if (isErrorSnapshot(snapshot)) {
|
|
479
|
+
return {
|
|
480
|
+
data: undefined,
|
|
481
|
+
errors: [snapshot.error],
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
// fulfilled or stale
|
|
485
|
+
var payload = {};
|
|
486
|
+
if ('data' in snapshot.data && snapshot.data.data !== undefined) {
|
|
487
|
+
payload.data = snapshot.data.data;
|
|
488
|
+
}
|
|
489
|
+
if (snapshot.data.errors !== undefined) {
|
|
490
|
+
payload.errors = snapshot.data.errors;
|
|
491
|
+
}
|
|
492
|
+
return payload;
|
|
493
|
+
}
|
|
494
|
+
var LWCGraphQLLuvioWireAdapter = /** @class */ (function (_super) {
|
|
495
|
+
__extends(LWCGraphQLLuvioWireAdapter, _super);
|
|
496
|
+
function LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback) {
|
|
497
|
+
var _this = _super.call(this, adapter, name, luvio, callback) || this;
|
|
498
|
+
_this.astResolver = astResolver;
|
|
499
|
+
return _this;
|
|
500
|
+
}
|
|
501
|
+
LWCGraphQLLuvioWireAdapter.prototype.update = function (config, _context) {
|
|
502
|
+
this.unsubscribe();
|
|
503
|
+
// graphql query AST is passed by reference
|
|
504
|
+
// sanitizing it makes a copy and we lose that reference
|
|
505
|
+
this.config = __assign(__assign({}, sanitize(config)), { query: config.query });
|
|
506
|
+
this.callAdapter();
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Emits new values to the callback.
|
|
510
|
+
*
|
|
511
|
+
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
512
|
+
*/
|
|
513
|
+
LWCGraphQLLuvioWireAdapter.prototype.emit = function (snapshot) {
|
|
514
|
+
var payload = snapshotToPayload(snapshot);
|
|
515
|
+
dataToTupleWeakMap.set(payload, [this.name, snapshot]);
|
|
516
|
+
try {
|
|
517
|
+
this.callback(payload);
|
|
518
|
+
}
|
|
519
|
+
catch (error) {
|
|
520
|
+
if (error instanceof Error) {
|
|
521
|
+
throwAnnotatedError(error, USERLAND_PROVISION_ERROR_MESSAGE);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
527
|
+
*/
|
|
528
|
+
LWCGraphQLLuvioWireAdapter.prototype.callAdapter = function () {
|
|
529
|
+
if (!this.connected || this.config === undefined) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
var query = this.config.query;
|
|
533
|
+
// gql returns null for invalid queries
|
|
534
|
+
if (query === null) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
var ast = this.astResolver(query);
|
|
538
|
+
if (ast === undefined) {
|
|
539
|
+
// this should only happen if the user didn't parse the query
|
|
540
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
541
|
+
throw new Error(USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE);
|
|
542
|
+
}
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
var snapshotOrPromise = this.adapter(__assign(__assign({}, this.config), { query: ast }));
|
|
546
|
+
this.processAdapterResponse(snapshotOrPromise);
|
|
547
|
+
};
|
|
548
|
+
return LWCGraphQLLuvioWireAdapter;
|
|
549
|
+
}(LWCLuvioWireAdapter));
|
|
550
|
+
/**
|
|
551
|
+
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
552
|
+
*
|
|
553
|
+
* @param adapter Adapter
|
|
554
|
+
* @param name name to assign to the generated constructor
|
|
555
|
+
* @param luvio Luvio
|
|
556
|
+
*/
|
|
557
|
+
function createGraphQLWireAdapterConstructor(adapter, name, luvio, astResolver) {
|
|
558
|
+
var constructor = function (callback) {
|
|
559
|
+
var delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback);
|
|
560
|
+
this.connect = function () { return delegate.connect(); };
|
|
561
|
+
this.disconnect = function () { return delegate.disconnect(); };
|
|
562
|
+
this.update = function (config, context) {
|
|
563
|
+
return delegate.update(config, context);
|
|
564
|
+
};
|
|
565
|
+
};
|
|
566
|
+
Object.defineProperty(constructor, 'name', { value: name });
|
|
567
|
+
return constructor;
|
|
568
|
+
}
|
|
569
|
+
|
|
459
570
|
exports.ADAPTER_UNFULFILLED_ERROR = ADAPTER_UNFULFILLED_ERROR;
|
|
460
571
|
exports.REFRESH_ADAPTER_EVENT = REFRESH_ADAPTER_EVENT;
|
|
461
572
|
exports.bindWireRefresh = bindWireRefresh;
|
|
573
|
+
exports.createGraphQLWireAdapterConstructor = createGraphQLWireAdapterConstructor;
|
|
462
574
|
exports.createInfiniteScrollingWireAdapterConstructor = createInfiniteScrollingWireAdapterConstructor;
|
|
463
575
|
exports.createWireAdapterConstructor = createWireAdapterConstructor;
|
|
464
576
|
exports.refreshData = refreshData;
|
package/dist/umd/es5/main.d.ts
CHANGED
|
@@ -2,4 +2,7 @@ import { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR } from './utils/consta
|
|
|
2
2
|
import { bindWireRefresh, refreshData } from './LWCLuvioBindings';
|
|
3
3
|
import { createWireAdapterConstructor } from './LWCLuvioWireAdapter';
|
|
4
4
|
import { createInfiniteScrollingWireAdapterConstructor } from './LWCInfiniteScrollingLuvioWireAdapter';
|
|
5
|
-
|
|
5
|
+
import { createGraphQLWireAdapterConstructor } from './LWCGraphQLLuvioWireAdapter';
|
|
6
|
+
import type { GraphQLError, GraphQLResponse } from './LWCGraphQLLuvioWireAdapter';
|
|
7
|
+
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, bindWireRefresh, refreshData, REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, };
|
|
8
|
+
export type { GraphQLError, GraphQLResponse };
|
|
@@ -3,7 +3,7 @@ export declare function isErrorSnapshot(snapshot: Snapshot<unknown, unknown>): s
|
|
|
3
3
|
export declare function isFulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is FulfilledSnapshot<unknown, unknown>;
|
|
4
4
|
export declare function isStaleSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is StaleSnapshot<unknown, unknown>;
|
|
5
5
|
export declare function isUnfulfilledSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is UnfulfilledSnapshot<unknown, unknown>;
|
|
6
|
-
export declare type EmittableSnapshot = FulfilledSnapshot<
|
|
6
|
+
export declare type EmittableSnapshot<T = unknown> = FulfilledSnapshot<T> | StaleSnapshot<T> | ErrorSnapshot;
|
|
7
7
|
/**
|
|
8
8
|
* Transform a Snapshot into a payload suitable for passing to a DataCallback.
|
|
9
9
|
*
|
|
@@ -2,3 +2,4 @@ export declare const REFRESH_ADAPTER_EVENT = "refresh-adapter-event";
|
|
|
2
2
|
export declare const ADAPTER_UNFULFILLED_ERROR = "adapter-unfulfilled-error";
|
|
3
3
|
export declare const USERLAND_PROVISION_ERROR_MESSAGE = "LWC component's @wire target property or method threw an error during value provisioning. Original error:";
|
|
4
4
|
export declare const ADAPTER_SNAPSHOT_REJECTED_MESSAGE = "Luvio wire adapter Promise<Snapshot> rejected. Original error:";
|
|
5
|
+
export declare const USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE = "Use `gql` parser to parse your \"query\" string";
|
package/package.json
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvio/lwc-luvio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.99.2",
|
|
4
4
|
"description": "Lightning Web Component bindings for Luvio",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/salesforce/luvio.git",
|
|
8
|
+
"directory": "packages/@luvio/lwc-luvio"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
5
11
|
"main": "dist/umd/es2018/lwcluvio.js",
|
|
6
12
|
"module": "dist/es/es2018/lwcluvio.js",
|
|
7
13
|
"types": "dist/es/es2018/main.d.ts",
|
|
8
|
-
"
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/"
|
|
16
|
+
],
|
|
9
17
|
"scripts": {
|
|
10
|
-
"clean": "rm -rf dist src/__tests__/components/generated",
|
|
11
18
|
"build": "yarn build:lwcluvio && yarn build:component-tests",
|
|
12
|
-
"build:lwcluvio": "rollup --config rollup.config.js",
|
|
13
19
|
"build:component-tests": "luvio generate src/__tests__/components/raml/api.raml src/__tests__/components/generated",
|
|
14
|
-
"
|
|
20
|
+
"build:lwcluvio": "rollup --config rollup.config.js",
|
|
21
|
+
"clean": "rm -rf dist src/__tests__/components/generated",
|
|
15
22
|
"test": "jest",
|
|
16
|
-
"test:size": "bundlesize"
|
|
23
|
+
"test:size": "bundlesize",
|
|
24
|
+
"watch": "yarn build --watch"
|
|
17
25
|
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@luvio/engine": "0.99.2",
|
|
28
|
+
"@lwc/engine-core": "2.11.3"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@luvio/adapter-test-library": "0.99.2",
|
|
32
|
+
"@luvio/cli": "0.99.2",
|
|
33
|
+
"@lwc/jest-preset": "11.2.2"
|
|
34
|
+
},
|
|
35
|
+
"bundlesize": [
|
|
36
|
+
{
|
|
37
|
+
"path": "./dist/es/es2018/lwcluvio.js",
|
|
38
|
+
"maxSize": "5 kB",
|
|
39
|
+
"compression": "brotli"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
18
42
|
"nx": {
|
|
19
43
|
"targets": {
|
|
20
44
|
"build": {
|
|
@@ -28,24 +52,5 @@
|
|
|
28
52
|
]
|
|
29
53
|
}
|
|
30
54
|
}
|
|
31
|
-
}
|
|
32
|
-
"files": [
|
|
33
|
-
"dist/"
|
|
34
|
-
],
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@luvio/adapter-test-library": "0.98.0",
|
|
37
|
-
"@luvio/cli": "0.98.0",
|
|
38
|
-
"@lwc/jest-preset": "11.2.2"
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"@luvio/engine": "0.98.0",
|
|
42
|
-
"@lwc/engine-core": "2.11.3"
|
|
43
|
-
},
|
|
44
|
-
"bundlesize": [
|
|
45
|
-
{
|
|
46
|
-
"path": "./dist/es/es2018/lwcluvio.js",
|
|
47
|
-
"maxSize": "5 kB",
|
|
48
|
-
"compression": "brotli"
|
|
49
|
-
}
|
|
50
|
-
]
|
|
55
|
+
}
|
|
51
56
|
}
|