alepha 0.20.2 → 0.20.4

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 (304) hide show
  1. package/README.md +0 -1
  2. package/assets/swagger-ui/swagger-ui-bundle.js +1 -1
  3. package/assets/swagger-ui/swagger-ui.css +1 -1
  4. package/dist/api/audits/index.browser.js +49 -0
  5. package/dist/api/audits/index.browser.js.map +1 -1
  6. package/dist/api/audits/index.js +49 -0
  7. package/dist/api/audits/index.js.map +1 -1
  8. package/dist/api/files/index.js.map +1 -1
  9. package/dist/api/jobs/index.d.ts +2 -61
  10. package/dist/api/jobs/index.d.ts.map +1 -1
  11. package/dist/api/jobs/index.js.map +1 -1
  12. package/dist/api/keys/index.d.ts +4 -4
  13. package/dist/api/keys/index.js.map +1 -1
  14. package/dist/api/notifications/index.d.ts +1 -10
  15. package/dist/api/notifications/index.d.ts.map +1 -1
  16. package/dist/api/parameters/index.browser.js +37 -0
  17. package/dist/api/parameters/index.browser.js.map +1 -1
  18. package/dist/api/parameters/index.d.ts +12 -68
  19. package/dist/api/parameters/index.d.ts.map +1 -1
  20. package/dist/api/parameters/index.js +57 -4
  21. package/dist/api/parameters/index.js.map +1 -1
  22. package/dist/api/payments/index.js.map +1 -1
  23. package/dist/api/users/index.browser.js +6 -0
  24. package/dist/api/users/index.browser.js.map +1 -1
  25. package/dist/api/users/index.d.ts +148 -227
  26. package/dist/api/users/index.d.ts.map +1 -1
  27. package/dist/api/users/index.js +60 -14
  28. package/dist/api/users/index.js.map +1 -1
  29. package/dist/api/verifications/index.d.ts.map +1 -1
  30. package/dist/api/verifications/index.js +2 -1
  31. package/dist/api/verifications/index.js.map +1 -1
  32. package/dist/bucket/index.d.ts +77 -107
  33. package/dist/bucket/index.d.ts.map +1 -1
  34. package/dist/bucket/index.js +153 -5
  35. package/dist/bucket/index.js.map +1 -1
  36. package/dist/bucket/index.workerd.js +12 -2
  37. package/dist/bucket/index.workerd.js.map +1 -1
  38. package/dist/cache/core/index.d.ts +26 -0
  39. package/dist/cache/core/index.d.ts.map +1 -1
  40. package/dist/cache/core/index.js +11 -1
  41. package/dist/cache/core/index.js.map +1 -1
  42. package/dist/cache/core/index.workerd.js +11 -1
  43. package/dist/cache/core/index.workerd.js.map +1 -1
  44. package/dist/captcha/index.js.map +1 -1
  45. package/dist/cli/config/index.d.ts +7 -5
  46. package/dist/cli/config/index.d.ts.map +1 -1
  47. package/dist/cli/config/index.js +2 -3
  48. package/dist/cli/config/index.js.map +1 -1
  49. package/dist/cli/core/index.d.ts +637 -11660
  50. package/dist/cli/core/index.d.ts.map +1 -1
  51. package/dist/cli/core/index.js +707 -532
  52. package/dist/cli/core/index.js.map +1 -1
  53. package/dist/cli/devtools/index.d.ts +4 -8
  54. package/dist/cli/devtools/index.d.ts.map +1 -1
  55. package/dist/cli/devtools/index.js +20 -16
  56. package/dist/cli/devtools/index.js.map +1 -1
  57. package/dist/cli/platform/index.d.ts +51 -77
  58. package/dist/cli/platform/index.d.ts.map +1 -1
  59. package/dist/cli/platform/index.js +65 -15
  60. package/dist/cli/platform/index.js.map +1 -1
  61. package/dist/cli/vendor/index.d.ts +10 -13
  62. package/dist/cli/vendor/index.d.ts.map +1 -1
  63. package/dist/cli/vendor/index.js +30 -12
  64. package/dist/cli/vendor/index.js.map +1 -1
  65. package/dist/command/index.js +1 -1
  66. package/dist/command/index.js.map +1 -1
  67. package/dist/core/index.browser.js +27 -3
  68. package/dist/core/index.browser.js.map +1 -1
  69. package/dist/core/index.d.ts +8 -11
  70. package/dist/core/index.d.ts.map +1 -1
  71. package/dist/core/index.js +27 -3
  72. package/dist/core/index.js.map +1 -1
  73. package/dist/core/index.native.js +27 -3
  74. package/dist/core/index.native.js.map +1 -1
  75. package/dist/core/index.workerd.js +27 -3
  76. package/dist/core/index.workerd.js.map +1 -1
  77. package/dist/crypto/index.js.map +1 -1
  78. package/dist/datetime/index.d.ts +69 -10
  79. package/dist/datetime/index.d.ts.map +1 -1
  80. package/dist/datetime/index.js +135 -13
  81. package/dist/datetime/index.js.map +1 -1
  82. package/dist/email/core/index.js.map +1 -1
  83. package/dist/email/smtp/index.js +130 -16
  84. package/dist/email/smtp/index.js.map +1 -1
  85. package/dist/fake/index.js.map +1 -1
  86. package/dist/lock/core/index.d.ts +30 -2
  87. package/dist/lock/core/index.d.ts.map +1 -1
  88. package/dist/lock/core/index.js +35 -12
  89. package/dist/lock/core/index.js.map +1 -1
  90. package/dist/lock/redis/index.js.map +1 -1
  91. package/dist/logger/index.js +32 -1
  92. package/dist/logger/index.js.map +1 -1
  93. package/dist/mcp/index.d.ts +238 -31
  94. package/dist/mcp/index.d.ts.map +1 -1
  95. package/dist/mcp/index.js +198 -67
  96. package/dist/mcp/index.js.map +1 -1
  97. package/dist/orm/core/index.browser.js +2 -362
  98. package/dist/orm/core/index.browser.js.map +1 -1
  99. package/dist/orm/core/index.bun.js +18 -409
  100. package/dist/orm/core/index.bun.js.map +1 -1
  101. package/dist/orm/core/index.d.ts +41 -194
  102. package/dist/orm/core/index.d.ts.map +1 -1
  103. package/dist/orm/core/index.js +27 -422
  104. package/dist/orm/core/index.js.map +1 -1
  105. package/dist/orm/postgres/index.bun.js +17 -20
  106. package/dist/orm/postgres/index.bun.js.map +1 -1
  107. package/dist/orm/postgres/index.d.ts +1 -5
  108. package/dist/orm/postgres/index.d.ts.map +1 -1
  109. package/dist/orm/postgres/index.js +17 -20
  110. package/dist/orm/postgres/index.js.map +1 -1
  111. package/dist/react/core/index.d.ts +102 -1
  112. package/dist/react/core/index.d.ts.map +1 -1
  113. package/dist/react/core/index.js +65 -1
  114. package/dist/react/core/index.js.map +1 -1
  115. package/dist/react/form/index.d.ts +6 -0
  116. package/dist/react/form/index.d.ts.map +1 -1
  117. package/dist/react/form/index.js +7 -7
  118. package/dist/react/form/index.js.map +1 -1
  119. package/dist/react/i18n/index.d.ts +7 -1
  120. package/dist/react/i18n/index.d.ts.map +1 -1
  121. package/dist/react/i18n/index.js +6 -0
  122. package/dist/react/i18n/index.js.map +1 -1
  123. package/dist/react/intro/index.js +22 -17
  124. package/dist/react/intro/index.js.map +1 -1
  125. package/dist/react/router/index.browser.js +98 -4
  126. package/dist/react/router/index.browser.js.map +1 -1
  127. package/dist/react/router/index.d.ts +58 -5
  128. package/dist/react/router/index.d.ts.map +1 -1
  129. package/dist/react/router/index.js +122 -6
  130. package/dist/react/router/index.js.map +1 -1
  131. package/dist/react/testing/{chunk-DBEY4PJZ.js → chunk-6Ep1yQYe.js} +1 -1
  132. package/dist/react/testing/index.js +1 -1
  133. package/dist/react/testing/index.js.map +1 -1
  134. package/dist/react/ui/index.d.ts +195 -1
  135. package/dist/react/ui/index.d.ts.map +1 -1
  136. package/dist/react/ui/index.js +64 -1
  137. package/dist/react/ui/index.js.map +1 -1
  138. package/dist/react/websocket/index.js.map +1 -1
  139. package/dist/redis/index.js.map +1 -1
  140. package/dist/scheduler/index.d.ts +1 -2
  141. package/dist/scheduler/index.d.ts.map +1 -1
  142. package/dist/scheduler/index.js +1 -1
  143. package/dist/scheduler/index.js.map +1 -1
  144. package/dist/scheduler/index.workerd.js +1 -1
  145. package/dist/scheduler/index.workerd.js.map +1 -1
  146. package/dist/security/index.browser.js.map +1 -1
  147. package/dist/security/index.d.ts.map +1 -1
  148. package/dist/security/index.js +2 -2
  149. package/dist/security/index.js.map +1 -1
  150. package/dist/server/auth/index.d.ts.map +1 -1
  151. package/dist/server/auth/index.js +24 -10
  152. package/dist/server/auth/index.js.map +1 -1
  153. package/dist/server/cookies/index.js.map +1 -1
  154. package/dist/server/core/index.browser.js +10 -3
  155. package/dist/server/core/index.browser.js.map +1 -1
  156. package/dist/server/core/index.d.ts +1 -4
  157. package/dist/server/core/index.d.ts.map +1 -1
  158. package/dist/server/core/index.js +47 -9
  159. package/dist/server/core/index.js.map +1 -1
  160. package/dist/server/links/index.browser.js.map +1 -1
  161. package/dist/server/links/index.js.map +1 -1
  162. package/dist/server/metrics/index.js +19 -1
  163. package/dist/server/metrics/index.js.map +1 -1
  164. package/dist/server/rate-limit/index.js.map +1 -1
  165. package/dist/server/static/index.js.map +1 -1
  166. package/dist/server/swagger/index.d.ts.map +1 -1
  167. package/dist/server/swagger/index.js +4 -5
  168. package/dist/server/swagger/index.js.map +1 -1
  169. package/dist/sms/index.js.map +1 -1
  170. package/dist/system/index.browser.js.map +1 -1
  171. package/dist/system/index.js.map +1 -1
  172. package/dist/system/index.workerd.js.map +1 -1
  173. package/dist/topic/core/index.js.map +1 -1
  174. package/dist/websocket/index.browser.js +32 -5
  175. package/dist/websocket/index.browser.js.map +1 -1
  176. package/dist/websocket/index.d.ts +3 -1
  177. package/dist/websocket/index.d.ts.map +1 -1
  178. package/dist/websocket/index.js +42 -6
  179. package/dist/websocket/index.js.map +1 -1
  180. package/package.json +685 -274
  181. package/src/api/files/__tests__/FileController.spec.ts +1 -1
  182. package/src/api/jobs/__tests__/$job.spec.ts +5 -1
  183. package/src/api/parameters/services/ParameterProvider.ts +21 -4
  184. package/src/api/users/__tests__/SessionService.spec.ts +99 -0
  185. package/src/api/users/__tests__/UserJobs.spec.ts +67 -0
  186. package/src/api/users/atoms/realmAuthSettingsAtom.ts +15 -0
  187. package/src/api/users/entities/sessions.ts +6 -0
  188. package/src/api/users/jobs/UserJobs.ts +44 -17
  189. package/src/api/users/providers/RealmProvider.ts +4 -0
  190. package/src/api/users/schemas/userQuerySchema.ts +0 -1
  191. package/src/api/users/services/SessionService.ts +27 -0
  192. package/src/api/users/services/UserService.ts +1 -5
  193. package/src/api/verifications/__tests__/CodeVerification.spec.ts +14 -0
  194. package/src/api/verifications/__tests__/LinkVerification.spec.ts +14 -0
  195. package/src/api/verifications/services/VerificationService.ts +1 -0
  196. package/src/bucket/__tests__/NodeS3BucketProvider.spec.ts +74 -0
  197. package/src/bucket/index.ts +19 -2
  198. package/src/bucket/primitives/$bucket.ts +9 -1
  199. package/src/bucket/providers/CloudflareR2Provider.ts +2 -137
  200. package/src/bucket/providers/NodeS3BucketProvider.ts +218 -0
  201. package/src/cache/core/index.ts +29 -0
  202. package/src/cache/core/primitives/$cache.ts +14 -1
  203. package/src/cli/config/defineConfig.ts +13 -15
  204. package/src/cli/core/__tests__/init.spec.ts +214 -7
  205. package/src/cli/core/commands/init.ts +12 -0
  206. package/src/cli/core/services/PackageManagerUtils.ts +23 -6
  207. package/src/cli/core/services/ProjectScaffolder.ts +315 -33
  208. package/src/cli/core/tasks/BuildCloudflareTask.ts +5 -0
  209. package/src/cli/core/tasks/BuildDockerTask.ts +9 -10
  210. package/src/cli/core/tasks/BuildServerTask.ts +8 -0
  211. package/src/cli/core/templates/agentMd.ts +2 -10
  212. package/src/cli/core/templates/apiIndexTs.ts +23 -1
  213. package/src/cli/core/templates/componentsJsonTs.ts +39 -0
  214. package/src/cli/core/templates/mainCss.ts +1 -0
  215. package/src/cli/core/templates/saasAdminLayoutTsx.ts +77 -0
  216. package/src/cli/core/templates/saasAdminPagesTsx.ts +26 -0
  217. package/src/cli/core/templates/saasAuthLayoutTsx.ts +20 -0
  218. package/src/cli/core/templates/saasAuthPagesTsx.ts +62 -0
  219. package/src/cli/core/templates/saasRealmProviderTs.ts +46 -0
  220. package/src/cli/core/templates/webAppRouterTs.ts +104 -1
  221. package/src/cli/core/templates/webIndexTs.ts +23 -1
  222. package/src/cli/devtools/index.ts +12 -26
  223. package/src/cli/platform/__tests__/SecretsCommand.spec.ts +2 -0
  224. package/src/cli/platform/index.ts +15 -24
  225. package/src/cli/vendor/atoms/vendorOptions.ts +1 -1
  226. package/src/cli/vendor/index.ts +14 -23
  227. package/src/command/providers/CliProvider.ts +1 -1
  228. package/src/core/Alepha.ts +11 -1
  229. package/src/core/helpers/ref.ts +18 -0
  230. package/src/core/index.shared.ts +1 -0
  231. package/src/core/interfaces/Service.ts +3 -1
  232. package/src/core/providers/SchemaValidator.ts +9 -1
  233. package/src/core/providers/TypeProvider.ts +2 -3
  234. package/src/datetime/REFACTORING.md +118 -0
  235. package/src/datetime/providers/DateTimeProvider.ts +203 -24
  236. package/src/lock/core/index.ts +31 -0
  237. package/src/lock/core/primitives/$lock.ts +14 -1
  238. package/src/logger/services/Logger.ts +1 -1
  239. package/src/mcp/__tests__/$resource.spec.ts +1 -1
  240. package/src/mcp/__tests__/$tool.spec.ts +1 -1
  241. package/src/mcp/__tests__/McpServerProvider.spec.ts +1 -1
  242. package/src/mcp/__tests__/jsonrpc.spec.ts +1 -1
  243. package/src/mcp/helpers/jsonrpc.ts +26 -1
  244. package/src/mcp/index.ts +10 -5
  245. package/src/mcp/interfaces/McpTypes.ts +83 -6
  246. package/src/mcp/primitives/$prompt.ts +18 -1
  247. package/src/mcp/primitives/$resource.ts +18 -1
  248. package/src/mcp/primitives/$tool.ts +83 -7
  249. package/src/mcp/providers/McpServerProvider.ts +74 -16
  250. package/src/mcp/transports/StreamableHttpMcpTransport.ts +226 -0
  251. package/src/orm/REFACTORING.md +330 -0
  252. package/src/orm/__tests__/$repository-tests.ts +1 -0
  253. package/src/orm/__tests__/orm-next-tests.ts +2 -67
  254. package/src/orm/__tests__/orm-next.spec.ts +0 -21
  255. package/src/orm/core/index.shared.ts +0 -2
  256. package/src/orm/core/index.ts +1 -2
  257. package/src/orm/core/primitives/$repository.ts +3 -6
  258. package/src/orm/core/primitives/$transactional.ts +11 -0
  259. package/src/orm/core/providers/drivers/DatabaseProvider.ts +0 -5
  260. package/src/orm/core/providers/drivers/NodeSqliteProvider.ts +11 -13
  261. package/src/orm/core/schemas/updateSchema.ts +1 -1
  262. package/src/orm/core/services/ModelBuilder.ts +1 -13
  263. package/src/orm/core/services/PgRelationManager.ts +4 -2
  264. package/src/orm/core/services/Repository.ts +1 -42
  265. package/src/orm/core/services/SqliteModelBuilder.ts +2 -33
  266. package/src/orm/postgres/services/PostgresModelBuilder.ts +10 -45
  267. package/src/react/core/__tests__/useQuery.browser.spec.tsx +86 -0
  268. package/src/react/core/hooks/useQuery.ts +153 -0
  269. package/src/react/core/index.ts +1 -0
  270. package/src/react/form/services/FormModel.ts +15 -6
  271. package/src/react/form/services/parseField.ts +8 -0
  272. package/src/react/i18n/providers/I18nProvider.ts +8 -2
  273. package/src/react/intro/components/GettingStartedAuthSlide.tsx +11 -4
  274. package/src/react/router/__tests__/$page.spec.tsx +0 -16
  275. package/src/react/router/__tests__/ReactBrowserProvider.browser.spec.ts +213 -2
  276. package/src/react/router/__tests__/ssr.spec.tsx +339 -0
  277. package/src/react/router/primitives/$page.ts +28 -4
  278. package/src/react/router/providers/ReactBrowserProvider.ts +73 -0
  279. package/src/react/router/providers/ReactBrowserRouterProvider.ts +1 -1
  280. package/src/react/router/providers/ReactPageProvider.ts +27 -9
  281. package/src/react/router/providers/ReactPreloadProvider.ts +1 -1
  282. package/src/react/router/providers/ReactServerProvider.ts +1 -0
  283. package/src/react/ui/atoms/uiThemeListAtom.ts +36 -0
  284. package/src/react/ui/index.ts +6 -0
  285. package/src/react/ui/services/SchemaControl.ts +209 -0
  286. package/src/scheduler/providers/CronProvider.ts +1 -1
  287. package/src/security/primitives/$basicAuth.ts +1 -1
  288. package/src/security/primitives/$issuer.ts +6 -3
  289. package/src/server/auth/providers/ServerAuthProvider.ts +5 -1
  290. package/src/server/core/__tests__/ServerRouterProvider-serializationError.spec.ts +75 -0
  291. package/src/server/core/__tests__/ServerRouterProvider-validationError.spec.ts +306 -0
  292. package/src/server/core/errors/ValidationError.ts +13 -1
  293. package/src/server/core/interfaces/ServerRequest.ts +1 -0
  294. package/src/server/core/primitives/$action.ts +16 -5
  295. package/src/server/core/providers/ServerProvider.ts +1 -1
  296. package/src/server/core/providers/ServerRouterProvider.ts +28 -6
  297. package/src/server/core/services/HttpClient.ts +1 -1
  298. package/src/server/swagger/providers/ServerSwaggerProvider.ts +6 -8
  299. package/src/websocket/providers/NodeWebSocketServerProvider.ts +10 -4
  300. package/src/websocket/services/WebSocketClient.ts +11 -5
  301. package/src/mcp/transports/SseMcpTransport.ts +0 -182
  302. package/src/orm/core/__tests__/parseQueryString.spec.ts +0 -196
  303. package/src/orm/core/helpers/parseQueryString.ts +0 -502
  304. package/src/orm/core/primitives/$view.ts +0 -88
