@harperfast/harper 5.2.0-alpha.6 → 5.2.0-beta.2

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 (276) hide show
  1. package/bin/cliOperations.ts +76 -12
  2. package/bin/run.ts +10 -0
  3. package/bin/status.ts +1 -1
  4. package/components/Application.ts +146 -83
  5. package/components/Scope.ts +4 -0
  6. package/components/componentLoader.ts +7 -0
  7. package/components/operations.js +21 -1
  8. package/config/configUtils.ts +139 -5
  9. package/config-app.schema.json +70 -0
  10. package/dataLayer/harperBridge/ResourceBridge.ts +7 -0
  11. package/dist/bin/cliOperations.js +76 -12
  12. package/dist/bin/cliOperations.js.map +1 -1
  13. package/dist/bin/run.js +9 -0
  14. package/dist/bin/run.js.map +1 -1
  15. package/dist/bin/status.js +1 -1
  16. package/dist/bin/status.js.map +1 -1
  17. package/dist/components/Application.d.ts +12 -5
  18. package/dist/components/Application.js +121 -60
  19. package/dist/components/Application.js.map +1 -1
  20. package/dist/components/Scope.d.ts +1 -0
  21. package/dist/components/Scope.js +4 -0
  22. package/dist/components/Scope.js.map +1 -1
  23. package/dist/components/componentLoader.js +7 -0
  24. package/dist/components/componentLoader.js.map +1 -1
  25. package/dist/components/operations.js +20 -1
  26. package/dist/components/operations.js.map +1 -1
  27. package/dist/config/configUtils.d.ts +31 -0
  28. package/dist/config/configUtils.js +127 -5
  29. package/dist/config/configUtils.js.map +1 -1
  30. package/dist/dataLayer/harperBridge/ResourceBridge.js +8 -0
  31. package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
  32. package/dist/resources/DatabaseTransaction.d.ts +12 -0
  33. package/dist/resources/DatabaseTransaction.js +97 -0
  34. package/dist/resources/DatabaseTransaction.js.map +1 -1
  35. package/dist/resources/RequestTarget.js +13 -3
  36. package/dist/resources/RequestTarget.js.map +1 -1
  37. package/dist/resources/Resource.js +21 -2
  38. package/dist/resources/Resource.js.map +1 -1
  39. package/dist/resources/Table.d.ts +3 -1
  40. package/dist/resources/Table.js +48 -5
  41. package/dist/resources/Table.js.map +1 -1
  42. package/dist/resources/analytics/metadata.d.ts +3 -0
  43. package/dist/resources/analytics/metadata.js +3 -0
  44. package/dist/resources/analytics/metadata.js.map +1 -1
  45. package/dist/resources/analytics/write.js +22 -0
  46. package/dist/resources/analytics/write.js.map +1 -1
  47. package/dist/resources/databases.js +21 -0
  48. package/dist/resources/databases.js.map +1 -1
  49. package/dist/resources/defineResource.js +20 -7
  50. package/dist/resources/defineResource.js.map +1 -1
  51. package/dist/resources/jsResource.d.ts +24 -0
  52. package/dist/resources/jsResource.js +58 -2
  53. package/dist/resources/jsResource.js.map +1 -1
  54. package/dist/resources/openApi.js +45 -20
  55. package/dist/resources/openApi.js.map +1 -1
  56. package/dist/resources/scheduler/CronExpression.d.ts +71 -0
  57. package/dist/resources/scheduler/CronExpression.js +367 -0
  58. package/dist/resources/scheduler/CronExpression.js.map +1 -0
  59. package/dist/resources/scheduler/engine.d.ts +91 -0
  60. package/dist/resources/scheduler/engine.js +767 -0
  61. package/dist/resources/scheduler/engine.js.map +1 -0
  62. package/dist/resources/scheduler/scheduler.d.ts +33 -0
  63. package/dist/resources/scheduler/scheduler.js +200 -0
  64. package/dist/resources/scheduler/scheduler.js.map +1 -0
  65. package/dist/security/auth.js +1 -0
  66. package/dist/security/auth.js.map +1 -1
  67. package/dist/security/jsLoader.js +8 -0
  68. package/dist/security/jsLoader.js.map +1 -1
  69. package/dist/security/keys.d.ts +32 -0
  70. package/dist/security/keys.js +147 -0
  71. package/dist/security/keys.js.map +1 -1
  72. package/dist/server/REST.js +67 -1
  73. package/dist/server/REST.js.map +1 -1
  74. package/dist/server/Server.d.ts +6 -0
  75. package/dist/server/Server.js.map +1 -1
  76. package/dist/server/http.d.ts +2 -0
  77. package/dist/server/http.js +139 -14
  78. package/dist/server/http.js.map +1 -1
  79. package/dist/server/operationsServer.js +3 -3
  80. package/dist/server/operationsServer.js.map +1 -1
  81. package/dist/server/serverHelpers/progressEmitter.js +5 -1
  82. package/dist/server/serverHelpers/progressEmitter.js.map +1 -1
  83. package/dist/server/threads/threadServer.js +9 -5
  84. package/dist/server/threads/threadServer.js.map +1 -1
  85. package/dist/sqlEngine/binder/bind.d.ts +72 -0
  86. package/dist/sqlEngine/binder/bind.js +289 -0
  87. package/dist/sqlEngine/binder/bind.js.map +1 -0
  88. package/dist/sqlEngine/config.d.ts +35 -0
  89. package/dist/sqlEngine/config.js +62 -0
  90. package/dist/sqlEngine/config.js.map +1 -0
  91. package/dist/sqlEngine/diff/differential.d.ts +23 -0
  92. package/dist/sqlEngine/diff/differential.js +90 -0
  93. package/dist/sqlEngine/diff/differential.js.map +1 -0
  94. package/dist/sqlEngine/errors.d.ts +22 -0
  95. package/dist/sqlEngine/errors.js +36 -0
  96. package/dist/sqlEngine/errors.js.map +1 -0
  97. package/dist/sqlEngine/executor/runMutation.d.ts +35 -0
  98. package/dist/sqlEngine/executor/runMutation.js +352 -0
  99. package/dist/sqlEngine/executor/runMutation.js.map +1 -0
  100. package/dist/sqlEngine/executor/runSelect.d.ts +7 -0
  101. package/dist/sqlEngine/executor/runSelect.js +14 -0
  102. package/dist/sqlEngine/executor/runSelect.js.map +1 -0
  103. package/dist/sqlEngine/expressions/compile.d.ts +24 -0
  104. package/dist/sqlEngine/expressions/compile.js +326 -0
  105. package/dist/sqlEngine/expressions/compile.js.map +1 -0
  106. package/dist/sqlEngine/functions/aggregates.d.ts +12 -0
  107. package/dist/sqlEngine/functions/aggregates.js +299 -0
  108. package/dist/sqlEngine/functions/aggregates.js.map +1 -0
  109. package/dist/sqlEngine/functions/registry.d.ts +36 -0
  110. package/dist/sqlEngine/functions/registry.js +33 -0
  111. package/dist/sqlEngine/functions/registry.js.map +1 -0
  112. package/dist/sqlEngine/functions/standard.d.ts +9 -0
  113. package/dist/sqlEngine/functions/standard.js +86 -0
  114. package/dist/sqlEngine/functions/standard.js.map +1 -0
  115. package/dist/sqlEngine/index.d.ts +29 -0
  116. package/dist/sqlEngine/index.js +62 -0
  117. package/dist/sqlEngine/index.js.map +1 -0
  118. package/dist/sqlEngine/logical/build.d.ts +20 -0
  119. package/dist/sqlEngine/logical/build.js +326 -0
  120. package/dist/sqlEngine/logical/build.js.map +1 -0
  121. package/dist/sqlEngine/logical/op.d.ts +105 -0
  122. package/dist/sqlEngine/logical/op.js +10 -0
  123. package/dist/sqlEngine/logical/op.js.map +1 -0
  124. package/dist/sqlEngine/optimizer/joinAnalysis.d.ts +37 -0
  125. package/dist/sqlEngine/optimizer/joinAnalysis.js +144 -0
  126. package/dist/sqlEngine/optimizer/joinAnalysis.js.map +1 -0
  127. package/dist/sqlEngine/optimizer/optimize.d.ts +13 -0
  128. package/dist/sqlEngine/optimizer/optimize.js +53 -0
  129. package/dist/sqlEngine/optimizer/optimize.js.map +1 -0
  130. package/dist/sqlEngine/optimizer/ruleEngine.d.ts +7 -0
  131. package/dist/sqlEngine/optimizer/ruleEngine.js +26 -0
  132. package/dist/sqlEngine/optimizer/ruleEngine.js.map +1 -0
  133. package/dist/sqlEngine/optimizer/rules/limitPushdown.d.ts +19 -0
  134. package/dist/sqlEngine/optimizer/rules/limitPushdown.js +55 -0
  135. package/dist/sqlEngine/optimizer/rules/limitPushdown.js.map +1 -0
  136. package/dist/sqlEngine/optimizer/rules/planJoins.d.ts +19 -0
  137. package/dist/sqlEngine/optimizer/rules/planJoins.js +62 -0
  138. package/dist/sqlEngine/optimizer/rules/planJoins.js.map +1 -0
  139. package/dist/sqlEngine/optimizer/rules/predicateNormalize.d.ts +18 -0
  140. package/dist/sqlEngine/optimizer/rules/predicateNormalize.js +80 -0
  141. package/dist/sqlEngine/optimizer/rules/predicateNormalize.js.map +1 -0
  142. package/dist/sqlEngine/optimizer/rules/predicatePushdown.d.ts +11 -0
  143. package/dist/sqlEngine/optimizer/rules/predicatePushdown.js +48 -0
  144. package/dist/sqlEngine/optimizer/rules/predicatePushdown.js.map +1 -0
  145. package/dist/sqlEngine/optimizer/rules/projectionPushdown.d.ts +23 -0
  146. package/dist/sqlEngine/optimizer/rules/projectionPushdown.js +160 -0
  147. package/dist/sqlEngine/optimizer/rules/projectionPushdown.js.map +1 -0
  148. package/dist/sqlEngine/optimizer/rules/sortFromIndex.d.ts +14 -0
  149. package/dist/sqlEngine/optimizer/rules/sortFromIndex.js +49 -0
  150. package/dist/sqlEngine/optimizer/rules/sortFromIndex.js.map +1 -0
  151. package/dist/sqlEngine/optimizer/rules/validateScannable.d.ts +15 -0
  152. package/dist/sqlEngine/optimizer/rules/validateScannable.js +60 -0
  153. package/dist/sqlEngine/optimizer/rules/validateScannable.js.map +1 -0
  154. package/dist/sqlEngine/optimizer/whereToConditions.d.ts +85 -0
  155. package/dist/sqlEngine/optimizer/whereToConditions.js +484 -0
  156. package/dist/sqlEngine/optimizer/whereToConditions.js.map +1 -0
  157. package/dist/sqlEngine/parser/ast.d.ts +139 -0
  158. package/dist/sqlEngine/parser/ast.js +10 -0
  159. package/dist/sqlEngine/parser/ast.js.map +1 -0
  160. package/dist/sqlEngine/parser/normalizer.d.ts +28 -0
  161. package/dist/sqlEngine/parser/normalizer.js +413 -0
  162. package/dist/sqlEngine/parser/normalizer.js.map +1 -0
  163. package/dist/sqlEngine/parser/parse.d.ts +14 -0
  164. package/dist/sqlEngine/parser/parse.js +20 -0
  165. package/dist/sqlEngine/parser/parse.js.map +1 -0
  166. package/dist/sqlEngine/physical/PhysicalDistinct.d.ts +9 -0
  167. package/dist/sqlEngine/physical/PhysicalDistinct.js +29 -0
  168. package/dist/sqlEngine/physical/PhysicalDistinct.js.map +1 -0
  169. package/dist/sqlEngine/physical/PhysicalFilter.d.ts +10 -0
  170. package/dist/sqlEngine/physical/PhysicalFilter.js +25 -0
  171. package/dist/sqlEngine/physical/PhysicalFilter.js.map +1 -0
  172. package/dist/sqlEngine/physical/PhysicalHashAggregate.d.ts +27 -0
  173. package/dist/sqlEngine/physical/PhysicalHashAggregate.js +100 -0
  174. package/dist/sqlEngine/physical/PhysicalHashAggregate.js.map +1 -0
  175. package/dist/sqlEngine/physical/PhysicalHashJoin.d.ts +29 -0
  176. package/dist/sqlEngine/physical/PhysicalHashJoin.js +93 -0
  177. package/dist/sqlEngine/physical/PhysicalHashJoin.js.map +1 -0
  178. package/dist/sqlEngine/physical/PhysicalIndexNestedLoopJoin.d.ts +36 -0
  179. package/dist/sqlEngine/physical/PhysicalIndexNestedLoopJoin.js +78 -0
  180. package/dist/sqlEngine/physical/PhysicalIndexNestedLoopJoin.js.map +1 -0
  181. package/dist/sqlEngine/physical/PhysicalIndexScan.d.ts +22 -0
  182. package/dist/sqlEngine/physical/PhysicalIndexScan.js +77 -0
  183. package/dist/sqlEngine/physical/PhysicalIndexScan.js.map +1 -0
  184. package/dist/sqlEngine/physical/PhysicalLimit.d.ts +5 -0
  185. package/dist/sqlEngine/physical/PhysicalLimit.js +28 -0
  186. package/dist/sqlEngine/physical/PhysicalLimit.js.map +1 -0
  187. package/dist/sqlEngine/physical/PhysicalNestedLoopJoin.d.ts +20 -0
  188. package/dist/sqlEngine/physical/PhysicalNestedLoopJoin.js +51 -0
  189. package/dist/sqlEngine/physical/PhysicalNestedLoopJoin.js.map +1 -0
  190. package/dist/sqlEngine/physical/PhysicalProject.d.ts +18 -0
  191. package/dist/sqlEngine/physical/PhysicalProject.js +117 -0
  192. package/dist/sqlEngine/physical/PhysicalProject.js.map +1 -0
  193. package/dist/sqlEngine/physical/PhysicalQualify.d.ts +13 -0
  194. package/dist/sqlEngine/physical/PhysicalQualify.js +29 -0
  195. package/dist/sqlEngine/physical/PhysicalQualify.js.map +1 -0
  196. package/dist/sqlEngine/physical/PhysicalSort.d.ts +12 -0
  197. package/dist/sqlEngine/physical/PhysicalSort.js +59 -0
  198. package/dist/sqlEngine/physical/PhysicalSort.js.map +1 -0
  199. package/dist/sqlEngine/physical/op.d.ts +11 -0
  200. package/dist/sqlEngine/physical/op.js +9 -0
  201. package/dist/sqlEngine/physical/op.js.map +1 -0
  202. package/dist/sqlEngine/physical/plan.d.ts +23 -0
  203. package/dist/sqlEngine/physical/plan.js +162 -0
  204. package/dist/sqlEngine/physical/plan.js.map +1 -0
  205. package/dist/sqlEngine/router.d.ts +26 -0
  206. package/dist/sqlEngine/router.js +48 -0
  207. package/dist/sqlEngine/router.js.map +1 -0
  208. package/dist/sqlEngine/types.d.ts +37 -0
  209. package/dist/sqlEngine/types.js +13 -0
  210. package/dist/sqlEngine/types.js.map +1 -0
  211. package/dist/sqlTranslator/index.js +7 -1
  212. package/dist/sqlTranslator/index.js.map +1 -1
  213. package/dist/utility/common_utils.js +25 -0
  214. package/dist/utility/common_utils.js.map +1 -1
  215. package/dist/utility/install/installer.d.ts +9 -1
  216. package/dist/utility/install/installer.js +21 -0
  217. package/dist/utility/install/installer.js.map +1 -1
  218. package/dist/validation/configValidator.js +3 -0
  219. package/dist/validation/configValidator.js.map +1 -1
  220. package/dist/validation/deleteValidator.js +10 -2
  221. package/dist/validation/deleteValidator.js.map +1 -1
  222. package/npm-shrinkwrap.json +272 -230
  223. package/package.json +3 -3
  224. package/resources/DESIGN.md +17 -16
  225. package/resources/DatabaseTransaction.ts +95 -0
  226. package/resources/RequestTarget.ts +12 -3
  227. package/resources/Resource.ts +23 -2
  228. package/resources/Table.ts +57 -6
  229. package/resources/analytics/metadata.ts +3 -0
  230. package/resources/analytics/write.ts +23 -0
  231. package/resources/databases.ts +24 -0
  232. package/resources/defineResource.ts +17 -4
  233. package/resources/jsResource.ts +61 -2
  234. package/resources/openApi.ts +44 -19
  235. package/resources/scheduler/CronExpression.ts +394 -0
  236. package/resources/scheduler/engine.ts +812 -0
  237. package/resources/scheduler/scheduler.ts +236 -0
  238. package/security/auth.ts +1 -0
  239. package/security/jsLoader.ts +8 -0
  240. package/security/keys.ts +152 -0
  241. package/server/REST.ts +70 -1
  242. package/server/Server.ts +6 -0
  243. package/server/http.ts +122 -15
  244. package/server/operationsServer.ts +5 -3
  245. package/server/serverHelpers/progressEmitter.ts +5 -1
  246. package/server/threads/threadServer.js +9 -5
  247. package/sqlTranslator/index.ts +16 -6
  248. package/studio/web/assets/{Chat-CTjtL8Z4.js → Chat-DHP4XpID.js} +2 -2
  249. package/studio/web/assets/{Chat-CTjtL8Z4.js.map → Chat-DHP4XpID.js.map} +1 -1
  250. package/studio/web/assets/{FloatingChat-CafHR4Ur.js → FloatingChat-CJ7PssCv.js} +4 -4
  251. package/studio/web/assets/{FloatingChat-CafHR4Ur.js.map → FloatingChat-CJ7PssCv.js.map} +1 -1
  252. package/studio/web/assets/{applications-Buh_q0Vj.js → applications-DxXiGpsR.js} +2 -2
  253. package/studio/web/assets/{applications-Buh_q0Vj.js.map → applications-DxXiGpsR.js.map} +1 -1
  254. package/studio/web/assets/{index-0hXeECkS.js → index-BdbBanDP.js} +6 -6
  255. package/studio/web/assets/{index-0hXeECkS.js.map → index-BdbBanDP.js.map} +1 -1
  256. package/studio/web/assets/{index.lazy-B00B7VBT.js → index.lazy-B2eH28zD.js} +4 -4
  257. package/studio/web/assets/{index.lazy-B00B7VBT.js.map → index.lazy-B2eH28zD.js.map} +1 -1
  258. package/studio/web/assets/{profile-Cg2wwYPn.js → profile-DK5hgucv.js} +2 -2
  259. package/studio/web/assets/{profile-Cg2wwYPn.js.map → profile-DK5hgucv.js.map} +1 -1
  260. package/studio/web/assets/{setComponentFile-DCaDIvyB.js → setComponentFile-BVDWRYxx.js} +2 -2
  261. package/studio/web/assets/{setComponentFile-DCaDIvyB.js.map → setComponentFile-BVDWRYxx.js.map} +1 -1
  262. package/studio/web/assets/{setup-CAVcAQjK.js → setup-DJ9BInoK.js} +2 -2
  263. package/studio/web/assets/{setup-CAVcAQjK.js.map → setup-DJ9BInoK.js.map} +1 -1
  264. package/studio/web/assets/{status-BRXorNdD.js → status-B_qzmgfD.js} +2 -2
  265. package/studio/web/assets/{status-BRXorNdD.js.map → status-B_qzmgfD.js.map} +1 -1
  266. package/studio/web/assets/{swagger-ui-react-Dy1D62vO.js → swagger-ui-react-DOL5jCqg.js} +2 -2
  267. package/studio/web/assets/{swagger-ui-react-Dy1D62vO.js.map → swagger-ui-react-DOL5jCqg.js.map} +1 -1
  268. package/studio/web/assets/{tsMode-A8gbL74v.js → tsMode-DpxUxfTW.js} +2 -2
  269. package/studio/web/assets/{tsMode-A8gbL74v.js.map → tsMode-DpxUxfTW.js.map} +1 -1
  270. package/studio/web/assets/{useEntityRestURL-cDodrVcQ.js → useEntityRestURL-CU_lY6XW.js} +2 -2
  271. package/studio/web/assets/{useEntityRestURL-cDodrVcQ.js.map → useEntityRestURL-CU_lY6XW.js.map} +1 -1
  272. package/studio/web/index.html +1 -1
  273. package/utility/common_utils.ts +26 -0
  274. package/utility/install/installer.ts +26 -1
  275. package/validation/configValidator.ts +3 -0
  276. package/validation/deleteValidator.ts +11 -2
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Reads the SQL engine feature flag and runtime caps.
3
+ *
4
+ * sql.engine selects which engine handles a SQL request:
5
+ * 'legacy' — existing AlaSQL-based path.
6
+ * 'new' — new Resource-API-based path; throws EngineUnsupportedError for
7
+ * queries it can't plan.
8
+ * 'auto' — try the new path first; fall back to legacy on
9
+ * EngineUnsupportedError (default).
10
+ *
11
+ * The flag is read from the HARPER_SQL_ENGINE environment variable, then
12
+ * harperConfig.sql?.engine, then defaults to 'auto'. We deliberately keep
13
+ * this resolution lazy and lightweight so the router can be invoked without a
14
+ * fully booted Harper config (e.g., in unit tests).
15
+ *
16
+ * Phase 5 cutover: the default is now 'auto' — the new engine handles every SQL
17
+ * request it can plan and silently falls back to legacy on anything it can't, so
18
+ * no query changes behavior unless the new engine produces an identical result.
19
+ * The gate for this flip was full parity of the new engine (run in 'auto') against
20
+ * the existing SQL suite: the cutover-readiness differential (46/46 identical) plus
21
+ * the existing behavioral suites under 'auto' — northwind (575 SQL ops) and
22
+ * delete.test.mjs (76) — at 0 failures. Both trial-flip blockers (IN literal
23
+ * coercion, LIKE-predicate DELETE 403) and the northwind gaps (attribute-name
24
+ * validation, quoted-boolean coercion, != / NULL three-valued logic) are fixed.
25
+ * The remaining cutover work is burn-in (watch `sql-engine v2 fallback:` logs) then
26
+ * flipping to 'new' and deleting the legacy path. See PLAN.md phase-5 notes.
27
+ */
28
+ export type SqlEngineMode = 'legacy' | 'new' | 'auto';
29
+ export interface SqlEngineConfig {
30
+ engine: SqlEngineMode;
31
+ allowFullScan: boolean;
32
+ maxSortRows: number;
33
+ maxHashRows: number;
34
+ }
35
+ export declare function getSqlEngineConfig(): SqlEngineConfig;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /**
3
+ * Reads the SQL engine feature flag and runtime caps.
4
+ *
5
+ * sql.engine selects which engine handles a SQL request:
6
+ * 'legacy' — existing AlaSQL-based path.
7
+ * 'new' — new Resource-API-based path; throws EngineUnsupportedError for
8
+ * queries it can't plan.
9
+ * 'auto' — try the new path first; fall back to legacy on
10
+ * EngineUnsupportedError (default).
11
+ *
12
+ * The flag is read from the HARPER_SQL_ENGINE environment variable, then
13
+ * harperConfig.sql?.engine, then defaults to 'auto'. We deliberately keep
14
+ * this resolution lazy and lightweight so the router can be invoked without a
15
+ * fully booted Harper config (e.g., in unit tests).
16
+ *
17
+ * Phase 5 cutover: the default is now 'auto' — the new engine handles every SQL
18
+ * request it can plan and silently falls back to legacy on anything it can't, so
19
+ * no query changes behavior unless the new engine produces an identical result.
20
+ * The gate for this flip was full parity of the new engine (run in 'auto') against
21
+ * the existing SQL suite: the cutover-readiness differential (46/46 identical) plus
22
+ * the existing behavioral suites under 'auto' — northwind (575 SQL ops) and
23
+ * delete.test.mjs (76) — at 0 failures. Both trial-flip blockers (IN literal
24
+ * coercion, LIKE-predicate DELETE 403) and the northwind gaps (attribute-name
25
+ * validation, quoted-boolean coercion, != / NULL three-valued logic) are fixed.
26
+ * The remaining cutover work is burn-in (watch `sql-engine v2 fallback:` logs) then
27
+ * flipping to 'new' and deleting the legacy path. See PLAN.md phase-5 notes.
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.getSqlEngineConfig = getSqlEngineConfig;
31
+ const DEFAULTS = {
32
+ engine: 'auto',
33
+ allowFullScan: false,
34
+ maxSortRows: 1_000_000,
35
+ maxHashRows: 1_000_000,
36
+ };
37
+ function envEngine() {
38
+ const v = process.env.HARPER_SQL_ENGINE;
39
+ if (v === 'legacy' || v === 'new' || v === 'auto')
40
+ return v;
41
+ return undefined;
42
+ }
43
+ function harperConfigEngine() {
44
+ try {
45
+ const harperConfig = globalThis.harperConfig;
46
+ return harperConfig?.sql ?? {};
47
+ }
48
+ catch {
49
+ return {};
50
+ }
51
+ }
52
+ function getSqlEngineConfig() {
53
+ const fromConfig = harperConfigEngine();
54
+ const fromEnv = envEngine();
55
+ return {
56
+ engine: fromEnv ?? fromConfig.engine ?? DEFAULTS.engine,
57
+ allowFullScan: fromConfig.allowFullScan ?? DEFAULTS.allowFullScan,
58
+ maxSortRows: fromConfig.maxSortRows ?? DEFAULTS.maxSortRows,
59
+ maxHashRows: fromConfig.maxHashRows ?? DEFAULTS.maxHashRows,
60
+ };
61
+ }
62
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../sqlEngine/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;AAiCH,gDASC;AA/BD,MAAM,QAAQ,GAAoB;IACjC,MAAM,EAAE,MAAM;IACd,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,SAAS;CACtB,CAAC;AAEF,SAAS,SAAS;IACjB,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACxC,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,MAAM;QAAE,OAAO,CAAC,CAAC;IAC5D,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,kBAAkB;IAC1B,IAAI,CAAC;QACJ,MAAM,YAAY,GAAI,UAAoE,CAAC,YAAY,CAAC;QACxG,OAAO,YAAY,EAAE,GAAG,IAAI,EAAE,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,CAAC;IACX,CAAC;AACF,CAAC;AAED,SAAgB,kBAAkB;IACjC,MAAM,UAAU,GAAG,kBAAkB,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;IAC5B,OAAO;QACN,MAAM,EAAE,OAAO,IAAI,UAAU,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM;QACvD,aAAa,EAAE,UAAU,CAAC,aAAa,IAAI,QAAQ,CAAC,aAAa;QACjE,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW;QAC3D,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW;KAC3D,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Differential test harness.
3
+ *
4
+ * Runs a SQL query through both the legacy and new engines and deep-equals the
5
+ * results modulo:
6
+ * - row order when no ORDER BY is present (sorted by JSON serialization),
7
+ * - undefined → null translation (legacy returns both; we normalize),
8
+ * - object key order.
9
+ *
10
+ * Used by the parity test suite under core/unitTests/sqlEngine/.
11
+ */
12
+ export interface DifferentialOptions {
13
+ hdb_user?: unknown;
14
+ preserveOrder?: boolean;
15
+ bypass_auth?: boolean;
16
+ }
17
+ export interface DifferentialResult {
18
+ legacy: unknown;
19
+ v2: unknown;
20
+ equal: boolean;
21
+ v2Unsupported?: string;
22
+ }
23
+ export declare function runDifferential(sql: string, opts?: DifferentialOptions): Promise<DifferentialResult>;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ /**
3
+ * Differential test harness.
4
+ *
5
+ * Runs a SQL query through both the legacy and new engines and deep-equals the
6
+ * results modulo:
7
+ * - row order when no ORDER BY is present (sorted by JSON serialization),
8
+ * - undefined → null translation (legacy returns both; we normalize),
9
+ * - object key order.
10
+ *
11
+ * Used by the parity test suite under core/unitTests/sqlEngine/.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.runDifferential = runDifferential;
15
+ const errors_ts_1 = require("../errors.js");
16
+ function loadLegacy() {
17
+ return require('../../sqlTranslator/index.js');
18
+ }
19
+ function runLegacy(sql, opts) {
20
+ const translator = loadLegacy();
21
+ return new Promise((resolve, reject) => {
22
+ translator.evaluateSQL({ sql, hdb_user: opts.hdb_user, bypass_auth: opts.bypass_auth ?? true }, (err, data) => {
23
+ if (err)
24
+ reject(err);
25
+ else
26
+ resolve(data);
27
+ });
28
+ });
29
+ }
30
+ async function runV2(sql, opts) {
31
+ const previous = process.env.HARPER_SQL_ENGINE;
32
+ process.env.HARPER_SQL_ENGINE = 'new';
33
+ try {
34
+ return await runLegacy(sql, opts);
35
+ }
36
+ finally {
37
+ if (previous === undefined)
38
+ delete process.env.HARPER_SQL_ENGINE;
39
+ else
40
+ process.env.HARPER_SQL_ENGINE = previous;
41
+ }
42
+ }
43
+ function normalize(value) {
44
+ if (value === undefined)
45
+ return null;
46
+ if (value === null)
47
+ return null;
48
+ if (Array.isArray(value))
49
+ return value.map(normalize);
50
+ if (typeof value === 'object') {
51
+ const out = {};
52
+ for (const k of Object.keys(value).sort()) {
53
+ out[k] = normalize(value[k]);
54
+ }
55
+ return out;
56
+ }
57
+ return value;
58
+ }
59
+ function sortRows(rows) {
60
+ if (!Array.isArray(rows))
61
+ return rows;
62
+ return [...rows].sort((a, b) => {
63
+ const sa = JSON.stringify(a);
64
+ const sb = JSON.stringify(b);
65
+ return sa < sb ? -1 : sa > sb ? 1 : 0;
66
+ });
67
+ }
68
+ function deepEqual(a, b) {
69
+ return JSON.stringify(a) === JSON.stringify(b);
70
+ }
71
+ async function runDifferential(sql, opts = {}) {
72
+ const legacy = await runLegacy(sql, opts);
73
+ let v2;
74
+ let v2Unsupported;
75
+ try {
76
+ v2 = await runV2(sql, opts);
77
+ }
78
+ catch (err) {
79
+ if (err instanceof errors_ts_1.EngineUnsupportedError) {
80
+ return { legacy, v2: undefined, equal: false, v2Unsupported: err.reason };
81
+ }
82
+ throw err;
83
+ }
84
+ const normalizedLegacy = normalize(legacy);
85
+ const normalizedV2 = normalize(v2);
86
+ const a = opts.preserveOrder ? normalizedLegacy : sortRows(normalizedLegacy);
87
+ const b = opts.preserveOrder ? normalizedV2 : sortRows(normalizedV2);
88
+ return { legacy, v2, equal: deepEqual(a, b), v2Unsupported };
89
+ }
90
+ //# sourceMappingURL=differential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"differential.js","sourceRoot":"","sources":["../../../sqlEngine/diff/differential.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA4EH,0CAkBC;AA5FD,4CAAsD;AAmBtD,SAAS,UAAU;IAClB,OAAO,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,IAAyB;IACxD,MAAM,UAAU,GAAG,UAAU,EAAE,CAAC;IAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,UAAU,CAAC,WAAW,CACrB,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI,EAAE,EACvE,CAAC,GAAY,EAAE,IAAa,EAAE,EAAE;YAC/B,IAAI,GAAG;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;;gBAChB,OAAO,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,KAAK,CAAC,GAAW,EAAE,IAAyB;IAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC;IACtC,IAAI,CAAC;QACJ,OAAO,MAAM,SAAS,CA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;AAC9D,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Engine-specific error types for the new SQL engine.
3
+ *
4
+ * EngineUnsupportedError is thrown when a query cannot be handled by the new
5
+ * engine — either at plan time (a shape that can't map to the Resource API) or
6
+ * at execution time (an in-memory operator exceeding its row cap, before any
7
+ * result is emitted). The router catches this in 'auto' mode and falls back to
8
+ * the legacy AlaSQL engine.
9
+ *
10
+ * EngineRuntimeError is thrown for genuine runtime failures that are NOT
11
+ * recoverable by falling back (e.g., a mutation target with no primary key).
12
+ * The router does not fall back on it — it surfaces to the caller.
13
+ */
14
+ import { ClientError } from '../utility/errors/hdbError.js';
15
+ export declare class EngineUnsupportedError extends ClientError {
16
+ reason: string;
17
+ astSnippet?: unknown;
18
+ constructor(reason: string, astSnippet?: unknown);
19
+ }
20
+ export declare class EngineRuntimeError extends ClientError {
21
+ constructor(message: string);
22
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /**
3
+ * Engine-specific error types for the new SQL engine.
4
+ *
5
+ * EngineUnsupportedError is thrown when a query cannot be handled by the new
6
+ * engine — either at plan time (a shape that can't map to the Resource API) or
7
+ * at execution time (an in-memory operator exceeding its row cap, before any
8
+ * result is emitted). The router catches this in 'auto' mode and falls back to
9
+ * the legacy AlaSQL engine.
10
+ *
11
+ * EngineRuntimeError is thrown for genuine runtime failures that are NOT
12
+ * recoverable by falling back (e.g., a mutation target with no primary key).
13
+ * The router does not fall back on it — it surfaces to the caller.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.EngineRuntimeError = exports.EngineUnsupportedError = void 0;
17
+ const hdbError_js_1 = require("../utility/errors/hdbError.js");
18
+ class EngineUnsupportedError extends hdbError_js_1.ClientError {
19
+ reason;
20
+ astSnippet;
21
+ constructor(reason, astSnippet) {
22
+ super(`SQL engine v2: unsupported query — ${reason}`);
23
+ this.name = 'EngineUnsupportedError';
24
+ this.reason = reason;
25
+ this.astSnippet = astSnippet;
26
+ }
27
+ }
28
+ exports.EngineUnsupportedError = EngineUnsupportedError;
29
+ class EngineRuntimeError extends hdbError_js_1.ClientError {
30
+ constructor(message) {
31
+ super(`SQL engine v2: ${message}`);
32
+ this.name = 'EngineRuntimeError';
33
+ }
34
+ }
35
+ exports.EngineRuntimeError = EngineRuntimeError;
36
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../sqlEngine/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,+DAA4D;AAE5D,MAAa,sBAAuB,SAAQ,yBAAW;IACtD,MAAM,CAAS;IACf,UAAU,CAAW;IAErB,YAAY,MAAc,EAAE,UAAoB;QAC/C,KAAK,CAAC,sCAAsC,MAAM,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;CACD;AAVD,wDAUC;AAED,MAAa,kBAAmB,SAAQ,yBAAW;IAClD,YAAY,OAAe;QAC1B,KAAK,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IAClC,CAAC;CACD;AALD,gDAKC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Phase 4 mutation executors: INSERT / UPDATE / DELETE.
3
+ *
4
+ * Writes go through the Resource API exactly as production code does: the
5
+ * `databases`-resolved entry is the Table class, whose static
6
+ * `create`/`put`/`patch`/`delete`/`get` methods each call `transaction(context,
7
+ * …)` internally and *join* an already-open transaction on the context
8
+ * (resources/Resource.ts). So the whole mutation runs inside a single
9
+ * `transaction(context, …)`; every per-row write joins it and the batch commits
10
+ * (or aborts) atomically.
11
+ *
12
+ * UPDATE/DELETE find their target rows by running the ordinary SELECT pipeline
13
+ * (a synthetic `SELECT … FROM target WHERE …`) inside the same transaction, so
14
+ * the read sees a consistent snapshot with the writes.
15
+ *
16
+ * Response shapes match the legacy SQL path (dataLayer/insert.ts,
17
+ * dataLayer/delete.ts) so callers see no difference:
18
+ * INSERT → { message: "inserted N of M records", inserted_hashes, skipped_hashes }
19
+ * UPDATE → { message: "updated N of M records", update_hashes, skipped_hashes }
20
+ * DELETE → { message: "N of M records successfully deleted", deleted_hashes, skipped_hashes }
21
+ */
22
+ import type { BoundInsert, BoundUpdate, BoundDelete } from '../binder/bind.ts';
23
+ import type { SqlEngineContext } from '../types.ts';
24
+ /** A minimal context carrying the user; `transaction()` attaches `.transaction`. */
25
+ interface WriteContext {
26
+ user?: unknown;
27
+ transaction?: unknown;
28
+ }
29
+ type TransactionRunner = <T>(context: WriteContext, callback: () => Promise<T>) => Promise<T>;
30
+ /** Test hook: override the transaction runner. Pass null to restore the default. */
31
+ export declare function _setTransactionRunner(runner: TransactionRunner | null): void;
32
+ export declare function runInsert(bound: BoundInsert, ctx: SqlEngineContext): Promise<unknown>;
33
+ export declare function runUpdate(bound: BoundUpdate, ctx: SqlEngineContext): Promise<unknown>;
34
+ export declare function runDelete(bound: BoundDelete, ctx: SqlEngineContext): Promise<unknown>;
35
+ export {};