@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.3 → 3.5.0-ultramodern.30

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.
Files changed (32) hide show
  1. package/dist/cjs/builder/generator/getBuilderEnvironments.js +1 -0
  2. package/dist/cjs/index.js +50 -44
  3. package/dist/cjs/plugins/backendFederationBuild.js +347 -0
  4. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-contract.js +91 -0
  5. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-plan.js +93 -0
  6. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier.js +402 -0
  7. package/dist/cjs/plugins/deploy/platforms/cloudflare.js +272 -29
  8. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +346 -43
  9. package/dist/esm/builder/generator/getBuilderEnvironments.mjs +1 -0
  10. package/dist/esm/index.mjs +2 -0
  11. package/dist/esm/plugins/backendFederationBuild.mjs +296 -0
  12. package/dist/esm/plugins/deploy/platforms/cloudflare-output-contract.mjs +17 -0
  13. package/dist/esm/plugins/deploy/platforms/cloudflare-output-plan.mjs +45 -0
  14. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier.mjs +347 -0
  15. package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +272 -29
  16. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +346 -43
  17. package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +1 -0
  18. package/dist/esm-node/index.mjs +2 -0
  19. package/dist/esm-node/plugins/backendFederationBuild.mjs +297 -0
  20. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-contract.mjs +18 -0
  21. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-plan.mjs +46 -0
  22. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier.mjs +348 -0
  23. package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +272 -29
  24. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +346 -43
  25. package/dist/types/plugins/backendFederationBuild.d.ts +11 -0
  26. package/dist/types/plugins/deploy/platforms/cloudflare-output-contract.d.ts +13 -0
  27. package/dist/types/plugins/deploy/platforms/cloudflare-output-plan.d.ts +33 -0
  28. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier.d.ts +32 -0
  29. package/dist/types/types/config/cloudflareDeploy.d.ts +22 -0
  30. package/dist/types/types/config/deploy.d.ts +15 -2
  31. package/lib/types.d.ts +2 -3
  32. package/package.json +17 -11
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ createCloudflareOutputPlan: ()=>createCloudflareOutputPlan
41
+ });
42
+ const external_node_path_namespaceObject = require("node:path");
43
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
44
+ const external_cloudflare_output_contract_js_namespaceObject = require("./cloudflare-output-contract.js");
45
+ const resolveOutput = (outputDirectory, relativePath)=>external_node_path_default().join(outputDirectory, relativePath);
46
+ function createCloudflareOutputPlan(outputDirectory) {
47
+ return {
48
+ outputDirectory,
49
+ requiredFiles: [
50
+ external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_ENTRY,
51
+ external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_MANIFEST,
52
+ external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WRANGLER_CONFIG_FILE,
53
+ external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_OUTPUT_PACKAGE_FILE
54
+ ],
55
+ publicLeakDirectories: [
56
+ 'server',
57
+ external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_BUNDLE_DIRECTORY
58
+ ],
59
+ paths: {
60
+ workerEntry: resolveOutput(outputDirectory, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_ENTRY),
61
+ workerManifest: resolveOutput(outputDirectory, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_MANIFEST),
62
+ wranglerConfig: resolveOutput(outputDirectory, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WRANGLER_CONFIG_FILE),
63
+ outputPackage: resolveOutput(outputDirectory, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_OUTPUT_PACKAGE_FILE),
64
+ workerPackage: resolveOutput(outputDirectory, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_PACKAGE_FILE),
65
+ publicAssets: resolveOutput(outputDirectory, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY),
66
+ workerBundle: resolveOutput(outputDirectory, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_BUNDLE_DIRECTORY)
67
+ },
68
+ packages: {
69
+ output: {
70
+ type: external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_OUTPUT_PACKAGE_TYPE
71
+ },
72
+ worker: {
73
+ type: external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_PACKAGE_TYPE
74
+ }
75
+ },
76
+ wrangler: {
77
+ main: external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_ENTRY,
78
+ assets: {
79
+ binding: external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_ASSETS_BINDING,
80
+ directory: `./${external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY}`,
81
+ run_worker_first: true
82
+ },
83
+ requiredCompatibilityFlags: external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS
84
+ }
85
+ };
86
+ }
87
+ exports.createCloudflareOutputPlan = __webpack_exports__.createCloudflareOutputPlan;
88
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
89
+ "createCloudflareOutputPlan"
90
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
91
+ Object.defineProperty(exports, '__esModule', {
92
+ value: true
93
+ });
@@ -0,0 +1,402 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ assertCloudflareOutput: ()=>assertCloudflareOutput,
41
+ verifyCloudflareOutput: ()=>verifyCloudflareOutput,
42
+ verifyCloudflareOutputMutationPolicy: ()=>verifyCloudflareOutputMutationPolicy
43
+ });
44
+ const promises_namespaceObject = require("node:fs/promises");
45
+ var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
46
+ const external_node_path_namespaceObject = require("node:path");
47
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
48
+ const external_node_url_namespaceObject = require("node:url");
49
+ const external_cloudflare_output_contract_js_namespaceObject = require("./cloudflare-output-contract.js");
50
+ const external_cloudflare_output_plan_js_namespaceObject = require("./cloudflare-output-plan.js");
51
+ const SOURCE_SCAN_FILE_PATTERN = /\.(?:[cm]?[jt]s|json)$/u;
52
+ const SOURCE_SCAN_IGNORED_DIRECTORY_NAMES = new Set([
53
+ '.codex',
54
+ '.fastcontext',
55
+ '.git',
56
+ '.mf',
57
+ '.modernjs',
58
+ '.output',
59
+ 'coverage',
60
+ 'dist',
61
+ 'dist-cloudflare',
62
+ 'node_modules',
63
+ 'repos',
64
+ 'topology'
65
+ ]);
66
+ const FORBIDDEN_MUTATION_PATTERNS = [
67
+ {
68
+ code: 'forbidden-mutation-pattern',
69
+ message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
70
+ pattern: /\.output\/server\/index\.mjs/u
71
+ },
72
+ {
73
+ code: 'forbidden-mutation-pattern',
74
+ message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
75
+ pattern: /path\.join\(\s*['"`]\.output['"`]\s*,\s*['"`]server['"`]\s*,\s*['"`]index\.mjs['"`]\s*\)/u
76
+ },
77
+ {
78
+ code: 'forbidden-mutation-pattern',
79
+ message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
80
+ pattern: /\.output\/worker\/[^'"`]*\.(?:mjs|cjs|js)/u
81
+ },
82
+ {
83
+ code: 'forbidden-mutation-pattern',
84
+ message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
85
+ pattern: /path\.join\(\s*['"`]\.output['"`]\s*,\s*['"`]worker['"`]\s*,\s*['"`][^'"`]+\.(?:mjs|cjs|js)['"`]\s*\)/u
86
+ },
87
+ {
88
+ code: 'forbidden-mutation-pattern',
89
+ message: "Drizzle entityKind worker bundle markers must be fixed in the framework toolchain, not post-build scripts.",
90
+ pattern: /replaceAll\(\s*['"`];entityKind(?:,entityKind)?;/u
91
+ },
92
+ {
93
+ code: 'forbidden-mutation-pattern',
94
+ message: "Effect BFF Cloudflare dispatch must not depend on duck-typed runtime helper probing in app scripts.",
95
+ pattern: /(?:typeof\s+[^;\n]*dispatchEffectBffRequest|['"`]dispatchEffectBffRequest['"`]\s+in\s+|\.dispatchEffectBffRequest\b)/u
96
+ },
97
+ {
98
+ code: 'forbidden-mutation-pattern',
99
+ message: "Effect BFF Cloudflare dispatch must not branch on handler.length in app scripts.",
100
+ pattern: /\bhandler\s*\.\s*length\b/u
101
+ }
102
+ ];
103
+ const pathExists = async (filePath)=>{
104
+ try {
105
+ await promises_default().access(filePath);
106
+ return true;
107
+ } catch {
108
+ return false;
109
+ }
110
+ };
111
+ const readJson = async (filePath)=>JSON.parse(await promises_default().readFile(filePath, 'utf-8'));
112
+ const addIssue = (issues, issue)=>{
113
+ issues.push(issue);
114
+ };
115
+ const assertEqual = (issues, actual, expected, issue)=>{
116
+ if (actual !== expected) addIssue(issues, issue);
117
+ };
118
+ const assertFlag = (issues, flags, flag, issue)=>{
119
+ if (!Array.isArray(flags) || !flags.includes(flag)) addIssue(issues, issue);
120
+ };
121
+ const getReferencedRouteWorkers = (manifest)=>Array.isArray(manifest?.routeSpec?.routes) ? manifest.routeSpec.routes.map((route)=>'string' == typeof route?.worker && route.worker.length > 0 ? route.worker : void 0).filter((worker)=>'string' == typeof worker) : [];
122
+ const getEffectBffWorker = (manifest)=>manifest?.bff?.runtimeFramework === 'effect' && 'string' == typeof manifest.bff.worker ? manifest.bff.worker : void 0;
123
+ const getWorkerBundleReferences = (manifest)=>{
124
+ const effectBffWorker = getEffectBffWorker(manifest);
125
+ return [
126
+ ...effectBffWorker ? [
127
+ {
128
+ kind: 'effect-bff',
129
+ reference: effectBffWorker
130
+ }
131
+ ] : [],
132
+ ...getReferencedRouteWorkers(manifest).map((reference)=>({
133
+ kind: 'route',
134
+ reference
135
+ }))
136
+ ];
137
+ };
138
+ const resolveWorkerBundleReference = (issues, outputDirectory, reference, manifestPath)=>{
139
+ const workerRoot = external_node_path_default().resolve(outputDirectory, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_BUNDLE_DIRECTORY);
140
+ const workerPath = external_node_path_default().resolve(outputDirectory, reference.reference);
141
+ const relativeToWorkerRoot = external_node_path_default().relative(workerRoot, workerPath);
142
+ if (external_node_path_default().isAbsolute(reference.reference) || relativeToWorkerRoot.startsWith('..') || external_node_path_default().isAbsolute(relativeToWorkerRoot)) {
143
+ addIssue(issues, {
144
+ code: 'invalid-manifest',
145
+ message: 'Cloudflare output manifest worker bundle references must stay under worker/.',
146
+ path: manifestPath
147
+ });
148
+ return null;
149
+ }
150
+ return {
151
+ ...reference,
152
+ path: workerPath
153
+ };
154
+ };
155
+ const missingWorkerBundleMessage = (reference)=>'effect-bff' === reference.kind ? 'Cloudflare Effect BFF manifest points to a missing worker bundle.' : 'Cloudflare route worker manifest points to a missing worker bundle.';
156
+ const DELIVERY_UNIT_IDENTITY_FIELDS = [
157
+ 'unitId',
158
+ 'buildMarker',
159
+ 'sourceRevision'
160
+ ];
161
+ const verifyDeliveryUnitIdentity = (issues, manifest, manifestPath, declared)=>{
162
+ const stamped = manifest?.deliveryUnit;
163
+ const hasStamp = Boolean(stamped) && 'object' == typeof stamped;
164
+ if (declared) {
165
+ if (!hasStamp) return void addIssue(issues, {
166
+ code: 'missing-delivery-unit',
167
+ message: `Cloudflare worker manifest is missing the delivery-unit identity declared by the workspace topology (expected unitId ${declared.unitId}, buildMarker ${declared.buildMarker}).`,
168
+ path: manifestPath
169
+ });
170
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS)assertEqual(issues, stamped[field], declared[field], {
171
+ code: 'delivery-unit-drift',
172
+ message: `Cloudflare worker manifest deliveryUnit.${field} must match the topology delivery-unit record (expected ${declared[field]}, received ${stamped[field] ?? 'undefined'}).`,
173
+ path: manifestPath
174
+ });
175
+ }
176
+ if (hasStamp && stamped.surfaces && 'object' == typeof stamped.surfaces) for (const surface of [
177
+ 'ui',
178
+ 'api'
179
+ ]){
180
+ const marker = stamped.surfaces[surface];
181
+ if (!marker || 'object' != typeof marker) {
182
+ addIssue(issues, {
183
+ code: 'missing-delivery-unit',
184
+ message: `Cloudflare worker manifest is missing the ${surface} delivery-unit surface marker.`,
185
+ path: manifestPath
186
+ });
187
+ continue;
188
+ }
189
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS)assertEqual(issues, marker[field], stamped[field], {
190
+ code: 'delivery-unit-drift',
191
+ message: `Cloudflare worker manifest ${surface} surface deliveryUnit.${field} must derive from one delivery-unit record (expected ${stamped[field] ?? 'undefined'}, received ${marker[field] ?? 'undefined'}).`,
192
+ path: manifestPath
193
+ });
194
+ }
195
+ };
196
+ const verifyManifestShape = (issues, manifest, manifestPath)=>{
197
+ assertEqual(issues, manifest.runtime?.type, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_RUNTIME_TYPE, {
198
+ code: 'invalid-manifest',
199
+ message: 'Cloudflare output manifest runtime.type must be cloudflare-module-worker.',
200
+ path: manifestPath
201
+ });
202
+ assertEqual(issues, manifest.runtime?.entry, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_ENTRY, {
203
+ code: 'invalid-manifest',
204
+ message: `Cloudflare output manifest runtime.entry must be ${external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_WORKER_ENTRY}.`,
205
+ path: manifestPath
206
+ });
207
+ assertEqual(issues, manifest.runtime?.fetchExport, true, {
208
+ code: 'invalid-manifest',
209
+ message: 'Cloudflare output manifest runtime.fetchExport must be true.',
210
+ path: manifestPath
211
+ });
212
+ assertEqual(issues, manifest.runtime?.nodeListen, false, {
213
+ code: 'invalid-manifest',
214
+ message: 'Cloudflare output manifest runtime.nodeListen must be false.',
215
+ path: manifestPath
216
+ });
217
+ assertEqual(issues, manifest.assets?.binding, external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_ASSETS_BINDING, {
218
+ code: 'invalid-manifest',
219
+ message: 'Cloudflare output manifest assets.binding must be ASSETS.',
220
+ path: manifestPath
221
+ });
222
+ assertEqual(issues, manifest.assets?.directory, `./${external_cloudflare_output_contract_js_namespaceObject.CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY}`, {
223
+ code: 'invalid-manifest',
224
+ message: 'Cloudflare output manifest assets.directory must be ./public.',
225
+ path: manifestPath
226
+ });
227
+ assertEqual(issues, manifest.assets?.runWorkerFirst, true, {
228
+ code: 'invalid-manifest',
229
+ message: 'Cloudflare output manifest assets.runWorkerFirst must be true.',
230
+ path: manifestPath
231
+ });
232
+ };
233
+ const walkFiles = async (root)=>{
234
+ if (!await pathExists(root)) return [];
235
+ const entries = await promises_default().readdir(root, {
236
+ withFileTypes: true
237
+ });
238
+ const files = [];
239
+ for (const entry of entries){
240
+ if (SOURCE_SCAN_IGNORED_DIRECTORY_NAMES.has(entry.name)) continue;
241
+ const entryPath = external_node_path_default().join(root, entry.name);
242
+ if (entry.isDirectory()) {
243
+ files.push(...await walkFiles(entryPath));
244
+ continue;
245
+ }
246
+ if (SOURCE_SCAN_FILE_PATTERN.test(entry.name)) files.push(entryPath);
247
+ }
248
+ return files;
249
+ };
250
+ const verifyCloudflareOutputMutationPolicy = async (options)=>{
251
+ const issues = [];
252
+ const files = (await Promise.all(options.scanRoots.map((scanRoot)=>walkFiles(external_node_path_default().resolve(scanRoot))))).flat();
253
+ for (const file of files){
254
+ const source = await promises_default().readFile(file, 'utf-8');
255
+ for (const forbidden of FORBIDDEN_MUTATION_PATTERNS)if (forbidden.pattern.test(source)) addIssue(issues, {
256
+ code: forbidden.code,
257
+ message: forbidden.message,
258
+ path: file
259
+ });
260
+ }
261
+ return {
262
+ ok: 0 === issues.length,
263
+ issues
264
+ };
265
+ };
266
+ const verifyWorkerImport = async (issues, entryPath)=>{
267
+ try {
268
+ const worker = (await import(`${(0, external_node_url_namespaceObject.pathToFileURL)(entryPath).href}?t=${Date.now()}`)).default;
269
+ if (!worker || 'function' != typeof worker.fetch) addIssue(issues, {
270
+ code: 'worker-import-failed',
271
+ message: 'Cloudflare server entry must default-export a Worker with fetch.',
272
+ path: entryPath
273
+ });
274
+ } catch (error) {
275
+ addIssue(issues, {
276
+ code: 'worker-import-failed',
277
+ message: `Cloudflare server entry could not be imported: ${error instanceof Error ? error.message : String(error)}`,
278
+ path: entryPath
279
+ });
280
+ }
281
+ };
282
+ const verifyCloudflareOutput = async (options)=>{
283
+ const outputDirectory = external_node_path_default().resolve(options.outputDirectory);
284
+ const issues = [];
285
+ const outputPlan = (0, external_cloudflare_output_plan_js_namespaceObject.createCloudflareOutputPlan)(outputDirectory);
286
+ for (const relativePath of outputPlan.requiredFiles){
287
+ const filePath = external_node_path_default().join(outputDirectory, relativePath);
288
+ if (!await pathExists(filePath)) addIssue(issues, {
289
+ code: 'missing-file',
290
+ message: `Cloudflare output is missing ${relativePath}.`,
291
+ path: filePath
292
+ });
293
+ }
294
+ const manifestPath = outputPlan.paths.workerManifest;
295
+ const wranglerPath = outputPlan.paths.wranglerConfig;
296
+ const packagePath = outputPlan.paths.outputPackage;
297
+ const workerPackagePath = outputPlan.paths.workerPackage;
298
+ const manifest = await pathExists(manifestPath) ? await readJson(manifestPath) : void 0;
299
+ const wrangler = await pathExists(wranglerPath) ? await readJson(wranglerPath) : void 0;
300
+ const outputPackage = await pathExists(packagePath) ? await readJson(packagePath) : void 0;
301
+ const workerPackage = await pathExists(workerPackagePath) ? await readJson(workerPackagePath) : void 0;
302
+ if (manifest) {
303
+ verifyManifestShape(issues, manifest, manifestPath);
304
+ verifyDeliveryUnitIdentity(issues, manifest, manifestPath, options.deliveryUnit);
305
+ const workerReferences = getWorkerBundleReferences(manifest);
306
+ if (workerReferences.length > 0 && !await pathExists(workerPackagePath)) addIssue(issues, {
307
+ code: 'missing-file',
308
+ message: 'Cloudflare output is missing worker/package.json for referenced worker bundles.',
309
+ path: workerPackagePath
310
+ });
311
+ if (manifest.bff?.runtimeFramework === 'effect' && !getEffectBffWorker(manifest)) addIssue(issues, {
312
+ code: 'missing-worker-bundle',
313
+ message: 'Cloudflare Effect BFF manifest points to a missing worker bundle.'
314
+ });
315
+ for (const workerReference of workerReferences){
316
+ const resolvedWorker = resolveWorkerBundleReference(issues, outputDirectory, workerReference, manifestPath);
317
+ if (!resolvedWorker) continue;
318
+ const workerExists = await pathExists(resolvedWorker.path);
319
+ if (!workerExists) addIssue(issues, {
320
+ code: 'missing-worker-bundle',
321
+ message: missingWorkerBundleMessage(workerReference),
322
+ path: resolvedWorker.path
323
+ });
324
+ if (workerExists && 'effect-bff' === resolvedWorker.kind) {
325
+ const workerSource = await promises_default().readFile(resolvedWorker.path, 'utf-8');
326
+ if (workerSource.includes(';entityKind;') || workerSource.includes(';entityKind,entityKind;')) addIssue(issues, {
327
+ code: 'invalid-worker-bundle',
328
+ message: 'Cloudflare Effect BFF worker bundle contains invalid Drizzle entityKind marker references.',
329
+ path: resolvedWorker.path
330
+ });
331
+ }
332
+ }
333
+ }
334
+ if (wrangler) {
335
+ assertEqual(issues, wrangler.main, outputPlan.wrangler.main, {
336
+ code: 'invalid-wrangler',
337
+ message: `wrangler.json main must be ${outputPlan.wrangler.main}.`,
338
+ path: wranglerPath
339
+ });
340
+ assertEqual(issues, wrangler.assets?.binding, outputPlan.wrangler.assets.binding, {
341
+ code: 'invalid-wrangler',
342
+ message: 'wrangler.json assets.binding must be ASSETS.',
343
+ path: wranglerPath
344
+ });
345
+ assertEqual(issues, wrangler.assets?.directory, outputPlan.wrangler.assets.directory, {
346
+ code: 'invalid-wrangler',
347
+ message: 'wrangler.json assets.directory must be ./public.',
348
+ path: wranglerPath
349
+ });
350
+ assertEqual(issues, wrangler.assets?.run_worker_first, outputPlan.wrangler.assets.run_worker_first, {
351
+ code: 'invalid-wrangler',
352
+ message: 'wrangler.json assets.run_worker_first must be true.',
353
+ path: wranglerPath
354
+ });
355
+ for (const flag of outputPlan.wrangler.requiredCompatibilityFlags)assertFlag(issues, wrangler.compatibility_flags, flag, {
356
+ code: 'invalid-wrangler',
357
+ message: `wrangler.json compatibility_flags must include ${flag}.`,
358
+ path: wranglerPath
359
+ });
360
+ }
361
+ if (outputPackage) assertEqual(issues, outputPackage.type, outputPlan.packages.output.type, {
362
+ code: 'invalid-package',
363
+ message: '.output/package.json must declare type module.',
364
+ path: packagePath
365
+ });
366
+ if (workerPackage) assertEqual(issues, workerPackage.type, outputPlan.packages.worker.type, {
367
+ code: 'invalid-package',
368
+ message: '.output/worker/package.json must declare type commonjs.',
369
+ path: workerPackagePath
370
+ });
371
+ for (const leakedPath of outputPlan.publicLeakDirectories){
372
+ const publicPath = external_node_path_default().join(outputPlan.paths.publicAssets, leakedPath);
373
+ if (await pathExists(publicPath)) addIssue(issues, {
374
+ code: 'public-output-leak',
375
+ message: `Framework-owned ${leakedPath} output leaked into public assets.`,
376
+ path: publicPath
377
+ });
378
+ }
379
+ if (false !== options.importWorker && await pathExists(outputPlan.paths.workerEntry)) await verifyWorkerImport(issues, outputPlan.paths.workerEntry);
380
+ return {
381
+ ok: 0 === issues.length,
382
+ issues
383
+ };
384
+ };
385
+ const assertCloudflareOutput = async (options)=>{
386
+ const result = await verifyCloudflareOutput(options);
387
+ if (!result.ok) throw new Error([
388
+ 'Cloudflare output verification failed:',
389
+ ...result.issues.map((issue)=>`- ${issue.code}: ${issue.message}${issue.path ? ` (${issue.path})` : ''}`)
390
+ ].join('\n'));
391
+ };
392
+ exports.assertCloudflareOutput = __webpack_exports__.assertCloudflareOutput;
393
+ exports.verifyCloudflareOutput = __webpack_exports__.verifyCloudflareOutput;
394
+ exports.verifyCloudflareOutputMutationPolicy = __webpack_exports__.verifyCloudflareOutputMutationPolicy;
395
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
396
+ "assertCloudflareOutput",
397
+ "verifyCloudflareOutput",
398
+ "verifyCloudflareOutputMutationPolicy"
399
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
400
+ Object.defineProperty(exports, '__esModule', {
401
+ value: true
402
+ });