@pwfabric/runtime 0.0.0-stage → 1.0.0-rc.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 (447) hide show
  1. package/LICENSE +90 -0
  2. package/README.md +43 -2
  3. package/dist/a11y/announcer.d.ts +65 -0
  4. package/dist/a11y/announcer.js +140 -0
  5. package/dist/a11y/announcer.js.map +1 -0
  6. package/dist/a11y/contrast.d.ts +54 -0
  7. package/dist/a11y/contrast.js +93 -0
  8. package/dist/a11y/contrast.js.map +1 -0
  9. package/dist/a11y/focus.d.ts +123 -0
  10. package/dist/a11y/focus.js +282 -0
  11. package/dist/a11y/focus.js.map +1 -0
  12. package/dist/a11y/index.d.ts +21 -0
  13. package/dist/a11y/index.js +18 -0
  14. package/dist/a11y/index.js.map +1 -0
  15. package/dist/a11y/keyboard.d.ts +144 -0
  16. package/dist/a11y/keyboard.js +317 -0
  17. package/dist/a11y/keyboard.js.map +1 -0
  18. package/dist/adapters/default-image.d.ts +25 -0
  19. package/dist/adapters/default-image.js +37 -0
  20. package/dist/adapters/default-image.js.map +1 -0
  21. package/dist/adapters/index.d.ts +27 -0
  22. package/dist/adapters/index.js +28 -0
  23. package/dist/adapters/index.js.map +1 -0
  24. package/dist/adapters/next-image.d.ts +38 -0
  25. package/dist/adapters/next-image.js +124 -0
  26. package/dist/adapters/next-image.js.map +1 -0
  27. package/dist/adapters/types.d.ts +61 -0
  28. package/dist/adapters/types.js +11 -0
  29. package/dist/adapters/types.js.map +1 -0
  30. package/dist/analytics/index.d.ts +14 -0
  31. package/dist/analytics/index.js +15 -0
  32. package/dist/analytics/index.js.map +1 -0
  33. package/dist/analytics/tracker.d.ts +65 -0
  34. package/dist/analytics/tracker.js +251 -0
  35. package/dist/analytics/tracker.js.map +1 -0
  36. package/dist/analytics/types.d.ts +130 -0
  37. package/dist/analytics/types.js +11 -0
  38. package/dist/analytics/types.js.map +1 -0
  39. package/dist/auth/index.d.ts +15 -0
  40. package/dist/auth/index.js +14 -0
  41. package/dist/auth/index.js.map +1 -0
  42. package/dist/auth/provider.d.ts +132 -0
  43. package/dist/auth/provider.js +473 -0
  44. package/dist/auth/provider.js.map +1 -0
  45. package/dist/auth/types.d.ts +117 -0
  46. package/dist/auth/types.js +9 -0
  47. package/dist/auth/types.js.map +1 -0
  48. package/dist/binding/collection.d.ts +190 -0
  49. package/dist/binding/collection.js +358 -0
  50. package/dist/binding/collection.js.map +1 -0
  51. package/dist/binding/datasource.d.ts +319 -0
  52. package/dist/binding/datasource.js +556 -0
  53. package/dist/binding/datasource.js.map +1 -0
  54. package/dist/binding/engine.d.ts +65 -0
  55. package/dist/binding/engine.js +268 -0
  56. package/dist/binding/engine.js.map +1 -0
  57. package/dist/binding/expression.d.ts +150 -0
  58. package/dist/binding/expression.js +787 -0
  59. package/dist/binding/expression.js.map +1 -0
  60. package/dist/binding/index.d.ts +19 -0
  61. package/dist/binding/index.js +14 -0
  62. package/dist/binding/index.js.map +1 -0
  63. package/dist/binding/two-way.d.ts +149 -0
  64. package/dist/binding/two-way.js +462 -0
  65. package/dist/binding/two-way.js.map +1 -0
  66. package/dist/binding/types.d.ts +119 -0
  67. package/dist/binding/types.js +9 -0
  68. package/dist/binding/types.js.map +1 -0
  69. package/dist/blocks/component-types.d.ts +81 -0
  70. package/dist/blocks/component-types.js +11 -0
  71. package/dist/blocks/component-types.js.map +1 -0
  72. package/dist/blocks/composition-rules.d.ts +168 -0
  73. package/dist/blocks/composition-rules.js +391 -0
  74. package/dist/blocks/composition-rules.js.map +1 -0
  75. package/dist/blocks/hooks.d.ts +31 -0
  76. package/dist/blocks/hooks.js +42 -0
  77. package/dist/blocks/hooks.js.map +1 -0
  78. package/dist/blocks/index.d.ts +14 -0
  79. package/dist/blocks/index.js +23 -0
  80. package/dist/blocks/index.js.map +1 -0
  81. package/dist/blocks/registry.d.ts +84 -0
  82. package/dist/blocks/registry.js +136 -0
  83. package/dist/blocks/registry.js.map +1 -0
  84. package/dist/blocks/rule-engine.d.ts +131 -0
  85. package/dist/blocks/rule-engine.js +321 -0
  86. package/dist/blocks/rule-engine.js.map +1 -0
  87. package/dist/blocks/surface-event-context.d.ts +13 -0
  88. package/dist/blocks/surface-event-context.js +14 -0
  89. package/dist/blocks/surface-event-context.js.map +1 -0
  90. package/dist/blocks/surface-id-context.d.ts +13 -0
  91. package/dist/blocks/surface-id-context.js +15 -0
  92. package/dist/blocks/surface-id-context.js.map +1 -0
  93. package/dist/bus.d.ts +41 -0
  94. package/dist/bus.js +158 -0
  95. package/dist/bus.js.map +1 -0
  96. package/dist/cache/index.d.ts +9 -0
  97. package/dist/cache/index.js +10 -0
  98. package/dist/cache/index.js.map +1 -0
  99. package/dist/cache/memory.d.ts +32 -0
  100. package/dist/cache/memory.js +138 -0
  101. package/dist/cache/memory.js.map +1 -0
  102. package/dist/cache/types.d.ts +62 -0
  103. package/dist/cache/types.js +9 -0
  104. package/dist/cache/types.js.map +1 -0
  105. package/dist/capability/index.d.ts +72 -0
  106. package/dist/capability/index.js +87 -0
  107. package/dist/capability/index.js.map +1 -0
  108. package/dist/capability/kernel-capabilities.d.ts +31 -0
  109. package/dist/capability/kernel-capabilities.js +36 -0
  110. package/dist/capability/kernel-capabilities.js.map +1 -0
  111. package/dist/capability/platform-capabilities.d.ts +71 -0
  112. package/dist/capability/platform-capabilities.js +267 -0
  113. package/dist/capability/platform-capabilities.js.map +1 -0
  114. package/dist/capability/type-mapping.d.ts +70 -0
  115. package/dist/capability/type-mapping.js +107 -0
  116. package/dist/capability/type-mapping.js.map +1 -0
  117. package/dist/capability/validation.d.ts +46 -0
  118. package/dist/capability/validation.js +54 -0
  119. package/dist/capability/validation.js.map +1 -0
  120. package/dist/connectors/declared-connector.d.ts +48 -0
  121. package/dist/connectors/declared-connector.js +333 -0
  122. package/dist/connectors/declared-connector.js.map +1 -0
  123. package/dist/connectors/engine-registry.d.ts +50 -0
  124. package/dist/connectors/engine-registry.js +135 -0
  125. package/dist/connectors/engine-registry.js.map +1 -0
  126. package/dist/connectors/index.d.ts +14 -0
  127. package/dist/connectors/index.js +14 -0
  128. package/dist/connectors/index.js.map +1 -0
  129. package/dist/connectors/module-loader.d.ts +70 -0
  130. package/dist/connectors/module-loader.js +143 -0
  131. package/dist/connectors/module-loader.js.map +1 -0
  132. package/dist/connectors/types.d.ts +174 -0
  133. package/dist/connectors/types.js +23 -0
  134. package/dist/connectors/types.js.map +1 -0
  135. package/dist/context.d.ts +27 -0
  136. package/dist/context.js +38 -0
  137. package/dist/context.js.map +1 -0
  138. package/dist/data/DataCapabilityProvider.d.ts +39 -0
  139. package/dist/data/DataCapabilityProvider.js +58 -0
  140. package/dist/data/DataCapabilityProvider.js.map +1 -0
  141. package/dist/data/index.d.ts +17 -0
  142. package/dist/data/index.js +18 -0
  143. package/dist/data/index.js.map +1 -0
  144. package/dist/data/manager.d.ts +40 -0
  145. package/dist/data/manager.js +442 -0
  146. package/dist/data/manager.js.map +1 -0
  147. package/dist/data/types.d.ts +218 -0
  148. package/dist/data/types.js +2 -0
  149. package/dist/data/types.js.map +1 -0
  150. package/dist/entity/aggregate.d.ts +8 -0
  151. package/dist/entity/aggregate.js +24 -0
  152. package/dist/entity/aggregate.js.map +1 -0
  153. package/dist/entity/apply-query.d.ts +58 -0
  154. package/dist/entity/apply-query.js +264 -0
  155. package/dist/entity/apply-query.js.map +1 -0
  156. package/dist/entity/behavior.d.ts +94 -0
  157. package/dist/entity/behavior.js +78 -0
  158. package/dist/entity/behavior.js.map +1 -0
  159. package/dist/entity/connector.d.ts +141 -0
  160. package/dist/entity/connector.js +89 -0
  161. package/dist/entity/connector.js.map +1 -0
  162. package/dist/entity/connectors/index.d.ts +12 -0
  163. package/dist/entity/connectors/index.js +11 -0
  164. package/dist/entity/connectors/index.js.map +1 -0
  165. package/dist/entity/connectors/static.d.ts +51 -0
  166. package/dist/entity/connectors/static.js +245 -0
  167. package/dist/entity/connectors/static.js.map +1 -0
  168. package/dist/entity/entity-datasource.d.ts +50 -0
  169. package/dist/entity/entity-datasource.js +33 -0
  170. package/dist/entity/entity-datasource.js.map +1 -0
  171. package/dist/entity/facade.d.ts +70 -0
  172. package/dist/entity/facade.js +70 -0
  173. package/dist/entity/facade.js.map +1 -0
  174. package/dist/entity/http-connector.d.ts +123 -0
  175. package/dist/entity/http-connector.js +295 -0
  176. package/dist/entity/http-connector.js.map +1 -0
  177. package/dist/entity/index.d.ts +38 -0
  178. package/dist/entity/index.js +31 -0
  179. package/dist/entity/index.js.map +1 -0
  180. package/dist/entity/postgres-connector.d.ts +64 -0
  181. package/dist/entity/postgres-connector.js +239 -0
  182. package/dist/entity/postgres-connector.js.map +1 -0
  183. package/dist/entity/registry.d.ts +59 -0
  184. package/dist/entity/registry.js +90 -0
  185. package/dist/entity/registry.js.map +1 -0
  186. package/dist/entity/store.d.ts +66 -0
  187. package/dist/entity/store.js +349 -0
  188. package/dist/entity/store.js.map +1 -0
  189. package/dist/entity/types.d.ts +180 -0
  190. package/dist/entity/types.js +10 -0
  191. package/dist/entity/types.js.map +1 -0
  192. package/dist/execution-context.d.ts +88 -0
  193. package/dist/execution-context.js +146 -0
  194. package/dist/execution-context.js.map +1 -0
  195. package/dist/executor.d.ts +27 -0
  196. package/dist/executor.js +33 -0
  197. package/dist/executor.js.map +1 -0
  198. package/dist/forms/form-entity-bridge.d.ts +94 -0
  199. package/dist/forms/form-entity-bridge.js +96 -0
  200. package/dist/forms/form-entity-bridge.js.map +1 -0
  201. package/dist/forms/form-write-target.d.ts +34 -0
  202. package/dist/forms/form-write-target.js +81 -0
  203. package/dist/forms/form-write-target.js.map +1 -0
  204. package/dist/forms/index.d.ts +22 -0
  205. package/dist/forms/index.js +25 -0
  206. package/dist/forms/index.js.map +1 -0
  207. package/dist/forms/named-control-values.d.ts +27 -0
  208. package/dist/forms/named-control-values.js +42 -0
  209. package/dist/forms/named-control-values.js.map +1 -0
  210. package/dist/forms/processor.d.ts +55 -0
  211. package/dist/forms/processor.js +154 -0
  212. package/dist/forms/processor.js.map +1 -0
  213. package/dist/forms/types.d.ts +174 -0
  214. package/dist/forms/types.js +33 -0
  215. package/dist/forms/types.js.map +1 -0
  216. package/dist/forms/validator.d.ts +61 -0
  217. package/dist/forms/validator.js +218 -0
  218. package/dist/forms/validator.js.map +1 -0
  219. package/dist/graph/index.d.ts +10 -0
  220. package/dist/graph/index.js +9 -0
  221. package/dist/graph/index.js.map +1 -0
  222. package/dist/graph/resolver.d.ts +66 -0
  223. package/dist/graph/resolver.js +243 -0
  224. package/dist/graph/resolver.js.map +1 -0
  225. package/dist/graph/types.d.ts +125 -0
  226. package/dist/graph/types.js +9 -0
  227. package/dist/graph/types.js.map +1 -0
  228. package/dist/hooks/useInstalledAtoms.d.ts +96 -0
  229. package/dist/hooks/useInstalledAtoms.js +92 -0
  230. package/dist/hooks/useInstalledAtoms.js.map +1 -0
  231. package/dist/i18n/index.d.ts +15 -0
  232. package/dist/i18n/index.js +14 -0
  233. package/dist/i18n/index.js.map +1 -0
  234. package/dist/i18n/translator.d.ts +76 -0
  235. package/dist/i18n/translator.js +357 -0
  236. package/dist/i18n/translator.js.map +1 -0
  237. package/dist/i18n/types.d.ts +93 -0
  238. package/dist/i18n/types.js +9 -0
  239. package/dist/i18n/types.js.map +1 -0
  240. package/dist/index.d.ts +64 -0
  241. package/dist/index.js +95 -0
  242. package/dist/index.js.map +1 -0
  243. package/dist/kernel.d.ts +47 -0
  244. package/dist/kernel.js +258 -0
  245. package/dist/kernel.js.map +1 -0
  246. package/dist/perf/budget.d.ts +92 -0
  247. package/dist/perf/budget.js +122 -0
  248. package/dist/perf/budget.js.map +1 -0
  249. package/dist/perf/index.d.ts +16 -0
  250. package/dist/perf/index.js +13 -0
  251. package/dist/perf/index.js.map +1 -0
  252. package/dist/perf/render-timer.d.ts +90 -0
  253. package/dist/perf/render-timer.js +136 -0
  254. package/dist/perf/render-timer.js.map +1 -0
  255. package/dist/perf/reporter.d.ts +126 -0
  256. package/dist/perf/reporter.js +241 -0
  257. package/dist/perf/reporter.js.map +1 -0
  258. package/dist/perf/web-vitals.d.ts +111 -0
  259. package/dist/perf/web-vitals.js +268 -0
  260. package/dist/perf/web-vitals.js.map +1 -0
  261. package/dist/registry.d.ts +63 -0
  262. package/dist/registry.js +126 -0
  263. package/dist/registry.js.map +1 -0
  264. package/dist/render/BehaviorSurfaceProvider.d.ts +65 -0
  265. package/dist/render/BehaviorSurfaceProvider.js +185 -0
  266. package/dist/render/BehaviorSurfaceProvider.js.map +1 -0
  267. package/dist/render/BlockErrorBoundary.d.ts +26 -0
  268. package/dist/render/BlockErrorBoundary.js +41 -0
  269. package/dist/render/BlockErrorBoundary.js.map +1 -0
  270. package/dist/render/DataBoundSurfaceRenderer.d.ts +78 -0
  271. package/dist/render/DataBoundSurfaceRenderer.js +998 -0
  272. package/dist/render/DataBoundSurfaceRenderer.js.map +1 -0
  273. package/dist/render/DynamicBlockWrapper.d.ts +23 -0
  274. package/dist/render/DynamicBlockWrapper.js +117 -0
  275. package/dist/render/DynamicBlockWrapper.js.map +1 -0
  276. package/dist/render/appearance-resolver.d.ts +50 -0
  277. package/dist/render/appearance-resolver.js +78 -0
  278. package/dist/render/appearance-resolver.js.map +1 -0
  279. package/dist/render/capability-gate.d.ts +69 -0
  280. package/dist/render/capability-gate.js +94 -0
  281. package/dist/render/capability-gate.js.map +1 -0
  282. package/dist/render/conditional-states-css.d.ts +41 -0
  283. package/dist/render/conditional-states-css.js +82 -0
  284. package/dist/render/conditional-states-css.js.map +1 -0
  285. package/dist/render/connections-context.d.ts +31 -0
  286. package/dist/render/connections-context.js +34 -0
  287. package/dist/render/connections-context.js.map +1 -0
  288. package/dist/render/dark-theme-css.d.ts +36 -0
  289. package/dist/render/dark-theme-css.js +67 -0
  290. package/dist/render/dark-theme-css.js.map +1 -0
  291. package/dist/render/data-binding-types.d.ts +191 -0
  292. package/dist/render/data-binding-types.js +11 -0
  293. package/dist/render/data-binding-types.js.map +1 -0
  294. package/dist/render/data-cache.d.ts +30 -0
  295. package/dist/render/data-cache.js +37 -0
  296. package/dist/render/data-cache.js.map +1 -0
  297. package/dist/render/derive-dark-theme.d.ts +17 -0
  298. package/dist/render/derive-dark-theme.js +18 -0
  299. package/dist/render/derive-dark-theme.js.map +1 -0
  300. package/dist/render/dynamic-artifact-context.d.ts +77 -0
  301. package/dist/render/dynamic-artifact-context.js +89 -0
  302. package/dist/render/dynamic-artifact-context.js.map +1 -0
  303. package/dist/render/dynamic-block-loader.d.ts +80 -0
  304. package/dist/render/dynamic-block-loader.js +197 -0
  305. package/dist/render/dynamic-block-loader.js.map +1 -0
  306. package/dist/render/endpoint.d.ts +18 -0
  307. package/dist/render/endpoint.js +109 -0
  308. package/dist/render/endpoint.js.map +1 -0
  309. package/dist/render/entity-facade-context.d.ts +34 -0
  310. package/dist/render/entity-facade-context.js +37 -0
  311. package/dist/render/entity-facade-context.js.map +1 -0
  312. package/dist/render/group-states-css.d.ts +41 -0
  313. package/dist/render/group-states-css.js +73 -0
  314. package/dist/render/group-states-css.js.map +1 -0
  315. package/dist/render/hooks/useSurfaceEvents.d.ts +8 -0
  316. package/dist/render/hooks/useSurfaceEvents.js +9 -0
  317. package/dist/render/hooks/useSurfaceEvents.js.map +1 -0
  318. package/dist/render/hooks/useSurfaceId.d.ts +8 -0
  319. package/dist/render/hooks/useSurfaceId.js +9 -0
  320. package/dist/render/hooks/useSurfaceId.js.map +1 -0
  321. package/dist/render/index.d.ts +48 -0
  322. package/dist/render/index.js +61 -0
  323. package/dist/render/index.js.map +1 -0
  324. package/dist/render/interaction-rule-engine.d.ts +12 -0
  325. package/dist/render/interaction-rule-engine.js +47 -0
  326. package/dist/render/interaction-rule-engine.js.map +1 -0
  327. package/dist/render/keyframes-css.d.ts +31 -0
  328. package/dist/render/keyframes-css.js +44 -0
  329. package/dist/render/keyframes-css.js.map +1 -0
  330. package/dist/render/query-state.d.ts +3 -0
  331. package/dist/render/query-state.js +70 -0
  332. package/dist/render/query-state.js.map +1 -0
  333. package/dist/render/renderer.d.ts +44 -0
  334. package/dist/render/renderer.js +937 -0
  335. package/dist/render/renderer.js.map +1 -0
  336. package/dist/render/resolve-expressions.d.ts +37 -0
  337. package/dist/render/resolve-expressions.js +309 -0
  338. package/dist/render/resolve-expressions.js.map +1 -0
  339. package/dist/render/responsive-style-css.d.ts +42 -0
  340. package/dist/render/responsive-style-css.js +123 -0
  341. package/dist/render/responsive-style-css.js.map +1 -0
  342. package/dist/render/responsive.d.ts +49 -0
  343. package/dist/render/responsive.js +99 -0
  344. package/dist/render/responsive.js.map +1 -0
  345. package/dist/render/scoped-css.d.ts +71 -0
  346. package/dist/render/scoped-css.js +102 -0
  347. package/dist/render/scoped-css.js.map +1 -0
  348. package/dist/render/shell-selection.d.ts +69 -0
  349. package/dist/render/shell-selection.js +117 -0
  350. package/dist/render/shell-selection.js.map +1 -0
  351. package/dist/render/states-css.d.ts +32 -0
  352. package/dist/render/states-css.js +63 -0
  353. package/dist/render/states-css.js.map +1 -0
  354. package/dist/render/surface-data-context.d.ts +18 -0
  355. package/dist/render/surface-data-context.js +21 -0
  356. package/dist/render/surface-data-context.js.map +1 -0
  357. package/dist/render/surface-event-bus.d.ts +19 -0
  358. package/dist/render/surface-event-bus.js +68 -0
  359. package/dist/render/surface-event-bus.js.map +1 -0
  360. package/dist/render/surface-event-context.d.ts +11 -0
  361. package/dist/render/surface-event-context.js +12 -0
  362. package/dist/render/surface-event-context.js.map +1 -0
  363. package/dist/render/surface-id-context.d.ts +8 -0
  364. package/dist/render/surface-id-context.js +9 -0
  365. package/dist/render/surface-id-context.js.map +1 -0
  366. package/dist/render/theme-utils.d.ts +14 -0
  367. package/dist/render/theme-utils.js +15 -0
  368. package/dist/render/theme-utils.js.map +1 -0
  369. package/dist/render/types.d.ts +282 -0
  370. package/dist/render/types.js +9 -0
  371. package/dist/render/types.js.map +1 -0
  372. package/dist/render/visibility-css.d.ts +42 -0
  373. package/dist/render/visibility-css.js +119 -0
  374. package/dist/render/visibility-css.js.map +1 -0
  375. package/dist/render/width-scope.d.ts +34 -0
  376. package/dist/render/width-scope.js +44 -0
  377. package/dist/render/width-scope.js.map +1 -0
  378. package/dist/render/write-only-sources.d.ts +33 -0
  379. package/dist/render/write-only-sources.js +99 -0
  380. package/dist/render/write-only-sources.js.map +1 -0
  381. package/dist/routing/index.d.ts +14 -0
  382. package/dist/routing/index.js +15 -0
  383. package/dist/routing/index.js.map +1 -0
  384. package/dist/routing/router.d.ts +42 -0
  385. package/dist/routing/router.js +218 -0
  386. package/dist/routing/router.js.map +1 -0
  387. package/dist/routing/types.d.ts +124 -0
  388. package/dist/routing/types.js +9 -0
  389. package/dist/routing/types.js.map +1 -0
  390. package/dist/seo/generator.d.ts +39 -0
  391. package/dist/seo/generator.js +236 -0
  392. package/dist/seo/generator.js.map +1 -0
  393. package/dist/seo/index.d.ts +14 -0
  394. package/dist/seo/index.js +15 -0
  395. package/dist/seo/index.js.map +1 -0
  396. package/dist/seo/types.d.ts +181 -0
  397. package/dist/seo/types.js +9 -0
  398. package/dist/seo/types.js.map +1 -0
  399. package/dist/state/index.d.ts +15 -0
  400. package/dist/state/index.js +16 -0
  401. package/dist/state/index.js.map +1 -0
  402. package/dist/state/manager.d.ts +33 -0
  403. package/dist/state/manager.js +81 -0
  404. package/dist/state/manager.js.map +1 -0
  405. package/dist/state/store.d.ts +40 -0
  406. package/dist/state/store.js +145 -0
  407. package/dist/state/store.js.map +1 -0
  408. package/dist/state/types.d.ts +107 -0
  409. package/dist/state/types.js +9 -0
  410. package/dist/state/types.js.map +1 -0
  411. package/dist/surface/expression.d.ts +65 -0
  412. package/dist/surface/expression.js +179 -0
  413. package/dist/surface/expression.js.map +1 -0
  414. package/dist/surface/index.d.ts +32 -0
  415. package/dist/surface/index.js +25 -0
  416. package/dist/surface/index.js.map +1 -0
  417. package/dist/surface/interpreter.d.ts +96 -0
  418. package/dist/surface/interpreter.js +231 -0
  419. package/dist/surface/interpreter.js.map +1 -0
  420. package/dist/surface/layout.d.ts +54 -0
  421. package/dist/surface/layout.js +288 -0
  422. package/dist/surface/layout.js.map +1 -0
  423. package/dist/surface/output.d.ts +90 -0
  424. package/dist/surface/output.js +104 -0
  425. package/dist/surface/output.js.map +1 -0
  426. package/dist/surface/primitives.d.ts +180 -0
  427. package/dist/surface/primitives.js +339 -0
  428. package/dist/surface/primitives.js.map +1 -0
  429. package/dist/surface/renderer.d.ts +96 -0
  430. package/dist/surface/renderer.js +190 -0
  431. package/dist/surface/renderer.js.map +1 -0
  432. package/dist/surface/schemas.d.ts +181 -0
  433. package/dist/surface/schemas.js +142 -0
  434. package/dist/surface/schemas.js.map +1 -0
  435. package/dist/surface/transforms.d.ts +144 -0
  436. package/dist/surface/transforms.js +120 -0
  437. package/dist/surface/transforms.js.map +1 -0
  438. package/dist/surface/types.d.ts +160 -0
  439. package/dist/surface/types.js +51 -0
  440. package/dist/surface/types.js.map +1 -0
  441. package/dist/surface/validation.d.ts +123 -0
  442. package/dist/surface/validation.js +147 -0
  443. package/dist/surface/validation.js.map +1 -0
  444. package/dist/validator.d.ts +55 -0
  445. package/dist/validator.js +100 -0
  446. package/dist/validator.js.map +1 -0
  447. package/package.json +106 -3
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Entity Lifecycle Engine
3
+ *
4
+ * Event-driven logic on entity lifecycle transitions
5
+ * using a trigger-guard-action pattern with priority-based execution.
6
+ *
7
+ * @module @pwfabric/runtime/entity/behavior
8
+ */
9
+ import type { EntityTypeId, EntityInstanceId } from './types.js';
10
+ /**
11
+ * Entity lifecycle events
12
+ */
13
+ export type EntityLifecycleEvent = 'onCreate' | 'onUpdate' | 'onDelete' | 'onRead';
14
+ /**
15
+ * Context passed to guards and actions during lifecycle hook execution
16
+ */
17
+ export interface EntityBehaviorContext {
18
+ readonly entityType: EntityTypeId;
19
+ readonly event: EntityLifecycleEvent;
20
+ readonly data: Record<string, unknown>;
21
+ readonly previousData?: Record<string, unknown>;
22
+ readonly instanceId?: EntityInstanceId;
23
+ readonly metadata: Readonly<Record<string, unknown>>;
24
+ }
25
+ /**
26
+ * Guard function that determines whether an action should execute
27
+ */
28
+ export type EntityGuard = (context: EntityBehaviorContext) => boolean;
29
+ /**
30
+ * Action function executed during a lifecycle event
31
+ */
32
+ export type EntityAction = (context: EntityBehaviorContext) => void | Promise<void>;
33
+ /**
34
+ * Entity lifecycle hook definition combining trigger, guard, and action.
35
+ * Primary name de-behaviorization.
36
+ */
37
+ export interface EntityLifecycleHook {
38
+ readonly id: string;
39
+ readonly entityType: EntityTypeId;
40
+ readonly trigger: EntityLifecycleEvent;
41
+ readonly guard?: EntityGuard;
42
+ readonly action: EntityAction;
43
+ readonly priority?: number;
44
+ }
45
+ /**
46
+ * Entity lifecycle hook engine — registers and executes the
47
+ * onCreate/onUpdate/onDelete/onRead hooks.
48
+ */
49
+ export interface EntityLifecycleEngine {
50
+ /**
51
+ * Register a lifecycle hook
52
+ * @throws Error if a hook with the same id is already registered
53
+ */
54
+ register(hook: EntityLifecycleHook): void;
55
+ /**
56
+ * Unregister a hook by id
57
+ */
58
+ unregister(hookId: string): boolean;
59
+ /**
60
+ * Execute all matching hooks for an entity type and event.
61
+ * Hooks are executed in priority order (lower priority number = higher precedence).
62
+ * Guards are checked before each action. Async actions are awaited.
63
+ */
64
+ execute(entityType: EntityTypeId, event: EntityLifecycleEvent, context: EntityBehaviorContext): Promise<void>;
65
+ /**
66
+ * Get all hooks for an entity type, optionally filtered by event
67
+ */
68
+ getBehaviors(entityType: EntityTypeId, event?: EntityLifecycleEvent): readonly EntityLifecycleHook[];
69
+ /**
70
+ * Remove all hooks
71
+ */
72
+ clear(): void;
73
+ }
74
+ /**
75
+ * Default EntityLifecycleEngine implementation.
76
+ * Stores hooks in a Map, executes in priority order.
77
+ */
78
+ export declare class DefaultEntityLifecycleEngine implements EntityLifecycleEngine {
79
+ private readonly hooks;
80
+ register(hook: EntityLifecycleHook): void;
81
+ unregister(hookId: string): boolean;
82
+ execute(entityType: EntityTypeId, event: EntityLifecycleEvent, context: EntityBehaviorContext): Promise<void>;
83
+ getBehaviors(entityType: EntityTypeId, event?: EntityLifecycleEvent): readonly EntityLifecycleHook[];
84
+ clear(): void;
85
+ }
86
+ /**
87
+ * Entity lifecycle transition type. Use instead of EntityLifecycleEvent
88
+ * when referring to transitions (not bus events).
89
+ */
90
+ export type EntityLifecycleTransition = EntityLifecycleEvent;
91
+ /**
92
+ * Create an entity lifecycle engine.
93
+ */
94
+ export declare function createEntityLifecycleEngine(): EntityLifecycleEngine;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Entity Lifecycle Engine
3
+ *
4
+ * Event-driven logic on entity lifecycle transitions
5
+ * using a trigger-guard-action pattern with priority-based execution.
6
+ *
7
+ * @module @pwfabric/runtime/entity/behavior
8
+ */
9
+ // ============================================================
10
+ // DEFAULT BEHAVIOR ENGINE
11
+ // ============================================================
12
+ /**
13
+ * Default EntityLifecycleEngine implementation.
14
+ * Stores hooks in a Map, executes in priority order.
15
+ */
16
+ export class DefaultEntityLifecycleEngine {
17
+ hooks = new Map();
18
+ register(hook) {
19
+ if (!hook.id) {
20
+ throw new Error('Lifecycle hook must have an id');
21
+ }
22
+ if (!hook.entityType) {
23
+ throw new Error('Lifecycle hook must have an entityType');
24
+ }
25
+ if (!hook.trigger) {
26
+ throw new Error('Lifecycle hook must have a trigger');
27
+ }
28
+ if (!hook.action) {
29
+ throw new Error('Lifecycle hook must have an action');
30
+ }
31
+ if (this.hooks.has(hook.id)) {
32
+ throw new Error(`Lifecycle hook '${hook.id}' is already registered`);
33
+ }
34
+ this.hooks.set(hook.id, hook);
35
+ }
36
+ unregister(hookId) {
37
+ return this.hooks.delete(hookId);
38
+ }
39
+ async execute(entityType, event, context) {
40
+ const matching = this.getBehaviors(entityType, event);
41
+ // Sort by priority (lower number = higher precedence, default = 100)
42
+ const sorted = [...matching].sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));
43
+ for (const hook of sorted) {
44
+ // Check guard
45
+ if (hook.guard) {
46
+ const allowed = hook.guard(context);
47
+ if (!allowed) {
48
+ continue;
49
+ }
50
+ }
51
+ // Execute action (await if async)
52
+ await hook.action(context);
53
+ }
54
+ }
55
+ getBehaviors(entityType, event) {
56
+ const result = [];
57
+ for (const hook of this.hooks.values()) {
58
+ if (hook.entityType !== entityType) {
59
+ continue;
60
+ }
61
+ if (event && hook.trigger !== event) {
62
+ continue;
63
+ }
64
+ result.push(hook);
65
+ }
66
+ return result;
67
+ }
68
+ clear() {
69
+ this.hooks.clear();
70
+ }
71
+ }
72
+ /**
73
+ * Create an entity lifecycle engine.
74
+ */
75
+ export function createEntityLifecycleEngine() {
76
+ return new DefaultEntityLifecycleEngine();
77
+ }
78
+ //# sourceMappingURL=behavior.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"behavior.js","sourceRoot":"","sources":["../../src/entity/behavior.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA6FH,+DAA+D;AAC/D,0BAA0B;AAC1B,+DAA+D;AAE/D;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IACtB,KAAK,GAAG,IAAI,GAAG,EAA+B,CAAA;IAE/D,QAAQ,CAAC,IAAyB;QAChC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACnD,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;QAC3D,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;QACvD,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;QACvD,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,CAAC,EAAE,yBAAyB,CAAC,CAAA;QACtE,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IAC/B,CAAC;IAED,UAAU,CAAC,MAAc;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;IAED,KAAK,CAAC,OAAO,CACX,UAAwB,EACxB,KAA2B,EAC3B,OAA8B;QAE9B,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;QAErD,qEAAqE;QACrE,MAAM,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAA;QAEtF,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YAC1B,cAAc;YACd,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;gBACnC,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,SAAQ;gBACV,CAAC;YACH,CAAC;YAED,kCAAkC;YAClC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,YAAY,CACV,UAAwB,EACxB,KAA4B;QAE5B,MAAM,MAAM,GAA0B,EAAE,CAAA;QAExC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,IAAI,IAAI,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;gBACnC,SAAQ;YACV,CAAC;YAED,IAAI,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;gBACpC,SAAQ;YACV,CAAC;YAED,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACnB,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF;AAYD;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,IAAI,4BAA4B,EAAE,CAAA;AAC3C,CAAC","sourcesContent":["/**\n * Entity Lifecycle Engine\n *\n * Event-driven logic on entity lifecycle transitions\n * using a trigger-guard-action pattern with priority-based execution.\n *\n * @module @pwfabric/runtime/entity/behavior\n */\n\nimport type { EntityTypeId, EntityInstanceId } from './types.js'\n\n// ============================================================\n// LIFECYCLE TYPES\n// ============================================================\n\n/**\n * Entity lifecycle events\n */\nexport type EntityLifecycleEvent = 'onCreate' | 'onUpdate' | 'onDelete' | 'onRead'\n\n/**\n * Context passed to guards and actions during lifecycle hook execution\n */\nexport interface EntityBehaviorContext {\n readonly entityType: EntityTypeId\n readonly event: EntityLifecycleEvent\n readonly data: Record<string, unknown>\n readonly previousData?: Record<string, unknown>\n readonly instanceId?: EntityInstanceId\n readonly metadata: Readonly<Record<string, unknown>>\n}\n\n/**\n * Guard function that determines whether an action should execute\n */\nexport type EntityGuard = (context: EntityBehaviorContext) => boolean\n\n/**\n * Action function executed during a lifecycle event\n */\nexport type EntityAction = (context: EntityBehaviorContext) => void | Promise<void>\n\n/**\n * Entity lifecycle hook definition combining trigger, guard, and action.\n * Primary name de-behaviorization.\n */\nexport interface EntityLifecycleHook {\n readonly id: string\n readonly entityType: EntityTypeId\n readonly trigger: EntityLifecycleEvent\n readonly guard?: EntityGuard\n readonly action: EntityAction\n readonly priority?: number\n}\n\n// ============================================================\n// LIFECYCLE ENGINE INTERFACE\n// ============================================================\n\n/**\n * Entity lifecycle hook engine — registers and executes the\n * onCreate/onUpdate/onDelete/onRead hooks.\n */\nexport interface EntityLifecycleEngine {\n /**\n * Register a lifecycle hook\n * @throws Error if a hook with the same id is already registered\n */\n register(hook: EntityLifecycleHook): void\n\n /**\n * Unregister a hook by id\n */\n unregister(hookId: string): boolean\n\n /**\n * Execute all matching hooks for an entity type and event.\n * Hooks are executed in priority order (lower priority number = higher precedence).\n * Guards are checked before each action. Async actions are awaited.\n */\n execute(\n entityType: EntityTypeId,\n event: EntityLifecycleEvent,\n context: EntityBehaviorContext\n ): Promise<void>\n\n /**\n * Get all hooks for an entity type, optionally filtered by event\n */\n getBehaviors(\n entityType: EntityTypeId,\n event?: EntityLifecycleEvent\n ): readonly EntityLifecycleHook[]\n\n /**\n * Remove all hooks\n */\n clear(): void\n}\n\n// ============================================================\n// DEFAULT BEHAVIOR ENGINE\n// ============================================================\n\n/**\n * Default EntityLifecycleEngine implementation.\n * Stores hooks in a Map, executes in priority order.\n */\nexport class DefaultEntityLifecycleEngine implements EntityLifecycleEngine {\n private readonly hooks = new Map<string, EntityLifecycleHook>()\n\n register(hook: EntityLifecycleHook): void {\n if (!hook.id) {\n throw new Error('Lifecycle hook must have an id')\n }\n\n if (!hook.entityType) {\n throw new Error('Lifecycle hook must have an entityType')\n }\n\n if (!hook.trigger) {\n throw new Error('Lifecycle hook must have a trigger')\n }\n\n if (!hook.action) {\n throw new Error('Lifecycle hook must have an action')\n }\n\n if (this.hooks.has(hook.id)) {\n throw new Error(`Lifecycle hook '${hook.id}' is already registered`)\n }\n\n this.hooks.set(hook.id, hook)\n }\n\n unregister(hookId: string): boolean {\n return this.hooks.delete(hookId)\n }\n\n async execute(\n entityType: EntityTypeId,\n event: EntityLifecycleEvent,\n context: EntityBehaviorContext\n ): Promise<void> {\n const matching = this.getBehaviors(entityType, event)\n\n // Sort by priority (lower number = higher precedence, default = 100)\n const sorted = [...matching].sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100))\n\n for (const hook of sorted) {\n // Check guard\n if (hook.guard) {\n const allowed = hook.guard(context)\n if (!allowed) {\n continue\n }\n }\n\n // Execute action (await if async)\n await hook.action(context)\n }\n }\n\n getBehaviors(\n entityType: EntityTypeId,\n event?: EntityLifecycleEvent\n ): readonly EntityLifecycleHook[] {\n const result: EntityLifecycleHook[] = []\n\n for (const hook of this.hooks.values()) {\n if (hook.entityType !== entityType) {\n continue\n }\n\n if (event && hook.trigger !== event) {\n continue\n }\n\n result.push(hook)\n }\n\n return result\n }\n\n clear(): void {\n this.hooks.clear()\n }\n}\n\n// ============================================================\n// LIFECYCLE TRANSITIONS AND FACTORY\n// ============================================================\n\n/**\n * Entity lifecycle transition type. Use instead of EntityLifecycleEvent\n * when referring to transitions (not bus events).\n */\nexport type EntityLifecycleTransition = EntityLifecycleEvent\n\n/**\n * Create an entity lifecycle engine.\n */\nexport function createEntityLifecycleEngine(): EntityLifecycleEngine {\n return new DefaultEntityLifecycleEngine()\n}\n"]}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Entity Connector Interface
3
+ *
4
+ * Connector abstraction for entity data persistence and retrieval.
5
+ * Follows the adapter pattern established by existing data source implementations.
6
+ *
7
+ * @module @pwfabric/runtime/entity/connector
8
+ */
9
+ import type { EntityTypeId, EntityInstanceId, EntityQuery, EntityQueryResult, EntityAggregate, EntityAggregateResult } from './types.js';
10
+ /**
11
+ * Supported connector types
12
+ */
13
+ export type EntityConnectorType = 'http' | 'database' | 'static' | 'custom';
14
+ /**
15
+ * Result of a connector CRUD operation
16
+ */
17
+ export type ConnectorResult = {
18
+ readonly success: true;
19
+ readonly data: Record<string, unknown>;
20
+ } | {
21
+ readonly success: false;
22
+ readonly error: string;
23
+ };
24
+ /**
25
+ * Result of a connector query operation
26
+ */
27
+ export type ConnectorQueryResult = {
28
+ readonly success: true;
29
+ readonly result: EntityQueryResult;
30
+ } | {
31
+ readonly success: false;
32
+ readonly error: string;
33
+ };
34
+ /**
35
+ * Result of a connector aggregate operation
36
+ */
37
+ export type ConnectorAggregateResult = {
38
+ readonly success: true;
39
+ readonly result: EntityAggregateResult;
40
+ } | {
41
+ readonly success: false;
42
+ readonly error: string;
43
+ };
44
+ /**
45
+ * Interface for entity data connectors.
46
+ * Connectors handle actual data persistence and retrieval.
47
+ */
48
+ export interface EntityConnector {
49
+ /** Connector name for identification */
50
+ readonly name: string;
51
+ /** Connector type */
52
+ readonly type: EntityConnectorType;
53
+ /**
54
+ * Create a new entity instance
55
+ */
56
+ create(entityType: EntityTypeId, data: Record<string, unknown>): Promise<ConnectorResult>;
57
+ /**
58
+ * Read a single entity instance by id
59
+ */
60
+ read(entityType: EntityTypeId, instanceId: EntityInstanceId): Promise<ConnectorResult>;
61
+ /**
62
+ * Update an existing entity instance
63
+ */
64
+ update(entityType: EntityTypeId, instanceId: EntityInstanceId, data: Record<string, unknown>): Promise<ConnectorResult>;
65
+ /**
66
+ * Delete an entity instance
67
+ */
68
+ delete(entityType: EntityTypeId, instanceId: EntityInstanceId): Promise<ConnectorResult>;
69
+ /**
70
+ * Query entity instances with filter, sort, and pagination
71
+ */
72
+ query(entityType: EntityTypeId, query: EntityQuery): Promise<ConnectorQueryResult>;
73
+ /**
74
+ * One number over the collection, server-side. OPTIONAL: a connector
75
+ * that only lists is reduced in memory by `aggregateThrough` instead.
76
+ */
77
+ aggregate?(entityType: EntityTypeId, aggregate: EntityAggregate): Promise<ConnectorAggregateResult>;
78
+ }
79
+ /**
80
+ * Registry for entity connectors with per-entity-type binding support
81
+ */
82
+ export interface ConnectorRegistry {
83
+ /**
84
+ * Register a connector by name
85
+ */
86
+ register(connector: EntityConnector): void;
87
+ /**
88
+ * Get a connector by name
89
+ */
90
+ get(name: string): EntityConnector | undefined;
91
+ /**
92
+ * Check if a connector is registered
93
+ */
94
+ has(name: string): boolean;
95
+ /**
96
+ * Bind an entity type to a specific connector
97
+ */
98
+ bind(entityType: EntityTypeId, connectorName: string): void;
99
+ /**
100
+ * Resolve the connector for an entity type.
101
+ * Returns the bound connector, or the default connector if set.
102
+ */
103
+ resolve(entityType: EntityTypeId): EntityConnector | undefined;
104
+ /**
105
+ * Set a default connector for unbound entity types
106
+ */
107
+ setDefault(connectorName: string): void;
108
+ /**
109
+ * List all registered connector names
110
+ */
111
+ list(): readonly string[];
112
+ /**
113
+ * Remove a connector by name
114
+ */
115
+ unregister(name: string): boolean;
116
+ /**
117
+ * Remove all connectors and bindings
118
+ */
119
+ clear(): void;
120
+ }
121
+ /**
122
+ * In-memory implementation of ConnectorRegistry
123
+ */
124
+ export declare class InMemoryConnectorRegistry implements ConnectorRegistry {
125
+ private readonly connectors;
126
+ private readonly bindings;
127
+ private defaultConnectorName;
128
+ register(connector: EntityConnector): void;
129
+ get(name: string): EntityConnector | undefined;
130
+ has(name: string): boolean;
131
+ bind(entityType: EntityTypeId, connectorName: string): void;
132
+ resolve(entityType: EntityTypeId): EntityConnector | undefined;
133
+ setDefault(connectorName: string): void;
134
+ list(): readonly string[];
135
+ unregister(name: string): boolean;
136
+ clear(): void;
137
+ }
138
+ /**
139
+ * Create a connector registry
140
+ */
141
+ export declare function createConnectorRegistry(): ConnectorRegistry;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Entity Connector Interface
3
+ *
4
+ * Connector abstraction for entity data persistence and retrieval.
5
+ * Follows the adapter pattern established by existing data source implementations.
6
+ *
7
+ * @module @pwfabric/runtime/entity/connector
8
+ */
9
+ // ============================================================
10
+ // IN-MEMORY CONNECTOR REGISTRY
11
+ // ============================================================
12
+ /**
13
+ * In-memory implementation of ConnectorRegistry
14
+ */
15
+ export class InMemoryConnectorRegistry {
16
+ connectors = new Map();
17
+ bindings = new Map();
18
+ defaultConnectorName;
19
+ register(connector) {
20
+ if (!connector.name) {
21
+ throw new Error('Connector must have a name');
22
+ }
23
+ if (this.connectors.has(connector.name)) {
24
+ throw new Error(`Connector '${connector.name}' is already registered`);
25
+ }
26
+ this.connectors.set(connector.name, connector);
27
+ }
28
+ get(name) {
29
+ return this.connectors.get(name);
30
+ }
31
+ has(name) {
32
+ return this.connectors.has(name);
33
+ }
34
+ bind(entityType, connectorName) {
35
+ if (!this.connectors.has(connectorName)) {
36
+ throw new Error(`Connector '${connectorName}' is not registered`);
37
+ }
38
+ this.bindings.set(entityType, connectorName);
39
+ }
40
+ resolve(entityType) {
41
+ // Check entity-specific binding first
42
+ const boundName = this.bindings.get(entityType);
43
+ if (boundName) {
44
+ return this.connectors.get(boundName);
45
+ }
46
+ // Fall back to default
47
+ if (this.defaultConnectorName) {
48
+ return this.connectors.get(this.defaultConnectorName);
49
+ }
50
+ return undefined;
51
+ }
52
+ setDefault(connectorName) {
53
+ if (!this.connectors.has(connectorName)) {
54
+ throw new Error(`Connector '${connectorName}' is not registered`);
55
+ }
56
+ this.defaultConnectorName = connectorName;
57
+ }
58
+ list() {
59
+ return Array.from(this.connectors.keys());
60
+ }
61
+ unregister(name) {
62
+ // Remove any bindings pointing to this connector
63
+ for (const [entityType, boundName] of this.bindings) {
64
+ if (boundName === name) {
65
+ this.bindings.delete(entityType);
66
+ }
67
+ }
68
+ // Clear default if it matches
69
+ if (this.defaultConnectorName === name) {
70
+ this.defaultConnectorName = undefined;
71
+ }
72
+ return this.connectors.delete(name);
73
+ }
74
+ clear() {
75
+ this.connectors.clear();
76
+ this.bindings.clear();
77
+ this.defaultConnectorName = undefined;
78
+ }
79
+ }
80
+ // ============================================================
81
+ // FACTORY FUNCTION
82
+ // ============================================================
83
+ /**
84
+ * Create a connector registry
85
+ */
86
+ export function createConnectorRegistry() {
87
+ return new InMemoryConnectorRegistry();
88
+ }
89
+ //# sourceMappingURL=connector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector.js","sourceRoot":"","sources":["../../src/entity/connector.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmJH,+DAA+D;AAC/D,+BAA+B;AAC/B,+DAA+D;AAE/D;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACnB,UAAU,GAAG,IAAI,GAAG,EAA2B,CAAA;IAC/C,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAA;IACnD,oBAAoB,CAAoB;IAEhD,QAAQ,CAAC,SAA0B;QACjC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC/C,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,cAAc,SAAS,CAAC,IAAI,yBAAyB,CAAC,CAAA;QACxE,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IAChD,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAED,IAAI,CAAC,UAAwB,EAAE,aAAqB;QAClD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,cAAc,aAAa,qBAAqB,CAAC,CAAA;QACnE,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;IAC9C,CAAC;IAED,OAAO,CAAC,UAAwB;QAC9B,sCAAsC;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAC/C,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QACvC,CAAC;QAED,uBAAuB;QACvB,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;QACvD,CAAC;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,UAAU,CAAC,aAAqB;QAC9B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,cAAc,aAAa,qBAAqB,CAAC,CAAA;QACnE,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,aAAa,CAAA;IAC3C,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAA;IAC3C,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,iDAAiD;QACjD,KAAK,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpD,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;gBACvB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;YAClC,CAAC;QACH,CAAC;QAED,8BAA8B;QAC9B,IAAI,IAAI,CAAC,oBAAoB,KAAK,IAAI,EAAE,CAAC;YACvC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAA;QACvC,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;QACvB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;QACrB,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAA;IACvC,CAAC;CACF;AAED,+DAA+D;AAC/D,mBAAmB;AACnB,+DAA+D;AAE/D;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,IAAI,yBAAyB,EAAE,CAAA;AACxC,CAAC","sourcesContent":["/**\n * Entity Connector Interface\n *\n * Connector abstraction for entity data persistence and retrieval.\n * Follows the adapter pattern established by existing data source implementations.\n *\n * @module @pwfabric/runtime/entity/connector\n */\n\nimport type {\n EntityTypeId,\n EntityInstanceId,\n EntityQuery,\n EntityQueryResult,\n EntityAggregate,\n EntityAggregateResult,\n} from './types.js'\n\n// ============================================================\n// CONNECTOR TYPES\n// ============================================================\n\n/**\n * Supported connector types\n */\nexport type EntityConnectorType = 'http' | 'database' | 'static' | 'custom'\n\n/**\n * Result of a connector CRUD operation\n */\nexport type ConnectorResult =\n | { readonly success: true; readonly data: Record<string, unknown> }\n | { readonly success: false; readonly error: string }\n\n/**\n * Result of a connector query operation\n */\nexport type ConnectorQueryResult =\n | { readonly success: true; readonly result: EntityQueryResult }\n | { readonly success: false; readonly error: string }\n\n/**\n * Result of a connector aggregate operation\n */\nexport type ConnectorAggregateResult =\n | { readonly success: true; readonly result: EntityAggregateResult }\n | { readonly success: false; readonly error: string }\n\n// ============================================================\n// ENTITY CONNECTOR INTERFACE\n// ============================================================\n\n/**\n * Interface for entity data connectors.\n * Connectors handle actual data persistence and retrieval.\n */\nexport interface EntityConnector {\n /** Connector name for identification */\n readonly name: string\n\n /** Connector type */\n readonly type: EntityConnectorType\n\n /**\n * Create a new entity instance\n */\n create(entityType: EntityTypeId, data: Record<string, unknown>): Promise<ConnectorResult>\n\n /**\n * Read a single entity instance by id\n */\n read(entityType: EntityTypeId, instanceId: EntityInstanceId): Promise<ConnectorResult>\n\n /**\n * Update an existing entity instance\n */\n update(\n entityType: EntityTypeId,\n instanceId: EntityInstanceId,\n data: Record<string, unknown>\n ): Promise<ConnectorResult>\n\n /**\n * Delete an entity instance\n */\n delete(entityType: EntityTypeId, instanceId: EntityInstanceId): Promise<ConnectorResult>\n\n /**\n * Query entity instances with filter, sort, and pagination\n */\n query(entityType: EntityTypeId, query: EntityQuery): Promise<ConnectorQueryResult>\n\n /**\n * One number over the collection, server-side. OPTIONAL: a connector\n * that only lists is reduced in memory by `aggregateThrough` instead.\n */\n aggregate?(entityType: EntityTypeId, aggregate: EntityAggregate): Promise<ConnectorAggregateResult>\n}\n\n// ============================================================\n// CONNECTOR REGISTRY\n// ============================================================\n\n/**\n * Registry for entity connectors with per-entity-type binding support\n */\nexport interface ConnectorRegistry {\n /**\n * Register a connector by name\n */\n register(connector: EntityConnector): void\n\n /**\n * Get a connector by name\n */\n get(name: string): EntityConnector | undefined\n\n /**\n * Check if a connector is registered\n */\n has(name: string): boolean\n\n /**\n * Bind an entity type to a specific connector\n */\n bind(entityType: EntityTypeId, connectorName: string): void\n\n /**\n * Resolve the connector for an entity type.\n * Returns the bound connector, or the default connector if set.\n */\n resolve(entityType: EntityTypeId): EntityConnector | undefined\n\n /**\n * Set a default connector for unbound entity types\n */\n setDefault(connectorName: string): void\n\n /**\n * List all registered connector names\n */\n list(): readonly string[]\n\n /**\n * Remove a connector by name\n */\n unregister(name: string): boolean\n\n /**\n * Remove all connectors and bindings\n */\n clear(): void\n}\n\n// ============================================================\n// IN-MEMORY CONNECTOR REGISTRY\n// ============================================================\n\n/**\n * In-memory implementation of ConnectorRegistry\n */\nexport class InMemoryConnectorRegistry implements ConnectorRegistry {\n private readonly connectors = new Map<string, EntityConnector>()\n private readonly bindings = new Map<EntityTypeId, string>()\n private defaultConnectorName: string | undefined\n\n register(connector: EntityConnector): void {\n if (!connector.name) {\n throw new Error('Connector must have a name')\n }\n\n if (this.connectors.has(connector.name)) {\n throw new Error(`Connector '${connector.name}' is already registered`)\n }\n\n this.connectors.set(connector.name, connector)\n }\n\n get(name: string): EntityConnector | undefined {\n return this.connectors.get(name)\n }\n\n has(name: string): boolean {\n return this.connectors.has(name)\n }\n\n bind(entityType: EntityTypeId, connectorName: string): void {\n if (!this.connectors.has(connectorName)) {\n throw new Error(`Connector '${connectorName}' is not registered`)\n }\n\n this.bindings.set(entityType, connectorName)\n }\n\n resolve(entityType: EntityTypeId): EntityConnector | undefined {\n // Check entity-specific binding first\n const boundName = this.bindings.get(entityType)\n if (boundName) {\n return this.connectors.get(boundName)\n }\n\n // Fall back to default\n if (this.defaultConnectorName) {\n return this.connectors.get(this.defaultConnectorName)\n }\n\n return undefined\n }\n\n setDefault(connectorName: string): void {\n if (!this.connectors.has(connectorName)) {\n throw new Error(`Connector '${connectorName}' is not registered`)\n }\n\n this.defaultConnectorName = connectorName\n }\n\n list(): readonly string[] {\n return Array.from(this.connectors.keys())\n }\n\n unregister(name: string): boolean {\n // Remove any bindings pointing to this connector\n for (const [entityType, boundName] of this.bindings) {\n if (boundName === name) {\n this.bindings.delete(entityType)\n }\n }\n\n // Clear default if it matches\n if (this.defaultConnectorName === name) {\n this.defaultConnectorName = undefined\n }\n\n return this.connectors.delete(name)\n }\n\n clear(): void {\n this.connectors.clear()\n this.bindings.clear()\n this.defaultConnectorName = undefined\n }\n}\n\n// ============================================================\n// FACTORY FUNCTION\n// ============================================================\n\n/**\n * Create a connector registry\n */\nexport function createConnectorRegistry(): ConnectorRegistry {\n return new InMemoryConnectorRegistry()\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Entity Connectors Module
3
+ *
4
+ * Connector implementations for entity data persistence.
5
+ *
6
+ * @module @pwfabric/runtime/entity/connectors
7
+ */
8
+ export { StaticConnector, createStaticConnector } from './static.js';
9
+ export type { HttpAuthConfig, HttpRetryConfig, HttpConnectorConfig } from '../http-connector.js';
10
+ export { HttpEntityConnector, createHttpConnector } from '../http-connector.js';
11
+ export type { PostgresConnectorConfig, DatabaseAdapter, DatabaseResult, } from '../postgres-connector.js';
12
+ export { PostgresEntityConnector, createPostgresConnector } from '../postgres-connector.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Entity Connectors Module
3
+ *
4
+ * Connector implementations for entity data persistence.
5
+ *
6
+ * @module @pwfabric/runtime/entity/connectors
7
+ */
8
+ export { StaticConnector, createStaticConnector } from './static.js';
9
+ export { HttpEntityConnector, createHttpConnector } from '../http-connector.js';
10
+ export { PostgresEntityConnector, createPostgresConnector } from '../postgres-connector.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entity/connectors/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAIpE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAQ/E,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA","sourcesContent":["/**\n * Entity Connectors Module\n *\n * Connector implementations for entity data persistence.\n *\n * @module @pwfabric/runtime/entity/connectors\n */\n\nexport { StaticConnector, createStaticConnector } from './static.js'\n\n// HTTP connector\nexport type { HttpAuthConfig, HttpRetryConfig, HttpConnectorConfig } from '../http-connector.js'\nexport { HttpEntityConnector, createHttpConnector } from '../http-connector.js'\n\n// PostgreSQL connector\nexport type {\n PostgresConnectorConfig,\n DatabaseAdapter,\n DatabaseResult,\n} from '../postgres-connector.js'\nexport { PostgresEntityConnector, createPostgresConnector } from '../postgres-connector.js'\n"]}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Static Entity Connector
3
+ *
4
+ * In-memory Map-based connector for prototyping and testing.
5
+ * Supports filter, sort, and pagination operations.
6
+ *
7
+ * @module @pwfabric/runtime/entity/connectors/static
8
+ */
9
+ import type { EntityTypeId, EntityInstanceId, EntityQuery } from '../types.js';
10
+ import type { EntityConnector, ConnectorResult, ConnectorQueryResult } from '../connector.js';
11
+ /**
12
+ * In-memory static connector for prototyping and testing.
13
+ * Stores data in a Map keyed by entity type, then by instance id.
14
+ */
15
+ export declare class StaticConnector implements EntityConnector {
16
+ readonly name: string;
17
+ readonly type: "static";
18
+ private readonly store;
19
+ private counter;
20
+ constructor(name?: string);
21
+ create(entityType: EntityTypeId, data: Record<string, unknown>): Promise<ConnectorResult>;
22
+ read(entityType: EntityTypeId, instanceId: EntityInstanceId): Promise<ConnectorResult>;
23
+ update(entityType: EntityTypeId, instanceId: EntityInstanceId, data: Record<string, unknown>): Promise<ConnectorResult>;
24
+ delete(entityType: EntityTypeId, instanceId: EntityInstanceId): Promise<ConnectorResult>;
25
+ query(entityType: EntityTypeId, query: EntityQuery): Promise<ConnectorQueryResult>;
26
+ /**
27
+ * Seed data into the connector for testing
28
+ */
29
+ seed(entityType: EntityTypeId, records: Record<string, unknown>[]): void;
30
+ /**
31
+ * Clear all data from the connector
32
+ */
33
+ clear(): void;
34
+ /**
35
+ * Clear data for a specific entity type
36
+ */
37
+ clearType(entityType: EntityTypeId): void;
38
+ /**
39
+ * Get the total count of records for an entity type
40
+ */
41
+ count(entityType: EntityTypeId): number;
42
+ private getOrCreateTypeStore;
43
+ private generateId;
44
+ private applyFilter;
45
+ private matchesCondition;
46
+ private applySort;
47
+ }
48
+ /**
49
+ * Create a static connector
50
+ */
51
+ export declare function createStaticConnector(name?: string): StaticConnector;