alepha 0.15.0 → 0.15.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 (222) hide show
  1. package/README.md +43 -98
  2. package/dist/api/audits/index.d.ts +240 -240
  3. package/dist/api/audits/index.d.ts.map +1 -1
  4. package/dist/api/audits/index.js +2 -2
  5. package/dist/api/audits/index.js.map +1 -1
  6. package/dist/api/files/index.d.ts +185 -185
  7. package/dist/api/files/index.d.ts.map +1 -1
  8. package/dist/api/files/index.js +2 -2
  9. package/dist/api/files/index.js.map +1 -1
  10. package/dist/api/jobs/index.d.ts +245 -245
  11. package/dist/api/jobs/index.d.ts.map +1 -1
  12. package/dist/api/notifications/index.browser.js +4 -4
  13. package/dist/api/notifications/index.browser.js.map +1 -1
  14. package/dist/api/notifications/index.d.ts +74 -74
  15. package/dist/api/notifications/index.d.ts.map +1 -1
  16. package/dist/api/notifications/index.js +4 -4
  17. package/dist/api/notifications/index.js.map +1 -1
  18. package/dist/api/parameters/index.d.ts +221 -221
  19. package/dist/api/parameters/index.d.ts.map +1 -1
  20. package/dist/api/users/index.d.ts +1632 -1631
  21. package/dist/api/users/index.d.ts.map +1 -1
  22. package/dist/api/users/index.js +26 -34
  23. package/dist/api/users/index.js.map +1 -1
  24. package/dist/api/verifications/index.d.ts +132 -132
  25. package/dist/api/verifications/index.d.ts.map +1 -1
  26. package/dist/batch/index.d.ts +122 -122
  27. package/dist/batch/index.d.ts.map +1 -1
  28. package/dist/bucket/index.d.ts +163 -163
  29. package/dist/bucket/index.d.ts.map +1 -1
  30. package/dist/cache/core/index.d.ts +46 -46
  31. package/dist/cache/core/index.d.ts.map +1 -1
  32. package/dist/cache/redis/index.d.ts.map +1 -1
  33. package/dist/cache/redis/index.js +2 -2
  34. package/dist/cache/redis/index.js.map +1 -1
  35. package/dist/cli/index.d.ts +5933 -201
  36. package/dist/cli/index.d.ts.map +1 -1
  37. package/dist/cli/index.js +609 -169
  38. package/dist/cli/index.js.map +1 -1
  39. package/dist/command/index.d.ts +296 -296
  40. package/dist/command/index.d.ts.map +1 -1
  41. package/dist/command/index.js +19 -19
  42. package/dist/command/index.js.map +1 -1
  43. package/dist/core/index.browser.js +268 -79
  44. package/dist/core/index.browser.js.map +1 -1
  45. package/dist/core/index.d.ts +768 -694
  46. package/dist/core/index.d.ts.map +1 -1
  47. package/dist/core/index.js +268 -79
  48. package/dist/core/index.js.map +1 -1
  49. package/dist/core/index.native.js +268 -79
  50. package/dist/core/index.native.js.map +1 -1
  51. package/dist/datetime/index.d.ts +44 -44
  52. package/dist/datetime/index.d.ts.map +1 -1
  53. package/dist/email/index.d.ts +25 -25
  54. package/dist/email/index.d.ts.map +1 -1
  55. package/dist/fake/index.d.ts +5409 -5409
  56. package/dist/fake/index.d.ts.map +1 -1
  57. package/dist/fake/index.js +22 -22
  58. package/dist/fake/index.js.map +1 -1
  59. package/dist/file/index.d.ts +435 -435
  60. package/dist/file/index.d.ts.map +1 -1
  61. package/dist/lock/core/index.d.ts +208 -208
  62. package/dist/lock/core/index.d.ts.map +1 -1
  63. package/dist/lock/redis/index.d.ts.map +1 -1
  64. package/dist/logger/index.d.ts +24 -24
  65. package/dist/logger/index.d.ts.map +1 -1
  66. package/dist/logger/index.js +1 -5
  67. package/dist/logger/index.js.map +1 -1
  68. package/dist/mcp/index.d.ts +216 -198
  69. package/dist/mcp/index.d.ts.map +1 -1
  70. package/dist/mcp/index.js +28 -4
  71. package/dist/mcp/index.js.map +1 -1
  72. package/dist/orm/index.browser.js +9 -9
  73. package/dist/orm/index.browser.js.map +1 -1
  74. package/dist/orm/index.bun.js +83 -76
  75. package/dist/orm/index.bun.js.map +1 -1
  76. package/dist/orm/index.d.ts +961 -960
  77. package/dist/orm/index.d.ts.map +1 -1
  78. package/dist/orm/index.js +88 -81
  79. package/dist/orm/index.js.map +1 -1
  80. package/dist/queue/core/index.d.ts +244 -244
  81. package/dist/queue/core/index.d.ts.map +1 -1
  82. package/dist/queue/redis/index.d.ts.map +1 -1
  83. package/dist/redis/index.d.ts +105 -105
  84. package/dist/redis/index.d.ts.map +1 -1
  85. package/dist/retry/index.d.ts +69 -69
  86. package/dist/retry/index.d.ts.map +1 -1
  87. package/dist/router/index.d.ts +6 -6
  88. package/dist/router/index.d.ts.map +1 -1
  89. package/dist/scheduler/index.d.ts +108 -26
  90. package/dist/scheduler/index.d.ts.map +1 -1
  91. package/dist/scheduler/index.js +393 -1
  92. package/dist/scheduler/index.js.map +1 -1
  93. package/dist/security/index.d.ts +532 -209
  94. package/dist/security/index.d.ts.map +1 -1
  95. package/dist/security/index.js +1422 -11
  96. package/dist/security/index.js.map +1 -1
  97. package/dist/server/auth/index.d.ts +1296 -271
  98. package/dist/server/auth/index.d.ts.map +1 -1
  99. package/dist/server/auth/index.js +1249 -18
  100. package/dist/server/auth/index.js.map +1 -1
  101. package/dist/server/cache/index.d.ts +56 -56
  102. package/dist/server/cache/index.d.ts.map +1 -1
  103. package/dist/server/compress/index.d.ts +3 -3
  104. package/dist/server/compress/index.d.ts.map +1 -1
  105. package/dist/server/cookies/index.d.ts +6 -6
  106. package/dist/server/cookies/index.d.ts.map +1 -1
  107. package/dist/server/core/index.d.ts +196 -186
  108. package/dist/server/core/index.d.ts.map +1 -1
  109. package/dist/server/core/index.js +43 -27
  110. package/dist/server/core/index.js.map +1 -1
  111. package/dist/server/cors/index.d.ts +11 -11
  112. package/dist/server/cors/index.d.ts.map +1 -1
  113. package/dist/server/health/index.d.ts.map +1 -1
  114. package/dist/server/helmet/index.d.ts +2 -2
  115. package/dist/server/helmet/index.d.ts.map +1 -1
  116. package/dist/server/links/index.browser.js +9 -1
  117. package/dist/server/links/index.browser.js.map +1 -1
  118. package/dist/server/links/index.d.ts +83 -83
  119. package/dist/server/links/index.d.ts.map +1 -1
  120. package/dist/server/links/index.js +13 -5
  121. package/dist/server/links/index.js.map +1 -1
  122. package/dist/server/metrics/index.d.ts +514 -1
  123. package/dist/server/metrics/index.d.ts.map +1 -1
  124. package/dist/server/metrics/index.js +4462 -4
  125. package/dist/server/metrics/index.js.map +1 -1
  126. package/dist/server/multipart/index.d.ts +6 -6
  127. package/dist/server/multipart/index.d.ts.map +1 -1
  128. package/dist/server/proxy/index.d.ts +102 -102
  129. package/dist/server/proxy/index.d.ts.map +1 -1
  130. package/dist/server/rate-limit/index.d.ts +16 -16
  131. package/dist/server/rate-limit/index.d.ts.map +1 -1
  132. package/dist/server/static/index.d.ts +44 -44
  133. package/dist/server/static/index.d.ts.map +1 -1
  134. package/dist/server/swagger/index.d.ts +47 -47
  135. package/dist/server/swagger/index.d.ts.map +1 -1
  136. package/dist/sms/index.d.ts +11 -11
  137. package/dist/sms/index.d.ts.map +1 -1
  138. package/dist/sms/index.js +3 -3
  139. package/dist/sms/index.js.map +1 -1
  140. package/dist/thread/index.d.ts +71 -71
  141. package/dist/thread/index.d.ts.map +1 -1
  142. package/dist/thread/index.js +2 -2
  143. package/dist/thread/index.js.map +1 -1
  144. package/dist/topic/core/index.d.ts +318 -318
  145. package/dist/topic/core/index.d.ts.map +1 -1
  146. package/dist/topic/redis/index.d.ts +6 -6
  147. package/dist/topic/redis/index.d.ts.map +1 -1
  148. package/dist/vite/index.d.ts +2324 -1719
  149. package/dist/vite/index.d.ts.map +1 -1
  150. package/dist/vite/index.js +123 -475
  151. package/dist/vite/index.js.map +1 -1
  152. package/dist/websocket/index.browser.js +3 -3
  153. package/dist/websocket/index.browser.js.map +1 -1
  154. package/dist/websocket/index.d.ts +275 -275
  155. package/dist/websocket/index.d.ts.map +1 -1
  156. package/dist/websocket/index.js +3 -3
  157. package/dist/websocket/index.js.map +1 -1
  158. package/package.json +9 -9
  159. package/src/api/users/services/SessionService.ts +0 -10
  160. package/src/cli/apps/AlephaCli.ts +2 -2
  161. package/src/cli/apps/AlephaPackageBuilderCli.ts +9 -1
  162. package/src/cli/assets/apiHelloControllerTs.ts +2 -1
  163. package/src/cli/assets/biomeJson.ts +2 -1
  164. package/src/cli/assets/claudeMd.ts +9 -4
  165. package/src/cli/assets/dummySpecTs.ts +2 -1
  166. package/src/cli/assets/editorconfig.ts +2 -1
  167. package/src/cli/assets/mainBrowserTs.ts +2 -1
  168. package/src/cli/assets/mainCss.ts +24 -0
  169. package/src/cli/assets/tsconfigJson.ts +2 -1
  170. package/src/cli/assets/webAppRouterTs.ts +2 -1
  171. package/src/cli/assets/webHelloComponentTsx.ts +6 -2
  172. package/src/cli/atoms/appEntryOptions.ts +13 -0
  173. package/src/cli/atoms/buildOptions.ts +1 -1
  174. package/src/cli/atoms/changelogOptions.ts +1 -1
  175. package/src/cli/commands/build.ts +63 -47
  176. package/src/cli/commands/dev.ts +16 -33
  177. package/src/cli/commands/gen/env.ts +1 -1
  178. package/src/cli/commands/init.ts +17 -8
  179. package/src/cli/commands/lint.ts +1 -1
  180. package/src/cli/defineConfig.ts +9 -0
  181. package/src/cli/index.ts +2 -1
  182. package/src/cli/providers/AppEntryProvider.ts +131 -0
  183. package/src/cli/providers/ViteBuildProvider.ts +82 -0
  184. package/src/cli/providers/ViteDevServerProvider.ts +350 -0
  185. package/src/cli/providers/ViteTemplateProvider.ts +27 -0
  186. package/src/cli/services/AlephaCliUtils.ts +33 -2
  187. package/src/cli/services/PackageManagerUtils.ts +13 -6
  188. package/src/cli/services/ProjectScaffolder.ts +72 -49
  189. package/src/core/Alepha.ts +2 -8
  190. package/src/core/primitives/$module.ts +12 -0
  191. package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +257 -0
  192. package/src/core/providers/KeylessJsonSchemaCodec.ts +396 -14
  193. package/src/core/providers/SchemaValidator.spec.ts +236 -0
  194. package/src/logger/providers/PrettyFormatterProvider.ts +0 -9
  195. package/src/mcp/errors/McpError.ts +30 -0
  196. package/src/mcp/index.ts +3 -0
  197. package/src/mcp/transports/SseMcpTransport.ts +16 -6
  198. package/src/orm/providers/DrizzleKitProvider.ts +3 -5
  199. package/src/orm/services/Repository.ts +11 -0
  200. package/src/server/core/index.ts +1 -1
  201. package/src/server/core/providers/BunHttpServerProvider.ts +1 -1
  202. package/src/server/core/providers/NodeHttpServerProvider.spec.ts +125 -0
  203. package/src/server/core/providers/NodeHttpServerProvider.ts +71 -22
  204. package/src/server/core/providers/ServerLoggerProvider.ts +2 -2
  205. package/src/server/core/providers/ServerProvider.ts +9 -12
  206. package/src/server/links/atoms/apiLinksAtom.ts +7 -0
  207. package/src/server/links/index.browser.ts +2 -0
  208. package/src/server/links/index.ts +2 -0
  209. package/src/vite/index.ts +3 -2
  210. package/src/vite/tasks/buildClient.ts +0 -1
  211. package/src/vite/tasks/buildServer.ts +68 -21
  212. package/src/vite/tasks/copyAssets.ts +5 -4
  213. package/src/vite/tasks/generateSitemap.ts +64 -23
  214. package/src/vite/tasks/index.ts +0 -2
  215. package/src/vite/tasks/prerenderPages.ts +49 -24
  216. package/src/cli/assets/indexHtml.ts +0 -15
  217. package/src/cli/commands/format.ts +0 -23
  218. package/src/vite/helpers/boot.ts +0 -117
  219. package/src/vite/plugins/viteAlephaDev.ts +0 -177
  220. package/src/vite/tasks/devServer.ts +0 -71
  221. package/src/vite/tasks/runAlepha.ts +0 -270
  222. /package/dist/orm/{chunk-DtkW-qnP.js → chunk-DH6iiROE.js} +0 -0
