@baseplate-dev/project-builder-lib 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler/admin-crud-action-compiler.d.ts +18 -0
- package/dist/compiler/admin-crud-action-compiler.d.ts.map +1 -0
- package/dist/compiler/admin-crud-action-compiler.js +6 -0
- package/dist/compiler/admin-crud-action-compiler.js.map +1 -0
- package/dist/compiler/admin-crud-column-compiler-spec.d.ts +6 -12
- package/dist/compiler/admin-crud-column-compiler-spec.d.ts.map +1 -1
- package/dist/compiler/admin-crud-column-compiler-spec.js +6 -29
- package/dist/compiler/admin-crud-column-compiler-spec.js.map +1 -1
- package/dist/compiler/admin-crud-input-spec.d.ts +6 -11
- package/dist/compiler/admin-crud-input-spec.d.ts.map +1 -1
- package/dist/compiler/admin-crud-input-spec.js +6 -26
- package/dist/compiler/admin-crud-input-spec.js.map +1 -1
- package/dist/compiler/app-compiler-spec.d.ts +8 -12
- package/dist/compiler/app-compiler-spec.d.ts.map +1 -1
- package/dist/compiler/app-compiler-spec.js +11 -18
- package/dist/compiler/app-compiler-spec.js.map +1 -1
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/index.js +1 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/compiler/model-transformer-compiler-spec.d.ts +6 -11
- package/dist/compiler/model-transformer-compiler-spec.d.ts.map +1 -1
- package/dist/compiler/model-transformer-compiler-spec.js +6 -26
- package/dist/compiler/model-transformer-compiler-spec.js.map +1 -1
- package/dist/definition/model/model-transformer-utils.d.ts +4 -6
- package/dist/definition/model/model-transformer-utils.d.ts.map +1 -1
- package/dist/definition/model/model-transformer-utils.js +8 -10
- package/dist/definition/model/model-transformer-utils.js.map +1 -1
- package/dist/definition/packages/package-utils.d.ts +11 -9
- package/dist/definition/packages/package-utils.d.ts.map +1 -1
- package/dist/definition/packages/package-utils.js +22 -11
- package/dist/definition/packages/package-utils.js.map +1 -1
- package/dist/definition/plugins/plugin-utils.d.ts.map +1 -1
- package/dist/definition/plugins/plugin-utils.js +2 -2
- package/dist/definition/plugins/plugin-utils.js.map +1 -1
- package/dist/definition/project-definition-container.d.ts +3 -3
- package/dist/definition/project-definition-container.d.ts.map +1 -1
- package/dist/definition/project-definition-container.js +2 -2
- package/dist/definition/project-definition-container.js.map +1 -1
- package/dist/definition/project-definition-container.test-utils.d.ts.map +1 -1
- package/dist/definition/project-definition-container.test-utils.js +8 -5
- package/dist/definition/project-definition-container.test-utils.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +2 -0
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/migration-022-rename-packages-to-libraries.d.ts +37 -0
- package/dist/migrations/migration-022-rename-packages-to-libraries.d.ts.map +1 -0
- package/dist/migrations/migration-022-rename-packages-to-libraries.js +45 -0
- package/dist/migrations/migration-022-rename-packages-to-libraries.js.map +1 -0
- package/dist/parser/parser.d.ts +4 -4
- package/dist/parser/parser.d.ts.map +1 -1
- package/dist/parser/parser.js +17 -42
- package/dist/parser/parser.js.map +1 -1
- package/dist/plugins/context/index.d.ts +2 -0
- package/dist/plugins/context/index.d.ts.map +1 -0
- package/dist/plugins/context/index.js +2 -0
- package/dist/plugins/context/index.js.map +1 -0
- package/dist/plugins/context/plugin-context.d.ts +30 -0
- package/dist/plugins/context/plugin-context.d.ts.map +1 -0
- package/dist/plugins/context/plugin-context.js +38 -0
- package/dist/plugins/context/plugin-context.js.map +1 -0
- package/dist/plugins/imports/loader.d.ts +11 -20
- package/dist/plugins/imports/loader.d.ts.map +1 -1
- package/dist/plugins/imports/loader.js +28 -69
- package/dist/plugins/imports/loader.js.map +1 -1
- package/dist/plugins/imports/types.d.ts +72 -13
- package/dist/plugins/imports/types.d.ts.map +1 -1
- package/dist/plugins/imports/types.js +17 -1
- package/dist/plugins/imports/types.js.map +1 -1
- package/dist/plugins/index.d.ts +3 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +3 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/migrations/run-migrations.d.ts +2 -2
- package/dist/plugins/migrations/run-migrations.d.ts.map +1 -1
- package/dist/plugins/migrations/run-migrations.js +2 -2
- package/dist/plugins/migrations/run-migrations.js.map +1 -1
- package/dist/plugins/spec/auth-config-spec.d.ts +13 -9
- package/dist/plugins/spec/auth-config-spec.d.ts.map +1 -1
- package/dist/plugins/spec/auth-config-spec.js +16 -3
- package/dist/plugins/spec/auth-config-spec.js.map +1 -1
- package/dist/plugins/spec/auth-models-spec.d.ts +16 -0
- package/dist/plugins/spec/auth-models-spec.d.ts.map +1 -0
- package/dist/plugins/spec/auth-models-spec.js +16 -0
- package/dist/plugins/spec/auth-models-spec.js.map +1 -0
- package/dist/plugins/spec/config-spec.d.ts +8 -13
- package/dist/plugins/spec/config-spec.d.ts.map +1 -1
- package/dist/plugins/spec/config-spec.js +20 -35
- package/dist/plugins/spec/config-spec.js.map +1 -1
- package/dist/plugins/spec/index.d.ts +1 -1
- package/dist/plugins/spec/index.d.ts.map +1 -1
- package/dist/plugins/spec/index.js +1 -1
- package/dist/plugins/spec/index.js.map +1 -1
- package/dist/plugins/spec/types.d.ts +66 -25
- package/dist/plugins/spec/types.d.ts.map +1 -1
- package/dist/plugins/spec/types.js +27 -10
- package/dist/plugins/spec/types.js.map +1 -1
- package/dist/plugins/spec/web-config-spec.d.ts +7 -10
- package/dist/plugins/spec/web-config-spec.d.ts.map +1 -1
- package/dist/plugins/spec/web-config-spec.js +6 -19
- package/dist/plugins/spec/web-config-spec.js.map +1 -1
- package/dist/plugins/store/index.d.ts.map +1 -0
- package/dist/plugins/store/index.js.map +1 -0
- package/dist/plugins/store/store.d.ts +23 -0
- package/dist/plugins/store/store.d.ts.map +1 -0
- package/dist/plugins/store/store.js +36 -0
- package/dist/plugins/store/store.js.map +1 -0
- package/dist/plugins/utils/create-field-map-spec.d.ts +17 -0
- package/dist/plugins/utils/create-field-map-spec.d.ts.map +1 -0
- package/dist/plugins/utils/create-field-map-spec.js +27 -0
- package/dist/plugins/utils/create-field-map-spec.js.map +1 -0
- package/dist/plugins/utils/create-plugin-field-map.d.ts +24 -0
- package/dist/plugins/utils/create-plugin-field-map.d.ts.map +1 -0
- package/dist/plugins/utils/create-plugin-field-map.js +29 -0
- package/dist/plugins/utils/create-plugin-field-map.js.map +1 -0
- package/dist/plugins/utils/index.d.ts +3 -0
- package/dist/plugins/utils/index.d.ts.map +1 -0
- package/dist/plugins/utils/index.js +3 -0
- package/dist/plugins/utils/index.js.map +1 -0
- package/dist/schema/apps/backend/index.d.ts +0 -2
- package/dist/schema/apps/backend/index.d.ts.map +1 -1
- package/dist/schema/apps/backend/index.js +0 -1
- package/dist/schema/apps/backend/index.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.d.ts +6 -13
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.js +5 -26
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-action-spec.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-crud-action.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-crud-action.js +1 -3
- package/dist/schema/apps/web/admin/sections/crud-actions/admin-crud-action.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.d.ts +6 -12
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.js +5 -26
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-column-spec.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-crud-column.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-crud-column.js +1 -3
- package/dist/schema/apps/web/admin/sections/crud-columns/admin-crud-column.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/admin-crud-input.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/admin-crud-input.js +1 -3
- package/dist/schema/apps/web/admin/sections/crud-form/admin-crud-input.js.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.d.ts +7 -13
- package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.d.ts.map +1 -1
- package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.js +5 -26
- package/dist/schema/apps/web/admin/sections/crud-form/admin-input-spec.js.map +1 -1
- package/dist/schema/creator/types.d.ts +3 -3
- package/dist/schema/creator/types.d.ts.map +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/{packages → libraries}/base.d.ts +3 -3
- package/dist/schema/libraries/base.d.ts.map +1 -0
- package/dist/schema/libraries/base.js +10 -0
- package/dist/schema/libraries/base.js.map +1 -0
- package/dist/schema/libraries/index.d.ts +3 -0
- package/dist/schema/libraries/index.d.ts.map +1 -0
- package/dist/schema/libraries/index.js +3 -0
- package/dist/schema/libraries/index.js.map +1 -0
- package/dist/schema/libraries/library.d.ts +19 -0
- package/dist/schema/libraries/library.d.ts.map +1 -0
- package/dist/schema/libraries/library.js +13 -0
- package/dist/schema/libraries/library.js.map +1 -0
- package/dist/schema/libraries/types.d.ts +2 -0
- package/dist/schema/libraries/types.d.ts.map +1 -0
- package/dist/schema/libraries/types.js +3 -0
- package/dist/schema/libraries/types.js.map +1 -0
- package/dist/schema/models/transformers/model-transformer-spec.d.ts +5 -11
- package/dist/schema/models/transformers/model-transformer-spec.d.ts.map +1 -1
- package/dist/schema/models/transformers/model-transformer-spec.js +5 -30
- package/dist/schema/models/transformers/model-transformer-spec.js.map +1 -1
- package/dist/schema/models/transformers/transformers.d.ts.map +1 -1
- package/dist/schema/models/transformers/transformers.js +2 -4
- package/dist/schema/models/transformers/transformers.js.map +1 -1
- package/dist/schema/plugins/definition.js +1 -1
- package/dist/schema/plugins/definition.js.map +1 -1
- package/dist/schema/project-definition.d.ts +6 -32
- package/dist/schema/project-definition.d.ts.map +1 -1
- package/dist/schema/project-definition.js +2 -10
- package/dist/schema/project-definition.js.map +1 -1
- package/dist/schema/settings/monorepo.d.ts +2 -2
- package/dist/schema/settings/monorepo.js +8 -8
- package/dist/schema/settings/monorepo.js.map +1 -1
- package/dist/schema/settings/settings.d.ts +1 -1
- package/dist/specs/index.d.ts +2 -0
- package/dist/specs/index.d.ts.map +1 -0
- package/dist/specs/index.js +2 -0
- package/dist/specs/index.js.map +1 -0
- package/dist/specs/packages/index.d.ts +3 -0
- package/dist/specs/packages/index.d.ts.map +1 -0
- package/dist/specs/packages/index.js +3 -0
- package/dist/specs/packages/index.js.map +1 -0
- package/dist/specs/packages/library-type-spec.d.ts +76 -0
- package/dist/specs/packages/library-type-spec.d.ts.map +1 -0
- package/dist/specs/packages/library-type-spec.js +31 -0
- package/dist/specs/packages/library-type-spec.js.map +1 -0
- package/dist/specs/packages/package-compiler-types.d.ts +111 -0
- package/dist/specs/packages/package-compiler-types.d.ts.map +1 -0
- package/dist/specs/packages/package-compiler-types.js +85 -0
- package/dist/specs/packages/package-compiler-types.js.map +1 -0
- package/dist/web/hooks/use-project-definition.d.ts +2 -2
- package/dist/web/hooks/use-project-definition.d.ts.map +1 -1
- package/dist/web/specs/admin-crud-action-web-spec.d.ts +6 -12
- package/dist/web/specs/admin-crud-action-web-spec.d.ts.map +1 -1
- package/dist/web/specs/admin-crud-action-web-spec.js +6 -29
- package/dist/web/specs/admin-crud-action-web-spec.js.map +1 -1
- package/dist/web/specs/admin-crud-column-web-spec.d.ts +6 -12
- package/dist/web/specs/admin-crud-column-web-spec.d.ts.map +1 -1
- package/dist/web/specs/admin-crud-column-web-spec.js +6 -29
- package/dist/web/specs/admin-crud-column-web-spec.js.map +1 -1
- package/dist/web/specs/admin-crud-input-web-spec.d.ts +6 -12
- package/dist/web/specs/admin-crud-input-web-spec.d.ts.map +1 -1
- package/dist/web/specs/admin-crud-input-web-spec.js +6 -29
- package/dist/web/specs/admin-crud-input-web-spec.js.map +1 -1
- package/dist/web/specs/model-transformer-web-spec.d.ts +8 -13
- package/dist/web/specs/model-transformer-web-spec.d.ts.map +1 -1
- package/dist/web/specs/model-transformer-web-spec.js +16 -28
- package/dist/web/specs/model-transformer-web-spec.js.map +1 -1
- package/package.json +5 -5
- package/dist/compiler/admin-crud-action-spec.d.ts +0 -26
- package/dist/compiler/admin-crud-action-spec.d.ts.map +0 -1
- package/dist/compiler/admin-crud-action-spec.js +0 -29
- package/dist/compiler/admin-crud-action-spec.js.map +0 -1
- package/dist/plugins/schema/index.d.ts.map +0 -1
- package/dist/plugins/schema/index.js.map +0 -1
- package/dist/plugins/schema/store.d.ts +0 -8
- package/dist/plugins/schema/store.d.ts.map +0 -1
- package/dist/plugins/schema/store.js +0 -17
- package/dist/plugins/schema/store.js.map +0 -1
- package/dist/plugins/spec/auth-model-config-spec.d.ts +0 -14
- package/dist/plugins/spec/auth-model-config-spec.d.ts.map +0 -1
- package/dist/plugins/spec/auth-model-config-spec.js +0 -6
- package/dist/plugins/spec/auth-model-config-spec.js.map +0 -1
- package/dist/schema/packages/base.d.ts.map +0 -1
- package/dist/schema/packages/base.js +0 -10
- package/dist/schema/packages/base.js.map +0 -1
- package/dist/schema/packages/index.d.ts +0 -4
- package/dist/schema/packages/index.d.ts.map +0 -1
- package/dist/schema/packages/index.js +0 -4
- package/dist/schema/packages/index.js.map +0 -1
- package/dist/schema/packages/node-library/index.d.ts +0 -16
- package/dist/schema/packages/node-library/index.d.ts.map +0 -1
- package/dist/schema/packages/node-library/index.js +0 -10
- package/dist/schema/packages/node-library/index.js.map +0 -1
- package/dist/schema/packages/types.d.ts +0 -6
- package/dist/schema/packages/types.d.ts.map +0 -1
- package/dist/schema/packages/types.js +0 -6
- package/dist/schema/packages/types.js.map +0 -1
- /package/dist/plugins/{schema → store}/index.d.ts +0 -0
- /package/dist/plugins/{schema → store}/index.js +0 -0
|
@@ -1,81 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { assertNoDuplicates } from '@baseplate-dev/utils';
|
|
2
|
+
import { mapValues } from 'es-toolkit';
|
|
3
3
|
import { stripUndefinedValues } from '#src/utils/strip.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// create export map of plugin ID to export spec name
|
|
17
|
-
const pluginModuleIdByExport = mapValues(initialSpecImplementations, () => 'built-in');
|
|
18
|
-
for (const { name, module, id } of pluginModules) {
|
|
19
|
-
for (const m of Object.values(module.exports ?? {})) {
|
|
20
|
-
const exportName = m.name;
|
|
21
|
-
if (exportName in pluginModuleIdByExport) {
|
|
22
|
-
const existingPlugin = pluginModulesById[pluginModuleIdByExport[exportName]];
|
|
23
|
-
throw new Error(`Duplicate export from plugins found ${exportName} (${name} and ${existingPlugin.name})`);
|
|
24
|
-
}
|
|
25
|
-
pluginModuleIdByExport[exportName] = id;
|
|
4
|
+
import { runInPluginContext } from '../context/plugin-context.js';
|
|
5
|
+
import { PluginSpecStore } from '../store/store.js';
|
|
6
|
+
/**
|
|
7
|
+
* Initialize ordered plugin modules.
|
|
8
|
+
* Each module's initialize function is called within a plugin context.
|
|
9
|
+
*/
|
|
10
|
+
export function initializeOrderedModules(orderedModules) {
|
|
11
|
+
const instances = new Map();
|
|
12
|
+
function use(spec) {
|
|
13
|
+
if (!instances.has(spec.name)) {
|
|
14
|
+
const instance = spec.initializer();
|
|
15
|
+
instances.set(spec.name, instance);
|
|
26
16
|
}
|
|
17
|
+
return instances.get(spec.name);
|
|
27
18
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.map((m) => {
|
|
31
|
-
const resolvedDep = pluginModuleIdByExport[m.name];
|
|
32
|
-
if (!resolvedDep) {
|
|
33
|
-
if (m.isOptional) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
throw new Error(`Cannot resolve plugin dependency for ${name} (${m.name})`);
|
|
37
|
-
}
|
|
38
|
-
if (resolvedDep === 'built-in') {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
return [resolvedDep, id];
|
|
42
|
-
})
|
|
43
|
-
.filter((x) => x !== undefined));
|
|
44
|
-
const nodes = pluginModules.map((p) => p.id);
|
|
45
|
-
return toposortOrdered(nodes, edges);
|
|
46
|
-
}
|
|
47
|
-
export function initializeOrderedPluginModules(orderedPluginModules, initialSpecImplementations) {
|
|
48
|
-
const specImplementations = { ...initialSpecImplementations };
|
|
49
|
-
for (const { name, module, pluginKey } of orderedPluginModules) {
|
|
19
|
+
for (const { module, key: moduleKey, pluginKey } of orderedModules) {
|
|
20
|
+
// Resolve dependencies by getting their setup interfaces
|
|
50
21
|
const dependencies = module.dependencies
|
|
51
|
-
? stripUndefinedValues(mapValues(module.dependencies, (
|
|
52
|
-
const implementation = specImplementations[dep.name];
|
|
53
|
-
if (!implementation && !dep.isOptional) {
|
|
54
|
-
throw new Error(`Plugin ${name} missing dependency ${dep.name}`);
|
|
55
|
-
}
|
|
56
|
-
return implementation;
|
|
57
|
-
}))
|
|
22
|
+
? stripUndefinedValues(mapValues(module.dependencies, (spec) => use(spec).init))
|
|
58
23
|
: {};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const exportedImplementation = exports[key];
|
|
63
|
-
if (!exportedImplementation) {
|
|
64
|
-
throw new Error(`Plugin ${name} did not return required export ${key}`);
|
|
65
|
-
}
|
|
66
|
-
specImplementations[spec.name] = exportedImplementation;
|
|
24
|
+
// Run initialize within plugin context for source tracking
|
|
25
|
+
runInPluginContext({ moduleKey, pluginKey }, () => {
|
|
26
|
+
module.initialize(dependencies, { moduleKey, pluginKey });
|
|
67
27
|
});
|
|
68
28
|
}
|
|
69
|
-
return
|
|
29
|
+
return instances;
|
|
70
30
|
}
|
|
71
31
|
/**
|
|
72
|
-
* Initialize the plugins based on their interdependencies
|
|
32
|
+
* Initialize the plugins based on their interdependencies.
|
|
33
|
+
* Returns a store that can be used to access spec implementations.
|
|
73
34
|
*/
|
|
74
|
-
export function initializePlugins(
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
const specImplementations = initializeOrderedPluginModules(orderedModuleIds.map((p) => pluginModulesById[p]), initialSpecImplementations);
|
|
79
|
-
return new PluginImplementationStore(specImplementations);
|
|
35
|
+
export function initializePlugins(pluginModules) {
|
|
36
|
+
assertNoDuplicates(pluginModules, 'plugin modules', (m) => m.key);
|
|
37
|
+
const instances = initializeOrderedModules(pluginModules);
|
|
38
|
+
return new PluginSpecStore(instances);
|
|
80
39
|
}
|
|
81
40
|
//# sourceMappingURL=loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/plugins/imports/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/plugins/imports/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAK3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,cAAqC;IAErC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAuC,CAAC;IAEjE,SAAS,GAAG,CACV,IAA6B;QAE7B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YACpC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAA6C,CAAC;IAC9E,CAAC;IAED,KAAK,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,cAAc,EAAE,CAAC;QACnE,yDAAyD;QACzD,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY;YACtC,CAAC,CAAC,oBAAoB,CAClB,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CACzD;YACH,CAAC,CAAC,EAAE,CAAC;QAEP,2DAA2D;QAC3D,kBAAkB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE;YAChD,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,aAAoC;IAEpC,kBAAkB,CAAC,aAAa,EAAE,gBAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAElE,MAAM,SAAS,GAAG,wBAAwB,CAAC,aAAa,CAAC,CAAC;IAE1D,OAAO,IAAI,eAAe,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -1,27 +1,86 @@
|
|
|
1
1
|
import type { PluginMetadataWithPaths } from '../metadata/types.js';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import type { InferPluginSpecInit, PluginSpec } from '../spec/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* A map of spec names to plugin specs.
|
|
5
|
+
*/
|
|
6
|
+
type PluginSpecMap = Record<string, PluginSpec>;
|
|
7
|
+
/**
|
|
8
|
+
* Extracts init interfaces from a spec map.
|
|
9
|
+
* Used for providing dependencies to plugin initializers.
|
|
10
|
+
*/
|
|
11
|
+
type ExtractInitFromSpecMap<T extends PluginSpecMap> = {
|
|
12
|
+
[TKey in keyof T]: InferPluginSpecInit<T[TKey]>;
|
|
6
13
|
};
|
|
7
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Context provided to plugin module initializers.
|
|
16
|
+
*/
|
|
17
|
+
export interface ModuleContext {
|
|
18
|
+
/** Full module key: "{pluginKey}/{moduleDir}/{name}" or "core/{platform}/{name}" */
|
|
19
|
+
moduleKey: string;
|
|
20
|
+
/** The plugin key (or "core" for core modules) */
|
|
8
21
|
pluginKey: string;
|
|
9
22
|
}
|
|
10
|
-
|
|
23
|
+
/**
|
|
24
|
+
* A plugin module defines how a plugin initializes and registers with specs.
|
|
25
|
+
*/
|
|
26
|
+
export interface PluginModule<TImports extends PluginSpecMap = PluginSpecMap> {
|
|
27
|
+
/** Unique name for this module within its plugin/core directory */
|
|
28
|
+
name: string;
|
|
29
|
+
/** Specs this module depends on (will be resolved before initialize is called) */
|
|
11
30
|
dependencies?: TImports;
|
|
12
|
-
|
|
13
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Initialize the plugin module and register with the dependent specs.
|
|
33
|
+
*/
|
|
34
|
+
initialize: (dependencies: ExtractInitFromSpecMap<TImports>, context: ModuleContext) => void;
|
|
14
35
|
}
|
|
15
|
-
|
|
16
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Creates a plugin module export.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* export default createPluginModule({
|
|
42
|
+
* name: 'node',
|
|
43
|
+
* dependencies: {
|
|
44
|
+
* config: pluginConfigSpec,
|
|
45
|
+
* },
|
|
46
|
+
* initialize: ({ config }, ctx) => {
|
|
47
|
+
* config.registerSchemaCreator(ctx.pluginKey, createSchema);
|
|
48
|
+
* },
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function createPluginModule<TImports extends PluginSpecMap>(config: PluginModule<TImports>): PluginModule;
|
|
53
|
+
/**
|
|
54
|
+
* A plugin module with a module directory.
|
|
55
|
+
*/
|
|
56
|
+
export interface PluginModuleWithDirectory {
|
|
57
|
+
/** The module directory within the plugin (e.g., "core", "admin") */
|
|
58
|
+
directory: string;
|
|
59
|
+
/** The module itself */
|
|
60
|
+
module: PluginModule;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A plugin module with a key and plugin key metadata.
|
|
64
|
+
*/
|
|
65
|
+
export interface PluginModuleWithKey {
|
|
66
|
+
/** The unique key for this module (e.g., "core/server/auth-compiler" or "auth/auth0/core/web") */
|
|
17
67
|
key: string;
|
|
18
|
-
|
|
68
|
+
/** The plugin key (or "core" for core modules) */
|
|
69
|
+
pluginKey: string;
|
|
70
|
+
/**
|
|
71
|
+
* The module itself
|
|
72
|
+
*/
|
|
73
|
+
module: PluginModule;
|
|
19
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* The plugin store containing all available plugins and additional core modules (project-builder-lib core modules are always included).
|
|
77
|
+
*/
|
|
20
78
|
export interface PluginStore {
|
|
21
79
|
availablePlugins: {
|
|
22
80
|
metadata: PluginMetadataWithPaths;
|
|
23
|
-
modules:
|
|
81
|
+
modules: PluginModuleWithDirectory[];
|
|
24
82
|
}[];
|
|
25
|
-
|
|
83
|
+
coreModules: PluginModuleWithKey[];
|
|
26
84
|
}
|
|
85
|
+
export {};
|
|
27
86
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/imports/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/imports/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAExE;;GAEG;AACH,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAEhD;;;GAGG;AACH,KAAK,sBAAsB,CAAC,CAAC,SAAS,aAAa,IAAI;KACpD,IAAI,IAAI,MAAM,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,QAAQ,SAAS,aAAa,GAAG,aAAa;IAC1E,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB;;OAEG;IACH,UAAU,EAAE,CACV,YAAY,EAAE,sBAAsB,CAAC,QAAQ,CAAC,EAC9C,OAAO,EAAE,aAAa,KACnB,IAAI,CAAC;CACX;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,SAAS,aAAa,EAC/D,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,GAC7B,YAAY,CAEd;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,wBAAwB;IACxB,MAAM,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,kGAAkG;IAClG,GAAG,EAAE,MAAM,CAAC;IACZ,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE;QAChB,QAAQ,EAAE,uBAAuB,CAAC;QAClC,OAAO,EAAE,yBAAyB,EAAE,CAAC;KACtC,EAAE,CAAC;IACJ,WAAW,EAAE,mBAAmB,EAAE,CAAC;CACpC"}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Creates a plugin module export.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* export default createPluginModule({
|
|
7
|
+
* name: 'node',
|
|
8
|
+
* dependencies: {
|
|
9
|
+
* config: pluginConfigSpec,
|
|
10
|
+
* },
|
|
11
|
+
* initialize: ({ config }, ctx) => {
|
|
12
|
+
* config.registerSchemaCreator(ctx.pluginKey, createSchema);
|
|
13
|
+
* },
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function createPluginModule(config) {
|
|
2
18
|
return config;
|
|
3
19
|
}
|
|
4
20
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugins/imports/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugins/imports/types.ts"],"names":[],"mappings":"AA2CA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA8B;IAE9B,OAAO,MAAsB,CAAC;AAChC,CAAC"}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from './context/index.js';
|
|
1
2
|
export * from './imports/index.js';
|
|
2
3
|
export * from './metadata/index.js';
|
|
3
4
|
export * from './migrations/index.js';
|
|
4
|
-
export * from './schema/index.js';
|
|
5
5
|
export * from './spec/index.js';
|
|
6
|
+
export * from './store/index.js';
|
|
7
|
+
export * from './utils/index.js';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from './context/index.js';
|
|
1
2
|
export * from './imports/index.js';
|
|
2
3
|
export * from './metadata/index.js';
|
|
3
4
|
export * from './migrations/index.js';
|
|
4
|
-
export * from './schema/index.js';
|
|
5
5
|
export * from './spec/index.js';
|
|
6
|
+
export * from './store/index.js';
|
|
7
|
+
export * from './utils/index.js';
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ProjectDefinition } from '#src/schema/project-definition.js';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function runPluginMigrations(projectDefinition: ProjectDefinition,
|
|
2
|
+
import type { PluginSpecStore } from '../store/store.js';
|
|
3
|
+
export declare function runPluginMigrations(projectDefinition: ProjectDefinition, pluginSpecStore: PluginSpecStore): ProjectDefinition;
|
|
4
4
|
//# sourceMappingURL=run-migrations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-migrations.d.ts","sourceRoot":"","sources":["../../../src/plugins/migrations/run-migrations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAI3E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"run-migrations.d.ts","sourceRoot":"","sources":["../../../src/plugins/migrations/run-migrations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAI3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzD,wBAAgB,mBAAmB,CACjC,iBAAiB,EAAE,iBAAiB,EACpC,eAAe,EAAE,eAAe,GAC/B,iBAAiB,CAqCnB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { produce } from 'immer';
|
|
2
2
|
import { pluginEntityType } from '#src/schema/plugins/entity-types.js';
|
|
3
3
|
import { pluginConfigSpec } from '../spec/config-spec.js';
|
|
4
|
-
export function runPluginMigrations(projectDefinition,
|
|
5
|
-
const pluginConfigService =
|
|
4
|
+
export function runPluginMigrations(projectDefinition, pluginSpecStore) {
|
|
5
|
+
const pluginConfigService = pluginSpecStore.use(pluginConfigSpec);
|
|
6
6
|
return produce(projectDefinition, (draft) => {
|
|
7
7
|
for (const pluginDefinition of draft.plugins ?? []) {
|
|
8
8
|
const pluginMigrations = pluginConfigService.getMigrations(pluginEntityType.keyFromId(pluginDefinition.id));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-migrations.js","sourceRoot":"","sources":["../../../src/plugins/migrations/run-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAIvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,UAAU,mBAAmB,CACjC,iBAAoC,EACpC,
|
|
1
|
+
{"version":3,"file":"run-migrations.js","sourceRoot":"","sources":["../../../src/plugins/migrations/run-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAIvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,UAAU,mBAAmB,CACjC,iBAAoC,EACpC,eAAgC;IAEhC,MAAM,mBAAmB,GAAG,eAAe,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClE,OAAO,OAAO,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC1C,KAAK,MAAM,gBAAgB,IAAI,KAAK,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YACnD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,aAAa,CACxD,gBAAgB,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAChD,CAAC;YACF,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,mBAAmB,IAAI,CAAC,CAAC,CAAC;YACxE,IAAI,CAAC,gBAAgB;gBAAE,SAAS;YAChC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,IAAI,CAAC,mBAAmB;gBAAE,SAAS;YAEnC,KAAK,MAAM,SAAS,IAAI,gBAAgB,EAAE,CAAC;gBACzC,IAAI,SAAS,CAAC,OAAO,GAAG,oBAAoB,EAAE,CAAC;oBAC7C,IAAI,CAAC;wBACH,MAAM,eAAe,GAAG,SAAS,CAAC,OAAO,CACvC,gBAAgB,CAAC,MAAM,EACvB,KAAK,CACN,CAAC;wBAEF,IAAI,eAAe,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;4BAChD,gBAAgB,CAAC,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC;wBAC1D,CAAC;wBAED,IAAI,eAAe,CAAC,uBAAuB,EAAE,CAAC;4BAC5C,eAAe,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;wBACjD,CAAC;oBACH,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CACb,0BAA0B,gBAAgB,CAAC,EAAE,eAAe,SAAS,CAAC,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAClG,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;YACD,gBAAgB,CAAC,mBAAmB,GAAG,mBAAmB,CAAC,OAAO,CAAC;QACrE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import type { ProjectDefinition } from '#src/schema/project-definition.js';
|
|
2
|
-
import type { PluginSpecImplementation } from './types.js';
|
|
3
2
|
export interface AuthRole {
|
|
4
3
|
id: string;
|
|
5
4
|
name: string;
|
|
6
5
|
comment: string;
|
|
7
6
|
builtIn: boolean;
|
|
8
7
|
}
|
|
9
|
-
type
|
|
8
|
+
type AuthConfigGetter = (definition: ProjectDefinition) => {
|
|
9
|
+
roles: AuthRole[];
|
|
10
|
+
};
|
|
10
11
|
/**
|
|
11
12
|
* Spec for allowing plugins to declare standard auth configurations
|
|
12
13
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
export declare const authConfigSpec: import("./types.js").PluginSpec<{
|
|
15
|
+
getAuthConfig: import("@baseplate-dev/utils").ScalarContainer<AuthConfigGetter | undefined>;
|
|
16
|
+
}, {
|
|
17
|
+
getAuthConfig: (definition: ProjectDefinition) => {
|
|
18
|
+
roles: AuthRole[];
|
|
19
|
+
} | undefined;
|
|
20
|
+
getAuthConfigOrThrow: (definition: ProjectDefinition) => {
|
|
21
|
+
roles: AuthRole[];
|
|
22
|
+
};
|
|
23
|
+
}>;
|
|
20
24
|
export {};
|
|
21
25
|
//# sourceMappingURL=auth-config-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-config-spec.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/auth-config-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-config-spec.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/auth-config-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAI3E,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,KAAK,gBAAgB,GAAG,CAAC,UAAU,EAAE,iBAAiB,KAAK;IACzD,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;;;gCAOO,iBAAiB;eAb1C,QAAQ,EAAE;;uCAesB,iBAAiB;eAfjD,QAAQ,EAAE;;EAwBlB,CAAC"}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createFieldMapSpec } from '../utils/create-field-map-spec.js';
|
|
2
2
|
/**
|
|
3
|
-
* Spec for
|
|
3
|
+
* Spec for allowing plugins to declare standard auth configurations
|
|
4
4
|
*/
|
|
5
|
-
export const authConfigSpec =
|
|
5
|
+
export const authConfigSpec = createFieldMapSpec('core/auth-config', (t) => ({
|
|
6
|
+
getAuthConfig: t.scalar(),
|
|
7
|
+
}), {
|
|
8
|
+
use: (values) => ({
|
|
9
|
+
getAuthConfig: (definition) => values.getAuthConfig?.(definition),
|
|
10
|
+
getAuthConfigOrThrow: (definition) => {
|
|
11
|
+
const config = values.getAuthConfig?.(definition);
|
|
12
|
+
if (!config) {
|
|
13
|
+
throw new Error('Auth config not found');
|
|
14
|
+
}
|
|
15
|
+
return config;
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
6
19
|
//# sourceMappingURL=auth-config-spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-config-spec.js","sourceRoot":"","sources":["../../../src/plugins/spec/auth-config-spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth-config-spec.js","sourceRoot":"","sources":["../../../src/plugins/spec/auth-config-spec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAavE;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAC9C,kBAAkB,EAClB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACN,aAAa,EAAE,CAAC,CAAC,MAAM,EAAoB;CAC5C,CAAC,EACF;IACE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChB,aAAa,EAAE,CAAC,UAA6B,EAAE,EAAE,CAC/C,MAAM,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC;QACpC,oBAAoB,EAAE,CAAC,UAA6B,EAAE,EAAE;YACtD,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,CAAC;YAClD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;CACH,CACF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProjectDefinition } from '#src/schema/project-definition.js';
|
|
2
|
+
type AuthModelsGetter = (definition: ProjectDefinition) => {
|
|
3
|
+
user: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const authModelsSpec: import("./types.js").PluginSpec<{
|
|
6
|
+
getAuthModels: import("@baseplate-dev/utils").ScalarContainer<AuthModelsGetter | undefined>;
|
|
7
|
+
}, {
|
|
8
|
+
getAuthModels: (definition: ProjectDefinition) => {
|
|
9
|
+
user: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
getAuthModelsOrThrow: (definition: ProjectDefinition) => {
|
|
12
|
+
user: string;
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=auth-models-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-models-spec.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/auth-models-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAI3E,KAAK,gBAAgB,GAAG,CAAC,UAAU,EAAE,iBAAiB,KAAK;IACzD,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,cAAc;;;gCAOO,iBAAiB;cAV3C,MAAM;;uCAY2B,iBAAiB;cAZlD,MAAM;;EAqBb,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createFieldMapSpec } from '../utils/create-field-map-spec.js';
|
|
2
|
+
export const authModelsSpec = createFieldMapSpec('core/auth-models', (t) => ({
|
|
3
|
+
getAuthModels: t.scalar(),
|
|
4
|
+
}), {
|
|
5
|
+
use: (values) => ({
|
|
6
|
+
getAuthModels: (definition) => values.getAuthModels?.(definition),
|
|
7
|
+
getAuthModelsOrThrow: (definition) => {
|
|
8
|
+
const authModels = values.getAuthModels?.(definition);
|
|
9
|
+
if (!authModels) {
|
|
10
|
+
throw new Error('Auth models not found');
|
|
11
|
+
}
|
|
12
|
+
return authModels;
|
|
13
|
+
},
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=auth-models-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-models-spec.js","sourceRoot":"","sources":["../../../src/plugins/spec/auth-models-spec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAMvE,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAC9C,kBAAkB,EAClB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACN,aAAa,EAAE,CAAC,CAAC,MAAM,EAAoB;CAC5C,CAAC,EACF;IACE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChB,aAAa,EAAE,CAAC,UAA6B,EAAE,EAAE,CAC/C,MAAM,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC;QACpC,oBAAoB,EAAE,CAAC,UAA6B,EAAE,EAAE;YACtD,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,CAAC;YACtD,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC;CACH,CACF,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { DefinitionSchemaCreator } from '#src/schema/index.js';
|
|
2
|
-
import type { PluginSpecImplementation } from './types.js';
|
|
3
2
|
export interface PluginMigrationResult {
|
|
4
3
|
updatedConfig?: unknown;
|
|
5
4
|
updateProjectDefinition?: (draft: unknown) => void;
|
|
@@ -16,17 +15,6 @@ export interface PluginConfigMigration {
|
|
|
16
15
|
*/
|
|
17
16
|
migrate: (config: unknown, projectDefinition: unknown) => PluginMigrationResult;
|
|
18
17
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Spec for registering plugin config schema
|
|
21
|
-
*/
|
|
22
|
-
export interface PluginConfigSpec extends PluginSpecImplementation {
|
|
23
|
-
registerSchemaCreator: (pluginKey: string, schemaCreator: DefinitionSchemaCreator) => void;
|
|
24
|
-
registerMigrations: (pluginKey: string, migrations: PluginConfigMigration[]) => void;
|
|
25
|
-
getSchemaCreator(pluginKey: string): DefinitionSchemaCreator | undefined;
|
|
26
|
-
getMigrations(pluginKey: string): PluginConfigMigration[] | undefined;
|
|
27
|
-
getLastMigrationVersion(pluginKey: string): number | undefined;
|
|
28
|
-
}
|
|
29
|
-
export declare function createPluginConfigImplementation(): PluginConfigSpec;
|
|
30
18
|
/**
|
|
31
19
|
* Spec for adding config for the plugin in the core plugin e.g.
|
|
32
20
|
* {
|
|
@@ -38,5 +26,12 @@ export declare function createPluginConfigImplementation(): PluginConfigSpec;
|
|
|
38
26
|
* }]
|
|
39
27
|
* }
|
|
40
28
|
*/
|
|
41
|
-
export declare const pluginConfigSpec: import("./types.js").
|
|
29
|
+
export declare const pluginConfigSpec: import("./types.js").PluginSpec<{
|
|
30
|
+
schemas: import("@baseplate-dev/utils").MapContainer<string, DefinitionSchemaCreator>;
|
|
31
|
+
migrations: import("@baseplate-dev/utils").MapContainer<string, PluginConfigMigration[]>;
|
|
32
|
+
}, {
|
|
33
|
+
getSchemaCreator: (pluginKey: string) => DefinitionSchemaCreator | undefined;
|
|
34
|
+
getMigrations: (pluginKey: string) => PluginConfigMigration[] | undefined;
|
|
35
|
+
getLastMigrationVersion: (pluginKey: string) => number | undefined;
|
|
36
|
+
}>;
|
|
42
37
|
//# sourceMappingURL=config-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-spec.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/config-spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-spec.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/config-spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAIpE,MAAM,WAAW,qBAAqB;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpD;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,OAAO,EAAE,CACP,MAAM,EAAE,OAAO,EACf,iBAAiB,EAAE,OAAO,KACvB,qBAAqB,CAAC;CAC5B;AAyBD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB;;;;kCAcS,MAAM;+BACT,MAAM;yCAEI,MAAM;EAOlD,CAAC"}
|
|
@@ -1,46 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { mapValuesOfMap } from '@baseplate-dev/utils';
|
|
2
|
+
import { createFieldMapSpec } from '../utils/create-field-map-spec.js';
|
|
3
|
+
function sortAndValidateMigrations(migrations, pluginKey) {
|
|
3
4
|
// make sure migrations are sorted by version and they are all unique
|
|
4
5
|
const sortedMigrations = [...migrations].sort((a, b) => a.version - b.version);
|
|
5
6
|
if (sortedMigrations.some((m) => m.version <= 0)) {
|
|
6
|
-
throw new Error(`
|
|
7
|
+
throw new Error(`All migrations for plugin ${pluginKey} must have a positive version`);
|
|
7
8
|
}
|
|
8
9
|
for (let i = 0; i < sortedMigrations.length - 1; i++) {
|
|
9
10
|
if (sortedMigrations[i].version === sortedMigrations[i + 1].version) {
|
|
10
|
-
throw new Error(`
|
|
11
|
+
throw new Error(`All migrations for plugin ${pluginKey} must have a unique version`);
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
return sortedMigrations;
|
|
14
15
|
}
|
|
15
|
-
export function createPluginConfigImplementation() {
|
|
16
|
-
const schemas = new Map();
|
|
17
|
-
const migrationsMap = new Map();
|
|
18
|
-
return {
|
|
19
|
-
registerSchemaCreator(pluginKey, schemaCreator) {
|
|
20
|
-
if (schemas.has(pluginKey)) {
|
|
21
|
-
throw new Error(`Schema for plugin ${pluginKey} is already registered`);
|
|
22
|
-
}
|
|
23
|
-
schemas.set(pluginKey, schemaCreator);
|
|
24
|
-
},
|
|
25
|
-
registerMigrations(pluginKey, migrations) {
|
|
26
|
-
if (migrationsMap.has(pluginKey)) {
|
|
27
|
-
throw new Error(`Migrations for plugin ${pluginKey} are already registered`);
|
|
28
|
-
}
|
|
29
|
-
const sortedMigrations = sortAndValidateMigrations(migrations);
|
|
30
|
-
migrationsMap.set(pluginKey, sortedMigrations);
|
|
31
|
-
},
|
|
32
|
-
getSchemaCreator(pluginKey) {
|
|
33
|
-
return schemas.get(pluginKey);
|
|
34
|
-
},
|
|
35
|
-
getMigrations(pluginKey) {
|
|
36
|
-
return migrationsMap.get(pluginKey);
|
|
37
|
-
},
|
|
38
|
-
getLastMigrationVersion(pluginKey) {
|
|
39
|
-
const migrations = migrationsMap.get(pluginKey);
|
|
40
|
-
return migrations?.[migrations.length - 1]?.version;
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
16
|
/**
|
|
45
17
|
* Spec for adding config for the plugin in the core plugin e.g.
|
|
46
18
|
* {
|
|
@@ -52,7 +24,20 @@ export function createPluginConfigImplementation() {
|
|
|
52
24
|
* }]
|
|
53
25
|
* }
|
|
54
26
|
*/
|
|
55
|
-
export const pluginConfigSpec =
|
|
56
|
-
|
|
27
|
+
export const pluginConfigSpec = createFieldMapSpec('core/plugin-config', (t) => ({
|
|
28
|
+
schemas: t.map(),
|
|
29
|
+
migrations: t.map(),
|
|
30
|
+
}), {
|
|
31
|
+
use: (values) => {
|
|
32
|
+
const validatedMigrations = mapValuesOfMap(values.migrations, (migrations, pluginKey) => sortAndValidateMigrations(migrations, pluginKey));
|
|
33
|
+
return {
|
|
34
|
+
getSchemaCreator: (pluginKey) => values.schemas.get(pluginKey),
|
|
35
|
+
getMigrations: (pluginKey) => validatedMigrations.get(pluginKey),
|
|
36
|
+
getLastMigrationVersion: (pluginKey) => {
|
|
37
|
+
const migrations = values.migrations.get(pluginKey);
|
|
38
|
+
return migrations?.[migrations.length - 1]?.version;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
},
|
|
57
42
|
});
|
|
58
43
|
//# sourceMappingURL=config-spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-spec.js","sourceRoot":"","sources":["../../../src/plugins/spec/config-spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-spec.js","sourceRoot":"","sources":["../../../src/plugins/spec/config-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAuBvE,SAAS,yBAAyB,CAChC,UAAmC,EACnC,SAAiB;IAEjB,qEAAqE;IACrE,MAAM,gBAAgB,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAC3C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAChC,CAAC;IACF,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CACb,6BAA6B,SAAS,+BAA+B,CACtE,CAAC;IACJ,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACpE,MAAM,IAAI,KAAK,CACb,6BAA6B,SAAS,6BAA6B,CACpE,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAChD,oBAAoB,EACpB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,GAAG,EAAmC;IACjD,UAAU,EAAE,CAAC,CAAC,GAAG,EAAmC;CACrD,CAAC,EACF;IACE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE;QACd,MAAM,mBAAmB,GAAG,cAAc,CACxC,MAAM,CAAC,UAAU,EACjB,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,CACxB,yBAAyB,CAAC,UAAU,EAAE,SAAS,CAAC,CACnD,CAAC;QACF,OAAO;YACL,gBAAgB,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;YACtE,aAAa,EAAE,CAAC,SAAiB,EAAE,EAAE,CACnC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC;YACpC,uBAAuB,EAAE,CAAC,SAAiB,EAAE,EAAE;gBAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBACpD,OAAO,UAAU,EAAE,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC;YACtD,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC"}
|