alepha 0.19.3 → 0.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/assets/swagger-ui/swagger-ui-bundle.js +1 -1
  2. package/dist/api/audits/index.d.ts +8 -8
  3. package/dist/api/invitations/index.d.ts +790 -0
  4. package/dist/api/invitations/index.d.ts.map +1 -0
  5. package/dist/api/invitations/index.js +665 -0
  6. package/dist/api/invitations/index.js.map +1 -0
  7. package/dist/api/jobs/index.browser.js +8 -9
  8. package/dist/api/jobs/index.browser.js.map +1 -1
  9. package/dist/api/jobs/index.d.ts +99 -43
  10. package/dist/api/jobs/index.d.ts.map +1 -1
  11. package/dist/api/jobs/index.js +257 -40
  12. package/dist/api/jobs/index.js.map +1 -1
  13. package/dist/api/keys/index.d.ts +5 -5
  14. package/dist/api/notifications/index.browser.js +0 -1
  15. package/dist/api/notifications/index.browser.js.map +1 -1
  16. package/dist/api/notifications/index.d.ts +3 -3
  17. package/dist/api/notifications/index.d.ts.map +1 -1
  18. package/dist/api/notifications/index.js +0 -1
  19. package/dist/api/notifications/index.js.map +1 -1
  20. package/dist/api/parameters/index.browser.js +112 -1
  21. package/dist/api/parameters/index.browser.js.map +1 -1
  22. package/dist/api/parameters/index.d.ts +90 -3
  23. package/dist/api/parameters/index.d.ts.map +1 -1
  24. package/dist/api/parameters/index.js +79 -12
  25. package/dist/api/parameters/index.js.map +1 -1
  26. package/dist/{billing → api/payments}/index.d.ts +67 -49
  27. package/dist/api/payments/index.d.ts.map +1 -0
  28. package/dist/{billing → api/payments}/index.js +108 -74
  29. package/dist/api/payments/index.js.map +1 -0
  30. package/dist/api/subscriptions/index.d.ts +1692 -0
  31. package/dist/api/subscriptions/index.d.ts.map +1 -0
  32. package/dist/api/subscriptions/index.js +1870 -0
  33. package/dist/api/subscriptions/index.js.map +1 -0
  34. package/dist/api/users/index.d.ts +18 -2
  35. package/dist/api/users/index.d.ts.map +1 -1
  36. package/dist/api/users/index.js +167 -34
  37. package/dist/api/users/index.js.map +1 -1
  38. package/dist/api/verifications/index.d.ts +13 -13
  39. package/dist/api/workflows/index.browser.js +246 -0
  40. package/dist/api/workflows/index.browser.js.map +1 -0
  41. package/dist/api/workflows/index.d.ts +1618 -0
  42. package/dist/api/workflows/index.d.ts.map +1 -0
  43. package/dist/api/workflows/index.js +1504 -0
  44. package/dist/api/workflows/index.js.map +1 -0
  45. package/dist/cli/core/index.d.ts +44 -28
  46. package/dist/cli/core/index.d.ts.map +1 -1
  47. package/dist/cli/core/index.js +16 -61
  48. package/dist/cli/core/index.js.map +1 -1
  49. package/dist/cli/vendor/index.d.ts +31 -8
  50. package/dist/cli/vendor/index.d.ts.map +1 -1
  51. package/dist/cli/vendor/index.js +79 -24
  52. package/dist/cli/vendor/index.js.map +1 -1
  53. package/dist/core/index.browser.js +21 -2
  54. package/dist/core/index.browser.js.map +1 -1
  55. package/dist/core/index.d.ts +33 -2
  56. package/dist/core/index.d.ts.map +1 -1
  57. package/dist/core/index.js +21 -2
  58. package/dist/core/index.js.map +1 -1
  59. package/dist/core/index.native.js +21 -2
  60. package/dist/core/index.native.js.map +1 -1
  61. package/dist/core/index.workerd.js +21 -2
  62. package/dist/core/index.workerd.js.map +1 -1
  63. package/dist/email/smtp/index.js +24 -8
  64. package/dist/email/smtp/index.js.map +1 -1
  65. package/dist/orm/core/index.browser.js +0 -18
  66. package/dist/orm/core/index.browser.js.map +1 -1
  67. package/dist/orm/core/index.bun.js +0 -17
  68. package/dist/orm/core/index.bun.js.map +1 -1
  69. package/dist/orm/core/index.d.ts +1 -13
  70. package/dist/orm/core/index.d.ts.map +1 -1
  71. package/dist/orm/core/index.js +0 -17
  72. package/dist/orm/core/index.js.map +1 -1
  73. package/dist/orm/postgres/index.bun.js +3 -3
  74. package/dist/orm/postgres/index.bun.js.map +1 -1
  75. package/dist/orm/postgres/index.d.ts.map +1 -1
  76. package/dist/orm/postgres/index.js +3 -3
  77. package/dist/orm/postgres/index.js.map +1 -1
  78. package/dist/react/router/index.browser.js +25 -3
  79. package/dist/react/router/index.browser.js.map +1 -1
  80. package/dist/react/router/index.d.ts +16 -1
  81. package/dist/react/router/index.d.ts.map +1 -1
  82. package/dist/react/router/index.js +25 -3
  83. package/dist/react/router/index.js.map +1 -1
  84. package/dist/security/index.d.ts +28 -0
  85. package/dist/security/index.d.ts.map +1 -1
  86. package/dist/security/index.js +28 -0
  87. package/dist/security/index.js.map +1 -1
  88. package/package.json +37 -20
  89. package/src/api/invitations/__tests__/InvitationService.spec.ts +439 -0
  90. package/src/api/invitations/controllers/AdminInvitationController.ts +86 -0
  91. package/src/api/invitations/controllers/InvitationController.ts +84 -0
  92. package/src/api/invitations/entities/invitations.ts +33 -0
  93. package/src/api/invitations/index.ts +65 -0
  94. package/src/api/invitations/jobs/InvitationJobs.ts +37 -0
  95. package/src/api/invitations/providers/InvitationProvider.ts +45 -0
  96. package/src/api/invitations/schemas/createInvitationSchema.ts +12 -0
  97. package/src/api/invitations/schemas/invitationConfigAtom.ts +20 -0
  98. package/src/api/invitations/schemas/invitationQuerySchema.ts +15 -0
  99. package/src/api/invitations/schemas/invitationResourceSchema.ts +6 -0
  100. package/src/api/invitations/schemas/invitationWithResourceInfoSchema.ts +22 -0
  101. package/src/api/invitations/schemas/myInvitationsQuerySchema.ts +10 -0
  102. package/src/api/invitations/services/InvitationService.ts +556 -0
  103. package/src/api/jobs/__tests__/$job.spec.ts +876 -0
  104. package/src/api/jobs/controllers/AdminJobController.ts +44 -0
  105. package/src/api/jobs/entities/jobExecutionEntity.ts +0 -2
  106. package/src/api/jobs/index.ts +0 -3
  107. package/src/api/jobs/primitives/$job.ts +22 -11
  108. package/src/api/jobs/providers/JobProvider.ts +229 -19
  109. package/src/api/jobs/schemas/jobConfigAtom.ts +4 -0
  110. package/src/api/jobs/schemas/jobCronInfoSchema.ts +1 -0
  111. package/src/api/jobs/schemas/jobExecutionQuerySchema.ts +0 -1
  112. package/src/api/jobs/schemas/jobQueueDepthSchema.ts +1 -0
  113. package/src/api/jobs/schemas/jobRegistrationSchema.ts +1 -6
  114. package/src/api/jobs/services/JobService.ts +51 -12
  115. package/src/api/notifications/schemas/notificationQuerySchema.ts +0 -1
  116. package/src/api/parameters/__tests__/$parameter.spec.ts +327 -0
  117. package/src/api/parameters/controllers/AdminParameterController.ts +29 -3
  118. package/src/api/parameters/index.browser.ts +12 -0
  119. package/src/api/parameters/primitives/$parameter.ts +20 -3
  120. package/src/api/parameters/services/ParameterProvider.ts +48 -7
  121. package/src/{billing → api/payments}/__tests__/PaymentMethodService.spec.ts +32 -6
  122. package/src/api/payments/__tests__/PaymentService.spec.ts +279 -0
  123. package/src/{billing/controllers/AdminBillingController.ts → api/payments/controllers/AdminPaymentController.ts} +26 -21
  124. package/src/{billing/controllers/BillingController.ts → api/payments/controllers/PaymentController.ts} +23 -11
  125. package/src/{billing → api/payments}/entities/paymentIntents.ts +1 -0
  126. package/src/{billing/errors/BillingError.ts → api/payments/errors/PaymentError.ts} +1 -1
  127. package/src/{billing → api/payments}/index.ts +31 -25
  128. package/src/{billing/providers/MemoryBillingProvider.ts → api/payments/providers/MemoryPaymentProvider.ts} +4 -4
  129. package/src/{billing/providers/BillingProvider.ts → api/payments/providers/PaymentProvider.ts} +9 -2
  130. package/src/{billing → api/payments}/services/PaymentMethodService.ts +5 -5
  131. package/src/{billing/services/BillingService.ts → api/payments/services/PaymentService.ts} +94 -18
  132. package/src/api/subscriptions/__tests__/BillingService.spec.ts +218 -0
  133. package/src/api/subscriptions/__tests__/SubscriptionService.spec.ts +278 -0
  134. package/src/api/subscriptions/controllers/AdminSubscriptionController.ts +212 -0
  135. package/src/api/subscriptions/controllers/SubscriptionController.ts +189 -0
  136. package/src/api/subscriptions/entities/subscriptionEvents.ts +54 -0
  137. package/src/api/subscriptions/entities/subscriptions.ts +68 -0
  138. package/src/api/subscriptions/index.ts +144 -0
  139. package/src/api/subscriptions/jobs/SubscriptionJobs.ts +382 -0
  140. package/src/api/subscriptions/middleware/$requireLimit.ts +50 -0
  141. package/src/api/subscriptions/middleware/$requirePlan.ts +49 -0
  142. package/src/api/subscriptions/notifications/SubscriptionNotifications.ts +110 -0
  143. package/src/api/subscriptions/schemas/cancelSubscriptionSchema.ts +8 -0
  144. package/src/api/subscriptions/schemas/changePlanSchema.ts +9 -0
  145. package/src/api/subscriptions/schemas/createSubscriptionSchema.ts +11 -0
  146. package/src/api/subscriptions/schemas/entitlementsSchema.ts +21 -0
  147. package/src/api/subscriptions/schemas/mrrSchema.ts +13 -0
  148. package/src/api/subscriptions/schemas/planDefinitionSchema.ts +71 -0
  149. package/src/api/subscriptions/schemas/planResourceSchema.ts +25 -0
  150. package/src/api/subscriptions/schemas/subscriptionEventResourceSchema.ts +8 -0
  151. package/src/api/subscriptions/schemas/subscriptionQuerySchema.ts +19 -0
  152. package/src/api/subscriptions/schemas/subscriptionResourceSchema.ts +6 -0
  153. package/src/api/subscriptions/schemas/subscriptionSettingsSchema.ts +32 -0
  154. package/src/api/subscriptions/schemas/subscriptionStatsSchema.ts +23 -0
  155. package/src/api/subscriptions/services/BillingService.ts +437 -0
  156. package/src/api/subscriptions/services/SubscriptionConfig.ts +56 -0
  157. package/src/api/subscriptions/services/SubscriptionService.ts +867 -0
  158. package/src/api/subscriptions/services/UsageService.ts +118 -0
  159. package/src/api/users/__tests__/AdminUserController.spec.ts +80 -1
  160. package/src/api/users/__tests__/CredentialService.spec.ts +177 -0
  161. package/src/api/users/__tests__/EmailVerification.spec.ts +29 -18
  162. package/src/api/users/__tests__/PasswordReset.spec.ts +3 -0
  163. package/src/api/users/__tests__/RegistrationService.spec.ts +148 -1
  164. package/src/api/users/__tests__/SessionService.spec.ts +142 -1
  165. package/src/api/users/atoms/realmAuthSettingsAtom.ts +10 -1
  166. package/src/api/users/controllers/UserController.ts +3 -8
  167. package/src/api/users/notifications/UserNotifications.ts +23 -0
  168. package/src/api/users/schemas/loginSchema.ts +1 -1
  169. package/src/api/users/services/CredentialService.ts +51 -4
  170. package/src/api/users/services/RegistrationService.ts +38 -9
  171. package/src/api/users/services/SessionService.ts +62 -9
  172. package/src/api/users/services/UserService.ts +21 -12
  173. package/src/api/workflows/__tests__/$workflow.spec.ts +616 -0
  174. package/src/api/workflows/controllers/AdminWorkflowController.ts +191 -0
  175. package/src/api/workflows/entities/workflowExecutions.ts +74 -0
  176. package/src/api/workflows/entities/workflowStepExecutions.ts +74 -0
  177. package/src/api/workflows/entities/workflowStepLogs.ts +13 -0
  178. package/src/api/workflows/index.browser.ts +22 -0
  179. package/src/api/workflows/index.ts +124 -0
  180. package/src/api/workflows/jobs/WorkflowJobs.ts +77 -0
  181. package/src/api/workflows/primitives/$workflow.ts +202 -0
  182. package/src/api/workflows/providers/WorkflowProvider.ts +1284 -0
  183. package/src/api/workflows/schemas/workflowActivitySchema.ts +15 -0
  184. package/src/api/workflows/schemas/workflowConfigAtom.ts +51 -0
  185. package/src/api/workflows/schemas/workflowExecutionDetailSchema.ts +18 -0
  186. package/src/api/workflows/schemas/workflowExecutionQuerySchema.ts +26 -0
  187. package/src/api/workflows/schemas/workflowExecutionResourceSchema.ts +30 -0
  188. package/src/api/workflows/schemas/workflowRegistrationSchema.ts +26 -0
  189. package/src/api/workflows/schemas/workflowStatsSchema.ts +16 -0
  190. package/src/api/workflows/schemas/workflowStepExecutionResourceSchema.ts +15 -0
  191. package/src/api/workflows/services/WorkflowService.ts +382 -0
  192. package/src/cli/core/templates/webAppRouterTs.ts +5 -58
  193. package/src/cli/vendor/__tests__/VendorService.spec.ts +283 -178
  194. package/src/cli/vendor/services/VendorService.ts +126 -27
  195. package/src/core/__tests__/TypeProvider.spec.ts +4 -2
  196. package/src/core/providers/SchemaValidator.ts +1 -1
  197. package/src/core/providers/TypeProvider.ts +46 -3
  198. package/src/orm/__tests__/enums.spec.ts +22 -29
  199. package/src/orm/__tests__/orm-showcase-tests.ts +430 -0
  200. package/src/orm/__tests__/orm-showcase.spec.ts +167 -0
  201. package/src/orm/core/providers/DatabaseTypeProvider.ts +0 -29
  202. package/src/orm/postgres/services/PostgresModelBuilder.ts +3 -6
  203. package/src/react/router/__tests__/$page.browser.spec.tsx +157 -0
  204. package/src/react/router/providers/ReactBrowserProvider.ts +39 -0
  205. package/src/react/router/providers/ReactBrowserRouterProvider.ts +22 -0
  206. package/src/security/__tests__/$secure-combinations.spec.ts +945 -0
  207. package/src/security/primitives/$secure.ts +28 -0
  208. package/dist/billing/index.d.ts.map +0 -1
  209. package/dist/billing/index.js.map +0 -1
  210. package/src/billing/__tests__/BillingService.spec.ts +0 -136
  211. /package/src/{billing → api/payments}/entities/paymentMethods.ts +0 -0
  212. /package/src/{billing → api/payments}/entities/refunds.ts +0 -0
  213. /package/src/{billing → api/payments}/schemas/intentSchemas.ts +0 -0
  214. /package/src/{billing → api/payments}/schemas/paymentMethodSchemas.ts +0 -0
  215. /package/src/{billing → api/payments}/schemas/refundSchemas.ts +0 -0