@@ -35,14 +35,14 @@ var __exportAll = (all, symbols) => {
35
35
  }
36
36
  return target;
37
37
  };
38
- var __copyProps = (to, from, except, desc$1) => {
38
+ var __copyProps = (to, from, except, desc) => {
39
39
  if (from && typeof from === "object" || typeof from === "function") {
40
40
  for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
41
41
  key = keys[i];
42
42
  if (!__hasOwnProp.call(to, key) && key !== except) {
43
43
  __defProp(to, key, {
44
44
  get: ((k) => from[k]).bind(null, key),
45
- enumerable: !(desc$1 = __getOwnPropDesc(from, key)) || desc$1.enumerable
45
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
46
46
  });
47
47
  }
48
48
  }
@@ -92,14 +92,14 @@ const insertSchema = (obj) => {
92
92
 
93
93
  //#endregion
94
94
  //#region ../../src/orm/schemas/updateSchema.ts
95
- const updateSchema = (schema$1) => {
95
+ const updateSchema = (schema) => {
96
96
  const newProperties = {};
97
- for (const key in schema$1.properties) {
98
- const prop = schema$1.properties[key];
97
+ for (const key in schema.properties) {
98
+ const prop = schema.properties[key];
99
99
  if (t.schema.isOptional(prop)) newProperties[key] = t.optional(t.union([prop, t.raw.Null()]));
100
100
  else newProperties[key] = prop;
101
101
  }
102
- return t.object(newProperties, "options" in schema$1 && typeof schema$1.options === "object" ? { ...schema$1.options } : {});
102
+ return t.object(newProperties, "options" in schema && typeof schema.options === "object" ? { ...schema.options } : {});
103
103
  };
104
104
 
105
105
  //#endregion
@@ -130,10 +130,10 @@ var EntityPrimitive = class EntityPrimitive {
130
130
  constructor(options) {
131
131
  this.options = options;
132
132
  }
133
- alias(alias$1) {
133
+ alias(alias) {
134
134
  const aliased = new EntityPrimitive(this.options);
135
135
  return new Proxy(aliased, { get(target, prop, receiver) {
136
- if (prop === "$alias") return alias$1;
136
+ if (prop === "$alias") return alias;
137
137
  return Reflect.get(target, prop, receiver);
138
138
  } });
139
139
  }
@@ -199,8 +199,8 @@ var DatabaseProvider = class {
199
199
  registerSequence(sequence) {
200
200
  this.builder.buildSequence(sequence, this);
201
201
  }
202
- async run(statement, schema$1) {
203
- return (await this.execute(statement)).map((row) => this.alepha.codec.decode(schema$1, row));
202
+ async run(statement, schema) {
203
+ return (await this.execute(statement)).map((row) => this.alepha.codec.decode(schema, row));
204
204
  }
205
205
  /**
206
206
  * Get migrations folder path - can be overridden
@@ -323,7 +323,7 @@ var DrizzleKitProvider = class {
323
323
  await this.executeStatements(statements, provider, true);
324
324
  await this.saveDevMigrations(provider, snapshot, entry);
325
325
  }
326
- this.log.info(`Db '${provider.name}' synchronization OK [${Date.now() - now}ms]`);
326
+ this.log.info(`Sync with '${provider.name}' OK [${Date.now() - now}ms]`);
327
327
  }
328
328
  /**
329
329
  * Mostly used for testing purposes. You can generate SQL migration statements without executing them.
@@ -333,16 +333,16 @@ var DrizzleKitProvider = class {
333
333
  const models = this.getModels(provider);
334
334
  if (Object.keys(models).length > 0) {
335
335
  if (provider.dialect === "sqlite") {
336
- const prev$1 = prevSnapshot ?? await kit.generateSQLiteDrizzleJson({});
337
- const curr$1 = await kit.generateSQLiteDrizzleJson(models);
336
+ const prev = prevSnapshot ?? await kit.generateSQLiteDrizzleJson({});
337
+ const curr = await kit.generateSQLiteDrizzleJson(models);
338
338
  return {
339
339
  models,
340
- statements: await kit.generateSQLiteMigration(prev$1, curr$1),
341
- snapshot: curr$1
340
+ statements: await kit.generateSQLiteMigration(prev, curr),
341
+ snapshot: curr
342
342
  };
343
343
  }
344
- const prev = prevSnapshot ?? await kit.generateDrizzleJson({});
345
- const curr = await kit.generateDrizzleJson(models);
344
+ const prev = prevSnapshot ?? kit.generateDrizzleJson({});
345
+ const curr = kit.generateDrizzleJson(models);
346
346
  return {
347
347
  models,
348
348
  statements: await kit.generateMigration(prev, curr),
@@ -629,8 +629,8 @@ var PostgresModelBuilder = class extends ModelBuilder {
629
629
  };
630
630
  return this.buildTableConfig(entity, pgBuilders, tableResolver);
631
631
  }
632
- schemaToPgColumns = (tableName, schema$1, nsp, enums, tables) => {
633
- return Object.entries(schema$1.properties).reduce((columns, [key, value]) => {
632
+ schemaToPgColumns = (tableName, schema, nsp, enums, tables) => {
633
+ return Object.entries(schema.properties).reduce((columns, [key, value]) => {
634
634
  let col = this.mapFieldToColumn(tableName, key, value, nsp, enums);
635
635
  if ("default" in value && value.default != null) col = col.default(value.default);
636
636
  if (PG_PRIMARY_KEY in value) col = col.primaryKey();
@@ -645,7 +645,7 @@ var PostgresModelBuilder = class extends ModelBuilder {
645
645
  return target;
646
646
  }, config.actions);
647
647
  }
648
- if (schema$1.required?.includes(key)) col = col.notNull();
648
+ if (schema.required?.includes(key)) col = col.notNull();
649
649
  return {
650
650
  ...columns,
651
651
  [key]: col
@@ -684,7 +684,7 @@ var PostgresModelBuilder = class extends ModelBuilder {
684
684
  if (t.schema.isBoolean(value)) return pg$2.boolean(key);
685
685
  if (t.schema.isObject(value)) return schema(key, value);
686
686
  if (t.schema.isRecord(value)) return schema(key, value);
687
- const isTypeEnum = (value$1) => t.schema.isUnsafe(value$1) && "type" in value$1 && value$1.type === "string" && "enum" in value$1 && Array.isArray(value$1.enum);
687
+ const isTypeEnum = (value) => t.schema.isUnsafe(value) && "type" in value && value.type === "string" && "enum" in value && Array.isArray(value.enum);
688
688
  if (t.schema.isArray(value)) {
689
689
  if (t.schema.isObject(value.items)) return schema(key, value);
690
690
  if (t.schema.isRecord(value.items)) return schema(key, value);
@@ -812,8 +812,8 @@ var BunPostgresProvider = class extends DatabaseProvider {
812
812
  return this.bunDb;
813
813
  }
814
814
  async executeMigrations(migrationsFolder) {
815
- const { migrate: migrate$1 } = await import("drizzle-orm/bun-sql/migrator");
816
- await migrate$1(this.bunDb, { migrationsFolder });
815
+ const { migrate } = await import("drizzle-orm/bun-sql/migrator");
816
+ await migrate(this.bunDb, { migrationsFolder });
817
817
  }
818
818
  onStart = $hook({
819
819
  on: "start",
@@ -841,10 +841,10 @@ var BunPostgresProvider = class extends DatabaseProvider {
841
841
  async connect() {
842
842
  this.log.debug("Connect ..");
843
843
  if (typeof Bun === "undefined") throw new AlephaError("BunPostgresProvider requires the Bun runtime. Use NodePostgresProvider for Node.js.");
844
- const { drizzle: drizzle$1 } = await import("drizzle-orm/bun-sql");
844
+ const { drizzle } = await import("drizzle-orm/bun-sql");
845
845
  this.client = new Bun.SQL(this.url);
846
846
  await this.client.unsafe("SELECT 1");
847
- this.bunDb = drizzle$1({
847
+ this.bunDb = drizzle({
848
848
  client: this.client,
849
849
  logger: { logQuery: (query, params) => {
850
850
  this.log.trace(query, { params });
@@ -897,8 +897,8 @@ var SqliteModelBuilder = class extends ModelBuilder {
897
897
  return Array.isArray(customConfigs) ? customConfigs : [];
898
898
  });
899
899
  }
900
- schemaToSqliteColumns = (tableName, schema$1, enums, tables) => {
901
- return Object.entries(schema$1.properties).reduce((columns, [key, value]) => {
900
+ schemaToSqliteColumns = (tableName, schema, enums, tables) => {
901
+ return Object.entries(schema.properties).reduce((columns, [key, value]) => {
902
902
  let col = this.mapFieldToSqliteColumn(tableName, key, value, enums);
903
903
  if ("default" in value && value.default != null) col = col.default(value.default);
904
904
  if (PG_PRIMARY_KEY in value) col = col.primaryKey();
@@ -913,7 +913,7 @@ var SqliteModelBuilder = class extends ModelBuilder {
913
913
  return target;
914
914
  }, config.actions);
915
915
  }
916
- if (schema$1.required?.includes(key)) col = col.notNull();
916
+ if (schema.required?.includes(key)) col = col.notNull();
917
917
  return {
918
918
  ...columns,
919
919
  [key]: col
@@ -1062,14 +1062,14 @@ var BunSqliteProvider = class extends DatabaseProvider {
1062
1062
  handler: async () => {
1063
1063
  if (typeof Bun === "undefined") throw new AlephaError("BunSqliteProvider requires the Bun runtime. Use NodeSqliteProvider for Node.js.");
1064
1064
  const { Database } = await import("bun:sqlite");
1065
- const { drizzle: drizzle$1 } = await import("drizzle-orm/bun-sqlite");
1065
+ const { drizzle } = await import("drizzle-orm/bun-sqlite");
1066
1066
  const filepath = this.url.replace("sqlite://", "").replace("sqlite:", "");
1067
1067
  if (filepath !== ":memory:" && filepath !== "") {
1068
1068
  const dirname = filepath.split("/").slice(0, -1).join("/");
1069
1069
  if (dirname) await mkdir(dirname, { recursive: true }).catch(() => null);
1070
1070
  }
1071
1071
  this.sqlite = new Database(filepath);
1072
- this.bunDb = drizzle$1({
1072
+ this.bunDb = drizzle({
1073
1073
  client: this.sqlite,
1074
1074
  logger: { logQuery: (query, params) => {
1075
1075
  this.log.trace(query, { params });
@@ -1092,8 +1092,8 @@ var BunSqliteProvider = class extends DatabaseProvider {
1092
1092
  }
1093
1093
  });
1094
1094
  async executeMigrations(migrationsFolder) {
1095
- const { migrate: migrate$1 } = await import("drizzle-orm/bun-sqlite/migrator");
1096
- await migrate$1(this.bunDb, { migrationsFolder });
1095
+ const { migrate } = await import("drizzle-orm/bun-sqlite/migrator");
1096
+ await migrate(this.bunDb, { migrationsFolder });
1097
1097
  }
1098
1098
  };
1099
1099
 
@@ -1145,15 +1145,15 @@ var CloudflareD1Provider = class extends DatabaseProvider {
1145
1145
  const binding = cloudflareEnv[bindingName];
1146
1146
  if (!binding) throw new AlephaError(`D1 binding '${bindingName}' not found in Cloudflare Workers environment.`);
1147
1147
  this.d1 = binding;
1148
- const { drizzle: drizzle$1 } = await import("drizzle-orm/d1");
1149
- this.drizzleDb = drizzle$1(this.d1);
1148
+ const { drizzle } = await import("drizzle-orm/d1");
1149
+ this.drizzleDb = drizzle(this.d1);
1150
1150
  await this.migrate();
1151
1151
  this.log.info("Using Cloudflare D1 database");
1152
1152
  }
1153
1153
  });
1154
1154
  async executeMigrations(migrationsFolder) {
1155
- const { migrate: migrate$1 } = await import("drizzle-orm/d1/migrator");
1156
- await migrate$1(this.db, { migrationsFolder });
1155
+ const { migrate } = await import("drizzle-orm/d1/migrator");
1156
+ await migrate(this.db, { migrationsFolder });
1157
1157
  }
1158
1158
  /**
1159
1159
  * Override development migration to skip sync (not supported on D1).
@@ -1220,13 +1220,13 @@ var PglitePostgresProvider = class PglitePostgresProvider extends DatabaseProvid
1220
1220
  if (Object.keys(this.kit.getModels(this)).length === 0) return;
1221
1221
  const module = PglitePostgresProvider.importPglite();
1222
1222
  if (!module) throw new AlephaError("@electric-sql/pglite is not installed. Please install it to use the pglite driver.");
1223
- const { drizzle: drizzle$1 } = createRequire(import.meta.url)("drizzle-orm/pglite");
1223
+ const { drizzle } = createRequire(import.meta.url)("drizzle-orm/pglite");
1224
1224
  const path = this.url;
1225
1225
  if (path !== ":memory:") {
1226
1226
  await mkdir(path, { recursive: true }).catch(() => null);
1227
1227
  this.client = new module.PGlite(path);
1228
1228
  } else this.client = new module.PGlite();
1229
- this.pglite = drizzle$1({ client: this.client });
1229
+ this.pglite = drizzle({ client: this.client });
1230
1230
  await this.migrate();
1231
1231
  this.log.info(`Using PGlite database at ${path}`);
1232
1232
  }
@@ -1303,10 +1303,10 @@ const pgAttr = (type, attr, value) => {
1303
1303
  /**
1304
1304
  * Retrieves the fields of a schema that have a specific attribute.
1305
1305
  */
1306
- const getAttrFields = (schema$1, name) => {
1306
+ const getAttrFields = (schema, name) => {
1307
1307
  const fields = [];
1308
- for (const key of Object.keys(schema$1.properties)) {
1309
- const value = schema$1.properties[key];
1308
+ for (const key of Object.keys(schema.properties)) {
1309
+ const value = schema.properties[key];
1310
1310
  if (name in value) fields.push({
1311
1311
  type: value,
1312
1312
  key,
@@ -1342,13 +1342,13 @@ var PgRelationManager = class {
1342
1342
  /**
1343
1343
  * Map a row with its joined relations based on the joins definition
1344
1344
  */
1345
- mapRowWithJoins(record, row, schema$1, joins, parentKey) {
1345
+ mapRowWithJoins(record, row, schema, joins, parentKey) {
1346
1346
  for (const join of joins) if (join.parent === parentKey) {
1347
1347
  const joinedData = row[join.table];
1348
1348
  if (this.isAllNull(joinedData)) record[join.key] = void 0;
1349
1349
  else {
1350
1350
  record[join.key] = joinedData;
1351
- this.mapRowWithJoins(record[join.key], row, schema$1, joins, parentKey ? `${parentKey}.${join.key}` : join.key);
1351
+ this.mapRowWithJoins(record[join.key], row, schema, joins, parentKey ? `${parentKey}.${join.key}` : join.key);
1352
1352
  }
1353
1353
  }
1354
1354
  return record;
@@ -1365,16 +1365,16 @@ var PgRelationManager = class {
1365
1365
  * Build a schema that includes all join properties recursively
1366
1366
  */
1367
1367
  buildSchemaWithJoins(baseSchema, joins, parentPath) {
1368
- const schema$1 = Value.Clone(baseSchema);
1368
+ const schema = Value.Clone(baseSchema);
1369
1369
  const joinsAtThisLevel = joins.filter((j) => j.parent === parentPath);
1370
1370
  for (const join of joinsAtThisLevel) {
1371
1371
  const joinPath = parentPath ? `${parentPath}.${join.key}` : join.key;
1372
1372
  const childJoins = joins.filter((j) => j.parent === joinPath);
1373
1373
  let joinSchema = join.schema;
1374
1374
  if (childJoins.length > 0) joinSchema = this.buildSchemaWithJoins(join.schema, joins, joinPath);
1375
- schema$1.properties[join.key] = t.optional(joinSchema);
1375
+ schema.properties[join.key] = t.optional(joinSchema);
1376
1376
  }
1377
- return schema$1;
1377
+ return schema;
1378
1378
  }
1379
1379
  };
1380
1380
 
@@ -1386,7 +1386,7 @@ var QueryManager = class {
1386
1386
  * Convert a query object to a SQL query.
1387
1387
  */
1388
1388
  toSQL(query, options) {
1389
- const { schema: schema$1, col, joins } = options;
1389
+ const { schema, col, joins } = options;
1390
1390
  const conditions = [];
1391
1391
  if (isSQLWrapper(query)) conditions.push(query);
1392
1392
  else {
@@ -1408,13 +1408,13 @@ var QueryManager = class {
1408
1408
  parent: newParent
1409
1409
  };
1410
1410
  });
1411
- const sql$2 = this.toSQL(query[key], {
1411
+ const sql = this.toSQL(query[key], {
1412
1412
  schema: join.schema,
1413
1413
  col: join.col,
1414
1414
  joins: recursiveJoins.length > 0 ? recursiveJoins : void 0,
1415
1415
  dialect: options.dialect
1416
1416
  });
1417
- if (sql$2) conditions.push(sql$2);
1417
+ if (sql) conditions.push(sql);
1418
1418
  continue;
1419
1419
  }
1420
1420
  }
@@ -1422,7 +1422,7 @@ var QueryManager = class {
1422
1422
  const operations = operator.map((it) => {
1423
1423
  if (isSQLWrapper(it)) return it;
1424
1424
  return this.toSQL(it, {
1425
- schema: schema$1,
1425
+ schema,
1426
1426
  col,
1427
1427
  joins,
1428
1428
  dialect: options.dialect
@@ -1433,7 +1433,7 @@ var QueryManager = class {
1433
1433
  }
1434
1434
  if (key === "not") {
1435
1435
  const where = this.toSQL(operator, {
1436
- schema: schema$1,
1436
+ schema,
1437
1437
  col,
1438
1438
  joins,
1439
1439
  dialect: options.dialect
@@ -1442,8 +1442,8 @@ var QueryManager = class {
1442
1442
  }
1443
1443
  if (operator) {
1444
1444
  const column = col(key);
1445
- const sql$2 = this.mapOperatorToSql(operator, column, schema$1, key, options.dialect);
1446
- if (sql$2) conditions.push(sql$2);
1445
+ const sql = this.mapOperatorToSql(operator, column, schema, key, options.dialect);
1446
+ if (sql) conditions.push(sql);
1447
1447
  }
1448
1448
  }
1449
1449
  }
@@ -1612,7 +1612,7 @@ var QueryManager = class {
1612
1612
 
1613
1613
  //#endregion
1614
1614
  //#region ../../src/orm/services/Repository.ts
1615
- var Repository = class {
1615
+ var Repository = class Repository {
1616
1616
  entity;
1617
1617
  provider;
1618
1618
  log = $logger();
@@ -1620,6 +1620,13 @@ var Repository = class {
1620
1620
  queryManager = $inject(QueryManager);
1621
1621
  dateTimeProvider = $inject(DateTimeProvider);
1622
1622
  alepha = $inject(Alepha);
1623
+ static of(entity, provider = DatabaseProvider) {
1624
+ return class InlineRepository extends Repository {
1625
+ constructor() {
1626
+ super(entity, provider);
1627
+ }
1628
+ };
1629
+ }
1623
1630
  constructor(entity, provider = DatabaseProvider) {
1624
1631
  this.entity = entity;
1625
1632
  this.provider = this.alepha.inject(provider);
@@ -1674,11 +1681,11 @@ var Repository = class {
1674
1681
  * }
1675
1682
  * ```
1676
1683
  */
1677
- async query(query, schema$1) {
1684
+ async query(query, schema) {
1678
1685
  const raw = typeof query === "function" ? query(this.table, this.db) : query;
1679
1686
  if (typeof raw === "string" && raw.includes("[object Object]")) throw new AlephaError("Invalid SQL query. Did you forget to call the 'sql' function?");
1680
1687
  return (await this.provider.execute(raw)).map((it) => {
1681
- return this.clean(this.mapRawFieldsToEntity(it), schema$1 ?? this.entity.schema);
1688
+ return this.clean(this.mapRawFieldsToEntity(it), schema ?? this.entity.schema);
1682
1689
  });
1683
1690
  }
1684
1691
  /**
@@ -1724,11 +1731,11 @@ var Repository = class {
1724
1731
  * Start a SELECT DISTINCT query on the table.
1725
1732
  */
1726
1733
  rawSelectDistinct(opts = {}, columns = []) {
1727
- const db$1 = opts.tx ?? this.db;
1734
+ const db = opts.tx ?? this.db;
1728
1735
  const table = this.table;
1729
1736
  const fields = {};
1730
1737
  for (const column of columns) if (typeof column === "string") fields[column] = this.col(column);
1731
- return db$1.selectDistinct(fields).from(table);
1738
+ return db.selectDistinct(fields).from(table);
1732
1739
  }
1733
1740
  /**
1734
1741
  * Start an INSERT query on the table.
@@ -1780,21 +1787,21 @@ var Repository = class {
1780
1787
  }
1781
1788
  try {
1782
1789
  let rows = await builder.execute();
1783
- let schema$1 = this.entity.schema;
1784
- if (columns) schema$1 = t.pick(schema$1, columns);
1790
+ let schema = this.entity.schema;
1791
+ if (columns) schema = t.pick(schema, columns);
1785
1792
  if (joins.length) rows = rows.map((row) => {
1786
1793
  const rowSchema = {
1787
- ...schema$1,
1788
- properties: { ...schema$1.properties }
1794
+ ...schema,
1795
+ properties: { ...schema.properties }
1789
1796
  };
1790
1797
  return this.relationManager.mapRowWithJoins(row[this.tableName], row, rowSchema, joins);
1791
1798
  });
1792
1799
  rows = rows.map((row) => {
1793
1800
  if (joins.length) {
1794
- const joinedSchema = this.relationManager.buildSchemaWithJoins(schema$1, joins);
1801
+ const joinedSchema = this.relationManager.buildSchemaWithJoins(schema, joins);
1795
1802
  return this.cleanWithJoins(row, joinedSchema, joins);
1796
1803
  }
1797
- return this.clean(row, schema$1);
1804
+ return this.clean(row, schema);
1798
1805
  });
1799
1806
  await this.alepha.events.emit("repository:read:after", {
1800
1807
  tableName: this.tableName,
@@ -2140,27 +2147,27 @@ var Repository = class {
2140
2147
  * Convert something to valid Pg Insert Value.
2141
2148
  */
2142
2149
  cast(data, insert) {
2143
- const schema$1 = insert ? this.entity.insertSchema : t.partial(this.entity.updateSchema);
2144
- return this.alepha.codec.encode(schema$1, data);
2150
+ const schema = insert ? this.entity.insertSchema : t.partial(this.entity.updateSchema);
2151
+ return this.alepha.codec.encode(schema, data);
2145
2152
  }
2146
2153
  /**
2147
2154
  * Transform a row from the database into a clean entity.
2148
2155
  */
2149
- clean(row, schema$1) {
2150
- for (const key of Object.keys(schema$1.properties)) {
2151
- const value = schema$1.properties[key];
2156
+ clean(row, schema) {
2157
+ for (const key of Object.keys(schema.properties)) {
2158
+ const value = schema.properties[key];
2152
2159
  if (typeof row[key] === "string") {
2153
2160
  if (t.schema.isDateTime(value)) row[key] = this.dateTimeProvider.of(row[key]).toISOString();
2154
2161
  else if (t.schema.isDate(value)) row[key] = this.dateTimeProvider.of(`${row[key]}T00:00:00Z`).toISOString().split("T")[0];
2155
2162
  }
2156
2163
  if (typeof row[key] === "bigint" && t.schema.isBigInt(value)) row[key] = row[key].toString();
2157
2164
  }
2158
- return this.alepha.codec.decode(schema$1, row);
2165
+ return this.alepha.codec.decode(schema, row);
2159
2166
  }
2160
2167
  /**
2161
2168
  * Clean a row with joins recursively
2162
2169
  */
2163
- cleanWithJoins(row, schema$1, joins, parentPath) {
2170
+ cleanWithJoins(row, schema, joins, parentPath) {
2164
2171
  const joinsAtThisLevel = joins.filter((j) => j.parent === parentPath);
2165
2172
  const cleanRow = { ...row };
2166
2173
  const joinedData = {};
@@ -2168,7 +2175,7 @@ var Repository = class {
2168
2175
  joinedData[join.key] = cleanRow[join.key];
2169
2176
  delete cleanRow[join.key];
2170
2177
  }
2171
- const entity = this.clean(cleanRow, schema$1);
2178
+ const entity = this.clean(cleanRow, schema);
2172
2179
  for (const join of joinsAtThisLevel) {
2173
2180
  const joinedValue = joinedData[join.key];
2174
2181
  if (joinedValue != null) {
@@ -2204,8 +2211,8 @@ var Repository = class {
2204
2211
  /**
2205
2212
  * Find a primary key in the schema.
2206
2213
  */
2207
- getPrimaryKey(schema$1) {
2208
- const primaryKeys = getAttrFields(schema$1, PG_PRIMARY_KEY);
2214
+ getPrimaryKey(schema) {
2215
+ const primaryKeys = getAttrFields(schema, PG_PRIMARY_KEY);
2209
2216
  if (primaryKeys.length === 0) throw new AlephaError("Primary key not found in schema");
2210
2217
  if (primaryKeys.length > 1) throw new AlephaError(`Multiple primary keys (${primaryKeys.length}) are not supported`);
2211
2218
  return {
@@ -2523,8 +2530,8 @@ function buildQueryString(where) {
2523
2530
  if (!where || typeof where !== "object") return "";
2524
2531
  if ("and" in where && Array.isArray(where.and)) return where.and.map((w) => buildQueryString(w)).join("&");
2525
2532
  if ("or" in where && Array.isArray(where.or)) {
2526
- const parts$1 = where.or.map((w) => buildQueryString(w));
2527
- return parts$1.length > 1 ? `(${parts$1.join("|")})` : parts$1[0];
2533
+ const parts = where.or.map((w) => buildQueryString(w));
2534
+ return parts.length > 1 ? `(${parts.join("|")})` : parts[0];
2528
2535
  }
2529
2536
  if ("not" in where) return "";
2530
2537
  const parts = [];