@@ -291,314 +291,6 @@ var DbTableNotFoundError = class DbTableNotFoundError extends DbError {
291
291
  }
292
292
  };
293
293
  //#endregion
294
- //#region ../../src/orm/core/helpers/parseQueryString.ts
295
- /**
296
- * Parse a string query into a PgQueryWhere object.
297
- *
298
- * Supported syntax:
299
- * - Simple equality: "name=John"
300
- * - Wildcard patterns: "name=John*" (startsWith), "name=*John" (endsWith), "name=*John*" (contains)
301
- * - Operators: "age>18", "age>=18", "age<65", "age<=65", "status!=active"
302
- * - NULL checks: "deletedAt=null", "email!=null"
303
- * - IN arrays: "status=[pending,active]"
304
- * - AND conditions: "name=John&age>18"
305
- * - OR conditions: "name=John|email=john@example.com"
306
- * - Nested AND/OR: "(name=John|name=Jane)&age>18"
307
- * - JSONB nested: "profile.city=Paris"
308
- *
309
- * @example
310
- * ```ts
311
- * // Simple equality
312
- * parseQueryString("name=John")
313
- * // => { name: { eq: "John" } }
314
- *
315
- * // Wildcard patterns
316
- * parseQueryString("name=John*") // startsWith
317
- * // => { name: { startsWith: "John" } }
318
- * parseQueryString("name=*Smith") // endsWith
319
- * // => { name: { endsWith: "Smith" } }
320
- * parseQueryString("name=*oh*") // contains
321
- * // => { name: { contains: "oh" } }
322
- *
323
- * // Multiple conditions
324
- * parseQueryString("name=John&age>18")
325
- * // => { and: [{ name: { eq: "John" } }, { age: { gt: 18 } }] }
326
- *
327
- * // OR conditions
328
- * parseQueryString("status=active|status=pending")
329
- * // => { or: [{ status: { eq: "active" } }, { status: { eq: "pending" } }] }
330
- *
331
- * // Complex nested
332
- * parseQueryString("(name=John|name=Jane)&age>18&status!=archived")
333
- * // => { and: [
334
- * // { or: [{ name: { eq: "John" } }, { name: { eq: "Jane" } }] },
335
- * // { age: { gt: 18 } },
336
- * // { status: { ne: "archived" } }
337
- * // ] }
338
- *
339
- * // JSONB nested query
340
- * parseQueryString("profile.city=Paris&profile.age>25")
341
- * // => { profile: { city: { eq: "Paris" }, age: { gt: 25 } } }
342
- * ```
343
- */
344
- function parseQueryString(query) {
345
- if (!query || query.trim() === "") return {};
346
- return new QueryStringParser(query).parse();
347
- }
348
- var QueryStringParser = class {
349
- pos = 0;
350
- query;
351
- constructor(query) {
352
- this.query = query.trim();
353
- }
354
- parse() {
355
- return this.parseExpression();
356
- }
357
- parseExpression() {
358
- return this.parseOr();
359
- }
360
- parseOr() {
361
- const left = this.parseAnd();
362
- if (this.peek() === "|") {
363
- const conditions = [left];
364
- while (this.peek() === "|") {
365
- this.consume("|");
366
- conditions.push(this.parseAnd());
367
- }
368
- return { or: conditions };
369
- }
370
- return left;
371
- }
372
- parseAnd() {
373
- const left = this.parsePrimary();
374
- if (this.peek() === "&") {
375
- const conditions = [left];
376
- while (this.peek() === "&") {
377
- this.consume("&");
378
- conditions.push(this.parsePrimary());
379
- }
380
- return { and: conditions };
381
- }
382
- return left;
383
- }
384
- parsePrimary() {
385
- this.skipWhitespace();
386
- if (this.peek() === "(") {
387
- this.consume("(");
388
- const expr = this.parseExpression();
389
- this.consume(")");
390
- return expr;
391
- }
392
- return this.parseCondition();
393
- }
394
- parseCondition() {
395
- const field = this.parseFieldPath();
396
- this.skipWhitespace();
397
- const operator = this.parseOperator();
398
- this.skipWhitespace();
399
- const value = this.parseValue();
400
- if (value === "") throw new AlephaError(`Expected value for field '${field.join(".")}'`);
401
- return this.buildCondition(field, operator, value);
402
- }
403
- parseFieldPath() {
404
- const path = [];
405
- let current = "";
406
- while (this.pos < this.query.length) {
407
- const ch = this.query[this.pos];
408
- if (ch === "." && current) {
409
- path.push(current);
410
- current = "";
411
- this.pos++;
412
- continue;
413
- }
414
- if (ch === "=" || ch === "!" || ch === ">" || ch === "<" || ch === " ") break;
415
- current += ch;
416
- this.pos++;
417
- }
418
- if (current) path.push(current);
419
- return path;
420
- }
421
- parseOperator() {
422
- this.skipWhitespace();
423
- const remaining = this.query.slice(this.pos);
424
- if (remaining.startsWith(">=")) {
425
- this.pos += 2;
426
- return ">=";
427
- }
428
- if (remaining.startsWith("<=")) {
429
- this.pos += 2;
430
- return "<=";
431
- }
432
- if (remaining.startsWith("!=")) {
433
- this.pos += 2;
434
- return "!=";
435
- }
436
- const ch = this.query[this.pos];
437
- if (ch === "=" || ch === ">" || ch === "<") {
438
- this.pos++;
439
- return ch;
440
- }
441
- throw new AlephaError(`Expected operator at position ${this.pos}`);
442
- }
443
- parseValue() {
444
- this.skipWhitespace();
445
- if (this.query.slice(this.pos, this.pos + 4).toLowerCase() === "null") {
446
- this.pos += 4;
447
- return null;
448
- }
449
- if (this.query[this.pos] === "[") return this.parseArray();
450
- if (this.query[this.pos] === "\"" || this.query[this.pos] === "'") return this.parseQuotedString();
451
- let value = "";
452
- while (this.pos < this.query.length) {
453
- const ch = this.query[this.pos];
454
- if (ch === "&" || ch === "|" || ch === ")") break;
455
- value += ch;
456
- this.pos++;
457
- }
458
- return this.coerceValue(value.trim());
459
- }
460
- parseArray() {
461
- this.consume("[");
462
- const values = [];
463
- while (this.pos < this.query.length && this.query[this.pos] !== "]") {
464
- this.skipWhitespace();
465
- if (this.query[this.pos] === "\"" || this.query[this.pos] === "'") values.push(this.parseQuotedString());
466
- else {
467
- let value = "";
468
- while (this.pos < this.query.length && this.query[this.pos] !== "," && this.query[this.pos] !== "]") {
469
- value += this.query[this.pos];
470
- this.pos++;
471
- }
472
- values.push(this.coerceValue(value.trim()));
473
- }
474
- this.skipWhitespace();
475
- if (this.query[this.pos] === ",") this.pos++;
476
- }
477
- this.consume("]");
478
- return values;
479
- }
480
- parseQuotedString() {
481
- const quote = this.query[this.pos];
482
- this.pos++;
483
- let value = "";
484
- let escaped = false;
485
- while (this.pos < this.query.length) {
486
- const ch = this.query[this.pos];
487
- if (escaped) {
488
- value += ch;
489
- escaped = false;
490
- this.pos++;
491
- continue;
492
- }
493
- if (ch === "\\") {
494
- escaped = true;
495
- this.pos++;
496
- continue;
497
- }
498
- if (ch === quote) {
499
- this.pos++;
500
- break;
501
- }
502
- value += ch;
503
- this.pos++;
504
- }
505
- return value;
506
- }
507
- coerceValue(value) {
508
- if (/^-?\d+$/.test(value)) return parseInt(value, 10);
509
- if (/^-?\d+\.\d+$/.test(value)) return parseFloat(value);
510
- if (value.toLowerCase() === "true") return true;
511
- if (value.toLowerCase() === "false") return false;
512
- return value;
513
- }
514
- buildCondition(path, operator, value) {
515
- let filterOp;
516
- if (operator === "=") if (value === null) filterOp = { isNull: true };
517
- else if (Array.isArray(value)) filterOp = { inArray: value };
518
- else if (typeof value === "string" && value.includes("*")) {
519
- const startsWithAsterisk = value.startsWith("*");
520
- const endsWithAsterisk = value.endsWith("*");
521
- const cleanValue = value.replace(/^\*|\*$/g, "");
522
- if (startsWithAsterisk && endsWithAsterisk) filterOp = { contains: cleanValue };
523
- else if (startsWithAsterisk) filterOp = { endsWith: cleanValue };
524
- else if (endsWithAsterisk) filterOp = { startsWith: cleanValue };
525
- else filterOp = { eq: value };
526
- } else filterOp = { eq: value };
527
- else if (operator === "!=") if (value === null) filterOp = { isNotNull: true };
528
- else filterOp = { ne: value };
529
- else if (operator === ">") filterOp = { gt: value };
530
- else if (operator === ">=") filterOp = { gte: value };
531
- else if (operator === "<") filterOp = { lt: value };
532
- else if (operator === "<=") filterOp = { lte: value };
533
- else throw new AlephaError(`Unsupported operator: ${operator}`);
534
- if (path.length === 1) return { [path[0]]: filterOp };
535
- let result = filterOp;
536
- for (let i = path.length - 1; i >= 0; i--) result = { [path[i]]: result };
537
- return result;
538
- }
539
- peek() {
540
- this.skipWhitespace();
541
- return this.query[this.pos] || "";
542
- }
543
- consume(expected) {
544
- this.skipWhitespace();
545
- if (this.query[this.pos] !== expected) throw new AlephaError(`Expected '${expected}' at position ${this.pos}, got '${this.query[this.pos]}'`);
546
- this.pos++;
547
- }
548
- skipWhitespace() {
549
- while (this.pos < this.query.length && /\s/.test(this.query[this.pos])) this.pos++;
550
- }
551
- };
552
- /**
553
- * Helper function to build query strings programmatically
554
- *
555
- * @example
556
- * ```ts
557
- * buildQueryString({
558
- * and: [
559
- * { name: "eq:John" },
560
- * { age: "gt:18" }
561
- * ]
562
- * })
563
- * // => "name=John&age>18"
564
- * ```
565
- */
566
- function buildQueryString(where) {
567
- if (!where || typeof where !== "object") return "";
568
- if ("and" in where && Array.isArray(where.and)) return where.and.map((w) => buildQueryString(w)).join("&");
569
- if ("or" in where && Array.isArray(where.or)) {
570
- const parts = where.or.map((w) => buildQueryString(w));
571
- return parts.length > 1 ? `(${parts.join("|")})` : parts[0];
572
- }
573
- if ("not" in where) return "";
574
- const parts = [];
575
- for (const [field, condition] of Object.entries(where)) {
576
- if (typeof condition !== "object" || condition === null) {
577
- parts.push(`${field}=${condition}`);
578
- continue;
579
- }
580
- if ("eq" in condition) parts.push(`${field}=${condition.eq}`);
581
- else if ("ne" in condition) parts.push(`${field}!=${condition.ne}`);
582
- else if ("gt" in condition) parts.push(`${field}>${condition.gt}`);
583
- else if ("gte" in condition) parts.push(`${field}>=${condition.gte}`);
584
- else if ("lt" in condition) parts.push(`${field}<${condition.lt}`);
585
- else if ("lte" in condition) parts.push(`${field}<=${condition.lte}`);
586
- else if ("contains" in condition) parts.push(`${field}=*${condition.contains}*`);
587
- else if ("startsWith" in condition) parts.push(`${field}=${condition.startsWith}*`);
588
- else if ("endsWith" in condition) parts.push(`${field}=*${condition.endsWith}`);
589
- else if ("isNull" in condition && condition.isNull) parts.push(`${field}=null`);
590
- else if ("isNotNull" in condition && condition.isNotNull) parts.push(`${field}!=null`);
591
- else if ("inArray" in condition && Array.isArray(condition.inArray)) {
592
- const values = condition.inArray.map((v) => typeof v === "string" ? `"${v}"` : v);
593
- parts.push(`${field}=[${values.join(",")}]`);
594
- } else {
595
- const nested = buildQueryString(condition);
596
- if (nested) parts.push(`${field}.${nested}`);
597
- }
598
- }
599
- return parts.join("&");
600
- }
601
- //#endregion
602
294
  //#region ../../src/orm/core/helpers/pgAttr.ts