@@ -82,6 +82,12 @@ interface VendorDiffResult {
82
82
  packages: VendorPackageDiff[];
83
83
  totalChanges: number;
84
84
  }
85
+ /**
86
+ * Shape of the <root>/.alepha/vendor.json lock file.
87
+ */
88
+ interface VendorLock {
89
+ commit: string;
90
+ }
85
91
  /**
86
92
  * Handles syncing and diffing vendored packages from a remote git repository.
87
93
  */
@@ -92,17 +98,18 @@ declare class VendorService {
92
98
  /**
93
99
  * Sync vendored packages from a remote repository.
94
100
  *
95
- * Shallow-clones the remote once, then:
96
- * - Without `force`: diffs first. If local modifications exist, aborts
97
- * and returns the diff result without touching local files.
98
- * - With `force` (or no changes): removes local copies and replaces them.
101
+ * Without `force`: checks for local modifications by comparing the local
102
+ * copy against the last-synced commit (stored in .alepha/vendor.json).
103
+ * If modifications are found, aborts without touching local files.
104
+ *
105
+ * With `force` (or first sync): replaces local copies unconditionally.
99
106
  */
100
107
  sync(options: VendorSyncOptions): Promise<VendorSyncResult>;
101
108
  /**
102
- * Diff vendored packages against a remote repository.
109
+ * Diff vendored packages against the last-synced commit.
103
110
  *
104
- * Shallow-clones the remote, then for each package: recursively compares
105
- * files to identify added, modified, and removed files.
111
+ * Reads the commit hash from .alepha/vendor.json, clones at that commit,
112
+ * and compares local files to detect modifications since last sync.
106
113
  */
107
114
  diff(options: VendorDiffOptions): Promise<VendorDiffResult>;
108
115
  /**
@@ -117,6 +124,22 @@ declare class VendorService {
117
124
  * Clone a remote repository into a temporary directory.
118
125
  */
119
126
  protected cloneRemote(remote: string, branch: string): Promise<string>;
127
+ /**
128
+ * Clone a remote repository at a specific commit hash.
129
+ */
130
+ protected cloneAtCommit(remote: string, commit: string): Promise<string>;
131
+ /**
132
+ * Get the HEAD commit hash from a cloned repository.
133
+ */
134
+ protected getCommitHash(repoDir: string): Promise<string>;
135
+ /**
136
+ * Read the vendor lock file.
137
+ */
138
+ protected readLock(root: string): Promise<VendorLock | undefined>;
139
+ /**
140
+ * Write the vendor lock file.
141
+ */
142
+ protected writeLock(root: string, lock: VendorLock): Promise<void>;
120
143
  /**
121
144
  * Directories to ignore during diff comparisons.
122
145
  */
@@ -197,5 +220,5 @@ declare module "alepha/cli/config" {
197
220
  */
198
221
  declare const AlephaCliVendorPlugin: _$alepha.Service<_$alepha.Module>;
199
222
  //#endregion
200
- export { AlephaCliVendorPlugin, VendorCommand, VendorDiffOptions, VendorDiffResult, VendorOptions, VendorPackageDiff, VendorService, VendorSyncOptions, VendorSyncResult, vendorOptions };
223
+ export { AlephaCliVendorPlugin, VendorCommand, VendorDiffOptions, VendorDiffResult, VendorLock, VendorOptions, VendorPackageDiff, VendorService, VendorSyncOptions, VendorSyncResult, vendorOptions };
201
224
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/cli/vendor/atoms/vendorOptions.ts","../../../src/cli/vendor/services/VendorService.ts","../../../src/cli/vendor/commands/VendorCommand.ts","../../../src/cli/vendor/index.ts"],"mappings":";;;;;;;;;;;;;;;cAQa,aAAA,EAAa,QAAA,CAAA,IAA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AA,CACF,MAAA;EAAA,mBACH,OAAA,EAAO,QAAA;;;;;qBACP,aAAA,EAAa,aAAA;EAAA,mBACb,KAAA,EAAK,oBAAA;EAAA,mBACL,EAAA,EAAE,mBAAA;;;;YAKX,cAAA,CAAA;;;;;qBAiBS,SAAA,WAAS,OAAA;8BAtBP,QAAA,CAAA,QAAA;EAAA;EAAA,mBA+BF,IAAA,oBAAI,gBAAA,UAAA,OAAA;8BATK,QAAA,CAAA,QAAA;EAAA,IASL,QAAA,CAAA,OAAA;qBAmFJ,IAAA,EAAI,iBAAA,CAAA,gBAAA,CAAA,QAAA,CAAA,OAAA,CAnFA,QAAA,CAmFA,WAAA,GAAA,QAAA,CAAA,OAAA,EAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,WAAA;EAAA,SA4DP,MAAA,EAAM,iBAAA,CAAA,gBAAA,CAAA,QAAA,CAAA,OAAA,CA5DC,QAAA,CA4DD,WAAA,GAAA,QAAA,CAAA,OAAA,EAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,WAAA;AAAA;;;;YC1LZ,eAAA;IACR,MAAA,GAAS,aAAA;EAAA;AAAA;;;;AHFb;;;;;;;;;;;;;;;;;;;;;;cGiCa,qBAAA,EAAqB,QAAA,CAAA,OAAA,CAIhC,QAAA,CAJgC,MAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/cli/vendor/atoms/vendorOptions.ts","../../../src/cli/vendor/services/VendorService.ts","../../../src/cli/vendor/commands/VendorCommand.ts","../../../src/cli/vendor/index.ts"],"mappings":";;;;;;;;;;;;;;;cAQa,aAAA,EAAa,QAAA,CAAA,IAAA,CAAA,QAAA,CAAA,SAAA,UAAA,OAAA;;AAA1B;;;;6BA2BE,QAAA,CAAA,OAAA;;;;;;;EA3BwB;;;;;;;;;;KAgCd,aAAA,GAAgB,MAAA,QAAc,aAAA,CAAc,MAAA;;;;;;UCjCvC,iBAAA;EACf,IAAA;EACA,MAAA;EACA,MAAA;EACA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AA;IAAiB,QAAA;IAAoB,OAAA;EAAA;AAAA;;;cCtXvC,aAAA;EAAA,mBACQ,GAAA,EADK,gBAAA,CACF,MAAA;EAAA,mBACH,OAAA,EAAO,QAAA;;;;;qBACP,aAAA,EAAa,aAAA;EAAA,mBACb,KAAA,EAAK,oBAAA;EAAA,mBACL,EAAA,EAAE,mBAAA;;;;YAKX,cAAA,CAAA;;;;;qBAiBS,SAAA,WAAS,OAAA;8BAtBP,QAAA,CAAA,QAAA;EAAA;EAAA,mBA+BF,IAAA,oBAAI,gBAAA,UAAA,OAAA;8BATK,QAAA,CAAA,QAAA;EAAA,IASL,QAAA,CAAA,OAAA;qBAmFJ,IAAA,EAAI,iBAAA,CAAA,gBAAA,CAAA,QAAA,CAAA,OAAA,CAnFA,QAAA,CAmFA,WAAA,GAAA,QAAA,CAAA,OAAA,EAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,WAAA;EAAA,SA4DP,MAAA,EAAM,iBAAA,CAAA,gBAAA,CAAA,QAAA,CAAA,OAAA,CA5DC,QAAA,CA4DD,WAAA,GAAA,QAAA,CAAA,OAAA,EAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,WAAA;AAAA;;;;YC1LZ,eAAA;IACR,MAAA,GAAS,aAAA;EAAA;AAAA;;;;AHFb;;;;;;;;;;;;;;;;;;;;;;cGiCa,qBAAA,EAAqB,QAAA,CAAA,OAAA,CAIhC,QAAA,CAJgC,MAAA"}
@@ -32,25 +32,38 @@ var VendorService = class {
32
32
  /**
33
33
  * Sync vendored packages from a remote repository.
34
34
  *
35
- * Shallow-clones the remote once, then:
36
- * - Without `force`: diffs first. If local modifications exist, aborts
37
- * and returns the diff result without touching local files.
38
- * - With `force` (or no changes): removes local copies and replaces them.
35
+ * Without `force`: checks for local modifications by comparing the local
36
+ * copy against the last-synced commit (stored in .alepha/vendor.json).
37
+ * If modifications are found, aborts without touching local files.
38
+ *
39
+ * With `force` (or first sync): replaces local copies unconditionally.
39
40
  */
40
41
  async sync(options) {
41
42
  const synced = [];
42
43
  const errors = [];
44
+ if (!options.force) {
45
+ const lock = await this.readLock(options.root);
46
+ if (lock) {
47
+ let baselineDir;
48
+ try {
49
+ baselineDir = await this.cloneAtCommit(options.remote, lock.commit);
50
+ const diffResult = await this.diffFromClone(options.root, baselineDir, options.packages);
51
+ if (diffResult.totalChanges > 0) return {
52
+ synced: [],
53
+ errors: [],
54
+ aborted: diffResult
55
+ };
56
+ } finally {
57
+ if (baselineDir) await this.fs.rm(baselineDir, {
58
+ recursive: true,
59
+ force: true
60
+ });
61
+ }
62
+ }
63
+ }
43
64
  let tmpDir;
44
65
  try {
45
66
  tmpDir = await this.cloneRemote(options.remote, options.branch);
46
- if (!options.force) {
47
- const diffResult = await this.diffFromClone(options.root, tmpDir, options.packages);
48
- if (diffResult.totalChanges > 0) return {
49
- synced: [],
50
- errors: [],
51
- aborted: diffResult
52
- };
53
- }
54
67
  for (const pkg of options.packages) {
55
68
  const remotePkgDir = this.fs.join(tmpDir, "packages", pkg);
56
69
  const localPkgDir = this.fs.join(options.root, "packages", pkg);
@@ -67,6 +80,8 @@ var VendorService = class {
67
80
  await this.removeIgnoredFiles(localPkgDir);
68
81
  synced.push(pkg);
69
82
  }
83
+ const commit = await this.getCommitHash(tmpDir);
84
+ await this.writeLock(options.root, { commit });
70
85
  } finally {
71
86
  if (tmpDir) await this.fs.rm(tmpDir, {
72
87
  recursive: true,
@@ -79,15 +94,20 @@ var VendorService = class {
79
94
  };
80
95
  }
81
96
  /**
82
- * Diff vendored packages against a remote repository.
97
+ * Diff vendored packages against the last-synced commit.
83
98
  *
84
- * Shallow-clones the remote, then for each package: recursively compares
85
- * files to identify added, modified, and removed files.
99
+ * Reads the commit hash from .alepha/vendor.json, clones at that commit,
100
+ * and compares local files to detect modifications since last sync.
86
101
  */
87
102
  async diff(options) {
103
+ const lock = await this.readLock(options.root);
104
+ if (!lock) return {
105
+ packages: [],
106
+ totalChanges: 0
107
+ };
88
108
  let tmpDir;
89
109
  try {
90
- tmpDir = await this.cloneRemote(options.remote, options.branch);
110
+ tmpDir = await this.cloneAtCommit(options.remote, lock.commit);
91
111
  return await this.diffFromClone(options.root, tmpDir, options.packages);
92
112
  } finally {
93
113
  if (tmpDir) await this.fs.rm(tmpDir, {
@@ -120,9 +140,9 @@ var VendorService = class {
120
140
  const localFiles = await this.fs.ls(localPkgDir, { recursive: true });
121
141
  results.push({
122
142
  name: pkg,
123
- added: [],
143
+ added: localFiles,
124
144
  modified: [],
125
- removed: localFiles
145
+ removed: []
126
146
  });
127
147
  totalChanges += localFiles.length;
128
148
  continue;
@@ -131,9 +151,9 @@ var VendorService = class {
131
151
  const remoteFiles = await this.fs.ls(remotePkgDir, { recursive: true });
132
152
  results.push({
133
153
  name: pkg,
134
- added: remoteFiles,
154
+ added: [],
135
155
  modified: [],
136
- removed: []
156
+ removed: remoteFiles
137
157
  });
138
158
  totalChanges += remoteFiles.length;
139
159
  continue;
@@ -158,7 +178,7 @@ var VendorService = class {
158
178
  */
159
179
  async removeIgnoredFiles(pkgDir) {
160
180
  const allFiles = await this.fs.ls(pkgDir, { recursive: true });
161
- for (const file of allFiles) if (file.endsWith(".spec.ts") || file.endsWith(".spec.tsx") || file === "LICENSE") await this.fs.rm(this.fs.join(pkgDir, file), { force: true });
181
+ for (const file of allFiles) if (file.endsWith(".spec.ts") || file.endsWith(".spec.tsx") || file === "LICENSE" || file === "tsdown.config.ts") await this.fs.rm(this.fs.join(pkgDir, file), { force: true });
162
182
  for (const file of allFiles) for (const ignored of this.ignoredPaths) if (file === ignored || file.startsWith(`${ignored}/`) || file.includes(`/${ignored}/`) || file.endsWith(`/${ignored}`)) {
163
183
  const idx = file.indexOf(ignored);
164
184
  const dirPath = this.fs.join(pkgDir, file.substring(0, idx + ignored.length));
@@ -179,6 +199,41 @@ var VendorService = class {
179
199
  return tmpDir;
180
200
  }
181
201
  /**
202
+ * Clone a remote repository at a specific commit hash.
203
+ */
204
+ async cloneAtCommit(remote, commit) {
205
+ const tmpDir = this.fs.join(process.env.TMPDIR || "/tmp", `.alepha-vendor-${Date.now()}`);
206
+ this.log.debug(`Cloning ${remote}@${commit} into ${tmpDir}`);
207
+ await this.shell.run(`git init ${tmpDir}`, { capture: true });
208
+ await this.shell.run(`git -C ${tmpDir} remote add origin ${remote}`, { capture: true });
209
+ await this.shell.run(`git -C ${tmpDir} fetch --depth 1 origin ${commit}`, { capture: true });
210
+ await this.shell.run(`git -C ${tmpDir} checkout FETCH_HEAD`, { capture: true });
211
+ return tmpDir;
212
+ }
213
+ /**
214
+ * Get the HEAD commit hash from a cloned repository.
215
+ */
216
+ async getCommitHash(repoDir) {
217
+ return (await this.shell.run(`git -C ${repoDir} rev-parse HEAD`, { capture: true })).trim();
218
+ }
219
+ /**
220
+ * Read the vendor lock file.
221
+ */
222
+ async readLock(root) {
223
+ const lockPath = this.fs.join(root, ".alepha", "vendor.json");
224
+ if (!await this.fs.exists(lockPath)) return;
225
+ const content = await this.fs.readFile(lockPath);
226
+ return JSON.parse(content.toString());
227
+ }
228
+ /**
229
+ * Write the vendor lock file.
230
+ */
231
+ async writeLock(root, lock) {
232
+ const dir = this.fs.join(root, ".alepha");
233
+ await this.fs.mkdir(dir, { recursive: true });
234
+ await this.fs.writeFile(this.fs.join(dir, "vendor.json"), JSON.stringify(lock, null, 2));
235
+ }
236
+ /**
182
237
  * Directories to ignore during diff comparisons.
183
238
  */
184
239
  ignoredPaths = [
@@ -191,7 +246,7 @@ var VendorService = class {
191
246
  * Check if a file path should be ignored during diff.
192
247
  */
193
248
  isIgnored(filePath) {
194
- if (filePath.endsWith(".spec.ts") || filePath.endsWith(".spec.tsx") || filePath === "LICENSE") return true;
249
+ if (filePath.endsWith(".spec.ts") || filePath.endsWith(".spec.tsx") || filePath === "LICENSE" || filePath === "tsdown.config.ts") return true;
195
250
  return this.ignoredPaths.some((p) => filePath === p || filePath.startsWith(`${p}/`) || filePath.includes(`/${p}/`) || filePath.endsWith(`/${p}`));
196
251
  }
197
252
  /**
@@ -208,7 +263,7 @@ var VendorService = class {
208
263
  const remoteSet = new Set(filteredRemote);
209
264
  for (const file of filteredRemote) {
210
265
  if (!localSet.has(file)) {
211
- added.push(file);
266
+ removed.push(file);
212
267
  continue;
213
268
  }
214
269
  try {
@@ -216,7 +271,7 @@ var VendorService = class {
216
271
  if (!localContent.equals(remoteContent)) modified.push(file);
217
272
  } catch {}
218
273
  }
219
- for (const file of filteredLocal) if (!remoteSet.has(file)) removed.push(file);
274
+ for (const file of filteredLocal) if (!remoteSet.has(file)) added.push(file);
220
275
  return {
221
276
  added,
222
277
  modified,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/cli/vendor/atoms/vendorOptions.ts","../../../src/cli/vendor/services/VendorService.ts","../../../src/cli/vendor/commands/VendorCommand.ts","../../../src/cli/vendor/index.ts"],"sourcesContent":["import { $atom, type Static, t } from \"alepha\";\n\n/**\n * Vendor configuration atom.\n *\n * Filled from the `vendor` section of `alepha.config.ts`.\n * Read by `VendorCommand` to resolve remote, branch, and packages.\n */\nexport const vendorOptions = $atom({\n name: \"alepha.cli.vendor.options\",\n description: \"Vendor synchronization configuration\",\n schema: t.optional(\n t.object({\n /**\n * Git remote URL.\n *\n * @default \"git@github.com:feunard/alepha.git\"\n */\n remote: t.optional(t.text()),\n\n /**\n * Branch to sync from.\n *\n * @default \"main\"\n */\n branch: t.optional(t.text()),\n\n /**\n * Package directory names under `packages/` to sync.\n *\n * @example [\"alepha\", \"@alepha/bucket-s3\"]\n */\n packages: t.array(t.text()),\n }),\n ),\n});\n\n/**\n * Type for vendor options.\n */\nexport type VendorOptions = Static<typeof vendorOptions.schema>;\n","import { $inject } from \"alepha\";\nimport { $logger } from \"alepha/logger\";\nimport { FileSystemProvider, ShellProvider } from \"alepha/system\";\n\n/**\n * Options for syncing vendored packages from a remote repository.\n */\nexport interface VendorSyncOptions {\n root: string;\n remote: string;\n branch: string;\n packages: string[];\n force?: boolean;\n}\n\n/**\n * Result of a vendor sync operation.\n */\nexport interface VendorSyncResult {\n synced: string[];\n errors: string[];\n aborted?: VendorDiffResult;\n}\n\n/**\n * Options for diffing vendored packages against a remote repository.\n */\nexport interface VendorDiffOptions {\n root: string;\n remote: string;\n branch: string;\n packages: string[];\n}\n\n/**\n * Diff result for a single vendored package.\n */\nexport interface VendorPackageDiff {\n name: string;\n added: string[];\n modified: string[];\n removed: string[];\n}\n\n/**\n * Result of a vendor diff operation.\n */\nexport interface VendorDiffResult {\n packages: VendorPackageDiff[];\n totalChanges: number;\n}\n\n/**\n * Handles syncing and diffing vendored packages from a remote git repository.\n */\nexport class VendorService {\n protected readonly log = $logger();\n protected readonly shell = $inject(ShellProvider);\n protected readonly fs = $inject(FileSystemProvider);\n\n /**\n * Sync vendored packages from a remote repository.\n *\n * Shallow-clones the remote once, then:\n * - Without `force`: diffs first. If local modifications exist, aborts\n * and returns the diff result without touching local files.\n * - With `force` (or no changes): removes local copies and replaces them.\n */\n async sync(options: VendorSyncOptions): Promise<VendorSyncResult> {\n const synced: string[] = [];\n const errors: string[] = [];\n let tmpDir: string | undefined;\n\n try {\n tmpDir = await this.cloneRemote(options.remote, options.branch);\n\n if (!options.force) {\n const diffResult = await this.diffFromClone(\n options.root,\n tmpDir,\n options.packages,\n );\n if (diffResult.totalChanges > 0) {\n return { synced: [], errors: [], aborted: diffResult };\n }\n }\n\n for (const pkg of options.packages) {\n const remotePkgDir = this.fs.join(tmpDir, \"packages\", pkg);\n const localPkgDir = this.fs.join(options.root, \"packages\", pkg);\n\n const remoteExists = await this.fs.exists(remotePkgDir);\n if (!remoteExists) {\n errors.push(`Package \"${pkg}\" not found in remote`);\n continue;\n }\n\n this.log.debug(`Syncing package: ${pkg}`);\n\n await this.fs.rm(localPkgDir, { recursive: true, force: true });\n await this.fs.cp(remotePkgDir, localPkgDir, { recursive: true });\n await this.removeIgnoredFiles(localPkgDir);\n\n synced.push(pkg);\n }\n } finally {\n if (tmpDir) {\n await this.fs.rm(tmpDir, { recursive: true, force: true });\n }\n }\n\n return { synced, errors };\n }\n\n /**\n * Diff vendored packages against a remote repository.\n *\n * Shallow-clones the remote, then for each package: recursively compares\n * files to identify added, modified, and removed files.\n */\n async diff(options: VendorDiffOptions): Promise<VendorDiffResult> {\n let tmpDir: string | undefined;\n\n try {\n tmpDir = await this.cloneRemote(options.remote, options.branch);\n return await this.diffFromClone(options.root, tmpDir, options.packages);\n } finally {\n if (tmpDir) {\n await this.fs.rm(tmpDir, { recursive: true, force: true });\n }\n }\n }\n\n /**\n * Diff local packages against an already-cloned remote.\n */\n protected async diffFromClone(\n root: string,\n tmpDir: string,\n packages: string[],\n ): Promise<VendorDiffResult> {\n const results: VendorPackageDiff[] = [];\n let totalChanges = 0;\n\n for (const pkg of packages) {\n const remotePkgDir = this.fs.join(tmpDir, \"packages\", pkg);\n const localPkgDir = this.fs.join(root, \"packages\", pkg);\n\n const remoteExists = await this.fs.exists(remotePkgDir);\n const localExists = await this.fs.exists(localPkgDir);\n\n if (!remoteExists && !localExists) {\n results.push({ name: pkg, added: [], modified: [], removed: [] });\n continue;\n }\n\n if (!remoteExists) {\n const localFiles = await this.fs.ls(localPkgDir, { recursive: true });\n results.push({\n name: pkg,\n added: [],\n modified: [],\n removed: localFiles,\n });\n totalChanges += localFiles.length;\n continue;\n }\n\n if (!localExists) {\n const remoteFiles = await this.fs.ls(remotePkgDir, { recursive: true });\n results.push({\n name: pkg,\n added: remoteFiles,\n modified: [],\n removed: [],\n });\n totalChanges += remoteFiles.length;\n continue;\n }\n\n const result = await this.diffDirectories(localPkgDir, remotePkgDir);\n const pkgChanges =\n result.added.length + result.modified.length + result.removed.length;\n totalChanges += pkgChanges;\n\n results.push({\n name: pkg,\n added: result.added,\n modified: result.modified,\n removed: result.removed,\n });\n }\n\n return { packages: results, totalChanges };\n }\n\n /**\n * Remove test files and ignored directories from a synced package.\n */\n protected async removeIgnoredFiles(pkgDir: string): Promise<void> {\n const allFiles = await this.fs.ls(pkgDir, { recursive: true });\n\n // Remove ignored files\n for (const file of allFiles) {\n if (\n file.endsWith(\".spec.ts\") ||\n file.endsWith(\".spec.tsx\") ||\n file === \"LICENSE\"\n ) {\n await this.fs.rm(this.fs.join(pkgDir, file), { force: true });\n }\n }\n\n // Remove ignored directories (find all occurrences at any depth)\n for (const file of allFiles) {\n for (const ignored of this.ignoredPaths) {\n if (\n file === ignored ||\n file.startsWith(`${ignored}/`) ||\n file.includes(`/${ignored}/`) ||\n file.endsWith(`/${ignored}`)\n ) {\n // Extract the path to the ignored directory itself\n const idx = file.indexOf(ignored);\n const dirPath = this.fs.join(\n pkgDir,\n file.substring(0, idx + ignored.length),\n );\n await this.fs.rm(dirPath, { recursive: true, force: true });\n }\n }\n }\n }\n\n /**\n * Clone a remote repository into a temporary directory.\n */\n protected async cloneRemote(remote: string, branch: string): Promise<string> {\n const tmpDir = this.fs.join(\n process.env.TMPDIR || \"/tmp\",\n `.alepha-vendor-${Date.now()}`,\n );\n\n this.log.debug(`Cloning ${remote}#${branch} into ${tmpDir}`);\n\n const output = await this.shell.run(\n `git clone --depth 1 --branch ${branch} --filter=blob:none ${remote} ${tmpDir}`,\n { capture: true },\n );\n\n if (output) {\n this.log.debug(output);\n }\n\n return tmpDir;\n }\n\n /**\n * Directories to ignore during diff comparisons.\n */\n protected readonly ignoredPaths = [\n \"__tests__\",\n \"assets/swagger-ui\",\n \"node_modules\",\n \"dist\",\n ];\n\n /**\n * Check if a file path should be ignored during diff.\n */\n protected isIgnored(filePath: string): boolean {\n if (\n filePath.endsWith(\".spec.ts\") ||\n filePath.endsWith(\".spec.tsx\") ||\n filePath === \"LICENSE\"\n ) {\n return true;\n }\n return this.ignoredPaths.some(\n (p) =>\n filePath === p ||\n filePath.startsWith(`${p}/`) ||\n filePath.includes(`/${p}/`) ||\n filePath.endsWith(`/${p}`),\n );\n }\n\n /**\n * Recursively compare two directories and return the differences.\n */\n protected async diffDirectories(\n localDir: string,\n remoteDir: string,\n ): Promise<{ added: string[]; modified: string[]; removed: string[] }> {\n const added: string[] = [];\n const modified: string[] = [];\n const removed: string[] = [];\n\n const [localFiles, remoteFiles] = await Promise.all([\n this.fs.ls(localDir, { recursive: true }),\n this.fs.ls(remoteDir, { recursive: true }),\n ]);\n\n const filteredLocal = localFiles.filter((f) => !this.isIgnored(f));\n const filteredRemote = remoteFiles.filter((f) => !this.isIgnored(f));\n\n const localSet = new Set(filteredLocal);\n const remoteSet = new Set(filteredRemote);\n\n for (const file of filteredRemote) {\n if (!localSet.has(file)) {\n added.push(file);\n continue;\n }\n\n try {\n const [localContent, remoteContent] = await Promise.all([\n this.fs.readFile(this.fs.join(localDir, file)),\n this.fs.readFile(this.fs.join(remoteDir, file)),\n ]);\n\n if (!localContent.equals(remoteContent)) {\n modified.push(file);\n }\n } catch {\n // Skip directories and unreadable entries\n }\n }\n\n for (const file of filteredLocal) {\n if (!remoteSet.has(file)) {\n removed.push(file);\n }\n }\n\n return { added, modified, removed };\n }\n}\n","import { $inject, $state, AlephaError, t } from \"alepha\";\nimport { PackageManagerUtils } from \"alepha/cli\";\nimport { $command } from \"alepha/command\";\nimport { $logger, ConsoleColorProvider } from \"alepha/logger\";\nimport { vendorOptions } from \"../atoms/vendorOptions.ts\";\nimport type {\n VendorDiffResult,\n VendorSyncResult,\n} from \"../services/VendorService.ts\";\nimport { VendorService } from \"../services/VendorService.ts\";\n\n/**\n * Default remote when none is configured.\n */\nconst DEFAULT_REMOTE = \"git@github.com:feunard/alepha.git\";\n\nexport class VendorCommand {\n protected readonly log = $logger();\n protected readonly options = $state(vendorOptions);\n protected readonly vendorService = $inject(VendorService);\n protected readonly color = $inject(ConsoleColorProvider);\n protected readonly pm = $inject(PackageManagerUtils);\n\n /**\n * Ensure vendor config is present and return resolved options.\n */\n protected resolveOptions() {\n if (!this.options) {\n throw new AlephaError(\n 'Missing vendor configuration. Add a \"vendor\" section to alepha.config.ts.',\n );\n }\n return {\n remote: this.options.remote ?? DEFAULT_REMOTE,\n branch: this.options.branch ?? \"main\",\n packages: this.options.packages,\n };\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // alepha vendor sync\n // ─────────────────────────────────────────────────────────────────────────\n\n protected readonly syncFlags = t.object({\n force: t.optional(\n t.boolean({\n aliases: [\"f\"],\n description: \"Skip local modification check\",\n }),\n ),\n });\n\n protected readonly sync = $command({\n name: \"sync\",\n description: \"Replace local packages with remote source\",\n flags: this.syncFlags,\n handler: async ({ flags, root, run }) => {\n const opts = this.resolveOptions();\n const c = this.color;\n\n let result: VendorSyncResult = { synced: [], errors: [] };\n\n await run({\n name: `Syncing from ${opts.branch}`,\n handler: async () => {\n result = await this.vendorService.sync({\n root,\n remote: opts.remote,\n branch: opts.branch,\n packages: opts.packages,\n force: flags.force,\n });\n },\n });\n\n if (result.aborted) {\n run.end();\n\n process.stdout.write(\n `\\nLocal modifications detected. Use ${c.set(\"CYAN\", \"--force\")} to overwrite.\\n`,\n );\n\n for (const pkg of result.aborted.packages) {\n const count =\n pkg.added.length + pkg.modified.length + pkg.removed.length;\n if (count === 0) continue;\n\n process.stdout.write(\n `\\n${c.set(\"CYAN\", pkg.name)}: ${count} ${count === 1 ? \"file differs\" : \"files differ\"}\\n`,\n );\n for (const file of pkg.added) {\n process.stdout.write(` ${c.set(\"GREEN\", \"A\")} ${file}\\n`);\n }\n for (const file of pkg.modified) {\n process.stdout.write(` ${c.set(\"ORANGE\", \"M\")} ${file}\\n`);\n }\n for (const file of pkg.removed) {\n process.stdout.write(` ${c.set(\"RED\", \"D\")} ${file}\\n`);\n }\n }\n\n process.stdout.write(\"\\n\");\n return;\n }\n\n if (result.synced.length > 0) {\n const pmName = await this.pm.getPackageManager(root);\n await run(`${pmName} install`, { root });\n }\n\n run.end();\n\n if (result.errors.length > 0) {\n for (const error of result.errors) {\n process.stdout.write(`${c.set(\"RED\", \" error\")} ${error}\\n`);\n }\n }\n\n if (result.synced.length > 0) {\n process.stdout.write(\n `\\nSynced ${c.set(\"CYAN\", String(result.synced.length))} ${result.synced.length === 1 ? \"package\" : \"packages\"} from ${c.set(\"CYAN\", opts.branch)}\\n`,\n );\n for (const pkg of result.synced) {\n process.stdout.write(` ${c.set(\"GREEN\", \"\\u2713\")} ${pkg}\\n`);\n }\n }\n\n process.stdout.write(\"\\n\");\n },\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // alepha vendor diff\n // ─────────────────────────────────────────────────────────────────────────\n\n protected readonly diff = $command({\n name: \"diff\",\n description: \"Compare local packages against remote\",\n handler: async ({ root, run }) => {\n const opts = this.resolveOptions();\n\n let result: VendorDiffResult = { packages: [], totalChanges: 0 };\n\n await run({\n name: `Cloning ${opts.remote} at ${opts.branch}`,\n handler: async () => {\n result = await this.vendorService.diff({\n root,\n remote: opts.remote,\n branch: opts.branch,\n packages: opts.packages,\n });\n },\n });\n\n run.end();\n\n if (result.totalChanges === 0) {\n process.stdout.write(\"\\nNo changes\\n\\n\");\n return;\n }\n\n const c = this.color;\n\n for (const pkg of result.packages) {\n const count =\n pkg.added.length + pkg.modified.length + pkg.removed.length;\n if (count === 0) {\n process.stdout.write(`\\n${c.set(\"CYAN\", pkg.name)}: no changes\\n`);\n continue;\n }\n\n process.stdout.write(\n `\\n${c.set(\"CYAN\", pkg.name)}: ${count} ${count === 1 ? \"file differs\" : \"files differ\"}\\n`,\n );\n\n for (const file of pkg.added) {\n process.stdout.write(` ${c.set(\"GREEN\", \"A\")} ${file}\\n`);\n }\n for (const file of pkg.modified) {\n process.stdout.write(` ${c.set(\"ORANGE\", \"M\")} ${file}\\n`);\n }\n for (const file of pkg.removed) {\n process.stdout.write(` ${c.set(\"RED\", \"D\")} ${file}\\n`);\n }\n }\n\n process.stdout.write(\"\\n\");\n },\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // Parent command\n // ─────────────────────────────────────────────────────────────────────────\n\n public readonly vendor = $command({\n name: \"vendor\",\n description: \"Vendor Alepha packages into the project\",\n children: [this.sync, this.diff],\n handler: async ({ help }) => {\n help();\n },\n });\n}\n","import { $module } from \"alepha\";\nimport { cliConfigPlugins } from \"alepha/cli/config\";\nimport { type VendorOptions, vendorOptions } from \"./atoms/vendorOptions.ts\";\nimport { VendorCommand } from \"./commands/VendorCommand.ts\";\nimport { VendorService } from \"./services/VendorService.ts\";\n\n// ---------------------------------------------------------------------------\n\ndeclare module \"alepha/cli/config\" {\n interface AlephaCliConfig {\n vendor?: VendorOptions;\n }\n}\n\n// ---------------------------------------------------------------------------\n\n/**\n * CLI plugin for vendoring Alepha packages into external projects.\n *\n * Copies package source code from a git remote into the current project's\n * `packages/` directory. Useful for corporate projects that need a local\n * copy of Alepha for AI tooling, audits, documentation, or quick fixes.\n *\n * Commands:\n * - `alepha vendor sync` — replace local packages with remote source\n * - `alepha vendor diff` — compare local packages against remote HEAD\n *\n * Configuration in `alepha.config.ts`:\n *\n * ```typescript\n * import { AlephaCliVendorPlugin } from \"alepha/cli/vendor\";\n *\n * export default defineConfig({\n * services: [AlephaCliVendorPlugin],\n * vendor: {\n * branch: \"main\",\n * packages: [\"alepha\", \"@alepha/bucket-s3\"],\n * },\n * });\n * ```\n */\nexport const AlephaCliVendorPlugin = $module({\n name: \"alepha.cli.plugins.vendor\",\n atoms: [vendorOptions],\n services: [VendorCommand, VendorService],\n});\n\n// ---------------------------------------------------------------------------\n\ncliConfigPlugins.push((config, alepha) => {\n if (config.vendor) {\n alepha.set(vendorOptions, config.vendor);\n }\n});\n\n// ---------------------------------------------------------------------------\n\nexport * from \"./atoms/vendorOptions.ts\";\nexport * from \"./commands/VendorCommand.ts\";\nexport * from \"./services/VendorService.ts\";\n"],"mappings":";;;;;;;;;;;;;AAQA,MAAa,gBAAgB,MAAM;CACjC,MAAM;CACN,aAAa;CACb,QAAQ,EAAE,SACR,EAAE,OAAO;EAMP,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;EAO5B,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;EAO5B,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC;EAC5B,CAAC,CACH;CACF,CAAC;;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M,QAAQ,WAAW;AACxC,KAAI,OAAO,OACT,QAAO,IAAI,eAAe,OAAO,OAAO;EAE1C"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/cli/vendor/atoms/vendorOptions.ts","../../../src/cli/vendor/services/VendorService.ts","../../../src/cli/vendor/commands/VendorCommand.ts","../../../src/cli/vendor/index.ts"],"sourcesContent":["import { $atom, type Static, t } from \"alepha\";\n\n/**\n * Vendor configuration atom.\n *\n * Filled from the `vendor` section of `alepha.config.ts`.\n * Read by `VendorCommand` to resolve remote, branch, and packages.\n */\nexport const vendorOptions = $atom({\n name: \"alepha.cli.vendor.options\",\n description: \"Vendor synchronization configuration\",\n schema: t.optional(\n t.object({\n /**\n * Git remote URL.\n *\n * @default \"git@github.com:feunard/alepha.git\"\n */\n remote: t.optional(t.text()),\n\n /**\n * Branch to sync from.\n *\n * @default \"main\"\n */\n branch: t.optional(t.text()),\n\n /**\n * Package directory names under `packages/` to sync.\n *\n * @example [\"alepha\", \"@alepha/bucket-s3\"]\n */\n packages: t.array(t.text()),\n }),\n ),\n});\n\n/**\n * Type for vendor options.\n */\nexport type VendorOptions = Static<typeof vendorOptions.schema>;\n","import { $inject } from \"alepha\";\nimport { $logger } from \"alepha/logger\";\nimport { FileSystemProvider, ShellProvider } from \"alepha/system\";\n\n/**\n * Options for syncing vendored packages from a remote repository.\n */\nexport interface VendorSyncOptions {\n root: string;\n remote: string;\n branch: string;\n packages: string[];\n force?: boolean;\n}\n\n/**\n * Result of a vendor sync operation.\n */\nexport interface VendorSyncResult {\n synced: string[];\n errors: string[];\n aborted?: VendorDiffResult;\n}\n\n/**\n * Options for diffing vendored packages against a remote repository.\n */\nexport interface VendorDiffOptions {\n root: string;\n remote: string;\n branch: string;\n packages: string[];\n}\n\n/**\n * Diff result for a single vendored package.\n */\nexport interface VendorPackageDiff {\n name: string;\n added: string[];\n modified: string[];\n removed: string[];\n}\n\n/**\n * Result of a vendor diff operation.\n */\nexport interface VendorDiffResult {\n packages: VendorPackageDiff[];\n totalChanges: number;\n}\n\n/**\n * Shape of the <root>/.alepha/vendor.json lock file.\n */\nexport interface VendorLock {\n commit: string;\n}\n\n/**\n * Handles syncing and diffing vendored packages from a remote git repository.\n */\nexport class VendorService {\n protected readonly log = $logger();\n protected readonly shell = $inject(ShellProvider);\n protected readonly fs = $inject(FileSystemProvider);\n\n /**\n * Sync vendored packages from a remote repository.\n *\n * Without `force`: checks for local modifications by comparing the local\n * copy against the last-synced commit (stored in .alepha/vendor.json).\n * If modifications are found, aborts without touching local files.\n *\n * With `force` (or first sync): replaces local copies unconditionally.\n */\n async sync(options: VendorSyncOptions): Promise<VendorSyncResult> {\n const synced: string[] = [];\n const errors: string[] = [];\n\n if (!options.force) {\n const lock = await this.readLock(options.root);\n\n if (lock) {\n let baselineDir: string | undefined;\n try {\n baselineDir = await this.cloneAtCommit(options.remote, lock.commit);\n const diffResult = await this.diffFromClone(\n options.root,\n baselineDir,\n options.packages,\n );\n\n if (diffResult.totalChanges > 0) {\n return { synced: [], errors: [], aborted: diffResult };\n }\n } finally {\n if (baselineDir) {\n await this.fs.rm(baselineDir, { recursive: true, force: true });\n }\n }\n }\n }\n\n let tmpDir: string | undefined;\n\n try {\n tmpDir = await this.cloneRemote(options.remote, options.branch);\n\n for (const pkg of options.packages) {\n const remotePkgDir = this.fs.join(tmpDir, \"packages\", pkg);\n const localPkgDir = this.fs.join(options.root, \"packages\", pkg);\n\n const remoteExists = await this.fs.exists(remotePkgDir);\n if (!remoteExists) {\n errors.push(`Package \"${pkg}\" not found in remote`);\n continue;\n }\n\n this.log.debug(`Syncing package: ${pkg}`);\n\n await this.fs.rm(localPkgDir, { recursive: true, force: true });\n await this.fs.cp(remotePkgDir, localPkgDir, { recursive: true });\n await this.removeIgnoredFiles(localPkgDir);\n\n synced.push(pkg);\n }\n\n const commit = await this.getCommitHash(tmpDir);\n await this.writeLock(options.root, { commit });\n } finally {\n if (tmpDir) {\n await this.fs.rm(tmpDir, { recursive: true, force: true });\n }\n }\n\n return { synced, errors };\n }\n\n /**\n * Diff vendored packages against the last-synced commit.\n *\n * Reads the commit hash from .alepha/vendor.json, clones at that commit,\n * and compares local files to detect modifications since last sync.\n */\n async diff(options: VendorDiffOptions): Promise<VendorDiffResult> {\n const lock = await this.readLock(options.root);\n if (!lock) {\n return { packages: [], totalChanges: 0 };\n }\n\n let tmpDir: string | undefined;\n\n try {\n tmpDir = await this.cloneAtCommit(options.remote, lock.commit);\n return await this.diffFromClone(options.root, tmpDir, options.packages);\n } finally {\n if (tmpDir) {\n await this.fs.rm(tmpDir, { recursive: true, force: true });\n }\n }\n }\n\n /**\n * Diff local packages against an already-cloned remote.\n */\n protected async diffFromClone(\n root: string,\n tmpDir: string,\n packages: string[],\n ): Promise<VendorDiffResult> {\n const results: VendorPackageDiff[] = [];\n let totalChanges = 0;\n\n for (const pkg of packages) {\n const remotePkgDir = this.fs.join(tmpDir, \"packages\", pkg);\n const localPkgDir = this.fs.join(root, \"packages\", pkg);\n\n const remoteExists = await this.fs.exists(remotePkgDir);\n const localExists = await this.fs.exists(localPkgDir);\n\n if (!remoteExists && !localExists) {\n results.push({ name: pkg, added: [], modified: [], removed: [] });\n continue;\n }\n\n if (!remoteExists) {\n // No baseline = everything local was added by user\n const localFiles = await this.fs.ls(localPkgDir, { recursive: true });\n results.push({\n name: pkg,\n added: localFiles,\n modified: [],\n removed: [],\n });\n totalChanges += localFiles.length;\n continue;\n }\n\n if (!localExists) {\n // Baseline exists but local doesn't = user deleted everything\n const remoteFiles = await this.fs.ls(remotePkgDir, { recursive: true });\n results.push({\n name: pkg,\n added: [],\n modified: [],\n removed: remoteFiles,\n });\n totalChanges += remoteFiles.length;\n continue;\n }\n\n const result = await this.diffDirectories(localPkgDir, remotePkgDir);\n const pkgChanges =\n result.added.length + result.modified.length + result.removed.length;\n totalChanges += pkgChanges;\n\n results.push({\n name: pkg,\n added: result.added,\n modified: result.modified,\n removed: result.removed,\n });\n }\n\n return { packages: results, totalChanges };\n }\n\n /**\n * Remove test files and ignored directories from a synced package.\n */\n protected async removeIgnoredFiles(pkgDir: string): Promise<void> {\n const allFiles = await this.fs.ls(pkgDir, { recursive: true });\n\n // Remove ignored files\n for (const file of allFiles) {\n if (\n file.endsWith(\".spec.ts\") ||\n file.endsWith(\".spec.tsx\") ||\n file === \"LICENSE\" ||\n file === \"tsdown.config.ts\"\n ) {\n await this.fs.rm(this.fs.join(pkgDir, file), { force: true });\n }\n }\n\n // Remove ignored directories (find all occurrences at any depth)\n for (const file of allFiles) {\n for (const ignored of this.ignoredPaths) {\n if (\n file === ignored ||\n file.startsWith(`${ignored}/`) ||\n file.includes(`/${ignored}/`) ||\n file.endsWith(`/${ignored}`)\n ) {\n // Extract the path to the ignored directory itself\n const idx = file.indexOf(ignored);\n const dirPath = this.fs.join(\n pkgDir,\n file.substring(0, idx + ignored.length),\n );\n await this.fs.rm(dirPath, { recursive: true, force: true });\n }\n }\n }\n }\n\n /**\n * Clone a remote repository into a temporary directory.\n */\n protected async cloneRemote(remote: string, branch: string): Promise<string> {\n const tmpDir = this.fs.join(\n process.env.TMPDIR || \"/tmp\",\n `.alepha-vendor-${Date.now()}`,\n );\n\n this.log.debug(`Cloning ${remote}#${branch} into ${tmpDir}`);\n\n const output = await this.shell.run(\n `git clone --depth 1 --branch ${branch} --filter=blob:none ${remote} ${tmpDir}`,\n { capture: true },\n );\n\n if (output) {\n this.log.debug(output);\n }\n\n return tmpDir;\n }\n\n /**\n * Clone a remote repository at a specific commit hash.\n */\n protected async cloneAtCommit(\n remote: string,\n commit: string,\n ): Promise<string> {\n const tmpDir = this.fs.join(\n process.env.TMPDIR || \"/tmp\",\n `.alepha-vendor-${Date.now()}`,\n );\n\n this.log.debug(`Cloning ${remote}@${commit} into ${tmpDir}`);\n\n await this.shell.run(`git init ${tmpDir}`, { capture: true });\n await this.shell.run(`git -C ${tmpDir} remote add origin ${remote}`, {\n capture: true,\n });\n await this.shell.run(`git -C ${tmpDir} fetch --depth 1 origin ${commit}`, {\n capture: true,\n });\n await this.shell.run(`git -C ${tmpDir} checkout FETCH_HEAD`, {\n capture: true,\n });\n\n return tmpDir;\n }\n\n /**\n * Get the HEAD commit hash from a cloned repository.\n */\n protected async getCommitHash(repoDir: string): Promise<string> {\n const hash = await this.shell.run(`git -C ${repoDir} rev-parse HEAD`, {\n capture: true,\n });\n return hash.trim();\n }\n\n /**\n * Read the vendor lock file.\n */\n protected async readLock(root: string): Promise<VendorLock | undefined> {\n const lockPath = this.fs.join(root, \".alepha\", \"vendor.json\");\n const exists = await this.fs.exists(lockPath);\n if (!exists) {\n return undefined;\n }\n const content = await this.fs.readFile(lockPath);\n return JSON.parse(content.toString());\n }\n\n /**\n * Write the vendor lock file.\n */\n protected async writeLock(root: string, lock: VendorLock): Promise<void> {\n const dir = this.fs.join(root, \".alepha\");\n await this.fs.mkdir(dir, { recursive: true });\n await this.fs.writeFile(\n this.fs.join(dir, \"vendor.json\"),\n JSON.stringify(lock, null, 2),\n );\n }\n\n /**\n * Directories to ignore during diff comparisons.\n */\n protected readonly ignoredPaths = [\n \"__tests__\",\n \"assets/swagger-ui\",\n \"node_modules\",\n \"dist\",\n ];\n\n /**\n * Check if a file path should be ignored during diff.\n */\n protected isIgnored(filePath: string): boolean {\n if (\n filePath.endsWith(\".spec.ts\") ||\n filePath.endsWith(\".spec.tsx\") ||\n filePath === \"LICENSE\" ||\n filePath === \"tsdown.config.ts\"\n ) {\n return true;\n }\n return this.ignoredPaths.some(\n (p) =>\n filePath === p ||\n filePath.startsWith(`${p}/`) ||\n filePath.includes(`/${p}/`) ||\n filePath.endsWith(`/${p}`),\n );\n }\n\n /**\n * Recursively compare two directories and return the differences.\n */\n protected async diffDirectories(\n localDir: string,\n remoteDir: string,\n ): Promise<{ added: string[]; modified: string[]; removed: string[] }> {\n const added: string[] = [];\n const modified: string[] = [];\n const removed: string[] = [];\n\n const [localFiles, remoteFiles] = await Promise.all([\n this.fs.ls(localDir, { recursive: true }),\n this.fs.ls(remoteDir, { recursive: true }),\n ]);\n\n const filteredLocal = localFiles.filter((f) => !this.isIgnored(f));\n const filteredRemote = remoteFiles.filter((f) => !this.isIgnored(f));\n\n const localSet = new Set(filteredLocal);\n const remoteSet = new Set(filteredRemote);\n\n // Files in baseline but not local = user deleted them\n for (const file of filteredRemote) {\n if (!localSet.has(file)) {\n removed.push(file);\n continue;\n }\n\n try {\n const [localContent, remoteContent] = await Promise.all([\n this.fs.readFile(this.fs.join(localDir, file)),\n this.fs.readFile(this.fs.join(remoteDir, file)),\n ]);\n\n if (!localContent.equals(remoteContent)) {\n modified.push(file);\n }\n } catch {\n // Skip directories and unreadable entries\n }\n }\n\n // Files in local but not baseline = user added them\n for (const file of filteredLocal) {\n if (!remoteSet.has(file)) {\n added.push(file);\n }\n }\n\n return { added, modified, removed };\n }\n}\n","import { $inject, $state, AlephaError, t } from \"alepha\";\nimport { PackageManagerUtils } from \"alepha/cli\";\nimport { $command } from \"alepha/command\";\nimport { $logger, ConsoleColorProvider } from \"alepha/logger\";\nimport { vendorOptions } from \"../atoms/vendorOptions.ts\";\nimport type {\n VendorDiffResult,\n VendorSyncResult,\n} from \"../services/VendorService.ts\";\nimport { VendorService } from \"../services/VendorService.ts\";\n\n/**\n * Default remote when none is configured.\n */\nconst DEFAULT_REMOTE = \"git@github.com:feunard/alepha.git\";\n\nexport class VendorCommand {\n protected readonly log = $logger();\n protected readonly options = $state(vendorOptions);\n protected readonly vendorService = $inject(VendorService);\n protected readonly color = $inject(ConsoleColorProvider);\n protected readonly pm = $inject(PackageManagerUtils);\n\n /**\n * Ensure vendor config is present and return resolved options.\n */\n protected resolveOptions() {\n if (!this.options) {\n throw new AlephaError(\n 'Missing vendor configuration. Add a \"vendor\" section to alepha.config.ts.',\n );\n }\n return {\n remote: this.options.remote ?? DEFAULT_REMOTE,\n branch: this.options.branch ?? \"main\",\n packages: this.options.packages,\n };\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // alepha vendor sync\n // ─────────────────────────────────────────────────────────────────────────\n\n protected readonly syncFlags = t.object({\n force: t.optional(\n t.boolean({\n aliases: [\"f\"],\n description: \"Skip local modification check\",\n }),\n ),\n });\n\n protected readonly sync = $command({\n name: \"sync\",\n description: \"Replace local packages with remote source\",\n flags: this.syncFlags,\n handler: async ({ flags, root, run }) => {\n const opts = this.resolveOptions();\n const c = this.color;\n\n let result: VendorSyncResult = { synced: [], errors: [] };\n\n await run({\n name: `Syncing from ${opts.branch}`,\n handler: async () => {\n result = await this.vendorService.sync({\n root,\n remote: opts.remote,\n branch: opts.branch,\n packages: opts.packages,\n force: flags.force,\n });\n },\n });\n\n if (result.aborted) {\n run.end();\n\n process.stdout.write(\n `\\nLocal modifications detected. Use ${c.set(\"CYAN\", \"--force\")} to overwrite.\\n`,\n );\n\n for (const pkg of result.aborted.packages) {\n const count =\n pkg.added.length + pkg.modified.length + pkg.removed.length;\n if (count === 0) continue;\n\n process.stdout.write(\n `\\n${c.set(\"CYAN\", pkg.name)}: ${count} ${count === 1 ? \"file differs\" : \"files differ\"}\\n`,\n );\n for (const file of pkg.added) {\n process.stdout.write(` ${c.set(\"GREEN\", \"A\")} ${file}\\n`);\n }\n for (const file of pkg.modified) {\n process.stdout.write(` ${c.set(\"ORANGE\", \"M\")} ${file}\\n`);\n }\n for (const file of pkg.removed) {\n process.stdout.write(` ${c.set(\"RED\", \"D\")} ${file}\\n`);\n }\n }\n\n process.stdout.write(\"\\n\");\n return;\n }\n\n if (result.synced.length > 0) {\n const pmName = await this.pm.getPackageManager(root);\n await run(`${pmName} install`, { root });\n }\n\n run.end();\n\n if (result.errors.length > 0) {\n for (const error of result.errors) {\n process.stdout.write(`${c.set(\"RED\", \" error\")} ${error}\\n`);\n }\n }\n\n if (result.synced.length > 0) {\n process.stdout.write(\n `\\nSynced ${c.set(\"CYAN\", String(result.synced.length))} ${result.synced.length === 1 ? \"package\" : \"packages\"} from ${c.set(\"CYAN\", opts.branch)}\\n`,\n );\n for (const pkg of result.synced) {\n process.stdout.write(` ${c.set(\"GREEN\", \"\\u2713\")} ${pkg}\\n`);\n }\n }\n\n process.stdout.write(\"\\n\");\n },\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // alepha vendor diff\n // ─────────────────────────────────────────────────────────────────────────\n\n protected readonly diff = $command({\n name: \"diff\",\n description: \"Compare local packages against remote\",\n handler: async ({ root, run }) => {\n const opts = this.resolveOptions();\n\n let result: VendorDiffResult = { packages: [], totalChanges: 0 };\n\n await run({\n name: `Cloning ${opts.remote} at ${opts.branch}`,\n handler: async () => {\n result = await this.vendorService.diff({\n root,\n remote: opts.remote,\n branch: opts.branch,\n packages: opts.packages,\n });\n },\n });\n\n run.end();\n\n if (result.totalChanges === 0) {\n process.stdout.write(\"\\nNo changes\\n\\n\");\n return;\n }\n\n const c = this.color;\n\n for (const pkg of result.packages) {\n const count =\n pkg.added.length + pkg.modified.length + pkg.removed.length;\n if (count === 0) {\n process.stdout.write(`\\n${c.set(\"CYAN\", pkg.name)}: no changes\\n`);\n continue;\n }\n\n process.stdout.write(\n `\\n${c.set(\"CYAN\", pkg.name)}: ${count} ${count === 1 ? \"file differs\" : \"files differ\"}\\n`,\n );\n\n for (const file of pkg.added) {\n process.stdout.write(` ${c.set(\"GREEN\", \"A\")} ${file}\\n`);\n }\n for (const file of pkg.modified) {\n process.stdout.write(` ${c.set(\"ORANGE\", \"M\")} ${file}\\n`);\n }\n for (const file of pkg.removed) {\n process.stdout.write(` ${c.set(\"RED\", \"D\")} ${file}\\n`);\n }\n }\n\n process.stdout.write(\"\\n\");\n },\n });\n\n // ─────────────────────────────────────────────────────────────────────────\n // Parent command\n // ─────────────────────────────────────────────────────────────────────────\n\n public readonly vendor = $command({\n name: \"vendor\",\n description: \"Vendor Alepha packages into the project\",\n children: [this.sync, this.diff],\n handler: async ({ help }) => {\n help();\n },\n });\n}\n","import { $module } from \"alepha\";\nimport { cliConfigPlugins } from \"alepha/cli/config\";\nimport { type VendorOptions, vendorOptions } from \"./atoms/vendorOptions.ts\";\nimport { VendorCommand } from \"./commands/VendorCommand.ts\";\nimport { VendorService } from \"./services/VendorService.ts\";\n\n// ---------------------------------------------------------------------------\n\ndeclare module \"alepha/cli/config\" {\n interface AlephaCliConfig {\n vendor?: VendorOptions;\n }\n}\n\n// ---------------------------------------------------------------------------\n\n/**\n * CLI plugin for vendoring Alepha packages into external projects.\n *\n * Copies package source code from a git remote into the current project's\n * `packages/` directory. Useful for corporate projects that need a local\n * copy of Alepha for AI tooling, audits, documentation, or quick fixes.\n *\n * Commands:\n * - `alepha vendor sync` — replace local packages with remote source\n * - `alepha vendor diff` — compare local packages against remote HEAD\n *\n * Configuration in `alepha.config.ts`:\n *\n * ```typescript\n * import { AlephaCliVendorPlugin } from \"alepha/cli/vendor\";\n *\n * export default defineConfig({\n * services: [AlephaCliVendorPlugin],\n * vendor: {\n * branch: \"main\",\n * packages: [\"alepha\", \"@alepha/bucket-s3\"],\n * },\n * });\n * ```\n */\nexport const AlephaCliVendorPlugin = $module({\n name: \"alepha.cli.plugins.vendor\",\n atoms: [vendorOptions],\n services: [VendorCommand, VendorService],\n});\n\n// ---------------------------------------------------------------------------\n\ncliConfigPlugins.push((config, alepha) => {\n if (config.vendor) {\n alepha.set(vendorOptions, config.vendor);\n }\n});\n\n// ---------------------------------------------------------------------------\n\nexport * from \"./atoms/vendorOptions.ts\";\nexport * from \"./commands/VendorCommand.ts\";\nexport * from \"./services/VendorService.ts\";\n"],"mappings":";;;;;;;;;;;;;AAQA,MAAa,gBAAgB,MAAM;CACjC,MAAM;CACN,aAAa;CACb,QAAQ,EAAE,SACR,EAAE,OAAO;EAMP,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;EAO5B,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;EAO5B,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC;EAC5B,CAAC,CACH;CACF,CAAC;;;;;;AC2BF,IAAa,gBAAb,MAA2B;CACzB,MAAyB,SAAS;CAClC,QAA2B,QAAQ,cAAc;CACjD,KAAwB,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,aAAa;EACb,UAAU,CAAC,KAAK,MAAM,KAAK,KAAK;EAChC,SAAS,OAAO,EAAE,WAAW;AAC3B,SAAM;;EAET,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjKJ,MAAa,wBAAwB,QAAQ;CAC3C,MAAM;CACN,OAAO,CAAC,cAAc;CACtB,UAAU,CAAC,eAAe,cAAc;CACzC,CAAC;AAIF,iBAAiB,MAAM,QAAQ,WAAW;AACxC,KAAI,OAAO,OACT,QAAO,IAAI,eAAe,OAAO,OAAO;EAE1C"}
@@ -742,13 +742,32 @@ var TypeProvider = class TypeProvider {
742
742
  nullify = (schema, options) => Type.Mapped(Type.Identifier("K"), Type.KeyOf(schema), Type.Ref("K"), Type.Union([Type.Index(schema, Type.Ref("K")), Type.Null()]), options);
743
743
  /**
744
744
  * Create a schema for a string enum.
745
+ *
746
+ * By default, this creates a real PostgreSQL ENUM type in the database.
747
+ * Use `{ mode: "text" }` to store as a TEXT column instead.
748
+ *
749
+ * @example
750
+ * ```ts
751
+ * // PostgreSQL ENUM type (default)
752
+ * status: t.enum(["pending", "active", "archived"])
753
+ *
754
+ * // TEXT column
755
+ * status: t.enum(["pending", "active", "archived"], { mode: "text" })
756
+ *
757
+ * // Shared enum name across tables
758
+ * status: t.enum(["enabled", "disabled"], { name: "shared_status_enum" })
759
+ * ```
745
760
  */
746
761
  enum(values, options) {
747
- return Type.Unsafe(t.text({
762
+ const { mode, name, ...textOptions } = options ?? {};
763
+ const schema = Type.Unsafe(t.text({
748
764
  enum: values,
749
765
  pattern: values.map((v) => `^${v}$`).join("|"),
750
- ...options
766
+ ...textOptions
751
767
  }));
768
+ if (mode === "text") Object.assign(schema, { mode: "text" });
769
+ else Object.assign(schema, { enumName: name });
770
+ return schema;
752
771
  }
753
772
  /**
754
773
  * Create a schema for a bigint represented as a string.