@lorion-org/nuxt 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 +31 -33
- package/dist/extensions.js +15 -50
- package/dist/index.js +15 -50
- package/package.json +9 -11
- package/src/extensions.ts +18 -56
- package/examples/read-runtime-config.server.ts +0 -3
- package/examples/runtime-config-source.nuxt.config.ts +0 -13
- package/examples/selected-extensions.nuxt.config.ts +0 -30
package/README.md
CHANGED
|
@@ -111,11 +111,10 @@ src/
|
|
|
111
111
|
runtime-config.ts
|
|
112
112
|
runtime-config-node.ts
|
|
113
113
|
types.ts
|
|
114
|
-
|
|
114
|
+
snippets/
|
|
115
115
|
read-runtime-config.server.ts
|
|
116
116
|
runtime-config-source.nuxt.config.ts
|
|
117
117
|
selected-extensions.nuxt.config.ts
|
|
118
|
-
playground/
|
|
119
118
|
test/
|
|
120
119
|
fixtures/
|
|
121
120
|
unit/
|
|
@@ -126,9 +125,10 @@ test/
|
|
|
126
125
|
- `src/runtime-config.ts` contains universal runtime-config adapter helpers.
|
|
127
126
|
- `src/runtime-config-node.ts` contains Node-only source loading helpers.
|
|
128
127
|
- The published package exports the root Nuxt module, runtime-config subpaths, the descriptor schema, and runtime-safe extension helpers under `@lorion-org/nuxt/extensions`. Runtime-config composables are generated and auto-imported by the module.
|
|
129
|
-
- `
|
|
130
|
-
-
|
|
128
|
+
- `snippets/` contains Nuxt-focused config and server-route snippets.
|
|
129
|
+
- The runnable Nuxt example app lives at `examples/nuxt` in the repo root.
|
|
131
130
|
- `test/fixtures/` contains Nuxt applications used by end-to-end tests, and `test/unit/` contains package unit tests.
|
|
131
|
+
- The `srvx` devDependency is load-bearing for development only: it aligns this package's dev-time `nuxt` peer context with the standalone `examples/nuxt` app (which pulls `srvx` transitively through the Nitro server). Without it, pnpm resolves `nuxt` into two peer contexts and the `nuxt/schema` module augmentation in `src/types.ts` no longer typechecks. It is not imported by any source file — do not remove it as "unused". The root `package.json` `pnpm.overrides` pins `srvx` to one version workspace-wide so this alignment cannot silently drift when Nitro bumps its own `srvx` range; bump both together if Nitro ever requires a newer `srvx`.
|
|
132
132
|
|
|
133
133
|
## Nuxt module
|
|
134
134
|
|
|
@@ -462,36 +462,36 @@ export default defineNuxtConfig({
|
|
|
462
462
|
});
|
|
463
463
|
```
|
|
464
464
|
|
|
465
|
-
Nuxt-focused
|
|
465
|
+
Nuxt-focused snippets live in [`snippets/`](./snippets):
|
|
466
466
|
|
|
467
|
-
- [`selected-extensions.nuxt.config.ts`](./
|
|
468
|
-
- [`runtime-config-source.nuxt.config.ts`](./
|
|
469
|
-
- [`read-runtime-config.server.ts`](./
|
|
467
|
+
- [`selected-extensions.nuxt.config.ts`](./snippets/selected-extensions.nuxt.config.ts)
|
|
468
|
+
- [`runtime-config-source.nuxt.config.ts`](./snippets/runtime-config-source.nuxt.config.ts)
|
|
469
|
+
- [`read-runtime-config.server.ts`](./snippets/read-runtime-config.server.ts)
|
|
470
470
|
|
|
471
|
-
##
|
|
471
|
+
## Example app
|
|
472
472
|
|
|
473
|
-
|
|
473
|
+
The runnable Nuxt example lives at `examples/nuxt` (repo root). Run it from the
|
|
474
|
+
workspace root:
|
|
474
475
|
|
|
475
476
|
```shell
|
|
476
|
-
pnpm dev
|
|
477
|
+
pnpm --filter @lorion-examples/nuxt dev
|
|
477
478
|
```
|
|
478
479
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
Select a playground composition through the seed CLI or environment:
|
|
480
|
+
It runs with Lorion's `lorion-source` export condition so workspace imports
|
|
481
|
+
resolve to `src` instead of stale `dist` output. Select a composition through the
|
|
482
|
+
seed CLI or environment:
|
|
483
483
|
|
|
484
484
|
```shell
|
|
485
|
-
pnpm dev
|
|
486
|
-
LORION_CAPABILITIES="web payment-provider-invoice" pnpm dev
|
|
485
|
+
pnpm --filter @lorion-examples/nuxt dev -- --capabilities=web,payment-provider-invoice
|
|
486
|
+
LORION_CAPABILITIES="web payment-provider-invoice" pnpm --filter @lorion-examples/nuxt dev
|
|
487
487
|
```
|
|
488
488
|
|
|
489
|
-
The
|
|
489
|
+
The example app uses the module with no manual extension list in `nuxt.config.ts`.
|
|
490
490
|
It configures only the presentation-specific descriptor paths, loads runtime
|
|
491
491
|
config from `.runtimeconfig`, and registers the selected extension profile as
|
|
492
492
|
Nuxt layers.
|
|
493
493
|
|
|
494
|
-
The
|
|
494
|
+
The example app intentionally overrides the default extension root to make the
|
|
495
495
|
demo concept visible:
|
|
496
496
|
|
|
497
497
|
```ts
|
|
@@ -514,10 +514,10 @@ export default defineNuxtConfig({
|
|
|
514
514
|
});
|
|
515
515
|
```
|
|
516
516
|
|
|
517
|
-
The
|
|
517
|
+
The example app shape is:
|
|
518
518
|
|
|
519
519
|
```text
|
|
520
|
-
|
|
520
|
+
examples/nuxt/
|
|
521
521
|
app/
|
|
522
522
|
layer-extensions/
|
|
523
523
|
bundles/
|
|
@@ -534,7 +534,7 @@ playground/
|
|
|
534
534
|
runtime-config/
|
|
535
535
|
```
|
|
536
536
|
|
|
537
|
-
The root app lives under `
|
|
537
|
+
The root app lives under `examples/nuxt/app`. It owns normal Nuxt application
|
|
538
538
|
code. The `shops` layer extension provides the shop home route at `/`, the tiny
|
|
539
539
|
Registry Hub plugin backed by `@lorion-org/registry-hub`, and the shop registry
|
|
540
540
|
item type. Shop extensions depend on `shops`, register small shop entries
|
|
@@ -552,19 +552,19 @@ To run variants side by side, select the seed on the CLI and pass different
|
|
|
552
552
|
Nuxt ports:
|
|
553
553
|
|
|
554
554
|
```shell
|
|
555
|
-
pnpm dev
|
|
556
|
-
pnpm dev
|
|
557
|
-
pnpm dev
|
|
558
|
-
pnpm dev
|
|
555
|
+
pnpm --filter @lorion-examples/nuxt dev -- --port 3037
|
|
556
|
+
pnpm --filter @lorion-examples/nuxt dev -- --port 3039
|
|
557
|
+
pnpm --filter @lorion-examples/nuxt dev -- --capabilities=admin --port 3041
|
|
558
|
+
pnpm --filter @lorion-examples/nuxt dev -- --capabilities=web,payment-provider-invoice --port 3043
|
|
559
559
|
```
|
|
560
560
|
|
|
561
561
|
Each extension contributes only the Nuxt layer content it needs. The module
|
|
562
|
-
registers selected extensions as Nuxt layers; the
|
|
562
|
+
registers selected extensions as Nuxt layers; the example app does not list them
|
|
563
563
|
in `nuxt.config.ts`.
|
|
564
564
|
Provider extensions contribute checkout pages, register a small checkout
|
|
565
565
|
provider implementation through the payments layer interface, and expose server
|
|
566
566
|
routes. They declare `providesFor: "checkout"`; Stripe additionally
|
|
567
|
-
declares `defaultFor: "checkout"` so the
|
|
567
|
+
declares `defaultFor: "checkout"` so the example app demonstrates the
|
|
568
568
|
provider-owned default pattern. Runtime config for checkout, payments, and
|
|
569
569
|
providers is loaded from
|
|
570
570
|
`.runtimeconfig/runtime-config/<scope>/runtime.config.json`.
|
|
@@ -572,7 +572,7 @@ providers is loaded from
|
|
|
572
572
|
The module also exposes a public `extensionSelection` runtime-config object with
|
|
573
573
|
the selected profile, resolved descriptors, and active layer extension ids. The
|
|
574
574
|
module exposes a public `providerSelection` object with the selected provider,
|
|
575
|
-
candidate providers, selection mode, and excluded providers. The
|
|
575
|
+
candidate providers, selection mode, and excluded providers. The example app reads
|
|
576
576
|
those objects on `/tech` and its demo API returns a minimal view of them from
|
|
577
577
|
`/api/demo/overview`.
|
|
578
578
|
|
|
@@ -587,7 +587,7 @@ Demo extensions:
|
|
|
587
587
|
- `payment-provider-stripe`
|
|
588
588
|
- `payment-provider-invoice`
|
|
589
589
|
|
|
590
|
-
The
|
|
590
|
+
The example app also shows how the wider package set can work together:
|
|
591
591
|
|
|
592
592
|
- `@lorion-org/descriptor-discovery` discovers `extension.json` files.
|
|
593
593
|
- `@lorion-org/composition-graph` resolves selected profiles to active extensions.
|
|
@@ -605,7 +605,7 @@ The package has three test groups:
|
|
|
605
605
|
|
|
606
606
|
- unit tests for the adapter helpers and explicit extension activation
|
|
607
607
|
- an end-to-end Nuxt fixture that starts a real Nuxt app with the module
|
|
608
|
-
- typechecked TypeScript
|
|
608
|
+
- typechecked TypeScript snippets through the workspace snippets check
|
|
609
609
|
|
|
610
610
|
The e2e fixture verifies that `lorion.runtimeConfig` writes values into Nuxt
|
|
611
611
|
runtime config, that a server route can read them back through
|
|
@@ -621,7 +621,5 @@ pnpm test
|
|
|
621
621
|
pnpm test:unit
|
|
622
622
|
pnpm test:e2e
|
|
623
623
|
pnpm typecheck
|
|
624
|
-
pnpm typecheck:playground
|
|
625
|
-
pnpm build:playground
|
|
626
624
|
pnpm package:check
|
|
627
625
|
```
|
package/dist/extensions.js
CHANGED
|
@@ -12,9 +12,14 @@ import {
|
|
|
12
12
|
collectProviderDefaults,
|
|
13
13
|
collectProviderPreferences,
|
|
14
14
|
collectSelectedProviderPreferences,
|
|
15
|
-
resolveItemProviderSelection
|
|
16
|
-
resolveSelectedProviderRelationPreferences
|
|
15
|
+
resolveItemProviderSelection
|
|
17
16
|
} from "@lorion-org/provider-selection";
|
|
17
|
+
import {
|
|
18
|
+
applyProviderSelection,
|
|
19
|
+
assertSingleDefaultProvider,
|
|
20
|
+
descriptorSelectionPolicy,
|
|
21
|
+
providerRelationDescriptors
|
|
22
|
+
} from "@lorion-org/descriptor-selection";
|
|
18
23
|
|
|
19
24
|
// src/extension-descriptor.schema.json
|
|
20
25
|
var extension_descriptor_schema_default = {
|
|
@@ -120,23 +125,6 @@ var defaultExtensionOptions = {
|
|
|
120
125
|
descriptorPaths: ["extensions/*/extension.json"]
|
|
121
126
|
};
|
|
122
127
|
var defaultExtensionSelectionSeedKey = "capability";
|
|
123
|
-
var defaultExtensionResolutionRelations = [
|
|
124
|
-
"dependencies",
|
|
125
|
-
"defaultProviders",
|
|
126
|
-
"providerPreferences"
|
|
127
|
-
];
|
|
128
|
-
var defaultNuxtRelationDescriptors = [
|
|
129
|
-
{
|
|
130
|
-
direction: "incoming",
|
|
131
|
-
field: "defaultFor",
|
|
132
|
-
id: "defaultProviders"
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
id: "providerPreferences",
|
|
136
|
-
field: "providerPreferences",
|
|
137
|
-
targetMode: "values"
|
|
138
|
-
}
|
|
139
|
-
];
|
|
140
128
|
function isRecord(value) {
|
|
141
129
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
142
130
|
}
|
|
@@ -231,7 +219,7 @@ function discoverNuxtExtensionEntries(input) {
|
|
|
231
219
|
function createNuxtExtensionCatalog(input) {
|
|
232
220
|
return createDescriptorCatalog({
|
|
233
221
|
descriptors: input.entries.map((entry) => entry.descriptor),
|
|
234
|
-
relationDescriptors: [...
|
|
222
|
+
relationDescriptors: [...providerRelationDescriptors, ...input.relationDescriptors ?? []]
|
|
235
223
|
});
|
|
236
224
|
}
|
|
237
225
|
function createNuxtExtensionEntryMap(entries) {
|
|
@@ -248,27 +236,6 @@ function createNuxtSelectedProviderPreferences(input) {
|
|
|
248
236
|
selectedProviderIds: input.selectedExtensions
|
|
249
237
|
});
|
|
250
238
|
}
|
|
251
|
-
function createProviderSelectionAwareEntries(entries, selectedProviders) {
|
|
252
|
-
if (!Object.keys(selectedProviders).length) return entries;
|
|
253
|
-
return entries.map((entry) => {
|
|
254
|
-
const descriptor = { ...entry.descriptor };
|
|
255
|
-
const preferences = resolveSelectedProviderRelationPreferences({
|
|
256
|
-
providerId: entry.descriptor.id,
|
|
257
|
-
defaultFor: entry.descriptor.defaultFor,
|
|
258
|
-
providerPreferences: entry.descriptor.providerPreferences,
|
|
259
|
-
selectedProviders
|
|
260
|
-
});
|
|
261
|
-
delete descriptor.defaultFor;
|
|
262
|
-
delete descriptor.providerPreferences;
|
|
263
|
-
return {
|
|
264
|
-
...entry,
|
|
265
|
-
descriptor: {
|
|
266
|
-
...descriptor,
|
|
267
|
-
...preferences
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
239
|
function mergeRuntimeConfigSection(target = {}, source = {}) {
|
|
273
240
|
const merged = { ...target };
|
|
274
241
|
for (const [key, value] of Object.entries(source)) {
|
|
@@ -344,19 +311,17 @@ function createNuxtExtensionBootstrap(input) {
|
|
|
344
311
|
selectedExtensions
|
|
345
312
|
};
|
|
346
313
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
314
|
+
assertSingleDefaultProvider(entries.map((entry) => entry.descriptor));
|
|
315
|
+
const resolutionEntries = applyProviderSelection({
|
|
316
|
+
items: entries,
|
|
317
|
+
selected: selectedExtensions,
|
|
318
|
+
getDescriptor: (entry) => entry.descriptor,
|
|
319
|
+
withDescriptor: (entry, descriptor) => ({ ...entry, descriptor })
|
|
350
320
|
});
|
|
351
|
-
const resolutionEntries = createProviderSelectionAwareEntries(entries, selectedProviders);
|
|
352
321
|
const catalog = createCatalog(resolutionEntries);
|
|
353
322
|
const selection = catalog.resolveSelection({
|
|
354
323
|
baseDescriptors: baseExtensionIds,
|
|
355
|
-
policy:
|
|
356
|
-
inspectionRelationIds: defaultExtensionResolutionRelations,
|
|
357
|
-
provenanceRelationIds: defaultExtensionResolutionRelations,
|
|
358
|
-
resolutionRelationIds: defaultExtensionResolutionRelations
|
|
359
|
-
},
|
|
324
|
+
policy: descriptorSelectionPolicy(),
|
|
360
325
|
selected: selectedExtensions
|
|
361
326
|
});
|
|
362
327
|
const resolvedExtensionIds = selection.getResolved();
|
package/dist/index.js
CHANGED
|
@@ -26,9 +26,14 @@ import {
|
|
|
26
26
|
collectProviderDefaults,
|
|
27
27
|
collectProviderPreferences,
|
|
28
28
|
collectSelectedProviderPreferences,
|
|
29
|
-
resolveItemProviderSelection
|
|
30
|
-
resolveSelectedProviderRelationPreferences
|
|
29
|
+
resolveItemProviderSelection
|
|
31
30
|
} from "@lorion-org/provider-selection";
|
|
31
|
+
import {
|
|
32
|
+
applyProviderSelection,
|
|
33
|
+
assertSingleDefaultProvider,
|
|
34
|
+
descriptorSelectionPolicy,
|
|
35
|
+
providerRelationDescriptors
|
|
36
|
+
} from "@lorion-org/descriptor-selection";
|
|
32
37
|
|
|
33
38
|
// src/extension-descriptor.schema.json
|
|
34
39
|
var extension_descriptor_schema_default = {
|
|
@@ -134,23 +139,6 @@ var defaultExtensionOptions = {
|
|
|
134
139
|
descriptorPaths: ["extensions/*/extension.json"]
|
|
135
140
|
};
|
|
136
141
|
var defaultExtensionSelectionSeedKey = "capability";
|
|
137
|
-
var defaultExtensionResolutionRelations = [
|
|
138
|
-
"dependencies",
|
|
139
|
-
"defaultProviders",
|
|
140
|
-
"providerPreferences"
|
|
141
|
-
];
|
|
142
|
-
var defaultNuxtRelationDescriptors = [
|
|
143
|
-
{
|
|
144
|
-
direction: "incoming",
|
|
145
|
-
field: "defaultFor",
|
|
146
|
-
id: "defaultProviders"
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
id: "providerPreferences",
|
|
150
|
-
field: "providerPreferences",
|
|
151
|
-
targetMode: "values"
|
|
152
|
-
}
|
|
153
|
-
];
|
|
154
142
|
function isRecord(value) {
|
|
155
143
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
156
144
|
}
|
|
@@ -245,7 +233,7 @@ function discoverNuxtExtensionEntries(input) {
|
|
|
245
233
|
function createNuxtExtensionCatalog(input) {
|
|
246
234
|
return createDescriptorCatalog({
|
|
247
235
|
descriptors: input.entries.map((entry) => entry.descriptor),
|
|
248
|
-
relationDescriptors: [...
|
|
236
|
+
relationDescriptors: [...providerRelationDescriptors, ...input.relationDescriptors ?? []]
|
|
249
237
|
});
|
|
250
238
|
}
|
|
251
239
|
function createNuxtExtensionEntryMap(entries) {
|
|
@@ -262,27 +250,6 @@ function createNuxtSelectedProviderPreferences(input) {
|
|
|
262
250
|
selectedProviderIds: input.selectedExtensions
|
|
263
251
|
});
|
|
264
252
|
}
|
|
265
|
-
function createProviderSelectionAwareEntries(entries, selectedProviders) {
|
|
266
|
-
if (!Object.keys(selectedProviders).length) return entries;
|
|
267
|
-
return entries.map((entry) => {
|
|
268
|
-
const descriptor = { ...entry.descriptor };
|
|
269
|
-
const preferences = resolveSelectedProviderRelationPreferences({
|
|
270
|
-
providerId: entry.descriptor.id,
|
|
271
|
-
defaultFor: entry.descriptor.defaultFor,
|
|
272
|
-
providerPreferences: entry.descriptor.providerPreferences,
|
|
273
|
-
selectedProviders
|
|
274
|
-
});
|
|
275
|
-
delete descriptor.defaultFor;
|
|
276
|
-
delete descriptor.providerPreferences;
|
|
277
|
-
return {
|
|
278
|
-
...entry,
|
|
279
|
-
descriptor: {
|
|
280
|
-
...descriptor,
|
|
281
|
-
...preferences
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
253
|
function mergeRuntimeConfigSection(target = {}, source = {}) {
|
|
287
254
|
const merged = { ...target };
|
|
288
255
|
for (const [key, value] of Object.entries(source)) {
|
|
@@ -358,19 +325,17 @@ function createNuxtExtensionBootstrap(input) {
|
|
|
358
325
|
selectedExtensions
|
|
359
326
|
};
|
|
360
327
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
328
|
+
assertSingleDefaultProvider(entries.map((entry) => entry.descriptor));
|
|
329
|
+
const resolutionEntries = applyProviderSelection({
|
|
330
|
+
items: entries,
|
|
331
|
+
selected: selectedExtensions,
|
|
332
|
+
getDescriptor: (entry) => entry.descriptor,
|
|
333
|
+
withDescriptor: (entry, descriptor) => ({ ...entry, descriptor })
|
|
364
334
|
});
|
|
365
|
-
const resolutionEntries = createProviderSelectionAwareEntries(entries, selectedProviders);
|
|
366
335
|
const catalog = createCatalog(resolutionEntries);
|
|
367
336
|
const selection = catalog.resolveSelection({
|
|
368
337
|
baseDescriptors: baseExtensionIds,
|
|
369
|
-
policy:
|
|
370
|
-
inspectionRelationIds: defaultExtensionResolutionRelations,
|
|
371
|
-
provenanceRelationIds: defaultExtensionResolutionRelations,
|
|
372
|
-
resolutionRelationIds: defaultExtensionResolutionRelations
|
|
373
|
-
},
|
|
338
|
+
policy: descriptorSelectionPolicy(),
|
|
374
339
|
selected: selectedExtensions
|
|
375
340
|
});
|
|
376
341
|
const resolvedExtensionIds = selection.getResolved();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lorion-org/nuxt",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"description": "Nuxt module for LORION libraries and framework adapters.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -68,7 +68,6 @@
|
|
|
68
68
|
},
|
|
69
69
|
"files": [
|
|
70
70
|
"dist",
|
|
71
|
-
"examples",
|
|
72
71
|
"LICENSE",
|
|
73
72
|
"src/**/*.ts",
|
|
74
73
|
"src/**/*.json",
|
|
@@ -84,11 +83,12 @@
|
|
|
84
83
|
"node": "^20.19.0 || >=22.12.0"
|
|
85
84
|
},
|
|
86
85
|
"dependencies": {
|
|
87
|
-
"@lorion-org/
|
|
88
|
-
"@lorion-org/
|
|
89
|
-
"@lorion-org/
|
|
90
|
-
"@lorion-org/
|
|
91
|
-
"@lorion-org/provider-selection": "^1.0.0-beta.
|
|
86
|
+
"@lorion-org/descriptor-discovery": "^1.0.0-beta.5",
|
|
87
|
+
"@lorion-org/runtime-config": "^1.0.0-beta.5",
|
|
88
|
+
"@lorion-org/descriptor-selection": "^1.0.0-beta.5",
|
|
89
|
+
"@lorion-org/composition-graph": "^1.0.0-beta.5",
|
|
90
|
+
"@lorion-org/provider-selection": "^1.0.0-beta.5",
|
|
91
|
+
"@lorion-org/runtime-config-node": "^1.0.0-beta.5"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"@nuxt/kit": "^4.0.0",
|
|
@@ -99,7 +99,8 @@
|
|
|
99
99
|
"@nuxt/schema": "^4.4.2",
|
|
100
100
|
"@nuxt/test-utils": "^3.23.0",
|
|
101
101
|
"nuxt": "^4.4.2",
|
|
102
|
-
"
|
|
102
|
+
"srvx": "^0.11.15",
|
|
103
|
+
"@lorion-org/registry-hub": "^1.0.0-beta.5"
|
|
103
104
|
},
|
|
104
105
|
"scripts": {
|
|
105
106
|
"build": "rimraf dist && tsup src/index.ts src/runtime-config.ts src/runtime-config-node.ts src/descriptor-schema.ts src/extensions.ts --format esm --dts --splitting false",
|
|
@@ -109,9 +110,6 @@
|
|
|
109
110
|
"test": "pnpm test:unit && pnpm test:e2e",
|
|
110
111
|
"test:unit": "vitest run --config test/vitest.unit.config.mts",
|
|
111
112
|
"test:e2e": "vitest run --config test/vitest.e2e.config.mts",
|
|
112
|
-
"build:playground": "node ../../tools/run-source-condition.mjs nuxi build playground",
|
|
113
|
-
"dev:playground": "node ../../tools/run-source-condition.mjs nuxi dev playground",
|
|
114
|
-
"typecheck:playground": "node ../../tools/run-source-condition.mjs nuxi typecheck playground",
|
|
115
113
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
116
114
|
}
|
|
117
115
|
}
|
package/src/extensions.ts
CHANGED
|
@@ -15,9 +15,14 @@ import {
|
|
|
15
15
|
collectProviderPreferences,
|
|
16
16
|
collectSelectedProviderPreferences,
|
|
17
17
|
resolveItemProviderSelection,
|
|
18
|
-
resolveSelectedProviderRelationPreferences,
|
|
19
18
|
type ProviderPreferenceMap,
|
|
20
19
|
} from '@lorion-org/provider-selection';
|
|
20
|
+
import {
|
|
21
|
+
applyProviderSelection,
|
|
22
|
+
assertSingleDefaultProvider,
|
|
23
|
+
descriptorSelectionPolicy,
|
|
24
|
+
providerRelationDescriptors,
|
|
25
|
+
} from '@lorion-org/descriptor-selection';
|
|
21
26
|
import type { RuntimeConfigValidationPolicy } from '@lorion-org/runtime-config';
|
|
22
27
|
import type {
|
|
23
28
|
NuxtBaseExtensionSelectionInput,
|
|
@@ -79,23 +84,6 @@ const defaultExtensionOptions = {
|
|
|
79
84
|
descriptorPaths: ['extensions/*/extension.json'],
|
|
80
85
|
} as const;
|
|
81
86
|
const defaultExtensionSelectionSeedKey = 'capability';
|
|
82
|
-
const defaultExtensionResolutionRelations = [
|
|
83
|
-
'dependencies',
|
|
84
|
-
'defaultProviders',
|
|
85
|
-
'providerPreferences',
|
|
86
|
-
];
|
|
87
|
-
const defaultNuxtRelationDescriptors: RelationDescriptor[] = [
|
|
88
|
-
{
|
|
89
|
-
direction: 'incoming',
|
|
90
|
-
field: 'defaultFor',
|
|
91
|
-
id: 'defaultProviders',
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
id: 'providerPreferences',
|
|
95
|
-
field: 'providerPreferences',
|
|
96
|
-
targetMode: 'values',
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
87
|
|
|
100
88
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
101
89
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -243,7 +231,7 @@ export function createNuxtExtensionCatalog(input: {
|
|
|
243
231
|
}): DescriptorCatalog {
|
|
244
232
|
return createDescriptorCatalog({
|
|
245
233
|
descriptors: input.entries.map((entry) => entry.descriptor),
|
|
246
|
-
relationDescriptors: [...
|
|
234
|
+
relationDescriptors: [...providerRelationDescriptors, ...(input.relationDescriptors ?? [])],
|
|
247
235
|
});
|
|
248
236
|
}
|
|
249
237
|
|
|
@@ -262,6 +250,9 @@ function pickEntriesById(
|
|
|
262
250
|
.filter((entry): entry is NuxtExtensionEntry => Boolean(entry));
|
|
263
251
|
}
|
|
264
252
|
|
|
253
|
+
// The capability -> selected-provider map, used by the module to expose provider
|
|
254
|
+
// selection through runtime config. The selection cleaning itself is delegated to
|
|
255
|
+
// @lorion-org/descriptor-selection's `applyProviderSelection`.
|
|
265
256
|
export function createNuxtSelectedProviderPreferences(input: {
|
|
266
257
|
entries: NuxtExtensionEntry[];
|
|
267
258
|
selectedExtensions: string[];
|
|
@@ -274,34 +265,6 @@ export function createNuxtSelectedProviderPreferences(input: {
|
|
|
274
265
|
});
|
|
275
266
|
}
|
|
276
267
|
|
|
277
|
-
function createProviderSelectionAwareEntries(
|
|
278
|
-
entries: NuxtExtensionEntry[],
|
|
279
|
-
selectedProviders: ProviderPreferenceMap,
|
|
280
|
-
): NuxtExtensionEntry[] {
|
|
281
|
-
if (!Object.keys(selectedProviders).length) return entries;
|
|
282
|
-
|
|
283
|
-
return entries.map((entry) => {
|
|
284
|
-
const descriptor = { ...entry.descriptor };
|
|
285
|
-
const preferences = resolveSelectedProviderRelationPreferences({
|
|
286
|
-
providerId: entry.descriptor.id,
|
|
287
|
-
defaultFor: entry.descriptor.defaultFor,
|
|
288
|
-
providerPreferences: entry.descriptor.providerPreferences,
|
|
289
|
-
selectedProviders,
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
delete descriptor.defaultFor;
|
|
293
|
-
delete descriptor.providerPreferences;
|
|
294
|
-
|
|
295
|
-
return {
|
|
296
|
-
...entry,
|
|
297
|
-
descriptor: {
|
|
298
|
-
...descriptor,
|
|
299
|
-
...preferences,
|
|
300
|
-
},
|
|
301
|
-
};
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
|
|
305
268
|
function mergeRuntimeConfigSection(
|
|
306
269
|
target: NuxtRuntimeConfig['public'] = {},
|
|
307
270
|
source: NuxtRuntimeConfig['public'] = {},
|
|
@@ -405,19 +368,18 @@ export function createNuxtExtensionBootstrap(input: {
|
|
|
405
368
|
};
|
|
406
369
|
}
|
|
407
370
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
371
|
+
assertSingleDefaultProvider(entries.map((entry) => entry.descriptor));
|
|
372
|
+
|
|
373
|
+
const resolutionEntries = applyProviderSelection({
|
|
374
|
+
items: entries,
|
|
375
|
+
selected: selectedExtensions,
|
|
376
|
+
getDescriptor: (entry) => entry.descriptor,
|
|
377
|
+
withDescriptor: (entry, descriptor) => ({ ...entry, descriptor }),
|
|
411
378
|
});
|
|
412
|
-
const resolutionEntries = createProviderSelectionAwareEntries(entries, selectedProviders);
|
|
413
379
|
const catalog = createCatalog(resolutionEntries);
|
|
414
380
|
const selection = catalog.resolveSelection({
|
|
415
381
|
baseDescriptors: baseExtensionIds,
|
|
416
|
-
policy:
|
|
417
|
-
inspectionRelationIds: defaultExtensionResolutionRelations,
|
|
418
|
-
provenanceRelationIds: defaultExtensionResolutionRelations,
|
|
419
|
-
resolutionRelationIds: defaultExtensionResolutionRelations,
|
|
420
|
-
},
|
|
382
|
+
policy: descriptorSelectionPolicy(),
|
|
421
383
|
selected: selectedExtensions,
|
|
422
384
|
});
|
|
423
385
|
const resolvedExtensionIds = selection.getResolved();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineNuxtConfig } from 'nuxt/config';
|
|
2
|
-
import type {} from '@lorion-org/nuxt';
|
|
3
|
-
|
|
4
|
-
export default defineNuxtConfig({
|
|
5
|
-
modules: ['@lorion-org/nuxt'],
|
|
6
|
-
lorion: {
|
|
7
|
-
runtimeConfig: {
|
|
8
|
-
source: {
|
|
9
|
-
paths: ['.runtimeconfig/runtime-config/*/runtime.config.json'],
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { defineNuxtConfig } from 'nuxt/config';
|
|
2
|
-
import LorionNuxtModule, {
|
|
3
|
-
createNuxtExtensionBootstrap,
|
|
4
|
-
createNuxtExtensionLayerPaths,
|
|
5
|
-
} from '@lorion-org/nuxt';
|
|
6
|
-
|
|
7
|
-
const extensionBootstrap = createNuxtExtensionBootstrap({
|
|
8
|
-
rootDir: __dirname,
|
|
9
|
-
options: {
|
|
10
|
-
defaultSelection: 'default',
|
|
11
|
-
descriptorPaths: ['extensions/*/extension.json'],
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export default defineNuxtConfig({
|
|
16
|
-
extends: createNuxtExtensionLayerPaths(extensionBootstrap),
|
|
17
|
-
modules: [
|
|
18
|
-
[
|
|
19
|
-
LorionNuxtModule,
|
|
20
|
-
{
|
|
21
|
-
extensionBootstrap,
|
|
22
|
-
providers: {
|
|
23
|
-
configuredProviders: {
|
|
24
|
-
'payment-checkout': 'payment-provider-stripe',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
],
|
|
30
|
-
});
|