@luvio/lwc-luvio 0.143.8 → 0.144.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/dist/lwcluvio.js
CHANGED
|
@@ -181,7 +181,7 @@ class LWCLuvioWireAdapter {
|
|
|
181
181
|
*
|
|
182
182
|
* @param callback callback to be invoked with new values
|
|
183
183
|
*/
|
|
184
|
-
constructor(adapter, name, luvio, callback) {
|
|
184
|
+
constructor(adapter, name, luvio, callback, sourceContext) {
|
|
185
185
|
// a component can be connected-disconnected-reconnected multiple times during its
|
|
186
186
|
// life but we only want to keep subscriptions active while it is connected; the
|
|
187
187
|
// connect/disconnect methods below keep this value updated to reflect the current
|
|
@@ -191,6 +191,7 @@ class LWCLuvioWireAdapter {
|
|
|
191
191
|
this.name = name;
|
|
192
192
|
this.luvio = luvio;
|
|
193
193
|
this.callback = callback;
|
|
194
|
+
this.sourceContext = sourceContext;
|
|
194
195
|
// initialize the wired property with a properly shaped object so cmps can use <template if:true={wiredProperty.data}>
|
|
195
196
|
this.emit();
|
|
196
197
|
}
|
|
@@ -200,7 +201,7 @@ class LWCLuvioWireAdapter {
|
|
|
200
201
|
*/
|
|
201
202
|
connect() {
|
|
202
203
|
this.connected = true;
|
|
203
|
-
this.callAdapter();
|
|
204
|
+
this.callAdapter(this.generateAdapterRequestContext());
|
|
204
205
|
}
|
|
205
206
|
/**
|
|
206
207
|
* Called when the component associated with the wire adapter is disconnected.
|
|
@@ -215,20 +216,31 @@ class LWCLuvioWireAdapter {
|
|
|
215
216
|
* @param config new config parameters for the wire adapter
|
|
216
217
|
* @param _context not used
|
|
217
218
|
*/
|
|
218
|
-
update(config,
|
|
219
|
+
update(config, context) {
|
|
219
220
|
this.unsubscribe();
|
|
220
221
|
this.config = sanitize(config);
|
|
221
|
-
this.callAdapter();
|
|
222
|
+
this.callAdapter(this.generateAdapterRequestContext(context));
|
|
222
223
|
}
|
|
223
224
|
// private and protected utility methods
|
|
225
|
+
/**
|
|
226
|
+
* Accepts a WireContext and generates corresponding AdapterRequestContext
|
|
227
|
+
*/
|
|
228
|
+
generateAdapterRequestContext(_context) {
|
|
229
|
+
if (!this.sourceContext) {
|
|
230
|
+
return {};
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
sourceContext: { ...this.sourceContext },
|
|
234
|
+
};
|
|
235
|
+
}
|
|
224
236
|
/**
|
|
225
237
|
* Calls the adapter if config has been set and the component is connected.
|
|
226
238
|
*/
|
|
227
|
-
callAdapter() {
|
|
239
|
+
callAdapter(context) {
|
|
228
240
|
if (!this.connected || this.config === undefined) {
|
|
229
241
|
return;
|
|
230
242
|
}
|
|
231
|
-
const snapshotOrPromise = this.adapter(this.config);
|
|
243
|
+
const snapshotOrPromise = this.adapter(this.config, context);
|
|
232
244
|
this.processAdapterResponse(snapshotOrPromise);
|
|
233
245
|
}
|
|
234
246
|
processAdapterResponse(snapshotOrPromise) {
|
|
@@ -337,8 +349,8 @@ class LWCLuvioWireAdapter {
|
|
|
337
349
|
* @param luvio Luvio
|
|
338
350
|
*/
|
|
339
351
|
function createWireAdapterConstructor(adapter, name, luvio) {
|
|
340
|
-
const constructor = function (callback) {
|
|
341
|
-
const delegate = new LWCLuvioWireAdapter(adapter, name, luvio, callback);
|
|
352
|
+
const constructor = function (callback, sourceContext) {
|
|
353
|
+
const delegate = new LWCLuvioWireAdapter(adapter, name, luvio, callback, sourceContext);
|
|
342
354
|
this.connect = () => delegate.connect();
|
|
343
355
|
this.disconnect = () => delegate.disconnect();
|
|
344
356
|
this.update = (config, context) => delegate.update(config, context);
|
|
@@ -370,34 +382,32 @@ class LWCInfinteScrollingLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
|
370
382
|
*/
|
|
371
383
|
update(config, context) {
|
|
372
384
|
if (this.connectTimestamp) {
|
|
373
|
-
const
|
|
374
|
-
cachePolicy: {
|
|
375
|
-
type: 'valid-at',
|
|
376
|
-
timestamp: this.connectTimestamp,
|
|
377
|
-
},
|
|
378
|
-
}, context);
|
|
385
|
+
const adapterRequestContext = this.generateAdapterRequestContext(context);
|
|
379
386
|
super.unsubscribe();
|
|
380
387
|
this.config = sanitize(config);
|
|
381
|
-
this.callAdapterWithContext(mergedContext);
|
|
388
|
+
// this.callAdapterWithContext(mergedContext);
|
|
389
|
+
super.callAdapter(adapterRequestContext);
|
|
382
390
|
}
|
|
383
391
|
else {
|
|
384
392
|
super.update(config, context);
|
|
385
393
|
}
|
|
386
394
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
395
|
+
generateAdapterRequestContext(context) {
|
|
396
|
+
const baseContext = super.generateAdapterRequestContext(context);
|
|
397
|
+
// this code-path is only called when the wire adapter is connected
|
|
398
|
+
// and the connectTimestamp is set
|
|
399
|
+
return {
|
|
400
|
+
...baseContext,
|
|
401
|
+
cachePolicy: {
|
|
402
|
+
type: 'valid-at',
|
|
403
|
+
timestamp: this.connectTimestamp,
|
|
404
|
+
},
|
|
405
|
+
};
|
|
396
406
|
}
|
|
397
407
|
}
|
|
398
408
|
function createInfiniteScrollingWireAdapterConstructor(adapter, name, luvio) {
|
|
399
|
-
const constructor = function (callback) {
|
|
400
|
-
const delegate = new LWCInfinteScrollingLuvioWireAdapter(adapter, name, luvio, callback);
|
|
409
|
+
const constructor = function (callback, sourceContext) {
|
|
410
|
+
const delegate = new LWCInfinteScrollingLuvioWireAdapter(adapter, name, luvio, callback, sourceContext);
|
|
401
411
|
this.connect = () => delegate.connect();
|
|
402
412
|
this.disconnect = () => delegate.disconnect();
|
|
403
413
|
this.update = (config, context) => delegate.update(config, context);
|
|
@@ -427,11 +437,11 @@ function snapshotToPayload(snapshot) {
|
|
|
427
437
|
return payload;
|
|
428
438
|
}
|
|
429
439
|
class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
430
|
-
constructor(adapter, name, luvio, astResolver, callback) {
|
|
431
|
-
super(adapter, name, luvio, callback);
|
|
440
|
+
constructor(adapter, name, luvio, astResolver, callback, sourceContext) {
|
|
441
|
+
super(adapter, name, luvio, callback, sourceContext);
|
|
432
442
|
this.astResolver = astResolver;
|
|
433
443
|
}
|
|
434
|
-
update(config,
|
|
444
|
+
update(config, context) {
|
|
435
445
|
this.unsubscribe();
|
|
436
446
|
if (config.batchQuery) {
|
|
437
447
|
this.config = {
|
|
@@ -441,7 +451,7 @@ class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
|
441
451
|
else {
|
|
442
452
|
this.config = safeSanitizeGraphQLConfigObject(config);
|
|
443
453
|
}
|
|
444
|
-
this.callAdapter();
|
|
454
|
+
this.callAdapter(super.generateAdapterRequestContext(context));
|
|
445
455
|
}
|
|
446
456
|
/**
|
|
447
457
|
* Emits new values to the callback.
|
|
@@ -463,7 +473,7 @@ class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
|
463
473
|
/**
|
|
464
474
|
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
465
475
|
*/
|
|
466
|
-
callAdapter() {
|
|
476
|
+
callAdapter(context) {
|
|
467
477
|
if (!this.connected || this.config === undefined) {
|
|
468
478
|
return;
|
|
469
479
|
}
|
|
@@ -476,13 +486,13 @@ class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
|
476
486
|
if (batchConfig.batchQuery.some((val) => val === undefined)) {
|
|
477
487
|
return;
|
|
478
488
|
}
|
|
479
|
-
const snapshotOrPromise = this.adapter(batchConfig);
|
|
489
|
+
const snapshotOrPromise = this.adapter(batchConfig, context);
|
|
480
490
|
this.processAdapterResponse(snapshotOrPromise);
|
|
481
491
|
}
|
|
482
492
|
else if ('query' in config) {
|
|
483
493
|
const singleConfig = this.resolveQueryAst(config);
|
|
484
494
|
if (singleConfig !== undefined) {
|
|
485
|
-
const snapshotOrPromise = this.adapter(singleConfig);
|
|
495
|
+
const snapshotOrPromise = this.adapter(singleConfig, context);
|
|
486
496
|
this.processAdapterResponse(snapshotOrPromise);
|
|
487
497
|
}
|
|
488
498
|
}
|
|
@@ -524,8 +534,8 @@ function extractSnapshotData(snapshot) {
|
|
|
524
534
|
* @param luvio Luvio
|
|
525
535
|
*/
|
|
526
536
|
function createGraphQLWireAdapterConstructor(adapter, name, luvio, astResolver) {
|
|
527
|
-
const constructor = function (callback) {
|
|
528
|
-
const delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback);
|
|
537
|
+
const constructor = function (callback, sourceContext) {
|
|
538
|
+
const delegate = new LWCGraphQLLuvioWireAdapter(adapter, name, luvio, astResolver, callback, sourceContext);
|
|
529
539
|
this.connect = () => delegate.connect();
|
|
530
540
|
this.disconnect = () => delegate.disconnect();
|
|
531
541
|
this.update = (config, context) => delegate.update(config, context);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { Adapter, Luvio } from '@luvio/engine';
|
|
1
|
+
import type { Adapter, AdapterRequestContext, Luvio } from '@luvio/engine';
|
|
2
2
|
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
3
|
import type { AstResolver, DocumentNode } from '@luvio/graphql-parser';
|
|
4
|
+
import type { SourceContext } from './LWCLuvioWireAdapter';
|
|
4
5
|
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
5
6
|
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
6
7
|
export type GraphQLError = {
|
|
@@ -32,8 +33,8 @@ export type GraphQLResponse = {
|
|
|
32
33
|
};
|
|
33
34
|
export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
34
35
|
astResolver: AstResolver;
|
|
35
|
-
constructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver, callback: DataCallback);
|
|
36
|
-
update(config: WireConfigValue,
|
|
36
|
+
constructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, astResolver: AstResolver, callback: DataCallback, sourceContext?: SourceContext);
|
|
37
|
+
update(config: WireConfigValue, context?: WireContextValue): void;
|
|
37
38
|
/**
|
|
38
39
|
* Emits new values to the callback.
|
|
39
40
|
*
|
|
@@ -43,7 +44,7 @@ export declare class LWCGraphQLLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
|
43
44
|
/**
|
|
44
45
|
* Coerce config before calling the adapter, preserve current behavior otherwise
|
|
45
46
|
*/
|
|
46
|
-
protected callAdapter(): void;
|
|
47
|
+
protected callAdapter(context?: AdapterRequestContext): void;
|
|
47
48
|
resolveQueryAst(config: GraphQLUserInput): ResolvedGraphQLConfig | undefined;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Adapter, Luvio } from '@luvio/engine';
|
|
1
|
+
import type { Adapter, AdapterRequestContext, Luvio } from '@luvio/engine';
|
|
2
2
|
import type { WireConfigValue, WireContextValue, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
3
|
import { LWCLuvioWireAdapter } from './LWCLuvioWireAdapter';
|
|
4
4
|
export declare class LWCInfinteScrollingLuvioWireAdapter extends LWCLuvioWireAdapter {
|
|
@@ -18,9 +18,6 @@ export declare class LWCInfinteScrollingLuvioWireAdapter extends LWCLuvioWireAda
|
|
|
18
18
|
* @param context context for the wire adapter
|
|
19
19
|
*/
|
|
20
20
|
update(config: WireConfigValue, context?: WireContextValue): void;
|
|
21
|
-
|
|
22
|
-
* Calls the adapter if config has been set and the component is connected.
|
|
23
|
-
*/
|
|
24
|
-
private callAdapterWithContext;
|
|
21
|
+
protected generateAdapterRequestContext(context?: WireContextValue): AdapterRequestContext;
|
|
25
22
|
}
|
|
26
23
|
export declare function createInfiniteScrollingWireAdapterConstructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio): WireAdapterConstructor;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { Adapter, Luvio, Unsubscribe } from '@luvio/engine';
|
|
1
|
+
import type { Adapter, AdapterRequestContext, Luvio, Unsubscribe } from '@luvio/engine';
|
|
2
2
|
import type { WireConfigValue, WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
3
|
import type { EmittableSnapshot } from './utils/SnapshotState';
|
|
4
|
+
export type SourceContext = {
|
|
5
|
+
tagName: string;
|
|
6
|
+
};
|
|
4
7
|
export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
5
8
|
adapter: Adapter<unknown, unknown>;
|
|
6
9
|
name: string;
|
|
@@ -9,12 +12,13 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
9
12
|
connected: boolean;
|
|
10
13
|
luvio: Luvio;
|
|
11
14
|
unsubscriber?: Unsubscribe;
|
|
15
|
+
sourceContext?: SourceContext;
|
|
12
16
|
/**
|
|
13
17
|
* Constructs a new wire adapter instance for the given adapter.
|
|
14
18
|
*
|
|
15
19
|
* @param callback callback to be invoked with new values
|
|
16
20
|
*/
|
|
17
|
-
constructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, callback: DataCallback);
|
|
21
|
+
constructor(adapter: Adapter<unknown, unknown>, name: string, luvio: Luvio, callback: DataCallback, sourceContext?: SourceContext);
|
|
18
22
|
/**
|
|
19
23
|
* Called when the component associated with the wire adapter is connected.
|
|
20
24
|
*/
|
|
@@ -29,11 +33,15 @@ export declare class LWCLuvioWireAdapter implements WireAdapter {
|
|
|
29
33
|
* @param config new config parameters for the wire adapter
|
|
30
34
|
* @param _context not used
|
|
31
35
|
*/
|
|
32
|
-
update(config: WireConfigValue,
|
|
36
|
+
update(config: WireConfigValue, context?: WireContextValue): void;
|
|
37
|
+
/**
|
|
38
|
+
* Accepts a WireContext and generates corresponding AdapterRequestContext
|
|
39
|
+
*/
|
|
40
|
+
protected generateAdapterRequestContext(_context?: WireContextValue): AdapterRequestContext;
|
|
33
41
|
/**
|
|
34
42
|
* Calls the adapter if config has been set and the component is connected.
|
|
35
43
|
*/
|
|
36
|
-
protected callAdapter(): void;
|
|
44
|
+
protected callAdapter(context?: AdapterRequestContext): void;
|
|
37
45
|
protected processAdapterResponse(snapshotOrPromise: ReturnType<Adapter<unknown, unknown>>): void;
|
|
38
46
|
/**
|
|
39
47
|
* Emits new values to the callback.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvio/lwc-luvio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.144.0",
|
|
4
4
|
"description": "Lightning Web Component bindings for Luvio",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"watch": "yarn build --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@luvio/engine": "^0.
|
|
33
|
-
"@lwc/engine-core": "2.
|
|
32
|
+
"@luvio/engine": "^0.144.0",
|
|
33
|
+
"@lwc/engine-core": "2.49.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@luvio/adapter-test-library": "^0.
|
|
37
|
-
"@luvio/cli": "^0.
|
|
36
|
+
"@luvio/adapter-test-library": "^0.144.0",
|
|
37
|
+
"@luvio/cli": "^0.144.0",
|
|
38
38
|
"@lwc/jest-preset": "11.7.1",
|
|
39
39
|
"jest-environment-jsdom": "^29.5.0"
|
|
40
40
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"luvioBundlesize": [
|
|
45
45
|
{
|
|
46
|
-
"path": "./dist/
|
|
46
|
+
"path": "./dist/lwcluvio.js",
|
|
47
47
|
"maxSize": {
|
|
48
48
|
"none": "21 kB",
|
|
49
49
|
"min": "7.5 kB",
|