@njdamstra/appwrite-utils-cli 1.8.9

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 (392) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +1133 -0
  3. package/dist/adapters/AdapterFactory.d.ts +94 -0
  4. package/dist/adapters/AdapterFactory.js +405 -0
  5. package/dist/adapters/DatabaseAdapter.d.ts +233 -0
  6. package/dist/adapters/DatabaseAdapter.js +50 -0
  7. package/dist/adapters/LegacyAdapter.d.ts +50 -0
  8. package/dist/adapters/LegacyAdapter.js +612 -0
  9. package/dist/adapters/TablesDBAdapter.d.ts +45 -0
  10. package/dist/adapters/TablesDBAdapter.js +571 -0
  11. package/dist/adapters/index.d.ts +11 -0
  12. package/dist/adapters/index.js +12 -0
  13. package/dist/backups/operations/bucketBackup.d.ts +19 -0
  14. package/dist/backups/operations/bucketBackup.js +197 -0
  15. package/dist/backups/operations/collectionBackup.d.ts +30 -0
  16. package/dist/backups/operations/collectionBackup.js +201 -0
  17. package/dist/backups/operations/comprehensiveBackup.d.ts +25 -0
  18. package/dist/backups/operations/comprehensiveBackup.js +238 -0
  19. package/dist/backups/schemas/bucketManifest.d.ts +93 -0
  20. package/dist/backups/schemas/bucketManifest.js +33 -0
  21. package/dist/backups/schemas/comprehensiveManifest.d.ts +108 -0
  22. package/dist/backups/schemas/comprehensiveManifest.js +32 -0
  23. package/dist/backups/tracking/centralizedTracking.d.ts +34 -0
  24. package/dist/backups/tracking/centralizedTracking.js +274 -0
  25. package/dist/cli/commands/configCommands.d.ts +8 -0
  26. package/dist/cli/commands/configCommands.js +166 -0
  27. package/dist/cli/commands/databaseCommands.d.ts +13 -0
  28. package/dist/cli/commands/databaseCommands.js +554 -0
  29. package/dist/cli/commands/functionCommands.d.ts +7 -0
  30. package/dist/cli/commands/functionCommands.js +330 -0
  31. package/dist/cli/commands/schemaCommands.d.ts +7 -0
  32. package/dist/cli/commands/schemaCommands.js +169 -0
  33. package/dist/cli/commands/storageCommands.d.ts +5 -0
  34. package/dist/cli/commands/storageCommands.js +143 -0
  35. package/dist/cli/commands/transferCommands.d.ts +5 -0
  36. package/dist/cli/commands/transferCommands.js +384 -0
  37. package/dist/collections/attributes.d.ts +13 -0
  38. package/dist/collections/attributes.js +1364 -0
  39. package/dist/collections/indexes.d.ts +12 -0
  40. package/dist/collections/indexes.js +217 -0
  41. package/dist/collections/methods.d.ts +19 -0
  42. package/dist/collections/methods.js +682 -0
  43. package/dist/collections/tableOperations.d.ts +86 -0
  44. package/dist/collections/tableOperations.js +434 -0
  45. package/dist/collections/transferOperations.d.ts +8 -0
  46. package/dist/collections/transferOperations.js +412 -0
  47. package/dist/collections/wipeOperations.d.ts +16 -0
  48. package/dist/collections/wipeOperations.js +233 -0
  49. package/dist/config/ConfigManager.d.ts +445 -0
  50. package/dist/config/ConfigManager.js +625 -0
  51. package/dist/config/configMigration.d.ts +87 -0
  52. package/dist/config/configMigration.js +390 -0
  53. package/dist/config/configValidation.d.ts +66 -0
  54. package/dist/config/configValidation.js +358 -0
  55. package/dist/config/index.d.ts +8 -0
  56. package/dist/config/index.js +7 -0
  57. package/dist/config/services/ConfigDiscoveryService.d.ts +126 -0
  58. package/dist/config/services/ConfigDiscoveryService.js +374 -0
  59. package/dist/config/services/ConfigLoaderService.d.ts +129 -0
  60. package/dist/config/services/ConfigLoaderService.js +540 -0
  61. package/dist/config/services/ConfigMergeService.d.ts +208 -0
  62. package/dist/config/services/ConfigMergeService.js +308 -0
  63. package/dist/config/services/ConfigValidationService.d.ts +214 -0
  64. package/dist/config/services/ConfigValidationService.js +310 -0
  65. package/dist/config/services/SessionAuthService.d.ts +225 -0
  66. package/dist/config/services/SessionAuthService.js +456 -0
  67. package/dist/config/services/__tests__/ConfigMergeService.test.d.ts +1 -0
  68. package/dist/config/services/__tests__/ConfigMergeService.test.js +271 -0
  69. package/dist/config/services/index.d.ts +13 -0
  70. package/dist/config/services/index.js +10 -0
  71. package/dist/config/yamlConfig.d.ts +722 -0
  72. package/dist/config/yamlConfig.js +702 -0
  73. package/dist/databases/methods.d.ts +6 -0
  74. package/dist/databases/methods.js +35 -0
  75. package/dist/databases/setup.d.ts +5 -0
  76. package/dist/databases/setup.js +45 -0
  77. package/dist/examples/yamlTerminologyExample.d.ts +42 -0
  78. package/dist/examples/yamlTerminologyExample.js +272 -0
  79. package/dist/functions/deployments.d.ts +4 -0
  80. package/dist/functions/deployments.js +146 -0
  81. package/dist/functions/fnConfigDiscovery.d.ts +3 -0
  82. package/dist/functions/fnConfigDiscovery.js +108 -0
  83. package/dist/functions/methods.d.ts +16 -0
  84. package/dist/functions/methods.js +162 -0
  85. package/dist/functions/pathResolution.d.ts +37 -0
  86. package/dist/functions/pathResolution.js +185 -0
  87. package/dist/functions/templates/count-docs-in-collection/README.md +54 -0
  88. package/dist/functions/templates/count-docs-in-collection/src/main.ts +159 -0
  89. package/dist/functions/templates/count-docs-in-collection/src/request.ts +9 -0
  90. package/dist/functions/templates/hono-typescript/README.md +286 -0
  91. package/dist/functions/templates/hono-typescript/src/adapters/request.ts +74 -0
  92. package/dist/functions/templates/hono-typescript/src/adapters/response.ts +106 -0
  93. package/dist/functions/templates/hono-typescript/src/app.ts +180 -0
  94. package/dist/functions/templates/hono-typescript/src/context.ts +103 -0
  95. package/dist/functions/templates/hono-typescript/src/index.ts +54 -0
  96. package/dist/functions/templates/hono-typescript/src/middleware/appwrite.ts +119 -0
  97. package/dist/functions/templates/typescript-node/README.md +32 -0
  98. package/dist/functions/templates/typescript-node/src/context.ts +103 -0
  99. package/dist/functions/templates/typescript-node/src/index.ts +29 -0
  100. package/dist/functions/templates/uv/README.md +31 -0
  101. package/dist/functions/templates/uv/pyproject.toml +30 -0
  102. package/dist/functions/templates/uv/src/__init__.py +0 -0
  103. package/dist/functions/templates/uv/src/context.py +125 -0
  104. package/dist/functions/templates/uv/src/index.py +46 -0
  105. package/dist/init.d.ts +2 -0
  106. package/dist/init.js +57 -0
  107. package/dist/interactiveCLI.d.ts +31 -0
  108. package/dist/interactiveCLI.js +898 -0
  109. package/dist/main.d.ts +2 -0
  110. package/dist/main.js +1172 -0
  111. package/dist/migrations/afterImportActions.d.ts +17 -0
  112. package/dist/migrations/afterImportActions.js +306 -0
  113. package/dist/migrations/appwriteToX.d.ts +211 -0
  114. package/dist/migrations/appwriteToX.js +491 -0
  115. package/dist/migrations/comprehensiveTransfer.d.ts +147 -0
  116. package/dist/migrations/comprehensiveTransfer.js +1317 -0
  117. package/dist/migrations/dataLoader.d.ts +753 -0
  118. package/dist/migrations/dataLoader.js +1250 -0
  119. package/dist/migrations/importController.d.ts +23 -0
  120. package/dist/migrations/importController.js +268 -0
  121. package/dist/migrations/importDataActions.d.ts +50 -0
  122. package/dist/migrations/importDataActions.js +230 -0
  123. package/dist/migrations/relationships.d.ts +29 -0
  124. package/dist/migrations/relationships.js +204 -0
  125. package/dist/migrations/services/DataTransformationService.d.ts +55 -0
  126. package/dist/migrations/services/DataTransformationService.js +158 -0
  127. package/dist/migrations/services/FileHandlerService.d.ts +75 -0
  128. package/dist/migrations/services/FileHandlerService.js +236 -0
  129. package/dist/migrations/services/ImportOrchestrator.d.ts +97 -0
  130. package/dist/migrations/services/ImportOrchestrator.js +485 -0
  131. package/dist/migrations/services/RateLimitManager.d.ts +138 -0
  132. package/dist/migrations/services/RateLimitManager.js +279 -0
  133. package/dist/migrations/services/RelationshipResolver.d.ts +120 -0
  134. package/dist/migrations/services/RelationshipResolver.js +332 -0
  135. package/dist/migrations/services/UserMappingService.d.ts +109 -0
  136. package/dist/migrations/services/UserMappingService.js +277 -0
  137. package/dist/migrations/services/ValidationService.d.ts +74 -0
  138. package/dist/migrations/services/ValidationService.js +260 -0
  139. package/dist/migrations/transfer.d.ts +26 -0
  140. package/dist/migrations/transfer.js +608 -0
  141. package/dist/migrations/yaml/YamlImportConfigLoader.d.ts +131 -0
  142. package/dist/migrations/yaml/YamlImportConfigLoader.js +383 -0
  143. package/dist/migrations/yaml/YamlImportIntegration.d.ts +93 -0
  144. package/dist/migrations/yaml/YamlImportIntegration.js +341 -0
  145. package/dist/migrations/yaml/generateImportSchemas.d.ts +30 -0
  146. package/dist/migrations/yaml/generateImportSchemas.js +1327 -0
  147. package/dist/schemas/authUser.d.ts +24 -0
  148. package/dist/schemas/authUser.js +17 -0
  149. package/dist/setup.d.ts +2 -0
  150. package/dist/setup.js +5 -0
  151. package/dist/setupCommands.d.ts +58 -0
  152. package/dist/setupCommands.js +490 -0
  153. package/dist/setupController.d.ts +9 -0
  154. package/dist/setupController.js +34 -0
  155. package/dist/shared/attributeMapper.d.ts +20 -0
  156. package/dist/shared/attributeMapper.js +203 -0
  157. package/dist/shared/backupMetadataSchema.d.ts +94 -0
  158. package/dist/shared/backupMetadataSchema.js +38 -0
  159. package/dist/shared/backupTracking.d.ts +18 -0
  160. package/dist/shared/backupTracking.js +176 -0
  161. package/dist/shared/confirmationDialogs.d.ts +75 -0
  162. package/dist/shared/confirmationDialogs.js +236 -0
  163. package/dist/shared/errorUtils.d.ts +54 -0
  164. package/dist/shared/errorUtils.js +95 -0
  165. package/dist/shared/functionManager.d.ts +48 -0
  166. package/dist/shared/functionManager.js +336 -0
  167. package/dist/shared/indexManager.d.ts +24 -0
  168. package/dist/shared/indexManager.js +151 -0
  169. package/dist/shared/jsonSchemaGenerator.d.ts +50 -0
  170. package/dist/shared/jsonSchemaGenerator.js +290 -0
  171. package/dist/shared/logging.d.ts +61 -0
  172. package/dist/shared/logging.js +116 -0
  173. package/dist/shared/messageFormatter.d.ts +39 -0
  174. package/dist/shared/messageFormatter.js +162 -0
  175. package/dist/shared/migrationHelpers.d.ts +61 -0
  176. package/dist/shared/migrationHelpers.js +145 -0
  177. package/dist/shared/operationLogger.d.ts +10 -0
  178. package/dist/shared/operationLogger.js +12 -0
  179. package/dist/shared/operationQueue.d.ts +40 -0
  180. package/dist/shared/operationQueue.js +311 -0
  181. package/dist/shared/operationsTable.d.ts +26 -0
  182. package/dist/shared/operationsTable.js +286 -0
  183. package/dist/shared/operationsTableSchema.d.ts +48 -0
  184. package/dist/shared/operationsTableSchema.js +35 -0
  185. package/dist/shared/progressManager.d.ts +62 -0
  186. package/dist/shared/progressManager.js +215 -0
  187. package/dist/shared/pydanticModelGenerator.d.ts +17 -0
  188. package/dist/shared/pydanticModelGenerator.js +615 -0
  189. package/dist/shared/relationshipExtractor.d.ts +56 -0
  190. package/dist/shared/relationshipExtractor.js +138 -0
  191. package/dist/shared/schemaGenerator.d.ts +40 -0
  192. package/dist/shared/schemaGenerator.js +556 -0
  193. package/dist/shared/selectionDialogs.d.ts +214 -0
  194. package/dist/shared/selectionDialogs.js +544 -0
  195. package/dist/storage/backupCompression.d.ts +20 -0
  196. package/dist/storage/backupCompression.js +67 -0
  197. package/dist/storage/methods.d.ts +32 -0
  198. package/dist/storage/methods.js +472 -0
  199. package/dist/storage/schemas.d.ts +842 -0
  200. package/dist/storage/schemas.js +175 -0
  201. package/dist/types.d.ts +4 -0
  202. package/dist/types.js +3 -0
  203. package/dist/users/methods.d.ts +16 -0
  204. package/dist/users/methods.js +277 -0
  205. package/dist/utils/ClientFactory.d.ts +87 -0
  206. package/dist/utils/ClientFactory.js +212 -0
  207. package/dist/utils/configDiscovery.d.ts +78 -0
  208. package/dist/utils/configDiscovery.js +472 -0
  209. package/dist/utils/configMigration.d.ts +1 -0
  210. package/dist/utils/configMigration.js +261 -0
  211. package/dist/utils/constantsGenerator.d.ts +31 -0
  212. package/dist/utils/constantsGenerator.js +321 -0
  213. package/dist/utils/dataConverters.d.ts +46 -0
  214. package/dist/utils/dataConverters.js +139 -0
  215. package/dist/utils/directoryUtils.d.ts +22 -0
  216. package/dist/utils/directoryUtils.js +59 -0
  217. package/dist/utils/getClientFromConfig.d.ts +39 -0
  218. package/dist/utils/getClientFromConfig.js +199 -0
  219. package/dist/utils/helperFunctions.d.ts +63 -0
  220. package/dist/utils/helperFunctions.js +156 -0
  221. package/dist/utils/index.d.ts +2 -0
  222. package/dist/utils/index.js +2 -0
  223. package/dist/utils/loadConfigs.d.ts +50 -0
  224. package/dist/utils/loadConfigs.js +358 -0
  225. package/dist/utils/pathResolvers.d.ts +53 -0
  226. package/dist/utils/pathResolvers.js +72 -0
  227. package/dist/utils/projectConfig.d.ts +119 -0
  228. package/dist/utils/projectConfig.js +171 -0
  229. package/dist/utils/retryFailedPromises.d.ts +2 -0
  230. package/dist/utils/retryFailedPromises.js +23 -0
  231. package/dist/utils/sessionAuth.d.ts +48 -0
  232. package/dist/utils/sessionAuth.js +164 -0
  233. package/dist/utils/setupFiles.d.ts +4 -0
  234. package/dist/utils/setupFiles.js +1192 -0
  235. package/dist/utils/typeGuards.d.ts +35 -0
  236. package/dist/utils/typeGuards.js +57 -0
  237. package/dist/utils/validationRules.d.ts +43 -0
  238. package/dist/utils/validationRules.js +42 -0
  239. package/dist/utils/versionDetection.d.ts +58 -0
  240. package/dist/utils/versionDetection.js +251 -0
  241. package/dist/utils/yamlConverter.d.ts +100 -0
  242. package/dist/utils/yamlConverter.js +428 -0
  243. package/dist/utils/yamlLoader.d.ts +70 -0
  244. package/dist/utils/yamlLoader.js +267 -0
  245. package/dist/utilsController.d.ts +106 -0
  246. package/dist/utilsController.js +863 -0
  247. package/package.json +75 -0
  248. package/scripts/copy-templates.ts +23 -0
  249. package/src/adapters/AdapterFactory.ts +510 -0
  250. package/src/adapters/DatabaseAdapter.ts +306 -0
  251. package/src/adapters/LegacyAdapter.ts +841 -0
  252. package/src/adapters/TablesDBAdapter.ts +773 -0
  253. package/src/adapters/index.ts +37 -0
  254. package/src/backups/operations/bucketBackup.ts +277 -0
  255. package/src/backups/operations/collectionBackup.ts +310 -0
  256. package/src/backups/operations/comprehensiveBackup.ts +342 -0
  257. package/src/backups/schemas/bucketManifest.ts +78 -0
  258. package/src/backups/schemas/comprehensiveManifest.ts +76 -0
  259. package/src/backups/tracking/centralizedTracking.ts +352 -0
  260. package/src/cli/commands/configCommands.ts +201 -0
  261. package/src/cli/commands/databaseCommands.ts +749 -0
  262. package/src/cli/commands/functionCommands.ts +418 -0
  263. package/src/cli/commands/schemaCommands.ts +200 -0
  264. package/src/cli/commands/storageCommands.ts +152 -0
  265. package/src/cli/commands/transferCommands.ts +457 -0
  266. package/src/collections/attributes.ts +2054 -0
  267. package/src/collections/attributes.ts.backup +1555 -0
  268. package/src/collections/indexes.ts +352 -0
  269. package/src/collections/methods.ts +745 -0
  270. package/src/collections/tableOperations.ts +506 -0
  271. package/src/collections/transferOperations.ts +590 -0
  272. package/src/collections/wipeOperations.ts +346 -0
  273. package/src/config/ConfigManager.ts +808 -0
  274. package/src/config/README.md +274 -0
  275. package/src/config/configMigration.ts +575 -0
  276. package/src/config/configValidation.ts +445 -0
  277. package/src/config/index.ts +10 -0
  278. package/src/config/services/ConfigDiscoveryService.ts +463 -0
  279. package/src/config/services/ConfigLoaderService.ts +740 -0
  280. package/src/config/services/ConfigMergeService.ts +388 -0
  281. package/src/config/services/ConfigValidationService.ts +394 -0
  282. package/src/config/services/SessionAuthService.ts +565 -0
  283. package/src/config/services/__tests__/ConfigMergeService.test.ts +351 -0
  284. package/src/config/services/index.ts +29 -0
  285. package/src/config/yamlConfig.ts +761 -0
  286. package/src/databases/methods.ts +49 -0
  287. package/src/databases/setup.ts +77 -0
  288. package/src/examples/yamlTerminologyExample.ts +346 -0
  289. package/src/functions/deployments.ts +220 -0
  290. package/src/functions/fnConfigDiscovery.ts +103 -0
  291. package/src/functions/methods.ts +271 -0
  292. package/src/functions/pathResolution.ts +227 -0
  293. package/src/functions/templates/count-docs-in-collection/README.md +54 -0
  294. package/src/functions/templates/count-docs-in-collection/src/main.ts +159 -0
  295. package/src/functions/templates/count-docs-in-collection/src/request.ts +9 -0
  296. package/src/functions/templates/hono-typescript/README.md +286 -0
  297. package/src/functions/templates/hono-typescript/src/adapters/request.ts +74 -0
  298. package/src/functions/templates/hono-typescript/src/adapters/response.ts +106 -0
  299. package/src/functions/templates/hono-typescript/src/app.ts +180 -0
  300. package/src/functions/templates/hono-typescript/src/context.ts +103 -0
  301. package/src/functions/templates/hono-typescript/src/index.ts +54 -0
  302. package/src/functions/templates/hono-typescript/src/middleware/appwrite.ts +119 -0
  303. package/src/functions/templates/typescript-node/README.md +32 -0
  304. package/src/functions/templates/typescript-node/src/context.ts +103 -0
  305. package/src/functions/templates/typescript-node/src/index.ts +29 -0
  306. package/src/functions/templates/uv/README.md +31 -0
  307. package/src/functions/templates/uv/pyproject.toml +30 -0
  308. package/src/functions/templates/uv/src/__init__.py +0 -0
  309. package/src/functions/templates/uv/src/context.py +125 -0
  310. package/src/functions/templates/uv/src/index.py +46 -0
  311. package/src/init.ts +62 -0
  312. package/src/interactiveCLI.ts +1136 -0
  313. package/src/main.ts +1661 -0
  314. package/src/migrations/afterImportActions.ts +580 -0
  315. package/src/migrations/appwriteToX.ts +664 -0
  316. package/src/migrations/comprehensiveTransfer.ts +2285 -0
  317. package/src/migrations/dataLoader.ts +1702 -0
  318. package/src/migrations/importController.ts +428 -0
  319. package/src/migrations/importDataActions.ts +315 -0
  320. package/src/migrations/relationships.ts +334 -0
  321. package/src/migrations/services/DataTransformationService.ts +196 -0
  322. package/src/migrations/services/FileHandlerService.ts +311 -0
  323. package/src/migrations/services/ImportOrchestrator.ts +666 -0
  324. package/src/migrations/services/RateLimitManager.ts +363 -0
  325. package/src/migrations/services/RelationshipResolver.ts +461 -0
  326. package/src/migrations/services/UserMappingService.ts +345 -0
  327. package/src/migrations/services/ValidationService.ts +349 -0
  328. package/src/migrations/transfer.ts +1068 -0
  329. package/src/migrations/yaml/YamlImportConfigLoader.ts +439 -0
  330. package/src/migrations/yaml/YamlImportIntegration.ts +446 -0
  331. package/src/migrations/yaml/generateImportSchemas.ts +1354 -0
  332. package/src/schemas/authUser.ts +23 -0
  333. package/src/setup.ts +8 -0
  334. package/src/setupCommands.ts +603 -0
  335. package/src/setupController.ts +43 -0
  336. package/src/shared/attributeMapper.ts +229 -0
  337. package/src/shared/backupMetadataSchema.ts +93 -0
  338. package/src/shared/backupTracking.ts +211 -0
  339. package/src/shared/confirmationDialogs.ts +327 -0
  340. package/src/shared/errorUtils.ts +110 -0
  341. package/src/shared/functionManager.ts +525 -0
  342. package/src/shared/indexManager.ts +254 -0
  343. package/src/shared/jsonSchemaGenerator.ts +383 -0
  344. package/src/shared/logging.ts +149 -0
  345. package/src/shared/messageFormatter.ts +208 -0
  346. package/src/shared/migrationHelpers.ts +232 -0
  347. package/src/shared/operationLogger.ts +20 -0
  348. package/src/shared/operationQueue.ts +377 -0
  349. package/src/shared/operationsTable.ts +338 -0
  350. package/src/shared/operationsTableSchema.ts +60 -0
  351. package/src/shared/progressManager.ts +278 -0
  352. package/src/shared/pydanticModelGenerator.ts +618 -0
  353. package/src/shared/relationshipExtractor.ts +214 -0
  354. package/src/shared/schemaGenerator.ts +644 -0
  355. package/src/shared/selectionDialogs.ts +749 -0
  356. package/src/storage/backupCompression.ts +88 -0
  357. package/src/storage/methods.ts +698 -0
  358. package/src/storage/schemas.ts +205 -0
  359. package/src/types/node-appwrite-tablesdb.d.ts +44 -0
  360. package/src/types.ts +9 -0
  361. package/src/users/methods.ts +359 -0
  362. package/src/utils/ClientFactory.ts +240 -0
  363. package/src/utils/configDiscovery.ts +557 -0
  364. package/src/utils/configMigration.ts +348 -0
  365. package/src/utils/constantsGenerator.ts +369 -0
  366. package/src/utils/dataConverters.ts +159 -0
  367. package/src/utils/directoryUtils.ts +61 -0
  368. package/src/utils/getClientFromConfig.ts +257 -0
  369. package/src/utils/helperFunctions.ts +228 -0
  370. package/src/utils/index.ts +2 -0
  371. package/src/utils/loadConfigs.ts +449 -0
  372. package/src/utils/pathResolvers.ts +81 -0
  373. package/src/utils/projectConfig.ts +299 -0
  374. package/src/utils/retryFailedPromises.ts +29 -0
  375. package/src/utils/sessionAuth.ts +230 -0
  376. package/src/utils/setupFiles.ts +1238 -0
  377. package/src/utils/typeGuards.ts +65 -0
  378. package/src/utils/validationRules.ts +88 -0
  379. package/src/utils/versionDetection.ts +292 -0
  380. package/src/utils/yamlConverter.ts +542 -0
  381. package/src/utils/yamlLoader.ts +371 -0
  382. package/src/utilsController.ts +1203 -0
  383. package/tests/README.md +497 -0
  384. package/tests/adapters/AdapterFactory.test.ts +277 -0
  385. package/tests/integration/syncOperations.test.ts +463 -0
  386. package/tests/jest.config.js +25 -0
  387. package/tests/migration/configMigration.test.ts +546 -0
  388. package/tests/setup.ts +62 -0
  389. package/tests/testUtils.ts +340 -0
  390. package/tests/utils/loadConfigs.test.ts +350 -0
  391. package/tests/validation/configValidation.test.ts +412 -0
  392. package/tsconfig.json +44 -0
