@kubohiroya/turbowarp-http-server 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/README.ja.md +29 -13
  2. package/README.md +101 -42
  3. package/dist/cli.js +131 -17
  4. package/dist/cli.js.map +1 -1
  5. package/dist/compiler/adapters/cloudflare.d.ts +2 -0
  6. package/dist/compiler/adapters/cloudflare.js +477 -0
  7. package/dist/compiler/adapters/cloudflare.js.map +1 -0
  8. package/dist/compiler/adapters/firebase.d.ts +2 -0
  9. package/dist/compiler/adapters/firebase.js +489 -0
  10. package/dist/compiler/adapters/firebase.js.map +1 -0
  11. package/dist/compiler/adapters/index.d.ts +2 -0
  12. package/dist/compiler/adapters/index.js +3 -0
  13. package/dist/compiler/adapters/index.js.map +1 -0
  14. package/dist/compiler/binary/codec.d.ts +4 -0
  15. package/dist/compiler/binary/codec.js +45 -0
  16. package/dist/compiler/binary/codec.js.map +1 -0
  17. package/dist/compiler/binary/error.d.ts +3 -0
  18. package/dist/compiler/binary/error.js +21 -0
  19. package/dist/compiler/binary/error.js.map +1 -0
  20. package/dist/compiler/binary/index.d.ts +4 -0
  21. package/dist/compiler/binary/index.js +5 -0
  22. package/dist/compiler/binary/index.js.map +1 -0
  23. package/dist/compiler/binary/runtime.d.ts +18 -0
  24. package/dist/compiler/binary/runtime.js +123 -0
  25. package/dist/compiler/binary/runtime.js.map +1 -0
  26. package/dist/compiler/binary/types.d.ts +17 -0
  27. package/dist/compiler/binary/types.js +2 -0
  28. package/dist/compiler/binary/types.js.map +1 -0
  29. package/dist/compiler/feature-flags.d.ts +4 -0
  30. package/dist/compiler/feature-flags.js +4 -0
  31. package/dist/compiler/feature-flags.js.map +1 -0
  32. package/dist/compiler/index.d.ts +35 -0
  33. package/dist/compiler/index.js +84 -0
  34. package/dist/compiler/index.js.map +1 -0
  35. package/dist/compiler/ir-v2/canonical.d.ts +3 -0
  36. package/dist/compiler/ir-v2/canonical.js +50 -0
  37. package/dist/compiler/ir-v2/canonical.js.map +1 -0
  38. package/dist/compiler/ir-v2/index.d.ts +4 -0
  39. package/dist/compiler/ir-v2/index.js +5 -0
  40. package/dist/compiler/ir-v2/index.js.map +1 -0
  41. package/dist/compiler/ir-v2/parse.d.ts +10 -0
  42. package/dist/compiler/ir-v2/parse.js +753 -0
  43. package/dist/compiler/ir-v2/parse.js.map +1 -0
  44. package/dist/compiler/ir-v2/strict-json.d.ts +4 -0
  45. package/dist/compiler/ir-v2/strict-json.js +133 -0
  46. package/dist/compiler/ir-v2/strict-json.js.map +1 -0
  47. package/dist/compiler/ir-v2/types.d.ts +412 -0
  48. package/dist/compiler/ir-v2/types.js +84 -0
  49. package/dist/compiler/ir-v2/types.js.map +1 -0
  50. package/dist/compiler/kvs/lowering.d.ts +13 -0
  51. package/dist/compiler/kvs/lowering.js +77 -0
  52. package/dist/compiler/kvs/lowering.js.map +1 -0
  53. package/dist/compiler/manifest/error.d.ts +7 -0
  54. package/dist/compiler/manifest/error.js +9 -0
  55. package/dist/compiler/manifest/error.js.map +1 -0
  56. package/dist/compiler/manifest/index.d.ts +6 -0
  57. package/dist/compiler/manifest/index.js +7 -0
  58. package/dist/compiler/manifest/index.js.map +1 -0
  59. package/dist/compiler/manifest/operations.d.ts +12 -0
  60. package/dist/compiler/manifest/operations.js +60 -0
  61. package/dist/compiler/manifest/operations.js.map +1 -0
  62. package/dist/compiler/manifest/parse.d.ts +9 -0
  63. package/dist/compiler/manifest/parse.js +280 -0
  64. package/dist/compiler/manifest/parse.js.map +1 -0
  65. package/dist/compiler/manifest/registry.d.ts +3 -0
  66. package/dist/compiler/manifest/registry.js +48 -0
  67. package/dist/compiler/manifest/registry.js.map +1 -0
  68. package/dist/compiler/manifest/resolve.d.ts +14 -0
  69. package/dist/compiler/manifest/resolve.js +116 -0
  70. package/dist/compiler/manifest/resolve.js.map +1 -0
  71. package/dist/compiler/manifest/types.d.ts +95 -0
  72. package/dist/compiler/manifest/types.js +3 -0
  73. package/dist/compiler/manifest/types.js.map +1 -0
  74. package/dist/compiler/named-body/index.d.ts +1 -0
  75. package/dist/compiler/named-body/index.js +2 -0
  76. package/dist/compiler/named-body/index.js.map +1 -0
  77. package/dist/compiler/named-body/lowering.d.ts +18 -0
  78. package/dist/compiler/named-body/lowering.js +83 -0
  79. package/dist/compiler/named-body/lowering.js.map +1 -0
  80. package/dist/compiler/pipeline/compiler.d.ts +18 -0
  81. package/dist/compiler/pipeline/compiler.js +105 -0
  82. package/dist/compiler/pipeline/compiler.js.map +1 -0
  83. package/dist/compiler/pipeline/core-generator.d.ts +3 -0
  84. package/dist/compiler/pipeline/core-generator.js +483 -0
  85. package/dist/compiler/pipeline/core-generator.js.map +1 -0
  86. package/dist/compiler/pipeline/index.d.ts +5 -0
  87. package/dist/compiler/pipeline/index.js +6 -0
  88. package/dist/compiler/pipeline/index.js.map +1 -0
  89. package/dist/compiler/pipeline/registry.d.ts +7 -0
  90. package/dist/compiler/pipeline/registry.js +17 -0
  91. package/dist/compiler/pipeline/registry.js.map +1 -0
  92. package/dist/compiler/pipeline/requirements.d.ts +9 -0
  93. package/dist/compiler/pipeline/requirements.js +135 -0
  94. package/dist/compiler/pipeline/requirements.js.map +1 -0
  95. package/dist/compiler/pipeline/types.d.ts +65 -0
  96. package/dist/compiler/pipeline/types.js +2 -0
  97. package/dist/compiler/pipeline/types.js.map +1 -0
  98. package/dist/compiler/runtime/error.d.ts +6 -0
  99. package/dist/compiler/runtime/error.js +9 -0
  100. package/dist/compiler/runtime/error.js.map +1 -0
  101. package/dist/compiler/runtime/index.d.ts +1 -0
  102. package/dist/compiler/runtime/index.js +2 -0
  103. package/dist/compiler/runtime/index.js.map +1 -0
  104. package/dist/compiler/structured-data/index.d.ts +3 -0
  105. package/dist/compiler/structured-data/index.js +4 -0
  106. package/dist/compiler/structured-data/index.js.map +1 -0
  107. package/dist/compiler/structured-data/lowering.d.ts +30 -0
  108. package/dist/compiler/structured-data/lowering.js +202 -0
  109. package/dist/compiler/structured-data/lowering.js.map +1 -0
  110. package/dist/compiler/structured-data/path.d.ts +2 -0
  111. package/dist/compiler/structured-data/path.js +60 -0
  112. package/dist/compiler/structured-data/path.js.map +1 -0
  113. package/dist/compiler/structured-data/runtime.d.ts +20 -0
  114. package/dist/compiler/structured-data/runtime.js +210 -0
  115. package/dist/compiler/structured-data/runtime.js.map +1 -0
  116. package/dist/compiler/turbowarp-v2.d.ts +8 -0
  117. package/dist/compiler/turbowarp-v2.js +479 -0
  118. package/dist/compiler/turbowarp-v2.js.map +1 -0
  119. package/dist/compiler/validator/index.d.ts +4 -0
  120. package/dist/compiler/validator/index.js +5 -0
  121. package/dist/compiler/validator/index.js.map +1 -0
  122. package/dist/compiler/validator/ir-validator.d.ts +10 -0
  123. package/dist/compiler/validator/ir-validator.js +463 -0
  124. package/dist/compiler/validator/ir-validator.js.map +1 -0
  125. package/dist/compiler/validator/resource-lifetime.d.ts +18 -0
  126. package/dist/compiler/validator/resource-lifetime.js +106 -0
  127. package/dist/compiler/validator/resource-lifetime.js.map +1 -0
  128. package/dist/compiler/validator/turbowarp-subset.d.ts +3 -0
  129. package/dist/compiler/validator/turbowarp-subset.js +241 -0
  130. package/dist/compiler/validator/turbowarp-subset.js.map +1 -0
  131. package/dist/compiler/validator/types.d.ts +30 -0
  132. package/dist/compiler/validator/types.js +7 -0
  133. package/dist/compiler/validator/types.js.map +1 -0
  134. package/dist/config.d.ts +11 -0
  135. package/dist/config.js +12 -0
  136. package/dist/config.js.map +1 -0
  137. package/dist/digest-cli.js +0 -0
  138. package/dist/extension-manifest.json +102 -0
  139. package/dist/named-body.d.ts +57 -0
  140. package/dist/named-body.js +396 -0
  141. package/dist/named-body.js.map +1 -0
  142. package/dist/named-data-namespace.d.ts +3 -0
  143. package/dist/named-data-namespace.js +6 -0
  144. package/dist/named-data-namespace.js.map +1 -0
  145. package/dist/protocol.d.ts +13 -1
  146. package/dist/protocol.js +34 -0
  147. package/dist/protocol.js.map +1 -1
  148. package/dist/resource-named-body-provider.d.ts +8 -0
  149. package/dist/resource-named-body-provider.js +88 -0
  150. package/dist/resource-named-body-provider.js.map +1 -0
  151. package/dist/server.d.ts +10 -1
  152. package/dist/server.js +37 -7
  153. package/dist/server.js.map +1 -1
  154. package/dist/turbowarp-http-server.js +516 -1
  155. package/docs/binary-resource-semantics.ja.md +84 -0
  156. package/docs/cloudflare-worker-compiler.ja.md +90 -0
  157. package/docs/compiler-manifest-registry.ja.md +79 -0
  158. package/docs/compiler-platform-pipeline.ja.md +94 -0
  159. package/docs/deploy-ir-v2.ja.md +123 -0
  160. package/docs/fixed-input-editors.ja.md +23 -0
  161. package/docs/index.html +80 -0
  162. package/docs/ir-v2-conformance.ja.md +65 -0
  163. package/docs/named-response-body.ja.md +120 -0
  164. package/docs/platform-storage-adapters.ja.md +99 -0
  165. package/docs/server-executable-subset.ja.md +88 -0
  166. package/docs/structured-data-lowering.ja.md +63 -0
  167. package/examples/compiler/message-app.v2.ir.json +41 -0
  168. package/package.json +44 -20
  169. package/schemas/block-editor-fixed-inputs.schema.json +85 -0
  170. package/schemas/compiler-extension-manifest.schema.json +126 -0
  171. package/schemas/compiler-manifest-lock-v1.schema.json +48 -0
  172. package/schemas/deploy-ir-v2.schema.json +835 -0
  173. package/schemas/ir-v2-conformance-fixture.schema.json +44 -0
  174. package/src/block-definitions.json +76 -0
  175. package/src/cli.ts +136 -23
  176. package/src/compiler/adapters/cloudflare.ts +510 -0
  177. package/src/compiler/adapters/firebase.ts +538 -0
  178. package/src/compiler/adapters/index.ts +2 -0
  179. package/src/compiler/binary/codec.ts +61 -0
  180. package/src/compiler/binary/error.ts +25 -0
  181. package/src/compiler/binary/index.ts +4 -0
  182. package/src/compiler/binary/runtime.ts +133 -0
  183. package/src/compiler/binary/types.ts +26 -0
  184. package/src/compiler/feature-flags.ts +7 -0
  185. package/src/compiler/index.ts +114 -0
  186. package/src/compiler/ir-v2/canonical.ts +46 -0
  187. package/src/compiler/ir-v2/index.ts +9 -0
  188. package/src/compiler/ir-v2/parse.ts +921 -0
  189. package/src/compiler/ir-v2/strict-json.ts +129 -0
  190. package/src/compiler/ir-v2/types.ts +462 -0
  191. package/src/compiler/kvs/lowering.ts +88 -0
  192. package/src/compiler/manifest/error.ts +29 -0
  193. package/src/compiler/manifest/index.ts +17 -0
  194. package/src/compiler/manifest/operations.ts +175 -0
  195. package/src/compiler/manifest/parse.ts +390 -0
  196. package/src/compiler/manifest/registry.ts +74 -0
  197. package/src/compiler/manifest/resolve.ts +159 -0
  198. package/src/compiler/manifest/types.ts +112 -0
  199. package/src/compiler/named-body/index.ts +1 -0
  200. package/src/compiler/named-body/lowering.ts +186 -0
  201. package/src/compiler/pipeline/compiler.ts +138 -0
  202. package/src/compiler/pipeline/core-generator.ts +486 -0
  203. package/src/compiler/pipeline/index.ts +5 -0
  204. package/src/compiler/pipeline/registry.ts +18 -0
  205. package/src/compiler/pipeline/requirements.ts +139 -0
  206. package/src/compiler/pipeline/types.ts +59 -0
  207. package/src/compiler/runtime/error.ts +11 -0
  208. package/src/compiler/runtime/index.ts +1 -0
  209. package/src/compiler/structured-data/index.ts +3 -0
  210. package/src/compiler/structured-data/lowering.ts +314 -0
  211. package/src/compiler/structured-data/path.ts +53 -0
  212. package/src/compiler/structured-data/runtime.ts +221 -0
  213. package/src/compiler/turbowarp-v2.ts +610 -0
  214. package/src/compiler/validator/index.ts +4 -0
  215. package/src/compiler/validator/ir-validator.ts +812 -0
  216. package/src/compiler/validator/resource-lifetime.ts +153 -0
  217. package/src/compiler/validator/turbowarp-subset.ts +387 -0
  218. package/src/compiler/validator/types.ts +68 -0
  219. package/src/extension.ts +87 -1
  220. package/src/fixed-input-editors.ts +181 -0
  221. package/src/fixed-input-schema.ts +15 -0
  222. package/src/named-body.ts +495 -0
  223. package/src/named-data-namespace.ts +6 -0
  224. package/src/protocol.ts +50 -1
  225. package/src/resource-named-body-provider.ts +106 -0
  226. package/src/server.ts +88 -8
  227. package/docs/turbowarp-http-server.architecture.visual-check.1440x900.dark.png +0 -0
  228. package/docs/turbowarp-http-server.architecture.visual-check.1440x900.light.png +0 -0
  229. package/docs/turbowarp-http-server.architecture.visual-check.2048x1320.dark.png +0 -0
  230. package/docs/turbowarp-http-server.architecture.visual-check.2048x1320.light.png +0 -0
  231. package/docs/turbowarp-http-server.architecture.visual-check.html +0 -32
  232. package/docs/turbowarp-http-server.architecture.visual-check.json +0 -547
  233. package/schemas/extension-manifest.schema.json +0 -49
  234. package/src/extension-manifest.ts +0 -149