603
295
  /**
604
296
  * Decorates a typebox schema with a Postgres attribute.
@@ -669,7 +361,7 @@ const updateSchema = (schema) => {
669
361
  for (const key in schema.properties) {
670
362
  const prop = schema.properties[key];
671
363
  if (PG_GENERATED in prop) continue;
672
- if (t.schema.isOptional(prop)) newProperties[key] = t.optional(t.union([prop, t.raw.Null()]));
364
+ if (t.schema.isOptional(prop)) newProperties[key] = t.optional(t.union([prop, t.null()]));
673
365
  else newProperties[key] = prop;
674
366
  }
675
367
  return t.object(newProperties, "options" in schema && typeof schema.options === "object" ? { ...schema.options } : {});
@@ -732,58 +424,6 @@ var EntityPrimitive = class EntityPrimitive {
732
424
  };
733
425
  $entity[KIND] = EntityPrimitive;
734
426
  //#endregion
735
- //#region ../../src/orm/core/primitives/$view.ts
736
- /**
737
- * Creates a database view primitive from a TypeBox schema and SQL query.
738
- *
739
- * Views are read-only: Repository blocks all write operations.
740
- *
741
- * @example
742
- * ```ts
743
- * import { t } from "alepha";
744
- * import { $view } from "alepha/orm";
745
- * import { sql } from "drizzle-orm";
746
- *
747
- * const userSummary = $view({
748
- * name: "user_summary",
749
- * schema: t.object({
750
- * id: t.uuid(),
751
- * fullName: t.text(),
752
- * orderCount: t.integer(),
753
- * }),
754
- * query: sql`SELECT u.id, u.first_name || ' ' || u.last_name AS full_name, COUNT(o.id) AS order_count FROM users u LEFT JOIN orders o ON o.user_id = u.id GROUP BY u.id`,
755
- * });
756
- *
757
- * // Materialized view (PostgreSQL only)
758
- * const monthlyStats = $view({
759
- * name: "monthly_stats",
760
- * schema: t.object({ ... }),
761
- * query: sql`...`,
762
- * materialized: true,
763
- * });
764
- * ```
765
- */
766
- const $view = (options) => {
767
- return new ViewPrimitive(options);
768
- };
769
- var ViewPrimitive = class {
770
- options;
771
- isView = true;
772
- constructor(options) {
773
- this.options = options;
774
- }
775
- get name() {
776
- return this.options.name;
777
- }
778
- get schema() {
779
- return this.options.schema;
780
- }
781
- get materialized() {
782
- return this.options.materialized ?? false;
783
- }
784
- };
785
- $view[KIND] = ViewPrimitive;
786
- //#endregion
787
427
  //#region ../../src/orm/core/providers/DatabaseTypeProvider.ts
788
428
  var DatabaseTypeProvider = class {
789
429
  attr = pgAttr;
@@ -897,6 +537,6 @@ const AlephaOrm = $module({
897
537
  services: [AlephaDateTime]
898
538
  });
899
539
  //#endregion
900
- export { $entity, $view, AlephaOrm, DatabaseTypeProvider, DbColumnNotFoundError, DbConnectionError, DbDeadlockError, DbEntityNotFoundError, DbForeignKeyError, DbNotNullError, DbTableNotFoundError, EntityPrimitive, ViewPrimitive, buildQueryString, db, getAttrFields, legacyIdSchema, pageQuerySchema, pageSchema, parseQueryString, pgAttr, sql };
540
+ export { $entity, AlephaOrm, DatabaseTypeProvider, DbColumnNotFoundError, DbConnectionError, DbDeadlockError, DbEntityNotFoundError, DbForeignKeyError, DbNotNullError, DbTableNotFoundError, EntityPrimitive, db, getAttrFields, legacyIdSchema, pageQuerySchema, pageSchema, pgAttr, sql };
901
541
 
902
542
  //# sourceMappingURL=index.browser.js.map