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

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 (116) hide show
  1. package/dist/cjs/plugins/backend-federation/codegen.js +208 -0
  2. package/dist/cjs/plugins/backend-federation/config.js +217 -0
  3. package/dist/cjs/plugins/backend-federation/emit.js +139 -0
  4. package/dist/cjs/plugins/backendFederationBuild.js +4 -298
  5. package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +127 -0
  6. package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +137 -0
  7. package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +118 -0
  8. package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +135 -0
  9. package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +126 -0
  10. package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +223 -0
  11. package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +18 -0
  12. package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +66 -0
  13. package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +178 -0
  14. package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +189 -0
  15. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +83 -0
  16. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +184 -0
  17. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/issues.js +54 -0
  18. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +83 -0
  19. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +158 -0
  20. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +137 -0
  21. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier.js +23 -363
  22. package/dist/cjs/plugins/deploy/platforms/cloudflare.js +2 -745
  23. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
  24. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
  25. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
  26. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
  27. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
  28. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
  29. package/dist/esm/plugins/backend-federation/codegen.mjs +157 -0
  30. package/dist/esm/plugins/backend-federation/config.mjs +141 -0
  31. package/dist/esm/plugins/backend-federation/emit.mjs +88 -0
  32. package/dist/esm/plugins/backendFederationBuild.mjs +1 -296
  33. package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +64 -0
  34. package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +33 -0
  35. package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +67 -0
  36. package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +97 -0
  37. package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +78 -0
  38. package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +167 -0
  39. package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
  40. package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +12 -0
  41. package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +118 -0
  42. package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +135 -0
  43. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +45 -0
  44. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +129 -0
  45. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +10 -0
  46. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +45 -0
  47. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +97 -0
  48. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +68 -0
  49. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier.mjs +1 -347
  50. package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +1 -735
  51. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
  52. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
  53. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
  54. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
  55. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
  56. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
  57. package/dist/esm-node/plugins/backend-federation/codegen.mjs +158 -0
  58. package/dist/esm-node/plugins/backend-federation/config.mjs +142 -0
  59. package/dist/esm-node/plugins/backend-federation/emit.mjs +89 -0
  60. package/dist/esm-node/plugins/backendFederationBuild.mjs +1 -296
  61. package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +65 -0
  62. package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +34 -0
  63. package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +68 -0
  64. package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +98 -0
  65. package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +79 -0
  66. package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +168 -0
  67. package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +1 -0
  68. package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +13 -0
  69. package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +119 -0
  70. package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +136 -0
  71. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +46 -0
  72. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +130 -0
  73. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +11 -0
  74. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +46 -0
  75. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +98 -0
  76. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +69 -0
  77. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier.mjs +1 -347
  78. package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +1 -735
  79. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
  80. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
  81. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
  82. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
  83. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
  84. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
  85. package/dist/types/plugins/backend-federation/codegen.d.ts +82 -0
  86. package/dist/types/plugins/backend-federation/config.d.ts +103 -0
  87. package/dist/types/plugins/backend-federation/emit.d.ts +13 -0
  88. package/dist/types/plugins/backendFederationBuild.d.ts +2 -11
  89. package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +15 -0
  90. package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +23 -0
  91. package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +23 -0
  92. package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +21 -0
  93. package/dist/types/plugins/deploy/platforms/cloudflare/index.d.ts +2 -0
  94. package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +88 -0
  95. package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +5 -0
  96. package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +6 -0
  97. package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +100 -0
  98. package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +39 -0
  99. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +4 -0
  100. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +18 -0
  101. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +14 -0
  102. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +2 -0
  103. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +13 -0
  104. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +16 -0
  105. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier.d.ts +1 -32
  106. package/dist/types/plugins/deploy/platforms/cloudflare.d.ts +1 -2
  107. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -0
  108. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +1 -0
  109. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +1 -0
  110. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +1 -0
  111. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +1 -0
  112. package/package.json +11 -11
  113. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -879
  114. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -879
  115. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -879
  116. /package/dist/types/plugins/deploy/platforms/templates/{cloudflare-entry.d.mts → cloudflare-entry.006-fetch-handler.d.mts} +0 -0
