alepha 0.14.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +3 -3
  2. package/dist/api/audits/index.d.ts +80 -1
  3. package/dist/api/audits/index.d.ts.map +1 -1
  4. package/dist/api/audits/index.js.map +1 -1
  5. package/dist/api/files/index.d.ts +80 -1
  6. package/dist/api/files/index.d.ts.map +1 -1
  7. package/dist/api/files/index.js.map +1 -1
  8. package/dist/api/jobs/index.d.ts +236 -157
  9. package/dist/api/jobs/index.d.ts.map +1 -1
  10. package/dist/api/jobs/index.js.map +1 -1
  11. package/dist/api/notifications/index.d.ts +21 -1
  12. package/dist/api/notifications/index.d.ts.map +1 -1
  13. package/dist/api/parameters/index.d.ts +451 -4
  14. package/dist/api/parameters/index.d.ts.map +1 -1
  15. package/dist/api/parameters/index.js.map +1 -1
  16. package/dist/api/users/index.d.ts +252 -249
  17. package/dist/api/users/index.d.ts.map +1 -1
  18. package/dist/api/users/index.js +4 -0
  19. package/dist/api/users/index.js.map +1 -1
  20. package/dist/api/verifications/index.d.ts +128 -128
  21. package/dist/api/verifications/index.d.ts.map +1 -1
  22. package/dist/batch/index.js.map +1 -1
  23. package/dist/cache/core/index.js.map +1 -1
  24. package/dist/cli/index.d.ts +304 -115
  25. package/dist/cli/index.d.ts.map +1 -1
  26. package/dist/cli/index.js +650 -531
  27. package/dist/cli/index.js.map +1 -1
  28. package/dist/command/index.d.ts +210 -13
  29. package/dist/command/index.d.ts.map +1 -1
  30. package/dist/command/index.js +306 -69
  31. package/dist/command/index.js.map +1 -1
  32. package/dist/core/index.browser.js.map +1 -1
  33. package/dist/core/index.d.ts +1 -1
  34. package/dist/core/index.d.ts.map +1 -1
  35. package/dist/core/index.js +7 -6
  36. package/dist/core/index.js.map +1 -1
  37. package/dist/core/index.native.js +7 -6
  38. package/dist/core/index.native.js.map +1 -1
  39. package/dist/datetime/index.js.map +1 -1
  40. package/dist/fake/index.js.map +1 -1
  41. package/dist/file/index.d.ts.map +1 -1
  42. package/dist/file/index.js.map +1 -1
  43. package/dist/lock/redis/index.js.map +1 -1
  44. package/dist/logger/index.js.map +1 -1
  45. package/dist/mcp/index.js.map +1 -1
  46. package/dist/orm/index.browser.js +26 -5
  47. package/dist/orm/index.browser.js.map +1 -1
  48. package/dist/orm/index.d.ts +294 -215
  49. package/dist/orm/index.d.ts.map +1 -1
  50. package/dist/orm/index.js +522 -523
  51. package/dist/orm/index.js.map +1 -1
  52. package/dist/queue/redis/index.js +2 -4
  53. package/dist/queue/redis/index.js.map +1 -1
  54. package/dist/redis/index.d.ts +400 -29
  55. package/dist/redis/index.d.ts.map +1 -1
  56. package/dist/redis/index.js +412 -21
  57. package/dist/redis/index.js.map +1 -1
  58. package/dist/retry/index.js.map +1 -1
  59. package/dist/router/index.js.map +1 -1
  60. package/dist/scheduler/index.js.map +1 -1
  61. package/dist/security/index.d.ts.map +1 -1
  62. package/dist/security/index.js.map +1 -1
  63. package/dist/server/auth/index.d.ts +155 -155
  64. package/dist/server/auth/index.js.map +1 -1
  65. package/dist/server/cache/index.js.map +1 -1
  66. package/dist/server/cookies/index.browser.js.map +1 -1
  67. package/dist/server/cookies/index.js.map +1 -1
  68. package/dist/server/core/index.browser.js.map +1 -1
  69. package/dist/server/core/index.d.ts +0 -1
  70. package/dist/server/core/index.d.ts.map +1 -1
  71. package/dist/server/core/index.js.map +1 -1
  72. package/dist/server/helmet/index.d.ts +4 -1
  73. package/dist/server/helmet/index.d.ts.map +1 -1
  74. package/dist/server/helmet/index.js.map +1 -1
  75. package/dist/server/links/index.browser.js.map +1 -1
  76. package/dist/server/links/index.js.map +1 -1
  77. package/dist/server/multipart/index.d.ts.map +1 -1
  78. package/dist/server/multipart/index.js.map +1 -1
  79. package/dist/server/proxy/index.js.map +1 -1
  80. package/dist/server/rate-limit/index.js.map +1 -1
  81. package/dist/server/security/index.d.ts +9 -9
  82. package/dist/server/security/index.js.map +1 -1
  83. package/dist/server/swagger/index.js.map +1 -1
  84. package/dist/thread/index.js.map +1 -1
  85. package/dist/topic/core/index.js.map +1 -1
  86. package/dist/topic/redis/index.js +3 -3
  87. package/dist/topic/redis/index.js.map +1 -1
  88. package/dist/vite/index.js +9 -6
  89. package/dist/vite/index.js.map +1 -1
  90. package/dist/websocket/index.browser.js.map +1 -1
  91. package/dist/websocket/index.d.ts +7 -7
  92. package/dist/websocket/index.js.map +1 -1
  93. package/package.json +3 -3
  94. package/src/api/users/index.ts +4 -0
  95. package/src/cli/apps/AlephaCli.ts +36 -14
  96. package/src/cli/apps/AlephaPackageBuilderCli.ts +5 -1
  97. package/src/cli/assets/appRouterTs.ts +1 -1
  98. package/src/cli/atoms/changelogOptions.ts +45 -0
  99. package/src/cli/commands/{ViteCommands.ts → build.ts} +4 -93
  100. package/src/cli/commands/changelog.ts +244 -0
  101. package/src/cli/commands/clean.ts +14 -0
  102. package/src/cli/commands/{DrizzleCommands.ts → db.ts} +37 -124
  103. package/src/cli/commands/deploy.ts +118 -0
  104. package/src/cli/commands/dev.ts +57 -0
  105. package/src/cli/commands/format.ts +17 -0
  106. package/src/cli/commands/{CoreCommands.ts → init.ts} +2 -40
  107. package/src/cli/commands/lint.ts +17 -0
  108. package/src/cli/commands/root.ts +32 -0
  109. package/src/cli/commands/run.ts +24 -0
  110. package/src/cli/commands/test.ts +42 -0
  111. package/src/cli/commands/typecheck.ts +19 -0
  112. package/src/cli/commands/{VerifyCommands.ts → verify.ts} +1 -13
  113. package/src/cli/defineConfig.ts +24 -0
  114. package/src/cli/index.ts +17 -5
  115. package/src/cli/services/AlephaCliUtils.ts +4 -21
  116. package/src/cli/services/GitMessageParser.ts +77 -0
  117. package/src/command/helpers/EnvUtils.ts +37 -0
  118. package/src/command/index.ts +3 -1
  119. package/src/command/primitives/$command.ts +172 -6
  120. package/src/command/providers/CliProvider.ts +424 -91
  121. package/src/core/Alepha.ts +8 -5
  122. package/src/file/providers/NodeFileSystemProvider.ts +3 -1
  123. package/src/orm/index.browser.ts +1 -1
  124. package/src/orm/index.ts +18 -10
  125. package/src/orm/interfaces/PgQueryWhere.ts +1 -26
  126. package/src/orm/providers/{PostgresTypeProvider.ts → DatabaseTypeProvider.ts} +25 -3
  127. package/src/orm/providers/drivers/BunPostgresProvider.ts +225 -0
  128. package/src/orm/providers/drivers/BunSqliteProvider.ts +180 -0
  129. package/src/orm/providers/drivers/DatabaseProvider.ts +25 -0
  130. package/src/orm/providers/drivers/NodePostgresProvider.ts +0 -25
  131. package/src/orm/services/QueryManager.ts +10 -125
  132. package/src/queue/redis/providers/RedisQueueProvider.ts +2 -7
  133. package/src/redis/index.ts +65 -3
  134. package/src/redis/providers/BunRedisProvider.ts +304 -0
  135. package/src/redis/providers/BunRedisSubscriberProvider.ts +94 -0
  136. package/src/redis/providers/NodeRedisProvider.ts +280 -0
  137. package/src/redis/providers/NodeRedisSubscriberProvider.ts +94 -0
  138. package/src/redis/providers/RedisProvider.ts +134 -140
  139. package/src/redis/providers/RedisSubscriberProvider.ts +58 -49
  140. package/src/server/core/providers/BunHttpServerProvider.ts +0 -3
  141. package/src/server/core/providers/ServerBodyParserProvider.ts +3 -1
  142. package/src/server/core/providers/ServerProvider.ts +7 -4
  143. package/src/server/multipart/providers/ServerMultipartProvider.ts +3 -1
  144. package/src/server/proxy/providers/ServerProxyProvider.ts +1 -1
  145. package/src/topic/redis/providers/RedisTopicProvider.ts +3 -3
  146. package/src/vite/tasks/buildServer.ts +1 -0
  147. package/src/cli/commands/BiomeCommands.ts +0 -29
  148. package/src/cli/commands/ChangelogCommands.ts +0 -389
  149. package/src/orm/services/PgJsonQueryManager.ts +0 -511
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["keysToDelete: string[]"],"sources":["../../../src/cache/core/errors/CacheError.ts","../../../src/cache/core/providers/CacheProvider.ts","../../../src/cache/core/providers/MemoryCacheProvider.ts","../../../src/cache/core/primitives/$cache.ts","../../../src/cache/core/index.ts"],"sourcesContent":["import { AlephaError } from \"alepha\";\n\nexport class CacheError extends AlephaError {}\n","/**\n * Cache provider interface.\n *\n * All methods are asynchronous and return promises.\n * Values are stored as Uint8Array.\n */\nexport abstract class CacheProvider {\n /**\n * Get the value of a key.\n *\n * @param name Cache name, used to group keys. Should be Redis-like \"some:group:name\" format.\n * @param key The key of the value to get.\n *\n * @return The value of the key, or undefined if the key does not exist.\n */\n public abstract get(\n name: string,\n key: string,\n ): Promise<Uint8Array | undefined>;\n\n /**\n * Set the string value of a key.\n *\n * @param name Cache name, used to group keys. Should be Redis-like \"some:group:name\" format.\n * @param key The key of the value to set.\n * @param value The value to set.\n * @param ttl The time-to-live of the key, in milliseconds.\n *\n * @return The value of the key.\n */\n public abstract set(\n name: string,\n key: string,\n value: Uint8Array,\n ttl?: number,\n ): Promise<Uint8Array>;\n\n /**\n * Remove the specified keys.\n *\n * @param name Cache name, used to group keys. Should be Redis-like \"some:group:name\" format.\n * @param keys The keys to delete.\n */\n public abstract del(name: string, ...keys: string[]): Promise<void>;\n\n public abstract has(name: string, key: string): Promise<boolean>;\n\n public abstract keys(name: string, filter?: string): Promise<string[]>;\n\n /**\n * Remove all keys from all cache names.\n */\n public abstract clear(): Promise<void>;\n}\n","import { $inject } from \"alepha\";\nimport { DateTimeProvider, type Timeout } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport type { CacheProvider } from \"./CacheProvider.ts\";\n\ntype CacheName = string;\ntype CacheKey = string;\ntype CacheValue = {\n data?: Uint8Array;\n timeout?: Timeout;\n};\n\nexport class MemoryCacheProvider implements CacheProvider {\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n protected readonly log = $logger();\n\n protected store: Record<CacheName, Record<CacheKey, CacheValue>> = {};\n\n public async get(name: string, key: string): Promise<Uint8Array | undefined> {\n return this.store[name]?.[key]?.data;\n }\n\n public async set(\n name: string,\n key: string,\n value: Uint8Array,\n ttl?: number,\n ): Promise<Uint8Array> {\n if (this.store[name] == null) {\n this.store[name] = {};\n }\n\n this.store[name][key] ??= {};\n this.store[name][key].data = value;\n\n this.log.debug(`Setting cache for name`, { name, key, ttl });\n\n // clear previous timeout if exists\n if (this.store[name][key].timeout) {\n this.dateTimeProvider.clearTimeout(this.store[name][key].timeout);\n this.store[name][key].timeout = undefined;\n }\n\n if (ttl) {\n this.store[name][key].timeout = this.dateTimeProvider.createTimeout(\n () => this.del(name, key),\n ttl,\n );\n }\n\n return this.store[name][key].data;\n }\n\n public async del(name: string, ...keys: string[]): Promise<void> {\n // delete all keys in name\n if (keys.length === 0) {\n this.log.debug(`Deleting all cache for name`, { name });\n\n if (this.store[name]) {\n for (const key of Object.keys(this.store[name])) {\n const timeout = this.store[name][key]?.timeout;\n if (timeout) {\n this.dateTimeProvider.clearTimeout(timeout);\n }\n }\n }\n delete this.store[name];\n return;\n }\n\n this.log.debug(`Deleting cache for name`, { name, keys });\n\n // delete specific keys in name\n for (const key of keys) {\n if (this.store[name] == null) break;\n\n const timeout = this.store[name][key]?.timeout;\n if (timeout) {\n this.dateTimeProvider.clearTimeout(timeout);\n }\n\n delete this.store[name][key];\n }\n\n if (Object.keys(this.store[name] ?? {}).length === 0) {\n // if name is empty, delete it\n delete this.store[name];\n }\n }\n\n public async has(name: string, key: string): Promise<boolean> {\n return this.store[name]?.[key]?.data != null;\n }\n\n public async keys(name: string, filter?: string): Promise<string[]> {\n const store = this.store[name] ?? {};\n const keys = Object.keys(store);\n if (filter) {\n return keys.filter((key) => key.startsWith(filter));\n }\n return keys;\n }\n\n public async clear(): Promise<void> {\n this.log.debug(\"Clearing all cache\");\n\n // Clear all timeouts before clearing the store\n for (const name of Object.keys(this.store)) {\n for (const key of Object.keys(this.store[name])) {\n const timeout = this.store[name][key]?.timeout;\n if (timeout) {\n this.dateTimeProvider.clearTimeout(timeout);\n }\n }\n }\n\n this.store = {};\n }\n}\n","import {\n $env,\n $inject,\n createPrimitive,\n type InstantiableClass,\n KIND,\n Primitive,\n t,\n} from \"alepha\";\nimport { DateTimeProvider, type DurationLike } from \"alepha/datetime\";\nimport { CacheError } from \"../errors/CacheError.ts\";\nimport { CacheProvider } from \"../providers/CacheProvider.ts\";\nimport { MemoryCacheProvider } from \"../providers/MemoryCacheProvider.ts\";\n\n/**\n * Creates a cache primitive for high-performance data caching with automatic management.\n *\n * Provides a caching layer that improves application performance by storing frequently accessed\n * data in memory or external stores like Redis, with support for both function result caching\n * and manual cache operations.\n *\n * **Key Features**\n * - Automatic function result caching based on input parameters\n * - Multiple storage backends (in-memory, Redis, custom providers)\n * - Intelligent serialization for JSON, strings, and binary data\n * - Configurable TTL with automatic expiration\n * - Pattern-based cache invalidation with wildcard support\n * - Environment controls to enable/disable caching\n *\n * **Storage Backends**\n * - Memory: Fast in-memory cache (default for development)\n * - Redis: Distributed cache for production environments\n * - Custom providers: Implement your own storage backend\n *\n * @example\n * ```ts\n * class DataService {\n * // Function result caching\n * getUserData = $cache({\n * name: \"user-data\",\n * ttl: [10, \"minutes\"],\n * handler: async (userId: string) => {\n * return await database.users.findById(userId);\n * }\n * });\n *\n * // Manual cache operations\n * sessionCache = $cache<UserSession>({\n * name: \"sessions\",\n * ttl: [1, \"hour\"]\n * });\n *\n * async storeSession(id: string, session: UserSession) {\n * await this.sessionCache.set(id, session);\n * }\n *\n * async invalidateUserSessions(userId: string) {\n * await this.sessionCache.invalidate(`user:${userId}:*`);\n * }\n * }\n * ```\n */\nexport const $cache = <TReturn = string, TParameter extends any[] = any[]>(\n options: CachePrimitiveOptions<TReturn, TParameter> = {},\n): CachePrimitiveFn<TReturn, TParameter> => {\n const instance = createPrimitive(\n CachePrimitive<TReturn, TParameter>,\n options,\n );\n const fn = (...args: TParameter): Promise<TReturn> => instance.run(...args);\n return Object.setPrototypeOf(fn, instance) as CachePrimitiveFn<\n TReturn,\n TParameter\n >;\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface CachePrimitiveOptions<\n TReturn = any,\n TParameter extends any[] = any[],\n> {\n /**\n * The cache name. This is useful for invalidating multiple caches at once.\n *\n * Store key as `cache:$name:$key`.\n *\n * @default Name of the key of the class.\n */\n name?: string;\n\n /**\n * Function which returns cached data.\n */\n handler?: (...args: TParameter) => TReturn;\n\n /**\n * The key generator for the cache.\n * If not provided, the arguments will be json.stringify().\n */\n key?: (...args: TParameter) => string;\n\n /**\n * The store provider for the cache.\n * If not provided, the default store provider will be used.\n */\n provider?: InstantiableClass<CacheProvider> | \"memory\";\n\n /**\n * The time-to-live for the cache in seconds.\n * Set 0 to skip expiration.\n *\n * @default 300 (5 minutes).\n */\n ttl?: DurationLike;\n\n /**\n * If the cache is disabled.\n */\n disabled?: boolean;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nconst envSchema = t.object({\n CACHE_ENABLED: t.boolean({ default: true }),\n CACHE_DEFAULT_TTL: t.number({\n default: 300, // 5 minutes\n description: \"The default time to live for cache entries. In seconds.\",\n }),\n});\n\nexport class CachePrimitive<\n TReturn = any,\n TParameter extends any[] = any[],\n> extends Primitive<CachePrimitiveOptions<TReturn, TParameter>> {\n protected readonly env = $env(envSchema);\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n protected readonly provider = this.$provider();\n protected encoder: TextEncoder = new TextEncoder();\n protected decoder: TextDecoder = new TextDecoder();\n protected codes = {\n BINARY: 0x01,\n JSON: 0x02,\n STRING: 0x03,\n };\n\n public get container(): string {\n return (\n this.options.name ??\n `${this.config.service.name}:${this.config.propertyKey}`\n );\n }\n\n public async run(...args: TParameter): Promise<TReturn> {\n const handler = this.options.handler;\n if (!handler) {\n throw new Error(\"Cache handler is not defined.\");\n }\n\n const key = this.key(...args);\n const cached = await this.get(key);\n if (cached) {\n return cached;\n }\n\n const result = await handler(...args);\n // note: when exception occurs, don't cache the result\n\n await this.set(key, result);\n\n return result;\n }\n\n public key(...args: TParameter): string {\n return this.options.key ? this.options.key(...args) : JSON.stringify(args);\n }\n\n public async invalidate(...keys: string[]): Promise<void> {\n const keysToDelete: string[] = [];\n\n for (const key of keys) {\n if (key.endsWith(\"*\")) {\n const result = await this.provider.keys(\n this.container,\n key.slice(0, -1),\n );\n keysToDelete.push(...result);\n } else {\n keysToDelete.push(key);\n }\n }\n\n await this.provider.del(this.container, ...keysToDelete);\n }\n\n public async set(\n key: string,\n value: TReturn,\n ttl?: DurationLike,\n ): Promise<void> {\n const px = this.dateTimeProvider\n .duration(\n ttl ?? this.options.ttl ?? [this.env.CACHE_DEFAULT_TTL, \"seconds\"],\n )\n .as(\"milliseconds\");\n\n await this.provider.set(\n this.container,\n key,\n this.serialize(value),\n px > 0 ? px : undefined,\n );\n }\n\n public async get(key: string): Promise<TReturn | undefined> {\n if (\n !this.alepha.isStarted() ||\n this.options.disabled ||\n !this.env.CACHE_ENABLED\n ) {\n return undefined;\n }\n\n const data = await this.provider.get(this.container, key);\n if (data) {\n return await this.deserialize<TReturn>(data);\n }\n\n return undefined;\n }\n\n protected serialize<TReturn>(value: TReturn): Uint8Array {\n if (value instanceof Uint8Array) {\n return new Uint8Array([this.codes.BINARY, ...value]); // TODO: check if copy is ok?\n }\n\n if (typeof value === \"string\") {\n return new Uint8Array([this.codes.STRING, ...this.encoder.encode(value)]);\n }\n\n return new Uint8Array([\n this.codes.JSON,\n ...this.encoder.encode(JSON.stringify(value)),\n ]);\n }\n\n protected async deserialize<TReturn>(\n uint8Array: Uint8Array,\n ): Promise<TReturn> {\n const type = uint8Array[0];\n const payload = uint8Array.slice(1);\n\n if (type === this.codes.BINARY) {\n return payload as TReturn;\n }\n if (type === this.codes.JSON) {\n return JSON.parse(this.decoder.decode(payload)) as TReturn;\n }\n if (type === this.codes.STRING) {\n return this.decoder.decode(payload) as TReturn;\n }\n\n throw new CacheError(`Unknown serialization type: ${type}`);\n }\n\n protected $provider(): CacheProvider {\n if (!this.options.provider) {\n return this.alepha.inject(CacheProvider);\n }\n\n if (this.options.provider === \"memory\") {\n return this.alepha.inject(MemoryCacheProvider);\n }\n\n return this.alepha.inject(this.options.provider);\n }\n}\n\nexport interface CachePrimitiveFn<\n TReturn = any,\n TParameter extends any[] = any[],\n> extends CachePrimitive<TReturn, TParameter> {\n /**\n * Run the cache primitive with the provided arguments.\n */\n (...args: TParameter): Promise<TReturn>;\n}\n\n$cache[KIND] = CachePrimitive;\n","import { $module } from \"alepha\";\nimport { $cache } from \"./primitives/$cache.ts\";\nimport { CacheProvider } from \"./providers/CacheProvider.ts\";\nimport { MemoryCacheProvider } from \"./providers/MemoryCacheProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./primitives/$cache.ts\";\nexport * from \"./providers/CacheProvider.ts\";\nexport * from \"./providers/MemoryCacheProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Provides high-performance caching capabilities for Alepha applications with configurable TTL and multiple storage backends.\n *\n * The cache module enables declarative caching through the `$cache` primitive, allowing you to cache method results,\n * API responses, or computed values with automatic invalidation and type safety. It supports both in-memory and\n * persistent storage backends for different performance and durability requirements.\n *\n * @see {@link $cache}\n * @see {@link CacheProvider}\n * @module alepha.cache\n */\nexport const AlephaCache = $module({\n name: \"alepha.cache\",\n primitives: [$cache],\n services: [CacheProvider, MemoryCacheProvider],\n register: (alepha) =>\n alepha.with({\n optional: true,\n provide: CacheProvider,\n use: MemoryCacheProvider,\n }),\n});\n"],"mappings":";;;;;AAEA,IAAa,aAAb,cAAgC,YAAY;;;;;;;;;;ACI5C,IAAsB,gBAAtB,MAAoC;;;;ACMpC,IAAa,sBAAb,MAA0D;CACxD,AAAmB,mBAAmB,QAAQ,iBAAiB;CAC/D,AAAmB,MAAM,SAAS;CAElC,AAAU,QAAyD,EAAE;CAErE,MAAa,IAAI,MAAc,KAA8C;AAC3E,SAAO,KAAK,MAAM,QAAQ,MAAM;;CAGlC,MAAa,IACX,MACA,KACA,OACA,KACqB;AACrB,MAAI,KAAK,MAAM,SAAS,KACtB,MAAK,MAAM,QAAQ,EAAE;AAGvB,OAAK,MAAM,MAAM,SAAS,EAAE;AAC5B,OAAK,MAAM,MAAM,KAA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AK,MAAM,QAAQ,GAAG,KAAK,QAAQ,OAAO,MAAM,CAAC,CAAC;AAG3E,SAAO,IAAI,WAAW,CACpB,KAAK,MAAM,MACX,GAAG,KAAK,QAAQ,OAAO,KAAK,UAAU,MAAM,CAAC,CAC9C,CAAC;;CAGJ,MAAgB,YACd,YACkB;EAClB,MAAM,OAAO,WAAW;EACxB,MAAM,UAAU,WAAW,MAAM,EAAE;AAEnC,MAAI,SAAS,KAAK,MAAM,OACtB,QAAO;AAET,MAAI,SAAS,KAAK,MAAM,KACtB,QAAO,KAAK,MAAM,KAAK,QAAQ,OAAO,QAAQ,CAAC;AAEjD,MAAI,SAAS,KAAK,MAAM,OACtB,QAAO,KAAK,QAAQ,OAAO,QAAQ;AAGrC,QAAM,IAAI,WAAW,+BAA+B,OAAO;;CAG7D,AAAU,YAA2B;AACnC,MAAI,CAAC,KAAK,QAAQ,SAChB,QAAO,KAAK,OAAO,OAAO,cAAc;AAG1C,MAAI,KAAK,QAAQ,aAAa,SAC5B,QAAO,KAAK,OAAO,OAAO,oBAAoB;AAGhD,SAAO,KAAK,OAAO,OAAO,KAAK,QAAQ,SAAS;;;AAcpD,OAAO,QAAQ;;;;;;;;;;;;;;;ACzQf,MAAa,cAAc,QAAQ;CACjC,MAAM;CACN,YAAY,CAAC,OAAO;CACpB,UAAU,CAAC,eAAe,oBAAoB;CAC9C,WAAW,WACT,OAAO,KAAK;EACV,UAAU;EACV,SAAS;EACT,KAAK;EACN,CAAC;CACL,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/cache/core/errors/CacheError.ts","../../../src/cache/core/providers/CacheProvider.ts","../../../src/cache/core/providers/MemoryCacheProvider.ts","../../../src/cache/core/primitives/$cache.ts","../../../src/cache/core/index.ts"],"sourcesContent":["import { AlephaError } from \"alepha\";\n\nexport class CacheError extends AlephaError {}\n","/**\n * Cache provider interface.\n *\n * All methods are asynchronous and return promises.\n * Values are stored as Uint8Array.\n */\nexport abstract class CacheProvider {\n /**\n * Get the value of a key.\n *\n * @param name Cache name, used to group keys. Should be Redis-like \"some:group:name\" format.\n * @param key The key of the value to get.\n *\n * @return The value of the key, or undefined if the key does not exist.\n */\n public abstract get(\n name: string,\n key: string,\n ): Promise<Uint8Array | undefined>;\n\n /**\n * Set the string value of a key.\n *\n * @param name Cache name, used to group keys. Should be Redis-like \"some:group:name\" format.\n * @param key The key of the value to set.\n * @param value The value to set.\n * @param ttl The time-to-live of the key, in milliseconds.\n *\n * @return The value of the key.\n */\n public abstract set(\n name: string,\n key: string,\n value: Uint8Array,\n ttl?: number,\n ): Promise<Uint8Array>;\n\n /**\n * Remove the specified keys.\n *\n * @param name Cache name, used to group keys. Should be Redis-like \"some:group:name\" format.\n * @param keys The keys to delete.\n */\n public abstract del(name: string, ...keys: string[]): Promise<void>;\n\n public abstract has(name: string, key: string): Promise<boolean>;\n\n public abstract keys(name: string, filter?: string): Promise<string[]>;\n\n /**\n * Remove all keys from all cache names.\n */\n public abstract clear(): Promise<void>;\n}\n","import { $inject } from \"alepha\";\nimport { DateTimeProvider, type Timeout } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport type { CacheProvider } from \"./CacheProvider.ts\";\n\ntype CacheName = string;\ntype CacheKey = string;\ntype CacheValue = {\n data?: Uint8Array;\n timeout?: Timeout;\n};\n\nexport class MemoryCacheProvider implements CacheProvider {\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n protected readonly log = $logger();\n\n protected store: Record<CacheName, Record<CacheKey, CacheValue>> = {};\n\n public async get(name: string, key: string): Promise<Uint8Array | undefined> {\n return this.store[name]?.[key]?.data;\n }\n\n public async set(\n name: string,\n key: string,\n value: Uint8Array,\n ttl?: number,\n ): Promise<Uint8Array> {\n if (this.store[name] == null) {\n this.store[name] = {};\n }\n\n this.store[name][key] ??= {};\n this.store[name][key].data = value;\n\n this.log.debug(`Setting cache for name`, { name, key, ttl });\n\n // clear previous timeout if exists\n if (this.store[name][key].timeout) {\n this.dateTimeProvider.clearTimeout(this.store[name][key].timeout);\n this.store[name][key].timeout = undefined;\n }\n\n if (ttl) {\n this.store[name][key].timeout = this.dateTimeProvider.createTimeout(\n () => this.del(name, key),\n ttl,\n );\n }\n\n return this.store[name][key].data;\n }\n\n public async del(name: string, ...keys: string[]): Promise<void> {\n // delete all keys in name\n if (keys.length === 0) {\n this.log.debug(`Deleting all cache for name`, { name });\n\n if (this.store[name]) {\n for (const key of Object.keys(this.store[name])) {\n const timeout = this.store[name][key]?.timeout;\n if (timeout) {\n this.dateTimeProvider.clearTimeout(timeout);\n }\n }\n }\n delete this.store[name];\n return;\n }\n\n this.log.debug(`Deleting cache for name`, { name, keys });\n\n // delete specific keys in name\n for (const key of keys) {\n if (this.store[name] == null) break;\n\n const timeout = this.store[name][key]?.timeout;\n if (timeout) {\n this.dateTimeProvider.clearTimeout(timeout);\n }\n\n delete this.store[name][key];\n }\n\n if (Object.keys(this.store[name] ?? {}).length === 0) {\n // if name is empty, delete it\n delete this.store[name];\n }\n }\n\n public async has(name: string, key: string): Promise<boolean> {\n return this.store[name]?.[key]?.data != null;\n }\n\n public async keys(name: string, filter?: string): Promise<string[]> {\n const store = this.store[name] ?? {};\n const keys = Object.keys(store);\n if (filter) {\n return keys.filter((key) => key.startsWith(filter));\n }\n return keys;\n }\n\n public async clear(): Promise<void> {\n this.log.debug(\"Clearing all cache\");\n\n // Clear all timeouts before clearing the store\n for (const name of Object.keys(this.store)) {\n for (const key of Object.keys(this.store[name])) {\n const timeout = this.store[name][key]?.timeout;\n if (timeout) {\n this.dateTimeProvider.clearTimeout(timeout);\n }\n }\n }\n\n this.store = {};\n }\n}\n","import {\n $env,\n $inject,\n createPrimitive,\n type InstantiableClass,\n KIND,\n Primitive,\n t,\n} from \"alepha\";\nimport { DateTimeProvider, type DurationLike } from \"alepha/datetime\";\nimport { CacheError } from \"../errors/CacheError.ts\";\nimport { CacheProvider } from \"../providers/CacheProvider.ts\";\nimport { MemoryCacheProvider } from \"../providers/MemoryCacheProvider.ts\";\n\n/**\n * Creates a cache primitive for high-performance data caching with automatic management.\n *\n * Provides a caching layer that improves application performance by storing frequently accessed\n * data in memory or external stores like Redis, with support for both function result caching\n * and manual cache operations.\n *\n * **Key Features**\n * - Automatic function result caching based on input parameters\n * - Multiple storage backends (in-memory, Redis, custom providers)\n * - Intelligent serialization for JSON, strings, and binary data\n * - Configurable TTL with automatic expiration\n * - Pattern-based cache invalidation with wildcard support\n * - Environment controls to enable/disable caching\n *\n * **Storage Backends**\n * - Memory: Fast in-memory cache (default for development)\n * - Redis: Distributed cache for production environments\n * - Custom providers: Implement your own storage backend\n *\n * @example\n * ```ts\n * class DataService {\n * // Function result caching\n * getUserData = $cache({\n * name: \"user-data\",\n * ttl: [10, \"minutes\"],\n * handler: async (userId: string) => {\n * return await database.users.findById(userId);\n * }\n * });\n *\n * // Manual cache operations\n * sessionCache = $cache<UserSession>({\n * name: \"sessions\",\n * ttl: [1, \"hour\"]\n * });\n *\n * async storeSession(id: string, session: UserSession) {\n * await this.sessionCache.set(id, session);\n * }\n *\n * async invalidateUserSessions(userId: string) {\n * await this.sessionCache.invalidate(`user:${userId}:*`);\n * }\n * }\n * ```\n */\nexport const $cache = <TReturn = string, TParameter extends any[] = any[]>(\n options: CachePrimitiveOptions<TReturn, TParameter> = {},\n): CachePrimitiveFn<TReturn, TParameter> => {\n const instance = createPrimitive(\n CachePrimitive<TReturn, TParameter>,\n options,\n );\n const fn = (...args: TParameter): Promise<TReturn> => instance.run(...args);\n return Object.setPrototypeOf(fn, instance) as CachePrimitiveFn<\n TReturn,\n TParameter\n >;\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface CachePrimitiveOptions<\n TReturn = any,\n TParameter extends any[] = any[],\n> {\n /**\n * The cache name. This is useful for invalidating multiple caches at once.\n *\n * Store key as `cache:$name:$key`.\n *\n * @default Name of the key of the class.\n */\n name?: string;\n\n /**\n * Function which returns cached data.\n */\n handler?: (...args: TParameter) => TReturn;\n\n /**\n * The key generator for the cache.\n * If not provided, the arguments will be json.stringify().\n */\n key?: (...args: TParameter) => string;\n\n /**\n * The store provider for the cache.\n * If not provided, the default store provider will be used.\n */\n provider?: InstantiableClass<CacheProvider> | \"memory\";\n\n /**\n * The time-to-live for the cache in seconds.\n * Set 0 to skip expiration.\n *\n * @default 300 (5 minutes).\n */\n ttl?: DurationLike;\n\n /**\n * If the cache is disabled.\n */\n disabled?: boolean;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nconst envSchema = t.object({\n CACHE_ENABLED: t.boolean({ default: true }),\n CACHE_DEFAULT_TTL: t.number({\n default: 300, // 5 minutes\n description: \"The default time to live for cache entries. In seconds.\",\n }),\n});\n\nexport class CachePrimitive<\n TReturn = any,\n TParameter extends any[] = any[],\n> extends Primitive<CachePrimitiveOptions<TReturn, TParameter>> {\n protected readonly env = $env(envSchema);\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n protected readonly provider = this.$provider();\n protected encoder: TextEncoder = new TextEncoder();\n protected decoder: TextDecoder = new TextDecoder();\n protected codes = {\n BINARY: 0x01,\n JSON: 0x02,\n STRING: 0x03,\n };\n\n public get container(): string {\n return (\n this.options.name ??\n `${this.config.service.name}:${this.config.propertyKey}`\n );\n }\n\n public async run(...args: TParameter): Promise<TReturn> {\n const handler = this.options.handler;\n if (!handler) {\n throw new Error(\"Cache handler is not defined.\");\n }\n\n const key = this.key(...args);\n const cached = await this.get(key);\n if (cached) {\n return cached;\n }\n\n const result = await handler(...args);\n // note: when exception occurs, don't cache the result\n\n await this.set(key, result);\n\n return result;\n }\n\n public key(...args: TParameter): string {\n return this.options.key ? this.options.key(...args) : JSON.stringify(args);\n }\n\n public async invalidate(...keys: string[]): Promise<void> {\n const keysToDelete: string[] = [];\n\n for (const key of keys) {\n if (key.endsWith(\"*\")) {\n const result = await this.provider.keys(\n this.container,\n key.slice(0, -1),\n );\n keysToDelete.push(...result);\n } else {\n keysToDelete.push(key);\n }\n }\n\n await this.provider.del(this.container, ...keysToDelete);\n }\n\n public async set(\n key: string,\n value: TReturn,\n ttl?: DurationLike,\n ): Promise<void> {\n const px = this.dateTimeProvider\n .duration(\n ttl ?? this.options.ttl ?? [this.env.CACHE_DEFAULT_TTL, \"seconds\"],\n )\n .as(\"milliseconds\");\n\n await this.provider.set(\n this.container,\n key,\n this.serialize(value),\n px > 0 ? px : undefined,\n );\n }\n\n public async get(key: string): Promise<TReturn | undefined> {\n if (\n !this.alepha.isStarted() ||\n this.options.disabled ||\n !this.env.CACHE_ENABLED\n ) {\n return undefined;\n }\n\n const data = await this.provider.get(this.container, key);\n if (data) {\n return await this.deserialize<TReturn>(data);\n }\n\n return undefined;\n }\n\n protected serialize<TReturn>(value: TReturn): Uint8Array {\n if (value instanceof Uint8Array) {\n return new Uint8Array([this.codes.BINARY, ...value]); // TODO: check if copy is ok?\n }\n\n if (typeof value === \"string\") {\n return new Uint8Array([this.codes.STRING, ...this.encoder.encode(value)]);\n }\n\n return new Uint8Array([\n this.codes.JSON,\n ...this.encoder.encode(JSON.stringify(value)),\n ]);\n }\n\n protected async deserialize<TReturn>(\n uint8Array: Uint8Array,\n ): Promise<TReturn> {\n const type = uint8Array[0];\n const payload = uint8Array.slice(1);\n\n if (type === this.codes.BINARY) {\n return payload as TReturn;\n }\n if (type === this.codes.JSON) {\n return JSON.parse(this.decoder.decode(payload)) as TReturn;\n }\n if (type === this.codes.STRING) {\n return this.decoder.decode(payload) as TReturn;\n }\n\n throw new CacheError(`Unknown serialization type: ${type}`);\n }\n\n protected $provider(): CacheProvider {\n if (!this.options.provider) {\n return this.alepha.inject(CacheProvider);\n }\n\n if (this.options.provider === \"memory\") {\n return this.alepha.inject(MemoryCacheProvider);\n }\n\n return this.alepha.inject(this.options.provider);\n }\n}\n\nexport interface CachePrimitiveFn<\n TReturn = any,\n TParameter extends any[] = any[],\n> extends CachePrimitive<TReturn, TParameter> {\n /**\n * Run the cache primitive with the provided arguments.\n */\n (...args: TParameter): Promise<TReturn>;\n}\n\n$cache[KIND] = CachePrimitive;\n","import { $module } from \"alepha\";\nimport { $cache } from \"./primitives/$cache.ts\";\nimport { CacheProvider } from \"./providers/CacheProvider.ts\";\nimport { MemoryCacheProvider } from \"./providers/MemoryCacheProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./primitives/$cache.ts\";\nexport * from \"./providers/CacheProvider.ts\";\nexport * from \"./providers/MemoryCacheProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Provides high-performance caching capabilities for Alepha applications with configurable TTL and multiple storage backends.\n *\n * The cache module enables declarative caching through the `$cache` primitive, allowing you to cache method results,\n * API responses, or computed values with automatic invalidation and type safety. It supports both in-memory and\n * persistent storage backends for different performance and durability requirements.\n *\n * @see {@link $cache}\n * @see {@link CacheProvider}\n * @module alepha.cache\n */\nexport const AlephaCache = $module({\n name: \"alepha.cache\",\n primitives: [$cache],\n services: [CacheProvider, MemoryCacheProvider],\n register: (alepha) =>\n alepha.with({\n optional: true,\n provide: CacheProvider,\n use: MemoryCacheProvider,\n }),\n});\n"],"mappings":";;;;;AAEA,IAAa,aAAb,cAAgC,YAAY;;;;;;;;;;ACI5C,IAAsB,gBAAtB,MAAoC;;;;ACMpC,IAAa,sBAAb,MAA0D;CACxD,AAAmB,mBAAmB,QAAQ,iBAAiB;CAC/D,AAAmB,MAAM,SAAS;CAElC,AAAU,QAAyD,EAAE;CAErE,MAAa,IAAI,MAAc,KAA8C;AAC3E,SAAO,KAAK,MAAM,QAAQ,MAAM;;CAGlC,MAAa,IACX,MACA,KACA,OACA,KACqB;AACrB,MAAI,KAAK,MAAM,SAAS,KACtB,MAAK,MAAM,QAAQ,EAAE;AAGvB,OAAK,MAAM,MAAM,SAAS,EAAE;AAC5B,OAAK,MAAM,MAAM,KAAK,OAAO;AAE7B,OAAK,IAAI,MAAM,0BAA0B;GAAE;GAAM;GAAK;GAAK,CAAC;AAG5D,MAAI,KAAK,MAAM,MAAM,KAAK,SAAS;AACjC,QAAK,i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AO,KAAK,UAAU,MAAM,CAAC,CAC9C,CAAC;;CAGJ,MAAgB,YACd,YACkB;EAClB,MAAM,OAAO,WAAW;EACxB,MAAM,UAAU,WAAW,MAAM,EAAE;AAEnC,MAAI,SAAS,KAAK,MAAM,OACtB,QAAO;AAET,MAAI,SAAS,KAAK,MAAM,KACtB,QAAO,KAAK,MAAM,KAAK,QAAQ,OAAO,QAAQ,CAAC;AAEjD,MAAI,SAAS,KAAK,MAAM,OACtB,QAAO,KAAK,QAAQ,OAAO,QAAQ;AAGrC,QAAM,IAAI,WAAW,+BAA+B,OAAO;;CAG7D,AAAU,YAA2B;AACnC,MAAI,CAAC,KAAK,QAAQ,SAChB,QAAO,KAAK,OAAO,OAAO,cAAc;AAG1C,MAAI,KAAK,QAAQ,aAAa,SAC5B,QAAO,KAAK,OAAO,OAAO,oBAAoB;AAGhD,SAAO,KAAK,OAAO,OAAO,KAAK,QAAQ,SAAS;;;AAcpD,OAAO,QAAQ;;;;;;;;;;;;;;;ACzQf,MAAa,cAAc,QAAQ;CACjC,MAAM;CACN,YAAY,CAAC,OAAO;CACpB,UAAU,CAAC,eAAe,oBAAoB;CAC9C,WAAW,WACT,OAAO,KAAK;EACV,UAAU;EACV,SAAS;EACT,KAAK;EACN,CAAC;CACL,CAAC"}
@@ -1,9 +1,11 @@
1
1
  import * as alepha0 from "alepha";