package/README.md ADDED
@@ -0,0 +1,1133 @@
1
+ # appwrite-utils-cli
2
+
3
+ ## Overview
4
+
5
+ `@njdamstra/appwrite-utils-cli` is a powerful, YAML-first command-line interface tool designed for Appwrite developers who need to manage database migrations, schema generation, data import, and comprehensive project management. Built on a modular architecture with enhanced performance, this CLI tool facilitates complex tasks like setting up databases, running migrations, generating schemas, and managing backups efficiently.
6
+
7
+ Highlights:
8
+ - Adapter-first database orchestration (no legacy attribute fall-through)
9
+ - Safe diff-based updates for attributes and indexes (no duplicate creations)
10
+ - Manual push selections (no auto-push of all DBs)
11
+ - Multi-database targeting per table/collection via `databaseIds`
12
+ - Per-function configuration via `.fnconfig.yaml` (discovered anywhere in repo)
13
+
14
+ ## Features
15
+
16
+ ### Core Capabilities
17
+ - **YAML-First Configuration**: Modern YAML-based configuration with JSON Schema support for IntelliSense
18
+ - **Interactive Mode**: Professional guided CLI experience with rich visual feedback and progress tracking
19
+ - **Modular Import System**: Completely refactored import architecture with 50%+ complexity reduction
20
+ - **Enhanced Performance**: Configurable rate limiting and batch processing for optimal performance
21
+ - **Safety First**: Smart confirmation dialogs for destructive operations with explicit confirmations
22
+
23
+ ### Dual API Support (Collections & TablesDB)
24
+ - **Collections API**: Traditional Appwrite database operations with document-based terminology
25
+ - **TablesDB API**: New high-performance table API with column-based terminology
26
+ - **Automatic Detection**: Smart API mode detection (fetch-based detection; no extra packages required)
27
+ - **Seamless Migration**: Zero-downtime migration between Collections and TablesDB APIs
28
+ - **Terminology Flexibility**: Support for both `collections/documents/attributes` and `tables/rows/columns`
29
+
30
+ ### Data Management
31
+ - **Advanced Data Import**: YAML-configured imports with sophisticated file handling, URL support, and user deduplication
32
+ - **Relationship Resolution**: Intelligent cross-collection relationship mapping and ID resolution
33
+ - **User Management**: Advanced user deduplication with email/phone matching and merge capabilities
34
+ - **File Operations**: Complete file handling with URL downloads, local file search, and afterImportActions
35
+ - **Backup Management**: Comprehensive backup system with progress tracking and detailed reporting
36
+
37
+ ### Development Tools
38
+ - **Database Migrations**: Full migration control with progress tracking and operation summaries
39
+ - **Schema Generation**: Generate TypeScript (Zod), JSON, and Python (Pydantic) schemas/models from database configurations
40
+ - **Constants Generation**: Generate cross-language constants files (TypeScript, Python, PHP, Dart, JSON, Env) for database, collection, bucket, and function IDs
41
+ - **Data Transfer**: Transfer data between databases, collections, and instances with real-time progress
42
+ - **Configuration Sync**: Bidirectional synchronization between local YAML configs and Appwrite projects
43
+ - **Function Management**: Deploy and manage Appwrite Functions with specification updates
44
+
45
+ ## Installation
46
+
47
+ To use `@njdamstra/appwrite-utils-cli`, you can install it globally via npm to make it accessible from anywhere in your command line:
48
+
49
+ ```bash
50
+ npm install -g @njdamstra/appwrite-utils-cli
51
+ ```
52
+
53
+ However, due to the rapid development of this project, it's recommended to use the following command:
54
+
55
+ ```bash
56
+ npx --package=@njdamstra/appwrite-utils-cli@latest appwrite-migrate [options]
57
+ ```
58
+
59
+ **Note: Do not install this locally into your project. It is meant to be used as a command-line tool only.**
60
+
61
+ ## TablesDB Support
62
+
63
+ `@njdamstra/appwrite-utils-cli` provides comprehensive support for both traditional Appwrite Collections API and the new TablesDB API, enabling high-performance database operations with modern terminology.
64
+
65
+ ### API Mode Detection
66
+
67
+ The CLI automatically selects Collections or TablesDB using fetch-based server detection (health/version and endpoint probes). No additional SDK packages are required.
68
+
69
+ ### Configuration Comparison
70
+
71
+ #### Collections API (Traditional)
72
+ ```yaml
73
+ # .appwrite/config.yaml
74
+ databases:
75
+ - name: "main"
76
+ id: "main"
77
+ collections: # Collections terminology
78
+ - name: "Users"
79
+ id: "users"
80
+ attributes:
81
+ - key: "email"
82
+ type: "string"
83
+ required: true
84
+ ```
85
+
86
+ #### TablesDB API (New)
87
+ ```yaml
88
+ # .appwrite/config.yaml
89
+ databases:
90
+ - name: "main"
91
+ id: "main"
92
+ tables: # TablesDB terminology
93
+ - name: "Users"
94
+ id: "users"
95
+ attributes: # Internally consistent
96
+ - key: "email"
97
+ type: "string"
98
+ required: true
99
+ ```
100
+
101
+ ### Performance Benefits
102
+
103
+ TablesDB provides significant performance improvements:
104
+
105
+ - **Bulk Operations**: Native support for bulk inserts, updates, and deletes
106
+ - **Advanced Queries**: Enhanced query capabilities with better optimization
107
+ - **Reduced Latency**: Direct table operations without document overhead
108
+ - **Scalability**: Better performance with large datasets
109
+
110
+ ### Migration Commands
111
+
112
+ The CLI provides seamless migration between APIs:
113
+
114
+ ```bash
115
+ # Migrate Collections config to TablesDB format
116
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --migrate-to-tablesdb
117
+
118
+ # Convert existing Collections to Tables (when TablesDB is available)
119
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --sync --use-tablesdb
120
+
121
+ # Generate schemas for TablesDB
122
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --generate --api-mode=tablesdb
123
+ ```
124
+
125
+ ## YAML-First Configuration
126
+
127
+ Version 1.0.0 introduces a YAML-first approach for better cross-platform compatibility and enhanced developer experience.
128
+
129
+ ### Configuration Structure
130
+
131
+ The CLI automatically detects configuration files in this order:
132
+ 1. `.appwrite/config.yaml` (recommended)
133
+ 2. `appwrite.yaml`
134
+ 3. `appwriteConfig.ts` (legacy, still supported)
135
+
136
+ ### YAML Configuration Examples
137
+
138
+ #### Collections API Configuration
139
+ ```yaml
140
+ # .appwrite/config.yaml with JSON Schema support
141
+ # yaml-language-server: $schema=./.yaml_schemas/appwrite-config.schema.json
142
+
143
+ appwriteEndpoint: "https://cloud.appwrite.io/v1"
144
+ appwriteProject: "your-project-id"
145
+ appwriteKey: "your-api-key"
146
+
147
+ databases:
148
+ - name: "main"
149
+ id: "main"
150
+ collections: # Collections terminology
151
+ - name: "Users"
152
+ id: "users"
153
+ attributes:
154
+ - key: "email"
155
+ type: "string"
156
+ required: true
157
+ format: "email"
158
+ - key: "name"
159
+ type: "string"
160
+ required: true
161
+
162
+ buckets:
163
+ - name: "documents"
164
+ id: "documents"
165
+ permissions:
166
+ - target: "any"
167
+ permission: "read"
168
+
169
+ logging:
170
+ enabled: false # Disabled by default
171
+ level: "info"
172
+ console: true
173
+ ```
174
+
175
+ #### TablesDB API Configuration
176
+ ```yaml
177
+ # .appwrite/config.yaml for TablesDB
178
+ # yaml-language-server: $schema=./.yaml_schemas/appwrite-config.schema.json
179
+
180
+ appwriteEndpoint: "https://cloud.appwrite.io/v1"
181
+ appwriteProject: "your-project-id"
182
+ appwriteKey: "your-api-key"
183
+
184
+ databases:
185
+ - name: "main"
186
+ id: "main"
187
+ tables: # TablesDB terminology
188
+ - name: "Users"
189
+ id: "users"
190
+ attributes: # Internal compatibility
191
+ - key: "email"
192
+ type: "string"
193
+ required: true
194
+ format: "email"
195
+ - key: "name"
196
+ type: "string"
197
+ required: true
198
+
199
+ buckets:
200
+ - name: "documents"
201
+ id: "documents"
202
+ permissions:
203
+ - target: "any"
204
+ permission: "read"
205
+
206
+ logging:
207
+ enabled: false # Disabled by default
208
+ level: "info"
209
+ console: true
210
+ ```
211
+
212
+ ## Usage
213
+
214
+ After installation, you can access the tool directly from your command line using the provided commands.
215
+
216
+ ### Interactive Mode
217
+
218
+ Run the CLI in interactive mode with enhanced visual feedback:
219
+
220
+ ```bash
221
+ npx --package=@njdamstra/appwrite-utils-cli@latest appwrite-migrate --it
222
+ ```
223
+
224
+ This provides a professional guided experience with:
225
+ - Rich visual feedback and progress tracking
226
+ - Smart confirmation dialogs for destructive operations
227
+ - Operation summaries with detailed statistics
228
+ - Real-time progress bars with ETA calculations
229
+
230
+ ### Generate Schemas (Zod / JSON / Pydantic)
231
+
232
+ Interactive schema generation lets you pick the format and output directory:
233
+
234
+ ```bash
235
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --it
236
+ # Choose: Generate schemas
237
+ # Select: TypeScript (Zod), JSON, Python (Pydantic), or All
238
+ # Enter output directory (absolute path respected)
239
+ ```
240
+
241
+ - Pydantic models use modern typing (str | None, list[str]) and alias mapping for Appwrite system fields:
242
+ - Base model (written as `base.py`) defines aliases for `$id`, `$createdAt`, `$updatedAt`, `$permissions`, `$databaseId`, `$collectionId`, `$sequence`.
243
+ - Each collection/table generates a model extending `BaseAppwriteModel`.
244
+ - Serialize with aliases via `model_dump(by_alias=True)` and validate from Appwrite docs via `model_validate(...)`.
245
+ - Output directory is selectable; files are written directly to your chosen path (no extra subfolder).
246
+
247
+ ### Push (manual selection)
248
+
249
+ Pushing local schema is now an explicit, manual selection flow to avoid unintended changes:
250
+
251
+ ```bash
252
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --push
253
+ ```
254
+
255
+ - Select databases from the remote project (no default auto-selection)
256
+ - Select tables/collections to push per selected database
257
+ - Summary confirmation is shown before applying changes
258
+
259
+ Flags:
260
+ - `--dbIds=id1,id2` pre-selects databases by ID (skips DB prompt)
261
+ - `--collectionIds=c1,c2` pre-selects tables/collections by ID for the selected DB(s)
262
+
263
+ Eligibility per DB:
264
+ - A table/collection is considered eligible for a database if:
265
+ - `databaseIds` includes the database ID, or
266
+ - `databaseId` equals the database ID, or
267
+ - neither field is set (eligible everywhere)
268
+
269
+ Attribute/Index behavior:
270
+ - Attributes and indexes are compared and only created/updated when changed
271
+ - Unchanged definitions are skipped
272
+ - Status is monitored until available (with sensible timeouts)
273
+
274
+ ### Non-Interactive Mode
275
+
276
+ You can also use specific flags to run tasks without the interactive prompt:
277
+
278
+ ```bash
279
+ npx --package=@njdamstra/appwrite-utils-cli@latest appwrite-migrate [options]
280
+ ```
281
+
282
+ ## YAML Import Configuration System
283
+
284
+ Version 1.0.0 introduces a powerful YAML-based import system with sophisticated data handling capabilities.
285
+
286
+ ### Import Configuration Examples
287
+
288
+ #### Collections API Import
289
+ ```yaml
290
+ # .appwrite/import/users-import.yaml
291
+ # yaml-language-server: $schema=../.yaml_schemas/import-config.schema.json
292
+
293
+ source:
294
+ file: "importData/users.json"
295
+ basePath: "RECORDS"
296
+ type: "json"
297
+
298
+ target:
299
+ collection: "Users" # Collections terminology
300
+ type: "create"
301
+ primaryKey: "user_id"
302
+ createUsers: true
303
+
304
+ mapping:
305
+ attributes:
306
+ - oldKey: "user_id"
307
+ targetKey: "userId"
308
+ converters: ["anyToString"]
309
+ validation:
310
+ - rule: "required"
311
+ params: ["{userId}"]
312
+
313
+ - oldKey: "profile_image_url"
314
+ targetKey: "avatar"
315
+ fileData:
316
+ path: "{profile_image_url}"
317
+ name: "{user_id}_avatar"
318
+ afterImport:
319
+ - action: "createFileAndUpdateField"
320
+ params: ["{dbId}", "{collId}", "{docId}", "avatar", "{bucketId}", "{filePath}", "{fileName}"]
321
+
322
+ relationships:
323
+ - sourceField: "department_id"
324
+ targetField: "departmentId"
325
+ targetCollection: "Departments"
326
+
327
+ options:
328
+ batchSize: 50
329
+ continueOnError: true
330
+ ```
331
+
332
+ #### TablesDB API Import
333
+ ```yaml
334
+ # .appwrite/import/users-tablesdb-import.yaml
335
+ # yaml-language-server: $schema=../.yaml_schemas/import-config.schema.json
336
+
337
+ source:
338
+ file: "importData/users.json"
339
+ basePath: "RECORDS"
340
+ type: "json"
341
+
342
+ target:
343
+ table: "Users" # TablesDB terminology (alternatively: collection: "Users" works too)
344
+ type: "create"
345
+ primaryKey: "user_id"
346
+ createUsers: true
347
+
348
+ mapping:
349
+ attributes: # Note: Still uses 'attributes' for compatibility
350
+ - oldKey: "user_id"
351
+ targetKey: "userId"
352
+ converters: ["anyToString"]
353
+ validation:
354
+ - rule: "required"
355
+ params: ["{userId}"]
356
+
357
+ - oldKey: "profile_image_url"
358
+ targetKey: "avatar"
359
+ fileData:
360
+ path: "{profile_image_url}"
361
+ name: "{user_id}_avatar"
362
+ afterImport:
363
+ - action: "createFileAndUpdateRowField" # TablesDB-specific action
364
+ params: ["{dbId}", "{tableId}", "{rowId}", "avatar", "{bucketId}", "{filePath}", "{fileName}"]
365
+
366
+ relationships:
367
+ - sourceField: "department_id"
368
+ targetField: "departmentId"
369
+ targetTable: "Departments" # TablesDB terminology
370
+
371
+ options:
372
+ batchSize: 100 # TablesDB supports larger batches
373
+ continueOnError: true
374
+ useBulkOperations: true # Enable TablesDB bulk operations
375
+ ```
376
+
377
+ ### Import System Features
378
+
379
+ - **File Handling**: Complete support for URL downloads and local file search
380
+ - **User Deduplication**: Sophisticated email/phone matching with merge capabilities
381
+ - **Rate Limiting**: Configurable p-limit for optimal performance (5 concurrent by default)
382
+ - **Relationship Resolution**: Intelligent cross-collection ID mapping
383
+ - **Validation**: Pre-import validation with detailed error reporting
384
+ - **Progress Tracking**: Real-time progress bars with batch processing statistics
385
+ - **AfterImportActions**: Complete post-import action system for file uploads and field updates
386
+
387
+ ## Command-Line Options
388
+
389
+ Available options:
390
+
391
+ ### Core Operations
392
+ - `--it`: Run in interactive mode with enhanced visual feedback
393
+ - `--setup`: Create setup files (supports both YAML and TypeScript)
394
+ - `--generate`: Generate TypeScript and JSON schemas from database configurations
395
+ - `--import`: Import data using YAML configurations with advanced processing
396
+ - `--backup`: Comprehensive backup with progress tracking and detailed reporting
397
+
398
+ ### Data Management
399
+ - `--dbIds`: Comma-separated list of database IDs to operate on
400
+ - `--collectionIds`: Comma-separated list of collection IDs to operate on (also accepts `--tableIds`)
401
+ - `--bucketIds`: Comma-separated list of bucket IDs to operate on
402
+ - `--wipe`: Wipe data with smart confirmation (all: everything, docs: only documents, users: only user data)
403
+ - `--wipeCollections`: Non-destructively wipe specified collections (also `--wipeTables`)
404
+ - `--writeData`: Write converted imported data to file for validation
405
+
406
+ ### TablesDB-Specific Options
407
+ - `--api-mode`: Force API mode (`collections` or `tablesdb`)
408
+ - `--use-tablesdb`: Force TablesDB API usage when available
409
+ - `--migrate-to-tablesdb`: Convert Collections configuration to TablesDB format
410
+ - `--bulk-operations`: Enable bulk operations for TablesDB (default: true when available)
411
+ - `--tableIds`: Comma-separated list of table IDs (alias for `--collectionIds`)
412
+
413
+ ### Configuration & Synchronization
414
+ - `--push`: Push local YAML/TypeScript config to Appwrite project
415
+ - `--sync`: Synchronize by pulling config from Appwrite project
416
+ - `--endpoint`: Set the Appwrite endpoint
417
+ - `--projectId`: Set the Appwrite project ID
418
+ - `--apiKey`: Set the Appwrite API key
419
+
420
+ ### Transfer Operations
421
+ - `--transfer`: Transfer data between databases or collections with progress tracking
422
+ - `--transfer-users`: Transfer users between instances (will not overwrite)
423
+ - `--fromDbId` / `--sourceDbId`: Source database ID for transfer
424
+ - `--toDbId` / `--targetDbId`: Destination database ID for transfer
425
+ - `--fromCollectionId`: Source collection ID for transfer
426
+ - `--toCollectionId`: Destination collection ID for transfer
427
+ - `--fromBucketId`: Source bucket ID for transfer
428
+ - `--toBucketId`: Destination bucket ID for transfer
429
+ - `--remoteEndpoint`: Remote Appwrite endpoint for transfers
430
+ - `--remoteProjectId`: Remote Appwrite project ID for transfers
431
+ - `--remoteApiKey`: Remote Appwrite API key for transfers
432
+
433
+ ### Function Management
434
+ - `--updateFunctionSpec`: Update function specifications
435
+ - `--functionId`: Function ID to update
436
+ - `--specification`: New function specification (s-0.5vcpu-512mb to s-8vcpu-8gb)
437
+
438
+ ### Constants Generation
439
+ - `--generateConstants` / `--constants`: Generate cross-language constants files with database, collection, bucket, and function IDs
440
+ - `--constantsLanguages`: Comma-separated list of languages for constants generation (default: typescript)
441
+ - Available languages: `typescript`, `javascript`, `python`, `php`, `dart`, `json`, `env`
442
+ - `--constantsOutput`: Output directory for generated constants files (default: config-folder/constants)
443
+
444
+ ## Examples
445
+
446
+ ### Generate Constants
447
+
448
+ Generate cross-language constants files for all your Appwrite resource IDs:
449
+
450
+ ```bash
451
+ # Generate TypeScript constants (default)
452
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --generateConstants
453
+
454
+ # Generate multiple language formats
455
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --generateConstants --constantsLanguages="typescript,python,php,json"
456
+
457
+ # Generate all available formats
458
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --generateConstants --constantsLanguages="typescript,javascript,python,php,dart,json,env"
459
+
460
+ # Generate with custom output directory
461
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --generateConstants --constantsOutput="./my-constants"
462
+ ```
463
+
464
+ This generates constants files in your configuration directory (e.g., `.appwrite/constants/`) containing:
465
+ - Database IDs
466
+ - Collection IDs
467
+ - Bucket IDs
468
+ - Function IDs
469
+
470
+ **Example TypeScript output:**
471
+ ```typescript
472
+ export const DATABASE_IDS = {
473
+ MAIN_DATABASE: "main"
474
+ } as const;
475
+
476
+ export const COLLECTION_IDS = {
477
+ USERS: "01JYDBQTB5W8SCBAYB654CCADQ",
478
+ POSTS: "01JYDBQTB5W8SCBAYB654POSTS"
479
+ } as const;
480
+
481
+ // Type helpers and utility arrays included
482
+ export type DatabaseId = typeof DATABASE_IDS[keyof typeof DATABASE_IDS];
483
+ ```
484
+
485
+ ### Transfer Databases
486
+
487
+ Transfer databases within the same project or from a local to a remote project:
488
+
489
+ ```bash
490
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --transfer --fromDbId sourceDbId --toDbId targetDbId --remoteEndpoint https://appwrite.otherserver.com --remoteProjectId yourProjectId --remoteApiKey yourApiKey
491
+ ```
492
+
493
+ ### Transfer Specific Collections
494
+
495
+ Transfer specific collections from one place to another, with all of their data:
496
+
497
+ ```bash
498
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --transfer --fromDbId sourceDbId --toDbId targetDbId --fromCollectionId sourceCollectionId --toCollectionId targetCollectionId --remoteEndpoint https://appwrite.otherserver.com --remoteProjectId yourProjectId --remoteApiKey yourApiKey
499
+ ```
500
+
501
+ ### TablesDB Examples
502
+
503
+ #### Enable TablesDB Mode
504
+ ```bash
505
+ # Force TablesDB API usage
506
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --sync --use-tablesdb
507
+
508
+ # Generate schemas with TablesDB terminology
509
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --generate --api-mode=tablesdb
510
+ ```
511
+
512
+ #### Migration from Collections to TablesDB
513
+ ```bash
514
+ # Convert Collections configuration to TablesDB format
515
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --migrate-to-tablesdb
516
+
517
+ # Sync with TablesDB API (requires node-appwrite-tablesdb)
518
+ npx --package=node-appwrite-tablesdb appwrite-utils-cli appwrite-migrate --sync --use-tablesdb
519
+ ```
520
+
521
+ #### Bulk Operations with TablesDB
522
+ ```bash
523
+ # Import with bulk operations enabled
524
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --import --bulk-operations
525
+
526
+ # Transfer tables with high-performance bulk operations
527
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --transfer --fromDbId sourceDb --toDbId targetDb --tableIds table1,table2 --use-tablesdb
528
+ ```
529
+
530
+ #### Working with Tables (TablesDB terminology)
531
+ ```bash
532
+ # Wipe specific tables
533
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --wipeTables --tableIds users,posts
534
+
535
+ # Generate constants with table terminology
536
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --generateConstants --api-mode=tablesdb
537
+ ```
538
+
539
+ ### Transfer Buckets
540
+
541
+ Transfer files between buckets:
542
+
543
+ ```bash
544
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --transfer --fromBucketId sourceBucketId --toBucketId targetBucketId --remoteEndpoint https://appwrite.otherserver.com --remoteProjectId yourProjectId --remoteApiKey yourApiKey
545
+ ```
546
+
547
+ ### Update Function Specifications
548
+
549
+ **NOTE: IF IT DOES NOT WORK AND YOU ARE SELF-HOSTED, PLEASE SET MAX CPU_PER_FUNCTION AND RAM_PER_FUNCTION IN YOUR ENV VARS TO > 0, THIS IS A BUG IN 1.6.0 -- YOU SET THE FUNCTION RAM IN MB**
550
+
551
+ Update the CPU and RAM specifications for a function:
552
+
553
+ ```bash
554
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --updateFunctionSpec --functionId yourFunctionId --specification s-1vcpu-1gb
555
+ ```
556
+
557
+ Available specifications:
558
+
559
+ - s-0.5vcpu-512mb: 0.5 vCPU, 512MB RAM
560
+ - s-1vcpu-1gb: 1 vCPU, 1GB RAM
561
+ - s-2vcpu-2gb: 2 vCPU, 2GB RAM
562
+ - s-2vcpu-4gb: 2 vCPU, 4GB RAM
563
+ - s-4vcpu-4gb: 4 vCPU, 4GB RAM
564
+ - s-4vcpu-8gb: 4 vCPU, 8GB RAM
565
+ - s-8vcpu-4gb: 8 vCPU, 4GB RAM
566
+ - s-8vcpu-8gb: 8 vCPU, 8GB RAM
567
+
568
+ ## Additional Notes
569
+
570
+ - If you run out of RAM during large data imports, you can increase Node's memory allocation:
571
+
572
+ ```bash
573
+ export NODE_OPTIONS="--max-old-space-size=16384"
574
+ ```
575
+
576
+ This sets the allocation to 16GB. For most cases, 8GB (`8192`) should be sufficient.
577
+
578
+ - The CLI now supports OpenAPI generation for each attribute in the schema. Add a `description` to any attribute or collection, and it will export that schema to the `appwrite/openapi` folder.
579
+
580
+ This updated CLI ensures that developers have robust tools at their fingertips to manage complex Appwrite projects effectively from the command line, with both interactive and non-interactive modes available for flexibility.
581
+
582
+ ## Changelog
583
+
584
+ ### 1.5.0 - Recursive Zod v4 Schemas + One‑Way Relationship Support
585
+
586
+ Highlights
587
+ - Recursive getters: Generated schemas now use Zod v4 recursive getters (no `z.lazy`, no `BaseSchema` layering). Cleaner types and fully inferred mutual recursion.
588
+ - One‑way relationships: Relationship attributes are now included even when `twoWay: false`. Related imports resolve collection IDs to names.
589
+ - Required semantics: Relationship getters respect `required` and `array`:
590
+ - required scalar → `RelatedSchema`
591
+ - optional scalar → `RelatedSchema.nullish()`
592
+ - required array → `RelatedSchema.array()`
593
+ - optional array → `RelatedSchema.array().nullish()`
594
+ - JSON Schemas: `$ref` definitions use resolved collection names when YAML provides IDs.
595
+
596
+ Validation changes
597
+ - Relationship schema: `twoWayKey` and `side` are now required only when `twoWay` is `true`.
598
+ - Helpful errors: Keeps strong validation but removes false negatives for one‑way relationships.
599
+
600
+ Developer notes
601
+ - Imports: Schema generators import only `...Schema` from related collections (no type imports needed).
602
+ - Example YAML: `Posts.yaml` demonstrates a required `manyToMany` (`categories`) and a one‑way `manyToOne` (`author`).
603
+
604
+
605
+ ### 1.3.0 - Zod v4 Upgrade & Collection Management Fixes
606
+
607
+ **🎉 Major Release - Zod v4 Compatibility & Reliability Improvements**
608
+
609
+ #### Breaking Changes
610
+ - **Zod v4 Upgrade**: Updated to Zod v4.0.0 for enhanced schema validation
611
+ - ⚠️ **Potential Breaking Change**: Some schema validations may behave differently
612
+ - Function event types are now more flexible to accommodate Zod v4 changes
613
+ - Review your validation schemas if you experience issues
614
+
615
+ #### Major Bug Fixes
616
+ - **Fixed Duplicate Attribute Creation**: Resolved issue where attributes were being created multiple times
617
+ - Implemented intelligent filtering to only process new or changed attributes
618
+ - Enhanced status monitoring and error handling
619
+ - Significantly improved sync performance and reliability
620
+
621
+ - **Fixed Index Creation Issues**: Resolved indexes not being created from collection configurations
622
+ - Added proper null checks for index arrays from different collection sources
623
+ - Enhanced index creation with comprehensive status monitoring
624
+ - Improved error handling and retry logic for stuck indexes
625
+
626
+ #### Enhanced Collection Management
627
+ - **Smart Attribute Processing**: Attributes are now only created/updated when needed
628
+ - Compares existing vs. config attributes before processing
629
+ - Skips unchanged attributes with clear logging
630
+ - Better handling of edge cases and error conditions
631
+
632
+ - **Improved Index Handling**: More robust index creation from collection configs
633
+ - Proper fallback logic when indexes are undefined
634
+ - Enhanced compatibility with different collection sources
635
+ - Better error reporting and debugging information
636
+
637
+ #### Performance Improvements
638
+ - **Optimized Sync Operations**: Collections now process only necessary changes
639
+ - **Enhanced Status Monitoring**: Real-time feedback for attribute and index operations
640
+ - **Better Resource Management**: Reduced API calls through intelligent filtering
641
+
642
+ #### Developer Experience
643
+ - **Build Stability**: Resolved TypeScript compilation issues with function schemas
644
+ - **Type Safety**: Maintained strict typing while accommodating Zod v4 changes
645
+ - **Enhanced Logging**: Better progress reporting and error messages
646
+
647
+ #### Migration Guide
648
+ 1. **Update Dependencies**: Ensure compatibility with Zod v4.0.0
649
+ 2. **Test Collection Operations**: Verify that attribute and index creation works as expected
650
+ 3. **Review Validations**: Check any custom validation schemas for potential breaking changes
651
+ 4. **Function Events**: Function event arrays are now `string[]` for enhanced flexibility
652
+
653
+ **Integration Note**: This version significantly improves collection management reliability and provides full Zod v4 compatibility. The fixes address core synchronization issues that could cause duplicate resources or missing indexes.
654
+
655
+ ---
656
+
657
+ ### 1.1.0 - Enhanced Transfer System with Fault Tolerance
658
+
659
+ **🔧 Robust Transfer Operations with Status Monitoring**
660
+
661
+ #### Enhanced Attribute Creation with Fault Tolerance
662
+ - **Exponential Backoff**: Intelligent retry strategy starting at 2 seconds, doubling each retry (2s, 4s, 8s, 16s, 30s max)
663
+ - **Status Monitoring**: Real-time monitoring of attribute states ('available', 'processing', 'stuck', 'failed', 'deleting')
664
+ - **Retry Logic**: Collection deletion/recreation for stuck attributes with up to 5 retry attempts
665
+ - **Sequential Processing**: Attributes processed one-by-one to prevent overwhelming the server
666
+ - **Enhanced Logging**: Comprehensive console feedback with color-coded status messages
667
+
668
+ #### Enhanced Index Creation with Status Monitoring
669
+ - **Similar Fault Tolerance**: Index creation now includes the same robust monitoring and retry logic
670
+ - **Status Checking**: Real-time monitoring of index creation states with proper error handling
671
+ - **Collection Recreation**: Automatic collection deletion/recreation for stuck index operations
672
+ - **Sequential Processing**: Prevents rate limiting by processing indexes individually
673
+
674
+ #### Document Transfer Reliability Improvements
675
+ - **Enhanced Error Handling**: Improved document transfer with exponential backoff retry logic
676
+ - **Smaller Batch Sizes**: Reduced batch sizes (10 documents) to prevent server overload
677
+ - **Better Progress Reporting**: Enhanced progress tracking with success/failure counts
678
+ - **Fault Tolerance**: Graceful handling of duplicate documents and API errors
679
+
680
+ #### Remote Database Transfer Enhancements
681
+ - **Integrated Enhanced Methods**: Updated `transferDatabaseLocalToRemote` to use new attribute and index creation
682
+ - **Proper Wait Logic**: System now properly waits for attributes/indexes to be fully created before proceeding
683
+ - **Status Validation**: Comprehensive status checking throughout the transfer process
684
+ - **Continued Operation**: Transfer continues even if some attributes/indexes fail (with warnings)
685
+
686
+ #### AppwriteConfig Integration for Comprehensive Transfer
687
+ - **Smart Configuration Detection**: Automatically detects existing appwriteConfig for reuse
688
+ - **Source/Target Options**: Users can select their appwriteConfig for either source or target endpoints
689
+ - **Streamlined Setup**: Enhanced user experience with clear configuration prompts
690
+
691
+ #### Technical Implementation
692
+ - **Rate Limiting Respect**: Enhanced operations respect existing rate limiting while adding reliability
693
+ - **Memory Efficiency**: Optimized processing to handle large operations without overwhelming system resources
694
+ - **Error Resilience**: Comprehensive error handling with detailed user feedback and recovery options
695
+ - **Status Persistence**: Operations maintain state information for better debugging and monitoring
696
+
697
+ #### Usage Benefits
698
+ - **Reliability**: Transfer operations no longer fail due to timing issues or stuck operations
699
+ - **Visibility**: Clear progress indicators and status messages throughout all operations
700
+ - **Recovery**: Automatic retry and recovery mechanisms prevent data loss
701
+ - **Performance**: Optimized timing prevents API throttling while maintaining speed
702
+
703
+ **Breaking Change**: None - fully backward compatible with significantly enhanced reliability.
704
+
705
+ ### 1.0.9 - Enhanced User Transfer with Password Preservation
706
+
707
+ **🔐 Complete Password Hash Preservation During User Transfers**
708
+
709
+ #### Password Hash Support
710
+ - **Universal Hash Support**: Support for all Appwrite password hash types:
711
+ - **Argon2**: Modern default hashing (preserved)
712
+ - **Bcrypt**: Industry standard (preserved)
713
+ - **Scrypt**: Memory-hard function with custom parameters (preserved)
714
+ - **Scrypt Modified**: Firebase-style with salt/separator/signer (preserved)
715
+ - **MD5**: Legacy support (preserved)
716
+ - **SHA variants**: SHA1, SHA256, SHA512 (preserved)
717
+ - **PHPass**: WordPress-style hashing (preserved)
718
+ - **Dynamic Hash Detection**: Automatically detects and uses correct hash creation method
719
+ - **Parameter Preservation**: Maintains hash-specific parameters (salt, iterations, memory cost, etc.)
720
+
721
+ #### Enhanced User Transfer Logic
722
+ - **Smart Password Recreation**: Uses appropriate `create*User` method based on detected hash type
723
+ - **Fallback Mechanism**: Graceful fallback to temporary passwords if hash recreation fails
724
+ - **Hash Options Support**: Preserves algorithm-specific configuration from `hashOptions`
725
+ - **Detailed Logging**: Clear success/failure messages with hash type information
726
+
727
+ #### User Experience Improvements
728
+ - **Accurate Information**: Updated CLI messaging to reflect actual password preservation capabilities
729
+ - **Clear Expectations**: Distinguishes between users who keep passwords vs. those who need reset
730
+ - **Success Feedback**: Detailed reporting of password preservation success rate
731
+ - **Risk Assessment**: Proper warnings only for users who will lose passwords
732
+
733
+ #### Technical Implementation
734
+ - **Hash Type Detection**: `user.hash` field determines creation method
735
+ - **Configuration Parsing**: `user.hashOptions` provides algorithm parameters
736
+ - **Error Resilience**: Comprehensive try-catch with fallback to temporary passwords
737
+ - **Type Safety**: Proper handling of hash option types and parameters
738
+
739
+ #### Migration Benefits
740
+ - **Seamless Login**: Users with preserved hashes can immediately log in with original passwords
741
+ - **Reduced Support**: Dramatically fewer password reset requests after migration
742
+ - **Complete Fidelity**: Maintains original security posture and hash strength
743
+ - **Production Ready**: Safe for live user base migrations
744
+
745
+ #### Usage Examples
746
+ ```bash
747
+ # Users will now preserve passwords during comprehensive transfer
748
+ npx appwrite-utils-cli@latest appwrite-migrate --it
749
+ # Select: 🚀 Comprehensive transfer (users → databases → buckets → functions)
750
+
751
+ # Example output:
752
+ # ✅ User 123 created with preserved argon2 password
753
+ # ✅ User 456 created with preserved bcrypt password
754
+ # ⚠️ User 789 created with temporary password - password reset required
755
+ ```
756
+
757
+ **Breaking Change**: None - fully backward compatible with enhanced capabilities.
758
+
759
+ ### 1.0.8 - Comprehensive Transfer System with Enhanced Rate Limiting
760
+
761
+ **🚀 Complete Cross-Instance Transfer Solution**
762
+
763
+ #### Comprehensive Transfer System
764
+ - **New CLI Option**: `🚀 Comprehensive transfer (users → databases → buckets → functions)` in interactive mode
765
+ - **Orchestrated Transfer Flow**: Proper execution order (users → databases → buckets → functions) for dependency management
766
+ - **Cross-Instance Support**: Transfer entire Appwrite configurations between different instances/projects
767
+ - **Selective Transfer**: Choose which components to transfer (users, databases, buckets, functions)
768
+ - **Dry Run Mode**: Test transfers without making actual changes
769
+
770
+ #### Enhanced Rate Limiting Strategy
771
+ - **Configurable Limits**: 5 to 100 concurrent operations in steps of 5
772
+ - **Differentiated Rates**: Smart rate limiting based on operation type:
773
+ - **General Operations**: Full rate (databases, functions)
774
+ - **User Operations**: Half rate (more sensitive operations)
775
+ - **File Operations**: Quarter rate (most bandwidth intensive)
776
+ - **Visual Feedback**: Real-time rate limit display during transfers
777
+ - **Intelligent Scaling**: Automatic calculation of optimal rates for different operations
778
+
779
+ #### File Transfer Enhancements
780
+ - **File Validation**: Comprehensive integrity checking (empty files, size limits)
781
+ - **Retry Logic**: Exponential backoff for failed file transfers
782
+ - **Error Handling**: Graceful handling of corrupt/invalid files
783
+ - **Progress Tracking**: Real-time progress for large file transfers
784
+
785
+ #### Function Transfer Integration
786
+ - **Automated Function Migration**: Download from source, redeploy to target
787
+ - **Temporary Management**: Automatic cleanup of downloaded function code
788
+ - **Existing Code Integration**: Leverages existing deployment infrastructure
789
+ - **Configuration Preservation**: Maintains function settings and variables
790
+
791
+ #### User Experience Improvements
792
+ - **Password Reset Warnings**: Clear notifications about Appwrite password limitations
793
+ - **Interactive Configuration**: Step-by-step prompts for source/target setup
794
+ - **Comprehensive Reporting**: Detailed transfer summaries with statistics
795
+ - **Smart Confirmations**: Risk-based confirmations for destructive operations
796
+
797
+ #### Technical Implementation
798
+ - **Rate Limiting**: Uses p-limit for concurrent operation control
799
+ - **Error Resilience**: Robust error handling with detailed user feedback
800
+ - **Memory Management**: Efficient processing of large datasets
801
+ - **Progress Tracking**: Real-time progress bars with ETA calculations
802
+
803
+ #### Usage Examples
804
+ ```bash
805
+ # Interactive mode - select comprehensive transfer
806
+ npx appwrite-utils-cli@latest appwrite-migrate --it
807
+
808
+ # Example rate limiting at 20 concurrent:
809
+ # - General operations: 20 concurrent
810
+ # - User operations: 10 concurrent
811
+ # - File operations: 5 concurrent
812
+ ```
813
+
814
+ **Benefits**:
815
+ - Complete Appwrite instance migration capability
816
+ - Intelligent rate limiting prevents API throttling
817
+ - Enhanced file transfer reliability
818
+ - Comprehensive progress tracking and reporting
819
+ - Maintains data integrity across transfers
820
+
821
+ ### 1.0.7 - Forgot to remove debug logs
822
+
823
+ ### 1.0.6 - Cross-Language Constants Generation
824
+
825
+ **🚀 Enhanced Developer Experience with Multi-Language Constants**
826
+
827
+ #### Constants Generation System
828
+ - **Cross-Language Support**: Generate constants in 7 languages for seamless multi-platform development
829
+ - **TypeScript**: Type-safe constants with `as const` and helper types
830
+ - **JavaScript**: ES6 modules with utility arrays
831
+ - **Python**: Class-based constants with snake_case dictionaries
832
+ - **PHP**: Static class methods and associative arrays
833
+ - **Dart**: Maps with individual getter methods (camelCase)
834
+ - **JSON**: Structured data with metadata for cross-platform integration
835
+ - **Environment Variables**: Prefixed environment variables for deployment
836
+ - **Smart Directory Structure**: Constants generated in `{config-folder}/constants/` by default
837
+ - **CLI Integration**: Both command-line and interactive mode support
838
+ - **Custom Output**: Support for custom output directories when needed
839
+
840
+ #### Resource ID Extraction
841
+ - **Database IDs**: Extract all configured database identifiers
842
+ - **Collection IDs**: Generate constants for all collection ULIDs/names
843
+ - **Bucket IDs**: Include storage bucket identifiers
844
+ - **Function IDs**: Support for Appwrite Function identifiers
845
+ - **Naming Conventions**: Language-appropriate naming (UPPER_CASE, camelCase, snake_case)
846
+
847
+ #### Developer Experience Improvements
848
+ - **Interactive Mode**: Checkbox selection for languages with smart defaults
849
+ - **CLI Commands**: Simple `--generateConstants` with language and output options
850
+ - **Type Safety**: Full TypeScript support with generated types and helpers
851
+ - **Cross-Platform Compatibility**: Enable seamless development across different tech stacks
852
+
853
+ #### Usage Examples
854
+ ```bash
855
+ # Default TypeScript generation
856
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --generateConstants
857
+
858
+ # Multi-language generation
859
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --generateConstants --constantsLanguages="typescript,python,php,json"
860
+
861
+ # All formats with custom output
862
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --generateConstants --constantsLanguages="typescript,javascript,python,php,dart,json,env" --constantsOutput="./constants"
863
+ ```
864
+
865
+ **Migration Benefits**:
866
+ - Eliminates hardcoded resource IDs across codebases
867
+ - Enables type-safe resource access in TypeScript projects
868
+ - Supports multi-language development workflows
869
+ - Maintains constants alongside configuration for easy maintenance
870
+
871
+ ### 1.0.1 - Function Templates & Attribute Type Improvements
872
+
873
+ **🚀 Enhanced Function Management & Type System Fixes**
874
+
875
+ #### Function Template System Improvements
876
+ - **ES Module Compatibility**: Fixed `__dirname is not defined` error when creating function templates
877
+ - **Template-Specific Defaults**: Added pre-configured settings for all function templates:
878
+ - `typescript-node`: Node.js 21.0, TypeScript build setup, 0.5vCPU/512MB
879
+ - `uv`: Python 3.12, UV package manager, 0.5vCPU/512MB
880
+ - `count-docs-in-collection`: Node.js 21.0, specialized counting function, 1vCPU/512MB
881
+ - **YAML Config Integration**: Functions now automatically added to YAML config with generated ULIDs
882
+ - **Interactive Enhancement**: Improved template selection with descriptive names and smart defaults
883
+
884
+ #### YAML Collections Loading Fix
885
+ - **Path Resolution**: Fixed collections directory resolution for YAML configurations
886
+ - **Cross-Platform Support**: Collections now properly detected in `.appwrite/collections/` regardless of config location
887
+ - **Backwards Compatibility**: Both TypeScript and YAML collection structures fully supported
888
+
889
+ #### Attribute Type System Overhaul
890
+ - **Double/Float Compatibility**: Resolved Zod discriminated union errors with proper schema separation
891
+ - **Backwards Compatibility**: Full support for both "double" and "float" attribute types
892
+ - **Schema Architecture**: Clean separation with shared base schema for numeric attributes
893
+ - **Type Safety**: Enhanced TypeScript support with proper type inference
894
+
895
+ #### Developer Experience Improvements
896
+ - **Error Resolution**: Eliminated all TypeScript compilation errors
897
+ - **Template Updates**: Updated function template references from deprecated "poetry" to "uv"
898
+ - **Schema Validation**: Improved attribute validation with better error messages
899
+ - **Clean Architecture**: Removed deprecated relationship attributes for better performance
900
+
901
+ #### Bug Fixes
902
+ - Fixed YAML collection path resolution in nested directory structures
903
+ - Resolved ES module compatibility issues in function template creation
904
+ - Eliminated Zod discriminated union conflicts for numeric attribute types
905
+ - Updated outdated template references and improved template selection UX
906
+
907
+ **Migration Notes**:
908
+ - Function templates now automatically integrate with YAML configs
909
+ - Existing collections continue to work; deprecated relationship attributes converted to manual references
910
+ - All numeric attributes now use consistent "double" type with "float" backwards compatibility
911
+
912
+ ### 1.0.0 - YAML-First Architecture & Import System Revolution
913
+
914
+ **🎉 Major Release - Comprehensive Architecture Overhaul**
915
+
916
+ #### YAML-First Configuration System
917
+ - **Complete YAML support** with JSON Schema validation for IntelliSense
918
+ - **Automatic discovery**: `.appwrite/config.yaml`, `appwrite.yaml`, or `appwriteConfig.ts`
919
+ - **Cross-platform compatibility**: No TypeScript runner required
920
+ - **Better organization**: Clean `.appwrite` directory structure
921
+ - **Backward compatibility**: Existing TypeScript configs continue to work
922
+
923
+ #### Import System Revolution (50%+ Complexity Reduction)
924
+ - **Modular architecture**: Extracted DataLoader (1,688 lines) into focused services
925
+ - `DataTransformationService` - Pure data transformation logic
926
+ - `FileHandlerService` - URL downloads and local file handling
927
+ - `UserMappingService` - Sophisticated email/phone deduplication
928
+ - `ValidationService` - Centralized validation with detailed reporting
929
+ - `RelationshipResolver` - Cross-collection ID mapping
930
+ - `ImportOrchestrator` - High-level coordination
931
+ - **Enhanced rate limiting**: Configurable p-limit for different operations
932
+ - `dataInsertion: 5` (concurrent document creation)
933
+ - `fileUpload: 2` (conservative for large files)
934
+ - `validation: 10` (pre-import validation)
935
+ - `dataQuery: 25` (relationship resolution)
936
+
937
+ #### YAML Import Configuration System
938
+ - **Complete YAML import definitions** with JSON Schema support
939
+ - **Advanced file handling**: URL downloads with local file search fallback
940
+ - **Sophisticated validation**: Pre-import validation with detailed error reporting
941
+ - **Template generation**: Easy creation of new import configurations
942
+ - **Relationship mapping**: Intelligent cross-collection ID resolution
943
+ - **User deduplication**: Advanced email/phone matching with merge capabilities
944
+ - **AfterImportActions**: Complete post-import action system
945
+
946
+ #### Enhanced User Experience
947
+ - **Rich visual feedback**: Progress bars with ETA and speed indicators
948
+ - **Smart confirmation dialogs**: Risk-based confirmations for destructive operations
949
+ - **Operation summaries**: Detailed post-operation reports with statistics
950
+ - **Professional messaging**: Unified MessageFormatter with consistent styling
951
+ - **Configurable logging**: Disabled by default, full configuration support
952
+
953
+ #### Performance & Safety Improvements
954
+ - **Batch processing**: Enhanced with progress tracking and memory efficiency
955
+ - **Error resilience**: Improved error handling and recovery mechanisms
956
+ - **Transaction safety**: Better handling of partial failures
957
+ - **Memory optimization**: Efficient processing of large datasets
958
+
959
+ #### Developer Experience
960
+ - **JSON Schema generation**: Full IntelliSense support for YAML files
961
+ - **Example configurations**: Comprehensive templates and examples
962
+ - **Better error messages**: Clear validation and error reporting
963
+ - **Type safety**: Full TypeScript support for all new features
964
+
965
+ ### Changelog
966
+
967
+ - 1.2.18: Fix users transfer comparison not counting email or phone validation as a reason
968
+ - 1.2.17: Fixed users transfer not keeping validation of email / phone, temporarily disable bulk transfer to see if permissions aren't being updated by it
969
+ - 1.2.15: Fixed various transfer and sync functionalities
970
+ - 1.0.5: Fixed `.` directories being ignored. Normally a good thing
971
+ - 1.0.4: Fixed `appwriteConfig.yaml` being the name for the converted config, instead of `config.yaml`
972
+ - 1.0.3: Fixed appwriteConfig detection for `--it` so it detects when you can migrate your config
973
+ - 1.0.2: Fixed migrations, sorry about that!
974
+
975
+ **Migration Note**: While fully backward compatible, we recommend migrating to YAML configuration for the best experience. Use `--setup` to generate new YAML configurations.
976
+
977
+ - 0.10.86: Fixed `selectCollections` not always filtering by `databaseId`
978
+ - 0.10.85: Added logging to `wipeCollection`
979
+ - 0.10.83: Actually fixed the import oops
980
+ - 0.10.82: Fixed the `lodash` import, replaced with `es-toolkit`
981
+ - 0.10.81: Fixed `wipeCollection` -- it wasn't properly deleting all files in a loop
982
+ - 0.10.80: Updated `@njdamstra/appwrite-utils` req
983
+ - 0.10.78: Fixed `attributesSame` so it will properly update attributes that have changed
984
+ - 0.10.77: Added disclaimer to update function specifications for bug
985
+ - 0.10.76: Updated CLI commands to not require an `appwriteConfig.ts` if you set API Key, ProjectId, and Endpoint
986
+ - 0.10.75: Fixed slight issue writing ZOD Schema for collection without any attributes
987
+ - 0.10.74: Fix moving users, should update Labels now
988
+ - 0.10.73: Fix moving users, passwords should work now (from Appwrite, Argon2)
989
+ - 0.10.71: Fix create template function `__dirname`
990
+ - 0.10.70: Fixed `--transfer-users` phones
991
+ - 0.10.67: Added `--transfer-users` boolean flag to also transfer users between projects
992
+ - 0.10.66: Fixed `ignore` always being an empty array, if not set, so it properly ignores the defaults
993
+ - 0.10.65: Fixed the stupid local functions not caring about the ignore string, and added `__pycache__` and `.venv` to default ignores
994
+ - 0.10.64: Fixed `Deploy Function(s)` not ignoring things properly
995
+ - 0.10.63: My `collectLocalFunctions` function was failing to add the `scopes` and a few others to the function, accidentally, fixed now
996
+ - 0.10.62: Made `Deploy Function(s)` also update the functions, as not all things (timeout, specification, etc.) are updated via deploy
997
+ - 0.10.61: Fixed ignore haha, also added `ignore` to the `Functions` config, to specify what to ignore when creating the `.tar.gz` file
998
+ - 0.10.051: Added `node_modules` and a few others to the ignore
999
+ - 0.10.05: Made deploy function into deploy function(s) -- so you can do more than one at a time
1000
+ - 0.10.04: Fixed stupid progress bar not updating -- also fixed double text
1001
+ - 0.10.03: Fixed `syncDb` to push the configurations properly, accidentally hurt it during `synchronizeConfigurations`
1002
+ - 0.10.02: Updated `wipeCollection` to handle errors gracefully
1003
+ - 0.10.01: Fixed `predeployCommands` to work
1004
+ - 0.10.001: Updated `deployFunction` to not updateConfig if it's already present
1005
+ - 0.10.0: Fixed `synchronize configurations` for functions, now you do not need to deploy the function first
1006
+ - 0.9.999: Fixed Functions, looks for `./functions` in addition to `appwriteConfigFolder/functions`
1007
+ - 0.9.998: Fixed transfer finally, added `--targetDbId` and `--sourceDbId` as aliases
1008
+ - 0.9.994: Added function deployment management, in BETA, and fixed document transfer between databases
1009
+ - 0.9.993: Fixed `updateFunctionSpecifications` resetting functions to default with undefined values (oops)
1010
+ - 0.9.992: Added `updateFunctionSpecifications` which lists functions and specifications to allow you to update your functions max CPU and RAM usage per-function
1011
+ - 0.9.990: Fixed `transferFilesLocalToLocal` and `remote` if a document exists with that `$id`, also fixed wipe `"all"` option also wiping the associated buckets
1012
+ - 0.9.983: Fixed `afterImportActions` not resolving
1013
+ - 0.9.981: Try fixing `tryAwaitWithRetry` to catch `522` errors from Cloudflare, they were appearing for some users, also added a 1000ms delay to `tryAwaitWithRetry`
1014
+ - 0.9.98: Fixing some import errors reported by users
1015
+ - 0.9.95: Updated to include new version of `@njdamstra/appwrite-utils`
1016
+ - 0.9.93: Updated `selectDatabases` and `selectCollections` from the interactive CLI to prefer local collections or databases when synchronizing the databases
1017
+ - 0.9.92: Fixed `createOrUpdateAttributes` so it deletes attributes that don't exist in local config when you are running `syncDb`. Also updated the database and collection selection, so it won't try and fetch the collections and databases that don't exist (ones you picked from local config) and error
1018
+ - 0.9.91: Fixed another webpack error, screw you react (but you're supported now so I guess not-screw-you)
1019
+ - 0.9.90: Fixed Webpack errors (why tf does webpack add an extra `default`...???)
1020
+ - 0.9.80: Fixed collections not being unique between local and remote
1021
+ - 0.9.79: Fixed local collections not being considered for the synchronization unless all de-selected
1022
+ - 0.9.78: Added colored text! And also added a lot more customization options as to what to wipe, update, etc.
1023
+ - 0.9.75: Fixed attribute bug
1024
+ - 0.9.72: Fixed my own null bug
1025
+ - 0.9.71: Reverted `node-appwrite` to 14, this seems to fix the xdefault error
1026
+ - 0.9.70: I think I stopped it from deleting attributes, my bad on that
1027
+ - 0.9.68: Temporarily disabled updating Attributes until `updateStringAttribute` is fixed -- it just deletes them now
1028
+ - 0.9.65: Temporary fix for Appwrite's `updateStringAttribute` bug
1029
+ - 0.9.64: Fixed string attribute requiring xdefault
1030
+ - 0.9.61: Remove fileURLToPath -- should hopefully fix windows
1031
+ - 0.9.60: Fix init command to repository URL
1032
+ - 0.9.59: Fix to Windows path names for loading config
1033
+ - 0.9.58: The same as before, I just missed it hah
1034
+ - 0.9.57: Changed generated schema type of `$createdAt` and `$updatedAt` to string from `string | Date` cause honestly if you want a date just parse it
1035
+ - 0.9.56: Changed the updateAttribute so it doesn't always update attributes and hopefully fixed the required error
1036
+ - 0.9.55: Updated to use `node-appwrite@14` for appwrite 1.6.0
1037
+ - 0.9.54: Added small delay (`100ms`) between collection deletions, reduced other delays from `1000` to `500/250ms`
1038
+ - 0.9.53: Reduced delay, went too far
1039
+ - 0.9.52: Add delay after creating indexes, attributes, and others to prevent `fetch failed` errors during large-scale collection creation
1040
+ - 0.9.51: Fix transfer databases, remove "ensure duplicates" check
1041
+ - 0.9.5: Fixed not checking for storage bucket for each database (checking the creation status) when importing data
1042
+ - 0.9.4: Fixed migrations database ensuring it has the required collections
1043
+ - 0.9.3: Fixed deployment error && fix lack of existing `appwriteConfig.ts` file from causing error (you want to be able to setup yeah? haha)
1044
+ - 0.9.2: Added changelog back, whoops
1045
+ - 0.0.90: Updated README with new command-line options and fixed alias issues
1046
+ - 0.0.74: Added `--backup` support, even if only one database
1047
+ - 0.0.73: Fixed weird `workspace` issue
1048
+ - 0.0.72: Remove `ulid` for `ulidx`, fixing compatibility issues
1049
+ - 0.0.71: Slight change to file download logic after errors
1050
+ - 0.0.70: Bump to `node-appwrite` version
1051
+ - 0.0.69: Fixed single ID not getting replaced due to the below change =D also, `nice`
1052
+ - 0.0.68: Fixed the occasional case where, when mapping ID's from old data to new, there would be an array of ID's to match against. `idMappings` now supports arrays.
1053
+ - 0.0.67: Fixed `updates` in `importDef`'s update mappings overwriting postImportActions from the original
1054
+ - 0.0.57: Fixed `dataLoader`'s `idMapping`'s giving me issues
1055
+ - 0.0.55: Added `documentExists` check to batch creation functionality to try to prevent duplicates
1056
+ - 0.0.54: Various fixes in here
1057
+ - 0.0.50: Actually fixed the slight bug, it was really in the `mergeObjects`
1058
+ - 0.0.49: Fixed a slight bug with `dataLoader` not mapping updates correctly with `updateMapping`
1059
+ - 0.0.48: Added `--transfer`, `--fromdb <targetDatabaseId>`, `--targetdb <targetDatabaseId>`, `--transferendpoint <transferEndpoint>`, `--transferproject <transferProjectId>`, `--transferkey <transferApiKey>`. Additionally, I've added `--fromcoll <collectionId>` and `--targetcoll <collectionId>`. These allow you to do a few things. First, you can now transfer databases in the same project, and from local to a remote project. Second, you can now specify specific collections to transfer from one place to another, with all of their data. If `--fromcoll` and `--targetcoll` are ommitted, it will transfer the databases. During the database transfer, it will create any missing collections, attributes, and indices.
1060
+ - 0.0.47: Minor bugfixes in many releases, too small to take note of
1061
+ - 0.0.38: Lots of optimizations done to the code, added `tryAwaitWithRetry` for `fetch failed` and others like it errors (looking at you `server error`) -- this should prevent things from going sideways.
1062
+ - 0.0.37: Added `documentSecurity`, `enabled`, and `$id` to the `init` collection
1063
+ - 0.0.36: Made it update collections by default, sometimes you gotta do what you gotta do
1064
+ - 0.0.35: Added update collection if it exists and permissions or such are different (`documentSecurity` and `enabled`), also added a check for `fetch failed` errors to retry them with recursion, not sure how well that will work out, but we're gonna try it! It will still fail after 5 tries, but hopefully that gives Appwrite some time to figure it's stuff out
1065
+ - 0.0.34: Fixed the `bin` section of the package.json, apparently you can't use `node` to run it
1066
+ - 0.0.33: Fixed `idMappings`, if you are importing data and use the `idMappings` functionality, you can set a `fieldToSet` based on the value of a `sourceField` in the current imported items data (whether it's in the final data or the original), in order to match another field in another collection. So if you had a store, and it had items and the items have a Region ID for instance. You can then, in your regionId of the items, setup an `idMapping` that will allow you to map the value of the `targetField` based on the value of the `targetFieldToMatch` in the `targetCollection`. Sounds complex, but it's very useful. Like psuedo-relationship resolution, without the relationships.
1067
+ - 0.0.29: If you use the `description` variable in an attribute and collection, it'll add that description to the generated schemas. This assumes you have `zod-to-openpi`
1068
+ - 0.0.275: THINGS ARE NOW IN TYPESCRIPT WOOHOO. No but for reaal, super happy to report that everything has been converted to TypeScript, just way too many changes, I hope you enjoy it!
1069
+ - 0.0.274: Small improvement for attribute handling, rather than getting it every attribute, I check the collections attributes
1070
+ - 0.0.273: Small fix for relationship attribute comparisons
1071
+ - 0.0.272: That's what I get for not testing lmao, also updated logic for checking for existing attributes to take the `format` into consideration from the database (URL's are not of `type: "url"`, they are of `format: "url"`)
1072
+ - 0.0.271: Small change to update attributes that are different from each other by deleting the attribute and recreating, as we cannot update most things
1073
+ - 0.0.270: Fixed enums in `--sync`, added optional OpenAPI generation (in progress, almost done, but wanted to push other changes), added `--endpoint`, `--project`, `--key` as optional parameters to change the target destination (shoutout to [pingu24k](https://github.com/pingu2k4) for pointing out these bugs and suggesting those changes for endpoint customization)
1074
+ - 0.0.254: Added `--sync` to synchronize your Appwrite instance with your local `appwriteConfig.yaml` and generate schemas
1075
+ - 0.0.253: Added `--writeData` (or `--write-data`) to command to write the output of the import data to a file called dataLoaderOutput in your root dir
1076
+ - 0.0.23: Added batching to user deletion
1077
+ - 0.0.22: Converted all import processes except `postImportActions` and Relationship Resolution to the local data import, so it should be much faster.
1078
+ - 0.0.6: Added `setTargetFieldFromOtherCollectionDocumentsByMatchingField` for the below, but setting a different field than the field you matched. The names are long, but at least you know what's going on lmao.
1079
+ - 0.0.5: Added `setFieldFromOtherCollectionDocuments` to set an array of ID's for instance from another collection as a `postImportAction`
1080
+ ## Multi-Database Targeting
1081
+
1082
+ You can target the same table/collection to multiple databases by adding `databaseIds` to the definition:
1083
+
1084
+ ```ts
1085
+ // Example: table.ts
1086
+ export default {
1087
+ name: 'Analytics',
1088
+ databaseIds: ['dev', 'staging', 'main'],
1089
+ attributes: [
1090
+ { key: 'timestamp', type: 'datetime', required: true },
1091
+ { key: 'totalUsers', type: 'integer' }
1092
+ ],
1093
+ indexes: [{ key: 'ts_idx', type: 'key', attributes: ['timestamp'] }]
1094
+ };
1095
+ ```
1096
+
1097
+ During push, this table will appear under each selected database whose ID matches `databaseIds`.
1098
+
1099
+ ## Per-Function Configuration (.fnconfig.yaml)
1100
+
1101
+ You can define functions in per-directory YAML files named `.fnconfig.yaml` (or `.fnconfig.yml`), discovered anywhere under your git repository root:
1102
+
1103
+ ```yaml
1104
+ # ./functions/reporting/.fnconfig.yaml
1105
+ id: reporting
1106
+ name: Reporting
1107
+ runtime: node-22.0
1108
+ execute: ["any"]
1109
+ events: []
1110
+ dirPath: ./ # defaults to the directory containing this file
1111
+ commands: npm install
1112
+ entrypoint: index.js
1113
+ ```
1114
+
1115
+ Rules:
1116
+ - If `dirPath` starts with `~`, it expands to your home directory
1117
+ - Relative `dirPath` resolves against the `.fnconfig.yaml` directory
1118
+ - Absolute `dirPath` is used as-is
1119
+ - `.fnconfig.yaml` definitions merge with central `.appwrite/config.yaml` functions; if the same `$id` exists in both, `.fnconfig.yaml` overrides
1120
+
1121
+ Deployment uses the merged function set and resolves paths according to these rules.
1122
+ ### Generate Constants
1123
+
1124
+ Select which languages and which categories to generate (databases, collections/tables, buckets, functions):
1125
+
1126
+ ```bash
1127
+ npx @njdamstra/appwrite-utils-cli appwrite-migrate --it
1128
+ # Choose: Generate cross-language constants
1129
+ # Select languages (TS/JS/Python/PHP/Dart/JSON/Env)
1130
+ # Select categories to include
1131
+ ```
1132
+
1133
+ Constants are written to a configurable output directory under `.appwrite/` by default.