@@ -0,0 +1,479 @@
1
+ import { extensionConfig } from '../config.js';
2
+ import { DEPLOY_IR_V2_VERSION } from './ir-v2/types.js';
3
+ import { isKvsEntry, KvsLoweringContext } from './kvs/lowering.js';
4
+ import { lowerNamedBodyResponse } from './named-body/lowering.js';
5
+ import { StructuredDataLoweringContext } from './structured-data/lowering.js';
6
+ import { validateTurboWarpServerSubset } from './validator/turbowarp-subset.js';
7
+ const PREFIX = `${extensionConfig.id}_`;
8
+ const HAT_OPCODE = `${PREFIX}whenHttpRequestReceived`;
9
+ const NAMED_RESPONSE_OPCODE = `${PREFIX}respondWithNamedBody`;
10
+ const METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']);
11
+ /** Compiles the locked server-executable TurboWarp subset directly into typed IR v2. */
12
+ export function compileTurboWarpProjectV2(value, registry) {
13
+ const subsetDiagnostics = validateTurboWarpServerSubset(value, registry).map(toCompilerDiagnostic);
14
+ if (subsetDiagnostics.length > 0)
15
+ return { ir: emptyIr(), diagnostics: subsetDiagnostics };
16
+ const project = object(value);
17
+ if (!Array.isArray(project.targets))
18
+ throw new Error('TurboWarp project.targets must be an array.');
19
+ const diagnostics = [];
20
+ const capabilities = [];
21
+ const routes = [];
22
+ const structured = new StructuredDataLoweringContext();
23
+ let discoveredHandlers = 0;
24
+ project.targets.forEach((rawTarget, targetIndex) => {
25
+ const target = object(rawTarget);
26
+ const targetName = typeof target.name === 'string' ? target.name : `target-${targetIndex}`;
27
+ const blocks = blockMap(target.blocks);
28
+ const path = target.isStage === true ? '/' : `/${routeSegment(targetName)}`;
29
+ const context = {
30
+ blocks,
31
+ targetIndex,
32
+ targetName,
33
+ ...(registry === undefined ? {} : { registry }),
34
+ diagnostics,
35
+ capabilities
36
+ };
37
+ for (const [hatId, hat] of Object.entries(blocks)) {
38
+ if (hat.opcode !== HAT_OPCODE || hat.topLevel !== true)
39
+ continue;
40
+ discoveredHandlers += 1;
41
+ const firstId = blockId(hat.next);
42
+ const hatSource = sourceRef(context, hatId, HAT_OPCODE);
43
+ if (firstId === null) {
44
+ report(context, 'TW2_EMPTY_HANDLER', 'HTTP request hat has no handler body.', hatSource);
45
+ continue;
46
+ }
47
+ const first = blocks[firstId];
48
+ const route = first?.opcode === 'control_if'
49
+ ? compileMethodGuard(context, firstId, path, hatSource, routes.length, structured)
50
+ : compileRouteBody(context, firstId, 'ALL', path, hatSource, routes.length, structured);
51
+ if (route !== null)
52
+ routes.push(route);
53
+ }
54
+ });
55
+ diagnostics.push(...structured.diagnostics);
56
+ if (discoveredHandlers === 0) {
57
+ diagnostics.push({
58
+ severity: 'error',
59
+ code: 'TW2_NO_ROUTES',
60
+ message: 'No compilable HTTP request handlers were found.'
61
+ });
62
+ }
63
+ rejectDuplicateRoutes(routes, diagnostics);
64
+ return {
65
+ ir: {
66
+ version: DEPLOY_IR_V2_VERSION,
67
+ name: 'turbowarp-worker',
68
+ auth: { kind: 'none' },
69
+ capabilities: deduplicateCapabilities(capabilities),
70
+ routes
71
+ },
72
+ diagnostics
73
+ };
74
+ }
75
+ function compileMethodGuard(context, guardId, path, hatSource, routeIndex, structured) {
76
+ const guard = context.blocks[guardId];
77
+ if (guard === undefined)
78
+ return null;
79
+ const inputs = inputMap(guard.inputs);
80
+ const conditionId = inputBlockId(inputs.CONDITION);
81
+ const bodyId = inputBlockId(inputs.SUBSTACK);
82
+ const method = conditionId === null ? null : readMethodCondition(context.blocks, conditionId);
83
+ if (method === null || bodyId === null) {
84
+ report(context, 'TW2_UNSUPPORTED_GUARD', 'Top-level control_if must compare current HTTP method with GET, POST, PUT, PATCH, DELETE, or OPTIONS.', sourceRef(context, guardId, 'control_if'));
85
+ return null;
86
+ }
87
+ if (blockId(guard.next) !== null) {
88
+ report(context, 'TW2_UNSUPPORTED_CONTROL_FLOW', 'A method guard must be the only command after the HTTP request hat.', sourceRef(context, guardId, 'control_if'));
89
+ return null;
90
+ }
91
+ return compileRouteBody(context, bodyId, method, path, hatSource, routeIndex, structured);
92
+ }
93
+ function compileRouteBody(context, firstId, method, path, hatSource, routeIndex, structured) {
94
+ const body = compileStack(context, firstId, structured, true);
95
+ if (body === null)
96
+ return null;
97
+ return {
98
+ id: routeId(context.targetName, method.toLowerCase(), routeIndex),
99
+ method,
100
+ path,
101
+ auth: 'public',
102
+ body,
103
+ sourceRef: hatSource
104
+ };
105
+ }
106
+ function compileStack(context, firstId, structured, requireResponse) {
107
+ const statements = [];
108
+ const visited = new Set();
109
+ let id = firstId;
110
+ while (id !== null) {
111
+ if (visited.has(id)) {
112
+ report(context, 'TW2_BLOCK_CYCLE', 'Handler block chain contains a cycle.', blockSource(context, id));
113
+ return null;
114
+ }
115
+ visited.add(id);
116
+ const block = context.blocks[id];
117
+ if (block === undefined || typeof block.opcode !== 'string') {
118
+ report(context, 'TW2_MISSING_BLOCK', `Handler references missing block ${id}.`, sourceRef(context, id, '<missing>'));
119
+ return null;
120
+ }
121
+ const statement = compileStatement(context, id, block, structured);
122
+ if (statement === null)
123
+ return null;
124
+ statements.push(statement);
125
+ id = blockId(block.next);
126
+ }
127
+ const responseIndex = statements.findIndex(isTerminalResponse);
128
+ if (requireResponse && responseIndex < 0) {
129
+ report(context, 'TW2_MISSING_RESPONSE', 'Every handler must end with a response block.', blockSource(context, firstId));
130
+ return null;
131
+ }
132
+ if (responseIndex >= 0 && responseIndex !== statements.length - 1) {
133
+ report(context, 'TW2_RESPONSE_NOT_LAST', 'The response block must be the final command.', blockSource(context, firstId));
134
+ return null;
135
+ }
136
+ return statements;
137
+ }
138
+ function compileStatement(context, id, block, structured) {
139
+ const opcode = block.opcode;
140
+ const inputs = inputMap(block.inputs);
141
+ const source = sourceRef(context, id, opcode);
142
+ if (opcode === 'control_repeat') {
143
+ const count = integerLiteral(inputs.TIMES);
144
+ const bodyId = inputBlockId(inputs.SUBSTACK);
145
+ if (count === null || count < 0 || count > 1000) {
146
+ report(context, 'TW2_LOOP_BOUND_INVALID', 'repeat requires an integer literal from 0 to 1000.', source);
147
+ return null;
148
+ }
149
+ const body = bodyId === null ? [] : compileStack(context, bodyId, structured, false);
150
+ return body === null ? null : { kind: 'bounded-loop', maxIterations: count, body, sourceRef: source };
151
+ }
152
+ const manifestEntry = context.registry?.byProjectOpcode.get(opcode);
153
+ if (manifestEntry?.block.blockType === 'LOOP') {
154
+ const bodyId = inputBlockId(inputs.SUBSTACK);
155
+ const args = compileManifestArguments(context, manifestEntry, inputs, id, structured);
156
+ if (args === null)
157
+ return null;
158
+ let bodyFailed = false;
159
+ const statement = structured.lowerForEach(manifestEntry, args, source, (nested) => {
160
+ const body = bodyId === null ? [] : compileStack(context, bodyId, nested, false);
161
+ if (body === null) {
162
+ bodyFailed = true;
163
+ return [];
164
+ }
165
+ return body;
166
+ });
167
+ return bodyFailed || statement === undefined ? null : statement;
168
+ }
169
+ if (opcode === `${PREFIX}setHttpStatus`) {
170
+ const status = Number(literalValue(inputs.STATUS));
171
+ if (!Number.isInteger(status) || status < 100 || status > 599) {
172
+ report(context, 'TW2_DYNAMIC_STATUS', 'HTTP status must be a literal integer from 100 to 599.', source);
173
+ return null;
174
+ }
175
+ return { kind: 'set-status', status, sourceRef: source };
176
+ }
177
+ if (opcode === `${PREFIX}setResponseHeader`) {
178
+ const name = literalValue(inputs.NAME).trim().toLowerCase();
179
+ if (!safeHeader(name)) {
180
+ report(context, 'TW2_UNSAFE_HEADER', `Unsafe or runtime-owned response header: ${name}`, source);
181
+ return null;
182
+ }
183
+ const value = compileExpression(context, inputs.VALUE, id, structured);
184
+ return value === null ? null : { kind: 'set-header', name, value, sourceRef: source };
185
+ }
186
+ if (opcode === `${PREFIX}removeResponseHeader`) {
187
+ const name = literalValue(inputs.NAME).trim().toLowerCase();
188
+ if (!safeHeader(name)) {
189
+ report(context, 'TW2_UNSAFE_HEADER', `Unsafe or runtime-owned response header: ${name}`, source);
190
+ return null;
191
+ }
192
+ return { kind: 'remove-header', name, sourceRef: source };
193
+ }
194
+ if (opcode === `${PREFIX}setHandlerVariable` || opcode === `${PREFIX}changeHandlerVariable`) {
195
+ const name = compileExpression(context, inputs.NAME, id, structured);
196
+ const value = compileExpression(context, opcode === `${PREFIX}setHandlerVariable` ? inputs.VALUE : inputs.AMOUNT, id, structured);
197
+ if (name === null || value === null)
198
+ return null;
199
+ return {
200
+ kind: opcode === `${PREFIX}setHandlerVariable` ? 'set-handler-variable' : 'change-handler-variable',
201
+ name,
202
+ value,
203
+ sourceRef: source
204
+ };
205
+ }
206
+ if (opcode === `${PREFIX}deleteHandlerVariable`) {
207
+ const name = compileExpression(context, inputs.NAME, id, structured);
208
+ return name === null ? null : { kind: 'delete-handler-variable', name, sourceRef: source };
209
+ }
210
+ if (opcode === `${PREFIX}clearHandlerVariables`)
211
+ return { kind: 'clear-handler-variables', sourceRef: source };
212
+ if (opcode === NAMED_RESPONSE_OPCODE) {
213
+ const lowered = lowerNamedBodyResponse(namedArguments(inputs, source), source);
214
+ context.diagnostics.push(...lowered.diagnostics);
215
+ if (lowered.statement !== undefined)
216
+ addCapability(context, { kind: 'named-body-provider' });
217
+ return lowered.statement ?? null;
218
+ }
219
+ const responseFormats = {
220
+ [`${PREFIX}respondWithText`]: 'text',
221
+ [`${PREFIX}respondWithHtml`]: 'html',
222
+ [`${PREFIX}respondWithJson`]: 'json',
223
+ [`${PREFIX}sendResponse`]: 'text'
224
+ };
225
+ const format = responseFormats[opcode];
226
+ if (format !== undefined) {
227
+ const body = compileExpression(context, inputs.BODY, id, structured);
228
+ return body === null ? null : { kind: 'respond', format, body, sourceRef: source };
229
+ }
230
+ if (manifestEntry !== undefined && isKvsEntry(manifestEntry)) {
231
+ const args = compileManifestArguments(context, manifestEntry, inputs, id, structured);
232
+ if (args === null)
233
+ return null;
234
+ const statement = new KvsLoweringContext(context.diagnostics).lowerStatement(manifestEntry, args, source);
235
+ if (statement !== undefined)
236
+ addCapability(context, { kind: 'key-value-store' });
237
+ return statement ?? null;
238
+ }
239
+ report(context, 'TW2_UNSUPPORTED_COMMAND', `Unsupported command block: ${opcode}`, source);
240
+ return null;
241
+ }
242
+ function compileExpression(context, input, ownerId, structured) {
243
+ const reporterId = inputBlockId(input);
244
+ if (reporterId === null)
245
+ return literal('string', literalValue(input), blockSource(context, ownerId));
246
+ const reporter = context.blocks[reporterId];
247
+ if (reporter === undefined || typeof reporter.opcode !== 'string') {
248
+ report(context, 'TW2_MISSING_REPORTER', `Expression references missing block ${reporterId}.`, blockSource(context, ownerId));
249
+ return null;
250
+ }
251
+ const source = sourceRef(context, reporterId, reporter.opcode);
252
+ const inputs = inputMap(reporter.inputs);
253
+ const simpleSources = {
254
+ [`${PREFIX}currentHttpMethod`]: 'method',
255
+ [`${PREFIX}currentRequestPath`]: 'path',
256
+ [`${PREFIX}currentRequestUrl`]: 'url',
257
+ [`${PREFIX}currentRequestBody`]: 'body-text',
258
+ [`${PREFIX}currentRequestContentType`]: 'content-type',
259
+ [`${PREFIX}currentRequestClientAddress`]: 'client-address'
260
+ };
261
+ const requestSource = simpleSources[reporter.opcode];
262
+ if (requestSource !== undefined) {
263
+ if (requestSource === 'client-address')
264
+ addCapability(context, { kind: 'request-metadata', field: 'client-address' });
265
+ return { kind: 'request', valueType: 'string', source: requestSource, sourceRef: source };
266
+ }
267
+ const namedSources = {
268
+ [`${PREFIX}queryParameter`]: 'query',
269
+ [`${PREFIX}pathParameter`]: 'path-param',
270
+ [`${PREFIX}requestHeader`]: 'header'
271
+ };
272
+ const namedSource = namedSources[reporter.opcode];
273
+ if (namedSource !== undefined) {
274
+ if (inputBlockId(inputs.NAME) !== null) {
275
+ report(context, 'TW2_DYNAMIC_LOOKUP_NAME', 'Request lookup names must be non-empty literals.', source);
276
+ return null;
277
+ }
278
+ const name = literalValue(inputs.NAME);
279
+ if (name.length === 0) {
280
+ report(context, 'TW2_DYNAMIC_LOOKUP_NAME', 'Request lookup names must be non-empty literals.', source);
281
+ return null;
282
+ }
283
+ return { kind: 'request-value', valueType: 'string', source: namedSource, name, sourceRef: source };
284
+ }
285
+ if (reporter.opcode === 'operator_join') {
286
+ const left = compileExpression(context, inputs.STRING1, reporterId, structured);
287
+ const right = compileExpression(context, inputs.STRING2, reporterId, structured);
288
+ return left === null || right === null
289
+ ? null
290
+ : { kind: 'concat', valueType: 'string', left, right, sourceRef: source };
291
+ }
292
+ if (reporter.opcode === `${PREFIX}handlerVariable` || reporter.opcode === `${PREFIX}handlerVariableExists`) {
293
+ const name = compileExpression(context, inputs.NAME, reporterId, structured);
294
+ if (name === null)
295
+ return null;
296
+ return reporter.opcode === `${PREFIX}handlerVariable`
297
+ ? { kind: 'handler-variable', valueType: { kind: 'union', members: ['number', 'string'] }, name, sourceRef: source }
298
+ : { kind: 'handler-variable-exists', valueType: 'boolean', name, sourceRef: source };
299
+ }
300
+ if (reporter.opcode === `${PREFIX}listHandlerVariables`) {
301
+ return { kind: 'handler-variable-names', valueType: 'string', sourceRef: source };
302
+ }
303
+ const manifestEntry = context.registry?.byProjectOpcode.get(reporter.opcode);
304
+ if (manifestEntry !== undefined) {
305
+ const args = compileManifestArguments(context, manifestEntry, inputs, reporterId, structured);
306
+ if (args === null)
307
+ return null;
308
+ if (isKvsEntry(manifestEntry)) {
309
+ const expression = new KvsLoweringContext(context.diagnostics).lowerReporter(manifestEntry, args, source);
310
+ if (expression !== undefined)
311
+ addCapability(context, { kind: 'key-value-store' });
312
+ return expression ?? null;
313
+ }
314
+ return structured.lowerReporter(manifestEntry, args, source) ?? null;
315
+ }
316
+ report(context, 'TW2_UNSUPPORTED_REPORTER', `Unsupported reporter block: ${reporter.opcode}`, source);
317
+ return null;
318
+ }
319
+ function compileManifestArguments(context, entry, inputs, ownerId, structured) {
320
+ const args = {};
321
+ for (const argument of entry.block.arguments) {
322
+ const input = inputs[argument.id];
323
+ if (argument.type === 'NUMBER' && inputBlockId(input) === null) {
324
+ args[argument.id] = literal('number', Number(literalValue(input)), undefined);
325
+ continue;
326
+ }
327
+ const expression = compileExpression(context, input, ownerId, structured);
328
+ if (expression === null)
329
+ return null;
330
+ args[argument.id] = expression;
331
+ }
332
+ return args;
333
+ }
334
+ function readMethodCondition(blocks, id) {
335
+ const condition = blocks[id];
336
+ if (condition?.opcode !== 'operator_equals')
337
+ return null;
338
+ const inputs = inputMap(condition.inputs);
339
+ for (const [reporterInput, literalInput] of [
340
+ [inputs.OPERAND1, inputs.OPERAND2],
341
+ [inputs.OPERAND2, inputs.OPERAND1]
342
+ ]) {
343
+ const reporterId = inputBlockId(reporterInput);
344
+ const reporter = reporterId === null ? undefined : blocks[reporterId];
345
+ if (reporter?.opcode !== `${PREFIX}currentHttpMethod`)
346
+ continue;
347
+ const method = literalValue(literalInput).toUpperCase();
348
+ if (METHODS.has(method))
349
+ return method;
350
+ }
351
+ return null;
352
+ }
353
+ function namedArguments(inputs, source) {
354
+ return {
355
+ NAMESPACE: scratchLiteral(inputs.NAMESPACE, 'string', source),
356
+ NAME: scratchLiteral(inputs.NAME, 'string', source),
357
+ KIND: scratchLiteral(inputs.KIND, 'string', source),
358
+ SCOPE: scratchLiteral(inputs.SCOPE, 'string', source),
359
+ TARGET_ID: scratchLiteral(inputs.TARGET_ID, 'string', source),
360
+ REPRESENTATION: scratchLiteral(inputs.REPRESENTATION, 'string', source),
361
+ MAX_BYTES: scratchLiteral(inputs.MAX_BYTES, 'number', source)
362
+ };
363
+ }
364
+ function scratchLiteral(input, expected, source) {
365
+ if (inputBlockId(input) !== null)
366
+ return { kind: 'request', valueType: 'string', source: 'path', sourceRef: source };
367
+ const raw = literalValue(input);
368
+ return expected === 'number' ? literal('number', Number(raw), source) : literal('string', raw, source);
369
+ }
370
+ function literal(valueType, value, source) {
371
+ return { kind: 'literal', valueType, value, ...(source === undefined ? {} : { sourceRef: source }) };
372
+ }
373
+ function integerLiteral(input) {
374
+ if (inputBlockId(input) !== null)
375
+ return null;
376
+ const raw = literalValue(input);
377
+ if (!/^-?\d+$/u.test(raw))
378
+ return null;
379
+ const value = Number(raw);
380
+ return Number.isSafeInteger(value) ? value : null;
381
+ }
382
+ function isTerminalResponse(statement) {
383
+ return statement.kind === 'respond' || statement.kind === 'respond-binary' || statement.kind === 'respond-named-body';
384
+ }
385
+ function rejectDuplicateRoutes(routes, diagnostics) {
386
+ const seen = new Set();
387
+ for (const route of routes) {
388
+ const key = `${route.method} ${route.path}`;
389
+ if (seen.has(key)) {
390
+ diagnostics.push({
391
+ severity: 'error',
392
+ code: 'TW2_DUPLICATE_ROUTE',
393
+ message: `Duplicate route: ${key}`,
394
+ ...(route.sourceRef === undefined ? {} : { sourceRef: route.sourceRef })
395
+ });
396
+ }
397
+ seen.add(key);
398
+ }
399
+ }
400
+ function deduplicateCapabilities(capabilities) {
401
+ const entries = new Map();
402
+ for (const capability of capabilities)
403
+ entries.set(capabilityKey(capability), capability);
404
+ return [...entries.entries()]
405
+ .sort(([left], [right]) => left.localeCompare(right))
406
+ .map(([, capability]) => capability);
407
+ }
408
+ function addCapability(context, capability) {
409
+ context.capabilities.push(capability);
410
+ }
411
+ function report(context, code, message, source) {
412
+ context.diagnostics.push({ severity: 'error', code, message, ...(source === undefined ? {} : { sourceRef: source }) });
413
+ }
414
+ function sourceRef(context, blockIdValue, opcode) {
415
+ return { targetIndex: context.targetIndex, targetName: context.targetName, blockId: blockIdValue, opcode };
416
+ }
417
+ function blockSource(context, id) {
418
+ const opcode = context.blocks[id]?.opcode;
419
+ return sourceRef(context, id, typeof opcode === 'string' ? opcode : '<missing>');
420
+ }
421
+ function emptyIr() {
422
+ return { version: DEPLOY_IR_V2_VERSION, name: 'turbowarp-worker', auth: { kind: 'none' }, capabilities: [], routes: [] };
423
+ }
424
+ function capabilityKey(value) {
425
+ return JSON.stringify(value);
426
+ }
427
+ function safeHeader(name) {
428
+ return (/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u.test(name) &&
429
+ !['connection', 'content-length', 'transfer-encoding', 'upgrade'].includes(name));
430
+ }
431
+ function routeSegment(name) {
432
+ const normalized = name.normalize('NFKC').trim().toLowerCase().replace(/[^a-z0-9_-]+/gu, '-');
433
+ return normalized.replace(/^-+|-+$/gu, '') || 'sprite';
434
+ }
435
+ function routeId(target, method, index) {
436
+ return `${routeSegment(target)}-${method}-${index + 1}`;
437
+ }
438
+ function inputBlockId(value) {
439
+ if (!Array.isArray(value))
440
+ return null;
441
+ return typeof value[1] === 'string' ? value[1] : null;
442
+ }
443
+ function literalValue(value) {
444
+ if (!Array.isArray(value))
445
+ return '';
446
+ const primary = value[1];
447
+ if (Array.isArray(primary))
448
+ return String(primary[1] ?? '');
449
+ const shadow = value[2];
450
+ if (Array.isArray(shadow))
451
+ return String(shadow[1] ?? '');
452
+ return typeof primary === 'number' || typeof primary === 'boolean' ? String(primary) : '';
453
+ }
454
+ function inputMap(value) {
455
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
456
+ ? value
457
+ : {};
458
+ }
459
+ function blockMap(value) {
460
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : {};
461
+ }
462
+ function blockId(value) {
463
+ return typeof value === 'string' ? value : null;
464
+ }
465
+ function object(value) {
466
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
467
+ throw new Error('TurboWarp project value must be an object.');
468
+ }
469
+ return value;
470
+ }
471
+ function toCompilerDiagnostic(diagnostic) {
472
+ return {
473
+ severity: diagnostic.severity,
474
+ code: diagnostic.code,
475
+ message: diagnostic.message,
476
+ ...(diagnostic.sourceRef === undefined ? {} : { sourceRef: diagnostic.sourceRef })
477
+ };
478
+ }
479
+ //# sourceMappingURL=turbowarp-v2.js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AAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,SAAS,EAAE,UAAU,CAAC,SAAS,EAAC,CAAC;KACjF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { validateDeployIrV2Subset, targetCapabilityDiagnostic } from './ir-validator.js';
2
+ export { BinaryBodyLifetimeTracker } from './resource-lifetime.js';
3
+ export { validateTurboWarpServerSubset } from './turbowarp-subset.js';
4
+ export * from './types.js';
@@ -0,0 +1,5 @@
1
+ export { validateDeployIrV2Subset, targetCapabilityDiagnostic } from './ir-validator.js';
2
+ export { BinaryBodyLifetimeTracker } from './resource-lifetime.js';
3
+ export { validateTurboWarpServerSubset } from './turbowarp-subset.js';
4
+ export * from './types.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/compiler/validator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAE,0BAA0B,EAAC,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAC,yBAAyB,EAAC,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAC,6BAA6B,EAAC,MAAM,uBAAuB,CAAC;AACpE,cAAc,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { DeployIrV2, SourceRefV2 } from '../ir-v2/types.js';
2
+ import { type CompilerFeatureFlags } from '../feature-flags.js';
3
+ import { type ServerSubsetPolicy, type TargetCapabilityDiagnostic, type TargetNeutralDiagnostic } from './types.js';
4
+ export declare function validateDeployIrV2Subset(ir: DeployIrV2, policy?: Readonly<ServerSubsetPolicy>, featureFlags?: Readonly<CompilerFeatureFlags>): TargetNeutralDiagnostic[];
5
+ export declare function targetCapabilityDiagnostic(input: {
6
+ targetId: string;
7
+ routeId: string;
8
+ capability: string;
9
+ sourceRef?: SourceRefV2;
10
+ }): TargetCapabilityDiagnostic;