@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,34 @@
|
|
|
1
|
+
import { composeNodeGenerator, dockerComposeGenerator, vitestGenerator, } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { backendAppEntryType } from '@baseplate-dev/project-builder-lib';
|
|
3
|
+
import { AppEntryBuilder } from '../app-entry-builder.js';
|
|
4
|
+
import { buildFastify } from './fastify.js';
|
|
5
|
+
import { getPostgresSettings, getRedisSettings } from './utils.js';
|
|
6
|
+
function buildDocker(projectDefinition, app) {
|
|
7
|
+
return dockerComposeGenerator({
|
|
8
|
+
postgres: getPostgresSettings(projectDefinition).config,
|
|
9
|
+
...(app.enableRedis
|
|
10
|
+
? { redis: getRedisSettings(projectDefinition).config }
|
|
11
|
+
: {}),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function compileBackend(definitionContainer, app) {
|
|
15
|
+
const appBuilder = new AppEntryBuilder(definitionContainer, app, backendAppEntryType);
|
|
16
|
+
const { projectDefinition } = appBuilder;
|
|
17
|
+
const generalSettings = projectDefinition.settings.general;
|
|
18
|
+
const packageName = generalSettings.packageScope
|
|
19
|
+
? `@${generalSettings.packageScope}/${app.name}`
|
|
20
|
+
: `${generalSettings.name}-${app.name}`;
|
|
21
|
+
const rootBundle = composeNodeGenerator({
|
|
22
|
+
name: `${generalSettings.name}-${app.name}`,
|
|
23
|
+
packageName,
|
|
24
|
+
description: `Backend app for ${generalSettings.name}`,
|
|
25
|
+
version: '1.0.0',
|
|
26
|
+
children: {
|
|
27
|
+
docker: buildDocker(projectDefinition, app),
|
|
28
|
+
fastify: buildFastify(appBuilder, app),
|
|
29
|
+
vitest: vitestGenerator({}),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return appBuilder.buildProjectEntry(rootBundle);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/compiler/backend/index.ts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,CAAC,IAAI,EAAE;QACtD,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE;YACR,MAAM,EAAE,WAAW,CAAC,iBAAiB,EAAE,GAAG,CAAC;YAC3C,OAAO,EAAE,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC;YACtC,MAAM,EAAE,eAAe,CAAC,EAAE,CAAC;SAC5B;KACF,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAClD,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 buildModelsForFeature(appBuilder: BackendAppEntryBuilder, featureId: string): GeneratorBundle[];
|
|
4
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/compiler/backend/models.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAc3D,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAgIjC,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,sBAAsB,EAClC,SAAS,EAAE,MAAM,GAChB,eAAe,EAAE,CAMnB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { prismaFieldGenerator, prismaModelGenerator, prismaModelIdGenerator, prismaModelUniqueGenerator, prismaRelationFieldGenerator, } from '@baseplate-dev/fastify-generators';
|
|
2
|
+
import { ModelFieldUtils, ModelUtils, } from '@baseplate-dev/project-builder-lib';
|
|
3
|
+
function buildScalarField(builder, model, field, order) {
|
|
4
|
+
const { options } = field;
|
|
5
|
+
const { primaryKeyFieldRefs, uniqueConstraints } = model.model;
|
|
6
|
+
const isId = primaryKeyFieldRefs.length === 1 && primaryKeyFieldRefs.includes(field.id);
|
|
7
|
+
const isUnique = uniqueConstraints?.some((c) => c.fields.length === 1 && c.fields.some((f) => f.fieldRef === field.id));
|
|
8
|
+
return prismaFieldGenerator({
|
|
9
|
+
name: field.name,
|
|
10
|
+
type: field.type,
|
|
11
|
+
order,
|
|
12
|
+
id: isId,
|
|
13
|
+
options: {
|
|
14
|
+
autoGenerate: options.genUuid,
|
|
15
|
+
defaultToNow: options.defaultToNow,
|
|
16
|
+
updatedAt: options.updatedAt,
|
|
17
|
+
default: options.default,
|
|
18
|
+
defaultEnumValue: builder.definitionContainer.nameFromId(options.defaultEnumValueRef),
|
|
19
|
+
},
|
|
20
|
+
optional: field.isOptional,
|
|
21
|
+
unique: isUnique,
|
|
22
|
+
enumType: options.enumRef && builder.nameFromId(options.enumRef),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function buildRelationField(appBuilder, relationConfig, parentModel) {
|
|
26
|
+
const { projectDefinition } = appBuilder;
|
|
27
|
+
const { name, references, modelRef, foreignRelationName, onDelete, onUpdate, } = relationConfig;
|
|
28
|
+
const foreignModel = ModelUtils.byIdOrThrow(projectDefinition, modelRef);
|
|
29
|
+
const optional = ModelFieldUtils.isRelationOptional(parentModel, relationConfig);
|
|
30
|
+
const relationshipType = ModelFieldUtils.isRelationOneToOne(parentModel, relationConfig)
|
|
31
|
+
? 'oneToOne'
|
|
32
|
+
: 'oneToMany';
|
|
33
|
+
const relations = parentModel.model.relations ?? [];
|
|
34
|
+
// If there are multiple relations between the same models, we need to specify the
|
|
35
|
+
// relation name to avoid conflicts in Prisma
|
|
36
|
+
const foreignRelations = ModelUtils.getRelationsToModel(projectDefinition, parentModel.id).filter(({ model }) => model.id === relationConfig.modelRef);
|
|
37
|
+
const needsRelationName = foreignRelations.length +
|
|
38
|
+
relations.filter((r) => r.modelRef === modelRef).length >
|
|
39
|
+
1;
|
|
40
|
+
return prismaRelationFieldGenerator({
|
|
41
|
+
name,
|
|
42
|
+
fields: references.map((r) => appBuilder.definitionContainer.nameFromId(r.localRef)),
|
|
43
|
+
references: references.map((r) => appBuilder.definitionContainer.nameFromId(r.foreignRef)),
|
|
44
|
+
modelName: parentModel.name,
|
|
45
|
+
foreignModelName: foreignModel.name,
|
|
46
|
+
foreignRelationName,
|
|
47
|
+
relationshipName: needsRelationName ? foreignRelationName : undefined,
|
|
48
|
+
relationshipType,
|
|
49
|
+
optional,
|
|
50
|
+
onDelete,
|
|
51
|
+
onUpdate,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function buildModel(appBuilder, model) {
|
|
55
|
+
return prismaModelGenerator({
|
|
56
|
+
name: model.name,
|
|
57
|
+
children: {
|
|
58
|
+
fields: model.model.fields.map((field, idx) => buildScalarField(appBuilder, model, field, idx)),
|
|
59
|
+
relations: model.model.relations?.map((r) => buildRelationField(appBuilder, r, model)),
|
|
60
|
+
primaryKey: model.model.primaryKeyFieldRefs.length <= 1
|
|
61
|
+
? undefined
|
|
62
|
+
: prismaModelIdGenerator({
|
|
63
|
+
fields: model.model.primaryKeyFieldRefs.map((f) => appBuilder.nameFromId(f)),
|
|
64
|
+
}),
|
|
65
|
+
uniqueConstraints: model.model.uniqueConstraints
|
|
66
|
+
?.filter(({ fields }) => fields.length > 1)
|
|
67
|
+
.map(({ fields }) => prismaModelUniqueGenerator({
|
|
68
|
+
fields: fields.map((f) => ({
|
|
69
|
+
name: appBuilder.nameFromId(f.fieldRef),
|
|
70
|
+
})),
|
|
71
|
+
})),
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export function buildModelsForFeature(appBuilder, featureId) {
|
|
76
|
+
const models = ModelUtils.getModelsForFeature(appBuilder.projectDefinition, featureId);
|
|
77
|
+
return models.map((m) => buildModel(appBuilder, m));
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/compiler/backend/models.ts"],"names":[],"mappings":"A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AAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;iBAC1C,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAClB,0BAA0B,CAAC;gBACzB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBACzB,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;iBACxC,CAAC,CAAC;aACJ,CAAC,CACH;SACJ;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,UAAkC,EAClC,SAAiB;IAEjB,MAAM,MAAM,GAAG,UAAU,CAAC,mBAAmB,CAC3C,UAAU,CAAC,iBAAiB,EAC5B,SAAS,CACV,CAAC;IACF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;AACtD,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 buildServicesForFeature(appBuilder: BackendAppEntryBuilder, featureId: string): GeneratorBundle[];
|
|
4
|
+
//# sourceMappingURL=services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../src/compiler/backend/services.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAkB3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAiItE,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,sBAAsB,EAClC,SAAS,EAAE,MAAM,GAChB,eAAe,EAAE,CAcnB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { embeddedRelationTransformerGenerator, prismaCrudCreateGenerator, prismaCrudDeleteGenerator, prismaCrudServiceGenerator, prismaCrudUpdateGenerator, prismaPasswordTransformerGenerator, serviceFileGenerator, } from '@baseplate-dev/fastify-generators';
|
|
2
|
+
import { modelTransformerCompilerSpec, ModelUtils, undefinedIfEmpty, } from '@baseplate-dev/project-builder-lib';
|
|
3
|
+
import { notEmpty } from '@baseplate-dev/utils';
|
|
4
|
+
const embeddedRelationTransformerCompiler = {
|
|
5
|
+
name: 'embeddedRelation',
|
|
6
|
+
compileTransformer(definition, { definitionContainer, model }) {
|
|
7
|
+
// find foreign relation
|
|
8
|
+
const foreignRelation = ModelUtils.getRelationsToModel(definitionContainer.definition, model.id).find(({ relation }) => relation.foreignId === definition.foreignRelationRef);
|
|
9
|
+
if (!foreignRelation) {
|
|
10
|
+
throw new Error(`Could not find relation ${definition.foreignRelationRef} for embedded relation transformer`);
|
|
11
|
+
}
|
|
12
|
+
const foreignModel = foreignRelation.model;
|
|
13
|
+
return embeddedRelationTransformerGenerator({
|
|
14
|
+
name: foreignRelation.relation.foreignRelationName,
|
|
15
|
+
embeddedFieldNames: definition.embeddedFieldNames.map((e) => definitionContainer.nameFromId(e)),
|
|
16
|
+
embeddedTransformerNames: definition.embeddedTransformerNames?.map((t) => definitionContainer.nameFromId(t)),
|
|
17
|
+
foreignModelName: definition.embeddedTransformerNames
|
|
18
|
+
? foreignModel.name
|
|
19
|
+
: undefined,
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const passwordTransformerCompiler = {
|
|
24
|
+
name: 'password',
|
|
25
|
+
compileTransformer() {
|
|
26
|
+
return prismaPasswordTransformerGenerator({});
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
function buildTransformer(appBuilder, transformer, model) {
|
|
30
|
+
const { pluginStore } = appBuilder;
|
|
31
|
+
const compilerImplementation = pluginStore.getPluginSpec(modelTransformerCompilerSpec);
|
|
32
|
+
const compiler = compilerImplementation.getModelTransformerCompiler(transformer.type, [embeddedRelationTransformerCompiler, passwordTransformerCompiler]);
|
|
33
|
+
return compiler.compileTransformer(transformer, {
|
|
34
|
+
definitionContainer: appBuilder.definitionContainer,
|
|
35
|
+
model,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function buildServiceForModel(appBuilder, model) {
|
|
39
|
+
const { service } = model;
|
|
40
|
+
if (!ModelUtils.hasService(model)) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return serviceFileGenerator({
|
|
44
|
+
name: `${model.name}Service`,
|
|
45
|
+
id: `prisma-crud-service:${model.name}`,
|
|
46
|
+
children: {
|
|
47
|
+
$crud: prismaCrudServiceGenerator({
|
|
48
|
+
modelName: model.name,
|
|
49
|
+
children: {
|
|
50
|
+
transformers: service.transformers.map((transfomer) => buildTransformer(appBuilder, transfomer, model)),
|
|
51
|
+
create: service.create.fields?.length && service.create.enabled
|
|
52
|
+
? prismaCrudCreateGenerator({
|
|
53
|
+
name: 'create',
|
|
54
|
+
order: 1,
|
|
55
|
+
modelName: model.name,
|
|
56
|
+
prismaFields: service.create.fields.map((f) => appBuilder.nameFromId(f)),
|
|
57
|
+
transformerNames: undefinedIfEmpty(service.create.transformerNames?.map((f) => appBuilder.nameFromId(f))),
|
|
58
|
+
})
|
|
59
|
+
: undefined,
|
|
60
|
+
update: service.update.fields?.length && service.update.enabled
|
|
61
|
+
? prismaCrudUpdateGenerator({
|
|
62
|
+
name: 'update',
|
|
63
|
+
order: 2,
|
|
64
|
+
modelName: model.name,
|
|
65
|
+
prismaFields: service.update.fields.map((f) => appBuilder.nameFromId(f)),
|
|
66
|
+
transformerNames: undefinedIfEmpty(service.update.transformerNames?.map((f) => appBuilder.nameFromId(f))),
|
|
67
|
+
})
|
|
68
|
+
: undefined,
|
|
69
|
+
delete: service.delete.enabled
|
|
70
|
+
? prismaCrudDeleteGenerator({
|
|
71
|
+
name: 'delete',
|
|
72
|
+
order: 3,
|
|
73
|
+
modelName: model.name,
|
|
74
|
+
})
|
|
75
|
+
: undefined,
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export function buildServicesForFeature(appBuilder, featureId) {
|
|
82
|
+
const models = ModelUtils.getModelsForFeature(appBuilder.projectDefinition, featureId).filter((m) => !!m.service.create.enabled ||
|
|
83
|
+
!!m.service.update.enabled ||
|
|
84
|
+
!!m.service.delete.enabled ||
|
|
85
|
+
m.service.transformers.length > 0);
|
|
86
|
+
return models
|
|
87
|
+
.map((model) => buildServiceForModel(appBuilder, model))
|
|
88
|
+
.filter(notEmpty);
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../../src/compiler/backend/services.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,oCAAoC,EACpC,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,kCAAkC,EAClC,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,4BAA4B,EAC5B,UAAU,EACV,gBAAgB,GACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD,MAAM,mCAAmC,GACvC;IACE,IAAI,EAAE,kBAAkB;IACxB,kBAAkB,CAAC,UAAU,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE;QAC3D,wBAAwB;QACxB,MAAM,eAAe,GAAG,UAAU,CAAC,mBAAmB,CACpD,mBAAmB,CAAC,UAAU,EAC9B,KAAK,CAAC,EAAE,CACT,CAAC,IAAI,CACJ,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,KAAK,UAAU,CAAC,kBAAkB,CACvE,CAAC;QAEF,IAAI,CAAC,eAAe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K,CAAC,CAAC;SACvD,MAAM,CAAC,QAAQ,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProjectDefinition } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
export declare function getPostgresSettings(projectDefinition: ProjectDefinition): {
|
|
3
|
+
config: {
|
|
4
|
+
port: number;
|
|
5
|
+
password: string;
|
|
6
|
+
};
|
|
7
|
+
url: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function getRedisSettings(projectDefinition: ProjectDefinition): {
|
|
10
|
+
config: {
|
|
11
|
+
port: number;
|
|
12
|
+
password: string;
|
|
13
|
+
};
|
|
14
|
+
url: string;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/compiler/backend/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,iBAAiB,GAAG;IACzE,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,GAAG,EAAE,MAAM,CAAC;CACb,CAOA;AAED,wBAAgB,gBAAgB,CAAC,iBAAiB,EAAE,iBAAiB,GAAG;IACtE,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,GAAG,EAAE,MAAM,CAAC;CACb,CAOA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function getPostgresSettings(projectDefinition) {
|
|
2
|
+
const port = projectDefinition.settings.general.portOffset + 432;
|
|
3
|
+
const password = `${projectDefinition.settings.general.name}-backend-password`;
|
|
4
|
+
return {
|
|
5
|
+
config: { port, password },
|
|
6
|
+
url: `postgres://postgres:${password}@localhost:${port}/postgres?schema=public`,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function getRedisSettings(projectDefinition) {
|
|
10
|
+
const port = projectDefinition.settings.general.portOffset + 379;
|
|
11
|
+
const password = `${projectDefinition.settings.general.name}-backend-password`;
|
|
12
|
+
return {
|
|
13
|
+
config: { port, password },
|
|
14
|
+
url: `redis://:${password}@localhost:${port}`,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/compiler/backend/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,mBAAmB,CAAC,iBAAoC;IAOtE,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,GAAG,GAAG,CAAC;IACjE,MAAM,QAAQ,GAAG,GAAG,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,mBAAmB,CAAC;IAC/E,OAAO;QACL,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,GAAG,EAAE,uBAAuB,QAAQ,cAAc,IAAI,yBAAyB;KAChF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,iBAAoC;IAOnE,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,GAAG,GAAG,CAAC;IACjE,MAAM,QAAQ,GAAG,GAAG,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,mBAAmB,CAAC;IAC/E,OAAO;QACL,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,GAAG,EAAE,YAAY,QAAQ,cAAc,IAAI,EAAE;KAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compiler/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EAER,mBAAmB,EACpB,MAAM,oCAAoC,CAAC;AAS5C,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,mBAAmB,GAC3B,QAAQ,EAAE,CA2BZ"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ProjectDefinitionContainer } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import { sortBy } from 'es-toolkit';
|
|
3
|
+
import { compileAdmin } from './admin/index.js';
|
|
4
|
+
import { compileBackend } from './backend/index.js';
|
|
5
|
+
import { compileWeb } from './web/index.js';
|
|
6
|
+
export function compileApplications(projectJson, context) {
|
|
7
|
+
const definitionContainer = ProjectDefinitionContainer.fromSerializedConfig(projectJson, context);
|
|
8
|
+
// Compile backend app first since it's likely the dependency for the other apps
|
|
9
|
+
const appConfigs = sortBy(definitionContainer.definition.apps, [
|
|
10
|
+
(a) => (a.type === 'backend' ? 0 : 1),
|
|
11
|
+
(a) => a.name,
|
|
12
|
+
]);
|
|
13
|
+
const apps = appConfigs.map((app) => {
|
|
14
|
+
switch (app.type) {
|
|
15
|
+
case 'backend': {
|
|
16
|
+
return compileBackend(definitionContainer, app);
|
|
17
|
+
}
|
|
18
|
+
case 'web': {
|
|
19
|
+
return compileWeb(definitionContainer, app);
|
|
20
|
+
}
|
|
21
|
+
case 'admin': {
|
|
22
|
+
return compileAdmin(definitionContainer, app);
|
|
23
|
+
}
|
|
24
|
+
default: {
|
|
25
|
+
throw new Error(`Unknown app type: ${app.type}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return apps;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compiler/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CA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ACd,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WebAppConfig } 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 compileWebFeatures(builder: AppEntryBuilder<WebAppConfig>): GeneratorBundle[];
|
|
5
|
+
//# sourceMappingURL=features.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../../src/compiler/web/features.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAM3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAqC/D,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,GACrC,eAAe,EAAE,CAOnB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FeatureUtils } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import { reactRoutesGenerator } from '@baseplate-dev/react-generators';
|
|
3
|
+
import { notEmpty, safeMerge } from '@baseplate-dev/utils';
|
|
4
|
+
function compileWebFeatureRecursive(featureId, builder) {
|
|
5
|
+
const { projectDefinition } = builder;
|
|
6
|
+
const feature = FeatureUtils.getFeatureByIdOrThrow(projectDefinition, featureId);
|
|
7
|
+
const featureName = feature.name.split('/').pop();
|
|
8
|
+
if (!featureName) {
|
|
9
|
+
throw new Error('Feature name is required');
|
|
10
|
+
}
|
|
11
|
+
// find sub-features
|
|
12
|
+
const subFeatures = FeatureUtils.getFeatureChildren(projectDefinition, featureId);
|
|
13
|
+
const subDescriptors = subFeatures
|
|
14
|
+
.flatMap((subFeature) => compileWebFeatureRecursive(subFeature.id, builder))
|
|
15
|
+
.filter(notEmpty);
|
|
16
|
+
const generatorsForFeature = builder.appCompiler.getChildrenForFeature(featureId);
|
|
17
|
+
return reactRoutesGenerator({
|
|
18
|
+
id: featureId,
|
|
19
|
+
name: featureName,
|
|
20
|
+
children: safeMerge({ $childRoutes: subDescriptors }, generatorsForFeature),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function compileWebFeatures(builder) {
|
|
24
|
+
const { projectDefinition } = builder;
|
|
25
|
+
const rootFeatures = FeatureUtils.getRootFeatures(projectDefinition);
|
|
26
|
+
return rootFeatures
|
|
27
|
+
.flatMap((feature) => compileWebFeatureRecursive(feature.id, builder))
|
|
28
|
+
.filter(notEmpty);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=features.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../../src/compiler/web/features.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAI3D,SAAS,0BAA0B,CACjC,SAAiB,EACjB,OAAsC;IAEtC,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,OAAO,GAAG,YAAY,CAAC,qBAAqB,CAChD,iBAAiB,EACjB,SAAS,CACV,CAAC;IACF,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAElD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAED,oBAAoB;IACpB,MAAM,WAAW,GAAG,YAAY,CAAC,kBAAkB,CACjD,iBAAiB,EACjB,SAAS,CACV,CAAC;IAEF,MAAM,cAAc,GAAG,WAAW;SAC/B,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,0BAA0B,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;SAC3E,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEpB,MAAM,oBAAoB,GACxB,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAEvD,OAAO,oBAAoB,CAAC;QAC1B,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,SAAS,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,oBAAoB,CAAC;KAC5E,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAAsC;IAEtC,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,YAAY,GAAG,YAAY,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAErE,OAAO,YAAY;SAChB,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;SACrE,MAAM,CAAC,QAAQ,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compiler/web/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,0BAA0B,EAC1B,YAAY,EACb,MAAM,oCAAoC,CAAC;AAmE5C,wBAAgB,UAAU,CACxB,mBAAmB,EAAE,0BAA0B,EAC/C,GAAG,EAAE,YAAY,GAChB,QAAQ,CA0BV"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { composeNodeGenerator } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { AppUtils, webAppEntryType } from '@baseplate-dev/project-builder-lib';
|
|
3
|
+
import { apolloErrorGenerator, apolloErrorLinkGenerator, apolloSentryGenerator, composeReactGenerators, reactApolloGenerator, reactNotFoundHandlerGenerator, reactRouterGenerator, reactSentryGenerator, reactTailwindGenerator, } from '@baseplate-dev/react-generators';
|
|
4
|
+
import { safeMerge } from '@baseplate-dev/utils';
|
|
5
|
+
import { AppEntryBuilder } from '../app-entry-builder.js';
|
|
6
|
+
import { compileWebFeatures } from './features.js';
|
|
7
|
+
function buildReact(builder) {
|
|
8
|
+
const { projectDefinition, appConfig, appCompiler } = builder;
|
|
9
|
+
const backendApp = AppUtils.getBackendApp(projectDefinition);
|
|
10
|
+
const backendRelativePath = AppUtils.getBackendRelativePath(appConfig, backendApp);
|
|
11
|
+
const rootFeatures = appCompiler.getRootChildren();
|
|
12
|
+
return composeReactGenerators({
|
|
13
|
+
title: appConfig.title,
|
|
14
|
+
description: appConfig.description,
|
|
15
|
+
children: {
|
|
16
|
+
reactRouter: reactRouterGenerator({
|
|
17
|
+
children: safeMerge({
|
|
18
|
+
reactNotFoundHandler: reactNotFoundHandlerGenerator({}),
|
|
19
|
+
features: compileWebFeatures(builder),
|
|
20
|
+
}, rootFeatures),
|
|
21
|
+
}),
|
|
22
|
+
reactTailwind: reactTailwindGenerator({}),
|
|
23
|
+
reactSentry: reactSentryGenerator({}),
|
|
24
|
+
reactApollo: reactApolloGenerator({
|
|
25
|
+
devApiEndpoint: '/api/graphql',
|
|
26
|
+
schemaLocation: `${backendRelativePath}/schema.graphql`,
|
|
27
|
+
enableSubscriptions: appConfig.enableSubscriptions,
|
|
28
|
+
children: {
|
|
29
|
+
apolloErrorLink: apolloErrorLinkGenerator({}),
|
|
30
|
+
apolloSentry: apolloSentryGenerator({}),
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
apolloError: apolloErrorGenerator({}),
|
|
34
|
+
},
|
|
35
|
+
}, {
|
|
36
|
+
// TODO: Extract out logic
|
|
37
|
+
devBackendHost: `http://localhost:${projectDefinition.settings.general.portOffset + 1}`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function compileWeb(definitionContainer, app) {
|
|
41
|
+
const appBuilder = new AppEntryBuilder(definitionContainer, app, webAppEntryType);
|
|
42
|
+
const { projectDefinition } = appBuilder;
|
|
43
|
+
const generalSettings = projectDefinition.settings.general;
|
|
44
|
+
const packageName = generalSettings.packageScope
|
|
45
|
+
? `@${generalSettings.packageScope}/${app.name}`
|
|
46
|
+
: `${generalSettings.name}-${app.name}`;
|
|
47
|
+
const nodeBundle = composeNodeGenerator({
|
|
48
|
+
name: `${generalSettings.name}-${app.name}`,
|
|
49
|
+
packageName,
|
|
50
|
+
description: `Web app for ${generalSettings.name}`,
|
|
51
|
+
version: '1.0.0',
|
|
52
|
+
children: {
|
|
53
|
+
react: buildReact(appBuilder),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return appBuilder.buildProjectEntry(nodeBundle);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/compiler/web/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,6BAA6B,EAC7B,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,SAAS,UAAU,CAAC,OAAsC;IACxD,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAE9D,MAAM,UAAU,GAAG,QA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;IAEzC,MAAM,eAAe,GAAG,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC;IAE3D,MAAM,WAAW,GAAG,eAAe,CAAC,YAAY;QAC9C,CAAC,CAAC,IAAI,eAAe,CAAC,YAAY,IAAI,GAAG,CAAC,IAAI,EAAE;QAChD,CAAC,CAAC,GAAG,eAAe,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;IAE1C,MAAM,UAAU,GAAG,oBAAoB,CAAC;QACtC,IAAI,EAAE,GAAG,eAAe,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE;QAC3C,WAAW;QACX,WAAW,EAAE,eAAe,eAAe,CAAC,IAAI,EAAE;QAClD,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE;YACR,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC;SAC9B;KACF,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/constants/server.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/constants/server.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './api/index.js';
|
|
2
|
+
export * from './constants/index.js';
|
|
3
|
+
export * from './plugins/index.js';
|
|
4
|
+
export * from './server/index.js';
|
|
5
|
+
export * from './service/builder-service.js';
|
|
6
|
+
export * from './sync/index.js';
|
|
7
|
+
export * from './template-extractor/index.js';
|
|
8
|
+
export * from './user-config/index.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './api/index.js';
|
|
2
|
+
export * from './constants/index.js';
|
|
3
|
+
export * from './plugins/index.js';
|
|
4
|
+
export * from './server/index.js';
|
|
5
|
+
export * from './service/builder-service.js';
|
|
6
|
+
export * from './sync/index.js';
|
|
7
|
+
export * from './template-extractor/index.js';
|
|
8
|
+
export * from './user-config/index.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PluginMetadataWithPaths, PluginStore, SchemaParserContext } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import type { Logger } from '@baseplate-dev/sync';
|
|
3
|
+
export declare function createNodePluginStore(plugins: PluginMetadataWithPaths[]): Promise<PluginStore>;
|
|
4
|
+
export declare function createNodePluginStoreFromDirectory(projectDirectory: string, logger: Logger, builtinPlugins: PluginMetadataWithPaths[]): Promise<PluginStore>;
|
|
5
|
+
export declare function createNodeSchemaParserContext(projectDirectory: string, logger: Logger, builtinPlugins: PluginMetadataWithPaths[]): Promise<SchemaParserContext>;
|
|
6
|
+
//# sourceMappingURL=node-plugin-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-plugin-store.d.ts","sourceRoot":"","sources":["../../src/plugins/node-plugin-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EAEvB,WAAW,EACX,mBAAmB,EACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAkBlD,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,uBAAuB,EAAE,GACjC,OAAO,CAAC,WAAW,CAAC,CAuBtB;AAED,wBAAsB,kCAAkC,CACtD,gBAAgB,EAAE,MAAM,EACxB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,uBAAuB,EAAE,GACxC,OAAO,CAAC,WAAW,CAAC,CAStB;AAED,wBAAsB,6BAA6B,CACjD,gBAAgB,EAAE,MAAM,EACxB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,uBAAuB,EAAE,GACxC,OAAO,CAAC,mBAAmB,CAAC,CAQ9B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { adminCrudInputCompilerSpec, appCompilerSpec, modelTransformerCompilerSpec, } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { discoverPlugins } from './plugin-discovery.js';
|
|
5
|
+
const NODE_SPEC_IMPLEMENTATIONS = [
|
|
6
|
+
modelTransformerCompilerSpec,
|
|
7
|
+
adminCrudInputCompilerSpec,
|
|
8
|
+
appCompilerSpec,
|
|
9
|
+
];
|
|
10
|
+
export async function createNodePluginStore(plugins) {
|
|
11
|
+
const pluginsWithModules = await Promise.all(plugins.map(async (plugin) => ({
|
|
12
|
+
metadata: plugin,
|
|
13
|
+
modules: await Promise.all(plugin.nodeModulePaths.map(async (modulePath) => {
|
|
14
|
+
const mod = (await import(pathToFileURL(modulePath).href));
|
|
15
|
+
const unwrappedModule = 'default' in mod ? mod.default : mod;
|
|
16
|
+
return {
|
|
17
|
+
key: path.relative(plugin.pluginDirectory, modulePath),
|
|
18
|
+
module: unwrappedModule,
|
|
19
|
+
};
|
|
20
|
+
})),
|
|
21
|
+
})));
|
|
22
|
+
return {
|
|
23
|
+
availablePlugins: pluginsWithModules,
|
|
24
|
+
builtinSpecImplementations: NODE_SPEC_IMPLEMENTATIONS,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export async function createNodePluginStoreFromDirectory(projectDirectory, logger, builtinPlugins) {
|
|
28
|
+
const plugins = await discoverPlugins(projectDirectory, logger);
|
|
29
|
+
const allPlugins = [
|
|
30
|
+
...plugins,
|
|
31
|
+
...builtinPlugins.filter((p) => !plugins.some((p2) => p2.packageName === p.packageName)),
|
|
32
|
+
];
|
|
33
|
+
return createNodePluginStore(allPlugins);
|
|
34
|
+
}
|
|
35
|
+
export async function createNodeSchemaParserContext(projectDirectory, logger, builtinPlugins) {
|
|
36
|
+
return {
|
|
37
|
+
pluginStore: await createNodePluginStoreFromDirectory(projectDirectory, logger, builtinPlugins),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=node-plugin-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-plugin-store.js","sourceRoot":"","sources":["../../src/plugins/node-plugin-store.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,0BAA0B,EAC1B,e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UAAU,GAAG;QACjB,GAAG,OAAO;QACV,GAAG,cAAc,CAAC,MAAM,CACtB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,CAAC,CAC/D;KACF,CAAC;IACF,OAAO,qBAAqB,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,gBAAwB,EACxB,MAAc,EACd,cAAyC;IAEzC,OAAO;QACL,WAAW,EAAE,MAAM,kCAAkC,CACnD,gBAAgB,EAChB,MAAM,EACN,cAAc,CACf;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PluginMetadataWithPaths } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import type { Logger } from '@baseplate-dev/sync';
|
|
3
|
+
/**
|
|
4
|
+
* Finds the available plugins in the project.
|
|
5
|
+
*/
|
|
6
|
+
export declare function discoverPlugins(projectDirectory: string, logger: Logger): Promise<PluginMetadataWithPaths[]>;
|
|
7
|
+
//# sourceMappingURL=plugin-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-discovery.d.ts","sourceRoot":"","sources":["../../src/plugins/plugin-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAclD;;GAEG;AACH,wBAAsB,eAAe,CACnC,gBAAgB,EAAE,MAAM,EACxB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkEpC"}
|