2
- import { Alepha } from "alepha";
2
+ import { Alepha, Static } from "alepha";
3
3
  import { FileSystemProvider } from "alepha/file";
4
4
  import * as alepha_command0 from "alepha/command";
5
- import { CliProvider, RunnerMethod } from "alepha/command";
6
- import * as alepha_logger3 from "alepha/logger";
5
+ import { CliProvider, CommandPrimitive, EnvUtils, RunnerMethod } from "alepha/command";
6
+ import * as alepha_logger5 from "alepha/logger";
7
+ import * as typebox0 from "typebox";
8
+ import { DatabaseProvider } from "alepha/orm";
7
9
 
8
10
  //#region ../../src/cli/apps/AlephaCli.d.ts
9
11
  declare const AlephaCli: alepha0.Service<alepha0.Module>;
@@ -20,10 +22,37 @@ declare class AlephaPackageBuilderCli {
20
22
  src: string;
21
23
  dist: string;
22
24
  fs: FileSystemProvider;
23
- make: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema>;
25
+ make: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
24
26
  }
25
27
  declare function analyzeModules(srcDir: string, packageName: string): Promise<Module[]>;
26
28
  //#endregion
29
+ //#region ../../src/cli/atoms/changelogOptions.d.ts
30
+ /**
31
+ * Default scopes to ignore in changelog generation.
32
+ * Commits with these scopes won't appear in release notes.
33
+ */
34
+ declare const DEFAULT_IGNORE: string[];
35
+ /**
36
+ * Changelog configuration atom.
37
+ *
38
+ * Configure in `alepha.config.ts`:
39
+ * ```ts
40
+ * import { changelogOptions } from "alepha/cli";
41
+ *
42
+ * alepha.set(changelogOptions, {
43
+ * ignore: ["project", "release", "chore", "docs"],
44
+ * });
45
+ * ```
46
+ */
47
+ declare const changelogOptions: alepha0.Atom<alepha0.TObject<{
48
+ /**
49
+ * Scopes to ignore (e.g., "project", "release", "chore").
50
+ * Commits like `feat(chore): ...` will be excluded from changelog.
51
+ */
52
+ ignore: alepha0.TOptional<alepha0.TArray<alepha0.TString>>;
53
+ }>, "alepha.changelog">;
54
+ type ChangelogOptions = Static<typeof changelogOptions.schema>;
55
+ //#endregion
27
56
  //#region ../../src/cli/services/AlephaCliUtils.d.ts
