@bleedingdev/modern-js-create 3.2.0-ultramodern.12 → 3.2.0-ultramodern.121
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 +167 -72
- package/bin/run.js +0 -0
- package/dist/cjs/create-package-root.cjs +63 -0
- package/dist/cjs/index.cjs +528 -0
- package/dist/cjs/locale/en.cjs +93 -0
- package/dist/cjs/locale/index.cjs +50 -0
- package/dist/cjs/locale/zh.cjs +93 -0
- package/dist/cjs/ultramodern-package-source.cjs +135 -0
- package/dist/cjs/ultramodern-workspace/add-vertical.cjs +337 -0
- package/dist/cjs/ultramodern-workspace/app-files.cjs +223 -0
- package/dist/cjs/ultramodern-workspace/contracts.cjs +836 -0
- package/dist/cjs/ultramodern-workspace/demo-components.cjs +422 -0
- package/dist/cjs/ultramodern-workspace/descriptors.cjs +222 -0
- package/dist/cjs/ultramodern-workspace/effect-api.cjs +952 -0
- package/dist/cjs/ultramodern-workspace/fs-io.cjs +191 -0
- package/dist/cjs/ultramodern-workspace/index.cjs +48 -0
- package/dist/cjs/ultramodern-workspace/locales.cjs +173 -0
- package/dist/cjs/ultramodern-workspace/module-federation.cjs +487 -0
- package/dist/cjs/ultramodern-workspace/naming.cjs +161 -0
- package/dist/cjs/ultramodern-workspace/package-json.cjs +406 -0
- package/dist/cjs/ultramodern-workspace/package-source.cjs +59 -0
- package/dist/cjs/ultramodern-workspace/policy.cjs +248 -0
- package/dist/cjs/ultramodern-workspace/public-surface.cjs +268 -0
- package/dist/cjs/ultramodern-workspace/routes.cjs +375 -0
- package/dist/cjs/ultramodern-workspace/types.cjs +61 -0
- package/dist/cjs/ultramodern-workspace/versions.cjs +153 -0
- package/dist/cjs/ultramodern-workspace/workspace-scripts.cjs +153 -0
- package/dist/cjs/ultramodern-workspace/write-workspace.cjs +175 -0
- package/dist/esm/create-package-root.js +14 -0
- package/dist/esm/index.js +491 -0
- package/dist/esm/locale/en.js +55 -0
- package/dist/esm/locale/index.js +9 -0
- package/dist/esm/locale/zh.js +55 -0
- package/dist/esm/ultramodern-package-source.js +63 -0
- package/dist/esm/ultramodern-workspace/add-vertical.js +252 -0
- package/dist/esm/ultramodern-workspace/app-files.js +149 -0
- package/dist/esm/ultramodern-workspace/contracts.js +741 -0
- package/dist/esm/ultramodern-workspace/demo-components.js +363 -0
- package/dist/esm/ultramodern-workspace/descriptors.js +133 -0
- package/dist/esm/ultramodern-workspace/effect-api.js +854 -0
- package/dist/esm/ultramodern-workspace/fs-io.js +90 -0
- package/dist/esm/ultramodern-workspace/index.js +3 -0
- package/dist/esm/ultramodern-workspace/locales.js +122 -0
- package/dist/esm/ultramodern-workspace/module-federation.js +415 -0
- package/dist/esm/ultramodern-workspace/naming.js +71 -0
- package/dist/esm/ultramodern-workspace/package-json.js +338 -0
- package/dist/esm/ultramodern-workspace/package-source.js +21 -0
- package/dist/esm/ultramodern-workspace/policy.js +183 -0
- package/dist/esm/ultramodern-workspace/public-surface.js +183 -0
- package/dist/esm/ultramodern-workspace/routes.js +280 -0
- package/dist/esm/ultramodern-workspace/types.js +16 -0
- package/dist/esm/ultramodern-workspace/versions.js +34 -0
- package/dist/esm/ultramodern-workspace/workspace-scripts.js +91 -0
- package/dist/esm/ultramodern-workspace/write-workspace.js +121 -0
- package/dist/esm-node/create-package-root.js +15 -0
- package/dist/esm-node/index.js +492 -0
- package/dist/esm-node/locale/en.js +56 -0
- package/dist/esm-node/locale/index.js +10 -0
- package/dist/esm-node/locale/zh.js +56 -0
- package/dist/esm-node/ultramodern-package-source.js +64 -0
- package/dist/esm-node/ultramodern-workspace/add-vertical.js +253 -0
- package/dist/esm-node/ultramodern-workspace/app-files.js +150 -0
- package/dist/esm-node/ultramodern-workspace/contracts.js +742 -0
- package/dist/esm-node/ultramodern-workspace/demo-components.js +364 -0
- package/dist/esm-node/ultramodern-workspace/descriptors.js +134 -0
- package/dist/esm-node/ultramodern-workspace/effect-api.js +855 -0
- package/dist/esm-node/ultramodern-workspace/fs-io.js +91 -0
- package/dist/esm-node/ultramodern-workspace/index.js +4 -0
- package/dist/esm-node/ultramodern-workspace/locales.js +123 -0
- package/dist/esm-node/ultramodern-workspace/module-federation.js +416 -0
- package/dist/esm-node/ultramodern-workspace/naming.js +72 -0
- package/dist/esm-node/ultramodern-workspace/package-json.js +339 -0
- package/dist/esm-node/ultramodern-workspace/package-source.js +22 -0
- package/dist/esm-node/ultramodern-workspace/policy.js +184 -0
- package/dist/esm-node/ultramodern-workspace/public-surface.js +184 -0
- package/dist/esm-node/ultramodern-workspace/routes.js +281 -0
- package/dist/esm-node/ultramodern-workspace/types.js +17 -0
- package/dist/esm-node/ultramodern-workspace/versions.js +35 -0
- package/dist/esm-node/ultramodern-workspace/workspace-scripts.js +92 -0
- package/dist/esm-node/ultramodern-workspace/write-workspace.js +122 -0
- package/dist/types/create-package-root.d.ts +1 -0
- package/dist/types/locale/en.d.ts +8 -9
- package/dist/types/locale/index.d.ts +109 -2
- package/dist/types/locale/zh.d.ts +8 -9
- package/dist/types/ultramodern-package-source.d.ts +28 -0
- package/dist/types/ultramodern-workspace/add-vertical.d.ts +19 -0
- package/dist/types/ultramodern-workspace/app-files.d.ts +14 -0
- package/dist/types/ultramodern-workspace/contracts.d.ts +21 -0
- package/dist/types/ultramodern-workspace/demo-components.d.ts +9 -0
- package/dist/types/ultramodern-workspace/descriptors.d.ts +39 -0
- package/dist/types/ultramodern-workspace/effect-api.d.ts +73 -0
- package/dist/types/ultramodern-workspace/fs-io.d.ts +18 -0
- package/dist/types/ultramodern-workspace/index.d.ts +4 -0
- package/dist/types/ultramodern-workspace/locales.d.ts +183 -0
- package/dist/types/ultramodern-workspace/module-federation.d.ts +16 -0
- package/dist/types/ultramodern-workspace/naming.d.ts +16 -0
- package/dist/types/ultramodern-workspace/package-json.d.ts +12 -0
- package/dist/types/ultramodern-workspace/package-source.d.ts +2 -0
- package/dist/types/ultramodern-workspace/policy.d.ts +60 -0
- package/dist/types/ultramodern-workspace/public-surface.d.ts +37 -0
- package/dist/types/ultramodern-workspace/routes.d.ts +25 -0
- package/dist/types/ultramodern-workspace/types.d.ts +95 -0
- package/dist/types/ultramodern-workspace/versions.d.ts +38 -0
- package/dist/types/ultramodern-workspace/workspace-scripts.d.ts +10 -0
- package/dist/types/ultramodern-workspace/write-workspace.d.ts +4 -0
- package/package.json +34 -15
- package/template-workspace/.agents/agent-reference-repos.json +24 -0
- package/template-workspace/.agents/skills-lock.json +19 -0
- package/template-workspace/.codex/hooks.json +16 -0
- package/template-workspace/.github/renovate.json +29 -0
- package/template-workspace/.github/workflows/ultramodern-workspace-gates.yml.handlebars +67 -0
- package/template-workspace/.gitignore.handlebars +5 -0
- package/template-workspace/.mise.toml.handlebars +3 -0
- package/template-workspace/AGENTS.md.handlebars +87 -0
- package/template-workspace/README.md.handlebars +132 -11
- package/template-workspace/lefthook.yml +24 -0
- package/template-workspace/oxfmt.config.ts +1 -0
- package/template-workspace/oxlint.config.ts +1 -0
- package/template-workspace/pnpm-workspace.yaml.handlebars +40 -0
- package/template-workspace/scripts/bootstrap-agent-skills.mjs +184 -21
- package/template-workspace/scripts/setup-agent-reference-repos.mjs +370 -0
- package/templates/app/shell-frame.tsx +49 -0
- package/templates/app/ultramodern-route-head.tsx.handlebars +142 -0
- package/templates/packages/shared-contracts-index.ts +466 -0
- package/templates/workspace-scripts/assert-mf-types.mjs.handlebars +69 -0
- package/templates/workspace-scripts/check-ultramodern-i18n-boundaries.mjs +9 -0
- package/templates/workspace-scripts/generate-public-surface-assets.mjs +529 -0
- package/templates/workspace-scripts/proof-cloudflare-version.mjs +125 -0
- package/templates/workspace-scripts/ultramodern-cloudflare-proof.mjs +851 -0
- package/templates/workspace-scripts/ultramodern-performance-readiness.config.mjs +7 -0
- package/templates/workspace-scripts/ultramodern-performance-readiness.mjs +223 -0
- package/templates/workspace-scripts/validate-ultramodern-workspace.mjs.handlebars +593 -0
- package/dist/index.js +0 -2626
- package/dist/types/ultramodern-workspace.d.ts +0 -20
- package/template/.agents/skills-lock.json +0 -34
- package/template/.browserslistrc +0 -4
- package/template/.github/workflows/ultramodern-gates.yml.handlebars +0 -30
- package/template/.gitignore.handlebars +0 -30
- package/template/.nvmrc +0 -2
- package/template/AGENTS.md +0 -25
- package/template/README.md +0 -79
- package/template/api/effect/index.ts.handlebars +0 -23
- package/template/api/lambda/hello.ts.handlebars +0 -6
- package/template/config/public/locales/cs/translation.json +0 -39
- package/template/config/public/locales/en/translation.json +0 -39
- package/template/modern.config.ts.handlebars +0 -53
- package/template/oxfmt.config.ts +0 -8
- package/template/oxlint.config.ts +0 -12
- package/template/package.json.handlebars +0 -67
- package/template/postcss.config.mjs.handlebars +0 -6
- package/template/scripts/bootstrap-agent-skills.mjs +0 -95
- package/template/scripts/check-i18n-strings.mjs +0 -83
- package/template/scripts/validate-ultramodern.mjs.handlebars +0 -178
- package/template/shared/effect/api.ts.handlebars +0 -17
- package/template/src/modern-app-env.d.ts +0 -1
- package/template/src/modern.runtime.ts.handlebars +0 -23
- package/template/src/routes/index.css.handlebars +0 -129
- package/template/src/routes/layout.tsx.handlebars +0 -9
- package/template/src/routes/page.tsx.handlebars +0 -155
- package/template/tailwind.config.ts.handlebars +0 -10
- package/template/tsconfig.json +0 -120
- package/template-workspace/AGENTS.md +0 -50
- package/template-workspace/pnpm-workspace.yaml +0 -17
- package/template-workspace/scripts/check-i18n-strings.mjs +0 -83
- package/template-workspace/scripts/validate-ultramodern-workspace.mjs.handlebars +0 -433
|
@@ -0,0 +1,952 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
createEffectClient: ()=>createEffectClient,
|
|
32
|
+
createEffectDomainOperations: ()=>createEffectDomainOperations,
|
|
33
|
+
createEffectOperationContract: ()=>createEffectOperationContract,
|
|
34
|
+
createEffectReadinessContract: ()=>createEffectReadinessContract,
|
|
35
|
+
createEffectRequestContextContract: ()=>createEffectRequestContextContract,
|
|
36
|
+
createEffectServiceEntry: ()=>createEffectServiceEntry,
|
|
37
|
+
createEffectSharedApi: ()=>createEffectSharedApi,
|
|
38
|
+
createEffectSharedApiContract: ()=>createEffectSharedApiContract,
|
|
39
|
+
createEffectSharedApiImports: ()=>createEffectSharedApiImports,
|
|
40
|
+
createShellEffectClient: ()=>createShellEffectClient,
|
|
41
|
+
effectApiTopologyMetadata: ()=>effectApiTopologyMetadata,
|
|
42
|
+
verticalEffectApiExport: ()=>verticalEffectApiExport,
|
|
43
|
+
verticalEffectApiName: ()=>verticalEffectApiName,
|
|
44
|
+
verticalEffectCreatePayloadSchemaExport: ()=>verticalEffectCreatePayloadSchemaExport,
|
|
45
|
+
verticalEffectErrorStem: ()=>verticalEffectErrorStem,
|
|
46
|
+
verticalEffectGroupName: ()=>verticalEffectGroupName,
|
|
47
|
+
verticalEffectMarkerSchemaExport: ()=>verticalEffectMarkerSchemaExport,
|
|
48
|
+
verticalEffectNotFoundErrorExport: ()=>verticalEffectNotFoundErrorExport,
|
|
49
|
+
verticalEffectNotFoundSchemaExport: ()=>verticalEffectNotFoundSchemaExport,
|
|
50
|
+
verticalEffectReadinessSchemaExport: ()=>verticalEffectReadinessSchemaExport,
|
|
51
|
+
verticalEffectSchemaExport: ()=>verticalEffectSchemaExport
|
|
52
|
+
});
|
|
53
|
+
const external_descriptors_cjs_namespaceObject = require("./descriptors.cjs");
|
|
54
|
+
const external_naming_cjs_namespaceObject = require("./naming.cjs");
|
|
55
|
+
function verticalEffectApiExport(service) {
|
|
56
|
+
return `${(0, external_naming_cjs_namespaceObject.toCamelCase)((0, external_descriptors_cjs_namespaceObject.effectApiStem)(service))}EffectApi`;
|
|
57
|
+
}
|
|
58
|
+
function verticalEffectGroupName(service) {
|
|
59
|
+
return (0, external_naming_cjs_namespaceObject.toCamelCase)((0, external_descriptors_cjs_namespaceObject.effectApiStem)(service));
|
|
60
|
+
}
|
|
61
|
+
function verticalEffectApiName(service) {
|
|
62
|
+
return `${(0, external_naming_cjs_namespaceObject.toPascalCase)((0, external_descriptors_cjs_namespaceObject.effectApiStem)(service))}EffectApi`;
|
|
63
|
+
}
|
|
64
|
+
function verticalEffectSchemaExport(service) {
|
|
65
|
+
return `${(0, external_naming_cjs_namespaceObject.toCamelCase)((0, external_descriptors_cjs_namespaceObject.effectApiStem)(service))}ItemSchema`;
|
|
66
|
+
}
|
|
67
|
+
function verticalEffectMarkerSchemaExport(service) {
|
|
68
|
+
return `${(0, external_naming_cjs_namespaceObject.toCamelCase)((0, external_descriptors_cjs_namespaceObject.effectApiStem)(service))}MarkerSchema`;
|
|
69
|
+
}
|
|
70
|
+
function verticalEffectReadinessSchemaExport(service) {
|
|
71
|
+
return `${(0, external_naming_cjs_namespaceObject.toCamelCase)((0, external_descriptors_cjs_namespaceObject.effectApiStem)(service))}ReadinessSchema`;
|
|
72
|
+
}
|
|
73
|
+
function verticalEffectErrorStem(service) {
|
|
74
|
+
return (0, external_descriptors_cjs_namespaceObject.effectApiStem)(service);
|
|
75
|
+
}
|
|
76
|
+
function verticalEffectCreatePayloadSchemaExport(service) {
|
|
77
|
+
return `${(0, external_naming_cjs_namespaceObject.toCamelCase)((0, external_descriptors_cjs_namespaceObject.effectApiStem)(service))}CreatePayloadSchema`;
|
|
78
|
+
}
|
|
79
|
+
function verticalEffectNotFoundErrorExport(service) {
|
|
80
|
+
return `${(0, external_naming_cjs_namespaceObject.toPascalCase)(verticalEffectErrorStem(service))}NotFound`;
|
|
81
|
+
}
|
|
82
|
+
function verticalEffectNotFoundSchemaExport(service) {
|
|
83
|
+
return `${(0, external_naming_cjs_namespaceObject.toCamelCase)(verticalEffectErrorStem(service))}NotFoundSchema`;
|
|
84
|
+
}
|
|
85
|
+
function serviceHasCheckoutCartState(service) {
|
|
86
|
+
return 'checkout' === (0, external_descriptors_cjs_namespaceObject.effectApiStem)(service);
|
|
87
|
+
}
|
|
88
|
+
function createCheckoutCartSharedSchemas(service) {
|
|
89
|
+
if (!serviceHasCheckoutCartState(service)) return '';
|
|
90
|
+
return `
|
|
91
|
+
export const checkoutCartLineSchema = Schema.Struct({
|
|
92
|
+
sku: Schema.String,
|
|
93
|
+
name: Schema.String,
|
|
94
|
+
quantity: Schema.Finite,
|
|
95
|
+
unitPriceCents: Schema.Finite,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
export const checkoutCartSchema = Schema.Struct({
|
|
99
|
+
lines: Schema.Array(checkoutCartLineSchema),
|
|
100
|
+
subtotalCents: Schema.Finite,
|
|
101
|
+
totalQuantity: Schema.Finite,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export const checkoutAddCartItemPayloadSchema = Schema.Struct({
|
|
105
|
+
sku: Schema.String,
|
|
106
|
+
name: Schema.optional(Schema.String),
|
|
107
|
+
quantity: Schema.Finite,
|
|
108
|
+
unitPriceCents: Schema.optional(Schema.Finite),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export const checkoutRemoveCartItemPayloadSchema = Schema.Struct({
|
|
112
|
+
sku: Schema.String,
|
|
113
|
+
});
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
function createCheckoutCartEndpointDefinitions(service) {
|
|
117
|
+
if (!serviceHasCheckoutCartState(service)) return '';
|
|
118
|
+
return `
|
|
119
|
+
.add(
|
|
120
|
+
HttpApiEndpoint.get('getCart', '/effect/checkout/cart', {
|
|
121
|
+
success: checkoutCartSchema,
|
|
122
|
+
}),
|
|
123
|
+
)
|
|
124
|
+
.add(
|
|
125
|
+
HttpApiEndpoint.post('addCartItem', '/effect/checkout/cart/items', {
|
|
126
|
+
payload: checkoutAddCartItemPayloadSchema,
|
|
127
|
+
success: checkoutCartSchema,
|
|
128
|
+
}),
|
|
129
|
+
)
|
|
130
|
+
.add(
|
|
131
|
+
HttpApiEndpoint.post('removeCartItem', '/effect/checkout/cart/remove', {
|
|
132
|
+
payload: checkoutRemoveCartItemPayloadSchema,
|
|
133
|
+
success: checkoutCartSchema,
|
|
134
|
+
}),
|
|
135
|
+
)
|
|
136
|
+
.add(
|
|
137
|
+
HttpApiEndpoint.post('clearCart', '/effect/checkout/cart/clear', {
|
|
138
|
+
success: checkoutCartSchema,
|
|
139
|
+
}),
|
|
140
|
+
)`;
|
|
141
|
+
}
|
|
142
|
+
function createCheckoutCartOperationContexts(service) {
|
|
143
|
+
const apiName = verticalEffectApiName(service);
|
|
144
|
+
const groupName = verticalEffectGroupName(service);
|
|
145
|
+
if (!serviceHasCheckoutCartState(service)) return '';
|
|
146
|
+
return `
|
|
147
|
+
addCartItem: {
|
|
148
|
+
method: 'POST',
|
|
149
|
+
operationId: '${apiName}:${groupName}:addCartItem',
|
|
150
|
+
routePath: '/effect/checkout/cart/items',
|
|
151
|
+
source: 'generated-client',
|
|
152
|
+
},
|
|
153
|
+
clearCart: {
|
|
154
|
+
method: 'POST',
|
|
155
|
+
operationId: '${apiName}:${groupName}:clearCart',
|
|
156
|
+
routePath: '/effect/checkout/cart/clear',
|
|
157
|
+
source: 'generated-client',
|
|
158
|
+
},
|
|
159
|
+
getCart: {
|
|
160
|
+
method: 'GET',
|
|
161
|
+
operationId: '${apiName}:${groupName}:getCart',
|
|
162
|
+
routePath: '/effect/checkout/cart',
|
|
163
|
+
source: 'generated-client',
|
|
164
|
+
},
|
|
165
|
+
removeCartItem: {
|
|
166
|
+
method: 'POST',
|
|
167
|
+
operationId: '${apiName}:${groupName}:removeCartItem',
|
|
168
|
+
routePath: '/effect/checkout/cart/remove',
|
|
169
|
+
source: 'generated-client',
|
|
170
|
+
},`;
|
|
171
|
+
}
|
|
172
|
+
function createCheckoutCartApiContractFields(service) {
|
|
173
|
+
if (!serviceHasCheckoutCartState(service)) return '';
|
|
174
|
+
return ` checkoutCartPath: '${(0, external_descriptors_cjs_namespaceObject.effectApiPrefix)(service)}/effect/checkout/cart',
|
|
175
|
+
`;
|
|
176
|
+
}
|
|
177
|
+
function createCheckoutCartServerState(service) {
|
|
178
|
+
if (!serviceHasCheckoutCartState(service)) return '';
|
|
179
|
+
return `
|
|
180
|
+
type CheckoutCartLine = {
|
|
181
|
+
sku: string;
|
|
182
|
+
name: string;
|
|
183
|
+
quantity: number;
|
|
184
|
+
unitPriceCents: number;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const checkoutCartLines = new Map<string, CheckoutCartLine>();
|
|
188
|
+
|
|
189
|
+
const createCheckoutCartSnapshot = () => {
|
|
190
|
+
const lines = [...checkoutCartLines.values()].sort((left, right) =>
|
|
191
|
+
left.sku.localeCompare(right.sku),
|
|
192
|
+
);
|
|
193
|
+
return {
|
|
194
|
+
lines,
|
|
195
|
+
subtotalCents: lines.reduce(
|
|
196
|
+
(total, line) => total + line.quantity * line.unitPriceCents,
|
|
197
|
+
0,
|
|
198
|
+
),
|
|
199
|
+
totalQuantity: lines.reduce((total, line) => total + line.quantity, 0),
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
204
|
+
function createCheckoutCartServerHandlers(service) {
|
|
205
|
+
const groupName = verticalEffectGroupName(service);
|
|
206
|
+
if (!serviceHasCheckoutCartState(service)) return '';
|
|
207
|
+
return `
|
|
208
|
+
.handle('getCart', () =>
|
|
209
|
+
Effect.sync(() => createCheckoutCartSnapshot()).pipe(
|
|
210
|
+
Effect.withSpan('ultramodern.effect.${groupName}.checkout.getCart', {
|
|
211
|
+
attributes: operationAttributes(${groupName}OperationContexts.getCart),
|
|
212
|
+
kind: 'server',
|
|
213
|
+
}),
|
|
214
|
+
),
|
|
215
|
+
)
|
|
216
|
+
.handle('addCartItem', ({ payload }) =>
|
|
217
|
+
Effect.sync(() => {
|
|
218
|
+
const existingLine = checkoutCartLines.get(payload.sku);
|
|
219
|
+
checkoutCartLines.set(payload.sku, {
|
|
220
|
+
sku: payload.sku,
|
|
221
|
+
name: payload.name ?? existingLine?.name ?? payload.sku,
|
|
222
|
+
quantity: (existingLine?.quantity ?? 0) + payload.quantity,
|
|
223
|
+
unitPriceCents:
|
|
224
|
+
payload.unitPriceCents ?? existingLine?.unitPriceCents ?? 0,
|
|
225
|
+
});
|
|
226
|
+
return createCheckoutCartSnapshot();
|
|
227
|
+
}).pipe(
|
|
228
|
+
Effect.withSpan('ultramodern.effect.${groupName}.checkout.addCartItem', {
|
|
229
|
+
attributes: operationAttributes(${groupName}OperationContexts.addCartItem),
|
|
230
|
+
kind: 'server',
|
|
231
|
+
}),
|
|
232
|
+
),
|
|
233
|
+
)
|
|
234
|
+
.handle('removeCartItem', ({ payload }) =>
|
|
235
|
+
Effect.sync(() => {
|
|
236
|
+
checkoutCartLines.delete(payload.sku);
|
|
237
|
+
return createCheckoutCartSnapshot();
|
|
238
|
+
}).pipe(
|
|
239
|
+
Effect.withSpan('ultramodern.effect.${groupName}.checkout.removeCartItem', {
|
|
240
|
+
attributes: operationAttributes(${groupName}OperationContexts.removeCartItem),
|
|
241
|
+
kind: 'server',
|
|
242
|
+
}),
|
|
243
|
+
),
|
|
244
|
+
)
|
|
245
|
+
.handle('clearCart', () =>
|
|
246
|
+
Effect.sync(() => {
|
|
247
|
+
checkoutCartLines.clear();
|
|
248
|
+
return createCheckoutCartSnapshot();
|
|
249
|
+
}).pipe(
|
|
250
|
+
Effect.withSpan('ultramodern.effect.${groupName}.checkout.clearCart', {
|
|
251
|
+
attributes: operationAttributes(${groupName}OperationContexts.clearCart),
|
|
252
|
+
kind: 'server',
|
|
253
|
+
}),
|
|
254
|
+
),
|
|
255
|
+
)`;
|
|
256
|
+
}
|
|
257
|
+
function createCheckoutCartClientExports(service) {
|
|
258
|
+
if (!serviceHasCheckoutCartState(service)) return '';
|
|
259
|
+
const stem = (0, external_descriptors_cjs_namespaceObject.effectApiStem)(service);
|
|
260
|
+
const groupName = verticalEffectGroupName(service);
|
|
261
|
+
const pascalStem = (0, external_naming_cjs_namespaceObject.toPascalCase)(stem);
|
|
262
|
+
const clientOptionsName = `${pascalStem}ClientOptions`;
|
|
263
|
+
const createClientName = `create${pascalStem}Client`;
|
|
264
|
+
return `
|
|
265
|
+
export interface CheckoutCartLine {
|
|
266
|
+
sku: string;
|
|
267
|
+
name: string;
|
|
268
|
+
quantity: number;
|
|
269
|
+
unitPriceCents: number;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface CheckoutCart {
|
|
273
|
+
lines: readonly CheckoutCartLine[];
|
|
274
|
+
subtotalCents: number;
|
|
275
|
+
totalQuantity: number;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export interface CheckoutAddCartItemInput {
|
|
279
|
+
sku: string;
|
|
280
|
+
name?: string;
|
|
281
|
+
quantity: number;
|
|
282
|
+
unitPriceCents?: number;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export const getCheckoutCart = (
|
|
286
|
+
options: ${clientOptionsName} = {},
|
|
287
|
+
) =>
|
|
288
|
+
${createClientName}({
|
|
289
|
+
...options,
|
|
290
|
+
operationContext:
|
|
291
|
+
options.operationContext ?? ${groupName}OperationContexts.getCart,
|
|
292
|
+
}).pipe(
|
|
293
|
+
Effect.flatMap(client => client.${groupName}.getCart({})),
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
export const addCheckoutCartItem = (
|
|
297
|
+
payload: CheckoutAddCartItemInput,
|
|
298
|
+
options: ${clientOptionsName} = {},
|
|
299
|
+
) =>
|
|
300
|
+
${createClientName}({
|
|
301
|
+
...options,
|
|
302
|
+
operationContext:
|
|
303
|
+
options.operationContext ?? ${groupName}OperationContexts.addCartItem,
|
|
304
|
+
}).pipe(
|
|
305
|
+
Effect.flatMap(client =>
|
|
306
|
+
client.${groupName}.addCartItem({ payload }),
|
|
307
|
+
),
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
export const removeCheckoutCartItem = (
|
|
311
|
+
sku: string,
|
|
312
|
+
options: ${clientOptionsName} = {},
|
|
313
|
+
) =>
|
|
314
|
+
${createClientName}({
|
|
315
|
+
...options,
|
|
316
|
+
operationContext:
|
|
317
|
+
options.operationContext ?? ${groupName}OperationContexts.removeCartItem,
|
|
318
|
+
}).pipe(
|
|
319
|
+
Effect.flatMap(client =>
|
|
320
|
+
client.${groupName}.removeCartItem({ payload: { sku } }),
|
|
321
|
+
),
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
export const clearCheckoutCart = (
|
|
325
|
+
options: ${clientOptionsName} = {},
|
|
326
|
+
) =>
|
|
327
|
+
${createClientName}({
|
|
328
|
+
...options,
|
|
329
|
+
operationContext:
|
|
330
|
+
options.operationContext ?? ${groupName}OperationContexts.clearCart,
|
|
331
|
+
}).pipe(
|
|
332
|
+
Effect.flatMap(client => client.${groupName}.clearCart({})),
|
|
333
|
+
);
|
|
334
|
+
`;
|
|
335
|
+
}
|
|
336
|
+
function createEffectSharedApiImports() {
|
|
337
|
+
return `import {
|
|
338
|
+
HttpApi,
|
|
339
|
+
HttpApiEndpoint,
|
|
340
|
+
HttpApiGroup,
|
|
341
|
+
HttpApiSchema,
|
|
342
|
+
Schema,
|
|
343
|
+
} from '@modern-js/plugin-bff/effect-client';
|
|
344
|
+
`;
|
|
345
|
+
}
|
|
346
|
+
function createEffectSharedApiContract(service) {
|
|
347
|
+
const schemaExport = verticalEffectSchemaExport(service);
|
|
348
|
+
const markerSchemaExport = verticalEffectMarkerSchemaExport(service);
|
|
349
|
+
const readinessSchemaExport = verticalEffectReadinessSchemaExport(service);
|
|
350
|
+
const createPayloadSchemaExport = verticalEffectCreatePayloadSchemaExport(service);
|
|
351
|
+
const notFoundErrorExport = verticalEffectNotFoundErrorExport(service);
|
|
352
|
+
const notFoundSchemaExport = verticalEffectNotFoundSchemaExport(service);
|
|
353
|
+
const apiExport = verticalEffectApiExport(service);
|
|
354
|
+
const apiName = verticalEffectApiName(service);
|
|
355
|
+
const groupName = verticalEffectGroupName(service);
|
|
356
|
+
const stem = (0, external_descriptors_cjs_namespaceObject.effectApiStem)(service);
|
|
357
|
+
const apiPrefix = (0, external_descriptors_cjs_namespaceObject.effectApiPrefix)(service);
|
|
358
|
+
const checkoutCartSharedSchemas = createCheckoutCartSharedSchemas(service);
|
|
359
|
+
const checkoutCartSharedSchemaSection = '' === checkoutCartSharedSchemas ? '' : `${checkoutCartSharedSchemas}\n`;
|
|
360
|
+
const checkoutCartOperationContexts = createCheckoutCartOperationContexts(service).trimStart();
|
|
361
|
+
const checkoutCartOperationContextEntries = '' === checkoutCartOperationContexts ? '' : `${checkoutCartOperationContexts}\n`;
|
|
362
|
+
return `export const ${markerSchemaExport} = Schema.Struct({
|
|
363
|
+
appId: Schema.String,
|
|
364
|
+
build: Schema.String,
|
|
365
|
+
deployProfile: Schema.String,
|
|
366
|
+
packageName: Schema.String,
|
|
367
|
+
surface: Schema.String,
|
|
368
|
+
version: Schema.String,
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
export const ${schemaExport} = Schema.Struct({
|
|
372
|
+
id: Schema.String,
|
|
373
|
+
marker: ${markerSchemaExport},
|
|
374
|
+
title: Schema.String,
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
export const ${readinessSchemaExport} = Schema.Struct({
|
|
378
|
+
checks: Schema.Struct({
|
|
379
|
+
effectBff: Schema.Literal('ready'),
|
|
380
|
+
moduleFederation: Schema.Literal('ready'),
|
|
381
|
+
ssr: Schema.Literal('ready'),
|
|
382
|
+
translations: Schema.Literal('ready'),
|
|
383
|
+
}),
|
|
384
|
+
marker: ${markerSchemaExport},
|
|
385
|
+
status: Schema.Literal('ready'),
|
|
386
|
+
versionSkew: Schema.Literal('none'),
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
export const ${createPayloadSchemaExport} = Schema.Struct({
|
|
390
|
+
title: Schema.String,
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
${checkoutCartSharedSchemaSection}export class ${notFoundErrorExport} extends Schema.TaggedErrorClass<${notFoundErrorExport}>()(
|
|
394
|
+
'${notFoundErrorExport}',
|
|
395
|
+
{
|
|
396
|
+
id: Schema.String,
|
|
397
|
+
},
|
|
398
|
+
) {}
|
|
399
|
+
|
|
400
|
+
export const ${notFoundSchemaExport} = ${notFoundErrorExport}.pipe(
|
|
401
|
+
HttpApiSchema.status(404),
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
export interface OperationContext {
|
|
405
|
+
method: string;
|
|
406
|
+
operationId: string;
|
|
407
|
+
routePath: string;
|
|
408
|
+
source:
|
|
409
|
+
| 'client'
|
|
410
|
+
| 'server'
|
|
411
|
+
| 'generated-client'
|
|
412
|
+
| 'effect-adapter'
|
|
413
|
+
| 'data-platform'
|
|
414
|
+
| 'unknown';
|
|
415
|
+
traceId?: string;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export const ${apiExport} = HttpApi.make('${apiName}').add(
|
|
419
|
+
HttpApiGroup.make('${groupName}')
|
|
420
|
+
.add(
|
|
421
|
+
HttpApiEndpoint.get('list', '/effect/${stem}', {
|
|
422
|
+
query: {
|
|
423
|
+
limit: Schema.optional(Schema.FiniteFromString),
|
|
424
|
+
},
|
|
425
|
+
success: Schema.Struct({
|
|
426
|
+
items: Schema.Array(${schemaExport}),
|
|
427
|
+
}),
|
|
428
|
+
}),
|
|
429
|
+
)
|
|
430
|
+
.add(
|
|
431
|
+
HttpApiEndpoint.get('readiness', '/effect/${stem}/readiness', {
|
|
432
|
+
success: ${readinessSchemaExport},
|
|
433
|
+
}),
|
|
434
|
+
)
|
|
435
|
+
.add(
|
|
436
|
+
HttpApiEndpoint.get('get', '/effect/${stem}/:id', {
|
|
437
|
+
error: ${notFoundSchemaExport},
|
|
438
|
+
params: {
|
|
439
|
+
id: Schema.String,
|
|
440
|
+
},
|
|
441
|
+
success: ${schemaExport},
|
|
442
|
+
}),
|
|
443
|
+
)
|
|
444
|
+
.add(
|
|
445
|
+
HttpApiEndpoint.post('create', '/effect/${stem}', {
|
|
446
|
+
payload: ${createPayloadSchemaExport},
|
|
447
|
+
success: Schema.Struct({
|
|
448
|
+
item: ${schemaExport},
|
|
449
|
+
}),
|
|
450
|
+
}),
|
|
451
|
+
)${createCheckoutCartEndpointDefinitions(service)},
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
export const ${groupName}OperationContexts = {
|
|
455
|
+
${checkoutCartOperationContextEntries} create: {
|
|
456
|
+
method: 'POST',
|
|
457
|
+
operationId: '${apiName}:${groupName}:create',
|
|
458
|
+
routePath: '/effect/${stem}',
|
|
459
|
+
source: 'generated-client',
|
|
460
|
+
},
|
|
461
|
+
get: {
|
|
462
|
+
method: 'GET',
|
|
463
|
+
operationId: '${apiName}:${groupName}:get',
|
|
464
|
+
routePath: '/effect/${stem}/:id',
|
|
465
|
+
source: 'generated-client',
|
|
466
|
+
},
|
|
467
|
+
list: {
|
|
468
|
+
method: 'GET',
|
|
469
|
+
operationId: '${apiName}:${groupName}:list',
|
|
470
|
+
routePath: '/effect/${stem}',
|
|
471
|
+
source: 'generated-client',
|
|
472
|
+
},
|
|
473
|
+
readiness: {
|
|
474
|
+
method: 'GET',
|
|
475
|
+
operationId: '${apiName}:${groupName}:readiness',
|
|
476
|
+
routePath: '/effect/${stem}/readiness',
|
|
477
|
+
source: 'generated-client',
|
|
478
|
+
},
|
|
479
|
+
} satisfies Record<string, OperationContext>;
|
|
480
|
+
|
|
481
|
+
export const ${groupName}ApiContract = {
|
|
482
|
+
apiPrefix: '${apiPrefix}',
|
|
483
|
+
basePath: '${apiPrefix}/effect/${stem}',
|
|
484
|
+
${createCheckoutCartApiContractFields(service)} ownerId: '${service.id}',
|
|
485
|
+
readinessPath: '${apiPrefix}/effect/${stem}/readiness',
|
|
486
|
+
} as const;
|
|
487
|
+
`;
|
|
488
|
+
}
|
|
489
|
+
function createEffectSharedApi(service) {
|
|
490
|
+
return `${createEffectSharedApiImports()}
|
|
491
|
+
${createEffectSharedApiContract(service)}`;
|
|
492
|
+
}
|
|
493
|
+
function createEffectServiceEntry(service, contractImportPath) {
|
|
494
|
+
const apiExport = verticalEffectApiExport(service);
|
|
495
|
+
const groupName = verticalEffectGroupName(service);
|
|
496
|
+
const notFoundErrorExport = verticalEffectNotFoundErrorExport(service);
|
|
497
|
+
const stem = (0, external_descriptors_cjs_namespaceObject.effectApiStem)(service);
|
|
498
|
+
return `import {
|
|
499
|
+
defineEffectBff,
|
|
500
|
+
Effect,
|
|
501
|
+
HttpApiBuilder,
|
|
502
|
+
Layer,
|
|
503
|
+
} from '@modern-js/plugin-bff/effect-edge';
|
|
504
|
+
import { ultramodernApiMarker } from '../../src/ultramodern-build.ts';
|
|
505
|
+
import {
|
|
506
|
+
${apiExport},
|
|
507
|
+
${groupName}OperationContexts,
|
|
508
|
+
${notFoundErrorExport},
|
|
509
|
+
} from '${contractImportPath}';
|
|
510
|
+
import type { OperationContext } from '${contractImportPath}';
|
|
511
|
+
|
|
512
|
+
const ${groupName}Items = [
|
|
513
|
+
{
|
|
514
|
+
id: 'starter-${stem}',
|
|
515
|
+
marker: ultramodernApiMarker,
|
|
516
|
+
title: 'Wire a real ${stem} source here',
|
|
517
|
+
},
|
|
518
|
+
];
|
|
519
|
+
${createCheckoutCartServerState(service)}
|
|
520
|
+
|
|
521
|
+
const operationAttributes = (operationContext: OperationContext) => ({
|
|
522
|
+
'modernjs.operation.id': operationContext.operationId,
|
|
523
|
+
'modernjs.operation.method': operationContext.method,
|
|
524
|
+
'modernjs.operation.route': operationContext.routePath,
|
|
525
|
+
'modernjs.operation.source': operationContext.source,
|
|
526
|
+
...(typeof operationContext.traceId === 'string'
|
|
527
|
+
? { 'modernjs.trace.id': operationContext.traceId }
|
|
528
|
+
: {}),
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
const ${groupName}Layer = HttpApiBuilder.group(
|
|
532
|
+
${apiExport},
|
|
533
|
+
'${groupName}',
|
|
534
|
+
(handlers) =>
|
|
535
|
+
handlers
|
|
536
|
+
.handle('list', ({ query }) =>
|
|
537
|
+
Effect.succeed({
|
|
538
|
+
items:
|
|
539
|
+
typeof query.limit === 'number'
|
|
540
|
+
? ${groupName}Items.slice(0, query.limit)
|
|
541
|
+
: ${groupName}Items,
|
|
542
|
+
}).pipe(
|
|
543
|
+
Effect.withSpan('ultramodern.effect.${groupName}.list', {
|
|
544
|
+
attributes: operationAttributes(${groupName}OperationContexts.list),
|
|
545
|
+
kind: 'server',
|
|
546
|
+
}),
|
|
547
|
+
),
|
|
548
|
+
)
|
|
549
|
+
.handle('readiness', () =>
|
|
550
|
+
Effect.succeed({
|
|
551
|
+
checks: {
|
|
552
|
+
effectBff: 'ready' as const,
|
|
553
|
+
moduleFederation: 'ready' as const,
|
|
554
|
+
ssr: 'ready' as const,
|
|
555
|
+
translations: 'ready' as const,
|
|
556
|
+
},
|
|
557
|
+
marker: ultramodernApiMarker,
|
|
558
|
+
status: 'ready' as const,
|
|
559
|
+
versionSkew: 'none' as const,
|
|
560
|
+
}).pipe(
|
|
561
|
+
Effect.withSpan('ultramodern.effect.${groupName}.readiness', {
|
|
562
|
+
attributes: operationAttributes(${groupName}OperationContexts.readiness),
|
|
563
|
+
kind: 'server',
|
|
564
|
+
}),
|
|
565
|
+
),
|
|
566
|
+
)
|
|
567
|
+
.handle('get', ({ params }) => {
|
|
568
|
+
const matchedItem = ${groupName}Items.find(
|
|
569
|
+
candidate => candidate.id === params.id,
|
|
570
|
+
);
|
|
571
|
+
const result =
|
|
572
|
+
matchedItem === undefined
|
|
573
|
+
? Effect.fail(new ${notFoundErrorExport}({ id: params.id }))
|
|
574
|
+
: Effect.succeed(matchedItem);
|
|
575
|
+
|
|
576
|
+
return result.pipe(
|
|
577
|
+
Effect.withSpan('ultramodern.effect.${groupName}.get', {
|
|
578
|
+
attributes: operationAttributes(${groupName}OperationContexts.get),
|
|
579
|
+
kind: 'server',
|
|
580
|
+
}),
|
|
581
|
+
);
|
|
582
|
+
})
|
|
583
|
+
.handle('create', ({ payload }) =>
|
|
584
|
+
Effect.succeed({
|
|
585
|
+
item: {
|
|
586
|
+
id: \`generated-${stem}-\${payload.title
|
|
587
|
+
.toLowerCase()
|
|
588
|
+
.replaceAll(/[^a-z0-9]+/gu, '-')
|
|
589
|
+
.replaceAll(/^-|-$/gu, '')}\`,
|
|
590
|
+
marker: ultramodernApiMarker,
|
|
591
|
+
title: payload.title,
|
|
592
|
+
},
|
|
593
|
+
}).pipe(
|
|
594
|
+
Effect.withSpan('ultramodern.effect.${groupName}.create', {
|
|
595
|
+
attributes: operationAttributes(${groupName}OperationContexts.create),
|
|
596
|
+
kind: 'server',
|
|
597
|
+
}),
|
|
598
|
+
),
|
|
599
|
+
)${createCheckoutCartServerHandlers(service)},
|
|
600
|
+
);
|
|
601
|
+
|
|
602
|
+
const layer = HttpApiBuilder.layer(${apiExport}).pipe(
|
|
603
|
+
Layer.provide(${groupName}Layer),
|
|
604
|
+
);
|
|
605
|
+
|
|
606
|
+
export default defineEffectBff({
|
|
607
|
+
api: ${apiExport},
|
|
608
|
+
layer,
|
|
609
|
+
});
|
|
610
|
+
`;
|
|
611
|
+
}
|
|
612
|
+
function createEffectClient(service, contractImportPath) {
|
|
613
|
+
const apiExport = verticalEffectApiExport(service);
|
|
614
|
+
const contractExport = verticalEffectGroupName(service);
|
|
615
|
+
const stem = (0, external_descriptors_cjs_namespaceObject.effectApiStem)(service);
|
|
616
|
+
const groupName = verticalEffectGroupName(service);
|
|
617
|
+
const singular = verticalEffectErrorStem(service);
|
|
618
|
+
const clientOptionsName = `${(0, external_naming_cjs_namespaceObject.toPascalCase)(stem)}ClientOptions`;
|
|
619
|
+
const createClientName = `create${(0, external_naming_cjs_namespaceObject.toPascalCase)(stem)}Client`;
|
|
620
|
+
const listName = `list${(0, external_naming_cjs_namespaceObject.toPascalCase)(stem)}`;
|
|
621
|
+
const readinessName = `get${(0, external_naming_cjs_namespaceObject.toPascalCase)(stem)}Readiness`;
|
|
622
|
+
const getName = `get${(0, external_naming_cjs_namespaceObject.toPascalCase)(singular)}`;
|
|
623
|
+
const createName = `create${(0, external_naming_cjs_namespaceObject.toPascalCase)(singular)}`;
|
|
624
|
+
const checkoutCartClientExports = createCheckoutCartClientExports(service);
|
|
625
|
+
return `import {
|
|
626
|
+
Effect,
|
|
627
|
+
makeEffectHttpApiClient,
|
|
628
|
+
runEffectRequest,
|
|
629
|
+
} from '@modern-js/plugin-bff/effect-client';
|
|
630
|
+
import {
|
|
631
|
+
${contractExport}ApiContract,
|
|
632
|
+
${apiExport},
|
|
633
|
+
${groupName}OperationContexts,
|
|
634
|
+
} from '${contractImportPath}';
|
|
635
|
+
import type { OperationContext } from '${contractImportPath}';
|
|
636
|
+
|
|
637
|
+
export { Effect, runEffectRequest };
|
|
638
|
+
|
|
639
|
+
export interface ${clientOptionsName} {
|
|
640
|
+
baseUrl?: string | URL;
|
|
641
|
+
locale?: string;
|
|
642
|
+
operationContext?: OperationContext;
|
|
643
|
+
traceparent?: string;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
export const ${createClientName} = (
|
|
647
|
+
options: ${clientOptionsName} = {},
|
|
648
|
+
) =>
|
|
649
|
+
makeEffectHttpApiClient(${apiExport}, {
|
|
650
|
+
baseUrl: options.baseUrl ?? ${contractExport}ApiContract.apiPrefix,
|
|
651
|
+
requestContext: {
|
|
652
|
+
...(options.locale === undefined ? {} : { locale: options.locale }),
|
|
653
|
+
...(options.operationContext === undefined
|
|
654
|
+
? {}
|
|
655
|
+
: { operationContext: options.operationContext }),
|
|
656
|
+
...(options.traceparent === undefined
|
|
657
|
+
? {}
|
|
658
|
+
: { traceparent: options.traceparent }),
|
|
659
|
+
},
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
export const ${listName} = (
|
|
663
|
+
options: ${clientOptionsName} & { limit?: number } = {},
|
|
664
|
+
) =>
|
|
665
|
+
${createClientName}({
|
|
666
|
+
...options,
|
|
667
|
+
operationContext:
|
|
668
|
+
options.operationContext ?? ${groupName}OperationContexts.list,
|
|
669
|
+
}).pipe(
|
|
670
|
+
Effect.flatMap(client =>
|
|
671
|
+
client.${groupName}.list({ query: { limit: options.limit } }),
|
|
672
|
+
),
|
|
673
|
+
);
|
|
674
|
+
|
|
675
|
+
export const ${readinessName} = (
|
|
676
|
+
options: ${clientOptionsName} = {},
|
|
677
|
+
) =>
|
|
678
|
+
${createClientName}({
|
|
679
|
+
...options,
|
|
680
|
+
operationContext:
|
|
681
|
+
options.operationContext ?? ${groupName}OperationContexts.readiness,
|
|
682
|
+
}).pipe(
|
|
683
|
+
Effect.flatMap(client => client.${groupName}.readiness({})),
|
|
684
|
+
);
|
|
685
|
+
|
|
686
|
+
export const ${getName} = (
|
|
687
|
+
id: string,
|
|
688
|
+
options: ${clientOptionsName} = {},
|
|
689
|
+
) =>
|
|
690
|
+
${createClientName}({
|
|
691
|
+
...options,
|
|
692
|
+
operationContext:
|
|
693
|
+
options.operationContext ?? ${groupName}OperationContexts.get,
|
|
694
|
+
}).pipe(
|
|
695
|
+
Effect.flatMap(client => client.${groupName}.get({ params: { id } })),
|
|
696
|
+
);
|
|
697
|
+
|
|
698
|
+
export const ${createName} = (
|
|
699
|
+
title: string,
|
|
700
|
+
options: ${clientOptionsName} = {},
|
|
701
|
+
) =>
|
|
702
|
+
${createClientName}({
|
|
703
|
+
...options,
|
|
704
|
+
operationContext:
|
|
705
|
+
options.operationContext ?? ${groupName}OperationContexts.create,
|
|
706
|
+
}).pipe(
|
|
707
|
+
Effect.flatMap(client =>
|
|
708
|
+
client.${groupName}.create({ payload: { title } }),
|
|
709
|
+
),
|
|
710
|
+
);${checkoutCartClientExports}
|
|
711
|
+
`;
|
|
712
|
+
}
|
|
713
|
+
function createShellEffectClient(scope, remotes = []) {
|
|
714
|
+
const exports1 = (0, external_descriptors_cjs_namespaceObject.verticalEffectApps)(remotes).map((remote)=>{
|
|
715
|
+
const stem = (0, external_descriptors_cjs_namespaceObject.effectApiStem)(remote);
|
|
716
|
+
const pascalStem = (0, external_naming_cjs_namespaceObject.toPascalCase)(stem);
|
|
717
|
+
const pascalSingular = (0, external_naming_cjs_namespaceObject.toPascalCase)(verticalEffectErrorStem(remote));
|
|
718
|
+
const checkoutCartExports = serviceHasCheckoutCartState(remote) ? ` addCheckoutCartItem,
|
|
719
|
+
clearCheckoutCart,
|
|
720
|
+
getCheckoutCart,
|
|
721
|
+
removeCheckoutCartItem,
|
|
722
|
+
type CheckoutAddCartItemInput,
|
|
723
|
+
type CheckoutCart,
|
|
724
|
+
type CheckoutCartLine,
|
|
725
|
+
` : '';
|
|
726
|
+
return `export {
|
|
727
|
+
${checkoutCartExports} create${pascalSingular},
|
|
728
|
+
create${pascalStem}Client,
|
|
729
|
+
get${pascalSingular},
|
|
730
|
+
get${pascalStem}Readiness,
|
|
731
|
+
list${pascalStem},
|
|
732
|
+
type ${pascalStem}ClientOptions,
|
|
733
|
+
} from '${(0, external_naming_cjs_namespaceObject.packageName)(scope, remote.packageSuffix)}/effect/client';`;
|
|
734
|
+
}).join('\n\n');
|
|
735
|
+
return exports1 ? `${exports1}\n` : `export const ultramodernVerticalClients = [] as const;
|
|
736
|
+
`;
|
|
737
|
+
}
|
|
738
|
+
function createEffectReadinessContract(app) {
|
|
739
|
+
const stem = (0, external_descriptors_cjs_namespaceObject.effectApiStem)(app);
|
|
740
|
+
return {
|
|
741
|
+
endpoint: `/effect/${stem}/readiness`,
|
|
742
|
+
marker: {
|
|
743
|
+
ui: 'ultramodernUiMarker',
|
|
744
|
+
api: 'ultramodernApiMarker',
|
|
745
|
+
skew: 'none'
|
|
746
|
+
},
|
|
747
|
+
checks: [
|
|
748
|
+
'moduleFederation',
|
|
749
|
+
'ssr',
|
|
750
|
+
'translations',
|
|
751
|
+
'effectBff'
|
|
752
|
+
]
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
function createEffectRequestContextContract() {
|
|
756
|
+
return {
|
|
757
|
+
propagatedHeaders: [
|
|
758
|
+
'accept-language',
|
|
759
|
+
'authorization',
|
|
760
|
+
'traceparent',
|
|
761
|
+
'x-correlation-id',
|
|
762
|
+
'x-tenant-id',
|
|
763
|
+
'x-ultramodern-env',
|
|
764
|
+
'x-vertical-version-id'
|
|
765
|
+
],
|
|
766
|
+
source: 'shell-to-vertical-effect-client'
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
function createEffectDomainOperations(app) {
|
|
770
|
+
const stem = (0, external_descriptors_cjs_namespaceObject.effectApiStem)(app);
|
|
771
|
+
const group = verticalEffectGroupName(app);
|
|
772
|
+
const basePath = `/effect/${stem}`;
|
|
773
|
+
const checkoutCartOperations = serviceHasCheckoutCartState(app) ? {
|
|
774
|
+
checkoutCartAddItem: {
|
|
775
|
+
client: 'addCheckoutCartItem',
|
|
776
|
+
method: 'POST',
|
|
777
|
+
path: '/effect/checkout/cart/items',
|
|
778
|
+
resource: 'checkout-cart',
|
|
779
|
+
owner: app.id
|
|
780
|
+
},
|
|
781
|
+
checkoutCartClear: {
|
|
782
|
+
client: 'clearCheckoutCart',
|
|
783
|
+
method: 'POST',
|
|
784
|
+
path: '/effect/checkout/cart/clear',
|
|
785
|
+
resource: 'checkout-cart',
|
|
786
|
+
owner: app.id
|
|
787
|
+
},
|
|
788
|
+
checkoutCartRead: {
|
|
789
|
+
client: 'getCheckoutCart',
|
|
790
|
+
method: 'GET',
|
|
791
|
+
path: '/effect/checkout/cart',
|
|
792
|
+
resource: 'checkout-cart',
|
|
793
|
+
owner: app.id
|
|
794
|
+
},
|
|
795
|
+
checkoutCartRemoveItem: {
|
|
796
|
+
client: 'removeCheckoutCartItem',
|
|
797
|
+
method: 'POST',
|
|
798
|
+
path: '/effect/checkout/cart/remove',
|
|
799
|
+
resource: 'checkout-cart',
|
|
800
|
+
owner: app.id
|
|
801
|
+
}
|
|
802
|
+
} : {};
|
|
803
|
+
return {
|
|
804
|
+
...checkoutCartOperations,
|
|
805
|
+
workspaceFeed: {
|
|
806
|
+
client: `list${(0, external_naming_cjs_namespaceObject.toPascalCase)(stem)}`,
|
|
807
|
+
method: 'GET',
|
|
808
|
+
path: basePath,
|
|
809
|
+
resource: 'workspace-items',
|
|
810
|
+
owner: app.id
|
|
811
|
+
},
|
|
812
|
+
workspaceDetail: {
|
|
813
|
+
client: `get${(0, external_naming_cjs_namespaceObject.toPascalCase)(verticalEffectErrorStem(app))}`,
|
|
814
|
+
method: 'GET',
|
|
815
|
+
path: `${basePath}/:id`,
|
|
816
|
+
resource: 'workspace-item',
|
|
817
|
+
owner: app.id
|
|
818
|
+
},
|
|
819
|
+
workspaceCreate: {
|
|
820
|
+
client: `create${(0, external_naming_cjs_namespaceObject.toPascalCase)(verticalEffectErrorStem(app))}`,
|
|
821
|
+
method: 'POST',
|
|
822
|
+
path: basePath,
|
|
823
|
+
resource: group,
|
|
824
|
+
owner: app.id
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function effectApiTopologyMetadata(app) {
|
|
829
|
+
if (!(0, external_descriptors_cjs_namespaceObject.appHasEffectApi)(app)) return;
|
|
830
|
+
return {
|
|
831
|
+
effect: {
|
|
832
|
+
runtime: 'effect',
|
|
833
|
+
bff: {
|
|
834
|
+
prefix: app.effectApi.prefix,
|
|
835
|
+
openapi: '/openapi.json'
|
|
836
|
+
},
|
|
837
|
+
contract: {
|
|
838
|
+
export: './shared/effect/api',
|
|
839
|
+
path: `${app.directory}/shared/effect/api.ts`
|
|
840
|
+
},
|
|
841
|
+
client: {
|
|
842
|
+
export: './effect/client',
|
|
843
|
+
path: `${app.directory}/src/effect/${app.effectApi.stem}-client.ts`
|
|
844
|
+
},
|
|
845
|
+
serverEntry: `${app.directory}/api/effect/index.ts`,
|
|
846
|
+
basePath: `${app.effectApi.prefix}/effect/${app.effectApi.stem}`,
|
|
847
|
+
consumedBy: app.effectApi.consumedBy,
|
|
848
|
+
readiness: createEffectReadinessContract(app),
|
|
849
|
+
requestContext: createEffectRequestContextContract(),
|
|
850
|
+
domainOperations: createEffectDomainOperations(app)
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
function createEffectOperationContract(target) {
|
|
855
|
+
const stem = (0, external_descriptors_cjs_namespaceObject.effectApiStem)(target);
|
|
856
|
+
const checkoutCartOperations = serviceHasCheckoutCartState(target) ? {
|
|
857
|
+
addCartItem: {
|
|
858
|
+
method: 'POST',
|
|
859
|
+
path: '/effect/checkout/cart/items',
|
|
860
|
+
source: 'generated-client'
|
|
861
|
+
},
|
|
862
|
+
clearCart: {
|
|
863
|
+
method: 'POST',
|
|
864
|
+
path: '/effect/checkout/cart/clear',
|
|
865
|
+
source: 'generated-client'
|
|
866
|
+
},
|
|
867
|
+
getCart: {
|
|
868
|
+
method: 'GET',
|
|
869
|
+
path: '/effect/checkout/cart',
|
|
870
|
+
source: 'generated-client'
|
|
871
|
+
},
|
|
872
|
+
removeCartItem: {
|
|
873
|
+
method: 'POST',
|
|
874
|
+
path: '/effect/checkout/cart/remove',
|
|
875
|
+
source: 'generated-client'
|
|
876
|
+
}
|
|
877
|
+
} : {};
|
|
878
|
+
return {
|
|
879
|
+
group: verticalEffectGroupName(target),
|
|
880
|
+
notFound: verticalEffectNotFoundErrorExport(target),
|
|
881
|
+
operations: {
|
|
882
|
+
...checkoutCartOperations,
|
|
883
|
+
list: {
|
|
884
|
+
method: 'GET',
|
|
885
|
+
path: `/effect/${stem}`,
|
|
886
|
+
source: 'generated-client'
|
|
887
|
+
},
|
|
888
|
+
readiness: {
|
|
889
|
+
method: 'GET',
|
|
890
|
+
path: `/effect/${stem}/readiness`,
|
|
891
|
+
source: 'generated-client'
|
|
892
|
+
},
|
|
893
|
+
get: {
|
|
894
|
+
method: 'GET',
|
|
895
|
+
path: `/effect/${stem}/:id`,
|
|
896
|
+
source: 'generated-client'
|
|
897
|
+
},
|
|
898
|
+
create: {
|
|
899
|
+
method: 'POST',
|
|
900
|
+
path: `/effect/${stem}`,
|
|
901
|
+
source: 'generated-client'
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
exports.createEffectClient = __webpack_exports__.createEffectClient;
|
|
907
|
+
exports.createEffectDomainOperations = __webpack_exports__.createEffectDomainOperations;
|
|
908
|
+
exports.createEffectOperationContract = __webpack_exports__.createEffectOperationContract;
|
|
909
|
+
exports.createEffectReadinessContract = __webpack_exports__.createEffectReadinessContract;
|
|
910
|
+
exports.createEffectRequestContextContract = __webpack_exports__.createEffectRequestContextContract;
|
|
911
|
+
exports.createEffectServiceEntry = __webpack_exports__.createEffectServiceEntry;
|
|
912
|
+
exports.createEffectSharedApi = __webpack_exports__.createEffectSharedApi;
|
|
913
|
+
exports.createEffectSharedApiContract = __webpack_exports__.createEffectSharedApiContract;
|
|
914
|
+
exports.createEffectSharedApiImports = __webpack_exports__.createEffectSharedApiImports;
|
|
915
|
+
exports.createShellEffectClient = __webpack_exports__.createShellEffectClient;
|
|
916
|
+
exports.effectApiTopologyMetadata = __webpack_exports__.effectApiTopologyMetadata;
|
|
917
|
+
exports.verticalEffectApiExport = __webpack_exports__.verticalEffectApiExport;
|
|
918
|
+
exports.verticalEffectApiName = __webpack_exports__.verticalEffectApiName;
|
|
919
|
+
exports.verticalEffectCreatePayloadSchemaExport = __webpack_exports__.verticalEffectCreatePayloadSchemaExport;
|
|
920
|
+
exports.verticalEffectErrorStem = __webpack_exports__.verticalEffectErrorStem;
|
|
921
|
+
exports.verticalEffectGroupName = __webpack_exports__.verticalEffectGroupName;
|
|
922
|
+
exports.verticalEffectMarkerSchemaExport = __webpack_exports__.verticalEffectMarkerSchemaExport;
|
|
923
|
+
exports.verticalEffectNotFoundErrorExport = __webpack_exports__.verticalEffectNotFoundErrorExport;
|
|
924
|
+
exports.verticalEffectNotFoundSchemaExport = __webpack_exports__.verticalEffectNotFoundSchemaExport;
|
|
925
|
+
exports.verticalEffectReadinessSchemaExport = __webpack_exports__.verticalEffectReadinessSchemaExport;
|
|
926
|
+
exports.verticalEffectSchemaExport = __webpack_exports__.verticalEffectSchemaExport;
|
|
927
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
928
|
+
"createEffectClient",
|
|
929
|
+
"createEffectDomainOperations",
|
|
930
|
+
"createEffectOperationContract",
|
|
931
|
+
"createEffectReadinessContract",
|
|
932
|
+
"createEffectRequestContextContract",
|
|
933
|
+
"createEffectServiceEntry",
|
|
934
|
+
"createEffectSharedApi",
|
|
935
|
+
"createEffectSharedApiContract",
|
|
936
|
+
"createEffectSharedApiImports",
|
|
937
|
+
"createShellEffectClient",
|
|
938
|
+
"effectApiTopologyMetadata",
|
|
939
|
+
"verticalEffectApiExport",
|
|
940
|
+
"verticalEffectApiName",
|
|
941
|
+
"verticalEffectCreatePayloadSchemaExport",
|
|
942
|
+
"verticalEffectErrorStem",
|
|
943
|
+
"verticalEffectGroupName",
|
|
944
|
+
"verticalEffectMarkerSchemaExport",
|
|
945
|
+
"verticalEffectNotFoundErrorExport",
|
|
946
|
+
"verticalEffectNotFoundSchemaExport",
|
|
947
|
+
"verticalEffectReadinessSchemaExport",
|
|
948
|
+
"verticalEffectSchemaExport"
|
|
949
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
950
|
+
Object.defineProperty(exports, '__esModule', {
|
|
951
|
+
value: true
|
|
952
|
+
});
|