@luvio/lwc-luvio 0.99.0 → 0.99.1
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 +15 -2
- package/dist/es/es2018/LWCLuvioWireAdapter.d.ts +1 -1
- package/dist/es/es2018/lwcluvio.js +41 -3
- package/dist/es/es2018/main.d.ts +2 -0
- package/dist/es/es2018/utils/constants.d.ts +1 -0
- package/dist/umd/es2018/LWCGraphQLLuvioWireAdapter.d.ts +15 -2
- package/dist/umd/es2018/LWCLuvioWireAdapter.d.ts +1 -1
- package/dist/umd/es2018/lwcluvio.js +41 -3
- package/dist/umd/es2018/main.d.ts +2 -0
- package/dist/umd/es2018/utils/constants.d.ts +1 -0
- package/dist/umd/es5/LWCGraphQLLuvioWireAdapter.d.ts +15 -2
- package/dist/umd/es5/LWCLuvioWireAdapter.d.ts +1 -1
- package/dist/umd/es5/lwcluvio.js +50 -6
- package/dist/umd/es5/main.d.ts +2 -0
- package/dist/umd/es5/utils/constants.d.ts +1 -0
- package/package.json +31 -26
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
-
import type { WireAdapterConstructor } from '@lwc/engine-core';
|
|
2
|
+
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { AstResolver } from '@luvio/graphql-parser';
|
|
3
4
|
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
4
5
|
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
5
6
|
export declare type GraphQLError = {
|
|
@@ -11,6 +12,11 @@ export declare type GraphQLError = {
|
|
|
11
12
|
path?: Array<string | number>;
|
|
12
13
|
extensions?: Record<string, any>;
|
|
13
14
|
};
|
|
15
|
+
export declare type GraphQLUserInput = {
|
|
16
|
+
query: object;
|
|
17
|
+
variables?: Record<string, string | number | boolean>;
|
|
18
|
+
operationName?: string;
|
|
19
|
+
};
|
|
14
20
|
export declare type GraphQLResponse = {
|
|
15
21
|
data: any;
|
|
16
22
|
errors?: GraphQLError[];
|
|
@@ -18,12 +24,19 @@ export declare type GraphQLResponse = {
|
|
|
18
24
|
errors: GraphQLError[];
|
|
19
25
|
};
|
|
20
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;
|
|
21
30
|
/**
|
|
22
31
|
* Emits new values to the callback.
|
|
23
32
|
*
|
|
24
33
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
25
34
|
*/
|
|
26
35
|
protected emit(snapshot?: EmittableSnapshot<GraphQLResponse>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
38
|
+
*/
|
|
39
|
+
protected callAdapter(): void;
|
|
27
40
|
}
|
|
28
41
|
/**
|
|
29
42
|
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
@@ -32,4 +45,4 @@ export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
|
32
45
|
* @param name name to assign to the generated constructor
|
|
33
46
|
* @param luvio Luvio
|
|
34
47
|
*/
|
|
35
|
-
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio): WireAdapterConstructor;
|
|
48
|
+
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver): WireAdapterConstructor;
|
|
@@ -33,7 +33,7 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
33
33
|
/**
|
|
34
34
|
* Calls the adapter if config has been set and the component is connected.
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
protected callAdapter(): void;
|
|
37
37
|
protected processAdapterResponse(snapshotOrPromise: ReturnType<Adapter<unknown, unknown>>): void;
|
|
38
38
|
/**
|
|
39
39
|
* Emits new values to the callback.
|
|
@@ -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
|
|
@@ -429,6 +430,17 @@ function snapshotToPayload(snapshot) {
|
|
|
429
430
|
return payload;
|
|
430
431
|
}
|
|
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
|
+
// sanitize in the update is causing us to lose ast object reference
|
|
438
|
+
// TODO: we need to look into this to update sanitize or remove it
|
|
439
|
+
update(config, _context) {
|
|
440
|
+
this.unsubscribe();
|
|
441
|
+
this.config = config;
|
|
442
|
+
this.callAdapter();
|
|
443
|
+
}
|
|
432
444
|
/**
|
|
433
445
|
* Emits new values to the callback.
|
|
434
446
|
*
|
|
@@ -446,6 +458,32 @@ class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
|
446
458
|
}
|
|
447
459
|
}
|
|
448
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
463
|
+
*/
|
|
464
|
+
callAdapter() {
|
|
465
|
+
if (!this.connected || this.config === undefined) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const query = this.config.query;
|
|
469
|
+
// gql returns null for invalid queries
|
|
470
|
+
if (query === null) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const ast = this.astResolver(query);
|
|
474
|
+
if (ast === undefined) {
|
|
475
|
+
// this should only happen if the user didn't parse the query
|
|
476
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
477
|
+
throw new Error(USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE);
|
|
478
|
+
}
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const snapshotOrPromise = this.adapter({
|
|
482
|
+
...this.config,
|
|
483
|
+
query: ast,
|
|
484
|
+
});
|
|
485
|
+
this.processAdapterResponse(snapshotOrPromise);
|
|
486
|
+
}
|
|
449
487
|
}
|
|
450
488
|
/**
|
|
451
489
|
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
@@ -454,9 +492,9 @@ class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
|
454
492
|
* @param name name to assign to the generated constructor
|
|
455
493
|
* @param luvio Luvio
|
|
456
494
|
*/
|
|
457
|
-
function createGraphQLWireAdapterConstructor(adapter, name, luvio) {
|
|
495
|
+
function createGraphQLWireAdapterConstructor(adapter, name, luvio, astResolver) {
|
|
458
496
|
const constructor = function (callback) {
|
|
459
|
-
const delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, callback);
|
|
497
|
+
const delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback);
|
|
460
498
|
this.connect = () => delegate.connect();
|
|
461
499
|
this.disconnect = () => delegate.disconnect();
|
|
462
500
|
this.update = (config, context) => delegate.update(config, context);
|
package/dist/es/es2018/main.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ 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';
|
|
6
7
|
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, bindWireRefresh, refreshData, REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, };
|
|
8
|
+
export type { GraphQLError, GraphQLResponse };
|
|
@@ -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";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
-
import type { WireAdapterConstructor } from '@lwc/engine-core';
|
|
2
|
+
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { AstResolver } from '@luvio/graphql-parser';
|
|
3
4
|
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
4
5
|
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
5
6
|
export declare type GraphQLError = {
|
|
@@ -11,6 +12,11 @@ export declare type GraphQLError = {
|
|
|
11
12
|
path?: Array<string | number>;
|
|
12
13
|
extensions?: Record<string, any>;
|
|
13
14
|
};
|
|
15
|
+
export declare type GraphQLUserInput = {
|
|
16
|
+
query: object;
|
|
17
|
+
variables?: Record<string, string | number | boolean>;
|
|
18
|
+
operationName?: string;
|
|
19
|
+
};
|
|
14
20
|
export declare type GraphQLResponse = {
|
|
15
21
|
data: any;
|
|
16
22
|
errors?: GraphQLError[];
|
|
@@ -18,12 +24,19 @@ export declare type GraphQLResponse = {
|
|
|
18
24
|
errors: GraphQLError[];
|
|
19
25
|
};
|
|
20
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;
|
|
21
30
|
/**
|
|
22
31
|
* Emits new values to the callback.
|
|
23
32
|
*
|
|
24
33
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
25
34
|
*/
|
|
26
35
|
protected emit(snapshot?: EmittableSnapshot<GraphQLResponse>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
38
|
+
*/
|
|
39
|
+
protected callAdapter(): void;
|
|
27
40
|
}
|
|
28
41
|
/**
|
|
29
42
|
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
@@ -32,4 +45,4 @@ export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
|
32
45
|
* @param name name to assign to the generated constructor
|
|
33
46
|
* @param luvio Luvio
|
|
34
47
|
*/
|
|
35
|
-
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio): WireAdapterConstructor;
|
|
48
|
+
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver): WireAdapterConstructor;
|
|
@@ -33,7 +33,7 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
33
33
|
/**
|
|
34
34
|
* Calls the adapter if config has been set and the component is connected.
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
protected callAdapter(): void;
|
|
37
37
|
protected processAdapterResponse(snapshotOrPromise: ReturnType<Adapter<unknown, unknown>>): void;
|
|
38
38
|
/**
|
|
39
39
|
* Emits new values to the callback.
|
|
@@ -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
|
|
@@ -433,6 +434,17 @@
|
|
|
433
434
|
return payload;
|
|
434
435
|
}
|
|
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
|
+
// sanitize in the update is causing us to lose ast object reference
|
|
442
|
+
// TODO: we need to look into this to update sanitize or remove it
|
|
443
|
+
update(config, _context) {
|
|
444
|
+
this.unsubscribe();
|
|
445
|
+
this.config = config;
|
|
446
|
+
this.callAdapter();
|
|
447
|
+
}
|
|
436
448
|
/**
|
|
437
449
|
* Emits new values to the callback.
|
|
438
450
|
*
|
|
@@ -450,6 +462,32 @@
|
|
|
450
462
|
}
|
|
451
463
|
}
|
|
452
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
467
|
+
*/
|
|
468
|
+
callAdapter() {
|
|
469
|
+
if (!this.connected || this.config === undefined) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
const query = this.config.query;
|
|
473
|
+
// gql returns null for invalid queries
|
|
474
|
+
if (query === null) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const ast = this.astResolver(query);
|
|
478
|
+
if (ast === undefined) {
|
|
479
|
+
// this should only happen if the user didn't parse the query
|
|
480
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
481
|
+
throw new Error(USERLAND_GRAPHQL_PARSER_ERROR_MESSAGE);
|
|
482
|
+
}
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
const snapshotOrPromise = this.adapter({
|
|
486
|
+
...this.config,
|
|
487
|
+
query: ast,
|
|
488
|
+
});
|
|
489
|
+
this.processAdapterResponse(snapshotOrPromise);
|
|
490
|
+
}
|
|
453
491
|
}
|
|
454
492
|
/**
|
|
455
493
|
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
@@ -458,9 +496,9 @@
|
|
|
458
496
|
* @param name name to assign to the generated constructor
|
|
459
497
|
* @param luvio Luvio
|
|
460
498
|
*/
|
|
461
|
-
function createGraphQLWireAdapterConstructor(adapter, name, luvio) {
|
|
499
|
+
function createGraphQLWireAdapterConstructor(adapter, name, luvio, astResolver) {
|
|
462
500
|
const constructor = function (callback) {
|
|
463
|
-
const delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, callback);
|
|
501
|
+
const delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback);
|
|
464
502
|
this.connect = () => delegate.connect();
|
|
465
503
|
this.disconnect = () => delegate.disconnect();
|
|
466
504
|
this.update = (config, context) => delegate.update(config, context);
|
|
@@ -3,4 +3,6 @@ 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';
|
|
6
7
|
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, bindWireRefresh, refreshData, REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, };
|
|
8
|
+
export type { GraphQLError, GraphQLResponse };
|
|
@@ -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";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
-
import type { WireAdapterConstructor } from '@lwc/engine-core';
|
|
2
|
+
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { AstResolver } from '@luvio/graphql-parser';
|
|
3
4
|
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
4
5
|
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
5
6
|
export declare type GraphQLError = {
|
|
@@ -11,6 +12,11 @@ export declare type GraphQLError = {
|
|
|
11
12
|
path?: Array<string | number>;
|
|
12
13
|
extensions?: Record<string, any>;
|
|
13
14
|
};
|
|
15
|
+
export declare type GraphQLUserInput = {
|
|
16
|
+
query: object;
|
|
17
|
+
variables?: Record<string, string | number | boolean>;
|
|
18
|
+
operationName?: string;
|
|
19
|
+
};
|
|
14
20
|
export declare type GraphQLResponse = {
|
|
15
21
|
data: any;
|
|
16
22
|
errors?: GraphQLError[];
|
|
@@ -18,12 +24,19 @@ export declare type GraphQLResponse = {
|
|
|
18
24
|
errors: GraphQLError[];
|
|
19
25
|
};
|
|
20
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;
|
|
21
30
|
/**
|
|
22
31
|
* Emits new values to the callback.
|
|
23
32
|
*
|
|
24
33
|
* @param snapshot Snapshot to be emitted, if omitted then undefineds will be emitted
|
|
25
34
|
*/
|
|
26
35
|
protected emit(snapshot?: EmittableSnapshot<GraphQLResponse>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
38
|
+
*/
|
|
39
|
+
protected callAdapter(): void;
|
|
27
40
|
}
|
|
28
41
|
/**
|
|
29
42
|
* Wraps a luvio Adapter in a WireAdapterConstructor that conforms to https://rfcs.lwc.dev/rfcs/lwc/0000-wire-reform#wire-adapter-protocol.
|
|
@@ -32,4 +45,4 @@ export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
|
32
45
|
* @param name name to assign to the generated constructor
|
|
33
46
|
* @param luvio Luvio
|
|
34
47
|
*/
|
|
35
|
-
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio): WireAdapterConstructor;
|
|
48
|
+
export declare function createGraphQLWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver): WireAdapterConstructor;
|
|
@@ -33,7 +33,7 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
33
33
|
/**
|
|
34
34
|
* Calls the adapter if config has been set and the component is connected.
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
protected callAdapter(): void;
|
|
37
37
|
protected processAdapterResponse(snapshotOrPromise: ReturnType<Adapter<unknown, unknown>>): void;
|
|
38
38
|
/**
|
|
39
39
|
* Emits new values to the callback.
|
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
|
|
@@ -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);
|
|
@@ -481,9 +493,18 @@
|
|
|
481
493
|
}
|
|
482
494
|
var LWCGraphQLLuvioWireAdapter = /** @class */ (function (_super) {
|
|
483
495
|
__extends(LWCGraphQLLuvioWireAdapter, _super);
|
|
484
|
-
function LWCGraphQLLuvioWireAdapter() {
|
|
485
|
-
|
|
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;
|
|
486
500
|
}
|
|
501
|
+
// sanitize in the update is causing us to lose ast object reference
|
|
502
|
+
// TODO: we need to look into this to update sanitize or remove it
|
|
503
|
+
LWCGraphQLLuvioWireAdapter.prototype.update = function (config, _context) {
|
|
504
|
+
this.unsubscribe();
|
|
505
|
+
this.config = config;
|
|
506
|
+
this.callAdapter();
|
|
507
|
+
};
|
|
487
508
|
/**
|
|
488
509
|
* Emits new values to the callback.
|
|
489
510
|
*
|
|
@@ -501,6 +522,29 @@
|
|
|
501
522
|
}
|
|
502
523
|
}
|
|
503
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
|
+
};
|
|
504
548
|
return LWCGraphQLLuvioWireAdapter;
|
|
505
549
|
}(LWCLuvioWireAdapter));
|
|
506
550
|
/**
|
|
@@ -510,9 +554,9 @@
|
|
|
510
554
|
* @param name name to assign to the generated constructor
|
|
511
555
|
* @param luvio Luvio
|
|
512
556
|
*/
|
|
513
|
-
function createGraphQLWireAdapterConstructor(adapter, name, luvio) {
|
|
557
|
+
function createGraphQLWireAdapterConstructor(adapter, name, luvio, astResolver) {
|
|
514
558
|
var constructor = function (callback) {
|
|
515
|
-
var delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, callback);
|
|
559
|
+
var delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback);
|
|
516
560
|
this.connect = function () { return delegate.connect(); };
|
|
517
561
|
this.disconnect = function () { return delegate.disconnect(); };
|
|
518
562
|
this.update = function (config, context) {
|
package/dist/umd/es5/main.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ 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';
|
|
6
7
|
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, bindWireRefresh, refreshData, REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, };
|
|
8
|
+
export type { GraphQLError, GraphQLResponse };
|
|
@@ -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.99.
|
|
3
|
+
"version": "0.99.1",
|
|
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.1",
|
|
28
|
+
"@lwc/engine-core": "2.11.3"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@luvio/adapter-test-library": "0.99.1",
|
|
32
|
+
"@luvio/cli": "0.99.1",
|
|
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.99.0",
|
|
37
|
-
"@luvio/cli": "0.99.0",
|
|
38
|
-
"@lwc/jest-preset": "11.2.2"
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"@luvio/engine": "0.99.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
|
}
|