@baseplate-dev/project-builder-server 0.1.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/LICENSE +390 -0
- package/dist/api/context.d.ts +15 -0
- package/dist/api/context.d.ts.map +1 -0
- package/dist/api/context.js +21 -0
- package/dist/api/context.js.map +1 -0
- package/dist/api/index.d.ts +287 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +12 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/plugins.d.ts +35 -0
- package/dist/api/plugins.d.ts.map +1 -0
- package/dist/api/plugins.js +13 -0
- package/dist/api/plugins.js.map +1 -0
- package/dist/api/projects.d.ts +62 -0
- package/dist/api/projects.d.ts.map +1 -0
- package/dist/api/projects.js +64 -0
- package/dist/api/projects.js.map +1 -0
- package/dist/api/sync.d.ts +134 -0
- package/dist/api/sync.d.ts.map +1 -0
- package/dist/api/sync.js +90 -0
- package/dist/api/sync.js.map +1 -0
- package/dist/api/trpc.d.ts +50 -0
- package/dist/api/trpc.d.ts.map +1 -0
- package/dist/api/trpc.js +39 -0
- package/dist/api/trpc.js.map +1 -0
- package/dist/api/types.d.ts +13 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/version.d.ts +40 -0
- package/dist/api/version.d.ts.map +1 -0
- package/dist/api/version.js +9 -0
- package/dist/api/version.js.map +1 -0
- package/dist/compiler/admin/crud/displays.d.ts +5 -0
- package/dist/compiler/admin/crud/displays.d.ts.map +1 -0
- package/dist/compiler/admin/crud/displays.js +46 -0
- package/dist/compiler/admin/crud/displays.js.map +1 -0
- package/dist/compiler/admin/crud/index.d.ts +5 -0
- package/dist/compiler/admin/crud/index.d.ts.map +1 -0
- package/dist/compiler/admin/crud/index.js +90 -0
- package/dist/compiler/admin/crud/index.js.map +1 -0
- package/dist/compiler/admin/crud/inputs.d.ts +5 -0
- package/dist/compiler/admin/crud/inputs.d.ts.map +1 -0
- package/dist/compiler/admin/crud/inputs.js +146 -0
- package/dist/compiler/admin/crud/inputs.js.map +1 -0
- package/dist/compiler/admin/index.d.ts +3 -0
- package/dist/compiler/admin/index.d.ts.map +1 -0
- package/dist/compiler/admin/index.js +95 -0
- package/dist/compiler/admin/index.js.map +1 -0
- package/dist/compiler/admin/sections.d.ts +5 -0
- package/dist/compiler/admin/sections.d.ts.map +1 -0
- package/dist/compiler/admin/sections.js +54 -0
- package/dist/compiler/admin/sections.js.map +1 -0
- package/dist/compiler/app-entry-builder.d.ts +19 -0
- package/dist/compiler/app-entry-builder.d.ts.map +1 -0
- package/dist/compiler/app-entry-builder.js +45 -0
- package/dist/compiler/app-entry-builder.js.map +1 -0
- package/dist/compiler/backend/enums.d.ts +4 -0
- package/dist/compiler/backend/enums.d.ts.map +1 -0
- package/dist/compiler/backend/enums.js +14 -0
- package/dist/compiler/backend/enums.js.map +1 -0
- package/dist/compiler/backend/fastify.d.ts +5 -0
- package/dist/compiler/backend/fastify.d.ts.map +1 -0
- package/dist/compiler/backend/fastify.js +62 -0
- package/dist/compiler/backend/fastify.js.map +1 -0
- package/dist/compiler/backend/feature.d.ts +4 -0
- package/dist/compiler/backend/feature.d.ts.map +1 -0
- package/dist/compiler/backend/feature.js +26 -0
- package/dist/compiler/backend/feature.js.map +1 -0
- package/dist/compiler/backend/graphql.d.ts +4 -0
- package/dist/compiler/backend/graphql.d.ts.map +1 -0
- package/dist/compiler/backend/graphql.js +171 -0
- package/dist/compiler/backend/graphql.js.map +1 -0
- package/dist/compiler/backend/index.d.ts +3 -0
- package/dist/compiler/backend/index.d.ts.map +1 -0
- package/dist/compiler/backend/index.js +34 -0
- package/dist/compiler/backend/index.js.map +1 -0
- package/dist/compiler/backend/models.d.ts +4 -0
- package/dist/compiler/backend/models.d.ts.map +1 -0
- package/dist/compiler/backend/models.js +79 -0
- package/dist/compiler/backend/models.js.map +1 -0
- package/dist/compiler/backend/services.d.ts +4 -0
- package/dist/compiler/backend/services.d.ts.map +1 -0
- package/dist/compiler/backend/services.js +90 -0
- package/dist/compiler/backend/services.js.map +1 -0
- package/dist/compiler/backend/utils.d.ts +16 -0
- package/dist/compiler/backend/utils.d.ts.map +1 -0
- package/dist/compiler/backend/utils.js +17 -0
- package/dist/compiler/backend/utils.js.map +1 -0
- package/dist/compiler/index.d.ts +3 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +31 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/web/features.d.ts +5 -0
- package/dist/compiler/web/features.d.ts.map +1 -0
- package/dist/compiler/web/features.js +30 -0
- package/dist/compiler/web/features.js.map +1 -0
- package/dist/compiler/web/index.d.ts +3 -0
- package/dist/compiler/web/index.d.ts.map +1 -0
- package/dist/compiler/web/index.js +58 -0
- package/dist/compiler/web/index.js.map +1 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +2 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/server.d.ts +2 -0
- package/dist/constants/server.d.ts.map +1 -0
- package/dist/constants/server.js +2 -0
- package/dist/constants/server.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +3 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/node-plugin-store.d.ts +6 -0
- package/dist/plugins/node-plugin-store.d.ts.map +1 -0
- package/dist/plugins/node-plugin-store.js +40 -0
- package/dist/plugins/node-plugin-store.js.map +1 -0
- package/dist/plugins/plugin-discovery.d.ts +7 -0
- package/dist/plugins/plugin-discovery.d.ts.map +1 -0
- package/dist/plugins/plugin-discovery.js +50 -0
- package/dist/plugins/plugin-discovery.js.map +1 -0
- package/dist/server/builder-service-manager.d.ts +32 -0
- package/dist/server/builder-service-manager.d.ts.map +1 -0
- package/dist/server/builder-service-manager.js +52 -0
- package/dist/server/builder-service-manager.js.map +1 -0
- package/dist/server/graceful-shutdown.d.ts +2 -0
- package/dist/server/graceful-shutdown.d.ts.map +1 -0
- package/dist/server/graceful-shutdown.js +25 -0
- package/dist/server/graceful-shutdown.js.map +1 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/plugin.d.ts +12 -0
- package/dist/server/plugin.d.ts.map +1 -0
- package/dist/server/plugin.js +109 -0
- package/dist/server/plugin.js.map +1 -0
- package/dist/server/server.d.ts +16 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +47 -0
- package/dist/server/server.js.map +1 -0
- package/dist/service/builder-service.d.ts +154 -0
- package/dist/service/builder-service.d.ts.map +1 -0
- package/dist/service/builder-service.js +338 -0
- package/dist/service/builder-service.js.map +1 -0
- package/dist/sync/build-project.d.ts +54 -0
- package/dist/sync/build-project.d.ts.map +1 -0
- package/dist/sync/build-project.js +173 -0
- package/dist/sync/build-project.js.map +1 -0
- package/dist/sync/conflict-file-monitor.d.ts +27 -0
- package/dist/sync/conflict-file-monitor.d.ts.map +1 -0
- package/dist/sync/conflict-file-monitor.js +125 -0
- package/dist/sync/conflict-file-monitor.js.map +1 -0
- package/dist/sync/generate-for-directory.d.ts +29 -0
- package/dist/sync/generate-for-directory.d.ts.map +1 -0
- package/dist/sync/generate-for-directory.js +132 -0
- package/dist/sync/generate-for-directory.js.map +1 -0
- package/dist/sync/generator-steps-writer.d.ts +3 -0
- package/dist/sync/generator-steps-writer.d.ts.map +1 -0
- package/dist/sync/generator-steps-writer.js +6 -0
- package/dist/sync/generator-steps-writer.js.map +1 -0
- package/dist/sync/index.d.ts +4 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +4 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/sync-metadata-controller.d.ts +29 -0
- package/dist/sync/sync-metadata-controller.d.ts.map +1 -0
- package/dist/sync/sync-metadata-controller.js +95 -0
- package/dist/sync/sync-metadata-controller.js.map +1 -0
- package/dist/sync/sync-metadata-service.d.ts +20 -0
- package/dist/sync/sync-metadata-service.d.ts.map +1 -0
- package/dist/sync/sync-metadata-service.js +31 -0
- package/dist/sync/sync-metadata-service.js.map +1 -0
- package/dist/sync/sync-metadata.d.ts +444 -0
- package/dist/sync/sync-metadata.d.ts.map +1 -0
- package/dist/sync/sync-metadata.js +80 -0
- package/dist/sync/sync-metadata.js.map +1 -0
- package/dist/sync/utils.d.ts +8 -0
- package/dist/sync/utils.d.ts.map +1 -0
- package/dist/sync/utils.js +23 -0
- package/dist/sync/utils.js.map +1 -0
- package/dist/template-extractor/index.d.ts +2 -0
- package/dist/template-extractor/index.d.ts.map +1 -0
- package/dist/template-extractor/index.js +2 -0
- package/dist/template-extractor/index.js.map +1 -0
- package/dist/template-extractor/run-template-extractor.d.ts +4 -0
- package/dist/template-extractor/run-template-extractor.d.ts.map +1 -0
- package/dist/template-extractor/run-template-extractor.js +60 -0
- package/dist/template-extractor/run-template-extractor.js.map +1 -0
- package/dist/user-config/index.d.ts +2 -0
- package/dist/user-config/index.d.ts.map +1 -0
- package/dist/user-config/index.js +2 -0
- package/dist/user-config/index.js.map +1 -0
- package/dist/user-config/user-config-schema.d.ts +46 -0
- package/dist/user-config/user-config-schema.d.ts.map +1 -0
- package/dist/user-config/user-config-schema.js +30 -0
- package/dist/user-config/user-config-schema.js.map +1 -0
- package/dist/utils/case.d.ts +3 -0
- package/dist/utils/case.d.ts.map +1 -0
- package/dist/utils/case.js +14 -0
- package/dist/utils/case.js.map +1 -0
- package/dist/utils/errors.d.ts +10 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +15 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/paths.d.ts +8 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +17 -0
- package/dist/utils/paths.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compiler/admin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACR,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAiI5C,wBAAgB,YAAY,CAC1B,mBAAmB,EAAE,0BAA0B,EAC/C,GAAG,EAAE,cAAc,GAClB,QAAQ,CA0BV"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { composeNodeGenerator } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { adminAppEntryType, AppUtils, FeatureUtils, } from '@baseplate-dev/project-builder-lib';
|
|
3
|
+
import { adminBullBoardGenerator, adminComponentsGenerator, adminHomeGenerator, adminLayoutGenerator, apolloErrorGenerator, apolloErrorLinkGenerator, apolloSentryGenerator, composeReactGenerators, reactApolloGenerator, reactComponentsGenerator, reactNotFoundHandlerGenerator, reactRouterGenerator, reactSentryGenerator, reactTailwindGenerator, } from '@baseplate-dev/react-generators';
|
|
4
|
+
import { safeMerge } from '@baseplate-dev/utils';
|
|
5
|
+
import { capitalize } from 'inflection';
|
|
6
|
+
import { dasherizeCamel, titleizeCamel } from '#src/utils/case.js';
|
|
7
|
+
import { AppEntryBuilder } from '../app-entry-builder.js';
|
|
8
|
+
import { compileAdminFeatures } from './sections.js';
|
|
9
|
+
function buildNavigationLinks(builder) {
|
|
10
|
+
const config = builder.appConfig;
|
|
11
|
+
const { projectDefinition } = builder;
|
|
12
|
+
return (config.sections?.map((section) => ({
|
|
13
|
+
type: 'link',
|
|
14
|
+
label: titleizeCamel(section.name),
|
|
15
|
+
icon: section.icon ?? 'MdHome',
|
|
16
|
+
path: `${FeatureUtils.getFeatureByIdOrThrow(projectDefinition, section.featureRef).name}/${dasherizeCamel(section.name)}`,
|
|
17
|
+
})) ?? []);
|
|
18
|
+
}
|
|
19
|
+
function buildAdmin(builder) {
|
|
20
|
+
const { projectDefinition, appConfig, appCompiler } = builder;
|
|
21
|
+
const backendApp = AppUtils.getBackendApp(projectDefinition);
|
|
22
|
+
const backendRelativePath = AppUtils.getBackendRelativePath(appConfig, backendApp);
|
|
23
|
+
const rootFeatures = appCompiler.getRootChildren();
|
|
24
|
+
const generalSettings = projectDefinition.settings.general;
|
|
25
|
+
return composeReactGenerators({
|
|
26
|
+
title: `${capitalize(generalSettings.name)} Admin Dashboard`,
|
|
27
|
+
children: {
|
|
28
|
+
reactRouter: reactRouterGenerator({
|
|
29
|
+
children: safeMerge({
|
|
30
|
+
reactNotFoundHandler: reactNotFoundHandlerGenerator({}),
|
|
31
|
+
admin: adminHomeGenerator({}),
|
|
32
|
+
adminRoutes: backendApp.enableBullQueue
|
|
33
|
+
? adminBullBoardGenerator({
|
|
34
|
+
bullBoardUrl: `http://localhost:${generalSettings.portOffset + 1}`,
|
|
35
|
+
})
|
|
36
|
+
: undefined,
|
|
37
|
+
routes: compileAdminFeatures(builder),
|
|
38
|
+
}, rootFeatures),
|
|
39
|
+
}),
|
|
40
|
+
reactComponents: reactComponentsGenerator({
|
|
41
|
+
includeDatePicker: true,
|
|
42
|
+
}),
|
|
43
|
+
reactTailwind: reactTailwindGenerator({}),
|
|
44
|
+
reactSentry: reactSentryGenerator({}),
|
|
45
|
+
reactApollo: reactApolloGenerator({
|
|
46
|
+
devApiEndpoint: '/api/graphql',
|
|
47
|
+
schemaLocation: `${backendRelativePath}/schema.graphql`,
|
|
48
|
+
children: {
|
|
49
|
+
apolloErrorLink: apolloErrorLinkGenerator({}),
|
|
50
|
+
apolloSentry: apolloSentryGenerator({}),
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
apolloError: apolloErrorGenerator({}),
|
|
54
|
+
adminLayout: adminLayoutGenerator({
|
|
55
|
+
links: [
|
|
56
|
+
{ type: 'link', label: 'Home', icon: 'MdHome', path: '/' },
|
|
57
|
+
...buildNavigationLinks(builder),
|
|
58
|
+
...(backendApp.enableBullQueue
|
|
59
|
+
? [
|
|
60
|
+
{
|
|
61
|
+
type: 'link',
|
|
62
|
+
label: 'Queues',
|
|
63
|
+
icon: 'AiOutlineOrderedList',
|
|
64
|
+
path: '/bull-board',
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
: []),
|
|
68
|
+
],
|
|
69
|
+
}),
|
|
70
|
+
adminComponents: adminComponentsGenerator({}),
|
|
71
|
+
},
|
|
72
|
+
}, {
|
|
73
|
+
// TODO: Extract out logic
|
|
74
|
+
devBackendHost: `http://localhost:${generalSettings.portOffset + 1}`,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export function compileAdmin(definitionContainer, app) {
|
|
78
|
+
const appBuilder = new AppEntryBuilder(definitionContainer, app, adminAppEntryType);
|
|
79
|
+
const { projectDefinition } = appBuilder;
|
|
80
|
+
const generalSettings = projectDefinition.settings.general;
|
|
81
|
+
const packageName = generalSettings.packageScope
|
|
82
|
+
? `@${generalSettings.packageScope}/${app.name}`
|
|
83
|
+
: `${generalSettings.name}-${app.name}`;
|
|
84
|
+
const nodeBundle = composeNodeGenerator({
|
|
85
|
+
name: `${generalSettings.name}-${app.name}`,
|
|
86
|
+
packageName,
|
|
87
|
+
description: `Admin web app for ${generalSettings.name}`,
|
|
88
|
+
version: '1.0.0',
|
|
89
|
+
children: {
|
|
90
|
+
admin: buildAdmin(appBuilder),
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
return appBuilder.buildProjectEntry(nodeBundle);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/compiler/admin/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,uBAAuB,EACv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IAEH,OAAO,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AdminAppConfig } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import type { GeneratorBundle } from '@baseplate-dev/sync';
|
|
3
|
+
import type { AppEntryBuilder } from '../app-entry-builder.js';
|
|
4
|
+
export declare function compileAdminFeatures(builder: AppEntryBuilder<AdminAppConfig>): GeneratorBundle[];
|
|
5
|
+
//# sourceMappingURL=sections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sections.d.ts","sourceRoot":"","sources":["../../../src/compiler/admin/sections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAM3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AA+E/D,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,eAAe,CAAC,cAAc,CAAC,GACvC,eAAe,EAAE,CAOnB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FeatureUtils } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import { reactRoutesGenerator } from '@baseplate-dev/react-generators';
|
|
3
|
+
import { notEmpty } from '@baseplate-dev/utils';
|
|
4
|
+
import { compileAdminCrudSection } from './crud/index.js';
|
|
5
|
+
function compileAdminSections(featureId, builder, sectionsId) {
|
|
6
|
+
const sections = builder.appConfig.sections?.filter((s) => s.featureRef === featureId);
|
|
7
|
+
if (!sections?.length) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
return sections.map((section) => {
|
|
11
|
+
if (section.type === 'crud') {
|
|
12
|
+
return compileAdminCrudSection(section, builder, sectionsId);
|
|
13
|
+
}
|
|
14
|
+
throw new Error(`Unknown section type ${section.type}`);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function compileAdminFeatureRecursive(featureId, builder) {
|
|
18
|
+
const { projectDefinition } = builder;
|
|
19
|
+
const feature = FeatureUtils.getFeatureByIdOrThrow(projectDefinition, featureId);
|
|
20
|
+
const descriptorLocation = `${feature.name}/root`;
|
|
21
|
+
const featureName = feature.name.split('/').pop();
|
|
22
|
+
if (!featureName) {
|
|
23
|
+
throw new Error('Feature name is required');
|
|
24
|
+
}
|
|
25
|
+
// find sub-features
|
|
26
|
+
const subFeatures = FeatureUtils.getFeatureChildren(projectDefinition, featureId);
|
|
27
|
+
const subDescriptors = subFeatures
|
|
28
|
+
.flatMap((subFeature) => compileAdminFeatureRecursive(subFeature.id, builder))
|
|
29
|
+
.filter(notEmpty);
|
|
30
|
+
const sectionDescriptors = compileAdminSections(featureId, builder, `${descriptorLocation}:$sections`);
|
|
31
|
+
if (subDescriptors.length === 0 && !sectionDescriptors) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const generatorsForFeature = builder.appCompiler.getChildrenForFeature(featureId);
|
|
35
|
+
return reactRoutesGenerator({
|
|
36
|
+
id: featureId,
|
|
37
|
+
name: featureName,
|
|
38
|
+
// add admin layout to any root features
|
|
39
|
+
layoutKey: feature.parentRef ? undefined : 'admin',
|
|
40
|
+
children: {
|
|
41
|
+
$sections: sectionDescriptors,
|
|
42
|
+
$childRoutes: subDescriptors,
|
|
43
|
+
...generatorsForFeature,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export function compileAdminFeatures(builder) {
|
|
48
|
+
const { projectDefinition } = builder;
|
|
49
|
+
const rootFeatures = FeatureUtils.getRootFeatures(projectDefinition);
|
|
50
|
+
return rootFeatures
|
|
51
|
+
.flatMap((feature) => compileAdminFeatureRecursive(feature.id, builder))
|
|
52
|
+
.filter(notEmpty);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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MAAM,CAAC,QAAQ,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AdminAppConfig, AppCompiler, AppEntry, AppEntryType, BackendAppConfig, BaseAppConfig, PluginImplementationStore, ProjectDefinition, ProjectDefinitionContainer } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import type { GeneratorBundle } from '@baseplate-dev/sync';
|
|
3
|
+
export declare class AppEntryBuilder<AppConfig extends BaseAppConfig = BaseAppConfig> {
|
|
4
|
+
definitionContainer: ProjectDefinitionContainer;
|
|
5
|
+
appConfig: AppConfig;
|
|
6
|
+
appConfigType: AppEntryType<AppConfig>;
|
|
7
|
+
projectDefinition: ProjectDefinition;
|
|
8
|
+
pluginStore: PluginImplementationStore;
|
|
9
|
+
appCompiler: AppCompiler;
|
|
10
|
+
constructor(definitionContainer: ProjectDefinitionContainer, appConfig: AppConfig, appConfigType: AppEntryType<AppConfig>);
|
|
11
|
+
nameFromId(id: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Builds an AppEntry from the root bundle
|
|
14
|
+
*/
|
|
15
|
+
buildProjectEntry(rootBundle: GeneratorBundle): AppEntry;
|
|
16
|
+
}
|
|
17
|
+
export type AdminAppEntryBuilder = AppEntryBuilder<AdminAppConfig>;
|
|
18
|
+
export type BackendAppEntryBuilder = AppEntryBuilder<BackendAppConfig>;
|
|
19
|
+
//# sourceMappingURL=app-entry-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-entry-builder.d.ts","sourceRoot":"","sources":["../../src/compiler/app-entry-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAO3D,qBAAa,eAAe,CAAC,SAAS,SAAS,aAAa,GAAG,aAAa;IAQjE,mBAAmB,EAAE,0BAA0B;IAC/C,SAAS,EAAE,SAAS;IACpB,aAAa,EAAE,YAAY,CAAC,SAAS,CAAC;IATxC,iBAAiB,EAAE,iBAAiB,CAAC;IAErC,WAAW,EAAE,yBAAyB,CAAC;IAEvC,WAAW,EAAE,WAAW,CAAC;gBAGvB,mBAAmB,EAAE,0BAA0B,EAC/C,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,YAAY,CAAC,SAAS,CAAC;IAoB/C,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAK9B;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,eAAe,GAAG,QAAQ;CAUzD;AAED,MAAM,MAAM,oBAAoB,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;AAEnE,MAAM,MAAM,sBAAsB,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { appCompilerSpec, createAppCompiler, } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
export class AppEntryBuilder {
|
|
3
|
+
definitionContainer;
|
|
4
|
+
appConfig;
|
|
5
|
+
appConfigType;
|
|
6
|
+
projectDefinition;
|
|
7
|
+
pluginStore;
|
|
8
|
+
appCompiler;
|
|
9
|
+
constructor(definitionContainer, appConfig, appConfigType) {
|
|
10
|
+
this.definitionContainer = definitionContainer;
|
|
11
|
+
this.appConfig = appConfig;
|
|
12
|
+
this.appConfigType = appConfigType;
|
|
13
|
+
this.projectDefinition = definitionContainer.definition;
|
|
14
|
+
this.pluginStore = definitionContainer.pluginStore;
|
|
15
|
+
// initialize app compiler
|
|
16
|
+
this.appCompiler = createAppCompiler();
|
|
17
|
+
const appCompilerStore = this.pluginStore.getPluginSpec(appCompilerSpec);
|
|
18
|
+
const pluginCompilers = appCompilerStore.getAppCompilers(appConfigType);
|
|
19
|
+
for (const compiler of pluginCompilers) {
|
|
20
|
+
compiler.compile({
|
|
21
|
+
appDefinition: appConfig,
|
|
22
|
+
appCompiler: this.appCompiler,
|
|
23
|
+
projectDefinition: this.projectDefinition,
|
|
24
|
+
definitionContainer: this.definitionContainer,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
nameFromId(id) {
|
|
29
|
+
return this.definitionContainer.nameFromId(id);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Builds an AppEntry from the root bundle
|
|
33
|
+
*/
|
|
34
|
+
buildProjectEntry(rootBundle) {
|
|
35
|
+
return {
|
|
36
|
+
id: this.appConfig.id,
|
|
37
|
+
name: `${this.projectDefinition.settings.general.name}-${this.appConfig.name}`,
|
|
38
|
+
appDirectory: this.appConfig.packageLocation
|
|
39
|
+
? this.appConfig.packageLocation
|
|
40
|
+
: `packages/${this.appConfig.name}`,
|
|
41
|
+
generatorBundle: rootBundle,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=app-entry-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-entry-builder.js","sourceRoot":"","sources":["../../src/compiler/app-entry-builder.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,oCAAoC,CAAC;AAE5C,MAAM,OAAO,eAAe;IAQjB;IACA;IACA;IATF,iBAAiB,CAAoB;IAErC,WAAW,CAA4B;IAEvC,WAAW,CAAc;IAEhC,YACS,mBAA+C,EAC/C,SAAoB,EACpB,aAAsC;QAFtC,wBAAmB,GAAnB,mBAAmB,CAA4B;QAC/C,cAAS,GAAT,SAAS,CAAW;QACpB,kBAAa,GAAb,aAAa,CAAyB;QAE7C,IAAI,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;QAEnD,0BAA0B;QAC1B,IAAI,CAAC,WAAW,GAAG,iBAAiB,EAAE,CAAC;QACvC,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QAEzE,MAAM,eAAe,GAAG,gBAAgB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QACxE,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;YACvC,QAAQ,CAAC,OAAO,CAAC;gBACf,aAAa,EAAE,SAAS;gBACxB,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;gBACzC,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;aAC9C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAGD,UAAU,CAAC,EAAsB;QAC/B,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,UAA2B;QAC3C,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE;YACrB,IAAI,EAAE,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;YAC9E,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe;gBAC1C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe;gBAChC,CAAC,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;YACrC,eAAe,EAAE,UAAU;SAC5B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ProjectDefinition } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import type { GeneratorBundle } from '@baseplate-dev/sync';
|
|
3
|
+
export declare function buildEnumsForFeature(featureId: string, projectDefinition: ProjectDefinition): GeneratorBundle[];
|
|
4
|
+
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/compiler/backend/enums.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAa3D,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,iBAAiB,GACnC,eAAe,EAAE,CAKnB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { prismaEnumGenerator } from '@baseplate-dev/fastify-generators';
|
|
2
|
+
function buildEnum(enumConfig) {
|
|
3
|
+
return prismaEnumGenerator({
|
|
4
|
+
name: enumConfig.name,
|
|
5
|
+
values: enumConfig.values.map((value) => ({
|
|
6
|
+
name: value.name,
|
|
7
|
+
})),
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export function buildEnumsForFeature(featureId, projectDefinition) {
|
|
11
|
+
const enums = (projectDefinition.enums ?? []).filter((m) => m.featureRef === featureId);
|
|
12
|
+
return enums.map((m) => buildEnum(m));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=enums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/compiler/backend/enums.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,SAAS,SAAS,CAAC,UAAsB;IACvC,OAAO,mBAAmB,CAAC;QACzB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACxC,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC;KACJ,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,SAAiB,EACjB,iBAAoC;IAEpC,MAAM,KAAK,GAAG,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,CAClD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,SAAS,CAClC,CAAC;IACF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BackendAppConfig } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import type { GeneratorBundle } from '@baseplate-dev/sync';
|
|
3
|
+
import type { BackendAppEntryBuilder } from '../app-entry-builder.js';
|
|
4
|
+
export declare function buildFastify(builder: BackendAppEntryBuilder, app: BackendAppConfig): GeneratorBundle;
|
|
5
|
+
//# sourceMappingURL=fastify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../../../src/compiler/backend/fastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA0B3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAKtE,wBAAgB,YAAY,CAC1B,OAAO,EAAE,sBAAsB,EAC/B,GAAG,EAAE,gBAAgB,GACpB,eAAe,CA4DjB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { appModuleGenerator, axiosGenerator, bullMqGenerator, composeFastifyApplication, fastifyBullBoardGenerator, fastifyPostmarkGenerator, fastifyRedisGenerator, fastifySentryGenerator, fastifyServerGenerator, fastifyStripeGenerator, pothosGenerator, pothosPrismaGenerator, pothosScalarGenerator, pothosSentryGenerator, prismaGenerator, prismaUtilsGenerator, prismaVitestGenerator, readmeGenerator, yogaPluginGenerator, } from '@baseplate-dev/fastify-generators';
|
|
2
|
+
import { FeatureUtils } from '@baseplate-dev/project-builder-lib';
|
|
3
|
+
import { safeMergeAll } from '@baseplate-dev/utils';
|
|
4
|
+
import { buildFeature } from './feature.js';
|
|
5
|
+
import { getPostgresSettings, getRedisSettings } from './utils.js';
|
|
6
|
+
export function buildFastify(builder, app) {
|
|
7
|
+
const { projectDefinition, appCompiler } = builder;
|
|
8
|
+
const rootFeatures = FeatureUtils.getRootFeatures(projectDefinition);
|
|
9
|
+
// add graphql scalars
|
|
10
|
+
const graphqlBundle = appModuleGenerator({
|
|
11
|
+
id: 'graphql',
|
|
12
|
+
name: 'graphql',
|
|
13
|
+
children: {
|
|
14
|
+
schemaTypes: [
|
|
15
|
+
pothosScalarGenerator({ type: 'uuid' }),
|
|
16
|
+
pothosScalarGenerator({ type: 'dateTime' }),
|
|
17
|
+
pothosScalarGenerator({ type: 'date' }),
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
return composeFastifyApplication({
|
|
22
|
+
children: safeMergeAll({
|
|
23
|
+
fastifyServer: fastifyServerGenerator({
|
|
24
|
+
defaultPort: projectDefinition.settings.general.portOffset + 1,
|
|
25
|
+
}),
|
|
26
|
+
readme: readmeGenerator({
|
|
27
|
+
projectName: `${projectDefinition.settings.general.name} backend`,
|
|
28
|
+
}),
|
|
29
|
+
sentry: fastifySentryGenerator({}),
|
|
30
|
+
redis: app.enableRedis
|
|
31
|
+
? fastifyRedisGenerator({
|
|
32
|
+
defaultUrl: getRedisSettings(projectDefinition).url,
|
|
33
|
+
})
|
|
34
|
+
: undefined,
|
|
35
|
+
...(app.enableBullQueue
|
|
36
|
+
? {
|
|
37
|
+
bull: bullMqGenerator({}),
|
|
38
|
+
bullBoard: fastifyBullBoardGenerator({}),
|
|
39
|
+
}
|
|
40
|
+
: {}),
|
|
41
|
+
postmark: app.enablePostmark ? fastifyPostmarkGenerator({}) : undefined,
|
|
42
|
+
axios: app.enableAxios ? axiosGenerator({}) : undefined,
|
|
43
|
+
prisma: prismaGenerator({
|
|
44
|
+
defaultDatabaseUrl: getPostgresSettings(projectDefinition).url,
|
|
45
|
+
}),
|
|
46
|
+
prismaVitest: prismaVitestGenerator({}),
|
|
47
|
+
prismaUtils: prismaUtilsGenerator({}),
|
|
48
|
+
yoga: yogaPluginGenerator({
|
|
49
|
+
enableSubscriptions: app.enableSubscriptions,
|
|
50
|
+
}),
|
|
51
|
+
pothos: pothosGenerator({}),
|
|
52
|
+
pothosPrisma: pothosPrismaGenerator({}),
|
|
53
|
+
pothosSentry: pothosSentryGenerator({}),
|
|
54
|
+
modules: [
|
|
55
|
+
...rootFeatures.map((feature) => buildFeature(feature.id, builder)),
|
|
56
|
+
graphqlBundle,
|
|
57
|
+
],
|
|
58
|
+
stripe: app.enableStripe ? fastifyStripeGenerator({}) : undefined,
|
|
59
|
+
}, appCompiler.getRootChildren()),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=fastify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fastify.js","sourceRoot":"","sources":["../../../src/compiler/backend/fastify.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,GACpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,mBAAmB,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AAC,EAAE,CAAC;YACP,QAAQ,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;YACvE,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;YACvD,MAAM,EAAE,eAAe,CAAC;gBACtB,kBAAkB,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,CAAC,GAAG;aAC/D,CAAC;YACF,YAAY,EAAE,qBAAqB,CAAC,EAAE,CAAC;YACvC,WAAW,EAAE,oBAAoB,CAAC,EAAE,CAAC;YACrC,IAAI,EAAE,mBAAmB,CAAC;gBACxB,mBAAmB,EAAE,GAAG,CAAC,mBAAmB;aAC7C,CAAC;YACF,MAAM,EAAE,eAAe,CAAC,EAAE,CAAC;YAC3B,YAAY,EAAE,qBAAqB,CAAC,EAAE,CAAC;YACvC,YAAY,EAAE,qBAAqB,CAAC,EAAE,CAAC;YACvC,OAAO,EAAE;gBACP,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;gBACnE,aAAa;aACd;YACD,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;SAClE,EACD,WAAW,CAAC,eAAe,EAAE,CAC9B;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GeneratorBundle } from '@baseplate-dev/sync';
|
|
2
|
+
import type { BackendAppEntryBuilder } from '../app-entry-builder.js';
|
|
3
|
+
export declare function buildFeature(featureId: string, builder: BackendAppEntryBuilder): GeneratorBundle;
|
|
4
|
+
//# sourceMappingURL=feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../../src/compiler/backend/feature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAM3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAOtE,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,sBAAsB,GAC9B,eAAe,CA6BjB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { appModuleGenerator } from '@baseplate-dev/fastify-generators';
|
|
2
|
+
import { FeatureUtils } from '@baseplate-dev/project-builder-lib';
|
|
3
|
+
import { safeMergeAll } from '@baseplate-dev/utils';
|
|
4
|
+
import { buildEnumsForFeature } from './enums.js';
|
|
5
|
+
import { buildGraphqlForFeature } from './graphql.js';
|
|
6
|
+
import { buildModelsForFeature } from './models.js';
|
|
7
|
+
import { buildServicesForFeature } from './services.js';
|
|
8
|
+
export function buildFeature(featureId, builder) {
|
|
9
|
+
const { projectDefinition, appCompiler } = builder;
|
|
10
|
+
const feature = FeatureUtils.getFeatureByIdOrThrow(projectDefinition, featureId);
|
|
11
|
+
const featureName = FeatureUtils.getFeatureName(feature);
|
|
12
|
+
// find sub-features
|
|
13
|
+
const subFeatures = FeatureUtils.getFeatureChildren(projectDefinition, featureId);
|
|
14
|
+
return appModuleGenerator({
|
|
15
|
+
id: featureId,
|
|
16
|
+
name: featureName,
|
|
17
|
+
children: safeMergeAll({
|
|
18
|
+
enums: buildEnumsForFeature(featureId, projectDefinition),
|
|
19
|
+
models: buildModelsForFeature(builder, featureId),
|
|
20
|
+
services: buildServicesForFeature(builder, featureId),
|
|
21
|
+
graphql: buildGraphqlForFeature(builder, featureId),
|
|
22
|
+
submodules: subFeatures.map((subFeature) => buildFeature(subFeature.id, builder)),
|
|
23
|
+
}, appCompiler.getChildrenForFeature(featureId)),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=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zC,YAAY,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,CACrC;SACF,EACD,WAAW,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAC7C;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GeneratorBundle } from '@baseplate-dev/sync';
|
|
2
|
+
import type { BackendAppEntryBuilder } from '../app-entry-builder.js';
|
|
3
|
+
export declare function buildGraphqlForFeature(appBuilder: BackendAppEntryBuilder, featureId: string): GeneratorBundle[];
|
|
4
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/compiler/backend/graphql.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAiB3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AA+MtE,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,sBAAsB,EAClC,SAAS,EAAE,MAAM,GAChB,eAAe,EAAE,CAmBnB"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { pothosAuthorizeFieldGenerator, pothosEnumsFileGenerator, pothosPrismaCrudMutationGenerator, pothosPrismaEnumGenerator, pothosPrismaFindQueryGenerator, pothosPrismaListQueryGenerator, pothosPrismaObjectGenerator, pothosPrismaPrimaryKeyGenerator, pothosTypesFileGenerator, } from '@baseplate-dev/fastify-generators';
|
|
2
|
+
import { authConfigSpec, ModelUtils } from '@baseplate-dev/project-builder-lib';
|
|
3
|
+
import { notEmpty } from '@baseplate-dev/utils';
|
|
4
|
+
import { kebabCase } from 'change-case';
|
|
5
|
+
function buildObjectTypeFile(appBuilder, model) {
|
|
6
|
+
const { graphql } = model;
|
|
7
|
+
const { objectType, mutations, queries } = graphql ?? {};
|
|
8
|
+
const buildQuery = queries?.get?.enabled ?? queries?.list?.enabled;
|
|
9
|
+
const buildMutations = mutations?.create.enabled ??
|
|
10
|
+
mutations?.update.enabled ??
|
|
11
|
+
mutations?.delete.enabled;
|
|
12
|
+
if (!objectType?.enabled) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const { fields, localRelations = [], foreignRelations = [] } = objectType;
|
|
16
|
+
return pothosTypesFileGenerator({
|
|
17
|
+
id: `${model.id}-object-type`,
|
|
18
|
+
fileName: `${kebabCase(model.name)}.object-type`,
|
|
19
|
+
children: {
|
|
20
|
+
primaryKey: (!!buildMutations || !!buildQuery) &&
|
|
21
|
+
ModelUtils.getModelIdFields(model).length > 1
|
|
22
|
+
? pothosPrismaPrimaryKeyGenerator({
|
|
23
|
+
modelName: model.name,
|
|
24
|
+
order: 0,
|
|
25
|
+
})
|
|
26
|
+
: undefined,
|
|
27
|
+
objectType: pothosPrismaObjectGenerator({
|
|
28
|
+
modelName: model.name,
|
|
29
|
+
exposedFields: [...fields, ...foreignRelations, ...localRelations].map((id) => appBuilder.nameFromId(id)),
|
|
30
|
+
order: 1,
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function buildQueriesFileForModel(appBuilder, model) {
|
|
36
|
+
const { graphql } = model;
|
|
37
|
+
const { queries } = graphql ?? {};
|
|
38
|
+
if (!queries?.get?.enabled && !queries?.list?.enabled) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const { get, list } = queries;
|
|
42
|
+
const authConfig = appBuilder.definitionContainer.pluginStore.getPluginSpecOptional(authConfigSpec);
|
|
43
|
+
const isAuthEnabled = !!authConfig;
|
|
44
|
+
return pothosTypesFileGenerator({
|
|
45
|
+
id: `${model.id}-queries`,
|
|
46
|
+
fileName: `${kebabCase(model.name)}.queries`,
|
|
47
|
+
children: {
|
|
48
|
+
findQuery: get?.enabled
|
|
49
|
+
? pothosPrismaFindQueryGenerator({
|
|
50
|
+
order: 0,
|
|
51
|
+
modelName: model.name,
|
|
52
|
+
hasPrimaryKeyInputType: ModelUtils.getModelIdFields(model).length > 1,
|
|
53
|
+
children: {
|
|
54
|
+
authorize: !isAuthEnabled || !get.roles?.length
|
|
55
|
+
? undefined
|
|
56
|
+
: pothosAuthorizeFieldGenerator({
|
|
57
|
+
roles: get.roles.map((r) => appBuilder.nameFromId(r)),
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
: undefined,
|
|
62
|
+
listQuery: list?.enabled
|
|
63
|
+
? pothosPrismaListQueryGenerator({
|
|
64
|
+
order: 1,
|
|
65
|
+
modelName: model.name,
|
|
66
|
+
children: {
|
|
67
|
+
authorize: !isAuthEnabled || !list.roles?.length
|
|
68
|
+
? undefined
|
|
69
|
+
: pothosAuthorizeFieldGenerator({
|
|
70
|
+
roles: list.roles.map((r) => appBuilder.nameFromId(r)),
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
: undefined,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function buildMutationsFileForModel(appBuilder, model) {
|
|
79
|
+
const { graphql } = model;
|
|
80
|
+
const { mutations } = graphql ?? {};
|
|
81
|
+
const buildMutations = !!mutations &&
|
|
82
|
+
(!!mutations.create.enabled ||
|
|
83
|
+
!!mutations.update.enabled ||
|
|
84
|
+
!!mutations.delete.enabled);
|
|
85
|
+
if (!buildMutations) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
const { create, update, delete: del } = mutations;
|
|
89
|
+
const authConfig = appBuilder.definitionContainer.pluginStore.getPluginSpecOptional(authConfigSpec);
|
|
90
|
+
const isAuthEnabled = !!authConfig;
|
|
91
|
+
const sharedMutationConfig = {
|
|
92
|
+
modelName: model.name,
|
|
93
|
+
crudServiceRef: `prisma-crud-service:${model.name}`,
|
|
94
|
+
hasPrimaryKeyInputType: ModelUtils.getModelIdFields(model).length > 1,
|
|
95
|
+
};
|
|
96
|
+
return pothosTypesFileGenerator({
|
|
97
|
+
id: `${model.id}-mutations`,
|
|
98
|
+
fileName: `${kebabCase(model.name)}.mutations`,
|
|
99
|
+
children: {
|
|
100
|
+
create: create.enabled
|
|
101
|
+
? pothosPrismaCrudMutationGenerator({
|
|
102
|
+
...sharedMutationConfig,
|
|
103
|
+
order: 0,
|
|
104
|
+
type: 'create',
|
|
105
|
+
children: {
|
|
106
|
+
authorize: isAuthEnabled && create.roles
|
|
107
|
+
? pothosAuthorizeFieldGenerator({
|
|
108
|
+
roles: create.roles.map((r) => appBuilder.nameFromId(r)),
|
|
109
|
+
})
|
|
110
|
+
: undefined,
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
: undefined,
|
|
114
|
+
update: update.enabled
|
|
115
|
+
? pothosPrismaCrudMutationGenerator({
|
|
116
|
+
...sharedMutationConfig,
|
|
117
|
+
order: 1,
|
|
118
|
+
type: 'update',
|
|
119
|
+
children: {
|
|
120
|
+
authorize: isAuthEnabled && update.roles
|
|
121
|
+
? pothosAuthorizeFieldGenerator({
|
|
122
|
+
roles: update.roles.map((r) => appBuilder.nameFromId(r)),
|
|
123
|
+
})
|
|
124
|
+
: undefined,
|
|
125
|
+
},
|
|
126
|
+
})
|
|
127
|
+
: undefined,
|
|
128
|
+
delete: del.enabled
|
|
129
|
+
? pothosPrismaCrudMutationGenerator({
|
|
130
|
+
...sharedMutationConfig,
|
|
131
|
+
order: 2,
|
|
132
|
+
type: 'delete',
|
|
133
|
+
children: {
|
|
134
|
+
authorize: isAuthEnabled && del.roles
|
|
135
|
+
? pothosAuthorizeFieldGenerator({
|
|
136
|
+
roles: del.roles.map((r) => appBuilder.nameFromId(r)),
|
|
137
|
+
})
|
|
138
|
+
: undefined,
|
|
139
|
+
},
|
|
140
|
+
})
|
|
141
|
+
: undefined,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function buildEnumFileForModel(enumFileId, enums) {
|
|
146
|
+
if (enums.length === 0) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
return pothosEnumsFileGenerator({
|
|
150
|
+
id: enumFileId,
|
|
151
|
+
name: `Enums`,
|
|
152
|
+
children: {
|
|
153
|
+
enums: enums.map((enumConfig) => pothosPrismaEnumGenerator({
|
|
154
|
+
enumName: enumConfig.name,
|
|
155
|
+
})),
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
export function buildGraphqlForFeature(appBuilder, featureId) {
|
|
160
|
+
const models = ModelUtils.getModelsForFeature(appBuilder.projectDefinition, featureId).filter((m) => m.graphql);
|
|
161
|
+
const enums = appBuilder.projectDefinition.enums?.filter((e) => e.featureRef === featureId && e.isExposed) ?? [];
|
|
162
|
+
return [
|
|
163
|
+
...models.flatMap((model) => [
|
|
164
|
+
buildObjectTypeFile(appBuilder, model),
|
|
165
|
+
buildQueriesFileForModel(appBuilder, model),
|
|
166
|
+
buildMutationsFileForModel(appBuilder, model),
|
|
167
|
+
]),
|
|
168
|
+
buildEnumFileForModel(`${featureId}-enums`, enums),
|
|
169
|
+
].filter(notEmpty);
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../../src/compiler/backend/graphql.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,iCAAiC,EACjC,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,2BAA2B,EAC3B,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,SAAS,mBAAmB,CAC1B,UAAkC,EAClC,KAAkB;IAEl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