28
57
  /**
29
58
  * Utility service for common project operations used by CLI commands.
@@ -36,8 +65,9 @@ declare function analyzeModules(srcDir: string, packageName: string): Promise<Mo
36
65
  * - Alepha instance loading
37
66
  */
38
67
  declare class AlephaCliUtils {
39
- protected readonly log: alepha_logger3.Logger;
68
+ protected readonly log: alepha_logger5.Logger;
40
69
  protected readonly fs: FileSystemProvider;
70
+ protected readonly envUtils: EnvUtils;
41
71
  /**
42
72
  * Execute a command using npx with inherited stdio.
43
73
  *
@@ -173,7 +203,7 @@ declare class AlephaCliUtils {
173
203
  * Reads the .env file in the specified root directory and sets
174
204
  * the environment variables in process.env.
175
205
  */
176
- loadEnvFile(root: string, files?: string[]): Promise<void>;
206
+ loadEnv(root: string, files?: string[]): Promise<void>;
177
207
  getPackageManager(root: string, flags?: {
178
208
  yarn?: boolean;
179
209
  pnpm?: boolean;
@@ -233,112 +263,177 @@ interface DependencyModes {
233
263
  expo?: boolean;
234
264
  }
235
265
  //#endregion
236
- //#region ../../src/cli/commands/BiomeCommands.d.ts
237
- declare class BiomeCommands {
238
- protected readonly log: alepha_logger3.Logger;
266
+ //#region ../../src/cli/commands/build.d.ts
267
+ declare class BuildCommand {
268
+ protected readonly log: alepha_logger5.Logger;
239
269
  protected readonly utils: AlephaCliUtils;
240
- readonly format: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema>;
241
- readonly lint: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema>;
270
+ readonly build: alepha_command0.CommandPrimitive<alepha0.TObject<{
271
+ stats: alepha0.TOptional<alepha0.TBoolean>;
272
+ vercel: alepha0.TOptional<alepha0.TBoolean>;
273
+ cloudflare: alepha0.TOptional<alepha0.TBoolean>;
274
+ docker: alepha0.TOptional<alepha0.TBoolean>;
275
+ sitemap: alepha0.TOptional<alepha0.TString>;
276
+ }>, alepha0.TOptional<alepha0.TString>, alepha0.TObject<alepha0.TProperties>>;
242
277
  }
243
278
  //#endregion
244
- //#region ../../src/cli/commands/CoreCommands.d.ts
245
- declare class CoreCommands {
246
- protected readonly log: alepha_logger3.Logger;
247
- protected readonly cli: CliProvider;
248
- protected readonly utils: AlephaCliUtils;
279
+ //#region ../../src/cli/services/GitMessageParser.d.ts
280
+ /**
281
+ * Service for parsing git commit messages into structured format.
282
+ *
283
+ * Only parses **conventional commits with a scope**:
284
+ * - `feat(scope): description` → feature
285
+ * - `fix(scope): description` → bug fix
286
+ * - `feat(scope)!: description` → breaking change
287
+ *
288
+ * Commits without scope are ignored, allowing developers to commit
289
+ * work-in-progress changes without polluting release notes:
290
+ * - `cli: work in progress` → ignored (no type)
291
+ * - `fix: quick patch` → ignored (no scope)
292
+ * - `feat(cli): add command` → included
293
+ */
294
+ declare class GitMessageParser {
295
+ protected readonly log: alepha_logger5.Logger;
249
296
  /**
250
- * Called when no command is provided
297
+ * Parse a git commit line into a structured Commit object.
298
+ *
299
+ * **Format:** `type(scope): description` or `type(scope)!: description`
300
+ *
301
+ * **Supported types:** feat, fix, docs, refactor, perf, revert
302
+ *
303
+ * **Breaking changes:** Use `!` before `:` (e.g., `feat(api)!: remove endpoint`)
304
+ *
305
+ * @returns Commit object or null if not matching/ignored
251
306
  */
252
- readonly root: alepha_command0.CommandPrimitive<alepha0.TObject<{
253
- version: alepha0.TOptional<alepha0.TBoolean>;
254
- }>, alepha0.TSchema>;
307
+ parseCommit(line: string, config: ChangelogOptions): Commit | null;
308
+ }
309
+ //#endregion
310
+ //#region ../../src/cli/commands/changelog.d.ts
311
+ /**
312
+ * Git provider for executing git commands.
313
+ * Can be substituted in tests with a mock implementation.
314
+ */
315
+ declare class GitProvider {
316
+ exec(cmd: string, cwd: string): Promise<string>;
317
+ }
318
+ interface Commit {
319
+ hash: string;
320
+ type: string;
321
+ scope: string | null;
322
+ description: string;
323
+ breaking: boolean;
324
+ }
325
+ interface ChangelogEntry {
326
+ features: Commit[];
327
+ fixes: Commit[];
328
+ }
329
+ /**
330
+ * Changelog command for generating release notes from git commits.
331
+ *
332
+ * Usage:
333
+ * - `alepha changelog` - Show unreleased changes since latest tag to HEAD
334
+ * - `alepha changelog --from=1.0.0` - Show changes from version to HEAD
335
+ * - `alepha changelog --from=1.0.0 --to=1.1.0` - Show changes between two refs
336
+ * - `alepha changelog | tee -a CHANGELOG.md` - Append to file
337
+ */
338
+ declare class ChangelogCommand {
339
+ protected readonly log: alepha_logger5.Logger;
340
+ protected readonly git: GitProvider;
341
+ protected readonly parser: GitMessageParser;
342
+ protected readonly config: Readonly<{
343
+ ignore?: string[] | undefined;
344
+ }>;
255
345
  /**
256
- * Clean the project, removing the "dist" directory
346
+ * Format a single commit line.
347
+ * Example: `- **cli**: add new command (\`abc1234\`)`
348
+ * Breaking changes are flagged: `- **cli**: add new command [BREAKING] (\`abc1234\`)`
257
349
  */
258
- readonly clean: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema>;
350
+ protected formatCommit(commit: Commit): string;
259
351
  /**
260
- * Ensure the project has the necessary Alepha configuration files.
261
- * Add the correct dependencies to package.json and install them.
352
+ * Format the changelog entry with sections.
262
353
  */
263
- readonly init: alepha_command0.CommandPrimitive<alepha0.TObject<{
264
- yarn: alepha0.TOptional<alepha0.TBoolean>;
265
- pnpm: alepha0.TOptional<alepha0.TBoolean>;
266
- npm: alepha0.TOptional<alepha0.TBoolean>;
267
- bun: alepha0.TOptional<alepha0.TBoolean>;
268
- react: alepha0.TOptional<alepha0.TBoolean>;
269
- ui: alepha0.TOptional<alepha0.TBoolean>;
270
- test: alepha0.TOptional<alepha0.TBoolean>;
271
- }>, alepha0.TSchema>;
354
+ protected formatEntry(entry: ChangelogEntry): string;
355
+ /**
356
+ * Parse git log output into a changelog entry.
357
+ */
358
+ protected parseCommits(commitsOutput: string): ChangelogEntry;
359
+ /**
360
+ * Check if entry has any public commits.
361
+ */
362
+ protected hasChanges(entry: ChangelogEntry): boolean;
363
+ /**
364
+ * Get the latest version tag.
365
+ */
366
+ protected getLatestTag(git: (cmd: string) => Promise<string>): Promise<string | null>;
367
+ readonly changelog: alepha_command0.CommandPrimitive<alepha0.TObject<{
368
+ /**
369
+ * Show changes from this ref (tag, commit, branch).
370
+ * Defaults to the latest version tag.
371
+ * Example: --from=1.0.0
372
+ */
373
+ from: alepha0.TOptional<alepha0.TString>;
374
+ /**
375
+ * Show changes up to this ref (tag, commit, branch).
376
+ * Defaults to HEAD.
377
+ * Example: --to=main
378
+ */
379
+ to: alepha0.TOptional<alepha0.TString>;
380
+ }>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
272
381
  }
273
382
  //#endregion
274
- //#region ../../src/cli/commands/DrizzleCommands.d.ts
275
- declare class DrizzleCommands {
276
- log: alepha_logger3.Logger;
277
- utils: AlephaCliUtils;
383
+ //#region ../../src/cli/commands/clean.d.ts
384
+ declare class CleanCommand {
385
+ /**
386
+ * Clean the project, removing the "dist" directory
387
+ */
388
+ readonly clean: alepha_command0.CommandPrimitive<typebox0.TObject<typebox0.TProperties>, typebox0.TSchema, typebox0.TObject<typebox0.TProperties>>;
389
+ }
390
+ //#endregion
391
+ //#region ../../src/cli/commands/db.d.ts
392
+ declare class DbCommand {
393
+ protected readonly log: alepha_logger5.Logger;
394
+ protected readonly utils: AlephaCliUtils;
278
395
  /**
279
396
  * Check if database migrations are up to date.
280
397
  */
281
- check: alepha_command0.CommandPrimitive<alepha0.TObject<{
398
+ protected readonly check: alepha_command0.CommandPrimitive<alepha0.TObject<{
282
399
  provider: alepha0.TOptional<alepha0.TString>;
283
400
  mode: alepha0.TOptional<alepha0.TString>;
284
- }>, alepha0.TOptional<alepha0.TString>>;
401
+ }>, alepha0.TOptional<alepha0.TString>, alepha0.TObject<alepha0.TProperties>>;
285
402
  /**
286
403
  * Generate database migration files
287
- *
288
- * - Loads the Alepha instance from the specified entry file.
289
- * - Retrieves all repository primitives to gather database models.
290
- * - Creates temporary entity definitions based on the current database schema.
291
- * - Writes these definitions to a temporary schema file. (node_modules/.db/entities.ts)
292
- * - Invokes Drizzle Kit's CLI to generate migration files based on the current schema.
293
404
  */
294
- generate: alepha_command0.CommandPrimitive<alepha0.TObject<{
405
+ protected readonly generate: alepha_command0.CommandPrimitive<alepha0.TObject<{
295
406
  provider: alepha0.TOptional<alepha0.TString>;
296
407
  mode: alepha0.TOptional<alepha0.TString>;
297
408
  custom: alepha0.TOptional<alepha0.TString>;
298
- }>, alepha0.TOptional<alepha0.TString>>;
409
+ }>, alepha0.TOptional<alepha0.TString>, alepha0.TObject<alepha0.TProperties>>;
299
410
  /**
300
411
  * Push database schema changes directly to the database
301
- *
302
- * - Loads the Alepha instance from the specified entry file.
303
- * - Retrieves all repository primitives to gather database models.
304
- * - Creates temporary entity definitions and Drizzle config.
305
- * - Invokes Drizzle Kit's push command to apply schema changes directly.
306
412
  */
307
- push: alepha_command0.CommandPrimitive<alepha0.TObject<{
413
+ protected readonly push: alepha_command0.CommandPrimitive<alepha0.TObject<{
308
414
  provider: alepha0.TOptional<alepha0.TString>;
309
415
  mode: alepha0.TOptional<alepha0.TString>;
310
- }>, alepha0.TOptional<alepha0.TString>>;
416
+ }>, alepha0.TOptional<alepha0.TString>, alepha0.TObject<alepha0.TProperties>>;
311
417
  /**
312
418
  * Apply pending database migrations
313
- *
314
- * - Loads the Alepha instance from the specified entry file.
315
- * - Retrieves all repository primitives to gather database models.
316
- * - Creates temporary entity definitions and Drizzle config.
317
- * - Invokes Drizzle Kit's migrate command to apply pending migrations.
318
419
  */
319
- migrate: alepha_command0.CommandPrimitive<alepha0.TObject<{
420
+ protected readonly migrate: alepha_command0.CommandPrimitive<alepha0.TObject<{
320
421
  provider: alepha0.TOptional<alepha0.TString>;
321
422
  mode: alepha0.TOptional<alepha0.TString>;
322
- }>, alepha0.TOptional<alepha0.TString>>;
423
+ }>, alepha0.TOptional<alepha0.TString>, alepha0.TObject<alepha0.TProperties>>;
323
424
  /**
324
425
  * Launch Drizzle Studio database browser
325
- *
326
- * - Loads the Alepha instance from the specified entry file.
327
- * - Retrieves all repository primitives to gather database models.
328
- * - Creates temporary entity definitions and Drizzle config.
329
- * - Invokes Drizzle Kit's studio command to launch the web-based database browser.
330
426
  */
331
- studio: alepha_command0.CommandPrimitive<alepha0.TObject<{
427
+ protected readonly studio: alepha_command0.CommandPrimitive<alepha0.TObject<{
332
428
  provider: alepha0.TOptional<alepha0.TString>;
333
429
  mode: alepha0.TOptional<alepha0.TString>;
334
- }>, alepha0.TOptional<alepha0.TString>>;
430
+ }>, alepha0.TOptional<alepha0.TString>, alepha0.TObject<alepha0.TProperties>>;
431
+ /**
432
+ * Parent command for database operations.
433
+ */
434
+ readonly db: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
335
435
  /**
336
436
  * Run a drizzle-kit command for all database providers in an Alepha instance.
337
- *
338
- * Iterates through all repository providers, prepares Drizzle config for each,
339
- * and executes the specified drizzle-kit command.
340
- *
341
- * @param options - Configuration including command to run, flags, and logging
342
437
  */
343
438
  runDrizzleKitCommand(options: {
344
439
  root: string;
@@ -351,16 +446,10 @@ declare class DrizzleCommands {
351
446
  }): Promise<void>;
352
447
  /**
353
448
  * Prepare Drizzle configuration files for a database provider.
354
- *
355
- * Creates temporary entities.js and drizzle.config.js files needed
356
- * for Drizzle Kit commands to run properly.
357
- *
358
- * @param options - Configuration options including kit, provider info, and paths
359
- * @returns Path to the generated drizzle.config.js file
360
449
  */
361
450
  prepareDrizzleConfig(options: {
362
451
  kit: any;
363
- provider: any;
452
+ provider: DatabaseProvider;
364
453
  providerName: string;
365
454
  providerUrl: string;
366
455
  dialect: string;
@@ -369,8 +458,125 @@ declare class DrizzleCommands {
369
458
  }): Promise<string>;
370
459
  }
371
460
  //#endregion
372
- //#region ../../src/cli/commands/VerifyCommands.d.ts
373
- declare class VerifyCommands {
461
+ //#region ../../src/cli/commands/deploy.d.ts
462
+ declare class DeployCommand {
463
+ protected readonly log: alepha_logger5.Logger;
464
+ protected readonly utils: AlephaCliUtils;
465
+ /**
466
+ * Deploy the project to a hosting platform (e.g., Vercel, Cloudflare, Surge)
467
+ *
468
+ * Deploy command can be overridden by creating a alepha.config.ts in the project root:
469
+ *
470
+ * ```ts
471
+ * import { defineConfig } from "alepha/cli";
472
+ *
473
+ * export default defineConfig({
474
+ * commands: {
475
+ * deploy: {
476
+ * handler: async ({ root, mode, flags }) => {
477
+ * // Custom deployment logic here
478
+ * },
479
+ * },
480
+ * },
481
+ * });
482
+ * ```
483
+ */
484
+ readonly deploy: alepha_command0.CommandPrimitive<alepha0.TObject<{
485
+ build: alepha0.TBoolean;
486
+ migrate: alepha0.TBoolean;
487
+ }>, alepha0.TSchema, alepha0.TObject<{
488
+ VERCEL_TOKEN: alepha0.TOptional<alepha0.TString>;
489
+ VERCEL_ORG_ID: alepha0.TOptional<alepha0.TString>;
490
+ VERCEL_PROJECT_ID: alepha0.TOptional<alepha0.TString>;
491
+ CLOUDFLARE_API_TOKEN: alepha0.TOptional<alepha0.TString>;
492
+ CLOUDFLARE_ACCOUNT_ID: alepha0.TOptional<alepha0.TString>;
493
+ }>>;
494
+ }
495
+ //#endregion
496
+ //#region ../../src/cli/commands/dev.d.ts
497
+ declare class DevCommand {
498
+ protected readonly log: alepha_logger5.Logger;
499
+ protected readonly utils: AlephaCliUtils;
500
+ /**
501
+ * Will run the project in watch mode.
502
+ *
503
+ * - If an index.html file is found in the project root, it will run Vite in dev mode.
504
+ * - Otherwise, it will look for a server entry file and run it with tsx in watch mode.
505
+ */
506
+ readonly dev: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TOptional<alepha0.TString>, alepha0.TObject<alepha0.TProperties>>;
507
+ }
508
+ //#endregion
509
+ //#region ../../src/cli/commands/format.d.ts
510
+ declare class FormatCommand {
511
+ protected readonly utils: AlephaCliUtils;
512
+ readonly format: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
513
+ }
514
+ //#endregion
515
+ //#region ../../src/cli/commands/init.d.ts
516
+ declare class InitCommand {
517
+ protected readonly utils: AlephaCliUtils;
518
+ /**
519
+ * Ensure the project has the necessary Alepha configuration files.
520
+ * Add the correct dependencies to package.json and install them.
521
+ */
522
+ readonly init: alepha_command0.CommandPrimitive<alepha0.TObject<{
523
+ yarn: alepha0.TOptional<alepha0.TBoolean>;
524
+ pnpm: alepha0.TOptional<alepha0.TBoolean>;
525
+ npm: alepha0.TOptional<alepha0.TBoolean>;
526
+ bun: alepha0.TOptional<alepha0.TBoolean>;
527
+ react: alepha0.TOptional<alepha0.TBoolean>;
528
+ ui: alepha0.TOptional<alepha0.TBoolean>;
529
+ test: alepha0.TOptional<alepha0.TBoolean>;
530
+ }>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
531
+ }
532
+ //#endregion
533
+ //#region ../../src/cli/commands/lint.d.ts
534
+ declare class LintCommand {
535
+ protected readonly utils: AlephaCliUtils;
536
+ readonly lint: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
537
+ }
538
+ //#endregion
539
+ //#region ../../src/cli/commands/root.d.ts
540
+ declare class RootCommand {
541
+ protected readonly log: alepha_logger5.Logger;
542
+ protected readonly cli: CliProvider;
543
+ /**
544
+ * Called when no command is provided
545
+ */
546
+ readonly root: alepha_command0.CommandPrimitive<alepha0.TObject<{
547
+ version: alepha0.TOptional<alepha0.TBoolean>;
548
+ }>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
549
+ }
550
+ //#endregion
551
+ //#region ../../src/cli/commands/run.d.ts
552
+ declare class RunCommand {
553
+ protected readonly utils: AlephaCliUtils;
554
+ readonly run: alepha_command0.CommandPrimitive<alepha0.TObject<{
555
+ watch: alepha0.TOptional<alepha0.TBoolean>;
556
+ }>, alepha0.TString, alepha0.TObject<alepha0.TProperties>>;
557
+ }
558
+ //#endregion
559
+ //#region ../../src/cli/commands/test.d.ts
560
+ declare class TestCommand {
561
+ protected readonly utils: AlephaCliUtils;
562
+ readonly test: alepha_command0.CommandPrimitive<alepha0.TObject<{
563
+ config: alepha0.TOptional<alepha0.TString>;
564
+ }>, alepha0.TSchema, alepha0.TObject<{
565
+ VITEST_ARGS: alepha0.TOptional<alepha0.TString>;
566
+ }>>;
567
+ }
568
+ //#endregion
569
+ //#region ../../src/cli/commands/typecheck.d.ts
570
+ declare class TypecheckCommand {
571
+ protected readonly utils: AlephaCliUtils;
572
+ /**
573
+ * Run TypeScript type checking across the codebase with no emit.
574
+ */
575
+ readonly typecheck: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
576
+ }
577
+ //#endregion
578
+ //#region ../../src/cli/commands/verify.d.ts
579
+ declare class VerifyCommand {
374
580
  protected readonly utils: AlephaCliUtils;
375
581
  /**
376
582
  * Run a series of verification commands to ensure code quality and correctness.
@@ -385,43 +591,26 @@ declare class VerifyCommands {
385
591
  * - Build the project
386
592
  * - Clean the project again
387
593
  */
388
- readonly verify: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema>;
389
- /**
390
- * Run TypeScript type checking across the codebase with no emit.
391
- */
392
- readonly typecheck: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema>;
594
+ readonly verify: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
393
595
  }
394
596
  //#endregion
395
- //#region ../../src/cli/commands/ViteCommands.d.ts
396
- declare class ViteCommands {
397
- protected readonly log: alepha_logger3.Logger;
398
- protected readonly utils: AlephaCliUtils;
399
- protected readonly env: {
400
- VITEST_ARGS: string;
401
- };
402
- readonly run: alepha_command0.CommandPrimitive<alepha0.TObject<{
403
- watch: alepha0.TOptional<alepha0.TBoolean>;
404
- }>, alepha0.TString>;
405
- /**
406
- * Will run the project in watch mode.
407
- *
408
- * - If an index.html file is found in the project root, it will run Vite in dev mode.
409
- * - Otherwise, it will look for a server entry file and run it with tsx in watch mode.
410
- */
411
- readonly dev: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TOptional<alepha0.TString>>;
412
- readonly build: alepha_command0.CommandPrimitive<alepha0.TObject<{
413
- stats: alepha0.TOptional<alepha0.TBoolean>;
414
- vercel: alepha0.TOptional<alepha0.TBoolean>;
415
- cloudflare: alepha0.TOptional<alepha0.TBoolean>;
416
- docker: alepha0.TOptional<alepha0.TBoolean>;
417
- sitemap: alepha0.TOptional<alepha0.TString>;
418
- prerender: alepha0.TOptional<alepha0.TBoolean>;
419
- }>, alepha0.TOptional<alepha0.TString>>;
420
- readonly test: alepha_command0.CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema>;
421
- }
597
+ //#region ../../src/cli/defineConfig.d.ts
598
+ type AlephaCliConfig = (alepha: Alepha) => {
599
+ commands?: Record<string, CommandPrimitive>;
600
+ services?: Array<any>;
601
+ };
602
+ declare const defineConfig: (config: AlephaCliConfig) => (alepha: Alepha) => {
603
+ [x: string]: CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
604
+ };
605
+ /**
606
+ * @alias defineConfig
607
+ */
608
+ declare const defineAlephaConfig: (config: AlephaCliConfig) => (alepha: Alepha) => {
609
+ [x: string]: CommandPrimitive<alepha0.TObject<alepha0.TProperties>, alepha0.TSchema, alepha0.TObject<alepha0.TProperties>>;
610
+ };
422
611
  //#endregion
423
612
  //#region ../../src/cli/version.d.ts
424
613
  declare const version: any;
425
614
  //#endregion
426
- export { AlephaCli, AlephaCliUtils, AlephaPackageBuilderCli, BiomeCommands, CoreCommands, DependencyModes, DrizzleCommands, VerifyCommands, ViteCommands, analyzeModules, version };
615
+ export { AlephaCli, AlephaCliConfig, AlephaCliUtils, AlephaPackageBuilderCli, BuildCommand, ChangelogCommand, type ChangelogOptions, CleanCommand, Commit, DEFAULT_IGNORE, DbCommand, DependencyModes, DeployCommand, DevCommand, FormatCommand, GitMessageParser, GitProvider, InitCommand, LintCommand, RootCommand, RunCommand, TestCommand, TypecheckCommand, VerifyCommand, analyzeModules, changelogOptions, defineAlephaConfig, defineConfig, version };
427
616
  //# sourceMappingURL=index.d.ts.map