@lorion-org/provider-selection 1.0.0-beta.2 → 1.0.0-beta.5
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/README.md +5 -5
- package/package.json +1 -2
- package/examples/payment-checkout.ts +0 -38
- package/examples/provider-preferences.ts +0 -61
package/README.md
CHANGED
|
@@ -25,12 +25,12 @@ If a configured provider is set but not present among the candidates, the packag
|
|
|
25
25
|
does not silently fall back. It reports a mismatch and leaves that capability
|
|
26
26
|
unselected.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Example descriptors in this repository:
|
|
29
29
|
|
|
30
|
-
- `
|
|
31
|
-
- `
|
|
32
|
-
- `
|
|
33
|
-
- `
|
|
30
|
+
- `examples/nuxt/layer-extensions/payment-provider-stripe/extension.json`
|
|
31
|
+
- `examples/nuxt/layer-extensions/payment-provider-invoice/extension.json`
|
|
32
|
+
- `examples/react-runtime/capabilities/payment-provider-stripe/capability.json`
|
|
33
|
+
- `examples/react-runtime/capabilities/payment-provider-invoice/capability.json`
|
|
34
34
|
|
|
35
35
|
It does not know anything about:
|
|
36
36
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lorion-org/provider-selection",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"description": "Framework-free capability provider selection primitives.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
40
|
"dist",
|
|
41
|
-
"examples",
|
|
42
41
|
"LICENSE",
|
|
43
42
|
"src/**/*.ts",
|
|
44
43
|
"!src/**/*.spec.ts"
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { resolveItemProviderSelection } from '@lorion-org/provider-selection';
|
|
2
|
-
|
|
3
|
-
type PaymentProviderDescriptor = {
|
|
4
|
-
id: string;
|
|
5
|
-
providesFor?: string | string[];
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const descriptors: PaymentProviderDescriptor[] = [
|
|
9
|
-
{
|
|
10
|
-
id: 'payment-provider-stripe',
|
|
11
|
-
providesFor: 'checkout',
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
id: 'payment-provider-invoice',
|
|
15
|
-
providesFor: 'checkout',
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
const result = resolveItemProviderSelection({
|
|
20
|
-
items: descriptors,
|
|
21
|
-
getCapabilityId: (descriptor) => descriptor.providesFor,
|
|
22
|
-
getProviderId: (descriptor) => descriptor.id,
|
|
23
|
-
configuredProviders: {
|
|
24
|
-
checkout: 'payment-provider-stripe',
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
console.log(result.providersByCapability);
|
|
29
|
-
// Map { checkout => ['payment-provider-invoice', 'payment-provider-stripe'] }
|
|
30
|
-
|
|
31
|
-
console.log(result.selections);
|
|
32
|
-
// Map { checkout => { selectedProviderId: 'payment-provider-stripe', mode: 'configured', ... } }
|
|
33
|
-
|
|
34
|
-
console.log(result.mismatches);
|
|
35
|
-
// []
|
|
36
|
-
|
|
37
|
-
console.log(result.excludedProviderIds);
|
|
38
|
-
// ['payment-provider-invoice']
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
collectProviderDefaults,
|
|
3
|
-
collectProviderPreferences,
|
|
4
|
-
collectSelectedProviderPreferences,
|
|
5
|
-
resolveItemProviderSelection,
|
|
6
|
-
} from '@lorion-org/provider-selection';
|
|
7
|
-
|
|
8
|
-
type PlaygroundDescriptor = {
|
|
9
|
-
defaultFor?: string | string[];
|
|
10
|
-
id: string;
|
|
11
|
-
providerPreferences?: Record<string, string>;
|
|
12
|
-
providesFor?: string | string[];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const descriptors: PlaygroundDescriptor[] = [
|
|
16
|
-
{
|
|
17
|
-
id: 'web',
|
|
18
|
-
providerPreferences: {
|
|
19
|
-
checkout: 'payment-provider-stripe',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
id: 'payment-provider-stripe',
|
|
24
|
-
defaultFor: 'checkout',
|
|
25
|
-
providesFor: 'checkout',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: 'payment-provider-invoice',
|
|
29
|
-
providesFor: 'checkout',
|
|
30
|
-
},
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const providerDefaults = collectProviderDefaults({
|
|
34
|
-
items: descriptors,
|
|
35
|
-
getDefaultFor: (descriptor) => descriptor.defaultFor,
|
|
36
|
-
getProviderId: (descriptor) => descriptor.id,
|
|
37
|
-
});
|
|
38
|
-
const descriptorPreferences = collectProviderPreferences({
|
|
39
|
-
items: descriptors,
|
|
40
|
-
getProviderPreferences: (descriptor) => descriptor.providerPreferences,
|
|
41
|
-
});
|
|
42
|
-
const selectedProviders = collectSelectedProviderPreferences({
|
|
43
|
-
items: descriptors,
|
|
44
|
-
getCapabilityId: (descriptor) => descriptor.providesFor,
|
|
45
|
-
getProviderId: (descriptor) => descriptor.id,
|
|
46
|
-
selectedProviderIds: ['payment-provider-invoice'],
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const result = resolveItemProviderSelection({
|
|
50
|
-
items: descriptors,
|
|
51
|
-
getCapabilityId: (descriptor) => descriptor.providesFor,
|
|
52
|
-
getProviderId: (descriptor) => descriptor.id,
|
|
53
|
-
fallbackProviders: {
|
|
54
|
-
...providerDefaults,
|
|
55
|
-
...descriptorPreferences,
|
|
56
|
-
},
|
|
57
|
-
selectedProviders,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
console.log(Object.fromEntries(result.selections));
|
|
61
|
-
// { checkout: { selectedProviderId: 'payment-provider-invoice', mode: 'selected', ... } }
|