@salesforce/lds-bindings 1.124.1 → 1.124.3
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/ldsBindings.js +353 -353
- package/dist/{bindWireRefresh.d.ts → types/bindWireRefresh.d.ts} +7 -7
- package/dist/{constants.d.ts → types/constants.d.ts} +1 -1
- package/dist/{graphQLImperativeAdapter.d.ts → types/graphQLImperativeAdapter.d.ts} +32 -32
- package/dist/{imperativeAdapter.d.ts → types/imperativeAdapter.d.ts} +31 -31
- package/dist/{instrumentation.d.ts → types/instrumentation.d.ts} +29 -29
- package/dist/{instrumentedAdapter.d.ts → types/instrumentedAdapter.d.ts} +3 -3
- package/dist/{ldsAdapter.d.ts → types/ldsAdapter.d.ts} +7 -7
- package/dist/{main.d.ts → types/main.d.ts} +9 -9
- package/dist/{utils → types/utils}/lanugage.d.ts +5 -5
- package/dist/{utils → types/utils}/snapshotType.d.ts +3 -3
- package/dist/{utils → types/utils}/utils.d.ts +1 -1
- package/dist/{wireAdapter.d.ts → types/wireAdapter.d.ts} +7 -7
- package/package.json +3 -3
package/dist/ldsBindings.js
CHANGED
|
@@ -557,377 +557,377 @@ function safeSanitizeGraphQLConfigObject(config) {
|
|
|
557
557
|
};
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
-
// For use by callers within this module to instrument interesting things.
|
|
561
|
-
let instrumentation = {
|
|
562
|
-
refreshCalled: (_fromSource) => { },
|
|
563
|
-
instrumentAdapter: (adapter, _metadata) => {
|
|
564
|
-
return adapter;
|
|
565
|
-
},
|
|
566
|
-
};
|
|
567
|
-
/**
|
|
568
|
-
* Allows external modules (typically a runtime environment) to set
|
|
569
|
-
* instrumentation hooks for this module. Note that the hooks are
|
|
570
|
-
* incremental - hooks not suppiled in newInstrumentation will retain
|
|
571
|
-
* their previous values. The default instrumentation hooks are no-ops.
|
|
572
|
-
*
|
|
573
|
-
* @param newInstrumentation instrumentation hooks to be overridden
|
|
574
|
-
*/
|
|
575
|
-
function instrument(newInstrumentation) {
|
|
576
|
-
instrumentation = Object.assign(instrumentation, newInstrumentation);
|
|
560
|
+
// For use by callers within this module to instrument interesting things.
|
|
561
|
+
let instrumentation = {
|
|
562
|
+
refreshCalled: (_fromSource) => { },
|
|
563
|
+
instrumentAdapter: (adapter, _metadata) => {
|
|
564
|
+
return adapter;
|
|
565
|
+
},
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* Allows external modules (typically a runtime environment) to set
|
|
569
|
+
* instrumentation hooks for this module. Note that the hooks are
|
|
570
|
+
* incremental - hooks not suppiled in newInstrumentation will retain
|
|
571
|
+
* their previous values. The default instrumentation hooks are no-ops.
|
|
572
|
+
*
|
|
573
|
+
* @param newInstrumentation instrumentation hooks to be overridden
|
|
574
|
+
*/
|
|
575
|
+
function instrument(newInstrumentation) {
|
|
576
|
+
instrumentation = Object.assign(instrumentation, newInstrumentation);
|
|
577
577
|
}
|
|
578
578
|
|
|
579
|
-
let refresh;
|
|
580
|
-
function bindWireRefresh(luvio) {
|
|
581
|
-
const wireRefresh = bindWireRefresh$1(luvio);
|
|
582
|
-
refresh = (data, apiFamily) => {
|
|
583
|
-
instrumentation.refreshCalled(apiFamily);
|
|
584
|
-
return wireRefresh(data);
|
|
585
|
-
};
|
|
579
|
+
let refresh;
|
|
580
|
+
function bindWireRefresh(luvio) {
|
|
581
|
+
const wireRefresh = bindWireRefresh$1(luvio);
|
|
582
|
+
refresh = (data, apiFamily) => {
|
|
583
|
+
instrumentation.refreshCalled(apiFamily);
|
|
584
|
+
return wireRefresh(data);
|
|
585
|
+
};
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
-
function createInstrumentedAdapter(adapter, metadata) {
|
|
589
|
-
return instrumentation.instrumentAdapter(adapter, metadata);
|
|
588
|
+
function createInstrumentedAdapter(adapter, metadata) {
|
|
589
|
+
return instrumentation.instrumentAdapter(adapter, metadata);
|
|
590
590
|
}
|
|
591
591
|
|
|
592
|
-
function createLDSAdapter(luvio, name, factory) {
|
|
593
|
-
return factory(luvio);
|
|
592
|
+
function createLDSAdapter(luvio, name, factory) {
|
|
593
|
+
return factory(luvio);
|
|
594
594
|
}
|
|
595
595
|
|
|
596
596
|
const { create, defineProperty, defineProperties } = Object;
|
|
597
597
|
|
|
598
|
-
var SnapshotState;
|
|
599
|
-
(function (SnapshotState) {
|
|
600
|
-
SnapshotState["Fulfilled"] = "Fulfilled";
|
|
601
|
-
SnapshotState["Unfulfilled"] = "Unfulfilled";
|
|
602
|
-
SnapshotState["Error"] = "Error";
|
|
603
|
-
SnapshotState["Pending"] = "Pending";
|
|
604
|
-
SnapshotState["Stale"] = "Stale";
|
|
605
|
-
})(SnapshotState || (SnapshotState = {}));
|
|
606
|
-
function isErrorSnapshot(snapshot) {
|
|
607
|
-
return snapshot.state === SnapshotState.Error;
|
|
608
|
-
}
|
|
609
|
-
function isPendingSnapshot(snapshot) {
|
|
610
|
-
return snapshot.state === SnapshotState.Pending;
|
|
598
|
+
var SnapshotState;
|
|
599
|
+
(function (SnapshotState) {
|
|
600
|
+
SnapshotState["Fulfilled"] = "Fulfilled";
|
|
601
|
+
SnapshotState["Unfulfilled"] = "Unfulfilled";
|
|
602
|
+
SnapshotState["Error"] = "Error";
|
|
603
|
+
SnapshotState["Pending"] = "Pending";
|
|
604
|
+
SnapshotState["Stale"] = "Stale";
|
|
605
|
+
})(SnapshotState || (SnapshotState = {}));
|
|
606
|
+
function isErrorSnapshot(snapshot) {
|
|
607
|
+
return snapshot.state === SnapshotState.Error;
|
|
608
|
+
}
|
|
609
|
+
function isPendingSnapshot(snapshot) {
|
|
610
|
+
return snapshot.state === SnapshotState.Pending;
|
|
611
611
|
}
|
|
612
612
|
|
|
613
|
-
function isPromise(value) {
|
|
614
|
-
// check for Thenable due to test frameworks using custom Promise impls
|
|
615
|
-
return value !== null && value.then !== undefined;
|
|
613
|
+
function isPromise(value) {
|
|
614
|
+
// check for Thenable due to test frameworks using custom Promise impls
|
|
615
|
+
return value !== null && value.then !== undefined;
|
|
616
616
|
}
|
|
617
617
|
|
|
618
|
-
function snapshotToTuple$1(snapshot) {
|
|
619
|
-
if (isErrorSnapshot(snapshot)) {
|
|
620
|
-
return {
|
|
621
|
-
data: undefined,
|
|
622
|
-
error: snapshot.error,
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
// We might still get pending snapshot here from invoke calls here
|
|
626
|
-
return {
|
|
627
|
-
data: snapshot.data,
|
|
628
|
-
error: undefined,
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
function createInvalidConfigError$1() {
|
|
632
|
-
return {
|
|
633
|
-
data: undefined,
|
|
634
|
-
error: {
|
|
635
|
-
ok: false,
|
|
636
|
-
status: 400,
|
|
637
|
-
statusText: 'INVALID_CONFIG',
|
|
638
|
-
body: undefined,
|
|
639
|
-
headers: {},
|
|
640
|
-
errorType: 'fetchResponse',
|
|
641
|
-
},
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
/**
|
|
645
|
-
* Creates an imperative adapter
|
|
646
|
-
*
|
|
647
|
-
* @param luvio Luvio
|
|
648
|
-
* @param adapter luvio adapter
|
|
649
|
-
* @param metadata AdapterMetadata
|
|
650
|
-
* @returns Imperative adapter object with invoke and subscribe functions
|
|
651
|
-
*/
|
|
652
|
-
function createImperativeAdapter(luvio, adapter, metadata) {
|
|
653
|
-
const { name } = metadata;
|
|
654
|
-
const imperativeAdapterInvoke = (config, requestContext, callback) => {
|
|
655
|
-
const snapshotOrPromise = adapter(config, requestContext);
|
|
656
|
-
if (snapshotOrPromise === null) {
|
|
657
|
-
callback(createInvalidConfigError$1());
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
if (!isPromise(snapshotOrPromise)) {
|
|
661
|
-
callback(snapshotToTuple$1(snapshotOrPromise));
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
snapshotOrPromise.then((snapshot) => {
|
|
665
|
-
if (snapshot === null) {
|
|
666
|
-
callback(createInvalidConfigError$1());
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
callback(snapshotToTuple$1(snapshot));
|
|
670
|
-
});
|
|
671
|
-
};
|
|
672
|
-
defineProperty(imperativeAdapterInvoke, 'name', {
|
|
673
|
-
value: `${name}_invoke`,
|
|
674
|
-
});
|
|
675
|
-
// Invokes the adapter and subscribes to the received snapshot
|
|
676
|
-
// Returns an unsubscribe function to the consumer
|
|
677
|
-
const imperativeAdapterSubscribe = (config, requestContext, callback) => {
|
|
678
|
-
let subscriberCallback = callback;
|
|
679
|
-
let unsub;
|
|
680
|
-
const snapshotOrPromise = adapter(config, requestContext);
|
|
681
|
-
if (snapshotOrPromise === null) {
|
|
682
|
-
subscriberCallback(createInvalidConfigError$1());
|
|
683
|
-
return () => { };
|
|
684
|
-
}
|
|
685
|
-
// Can rebuild lead to pending snapshots?
|
|
686
|
-
const luvioStoreSubscribe = (snapshot) => {
|
|
687
|
-
unsub = luvio.storeSubscribe(snapshot, (snapshotFromRebuild) => {
|
|
688
|
-
if (subscriberCallback !== null && !isPendingSnapshot(snapshotFromRebuild)) {
|
|
689
|
-
subscriberCallback(snapshotToTuple$1(snapshotFromRebuild));
|
|
690
|
-
}
|
|
691
|
-
});
|
|
692
|
-
};
|
|
693
|
-
if (!isPromise(snapshotOrPromise)) {
|
|
694
|
-
// We don't want to return pending snapshots to user-land
|
|
695
|
-
// Instead we just subscribe to it
|
|
696
|
-
if (!isPendingSnapshot(snapshotOrPromise)) {
|
|
697
|
-
subscriberCallback(snapshotToTuple$1(snapshotOrPromise));
|
|
698
|
-
}
|
|
699
|
-
luvioStoreSubscribe(snapshotOrPromise);
|
|
700
|
-
}
|
|
701
|
-
else {
|
|
702
|
-
snapshotOrPromise.then((snapshot) => {
|
|
703
|
-
if (subscriberCallback !== null) {
|
|
704
|
-
if (snapshot === null) {
|
|
705
|
-
subscriberCallback(createInvalidConfigError$1());
|
|
706
|
-
return;
|
|
707
|
-
}
|
|
708
|
-
// We don't want to return pending snapshots to user-land
|
|
709
|
-
// Instead we just subscribe to it
|
|
710
|
-
if (!isPendingSnapshot(snapshot)) {
|
|
711
|
-
subscriberCallback(snapshotToTuple$1(snapshot));
|
|
712
|
-
}
|
|
713
|
-
luvioStoreSubscribe(snapshot);
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
}
|
|
717
|
-
return () => {
|
|
718
|
-
if (subscriberCallback !== null && unsub !== undefined) {
|
|
719
|
-
unsub();
|
|
720
|
-
}
|
|
721
|
-
subscriberCallback = null;
|
|
722
|
-
unsub = undefined;
|
|
723
|
-
};
|
|
724
|
-
};
|
|
725
|
-
defineProperty(imperativeAdapterSubscribe, 'name', {
|
|
726
|
-
value: `${name}_subscribe`,
|
|
727
|
-
});
|
|
728
|
-
return {
|
|
729
|
-
invoke: imperativeAdapterInvoke,
|
|
730
|
-
subscribe: imperativeAdapterSubscribe,
|
|
731
|
-
};
|
|
618
|
+
function snapshotToTuple$1(snapshot) {
|
|
619
|
+
if (isErrorSnapshot(snapshot)) {
|
|
620
|
+
return {
|
|
621
|
+
data: undefined,
|
|
622
|
+
error: snapshot.error,
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
// We might still get pending snapshot here from invoke calls here
|
|
626
|
+
return {
|
|
627
|
+
data: snapshot.data,
|
|
628
|
+
error: undefined,
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
function createInvalidConfigError$1() {
|
|
632
|
+
return {
|
|
633
|
+
data: undefined,
|
|
634
|
+
error: {
|
|
635
|
+
ok: false,
|
|
636
|
+
status: 400,
|
|
637
|
+
statusText: 'INVALID_CONFIG',
|
|
638
|
+
body: undefined,
|
|
639
|
+
headers: {},
|
|
640
|
+
errorType: 'fetchResponse',
|
|
641
|
+
},
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Creates an imperative adapter
|
|
646
|
+
*
|
|
647
|
+
* @param luvio Luvio
|
|
648
|
+
* @param adapter luvio adapter
|
|
649
|
+
* @param metadata AdapterMetadata
|
|
650
|
+
* @returns Imperative adapter object with invoke and subscribe functions
|
|
651
|
+
*/
|
|
652
|
+
function createImperativeAdapter(luvio, adapter, metadata) {
|
|
653
|
+
const { name } = metadata;
|
|
654
|
+
const imperativeAdapterInvoke = (config, requestContext, callback) => {
|
|
655
|
+
const snapshotOrPromise = adapter(config, requestContext);
|
|
656
|
+
if (snapshotOrPromise === null) {
|
|
657
|
+
callback(createInvalidConfigError$1());
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
if (!isPromise(snapshotOrPromise)) {
|
|
661
|
+
callback(snapshotToTuple$1(snapshotOrPromise));
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
snapshotOrPromise.then((snapshot) => {
|
|
665
|
+
if (snapshot === null) {
|
|
666
|
+
callback(createInvalidConfigError$1());
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
callback(snapshotToTuple$1(snapshot));
|
|
670
|
+
});
|
|
671
|
+
};
|
|
672
|
+
defineProperty(imperativeAdapterInvoke, 'name', {
|
|
673
|
+
value: `${name}_invoke`,
|
|
674
|
+
});
|
|
675
|
+
// Invokes the adapter and subscribes to the received snapshot
|
|
676
|
+
// Returns an unsubscribe function to the consumer
|
|
677
|
+
const imperativeAdapterSubscribe = (config, requestContext, callback) => {
|
|
678
|
+
let subscriberCallback = callback;
|
|
679
|
+
let unsub;
|
|
680
|
+
const snapshotOrPromise = adapter(config, requestContext);
|
|
681
|
+
if (snapshotOrPromise === null) {
|
|
682
|
+
subscriberCallback(createInvalidConfigError$1());
|
|
683
|
+
return () => { };
|
|
684
|
+
}
|
|
685
|
+
// Can rebuild lead to pending snapshots?
|
|
686
|
+
const luvioStoreSubscribe = (snapshot) => {
|
|
687
|
+
unsub = luvio.storeSubscribe(snapshot, (snapshotFromRebuild) => {
|
|
688
|
+
if (subscriberCallback !== null && !isPendingSnapshot(snapshotFromRebuild)) {
|
|
689
|
+
subscriberCallback(snapshotToTuple$1(snapshotFromRebuild));
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
};
|
|
693
|
+
if (!isPromise(snapshotOrPromise)) {
|
|
694
|
+
// We don't want to return pending snapshots to user-land
|
|
695
|
+
// Instead we just subscribe to it
|
|
696
|
+
if (!isPendingSnapshot(snapshotOrPromise)) {
|
|
697
|
+
subscriberCallback(snapshotToTuple$1(snapshotOrPromise));
|
|
698
|
+
}
|
|
699
|
+
luvioStoreSubscribe(snapshotOrPromise);
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
snapshotOrPromise.then((snapshot) => {
|
|
703
|
+
if (subscriberCallback !== null) {
|
|
704
|
+
if (snapshot === null) {
|
|
705
|
+
subscriberCallback(createInvalidConfigError$1());
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
// We don't want to return pending snapshots to user-land
|
|
709
|
+
// Instead we just subscribe to it
|
|
710
|
+
if (!isPendingSnapshot(snapshot)) {
|
|
711
|
+
subscriberCallback(snapshotToTuple$1(snapshot));
|
|
712
|
+
}
|
|
713
|
+
luvioStoreSubscribe(snapshot);
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
return () => {
|
|
718
|
+
if (subscriberCallback !== null && unsub !== undefined) {
|
|
719
|
+
unsub();
|
|
720
|
+
}
|
|
721
|
+
subscriberCallback = null;
|
|
722
|
+
unsub = undefined;
|
|
723
|
+
};
|
|
724
|
+
};
|
|
725
|
+
defineProperty(imperativeAdapterSubscribe, 'name', {
|
|
726
|
+
value: `${name}_subscribe`,
|
|
727
|
+
});
|
|
728
|
+
return {
|
|
729
|
+
invoke: imperativeAdapterInvoke,
|
|
730
|
+
subscribe: imperativeAdapterSubscribe,
|
|
731
|
+
};
|
|
732
732
|
}
|
|
733
733
|
|
|
734
|
-
function snapshotToTuple(snapshot) {
|
|
735
|
-
if (isErrorSnapshot(snapshot)) {
|
|
736
|
-
if (snapshot.error.errorType === 'adapterError') {
|
|
737
|
-
// GraphQL can return 200 with an errors array
|
|
738
|
-
return {
|
|
739
|
-
data: undefined,
|
|
740
|
-
errors: snapshot.error.error,
|
|
741
|
-
};
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
// This is a network error or some other error - usually with a single error bubled up.
|
|
745
|
-
return {
|
|
746
|
-
data: undefined,
|
|
747
|
-
errors: [snapshot.error],
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
// cast any PendingSnapshot to FulfilledSnapshot here,
|
|
752
|
-
// we shouldn't get anything pending at this point
|
|
753
|
-
const payload = {};
|
|
754
|
-
const dataSnapshot = snapshot;
|
|
755
|
-
if ('data' in dataSnapshot.data && dataSnapshot.data.data !== undefined) {
|
|
756
|
-
payload.data = dataSnapshot.data.data;
|
|
757
|
-
}
|
|
758
|
-
if (dataSnapshot.data.errors !== undefined) {
|
|
759
|
-
payload.errors = dataSnapshot.data.errors;
|
|
760
|
-
}
|
|
761
|
-
return payload;
|
|
762
|
-
}
|
|
763
|
-
function createInvalidConfigError() {
|
|
764
|
-
return {
|
|
765
|
-
data: undefined,
|
|
766
|
-
errors: [
|
|
767
|
-
{
|
|
768
|
-
ok: false,
|
|
769
|
-
status: 400,
|
|
770
|
-
statusText: 'INVALID_CONFIG',
|
|
771
|
-
body: undefined,
|
|
772
|
-
headers: {},
|
|
773
|
-
errorType: 'fetchResponse',
|
|
774
|
-
},
|
|
775
|
-
],
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
/**
|
|
779
|
-
* Creates an imperative adapter
|
|
780
|
-
*
|
|
781
|
-
* @param luvio Luvio
|
|
782
|
-
* @param adapter luvio adapter
|
|
783
|
-
* @param metadata AdapterMetadata
|
|
784
|
-
* @returns Imperative adapter object with invoke and subscribe functions
|
|
785
|
-
*/
|
|
786
|
-
function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
|
|
787
|
-
const { name } = metadata;
|
|
788
|
-
const imperativeAdapterInvoke = (config, requestContext, callback) => {
|
|
789
|
-
let coercedConfig = null;
|
|
790
|
-
if ('batchQuery' in config) {
|
|
791
|
-
coercedConfig = {
|
|
792
|
-
batchQuery: config.batchQuery.map((individualConfig) => ({
|
|
793
|
-
...individualConfig,
|
|
794
|
-
query: astResolver(individualConfig.query),
|
|
795
|
-
})),
|
|
796
|
-
};
|
|
797
|
-
// If any of the configurations are invalid, we bail out of calling the adapter.
|
|
798
|
-
if (coercedConfig.batchQuery.some((individualConfig) => individualConfig.query === undefined)) {
|
|
799
|
-
callback(createInvalidConfigError());
|
|
800
|
-
return;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
else if ('query' in config) {
|
|
804
|
-
const ast = astResolver(config.query);
|
|
805
|
-
if (ast === undefined) {
|
|
806
|
-
callback(createInvalidConfigError());
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
coercedConfig = {
|
|
810
|
-
...config,
|
|
811
|
-
query: ast,
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
const snapshotOrPromise = adapter(coercedConfig, requestContext);
|
|
815
|
-
if (snapshotOrPromise === null) {
|
|
816
|
-
callback(createInvalidConfigError());
|
|
817
|
-
return;
|
|
818
|
-
}
|
|
819
|
-
if (!isPromise(snapshotOrPromise)) {
|
|
820
|
-
callback(snapshotToTuple(snapshotOrPromise));
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
snapshotOrPromise.then((snapshot) => {
|
|
824
|
-
if (snapshot === null) {
|
|
825
|
-
callback(createInvalidConfigError());
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
callback(snapshotToTuple(snapshot));
|
|
829
|
-
});
|
|
830
|
-
};
|
|
831
|
-
defineProperty(imperativeAdapterInvoke, 'name', {
|
|
832
|
-
value: `${name}_invoke`,
|
|
833
|
-
});
|
|
834
|
-
// Invokes the adapter and subscribes to the received snapshot
|
|
835
|
-
// Returns an unsubscribe function to the consumer
|
|
836
|
-
const imperativeAdapterSubscribe = (config, requestContext, callback) => {
|
|
837
|
-
let subscriberCallback = callback;
|
|
838
|
-
let unsub;
|
|
839
|
-
let coercedConfig = null;
|
|
840
|
-
if ('batchQuery' in config) {
|
|
841
|
-
coercedConfig = {
|
|
842
|
-
batchQuery: config.batchQuery.map((individualConfig) => ({
|
|
843
|
-
...individualConfig,
|
|
844
|
-
query: astResolver(individualConfig.query),
|
|
845
|
-
})),
|
|
846
|
-
};
|
|
847
|
-
// If any of the configurations are invalid, we bail out of calling the adapter.
|
|
848
|
-
if (coercedConfig.batchQuery.some((individualConfig) => individualConfig.query === undefined)) {
|
|
849
|
-
callback(createInvalidConfigError());
|
|
850
|
-
return () => { };
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
else if ('query' in config) {
|
|
854
|
-
const ast = astResolver(config.query);
|
|
855
|
-
if (ast === undefined) {
|
|
856
|
-
callback(createInvalidConfigError());
|
|
857
|
-
return () => { };
|
|
858
|
-
}
|
|
859
|
-
coercedConfig = {
|
|
860
|
-
...config,
|
|
861
|
-
query: ast,
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
const snapshotOrPromise = adapter(coercedConfig, requestContext);
|
|
865
|
-
if (snapshotOrPromise === null) {
|
|
866
|
-
subscriberCallback(createInvalidConfigError());
|
|
867
|
-
return () => { };
|
|
868
|
-
}
|
|
869
|
-
// Can rebuild lead to pending snapshots?
|
|
870
|
-
const luvioStoreSubscribe = (snapshot) => {
|
|
871
|
-
unsub = luvio.storeSubscribe(snapshot, (snapshotFromRebuild) => {
|
|
872
|
-
if (subscriberCallback !== null && !isPendingSnapshot(snapshotFromRebuild)) {
|
|
873
|
-
subscriberCallback(snapshotToTuple(snapshotFromRebuild));
|
|
874
|
-
}
|
|
875
|
-
});
|
|
876
|
-
};
|
|
877
|
-
if (!isPromise(snapshotOrPromise)) {
|
|
878
|
-
// We don't want to return pending snapshots to user-land
|
|
879
|
-
// Instead we just subscribe to it
|
|
880
|
-
if (!isPendingSnapshot(snapshotOrPromise)) {
|
|
881
|
-
subscriberCallback(snapshotToTuple(snapshotOrPromise));
|
|
882
|
-
}
|
|
883
|
-
luvioStoreSubscribe(snapshotOrPromise);
|
|
884
|
-
}
|
|
885
|
-
else {
|
|
886
|
-
snapshotOrPromise.then((snapshot) => {
|
|
887
|
-
if (subscriberCallback !== null) {
|
|
888
|
-
if (snapshot === null) {
|
|
889
|
-
subscriberCallback(createInvalidConfigError());
|
|
890
|
-
return;
|
|
891
|
-
}
|
|
892
|
-
// TODO [W-11370904]: revisit this. Does GraphQL need to worry about pending?
|
|
893
|
-
// We don't want to return pending snapshots to user-land
|
|
894
|
-
// Instead we just subscribe to it
|
|
895
|
-
if (!isPendingSnapshot(snapshot)) {
|
|
896
|
-
subscriberCallback(snapshotToTuple(snapshot));
|
|
897
|
-
}
|
|
898
|
-
luvioStoreSubscribe(snapshot);
|
|
899
|
-
}
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
return () => {
|
|
903
|
-
if (subscriberCallback !== null && unsub !== undefined) {
|
|
904
|
-
unsub();
|
|
905
|
-
}
|
|
906
|
-
subscriberCallback = null;
|
|
907
|
-
unsub = undefined;
|
|
908
|
-
};
|
|
909
|
-
};
|
|
910
|
-
defineProperty(imperativeAdapterSubscribe, 'name', {
|
|
911
|
-
value: `${name}_subscribe`,
|
|
912
|
-
});
|
|
913
|
-
return {
|
|
914
|
-
invoke: imperativeAdapterInvoke,
|
|
915
|
-
subscribe: imperativeAdapterSubscribe,
|
|
916
|
-
};
|
|
734
|
+
function snapshotToTuple(snapshot) {
|
|
735
|
+
if (isErrorSnapshot(snapshot)) {
|
|
736
|
+
if (snapshot.error.errorType === 'adapterError') {
|
|
737
|
+
// GraphQL can return 200 with an errors array
|
|
738
|
+
return {
|
|
739
|
+
data: undefined,
|
|
740
|
+
errors: snapshot.error.error,
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
// This is a network error or some other error - usually with a single error bubled up.
|
|
745
|
+
return {
|
|
746
|
+
data: undefined,
|
|
747
|
+
errors: [snapshot.error],
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
// cast any PendingSnapshot to FulfilledSnapshot here,
|
|
752
|
+
// we shouldn't get anything pending at this point
|
|
753
|
+
const payload = {};
|
|
754
|
+
const dataSnapshot = snapshot;
|
|
755
|
+
if ('data' in dataSnapshot.data && dataSnapshot.data.data !== undefined) {
|
|
756
|
+
payload.data = dataSnapshot.data.data;
|
|
757
|
+
}
|
|
758
|
+
if (dataSnapshot.data.errors !== undefined) {
|
|
759
|
+
payload.errors = dataSnapshot.data.errors;
|
|
760
|
+
}
|
|
761
|
+
return payload;
|
|
762
|
+
}
|
|
763
|
+
function createInvalidConfigError() {
|
|
764
|
+
return {
|
|
765
|
+
data: undefined,
|
|
766
|
+
errors: [
|
|
767
|
+
{
|
|
768
|
+
ok: false,
|
|
769
|
+
status: 400,
|
|
770
|
+
statusText: 'INVALID_CONFIG',
|
|
771
|
+
body: undefined,
|
|
772
|
+
headers: {},
|
|
773
|
+
errorType: 'fetchResponse',
|
|
774
|
+
},
|
|
775
|
+
],
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Creates an imperative adapter
|
|
780
|
+
*
|
|
781
|
+
* @param luvio Luvio
|
|
782
|
+
* @param adapter luvio adapter
|
|
783
|
+
* @param metadata AdapterMetadata
|
|
784
|
+
* @returns Imperative adapter object with invoke and subscribe functions
|
|
785
|
+
*/
|
|
786
|
+
function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
|
|
787
|
+
const { name } = metadata;
|
|
788
|
+
const imperativeAdapterInvoke = (config, requestContext, callback) => {
|
|
789
|
+
let coercedConfig = null;
|
|
790
|
+
if ('batchQuery' in config) {
|
|
791
|
+
coercedConfig = {
|
|
792
|
+
batchQuery: config.batchQuery.map((individualConfig) => ({
|
|
793
|
+
...individualConfig,
|
|
794
|
+
query: astResolver(individualConfig.query),
|
|
795
|
+
})),
|
|
796
|
+
};
|
|
797
|
+
// If any of the configurations are invalid, we bail out of calling the adapter.
|
|
798
|
+
if (coercedConfig.batchQuery.some((individualConfig) => individualConfig.query === undefined)) {
|
|
799
|
+
callback(createInvalidConfigError());
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
else if ('query' in config) {
|
|
804
|
+
const ast = astResolver(config.query);
|
|
805
|
+
if (ast === undefined) {
|
|
806
|
+
callback(createInvalidConfigError());
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
coercedConfig = {
|
|
810
|
+
...config,
|
|
811
|
+
query: ast,
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
const snapshotOrPromise = adapter(coercedConfig, requestContext);
|
|
815
|
+
if (snapshotOrPromise === null) {
|
|
816
|
+
callback(createInvalidConfigError());
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
if (!isPromise(snapshotOrPromise)) {
|
|
820
|
+
callback(snapshotToTuple(snapshotOrPromise));
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
snapshotOrPromise.then((snapshot) => {
|
|
824
|
+
if (snapshot === null) {
|
|
825
|
+
callback(createInvalidConfigError());
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
callback(snapshotToTuple(snapshot));
|
|
829
|
+
});
|
|
830
|
+
};
|
|
831
|
+
defineProperty(imperativeAdapterInvoke, 'name', {
|
|
832
|
+
value: `${name}_invoke`,
|
|
833
|
+
});
|
|
834
|
+
// Invokes the adapter and subscribes to the received snapshot
|
|
835
|
+
// Returns an unsubscribe function to the consumer
|
|
836
|
+
const imperativeAdapterSubscribe = (config, requestContext, callback) => {
|
|
837
|
+
let subscriberCallback = callback;
|
|
838
|
+
let unsub;
|
|
839
|
+
let coercedConfig = null;
|
|
840
|
+
if ('batchQuery' in config) {
|
|
841
|
+
coercedConfig = {
|
|
842
|
+
batchQuery: config.batchQuery.map((individualConfig) => ({
|
|
843
|
+
...individualConfig,
|
|
844
|
+
query: astResolver(individualConfig.query),
|
|
845
|
+
})),
|
|
846
|
+
};
|
|
847
|
+
// If any of the configurations are invalid, we bail out of calling the adapter.
|
|
848
|
+
if (coercedConfig.batchQuery.some((individualConfig) => individualConfig.query === undefined)) {
|
|
849
|
+
callback(createInvalidConfigError());
|
|
850
|
+
return () => { };
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
else if ('query' in config) {
|
|
854
|
+
const ast = astResolver(config.query);
|
|
855
|
+
if (ast === undefined) {
|
|
856
|
+
callback(createInvalidConfigError());
|
|
857
|
+
return () => { };
|
|
858
|
+
}
|
|
859
|
+
coercedConfig = {
|
|
860
|
+
...config,
|
|
861
|
+
query: ast,
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
const snapshotOrPromise = adapter(coercedConfig, requestContext);
|
|
865
|
+
if (snapshotOrPromise === null) {
|
|
866
|
+
subscriberCallback(createInvalidConfigError());
|
|
867
|
+
return () => { };
|
|
868
|
+
}
|
|
869
|
+
// Can rebuild lead to pending snapshots?
|
|
870
|
+
const luvioStoreSubscribe = (snapshot) => {
|
|
871
|
+
unsub = luvio.storeSubscribe(snapshot, (snapshotFromRebuild) => {
|
|
872
|
+
if (subscriberCallback !== null && !isPendingSnapshot(snapshotFromRebuild)) {
|
|
873
|
+
subscriberCallback(snapshotToTuple(snapshotFromRebuild));
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
};
|
|
877
|
+
if (!isPromise(snapshotOrPromise)) {
|
|
878
|
+
// We don't want to return pending snapshots to user-land
|
|
879
|
+
// Instead we just subscribe to it
|
|
880
|
+
if (!isPendingSnapshot(snapshotOrPromise)) {
|
|
881
|
+
subscriberCallback(snapshotToTuple(snapshotOrPromise));
|
|
882
|
+
}
|
|
883
|
+
luvioStoreSubscribe(snapshotOrPromise);
|
|
884
|
+
}
|
|
885
|
+
else {
|
|
886
|
+
snapshotOrPromise.then((snapshot) => {
|
|
887
|
+
if (subscriberCallback !== null) {
|
|
888
|
+
if (snapshot === null) {
|
|
889
|
+
subscriberCallback(createInvalidConfigError());
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
// TODO [W-11370904]: revisit this. Does GraphQL need to worry about pending?
|
|
893
|
+
// We don't want to return pending snapshots to user-land
|
|
894
|
+
// Instead we just subscribe to it
|
|
895
|
+
if (!isPendingSnapshot(snapshot)) {
|
|
896
|
+
subscriberCallback(snapshotToTuple(snapshot));
|
|
897
|
+
}
|
|
898
|
+
luvioStoreSubscribe(snapshot);
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
return () => {
|
|
903
|
+
if (subscriberCallback !== null && unsub !== undefined) {
|
|
904
|
+
unsub();
|
|
905
|
+
}
|
|
906
|
+
subscriberCallback = null;
|
|
907
|
+
unsub = undefined;
|
|
908
|
+
};
|
|
909
|
+
};
|
|
910
|
+
defineProperty(imperativeAdapterSubscribe, 'name', {
|
|
911
|
+
value: `${name}_subscribe`,
|
|
912
|
+
});
|
|
913
|
+
return {
|
|
914
|
+
invoke: imperativeAdapterInvoke,
|
|
915
|
+
subscribe: imperativeAdapterSubscribe,
|
|
916
|
+
};
|
|
917
917
|
}
|
|
918
918
|
|
|
919
|
-
function createWireAdapterConstructor(luvio, adapter, metadata) {
|
|
920
|
-
const { apiFamily, name } = metadata;
|
|
921
|
-
return createWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio);
|
|
922
|
-
}
|
|
923
|
-
function createInfiniteScrollingWireAdapterConstructor(luvio, adapter, metadata) {
|
|
924
|
-
const { apiFamily, name } = metadata;
|
|
925
|
-
return createInfiniteScrollingWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio);
|
|
926
|
-
}
|
|
927
|
-
function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolver) {
|
|
928
|
-
const { apiFamily, name } = metadata;
|
|
929
|
-
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
919
|
+
function createWireAdapterConstructor(luvio, adapter, metadata) {
|
|
920
|
+
const { apiFamily, name } = metadata;
|
|
921
|
+
return createWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio);
|
|
922
|
+
}
|
|
923
|
+
function createInfiniteScrollingWireAdapterConstructor(luvio, adapter, metadata) {
|
|
924
|
+
const { apiFamily, name } = metadata;
|
|
925
|
+
return createInfiniteScrollingWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio);
|
|
926
|
+
}
|
|
927
|
+
function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolver) {
|
|
928
|
+
const { apiFamily, name } = metadata;
|
|
929
|
+
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
930
930
|
}
|
|
931
931
|
|
|
932
932
|
export { ADAPTER_UNFULFILLED_ERROR, REFRESH_ADAPTER_EVENT, bindWireRefresh, createGraphQLImperativeAdapter, createGraphQLWireAdapterConstructor, createImperativeAdapter, createInfiniteScrollingWireAdapterConstructor, createInstrumentedAdapter, createLDSAdapter, createWireAdapterConstructor, instrument, refresh };
|
|
933
|
-
// version: 1.124.
|
|
933
|
+
// version: 1.124.3-cf2dbb2fa
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Luvio } from '@luvio/engine';
|
|
2
|
-
export type refreshApiNames = {
|
|
3
|
-
refreshApex: string;
|
|
4
|
-
refreshUiApi: string;
|
|
5
|
-
};
|
|
6
|
-
export declare let refresh: (data: any, apiFamily: keyof refreshApiNames) => Promise<undefined> | undefined;
|
|
7
|
-
export declare function bindWireRefresh(luvio: Luvio): void;
|
|
1
|
+
import type { Luvio } from '@luvio/engine';
|
|
2
|
+
export type refreshApiNames = {
|
|
3
|
+
refreshApex: string;
|
|
4
|
+
refreshUiApi: string;
|
|
5
|
+
};
|
|
6
|
+
export declare let refresh: (data: any, apiFamily: keyof refreshApiNames) => Promise<undefined> | undefined;
|
|
7
|
+
export declare function bindWireRefresh(luvio: Luvio): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR } from '@luvio/lwc-luvio';
|
|
1
|
+
export { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR } from '@luvio/lwc-luvio';
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import type { Adapter, AdapterRequestContext, ErrorResponse as LuvioErrorResponse, Luvio, Unsubscribe } from '@luvio/engine';
|
|
2
|
-
import type { AstResolver } from '@luvio/graphql-parser';
|
|
3
|
-
import type { GraphQLError, GraphQLInput } from '@luvio/lwc-luvio';
|
|
4
|
-
import type { AdapterMetadata } from './ldsAdapter';
|
|
5
|
-
interface DataResponse {
|
|
6
|
-
data: any;
|
|
7
|
-
errors?: GraphQLError[];
|
|
8
|
-
}
|
|
9
|
-
interface ErrorResponse {
|
|
10
|
-
data: undefined;
|
|
11
|
-
errors: LuvioErrorResponse[];
|
|
12
|
-
}
|
|
13
|
-
type DataCallbackTuple = DataResponse | ErrorResponse;
|
|
14
|
-
interface DataCallback {
|
|
15
|
-
(response: DataCallbackTuple): void;
|
|
16
|
-
}
|
|
17
|
-
type ImperativeAdapterInvokeType<C> = (config: C, context: AdapterRequestContext, callback: DataCallback) => void;
|
|
18
|
-
type ImperativeAdapterSubscribeType<C> = (config: C, context: AdapterRequestContext, callback: DataCallback) => Unsubscribe;
|
|
19
|
-
interface ImperativeAdapter<C> {
|
|
20
|
-
invoke: ImperativeAdapterInvokeType<C>;
|
|
21
|
-
subscribe: ImperativeAdapterSubscribeType<C>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Creates an imperative adapter
|
|
25
|
-
*
|
|
26
|
-
* @param luvio Luvio
|
|
27
|
-
* @param adapter luvio adapter
|
|
28
|
-
* @param metadata AdapterMetadata
|
|
29
|
-
* @returns Imperative adapter object with invoke and subscribe functions
|
|
30
|
-
*/
|
|
31
|
-
export declare function createGraphQLImperativeAdapter<C extends GraphQLInput, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata, astResolver: AstResolver): ImperativeAdapter<C>;
|
|
32
|
-
export {};
|
|
1
|
+
import type { Adapter, AdapterRequestContext, ErrorResponse as LuvioErrorResponse, Luvio, Unsubscribe } from '@luvio/engine';
|
|
2
|
+
import type { AstResolver } from '@luvio/graphql-parser';
|
|
3
|
+
import type { GraphQLError, GraphQLInput } from '@luvio/lwc-luvio';
|
|
4
|
+
import type { AdapterMetadata } from './ldsAdapter';
|
|
5
|
+
interface DataResponse {
|
|
6
|
+
data: any;
|
|
7
|
+
errors?: GraphQLError[];
|
|
8
|
+
}
|
|
9
|
+
interface ErrorResponse {
|
|
10
|
+
data: undefined;
|
|
11
|
+
errors: LuvioErrorResponse[];
|
|
12
|
+
}
|
|
13
|
+
type DataCallbackTuple = DataResponse | ErrorResponse;
|
|
14
|
+
interface DataCallback {
|
|
15
|
+
(response: DataCallbackTuple): void;
|
|
16
|
+
}
|
|
17
|
+
type ImperativeAdapterInvokeType<C> = (config: C, context: AdapterRequestContext, callback: DataCallback) => void;
|
|
18
|
+
type ImperativeAdapterSubscribeType<C> = (config: C, context: AdapterRequestContext, callback: DataCallback) => Unsubscribe;
|
|
19
|
+
interface ImperativeAdapter<C> {
|
|
20
|
+
invoke: ImperativeAdapterInvokeType<C>;
|
|
21
|
+
subscribe: ImperativeAdapterSubscribeType<C>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates an imperative adapter
|
|
25
|
+
*
|
|
26
|
+
* @param luvio Luvio
|
|
27
|
+
* @param adapter luvio adapter
|
|
28
|
+
* @param metadata AdapterMetadata
|
|
29
|
+
* @returns Imperative adapter object with invoke and subscribe functions
|
|
30
|
+
*/
|
|
31
|
+
export declare function createGraphQLImperativeAdapter<C extends GraphQLInput, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata, astResolver: AstResolver): ImperativeAdapter<C>;
|
|
32
|
+
export {};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import type { Adapter, AdapterRequestContext, ErrorResponse as LuvioErrorResponse, Luvio, Snapshot, StaleSnapshot, UnfulfilledSnapshot, Unsubscribe } from '@luvio/engine';
|
|
2
|
-
import type { AdapterMetadata } from './ldsAdapter';
|
|
3
|
-
interface DataResponse<D> {
|
|
4
|
-
data: D;
|
|
5
|
-
error: undefined;
|
|
6
|
-
}
|
|
7
|
-
interface ErrorResponse {
|
|
8
|
-
data: undefined;
|
|
9
|
-
error: LuvioErrorResponse;
|
|
10
|
-
}
|
|
11
|
-
export type DataCallbackTuple<D> = DataResponse<D> | ErrorResponse;
|
|
12
|
-
export type CallbackSnapshot<D> = Exclude<Snapshot<D>, UnfulfilledSnapshot<D> | StaleSnapshot<D>>;
|
|
13
|
-
export interface DataCallback<D> {
|
|
14
|
-
(response: DataCallbackTuple<D>): void;
|
|
15
|
-
}
|
|
16
|
-
type ImperativeAdapterInvokeType<C, D> = (config: C, context: AdapterRequestContext | undefined, callback: DataCallback<D>) => void;
|
|
17
|
-
type ImperativeAdapterSubscribeType<C, D> = (config: C, context: AdapterRequestContext | undefined, callback: DataCallback<D>) => Unsubscribe;
|
|
18
|
-
export interface ImperativeAdapter<C, D> {
|
|
19
|
-
invoke: ImperativeAdapterInvokeType<C, D>;
|
|
20
|
-
subscribe: ImperativeAdapterSubscribeType<C, D>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Creates an imperative adapter
|
|
24
|
-
*
|
|
25
|
-
* @param luvio Luvio
|
|
26
|
-
* @param adapter luvio adapter
|
|
27
|
-
* @param metadata AdapterMetadata
|
|
28
|
-
* @returns Imperative adapter object with invoke and subscribe functions
|
|
29
|
-
*/
|
|
30
|
-
export declare function createImperativeAdapter<C, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata): ImperativeAdapter<C, D>;
|
|
31
|
-
export {};
|
|
1
|
+
import type { Adapter, AdapterRequestContext, ErrorResponse as LuvioErrorResponse, Luvio, Snapshot, StaleSnapshot, UnfulfilledSnapshot, Unsubscribe } from '@luvio/engine';
|
|
2
|
+
import type { AdapterMetadata } from './ldsAdapter';
|
|
3
|
+
interface DataResponse<D> {
|
|
4
|
+
data: D;
|
|
5
|
+
error: undefined;
|
|
6
|
+
}
|
|
7
|
+
interface ErrorResponse {
|
|
8
|
+
data: undefined;
|
|
9
|
+
error: LuvioErrorResponse;
|
|
10
|
+
}
|
|
11
|
+
export type DataCallbackTuple<D> = DataResponse<D> | ErrorResponse;
|
|
12
|
+
export type CallbackSnapshot<D> = Exclude<Snapshot<D>, UnfulfilledSnapshot<D> | StaleSnapshot<D>>;
|
|
13
|
+
export interface DataCallback<D> {
|
|
14
|
+
(response: DataCallbackTuple<D>): void;
|
|
15
|
+
}
|
|
16
|
+
type ImperativeAdapterInvokeType<C, D> = (config: C, context: AdapterRequestContext | undefined, callback: DataCallback<D>) => void;
|
|
17
|
+
type ImperativeAdapterSubscribeType<C, D> = (config: C, context: AdapterRequestContext | undefined, callback: DataCallback<D>) => Unsubscribe;
|
|
18
|
+
export interface ImperativeAdapter<C, D> {
|
|
19
|
+
invoke: ImperativeAdapterInvokeType<C, D>;
|
|
20
|
+
subscribe: ImperativeAdapterSubscribeType<C, D>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates an imperative adapter
|
|
24
|
+
*
|
|
25
|
+
* @param luvio Luvio
|
|
26
|
+
* @param adapter luvio adapter
|
|
27
|
+
* @param metadata AdapterMetadata
|
|
28
|
+
* @returns Imperative adapter object with invoke and subscribe functions
|
|
29
|
+
*/
|
|
30
|
+
export declare function createImperativeAdapter<C, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata): ImperativeAdapter<C, D>;
|
|
31
|
+
export {};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import type { Adapter } from '@luvio/engine';
|
|
2
|
-
import type { AdapterMetadata } from './ldsAdapter';
|
|
3
|
-
import type { refreshApiNames } from './bindWireRefresh';
|
|
4
|
-
/**
|
|
5
|
-
* Instrumentation hooks exposed by this module.
|
|
6
|
-
*/
|
|
7
|
-
export interface LwcBindingsInstrumentation {
|
|
8
|
-
/**
|
|
9
|
-
* Called when an LWC calls `refresh`.
|
|
10
|
-
*/
|
|
11
|
-
refreshCalled?: (fromSource: keyof refreshApiNames) => void;
|
|
12
|
-
/**
|
|
13
|
-
* Called when creating wire adapters.
|
|
14
|
-
*/
|
|
15
|
-
instrumentAdapter?: <C, D>(adapter: Adapter<C, D>, metadata: AdapterMetadata) => Adapter<C, D>;
|
|
16
|
-
}
|
|
17
|
-
export declare let instrumentation: {
|
|
18
|
-
refreshCalled: (_fromSource: keyof refreshApiNames) => void;
|
|
19
|
-
instrumentAdapter: <C, D>(adapter: Adapter<C, D>, _metadata: AdapterMetadata) => Adapter<C, D>;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Allows external modules (typically a runtime environment) to set
|
|
23
|
-
* instrumentation hooks for this module. Note that the hooks are
|
|
24
|
-
* incremental - hooks not suppiled in newInstrumentation will retain
|
|
25
|
-
* their previous values. The default instrumentation hooks are no-ops.
|
|
26
|
-
*
|
|
27
|
-
* @param newInstrumentation instrumentation hooks to be overridden
|
|
28
|
-
*/
|
|
29
|
-
export declare function instrument(newInstrumentation: LwcBindingsInstrumentation): void;
|
|
1
|
+
import type { Adapter } from '@luvio/engine';
|
|
2
|
+
import type { AdapterMetadata } from './ldsAdapter';
|
|
3
|
+
import type { refreshApiNames } from './bindWireRefresh';
|
|
4
|
+
/**
|
|
5
|
+
* Instrumentation hooks exposed by this module.
|
|
6
|
+
*/
|
|
7
|
+
export interface LwcBindingsInstrumentation {
|
|
8
|
+
/**
|
|
9
|
+
* Called when an LWC calls `refresh`.
|
|
10
|
+
*/
|
|
11
|
+
refreshCalled?: (fromSource: keyof refreshApiNames) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Called when creating wire adapters.
|
|
14
|
+
*/
|
|
15
|
+
instrumentAdapter?: <C, D>(adapter: Adapter<C, D>, metadata: AdapterMetadata) => Adapter<C, D>;
|
|
16
|
+
}
|
|
17
|
+
export declare let instrumentation: {
|
|
18
|
+
refreshCalled: (_fromSource: keyof refreshApiNames) => void;
|
|
19
|
+
instrumentAdapter: <C, D>(adapter: Adapter<C, D>, _metadata: AdapterMetadata) => Adapter<C, D>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Allows external modules (typically a runtime environment) to set
|
|
23
|
+
* instrumentation hooks for this module. Note that the hooks are
|
|
24
|
+
* incremental - hooks not suppiled in newInstrumentation will retain
|
|
25
|
+
* their previous values. The default instrumentation hooks are no-ops.
|
|
26
|
+
*
|
|
27
|
+
* @param newInstrumentation instrumentation hooks to be overridden
|
|
28
|
+
*/
|
|
29
|
+
export declare function instrument(newInstrumentation: LwcBindingsInstrumentation): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Adapter } from '@luvio/engine';
|
|
2
|
-
import type { AdapterMetadata } from './ldsAdapter';
|
|
3
|
-
export declare function createInstrumentedAdapter<C, D>(adapter: Adapter<C, D>, metadata: AdapterMetadata): Adapter<C, D>;
|
|
1
|
+
import type { Adapter } from '@luvio/engine';
|
|
2
|
+
import type { AdapterMetadata } from './ldsAdapter';
|
|
3
|
+
export declare function createInstrumentedAdapter<C, D>(adapter: Adapter<C, D>, metadata: AdapterMetadata): Adapter<C, D>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Luvio } from '@luvio/engine';
|
|
2
|
-
export interface AdapterMetadata {
|
|
3
|
-
apiFamily: string;
|
|
4
|
-
name: string;
|
|
5
|
-
ttl?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare function createLDSAdapter<T>(luvio: Luvio, name: string, factory: (luvio: Luvio) => T): T;
|
|
1
|
+
import type { Luvio } from '@luvio/engine';
|
|
2
|
+
export interface AdapterMetadata {
|
|
3
|
+
apiFamily: string;
|
|
4
|
+
name: string;
|
|
5
|
+
ttl?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function createLDSAdapter<T>(luvio: Luvio, name: string, factory: (luvio: Luvio) => T): T;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { bindWireRefresh, refresh } from './bindWireRefresh';
|
|
2
|
-
export { LwcBindingsInstrumentation, instrument } from './instrumentation';
|
|
3
|
-
export { createInstrumentedAdapter } from './instrumentedAdapter';
|
|
4
|
-
export { AdapterMetadata, createLDSAdapter } from './ldsAdapter';
|
|
5
|
-
export { createImperativeAdapter } from './imperativeAdapter';
|
|
6
|
-
export { createGraphQLImperativeAdapter } from './graphQLImperativeAdapter';
|
|
7
|
-
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, } from './wireAdapter';
|
|
8
|
-
export { DataCallback, DataCallbackTuple, ImperativeAdapter } from './imperativeAdapter';
|
|
9
|
-
export { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR } from './constants';
|
|
1
|
+
export { bindWireRefresh, refresh } from './bindWireRefresh';
|
|
2
|
+
export { LwcBindingsInstrumentation, instrument } from './instrumentation';
|
|
3
|
+
export { createInstrumentedAdapter } from './instrumentedAdapter';
|
|
4
|
+
export { AdapterMetadata, createLDSAdapter } from './ldsAdapter';
|
|
5
|
+
export { createImperativeAdapter } from './imperativeAdapter';
|
|
6
|
+
export { createGraphQLImperativeAdapter } from './graphQLImperativeAdapter';
|
|
7
|
+
export { createWireAdapterConstructor, createInfiniteScrollingWireAdapterConstructor, createGraphQLWireAdapterConstructor, } from './wireAdapter';
|
|
8
|
+
export { DataCallback, DataCallbackTuple, ImperativeAdapter } from './imperativeAdapter';
|
|
9
|
+
export { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR } from './constants';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const create: {
|
|
2
|
-
(o: object | null): any;
|
|
3
|
-
(o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
|
|
4
|
-
}, defineProperty: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T, defineProperties: <T>(o: T, properties: PropertyDescriptorMap & ThisType<any>) => T;
|
|
5
|
-
export { create as ObjectCreate, defineProperty as ObjectDefineProperty, defineProperties as ObjectDefineProperties, };
|
|
1
|
+
declare const create: {
|
|
2
|
+
(o: object | null): any;
|
|
3
|
+
(o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
|
|
4
|
+
}, defineProperty: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T, defineProperties: <T>(o: T, properties: PropertyDescriptorMap & ThisType<any>) => T;
|
|
5
|
+
export { create as ObjectCreate, defineProperty as ObjectDefineProperty, defineProperties as ObjectDefineProperties, };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ErrorSnapshot, PendingSnapshot, Snapshot } from '@luvio/engine';
|
|
2
|
-
export declare function isErrorSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is ErrorSnapshot;
|
|
3
|
-
export declare function isPendingSnapshot<D>(snapshot: Snapshot<D, unknown>): snapshot is PendingSnapshot<D>;
|
|
1
|
+
import type { ErrorSnapshot, PendingSnapshot, Snapshot } from '@luvio/engine';
|
|
2
|
+
export declare function isErrorSnapshot(snapshot: Snapshot<unknown, unknown>): snapshot is ErrorSnapshot;
|
|
3
|
+
export declare function isPendingSnapshot<D>(snapshot: Snapshot<D, unknown>): snapshot is PendingSnapshot<D>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function isPromise<D>(value: D | Promise<D> | null): value is Promise<D>;
|
|
1
|
+
export declare function isPromise<D>(value: D | Promise<D> | null): value is Promise<D>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
-
import type { WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
-
import type { AdapterMetadata } from './ldsAdapter';
|
|
4
|
-
import type { AstResolver } from '@luvio/graphql-parser';
|
|
5
|
-
export declare function createWireAdapterConstructor<C, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata): WireAdapterConstructor;
|
|
6
|
-
export declare function createInfiniteScrollingWireAdapterConstructor<C, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata): WireAdapterConstructor;
|
|
7
|
-
export declare function createGraphQLWireAdapterConstructor<C, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata, astResolver: AstResolver): WireAdapterConstructor;
|
|
1
|
+
import type { Adapter, Luvio } from '@luvio/engine';
|
|
2
|
+
import type { WireAdapterConstructor } from '@lwc/engine-core';
|
|
3
|
+
import type { AdapterMetadata } from './ldsAdapter';
|
|
4
|
+
import type { AstResolver } from '@luvio/graphql-parser';
|
|
5
|
+
export declare function createWireAdapterConstructor<C, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata): WireAdapterConstructor;
|
|
6
|
+
export declare function createInfiniteScrollingWireAdapterConstructor<C, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata): WireAdapterConstructor;
|
|
7
|
+
export declare function createGraphQLWireAdapterConstructor<C, D>(luvio: Luvio, adapter: Adapter<C, D>, metadata: AdapterMetadata, astResolver: AstResolver): WireAdapterConstructor;
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-bindings",
|
|
3
|
-
"version": "1.124.
|
|
3
|
+
"version": "1.124.3",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "LDS Bindings for SFDC",
|
|
6
6
|
"main": "dist/ldsBindings.js",
|
|
7
7
|
"module": "dist/ldsBindings.js",
|
|
8
|
-
"types": "dist/main.d.ts",
|
|
8
|
+
"types": "dist/types/main.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"import": "./dist/ldsBindings.js",
|
|
15
|
-
"types": "./dist/main.d.ts",
|
|
15
|
+
"types": "./dist/types/main.d.ts",
|
|
16
16
|
"default": "./dist/ldsBindings.js"
|
|
17
17
|
}
|
|
18
18
|
},
|