@@ -0,0 +1,167 @@
1
+ const DEFAULT_SECURITY_HEADERS = {
2
+ referrerPolicy: 'strict-origin-when-cross-origin',
3
+ contentTypeOptions: 'nosniff',
4
+ permissionsPolicy: 'camera=(), geolocation=(), microphone=(), payment=(), usb=()'
5
+ };
6
+ const DEFAULT_CORS_ALLOWED_METHODS = [
7
+ 'GET',
8
+ 'HEAD',
9
+ 'POST',
10
+ 'PUT',
11
+ 'PATCH',
12
+ 'DELETE',
13
+ 'OPTIONS'
14
+ ];
15
+ const DEFAULT_CSP_DIRECTIVES = {
16
+ 'base-uri': [
17
+ "'self'"
18
+ ],
19
+ 'connect-src': [
20
+ "'self'",
21
+ 'https:',
22
+ 'http:',
23
+ 'wss:',
24
+ 'ws:'
25
+ ],
26
+ 'default-src': [
27
+ "'self'"
28
+ ],
29
+ 'font-src': [
30
+ "'self'",
31
+ 'data:',
32
+ 'https:',
33
+ 'http:'
34
+ ],
35
+ 'form-action': [
36
+ "'self'"
37
+ ],
38
+ 'frame-ancestors': [
39
+ "'self'"
40
+ ],
41
+ 'img-src': [
42
+ "'self'",
43
+ 'data:',
44
+ 'blob:',
45
+ 'https:',
46
+ 'http:'
47
+ ],
48
+ 'manifest-src': [
49
+ "'self'",
50
+ 'https:',
51
+ 'http:'
52
+ ],
53
+ 'object-src': [
54
+ "'none'"
55
+ ],
56
+ "script-src": [
57
+ "'self'",
58
+ "'unsafe-inline'",
59
+ "'unsafe-eval'",
60
+ 'https:',
61
+ 'http:',
62
+ 'blob:'
63
+ ],
64
+ 'style-src': [
65
+ "'self'",
66
+ "'unsafe-inline'",
67
+ 'https:',
68
+ 'http:'
69
+ ],
70
+ 'worker-src': [
71
+ "'self'",
72
+ 'blob:'
73
+ ]
74
+ };
75
+ const normalizeDirectiveValues = (value)=>{
76
+ const values = Array.isArray(value) ? value : [
77
+ value
78
+ ];
79
+ return [
80
+ ...new Set(values.map((entry)=>entry.trim()).filter(Boolean))
81
+ ];
82
+ };
83
+ const appendDirectiveValues = (directives, name, values)=>{
84
+ if (!values?.length) return;
85
+ directives[name] = normalizeDirectiveValues([
86
+ ...directives[name] ?? [],
87
+ ...values
88
+ ]);
89
+ };
90
+ const createContentSecurityPolicy = (config)=>{
91
+ const mode = config?.mode ?? 'report-only';
92
+ if ('off' === mode) return {
93
+ mode,
94
+ directives: {},
95
+ reason: config?.reason
96
+ };
97
+ const directives = Object.fromEntries(Object.entries(DEFAULT_CSP_DIRECTIVES).map(([name, values])=>[
98
+ name,
99
+ [
100
+ ...values
101
+ ]
102
+ ]));
103
+ for (const [name, value] of Object.entries(config?.directives ?? {}))if (false === value) delete directives[name];
104
+ else directives[name] = normalizeDirectiveValues(value);
105
+ if (config?.frameAncestors === false) delete directives['frame-ancestors'];
106
+ else if (config?.frameAncestors) directives['frame-ancestors'] = normalizeDirectiveValues(config.frameAncestors);
107
+ appendDirectiveValues(directives, "script-src", config?.additionalScriptSrc);
108
+ appendDirectiveValues(directives, 'style-src', config?.additionalStyleSrc);
109
+ appendDirectiveValues(directives, 'connect-src', config?.additionalConnectSrc);
110
+ appendDirectiveValues(directives, 'img-src', config?.additionalImgSrc);
111
+ if (config?.reportUri) directives['report-uri'] = [
112
+ config.reportUri
113
+ ];
114
+ return {
115
+ mode,
116
+ directives,
117
+ reason: config?.reason
118
+ };
119
+ };
120
+ const createNoindexPolicy = (noindex)=>{
121
+ if (false === noindex) return {
122
+ workersDev: false,
123
+ localhost: false,
124
+ previewHostnames: []
125
+ };
126
+ if (true === noindex || void 0 === noindex) return {
127
+ workersDev: true,
128
+ localhost: true,
129
+ previewHostnames: []
130
+ };
131
+ return {
132
+ workersDev: noindex.workersDev ?? true,
133
+ localhost: noindex.localhost ?? true,
134
+ previewHostnames: noindex.previewHostnames ?? [],
135
+ reason: noindex.reason
136
+ };
137
+ };
138
+ const createCloudflareWorkerCorsPolicy = (cors)=>({
139
+ assets: cors?.assets ?? true,
140
+ allowedOrigins: normalizeDirectiveValues(cors?.allowedOrigins ?? []),
141
+ allowedMethods: cors?.allowedMethods?.length ? normalizeDirectiveValues(cors.allowedMethods.map((method)=>method.toUpperCase())) : DEFAULT_CORS_ALLOWED_METHODS,
142
+ allowedHeaders: cors?.allowedHeaders?.length ? normalizeDirectiveValues(cors.allowedHeaders) : [
143
+ '*'
144
+ ],
145
+ reason: cors?.reason
146
+ });
147
+ const createCloudflareWorkerSecurityPolicy = (modernConfig)=>{
148
+ const security = modernConfig.deploy?.worker?.security;
149
+ if (security?.enabled === false) return {
150
+ enabled: false,
151
+ cors: createCloudflareWorkerCorsPolicy(security.cors),
152
+ reason: security.reason
153
+ };
154
+ return {
155
+ enabled: true,
156
+ headers: {
157
+ referrerPolicy: security?.headers?.referrerPolicy ?? DEFAULT_SECURITY_HEADERS.referrerPolicy,
158
+ contentTypeOptions: security?.headers?.contentTypeOptions ?? DEFAULT_SECURITY_HEADERS.contentTypeOptions,
159
+ permissionsPolicy: security?.headers?.permissionsPolicy ?? DEFAULT_SECURITY_HEADERS.permissionsPolicy
160
+ },
161
+ contentSecurityPolicy: createContentSecurityPolicy(security?.contentSecurityPolicy),
162
+ noindex: createNoindexPolicy(security?.noindex),
163
+ cors: createCloudflareWorkerCorsPolicy(security?.cors),
164
+ reason: security?.reason
165
+ };
166
+ };
167
+ export { DEFAULT_CORS_ALLOWED_METHODS, DEFAULT_CSP_DIRECTIVES, DEFAULT_SECURITY_HEADERS, createCloudflareWorkerCorsPolicy, createCloudflareWorkerSecurityPolicy, createContentSecurityPolicy, createNoindexPolicy };
@@ -0,0 +1,12 @@
1
+ import node_path from "node:path";
2
+ const isRecord = (value)=>null !== value && 'object' == typeof value && !Array.isArray(value);
3
+ const normalizeRelativePath = (value, label, scope = 'app output', options = {})=>{
4
+ if ('string' != typeof value) throw new Error(`${label} must be a relative path inside the ${scope}.`);
5
+ const normalized = value.trim().replace(/\\/g, '/').replace(/^\.\/+/u, '').replace(/\/+$/u, '');
6
+ const segments = normalized.split('/');
7
+ const isRootDestination = '.' === normalized;
8
+ if (!normalized || node_path.isAbsolute(normalized) || !options.allowRoot && isRootDestination || segments.includes('..')) throw new Error(`${label} must be a relative path inside the ${scope}.`);
9
+ return normalized;
10
+ };
11
+ const isJsonRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
12
+ export { isJsonRecord, isRecord, normalizeRelativePath };
@@ -0,0 +1,118 @@
1
+ import node_path from "node:path";
2
+ import { fs } from "@modern-js/utils";
3
+ import { readRouteSpec } from "./artifacts.mjs";
4
+ import { ASSETS_BINDING, BFF_EFFECT_WORKER_ENTRY, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_BUNDLE_FORMAT, DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES, EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE, LOADABLE_STATS_FILE, PUBLIC_ASSETS_DIRECTORY, ROUTE_MANIFEST_FILE, ROUTE_SPEC_FILE, ROUTE_SPEC_OUTPUT, SERVER_BUNDLE_DIRECTORY, WORKER_BUNDLE_DIRECTORY, WORKER_ENTRY } from "./constants.mjs";
5
+ import { createI18nWorkerManifest } from "./i18n-worker.mjs";
6
+ import { createCloudflareWorkerSecurityPolicy } from "./security-policies.mjs";
7
+ import { normalizeRelativePath } from "./utils.mjs";
8
+ import { createWorkerManifestServiceBindings, createWorkerServiceBindings } from "./wrangler-config.mjs";
9
+ const createMissingEffectBffWorkerError = (outputDirectory, worker)=>new Error(`Cloudflare Effect API runtime is configured, but the BFF worker bundle is missing: ${node_path.join(outputDirectory, worker)}. ${EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE}`);
10
+ const createWorkerManifest = async (outputDirectory, modernConfig, appContext, deliveryUnitStamp)=>{
11
+ const routeSpec = await readRouteSpec(outputDirectory);
12
+ const routes = await Promise.all(routeSpec.routes.map(async (route)=>{
13
+ const worker = 'string' == typeof route.worker ? route.worker : void 0;
14
+ return {
15
+ urlPath: route.urlPath,
16
+ entryName: route.entryName,
17
+ entryPath: route.entryPath,
18
+ isSSR: Boolean(route.isSSR),
19
+ worker,
20
+ workerExists: worker ? await fs.pathExists(node_path.join(outputDirectory, worker)) : false
21
+ };
22
+ }));
23
+ const bffPrefix = modernConfig.bff?.prefix;
24
+ const primaryBffPrefix = Array.isArray(bffPrefix) ? bffPrefix[0] : bffPrefix;
25
+ const isEffectApi = Boolean(modernConfig.bff) && modernConfig.bff?.runtimeFramework !== 'hono';
26
+ const effectApiWorkerExists = await fs.pathExists(node_path.join(outputDirectory, BFF_EFFECT_WORKER_ENTRY));
27
+ const serviceBindings = createWorkerManifestServiceBindings(createWorkerServiceBindings(modernConfig, void 0));
28
+ if (isEffectApi && primaryBffPrefix && !effectApiWorkerExists) throw createMissingEffectBffWorkerError(outputDirectory, BFF_EFFECT_WORKER_ENTRY);
29
+ return {
30
+ version: 1,
31
+ runtime: {
32
+ type: CLOUDFLARE_RUNTIME_TYPE,
33
+ entry: WORKER_ENTRY,
34
+ fetchExport: true,
35
+ nodeListen: false
36
+ },
37
+ assets: {
38
+ binding: ASSETS_BINDING,
39
+ directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
40
+ runWorkerFirst: true
41
+ },
42
+ routeSpec: {
43
+ file: ROUTE_SPEC_OUTPUT,
44
+ routes
45
+ },
46
+ workerBundles: {
47
+ directory: WORKER_BUNDLE_DIRECTORY,
48
+ format: CLOUDFLARE_WORKER_BUNDLE_FORMAT,
49
+ importableFromModuleWorker: true,
50
+ requestHandlerExport: 'requestHandler'
51
+ },
52
+ resources: {
53
+ loadableStats: LOADABLE_STATS_FILE,
54
+ routeManifest: ROUTE_MANIFEST_FILE
55
+ },
56
+ security: createCloudflareWorkerSecurityPolicy(modernConfig),
57
+ ...deliveryUnitStamp ? {
58
+ deliveryUnit: deliveryUnitStamp
59
+ } : {},
60
+ i18n: createI18nWorkerManifest(routeSpec, appContext),
61
+ bff: isEffectApi && primaryBffPrefix && effectApiWorkerExists ? {
62
+ runtimeFramework: 'effect',
63
+ prefix: primaryBffPrefix,
64
+ worker: BFF_EFFECT_WORKER_ENTRY
65
+ } : void 0,
66
+ ...void 0 === serviceBindings ? {} : {
67
+ serviceBindings
68
+ }
69
+ };
70
+ };
71
+ const createWorkerModuleLoaders = (manifest)=>{
72
+ const imports = new Map();
73
+ for (const route of manifest.routeSpec.routes)if (route.worker && route.workerExists) {
74
+ const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
75
+ imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
76
+ }
77
+ if (manifest.bff?.worker) {
78
+ const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
79
+ imports.set(manifest.bff.worker, `() => import(${JSON.stringify(importPath)})`);
80
+ }
81
+ if (0 === imports.size) return '{}';
82
+ const loaders = [
83
+ ...imports.entries()
84
+ ].map(([worker, loader])=>`${JSON.stringify(worker)}: ${loader}`);
85
+ return `{\n${loaders.join(',\n')}\n}`;
86
+ };
87
+ const getPublicAssetExcludes = (appDirectory, modernConfig)=>[
88
+ ...DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES.filter((directory)=>{
89
+ try {
90
+ return fs.statSync(node_path.join(appDirectory, directory)).isDirectory();
91
+ } catch {
92
+ return false;
93
+ }
94
+ }),
95
+ ...modernConfig.deploy?.worker?.publicAssetExcludes ?? []
96
+ ].map((entry)=>normalizeRelativePath(entry, 'deploy.worker.publicAssetExcludes'));
97
+ const shouldCopyToPublicAssets = (src, distDirectory, publicAssetExcludes)=>{
98
+ const relativePath = node_path.relative(distDirectory, src);
99
+ if (!relativePath) return true;
100
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
101
+ const [topLevelDirectory] = normalizedRelativePath.split('/');
102
+ const basename = normalizedRelativePath.split('/').pop() ?? '';
103
+ return normalizedRelativePath !== ROUTE_SPEC_FILE && topLevelDirectory !== WORKER_BUNDLE_DIRECTORY && topLevelDirectory !== SERVER_BUNDLE_DIRECTORY && '.env' !== basename && !basename.startsWith('.env.') && !publicAssetExcludes.some((exclude)=>normalizedRelativePath === exclude || normalizedRelativePath.startsWith(`${exclude}/`));
104
+ };
105
+ const shouldCopyToWorkerBundle = (src, workerBundleDirectory)=>{
106
+ const relativePath = node_path.relative(workerBundleDirectory, src);
107
+ if (!relativePath) return true;
108
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
109
+ const basename = node_path.basename(normalizedRelativePath);
110
+ if (basename.startsWith('.') || normalizedRelativePath.includes('/.')) return false;
111
+ if (fs.statSync(src).isDirectory()) return true;
112
+ return [
113
+ '.cjs',
114
+ '.js',
115
+ '.mjs'
116
+ ].includes(node_path.extname(normalizedRelativePath));
117
+ };
118
+ export { createWorkerManifest, createWorkerModuleLoaders, getPublicAssetExcludes, shouldCopyToPublicAssets, shouldCopyToWorkerBundle };
@@ -0,0 +1,135 @@
1
+ import node_path from "node:path";
2
+ import { ASSETS_BINDING, COMPATIBILITY_DATE_PATTERN, DEFAULT_COMPATIBILITY_DATE, PUBLIC_ASSETS_DIRECTORY, REQUIRED_COMPATIBILITY_FLAGS, WORKER_ENTRY } from "./constants.mjs";
3
+ import { isJsonRecord, normalizeRelativePath } from "./utils.mjs";
4
+ const getCompatibilityDate = (modernConfig)=>{
5
+ const configuredDate = modernConfig.deploy?.worker?.compatibilityDate?.trim();
6
+ const compatibilityDate = configuredDate || DEFAULT_COMPATIBILITY_DATE;
7
+ if (!COMPATIBILITY_DATE_PATTERN.test(compatibilityDate)) throw new Error(`deploy.worker.compatibilityDate must use YYYY-MM-DD, received ${JSON.stringify(compatibilityDate)}.`);
8
+ return compatibilityDate;
9
+ };
10
+ const getWorkerName = (appDirectory)=>{
11
+ const basename = node_path.basename(appDirectory);
12
+ return basename.replace(/[^a-zA-Z0-9-_]/g, '-') || 'modern-cloudflare-worker';
13
+ };
14
+ const getConfiguredWorkerName = (appDirectory, modernConfig)=>{
15
+ const configuredName = modernConfig.deploy?.worker?.name?.trim();
16
+ return configuredName || getWorkerName(appDirectory);
17
+ };
18
+ const getConfiguredWrangler = (modernConfig)=>{
19
+ const wrangler = modernConfig.deploy?.worker?.wrangler;
20
+ if (void 0 === wrangler) return {};
21
+ if (!isJsonRecord(wrangler)) throw new Error('deploy.worker.wrangler must be a JSON object.');
22
+ return wrangler;
23
+ };
24
+ const createWranglerCompatibilityFlags = (configuredFlags)=>{
25
+ if (void 0 === configuredFlags) return [
26
+ ...REQUIRED_COMPATIBILITY_FLAGS
27
+ ];
28
+ if (!Array.isArray(configuredFlags) || configuredFlags.some((flag)=>'string' != typeof flag)) throw new Error('deploy.worker.wrangler.compatibility_flags must be an array of strings.');
29
+ return [
30
+ ...new Set([
31
+ ...configuredFlags,
32
+ ...REQUIRED_COMPATIBILITY_FLAGS
33
+ ])
34
+ ];
35
+ };
36
+ const createWranglerAssetsConfig = (configuredAssets)=>{
37
+ if (void 0 !== configuredAssets && !isJsonRecord(configuredAssets)) throw new Error('deploy.worker.wrangler.assets must be an object.');
38
+ return {
39
+ ...isJsonRecord(configuredAssets) ? configuredAssets : {},
40
+ directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
41
+ binding: ASSETS_BINDING,
42
+ run_worker_first: true
43
+ };
44
+ };
45
+ const assertNonEmptyString = (value, label)=>{
46
+ if ('string' != typeof value || 0 === value.trim().length) throw new Error(`${label} must be a non-empty string.`);
47
+ return value.trim();
48
+ };
49
+ const normalizeD1Database = (database, index)=>{
50
+ const binding = assertNonEmptyString(database.binding, `deploy.worker.d1Databases[${index}].binding`);
51
+ const databaseName = assertNonEmptyString(database.databaseName, `deploy.worker.d1Databases[${index}].databaseName`);
52
+ const databaseId = assertNonEmptyString(database.databaseId, `deploy.worker.d1Databases[${index}].databaseId`);
53
+ const migrationsDir = void 0 === database.migrationsDir ? void 0 : normalizeRelativePath(database.migrationsDir, `deploy.worker.d1Databases[${index}].migrationsDir`, 'app root');
54
+ const previewDatabaseId = void 0 === database.previewDatabaseId ? void 0 : assertNonEmptyString(database.previewDatabaseId, `deploy.worker.d1Databases[${index}].previewDatabaseId`);
55
+ return {
56
+ binding,
57
+ database_name: databaseName,
58
+ database_id: databaseId,
59
+ ...void 0 === migrationsDir ? {} : {
60
+ migrations_dir: migrationsDir
61
+ },
62
+ ...void 0 === previewDatabaseId ? {} : {
63
+ preview_database_id: previewDatabaseId
64
+ },
65
+ ...void 0 === database.remote ? {} : {
66
+ remote: database.remote
67
+ }
68
+ };
69
+ };
70
+ const createWranglerD1Databases = (modernConfig, configuredWranglerD1)=>{
71
+ const d1Databases = modernConfig.deploy?.worker?.d1Databases;
72
+ if (void 0 === d1Databases) return configuredWranglerD1;
73
+ if (void 0 !== configuredWranglerD1) throw new Error('Use deploy.worker.d1Databases or deploy.worker.wrangler.d1_databases, not both.');
74
+ if (!Array.isArray(d1Databases)) throw new Error('deploy.worker.d1Databases must be an array.');
75
+ return d1Databases.map(normalizeD1Database);
76
+ };
77
+ const normalizeServiceBinding = (service, index)=>{
78
+ const binding = assertNonEmptyString(service.binding, `deploy.worker.services[${index}].binding`);
79
+ const serviceName = assertNonEmptyString(service.service, `deploy.worker.services[${index}].service`);
80
+ const prefix = void 0 === service.prefix ? void 0 : assertNonEmptyString(service.prefix, `deploy.worker.services[${index}].prefix`);
81
+ return {
82
+ binding,
83
+ service: serviceName,
84
+ ...void 0 === prefix ? {} : {
85
+ prefix
86
+ }
87
+ };
88
+ };
89
+ const createWorkerServiceBindings = (modernConfig, configuredWranglerServices)=>{
90
+ const services = modernConfig.deploy?.worker?.services;
91
+ if (void 0 === services) return configuredWranglerServices;
92
+ if (void 0 !== configuredWranglerServices) throw new Error('Use deploy.worker.services or deploy.worker.wrangler.services, not both.');
93
+ if (!Array.isArray(services)) throw new Error('deploy.worker.services must be an array.');
94
+ return services.map(normalizeServiceBinding);
95
+ };
96
+ const createWranglerServices = (serviceBindings)=>{
97
+ if (!Array.isArray(serviceBindings)) return serviceBindings;
98
+ if (!serviceBindings.every(isJsonRecord)) return serviceBindings;
99
+ return serviceBindings.map((service)=>{
100
+ const { prefix, ...wranglerService } = service;
101
+ return wranglerService;
102
+ });
103
+ };
104
+ const createWorkerManifestServiceBindings = (serviceBindings)=>{
105
+ if (!Array.isArray(serviceBindings)) return;
106
+ const dispatchBindings = serviceBindings.filter((service)=>isJsonRecord(service) && 'string' == typeof service.binding && 'string' == typeof service.service && 'string' == typeof service.prefix).map((service)=>({
107
+ binding: service.binding,
108
+ service: service.service,
109
+ prefix: service.prefix,
110
+ interface: 'fetch'
111
+ }));
112
+ return dispatchBindings.length > 0 ? dispatchBindings : void 0;
113
+ };
114
+ const createWranglerConfig = (appDirectory, modernConfig)=>{
115
+ const wrangler = getConfiguredWrangler(modernConfig);
116
+ const d1Databases = createWranglerD1Databases(modernConfig, wrangler.d1_databases);
117
+ const serviceBindings = createWorkerServiceBindings(modernConfig, wrangler.services);
118
+ const wranglerServices = createWranglerServices(serviceBindings);
119
+ return {
120
+ $schema: 'node_modules/wrangler/config-schema.json',
121
+ name: getConfiguredWorkerName(appDirectory, modernConfig),
122
+ compatibility_date: getCompatibilityDate(modernConfig),
123
+ ...wrangler,
124
+ main: WORKER_ENTRY,
125
+ compatibility_flags: createWranglerCompatibilityFlags(wrangler.compatibility_flags),
126
+ assets: createWranglerAssetsConfig(wrangler.assets),
127
+ ...void 0 === d1Databases ? {} : {
128
+ d1_databases: d1Databases
129
+ },
130
+ ...void 0 === wranglerServices ? {} : {
131
+ services: wranglerServices
132
+ }
133
+ };
134
+ };
135
+ export { createWorkerManifestServiceBindings, createWorkerServiceBindings, createWranglerConfig };
@@ -0,0 +1,45 @@
1
+ import { DELIVERY_UNIT_IDENTITY_FIELDS, deliveryUnitIdentityFieldValue } from "@modern-js/utils/universal";
2
+ import { addIssue, assertEqual } from "./issues.mjs";
3
+ const verifyDeliveryUnitIdentity = (issues, manifest, manifestPath, declared)=>{
4
+ const stamped = manifest?.deliveryUnit;
5
+ const hasStamp = Boolean(stamped) && 'object' == typeof stamped;
6
+ if (declared) {
7
+ if (!hasStamp) return void addIssue(issues, {
8
+ code: 'missing-delivery-unit',
9
+ message: `Cloudflare worker manifest is missing the delivery-unit identity declared by the workspace topology (expected unitId ${declared.unitId}, buildMarker ${declared.buildMarker}).`,
10
+ path: manifestPath
11
+ });
12
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS){
13
+ const stampedValue = deliveryUnitIdentityFieldValue(stamped, field);
14
+ assertEqual(issues, stampedValue, declared[field], {
15
+ code: 'delivery-unit-drift',
16
+ message: `Cloudflare worker manifest deliveryUnit.${field} must match the topology delivery-unit record (expected ${declared[field]}, received ${stampedValue ?? 'undefined'}).`,
17
+ path: manifestPath
18
+ });
19
+ }
20
+ }
21
+ if (hasStamp && stamped.surfaces && 'object' == typeof stamped.surfaces) for (const surface of [
22
+ 'ui',
23
+ 'api'
24
+ ]){
25
+ const marker = stamped.surfaces[surface];
26
+ if (!marker || 'object' != typeof marker) {
27
+ addIssue(issues, {
28
+ code: 'missing-delivery-unit',
29
+ message: `Cloudflare worker manifest is missing the ${surface} delivery-unit surface marker.`,
30
+ path: manifestPath
31
+ });
32
+ continue;
33
+ }
34
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS){
35
+ const markerValue = deliveryUnitIdentityFieldValue(marker, field);
36
+ const stampedValue = deliveryUnitIdentityFieldValue(stamped, field);
37
+ assertEqual(issues, markerValue, stampedValue, {
38
+ code: 'delivery-unit-drift',
39
+ message: `Cloudflare worker manifest ${surface} surface deliveryUnit.${field} must derive from one delivery-unit record (expected ${stampedValue ?? 'undefined'}, received ${markerValue ?? 'undefined'}).`,
40
+ path: manifestPath
41
+ });
42
+ }
43
+ }
44
+ };
45
+ export { verifyDeliveryUnitIdentity };
@@ -0,0 +1,129 @@
1
+ import promises from "node:fs/promises";
2
+ import node_path from "node:path";
3
+ import { createCloudflareOutputPlan } from "../cloudflare-output-plan.mjs";
4
+ import { verifyDeliveryUnitIdentity } from "./identity.mjs";
5
+ import { addIssue, assertEqual, assertFlag } from "./issues.mjs";
6
+ import { verifyManifestShape } from "./manifest.mjs";
7
+ import { getEffectBffWorker, getWorkerBundleReferences, missingWorkerBundleMessage, resolveWorkerBundleReference, verifyWorkerBundleReferences, verifyWorkerImport } from "./worker-bundles.mjs";
8
+ const pathExists = async (filePath)=>{
9
+ try {
10
+ await promises.access(filePath);
11
+ return true;
12
+ } catch {
13
+ return false;
14
+ }
15
+ };
16
+ const readJson = async (filePath)=>JSON.parse(await promises.readFile(filePath, 'utf-8'));
17
+ const verifyCloudflareOutput = async (options)=>{
18
+ const outputDirectory = node_path.resolve(options.outputDirectory);
19
+ const issues = [];
20
+ const outputPlan = createCloudflareOutputPlan(outputDirectory);
21
+ for (const relativePath of outputPlan.requiredFiles){
22
+ const filePath = node_path.join(outputDirectory, relativePath);
23
+ if (!await pathExists(filePath)) addIssue(issues, {
24
+ code: 'missing-file',
25
+ message: `Cloudflare output is missing ${relativePath}.`,
26
+ path: filePath
27
+ });
28
+ }
29
+ const manifestPath = outputPlan.paths.workerManifest;
30
+ const wranglerPath = outputPlan.paths.wranglerConfig;
31
+ const packagePath = outputPlan.paths.outputPackage;
32
+ const workerPackagePath = outputPlan.paths.workerPackage;
33
+ const manifest = await pathExists(manifestPath) ? await readJson(manifestPath) : void 0;
34
+ const wrangler = await pathExists(wranglerPath) ? await readJson(wranglerPath) : void 0;
35
+ const outputPackage = await pathExists(packagePath) ? await readJson(packagePath) : void 0;
36
+ const workerPackage = await pathExists(workerPackagePath) ? await readJson(workerPackagePath) : void 0;
37
+ if (manifest) {
38
+ verifyManifestShape(issues, manifest, manifestPath);
39
+ verifyDeliveryUnitIdentity(issues, manifest, manifestPath, options.deliveryUnit);
40
+ const workerReferences = getWorkerBundleReferences(manifest);
41
+ if (workerReferences.length > 0 && !await pathExists(workerPackagePath)) addIssue(issues, {
42
+ code: 'missing-file',
43
+ message: 'Cloudflare output is missing worker/package.json for referenced worker bundles.',
44
+ path: workerPackagePath
45
+ });
46
+ if (manifest.bff?.runtimeFramework === 'effect' && !getEffectBffWorker(manifest)) addIssue(issues, {
47
+ code: 'missing-worker-bundle',
48
+ message: 'Cloudflare Effect BFF manifest points to a missing worker bundle.'
49
+ });
50
+ for (const workerReference of workerReferences){
51
+ const resolvedWorker = resolveWorkerBundleReference(issues, outputDirectory, workerReference, manifestPath);
52
+ if (!resolvedWorker) continue;
53
+ const workerExists = await pathExists(resolvedWorker.path);
54
+ if (!workerExists) addIssue(issues, {
55
+ code: 'missing-worker-bundle',
56
+ message: missingWorkerBundleMessage(workerReference),
57
+ path: resolvedWorker.path
58
+ });
59
+ if (workerExists) {
60
+ const workerSource = await promises.readFile(resolvedWorker.path, 'utf-8');
61
+ verifyWorkerBundleReferences(issues, resolvedWorker, workerSource);
62
+ if ('effect-bff' === resolvedWorker.kind && (workerSource.includes(';entityKind;') || workerSource.includes(';entityKind,entityKind;'))) addIssue(issues, {
63
+ code: 'invalid-worker-bundle',
64
+ message: 'Cloudflare Effect BFF worker bundle contains invalid Drizzle entityKind marker references.',
65
+ path: resolvedWorker.path
66
+ });
67
+ }
68
+ }
69
+ }
70
+ if (wrangler) {
71
+ assertEqual(issues, wrangler.main, outputPlan.wrangler.main, {
72
+ code: 'invalid-wrangler',
73
+ message: `wrangler.json main must be ${outputPlan.wrangler.main}.`,
74
+ path: wranglerPath
75
+ });
76
+ assertEqual(issues, wrangler.assets?.binding, outputPlan.wrangler.assets.binding, {
77
+ code: 'invalid-wrangler',
78
+ message: 'wrangler.json assets.binding must be ASSETS.',
79
+ path: wranglerPath
80
+ });
81
+ assertEqual(issues, wrangler.assets?.directory, outputPlan.wrangler.assets.directory, {
82
+ code: 'invalid-wrangler',
83
+ message: 'wrangler.json assets.directory must be ./public.',
84
+ path: wranglerPath
85
+ });
86
+ assertEqual(issues, wrangler.assets?.run_worker_first, outputPlan.wrangler.assets.run_worker_first, {
87
+ code: 'invalid-wrangler',
88
+ message: 'wrangler.json assets.run_worker_first must be true.',
89
+ path: wranglerPath
90
+ });
91
+ for (const flag of outputPlan.wrangler.requiredCompatibilityFlags)assertFlag(issues, wrangler.compatibility_flags, flag, {
92
+ code: 'invalid-wrangler',
93
+ message: `wrangler.json compatibility_flags must include ${flag}.`,
94
+ path: wranglerPath
95
+ });
96
+ }
97
+ if (outputPackage) assertEqual(issues, outputPackage.type, outputPlan.packages.output.type, {
98
+ code: 'invalid-package',
99
+ message: '.output/package.json must declare type module.',
100
+ path: packagePath
101
+ });
102
+ if (workerPackage) assertEqual(issues, workerPackage.type, outputPlan.packages.worker.type, {
103
+ code: 'invalid-package',
104
+ message: '.output/worker/package.json must declare type commonjs.',
105
+ path: workerPackagePath
106
+ });
107
+ for (const leakedPath of outputPlan.publicLeakDirectories){
108
+ const publicPath = node_path.join(outputPlan.paths.publicAssets, leakedPath);
109
+ if (await pathExists(publicPath)) addIssue(issues, {
110
+ code: 'public-output-leak',
111
+ message: `Framework-owned ${leakedPath} output leaked into public assets.`,
112
+ path: publicPath
113
+ });
114
+ }
115
+ if (false !== options.importWorker && await pathExists(outputPlan.paths.workerEntry)) await verifyWorkerImport(issues, outputPlan.paths.workerEntry);
116
+ return {
117
+ ok: 0 === issues.length,
118
+ issues
119
+ };
120
+ };
121
+ const assertCloudflareOutput = async (options)=>{
122
+ const result = await verifyCloudflareOutput(options);
123
+ if (!result.ok) throw new Error([
124
+ 'Cloudflare output verification failed:',
125
+ ...result.issues.map((issue)=>`- ${issue.code}: ${issue.message}${issue.path ? ` (${issue.path})` : ''}`)
126
+ ].join('\n'));
127
+ };
128
+ export { verifyCloudflareOutputMutationPolicy } from "./mutation-policy.mjs";
129
+ export { assertCloudflareOutput, verifyCloudflareOutput };
@@ -0,0 +1,10 @@
1
+ const addIssue = (issues, issue)=>{
2
+ issues.push(issue);
3
+ };
4
+ const assertEqual = (issues, actual, expected, issue)=>{
5
+ if (actual !== expected) addIssue(issues, issue);
6
+ };
7
+ const assertFlag = (issues, flags, flag, issue)=>{
8
+ if (!Array.isArray(flags) || !flags.includes(flag)) addIssue(issues, issue);
9
+ };
10
+ export { addIssue, assertEqual, assertFlag };
@@ -0,0 +1,45 @@
1
+ import { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_ENTRY } from "../cloudflare-output-contract.mjs";
2
+ import { addIssue, assertEqual } from "./issues.mjs";
3
+ const verifyManifestShape = (issues, manifest, manifestPath)=>{
4
+ assertEqual(issues, manifest.runtime?.type, CLOUDFLARE_RUNTIME_TYPE, {
5
+ code: 'invalid-manifest',
6
+ message: 'Cloudflare output manifest runtime.type must be cloudflare-module-worker.',
7
+ path: manifestPath
8
+ });
9
+ assertEqual(issues, manifest.runtime?.entry, CLOUDFLARE_WORKER_ENTRY, {
10
+ code: 'invalid-manifest',
11
+ message: `Cloudflare output manifest runtime.entry must be ${CLOUDFLARE_WORKER_ENTRY}.`,
12
+ path: manifestPath
13
+ });
14
+ assertEqual(issues, manifest.runtime?.fetchExport, true, {
15
+ code: 'invalid-manifest',
16
+ message: 'Cloudflare output manifest runtime.fetchExport must be true.',
17
+ path: manifestPath
18
+ });
19
+ assertEqual(issues, manifest.runtime?.nodeListen, false, {
20
+ code: 'invalid-manifest',
21
+ message: 'Cloudflare output manifest runtime.nodeListen must be false.',
22
+ path: manifestPath
23
+ });
24
+ assertEqual(issues, manifest.assets?.binding, CLOUDFLARE_ASSETS_BINDING, {
25
+ code: 'invalid-manifest',
26
+ message: 'Cloudflare output manifest assets.binding must be ASSETS.',
27
+ path: manifestPath
28
+ });
29
+ assertEqual(issues, manifest.assets?.directory, `./${CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY}`, {
30
+ code: 'invalid-manifest',
31
+ message: 'Cloudflare output manifest assets.directory must be ./public.',
32
+ path: manifestPath
33
+ });
34
+ assertEqual(issues, manifest.assets?.runWorkerFirst, true, {
35
+ code: 'invalid-manifest',
36
+ message: 'Cloudflare output manifest assets.runWorkerFirst must be true.',
37
+ path: manifestPath
38
+ });
39
+ if (!Array.isArray(manifest.routeSpec?.routes)) addIssue(issues, {
40
+ code: 'invalid-manifest',
41
+ message: 'Cloudflare output manifest routeSpec.routes must be array.',
42
+ path: manifestPath
43
+ });
44
+ };
45
+ export { verifyManifestShape };