@bleedingdev/modern-js-create 3.4.0-ultramodern.8 → 3.5.0-ultramodern.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -23
- package/dist/cjs/index.cjs +37 -4
- package/dist/cjs/locale/en.cjs +12 -2
- package/dist/cjs/locale/zh.cjs +12 -2
- package/dist/cjs/ultramodern-tooling/commands.cjs +185 -0
- package/dist/cjs/ultramodern-tooling/config.cjs +172 -0
- package/dist/cjs/ultramodern-workspace/add-vertical.cjs +87 -75
- package/dist/cjs/ultramodern-workspace/{effect-api.cjs → api.cjs} +207 -208
- package/dist/cjs/ultramodern-workspace/bridge-config.cjs +327 -0
- package/dist/cjs/ultramodern-workspace/codesmith.cjs +1 -0
- package/dist/cjs/ultramodern-workspace/contracts.cjs +127 -657
- package/dist/cjs/ultramodern-workspace/demo-components.cjs +12 -12
- package/dist/cjs/ultramodern-workspace/descriptors.cjs +25 -25
- package/dist/cjs/ultramodern-workspace/fs-io.cjs +117 -0
- package/dist/cjs/ultramodern-workspace/generation-result.cjs +5 -5
- package/dist/cjs/ultramodern-workspace/index.cjs +4 -0
- package/dist/cjs/ultramodern-workspace/mf-validation.cjs +571 -0
- package/dist/cjs/ultramodern-workspace/module-federation.cjs +33 -18
- package/dist/cjs/ultramodern-workspace/overlays.cjs +2 -2
- package/dist/cjs/ultramodern-workspace/package-json.cjs +57 -41
- package/dist/cjs/ultramodern-workspace/policy.cjs +4 -4
- package/dist/cjs/ultramodern-workspace/public-api.cjs +4 -0
- package/dist/cjs/ultramodern-workspace/public-surface.cjs +2 -2
- package/dist/cjs/ultramodern-workspace/versions.cjs +5 -0
- package/dist/cjs/ultramodern-workspace/workspace-scripts.cjs +119 -50
- package/dist/cjs/ultramodern-workspace/write-workspace.cjs +62 -21
- package/dist/esm/index.js +37 -4
- package/dist/esm/locale/en.js +12 -2
- package/dist/esm/locale/zh.js +12 -2
- package/dist/esm/ultramodern-tooling/commands.js +132 -0
- package/dist/esm/ultramodern-tooling/config.js +120 -0
- package/dist/esm/ultramodern-workspace/add-vertical.js +88 -79
- package/dist/esm/ultramodern-workspace/{effect-api.js → api.js} +146 -147
- package/dist/esm/ultramodern-workspace/bridge-config.js +270 -0
- package/dist/esm/ultramodern-workspace/codesmith.js +1 -0
- package/dist/esm/ultramodern-workspace/contracts.js +129 -611
- package/dist/esm/ultramodern-workspace/demo-components.js +13 -13
- package/dist/esm/ultramodern-workspace/descriptors.js +11 -11
- package/dist/esm/ultramodern-workspace/fs-io.js +116 -2
- package/dist/esm/ultramodern-workspace/generation-result.js +6 -6
- package/dist/esm/ultramodern-workspace/index.js +1 -0
- package/dist/esm/ultramodern-workspace/mf-validation.js +516 -0
- package/dist/esm/ultramodern-workspace/module-federation.js +34 -19
- package/dist/esm/ultramodern-workspace/overlays.js +2 -2
- package/dist/esm/ultramodern-workspace/package-json.js +56 -40
- package/dist/esm/ultramodern-workspace/policy.js +5 -5
- package/dist/esm/ultramodern-workspace/public-api.js +1 -0
- package/dist/esm/ultramodern-workspace/public-surface.js +2 -2
- package/dist/esm/ultramodern-workspace/versions.js +3 -1
- package/dist/esm/ultramodern-workspace/workspace-scripts.js +107 -34
- package/dist/esm/ultramodern-workspace/write-workspace.js +64 -26
- package/dist/esm-node/index.js +37 -4
- package/dist/esm-node/locale/en.js +12 -2
- package/dist/esm-node/locale/zh.js +12 -2
- package/dist/esm-node/ultramodern-tooling/commands.js +133 -0
- package/dist/esm-node/ultramodern-tooling/config.js +121 -0
- package/dist/esm-node/ultramodern-workspace/add-vertical.js +88 -79
- package/dist/esm-node/ultramodern-workspace/{effect-api.js → api.js} +146 -147
- package/dist/esm-node/ultramodern-workspace/bridge-config.js +271 -0
- package/dist/esm-node/ultramodern-workspace/codesmith.js +1 -0
- package/dist/esm-node/ultramodern-workspace/contracts.js +129 -611
- package/dist/esm-node/ultramodern-workspace/demo-components.js +13 -13
- package/dist/esm-node/ultramodern-workspace/descriptors.js +11 -11
- package/dist/esm-node/ultramodern-workspace/fs-io.js +116 -2
- package/dist/esm-node/ultramodern-workspace/generation-result.js +6 -6
- package/dist/esm-node/ultramodern-workspace/index.js +1 -0
- package/dist/esm-node/ultramodern-workspace/mf-validation.js +517 -0
- package/dist/esm-node/ultramodern-workspace/module-federation.js +34 -19
- package/dist/esm-node/ultramodern-workspace/overlays.js +2 -2
- package/dist/esm-node/ultramodern-workspace/package-json.js +56 -40
- package/dist/esm-node/ultramodern-workspace/policy.js +5 -5
- package/dist/esm-node/ultramodern-workspace/public-api.js +1 -0
- package/dist/esm-node/ultramodern-workspace/public-surface.js +2 -2
- package/dist/esm-node/ultramodern-workspace/versions.js +3 -1
- package/dist/esm-node/ultramodern-workspace/workspace-scripts.js +107 -34
- package/dist/esm-node/ultramodern-workspace/write-workspace.js +64 -26
- package/dist/types/locale/en.d.ts +10 -0
- package/dist/types/locale/index.d.ts +20 -0
- package/dist/types/locale/zh.d.ts +10 -0
- package/dist/types/ultramodern-tooling/commands.d.ts +1 -0
- package/dist/types/ultramodern-tooling/config.d.ts +43 -0
- package/dist/types/ultramodern-workspace/add-vertical.d.ts +5 -2
- package/dist/types/ultramodern-workspace/api.d.ts +73 -0
- package/dist/types/ultramodern-workspace/bridge-config.d.ts +64 -0
- package/dist/types/ultramodern-workspace/codesmith.d.ts +1 -0
- package/dist/types/ultramodern-workspace/contracts.d.ts +2 -17
- package/dist/types/ultramodern-workspace/descriptors.d.ts +10 -10
- package/dist/types/ultramodern-workspace/fs-io.d.ts +1 -0
- package/dist/types/ultramodern-workspace/index.d.ts +2 -0
- package/dist/types/ultramodern-workspace/mf-validation.d.ts +27 -0
- package/dist/types/ultramodern-workspace/package-json.d.ts +5 -4
- package/dist/types/ultramodern-workspace/public-api.d.ts +2 -0
- package/dist/types/ultramodern-workspace/types.d.ts +9 -7
- package/dist/types/ultramodern-workspace/versions.d.ts +2 -0
- package/dist/types/ultramodern-workspace/workspace-scripts.d.ts +2 -7
- package/dist/types/ultramodern-workspace/write-workspace.d.ts +4 -2
- package/package.json +5 -3
- package/template-workspace/{.agents → .codex}/skills-lock.json +12 -12
- package/template-workspace/.github/workflows/ultramodern-workspace-gates.yml.handlebars +2 -0
- package/template-workspace/.gitignore.handlebars +3 -0
- package/template-workspace/AGENTS.md.handlebars +11 -5
- package/template-workspace/README.md.handlebars +15 -12
- package/template-workspace/oxfmt.config.ts +1 -0
- package/template-workspace/oxlint.config.ts +1 -0
- package/template-workspace/patches/@tanstack__router-core@1.171.13.patch +51 -0
- package/template-workspace/pnpm-workspace.yaml.handlebars +4 -0
- package/template-workspace/scripts/bootstrap-agent-skills.mjs +77 -67
- package/templates/workspace-scripts/assert-mf-types.mjs.handlebars +51 -8
- package/templates/workspace-scripts/check-ultramodern-api-boundaries.mts +344 -0
- package/templates/workspace-scripts/{check-ultramodern-i18n-boundaries.mjs → check-ultramodern-i18n-boundaries.mts} +1 -1
- package/templates/workspace-scripts/generate-public-surface-assets.mjs +246 -9
- package/templates/workspace-scripts/proof-cloudflare-version.mjs +277 -9
- package/templates/workspace-scripts/ultramodern-cloudflare-proof.mjs +35 -10
- package/templates/workspace-scripts/ultramodern-performance-readiness.mjs +165 -2
- package/templates/workspace-scripts/ultramodern-typecheck.mjs +4 -2
- package/templates/workspace-scripts/validate-ultramodern-workspace.mjs.handlebars +840 -84
- package/dist/types/ultramodern-workspace/effect-api.d.ts +0 -73
- /package/template-workspace/{.agents → .codex}/rstackjs-agent-skills-LICENSE +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsbuild-best-practices/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/command-map.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/common-analysis-patterns.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor-common.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor-rspack.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor-webpack.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/install-rsdoctor.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rsdoctor-analysis/references/rsdoctor-data-types.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rslib-best-practices/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rslib-modern-package/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rspack-best-practices/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/SKILL.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/references/bottlenecks.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/references/tracing-guide.md +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rspack-tracing/scripts/analyze_trace.js +0 -0
- /package/template-workspace/{.agents → .codex}/skills/rstest-best-practices/SKILL.md +0 -0
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { appHasApi, resolveApiPrefix, resolveApiStem, verticalApiApps } from "./descriptors.js";
|
|
2
2
|
import { packageName, toCamelCase, toPascalCase } from "./naming.js";
|
|
3
|
-
function
|
|
4
|
-
return `${toCamelCase(
|
|
3
|
+
function verticalApiExport(service) {
|
|
4
|
+
return `${toCamelCase(resolveApiStem(service))}Api`;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return toCamelCase(
|
|
6
|
+
function verticalApiGroupName(service) {
|
|
7
|
+
return toCamelCase(resolveApiStem(service));
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return `${toPascalCase(
|
|
9
|
+
function verticalApiName(service) {
|
|
10
|
+
return `${toPascalCase(resolveApiStem(service))}Api`;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
return `${toCamelCase(
|
|
12
|
+
function verticalApiSchemaExport(service) {
|
|
13
|
+
return `${toCamelCase(resolveApiStem(service))}ItemSchema`;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return `${toCamelCase(
|
|
15
|
+
function verticalApiMarkerSchemaExport(service) {
|
|
16
|
+
return `${toCamelCase(resolveApiStem(service))}MarkerSchema`;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return `${toCamelCase(
|
|
18
|
+
function verticalApiReadinessSchemaExport(service) {
|
|
19
|
+
return `${toCamelCase(resolveApiStem(service))}ReadinessSchema`;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function verticalApiErrorStem(service) {
|
|
22
|
+
return resolveApiStem(service);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return `${toCamelCase(
|
|
24
|
+
function verticalApiCreatePayloadSchemaExport(service) {
|
|
25
|
+
return `${toCamelCase(resolveApiStem(service))}CreatePayloadSchema`;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return `${toPascalCase(
|
|
27
|
+
function verticalApiNotFoundErrorExport(service) {
|
|
28
|
+
return `${toPascalCase(verticalApiErrorStem(service))}NotFound`;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return `${toCamelCase(
|
|
30
|
+
function verticalApiNotFoundSchemaExport(service) {
|
|
31
|
+
return `${toCamelCase(verticalApiErrorStem(service))}NotFoundSchema`;
|
|
32
32
|
}
|
|
33
33
|
function serviceHasCheckoutCartState(service) {
|
|
34
|
-
return 'checkout' ===
|
|
34
|
+
return 'checkout' === resolveApiStem(service);
|
|
35
35
|
}
|
|
36
36
|
function createCheckoutCartSharedSchemas(service) {
|
|
37
37
|
if (!serviceHasCheckoutCartState(service)) return '';
|
|
@@ -89,61 +89,61 @@ function createCheckoutCartEndpointDefinitions(service) {
|
|
|
89
89
|
if (!serviceHasCheckoutCartState(service)) return '';
|
|
90
90
|
return `
|
|
91
91
|
.add(
|
|
92
|
-
HttpApiEndpoint.get('getCart', '/
|
|
92
|
+
HttpApiEndpoint.get('getCart', '/checkout/cart', {
|
|
93
93
|
success: checkoutCartSchema,
|
|
94
94
|
}),
|
|
95
95
|
)
|
|
96
96
|
.add(
|
|
97
|
-
HttpApiEndpoint.post('addCartItem', '/
|
|
97
|
+
HttpApiEndpoint.post('addCartItem', '/checkout/cart/items', {
|
|
98
98
|
payload: checkoutAddCartItemPayloadSchema,
|
|
99
99
|
success: checkoutCartSchema,
|
|
100
100
|
}),
|
|
101
101
|
)
|
|
102
102
|
.add(
|
|
103
|
-
HttpApiEndpoint.post('removeCartItem', '/
|
|
103
|
+
HttpApiEndpoint.post('removeCartItem', '/checkout/cart/remove', {
|
|
104
104
|
payload: checkoutRemoveCartItemPayloadSchema,
|
|
105
105
|
success: checkoutCartSchema,
|
|
106
106
|
}),
|
|
107
107
|
)
|
|
108
108
|
.add(
|
|
109
|
-
HttpApiEndpoint.post('clearCart', '/
|
|
109
|
+
HttpApiEndpoint.post('clearCart', '/checkout/cart/clear', {
|
|
110
110
|
success: checkoutCartSchema,
|
|
111
111
|
}),
|
|
112
112
|
)`;
|
|
113
113
|
}
|
|
114
114
|
function createCheckoutCartOperationContexts(service) {
|
|
115
|
-
const apiName =
|
|
116
|
-
const groupName =
|
|
115
|
+
const apiName = verticalApiName(service);
|
|
116
|
+
const groupName = verticalApiGroupName(service);
|
|
117
117
|
if (!serviceHasCheckoutCartState(service)) return '';
|
|
118
118
|
return `
|
|
119
119
|
addCartItem: {
|
|
120
120
|
method: 'POST',
|
|
121
121
|
operationId: '${apiName}:${groupName}:addCartItem',
|
|
122
|
-
routePath: '/
|
|
122
|
+
routePath: '/checkout/cart/items',
|
|
123
123
|
source: 'generated-client',
|
|
124
124
|
},
|
|
125
125
|
clearCart: {
|
|
126
126
|
method: 'POST',
|
|
127
127
|
operationId: '${apiName}:${groupName}:clearCart',
|
|
128
|
-
routePath: '/
|
|
128
|
+
routePath: '/checkout/cart/clear',
|
|
129
129
|
source: 'generated-client',
|
|
130
130
|
},
|
|
131
131
|
getCart: {
|
|
132
132
|
method: 'GET',
|
|
133
133
|
operationId: '${apiName}:${groupName}:getCart',
|
|
134
|
-
routePath: '/
|
|
134
|
+
routePath: '/checkout/cart',
|
|
135
135
|
source: 'generated-client',
|
|
136
136
|
},
|
|
137
137
|
removeCartItem: {
|
|
138
138
|
method: 'POST',
|
|
139
139
|
operationId: '${apiName}:${groupName}:removeCartItem',
|
|
140
|
-
routePath: '/
|
|
140
|
+
routePath: '/checkout/cart/remove',
|
|
141
141
|
source: 'generated-client',
|
|
142
142
|
},`;
|
|
143
143
|
}
|
|
144
144
|
function createCheckoutCartApiContractFields(service) {
|
|
145
145
|
if (!serviceHasCheckoutCartState(service)) return '';
|
|
146
|
-
return ` checkoutCartPath: '${
|
|
146
|
+
return ` checkoutCartPath: '${resolveApiPrefix(service)}/checkout/cart',
|
|
147
147
|
`;
|
|
148
148
|
}
|
|
149
149
|
function createCheckoutCartServerState(service) {
|
|
@@ -174,12 +174,12 @@ const createCheckoutCartSnapshot = () => {
|
|
|
174
174
|
`;
|
|
175
175
|
}
|
|
176
176
|
function createCheckoutCartServerHandlers(service) {
|
|
177
|
-
const groupName =
|
|
177
|
+
const groupName = verticalApiGroupName(service);
|
|
178
178
|
if (!serviceHasCheckoutCartState(service)) return '';
|
|
179
179
|
return `
|
|
180
180
|
.handle('getCart', () =>
|
|
181
181
|
Effect.sync(() => createCheckoutCartSnapshot()).pipe(
|
|
182
|
-
Effect.withSpan('ultramodern.
|
|
182
|
+
Effect.withSpan('ultramodern.api.${groupName}.checkout.getCart', {
|
|
183
183
|
attributes: operationAttributes(${groupName}OperationContexts.getCart),
|
|
184
184
|
kind: 'server',
|
|
185
185
|
}),
|
|
@@ -197,7 +197,7 @@ function createCheckoutCartServerHandlers(service) {
|
|
|
197
197
|
});
|
|
198
198
|
return createCheckoutCartSnapshot();
|
|
199
199
|
}).pipe(
|
|
200
|
-
Effect.withSpan('ultramodern.
|
|
200
|
+
Effect.withSpan('ultramodern.api.${groupName}.checkout.addCartItem', {
|
|
201
201
|
attributes: operationAttributes(${groupName}OperationContexts.addCartItem),
|
|
202
202
|
kind: 'server',
|
|
203
203
|
}),
|
|
@@ -208,7 +208,7 @@ function createCheckoutCartServerHandlers(service) {
|
|
|
208
208
|
checkoutCartLines.delete(payload.sku);
|
|
209
209
|
return createCheckoutCartSnapshot();
|
|
210
210
|
}).pipe(
|
|
211
|
-
Effect.withSpan('ultramodern.
|
|
211
|
+
Effect.withSpan('ultramodern.api.${groupName}.checkout.removeCartItem', {
|
|
212
212
|
attributes: operationAttributes(${groupName}OperationContexts.removeCartItem),
|
|
213
213
|
kind: 'server',
|
|
214
214
|
}),
|
|
@@ -219,7 +219,7 @@ function createCheckoutCartServerHandlers(service) {
|
|
|
219
219
|
checkoutCartLines.clear();
|
|
220
220
|
return createCheckoutCartSnapshot();
|
|
221
221
|
}).pipe(
|
|
222
|
-
Effect.withSpan('ultramodern.
|
|
222
|
+
Effect.withSpan('ultramodern.api.${groupName}.checkout.clearCart', {
|
|
223
223
|
attributes: operationAttributes(${groupName}OperationContexts.clearCart),
|
|
224
224
|
kind: 'server',
|
|
225
225
|
}),
|
|
@@ -228,8 +228,8 @@ function createCheckoutCartServerHandlers(service) {
|
|
|
228
228
|
}
|
|
229
229
|
function createCheckoutCartClientExports(service) {
|
|
230
230
|
if (!serviceHasCheckoutCartState(service)) return '';
|
|
231
|
-
const stem =
|
|
232
|
-
const groupName =
|
|
231
|
+
const stem = resolveApiStem(service);
|
|
232
|
+
const groupName = verticalApiGroupName(service);
|
|
233
233
|
const pascalStem = toPascalCase(stem);
|
|
234
234
|
const clientOptionsName = `${pascalStem}ClientOptions`;
|
|
235
235
|
const createClientName = `create${pascalStem}Client`;
|
|
@@ -306,7 +306,7 @@ export const clearCheckoutCart = (
|
|
|
306
306
|
);
|
|
307
307
|
`;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function createSharedApiImports() {
|
|
310
310
|
return `import {
|
|
311
311
|
HttpApi,
|
|
312
312
|
HttpApiEndpoint,
|
|
@@ -316,17 +316,17 @@ function createEffectSharedApiImports() {
|
|
|
316
316
|
} from '@modern-js/plugin-bff/effect-client';
|
|
317
317
|
`;
|
|
318
318
|
}
|
|
319
|
-
function
|
|
320
|
-
const schemaExport =
|
|
321
|
-
const markerSchemaExport =
|
|
322
|
-
const readinessSchemaExport =
|
|
323
|
-
const createPayloadSchemaExport =
|
|
324
|
-
const notFoundErrorExport =
|
|
325
|
-
const notFoundSchemaExport =
|
|
326
|
-
const apiExport =
|
|
327
|
-
const apiName =
|
|
328
|
-
const groupName =
|
|
329
|
-
const stem =
|
|
319
|
+
function createSharedApiContract(service) {
|
|
320
|
+
const schemaExport = verticalApiSchemaExport(service);
|
|
321
|
+
const markerSchemaExport = verticalApiMarkerSchemaExport(service);
|
|
322
|
+
const readinessSchemaExport = verticalApiReadinessSchemaExport(service);
|
|
323
|
+
const createPayloadSchemaExport = verticalApiCreatePayloadSchemaExport(service);
|
|
324
|
+
const notFoundErrorExport = verticalApiNotFoundErrorExport(service);
|
|
325
|
+
const notFoundSchemaExport = verticalApiNotFoundSchemaExport(service);
|
|
326
|
+
const apiExport = verticalApiExport(service);
|
|
327
|
+
const apiName = verticalApiName(service);
|
|
328
|
+
const groupName = verticalApiGroupName(service);
|
|
329
|
+
const stem = resolveApiStem(service);
|
|
330
330
|
const pascalStem = toPascalCase(stem);
|
|
331
331
|
const markerType = `${pascalStem}Marker`;
|
|
332
332
|
const itemType = `${pascalStem}Item`;
|
|
@@ -334,7 +334,7 @@ function createEffectSharedApiContract(service) {
|
|
|
334
334
|
const createPayloadType = `${pascalStem}CreatePayload`;
|
|
335
335
|
const createResponseType = `${pascalStem}CreateResponse`;
|
|
336
336
|
const listResponseType = `${pascalStem}ListResponse`;
|
|
337
|
-
const apiPrefix =
|
|
337
|
+
const apiPrefix = resolveApiPrefix(service);
|
|
338
338
|
const checkoutCartSharedSchemas = createCheckoutCartSharedSchemas(service);
|
|
339
339
|
const checkoutCartSharedSchemaSection = '' === checkoutCartSharedSchemas ? '' : `${checkoutCartSharedSchemas}\n`;
|
|
340
340
|
const checkoutCartOperationContexts = createCheckoutCartOperationContexts(service).trimStart();
|
|
@@ -356,7 +356,7 @@ export interface ${itemType} {
|
|
|
356
356
|
|
|
357
357
|
export interface ${readinessType} {
|
|
358
358
|
readonly checks: {
|
|
359
|
-
readonly
|
|
359
|
+
readonly api: 'ready';
|
|
360
360
|
readonly moduleFederation: 'ready';
|
|
361
361
|
readonly ssr: 'ready';
|
|
362
362
|
readonly translations: 'ready';
|
|
@@ -400,7 +400,7 @@ export const ${schemaExport}: Schema.Codec<${itemType}> = Schema.Struct({
|
|
|
400
400
|
|
|
401
401
|
export const ${readinessSchemaExport}: Schema.Codec<${readinessType}> = Schema.Struct({
|
|
402
402
|
checks: Schema.Struct({
|
|
403
|
-
|
|
403
|
+
api: Schema.Literal('ready'),
|
|
404
404
|
moduleFederation: Schema.Literal('ready'),
|
|
405
405
|
ssr: Schema.Literal('ready'),
|
|
406
406
|
translations: Schema.Literal('ready'),
|
|
@@ -437,7 +437,7 @@ export interface OperationContext {
|
|
|
437
437
|
export const ${apiExport} = HttpApi.make('${apiName}').add(
|
|
438
438
|
HttpApiGroup.make('${groupName}')
|
|
439
439
|
.add(
|
|
440
|
-
HttpApiEndpoint.get('list', '
|
|
440
|
+
HttpApiEndpoint.get('list', '/${stem}', {
|
|
441
441
|
query: {
|
|
442
442
|
limit: Schema.optional(Schema.FiniteFromString),
|
|
443
443
|
},
|
|
@@ -447,12 +447,12 @@ export const ${apiExport} = HttpApi.make('${apiName}').add(
|
|
|
447
447
|
}),
|
|
448
448
|
)
|
|
449
449
|
.add(
|
|
450
|
-
HttpApiEndpoint.get('readiness', '
|
|
450
|
+
HttpApiEndpoint.get('readiness', '/${stem}/readiness', {
|
|
451
451
|
success: ${readinessSchemaExport},
|
|
452
452
|
}),
|
|
453
453
|
)
|
|
454
454
|
.add(
|
|
455
|
-
HttpApiEndpoint.get('get', '
|
|
455
|
+
HttpApiEndpoint.get('get', '/${stem}/:id', {
|
|
456
456
|
error: ${notFoundSchemaExport},
|
|
457
457
|
params: {
|
|
458
458
|
id: Schema.String,
|
|
@@ -461,7 +461,7 @@ export const ${apiExport} = HttpApi.make('${apiName}').add(
|
|
|
461
461
|
}),
|
|
462
462
|
)
|
|
463
463
|
.add(
|
|
464
|
-
HttpApiEndpoint.post('create', '
|
|
464
|
+
HttpApiEndpoint.post('create', '/${stem}', {
|
|
465
465
|
payload: ${createPayloadSchemaExport},
|
|
466
466
|
success: Schema.Struct({
|
|
467
467
|
item: ${schemaExport},
|
|
@@ -474,46 +474,46 @@ export const ${groupName}OperationContexts = {
|
|
|
474
474
|
${checkoutCartOperationContextEntries} create: {
|
|
475
475
|
method: 'POST',
|
|
476
476
|
operationId: '${apiName}:${groupName}:create',
|
|
477
|
-
routePath: '
|
|
477
|
+
routePath: '/${stem}',
|
|
478
478
|
source: 'generated-client',
|
|
479
479
|
},
|
|
480
480
|
get: {
|
|
481
481
|
method: 'GET',
|
|
482
482
|
operationId: '${apiName}:${groupName}:get',
|
|
483
|
-
routePath: '
|
|
483
|
+
routePath: '/${stem}/:id',
|
|
484
484
|
source: 'generated-client',
|
|
485
485
|
},
|
|
486
486
|
list: {
|
|
487
487
|
method: 'GET',
|
|
488
488
|
operationId: '${apiName}:${groupName}:list',
|
|
489
|
-
routePath: '
|
|
489
|
+
routePath: '/${stem}',
|
|
490
490
|
source: 'generated-client',
|
|
491
491
|
},
|
|
492
492
|
readiness: {
|
|
493
493
|
method: 'GET',
|
|
494
494
|
operationId: '${apiName}:${groupName}:readiness',
|
|
495
|
-
routePath: '
|
|
495
|
+
routePath: '/${stem}/readiness',
|
|
496
496
|
source: 'generated-client',
|
|
497
497
|
},
|
|
498
498
|
} satisfies Record<string, OperationContext>;
|
|
499
499
|
|
|
500
500
|
export const ${groupName}ApiContract = {
|
|
501
501
|
apiPrefix: '${apiPrefix}',
|
|
502
|
-
basePath: '${apiPrefix}
|
|
502
|
+
basePath: '${apiPrefix}/${stem}',
|
|
503
503
|
${createCheckoutCartApiContractFields(service)} ownerId: '${service.id}',
|
|
504
|
-
readinessPath: '${apiPrefix}
|
|
504
|
+
readinessPath: '${apiPrefix}/${stem}/readiness',
|
|
505
505
|
} as const;
|
|
506
506
|
`;
|
|
507
507
|
}
|
|
508
|
-
function
|
|
509
|
-
return `${
|
|
510
|
-
${
|
|
508
|
+
function createSharedApi(service) {
|
|
509
|
+
return `${createSharedApiImports()}
|
|
510
|
+
${createSharedApiContract(service)}`;
|
|
511
511
|
}
|
|
512
|
-
function
|
|
513
|
-
const apiExport =
|
|
514
|
-
const groupName =
|
|
515
|
-
const notFoundErrorExport =
|
|
516
|
-
const stem =
|
|
512
|
+
function createApiServiceEntry(service, contractImportPath) {
|
|
513
|
+
const apiExport = verticalApiExport(service);
|
|
514
|
+
const groupName = verticalApiGroupName(service);
|
|
515
|
+
const notFoundErrorExport = verticalApiNotFoundErrorExport(service);
|
|
516
|
+
const stem = resolveApiStem(service);
|
|
517
517
|
return `import {
|
|
518
518
|
defineEffectBff,
|
|
519
519
|
Effect,
|
|
@@ -525,7 +525,7 @@ import type {
|
|
|
525
525
|
EffectBffRuntime,
|
|
526
526
|
EffectRuntimeLayer,
|
|
527
527
|
} from '@modern-js/plugin-bff/effect-edge';
|
|
528
|
-
import { ultramodernApiMarker } from '
|
|
528
|
+
import { ultramodernApiMarker } from '../shared/ultramodern-build.ts';
|
|
529
529
|
import {
|
|
530
530
|
${apiExport},
|
|
531
531
|
${groupName}OperationContexts,
|
|
@@ -566,7 +566,7 @@ const ${groupName}Layer = HttpApiBuilder.group(
|
|
|
566
566
|
? ${groupName}Items.slice(0, query.limit)
|
|
567
567
|
: ${groupName}Items,
|
|
568
568
|
}).pipe(
|
|
569
|
-
Effect.withSpan('ultramodern.
|
|
569
|
+
Effect.withSpan('ultramodern.api.${groupName}.list', {
|
|
570
570
|
attributes: operationAttributes(${groupName}OperationContexts.list),
|
|
571
571
|
kind: 'server',
|
|
572
572
|
}),
|
|
@@ -575,7 +575,7 @@ const ${groupName}Layer = HttpApiBuilder.group(
|
|
|
575
575
|
.handle('readiness', () =>
|
|
576
576
|
Effect.succeed({
|
|
577
577
|
checks: {
|
|
578
|
-
|
|
578
|
+
api: 'ready' as const,
|
|
579
579
|
moduleFederation: 'ready' as const,
|
|
580
580
|
ssr: 'ready' as const,
|
|
581
581
|
translations: 'ready' as const,
|
|
@@ -584,7 +584,7 @@ const ${groupName}Layer = HttpApiBuilder.group(
|
|
|
584
584
|
status: 'ready' as const,
|
|
585
585
|
versionSkew: 'none' as const,
|
|
586
586
|
}).pipe(
|
|
587
|
-
Effect.withSpan('ultramodern.
|
|
587
|
+
Effect.withSpan('ultramodern.api.${groupName}.readiness', {
|
|
588
588
|
attributes: operationAttributes(${groupName}OperationContexts.readiness),
|
|
589
589
|
kind: 'server',
|
|
590
590
|
}),
|
|
@@ -604,7 +604,7 @@ const ${groupName}Layer = HttpApiBuilder.group(
|
|
|
604
604
|
: Effect.succeed(matchedItem);
|
|
605
605
|
|
|
606
606
|
return result.pipe(
|
|
607
|
-
Effect.withSpan('ultramodern.
|
|
607
|
+
Effect.withSpan('ultramodern.api.${groupName}.get', {
|
|
608
608
|
attributes: operationAttributes(${groupName}OperationContexts.get),
|
|
609
609
|
kind: 'server',
|
|
610
610
|
}),
|
|
@@ -621,7 +621,7 @@ const ${groupName}Layer = HttpApiBuilder.group(
|
|
|
621
621
|
title: payload.title,
|
|
622
622
|
},
|
|
623
623
|
}).pipe(
|
|
624
|
-
Effect.withSpan('ultramodern.
|
|
624
|
+
Effect.withSpan('ultramodern.api.${groupName}.create', {
|
|
625
625
|
attributes: operationAttributes(${groupName}OperationContexts.create),
|
|
626
626
|
kind: 'server',
|
|
627
627
|
}),
|
|
@@ -633,21 +633,21 @@ const layer = HttpApiBuilder.layer(${apiExport}).pipe(
|
|
|
633
633
|
Layer.provide(${groupName}Layer),
|
|
634
634
|
) satisfies EffectRuntimeLayer;
|
|
635
635
|
|
|
636
|
-
const
|
|
636
|
+
const apiRuntime: EffectBffDefinition<typeof ${apiExport}, EffectRuntimeLayer> &
|
|
637
637
|
EffectBffRuntime<typeof ${apiExport}, EffectRuntimeLayer> = defineEffectBff({
|
|
638
638
|
api: ${apiExport},
|
|
639
639
|
layer,
|
|
640
640
|
});
|
|
641
641
|
|
|
642
|
-
export default
|
|
642
|
+
export default apiRuntime;
|
|
643
643
|
`;
|
|
644
644
|
}
|
|
645
|
-
function
|
|
646
|
-
const apiExport =
|
|
647
|
-
const contractExport =
|
|
648
|
-
const stem =
|
|
649
|
-
const groupName =
|
|
650
|
-
const singular =
|
|
645
|
+
function createApiClient(service, contractImportPath) {
|
|
646
|
+
const apiExport = verticalApiExport(service);
|
|
647
|
+
const contractExport = verticalApiGroupName(service);
|
|
648
|
+
const stem = resolveApiStem(service);
|
|
649
|
+
const groupName = verticalApiGroupName(service);
|
|
650
|
+
const singular = verticalApiErrorStem(service);
|
|
651
651
|
const clientOptionsName = `${toPascalCase(stem)}ClientOptions`;
|
|
652
652
|
const createClientName = `create${toPascalCase(stem)}Client`;
|
|
653
653
|
const clientTypeName = `${toPascalCase(stem)}Client`;
|
|
@@ -656,7 +656,7 @@ function createEffectClient(service, contractImportPath) {
|
|
|
656
656
|
const readinessName = `get${toPascalCase(stem)}Readiness`;
|
|
657
657
|
const getName = `get${toPascalCase(singular)}`;
|
|
658
658
|
const createName = `create${toPascalCase(singular)}`;
|
|
659
|
-
const notFoundErrorExport =
|
|
659
|
+
const notFoundErrorExport = verticalApiNotFoundErrorExport(service);
|
|
660
660
|
const pascalStem = toPascalCase(stem);
|
|
661
661
|
const itemType = `${pascalStem}Item`;
|
|
662
662
|
const readinessType = `${pascalStem}Readiness`;
|
|
@@ -691,7 +691,7 @@ import type {
|
|
|
691
691
|
|
|
692
692
|
export { Effect, runEffectRequest };
|
|
693
693
|
|
|
694
|
-
type ${pascalStem}
|
|
694
|
+
type ${pascalStem}ApiGroups = typeof ${apiExport} extends HttpApi.HttpApi<
|
|
695
695
|
infer _ApiId,
|
|
696
696
|
infer Groups
|
|
697
697
|
>
|
|
@@ -699,7 +699,7 @@ type ${pascalStem}EffectGroups = typeof ${apiExport} extends HttpApi.HttpApi<
|
|
|
699
699
|
: never;
|
|
700
700
|
|
|
701
701
|
export type ${clientTypeName} = HttpApiClient.Client<
|
|
702
|
-
Extract<${pascalStem}
|
|
702
|
+
Extract<${pascalStem}ApiGroups, HttpApiGroup.Any>,
|
|
703
703
|
never,
|
|
704
704
|
never
|
|
705
705
|
>;
|
|
@@ -789,11 +789,11 @@ export const ${createName} = (
|
|
|
789
789
|
);${checkoutCartClientExports}
|
|
790
790
|
`;
|
|
791
791
|
}
|
|
792
|
-
function
|
|
793
|
-
const exports =
|
|
794
|
-
const stem =
|
|
792
|
+
function createShellApiClient(scope, remotes = []) {
|
|
793
|
+
const exports = verticalApiApps(remotes).map((remote)=>{
|
|
794
|
+
const stem = resolveApiStem(remote);
|
|
795
795
|
const pascalStem = toPascalCase(stem);
|
|
796
|
-
const pascalSingular = toPascalCase(
|
|
796
|
+
const pascalSingular = toPascalCase(verticalApiErrorStem(remote));
|
|
797
797
|
const checkoutCartExports = serviceHasCheckoutCartState(remote) ? ` addCheckoutCartItem,
|
|
798
798
|
clearCheckoutCart,
|
|
799
799
|
getCheckoutCart,
|
|
@@ -809,15 +809,15 @@ ${checkoutCartExports} create${pascalSingular},
|
|
|
809
809
|
get${pascalStem}Readiness,
|
|
810
810
|
list${pascalStem},
|
|
811
811
|
type ${pascalStem}ClientOptions,
|
|
812
|
-
} from '${packageName(scope, remote.packageSuffix)}/
|
|
812
|
+
} from '${packageName(scope, remote.packageSuffix)}/api/client';`;
|
|
813
813
|
}).join('\n\n');
|
|
814
814
|
return exports ? `${exports}\n` : `export const ultramodernVerticalClients = [] as const;
|
|
815
815
|
`;
|
|
816
816
|
}
|
|
817
|
-
function
|
|
818
|
-
const stem =
|
|
817
|
+
function createApiReadinessContract(app) {
|
|
818
|
+
const stem = resolveApiStem(app);
|
|
819
819
|
return {
|
|
820
|
-
endpoint:
|
|
820
|
+
endpoint: `/${stem}/readiness`,
|
|
821
821
|
marker: {
|
|
822
822
|
ui: 'ultramodernUiMarker',
|
|
823
823
|
api: 'ultramodernApiMarker',
|
|
@@ -827,11 +827,11 @@ function createEffectReadinessContract(app) {
|
|
|
827
827
|
'moduleFederation',
|
|
828
828
|
'ssr',
|
|
829
829
|
'translations',
|
|
830
|
-
'
|
|
830
|
+
'api'
|
|
831
831
|
]
|
|
832
832
|
};
|
|
833
833
|
}
|
|
834
|
-
function
|
|
834
|
+
function createApiRequestContextContract() {
|
|
835
835
|
return {
|
|
836
836
|
propagatedHeaders: [
|
|
837
837
|
'accept-language',
|
|
@@ -842,39 +842,39 @@ function createEffectRequestContextContract() {
|
|
|
842
842
|
'x-ultramodern-env',
|
|
843
843
|
'x-vertical-version-id'
|
|
844
844
|
],
|
|
845
|
-
source: 'shell-to-vertical-
|
|
845
|
+
source: 'shell-to-vertical-api-client'
|
|
846
846
|
};
|
|
847
847
|
}
|
|
848
|
-
function
|
|
849
|
-
const stem =
|
|
850
|
-
const group =
|
|
851
|
-
const basePath =
|
|
848
|
+
function createApiDomainOperations(app) {
|
|
849
|
+
const stem = resolveApiStem(app);
|
|
850
|
+
const group = verticalApiGroupName(app);
|
|
851
|
+
const basePath = `/${stem}`;
|
|
852
852
|
const checkoutCartOperations = serviceHasCheckoutCartState(app) ? {
|
|
853
853
|
checkoutCartAddItem: {
|
|
854
854
|
client: 'addCheckoutCartItem',
|
|
855
855
|
method: 'POST',
|
|
856
|
-
path: '/
|
|
856
|
+
path: '/checkout/cart/items',
|
|
857
857
|
resource: 'checkout-cart',
|
|
858
858
|
owner: app.id
|
|
859
859
|
},
|
|
860
860
|
checkoutCartClear: {
|
|
861
861
|
client: 'clearCheckoutCart',
|
|
862
862
|
method: 'POST',
|
|
863
|
-
path: '/
|
|
863
|
+
path: '/checkout/cart/clear',
|
|
864
864
|
resource: 'checkout-cart',
|
|
865
865
|
owner: app.id
|
|
866
866
|
},
|
|
867
867
|
checkoutCartRead: {
|
|
868
868
|
client: 'getCheckoutCart',
|
|
869
869
|
method: 'GET',
|
|
870
|
-
path: '/
|
|
870
|
+
path: '/checkout/cart',
|
|
871
871
|
resource: 'checkout-cart',
|
|
872
872
|
owner: app.id
|
|
873
873
|
},
|
|
874
874
|
checkoutCartRemoveItem: {
|
|
875
875
|
client: 'removeCheckoutCartItem',
|
|
876
876
|
method: 'POST',
|
|
877
|
-
path: '/
|
|
877
|
+
path: '/checkout/cart/remove',
|
|
878
878
|
resource: 'checkout-cart',
|
|
879
879
|
owner: app.id
|
|
880
880
|
}
|
|
@@ -889,14 +889,14 @@ function createEffectDomainOperations(app) {
|
|
|
889
889
|
owner: app.id
|
|
890
890
|
},
|
|
891
891
|
workspaceDetail: {
|
|
892
|
-
client: `get${toPascalCase(
|
|
892
|
+
client: `get${toPascalCase(verticalApiErrorStem(app))}`,
|
|
893
893
|
method: 'GET',
|
|
894
894
|
path: `${basePath}/:id`,
|
|
895
895
|
resource: 'workspace-item',
|
|
896
896
|
owner: app.id
|
|
897
897
|
},
|
|
898
898
|
workspaceCreate: {
|
|
899
|
-
client: `create${toPascalCase(
|
|
899
|
+
client: `create${toPascalCase(verticalApiErrorStem(app))}`,
|
|
900
900
|
method: 'POST',
|
|
901
901
|
path: basePath,
|
|
902
902
|
resource: group,
|
|
@@ -904,82 +904,81 @@ function createEffectDomainOperations(app) {
|
|
|
904
904
|
}
|
|
905
905
|
};
|
|
906
906
|
}
|
|
907
|
-
function
|
|
908
|
-
if (!
|
|
907
|
+
function apiTopologyMetadata(app) {
|
|
908
|
+
if (!appHasApi(app)) return;
|
|
909
909
|
return {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
}
|
|
910
|
+
runtime: 'effect',
|
|
911
|
+
bff: {
|
|
912
|
+
prefix: app.api.prefix,
|
|
913
|
+
openapi: '/openapi.json',
|
|
914
|
+
strictEffectApproach: true
|
|
915
|
+
},
|
|
916
|
+
contract: {
|
|
917
|
+
export: './api',
|
|
918
|
+
path: `${app.directory}/shared/api.ts`
|
|
919
|
+
},
|
|
920
|
+
client: {
|
|
921
|
+
export: './api/client',
|
|
922
|
+
path: `${app.directory}/src/api/${app.api.stem}-client.ts`
|
|
923
|
+
},
|
|
924
|
+
serverEntry: `${app.directory}/api/index.ts`,
|
|
925
|
+
basePath: `${app.api.prefix}/${app.api.stem}`,
|
|
926
|
+
consumedBy: app.api.consumedBy,
|
|
927
|
+
readiness: createApiReadinessContract(app),
|
|
928
|
+
requestContext: createApiRequestContextContract(),
|
|
929
|
+
domainOperations: createApiDomainOperations(app)
|
|
931
930
|
};
|
|
932
931
|
}
|
|
933
|
-
function
|
|
934
|
-
const stem =
|
|
932
|
+
function createApiOperationContract(target) {
|
|
933
|
+
const stem = resolveApiStem(target);
|
|
935
934
|
const checkoutCartOperations = serviceHasCheckoutCartState(target) ? {
|
|
936
935
|
addCartItem: {
|
|
937
936
|
method: 'POST',
|
|
938
|
-
path: '/
|
|
937
|
+
path: '/checkout/cart/items',
|
|
939
938
|
source: 'generated-client'
|
|
940
939
|
},
|
|
941
940
|
clearCart: {
|
|
942
941
|
method: 'POST',
|
|
943
|
-
path: '/
|
|
942
|
+
path: '/checkout/cart/clear',
|
|
944
943
|
source: 'generated-client'
|
|
945
944
|
},
|
|
946
945
|
getCart: {
|
|
947
946
|
method: 'GET',
|
|
948
|
-
path: '/
|
|
947
|
+
path: '/checkout/cart',
|
|
949
948
|
source: 'generated-client'
|
|
950
949
|
},
|
|
951
950
|
removeCartItem: {
|
|
952
951
|
method: 'POST',
|
|
953
|
-
path: '/
|
|
952
|
+
path: '/checkout/cart/remove',
|
|
954
953
|
source: 'generated-client'
|
|
955
954
|
}
|
|
956
955
|
} : {};
|
|
957
956
|
return {
|
|
958
|
-
group:
|
|
959
|
-
notFound:
|
|
957
|
+
group: verticalApiGroupName(target),
|
|
958
|
+
notFound: verticalApiNotFoundErrorExport(target),
|
|
960
959
|
operations: {
|
|
961
960
|
...checkoutCartOperations,
|
|
962
961
|
list: {
|
|
963
962
|
method: 'GET',
|
|
964
|
-
path:
|
|
963
|
+
path: `/${stem}`,
|
|
965
964
|
source: 'generated-client'
|
|
966
965
|
},
|
|
967
966
|
readiness: {
|
|
968
967
|
method: 'GET',
|
|
969
|
-
path:
|
|
968
|
+
path: `/${stem}/readiness`,
|
|
970
969
|
source: 'generated-client'
|
|
971
970
|
},
|
|
972
971
|
get: {
|
|
973
972
|
method: 'GET',
|
|
974
|
-
path:
|
|
973
|
+
path: `/${stem}/:id`,
|
|
975
974
|
source: 'generated-client'
|
|
976
975
|
},
|
|
977
976
|
create: {
|
|
978
977
|
method: 'POST',
|
|
979
|
-
path:
|
|
978
|
+
path: `/${stem}`,
|
|
980
979
|
source: 'generated-client'
|
|
981
980
|
}
|
|
982
981
|
}
|
|
983
982
|
};
|
|
984
983
|
}
|
|
985
|
-
export {
|
|
984
|
+
export { apiTopologyMetadata, createApiClient, createApiDomainOperations, createApiOperationContract, createApiReadinessContract, createApiRequestContextContract, createApiServiceEntry, createSharedApi, createSharedApiContract, createSharedApiImports, createShellApiClient, verticalApiCreatePayloadSchemaExport, verticalApiErrorStem, verticalApiExport, verticalApiGroupName, verticalApiMarkerSchemaExport, verticalApiName, verticalApiNotFoundErrorExport, verticalApiNotFoundSchemaExport, verticalApiReadinessSchemaExport, verticalApiSchemaExport };
|