appwrite-utils-cli 1.6.2 → 1.6.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 (62) hide show
  1. package/CONFIG_TODO.md +1189 -0
  2. package/SERVICE_IMPLEMENTATION_REPORT.md +462 -0
  3. package/dist/cli/commands/configCommands.js +7 -1
  4. package/dist/cli/commands/databaseCommands.js +23 -15
  5. package/dist/collections/attributes.d.ts +1 -1
  6. package/dist/collections/attributes.js +163 -66
  7. package/dist/collections/indexes.js +3 -17
  8. package/dist/collections/methods.js +38 -0
  9. package/dist/config/ConfigManager.d.ts +445 -0
  10. package/dist/config/ConfigManager.js +625 -0
  11. package/dist/config/index.d.ts +8 -0
  12. package/dist/config/index.js +7 -0
  13. package/dist/config/services/ConfigDiscoveryService.d.ts +126 -0
  14. package/dist/config/services/ConfigDiscoveryService.js +374 -0
  15. package/dist/config/services/ConfigLoaderService.d.ts +105 -0
  16. package/dist/config/services/ConfigLoaderService.js +410 -0
  17. package/dist/config/services/ConfigMergeService.d.ts +208 -0
  18. package/dist/config/services/ConfigMergeService.js +307 -0
  19. package/dist/config/services/ConfigValidationService.d.ts +214 -0
  20. package/dist/config/services/ConfigValidationService.js +310 -0
  21. package/dist/config/services/SessionAuthService.d.ts +225 -0
  22. package/dist/config/services/SessionAuthService.js +456 -0
  23. package/dist/config/services/__tests__/ConfigMergeService.test.d.ts +1 -0
  24. package/dist/config/services/__tests__/ConfigMergeService.test.js +271 -0
  25. package/dist/config/services/index.d.ts +13 -0
  26. package/dist/config/services/index.js +10 -0
  27. package/dist/interactiveCLI.js +8 -6
  28. package/dist/main.js +2 -2
  29. package/dist/migrations/yaml/YamlImportConfigLoader.d.ts +1 -1
  30. package/dist/shared/operationQueue.js +1 -1
  31. package/dist/utils/ClientFactory.d.ts +87 -0
  32. package/dist/utils/ClientFactory.js +164 -0
  33. package/dist/utils/getClientFromConfig.js +4 -3
  34. package/dist/utils/helperFunctions.d.ts +1 -0
  35. package/dist/utils/helperFunctions.js +21 -5
  36. package/dist/utils/yamlConverter.d.ts +2 -0
  37. package/dist/utils/yamlConverter.js +21 -4
  38. package/dist/utilsController.d.ts +18 -15
  39. package/dist/utilsController.js +83 -131
  40. package/package.json +1 -1
  41. package/src/cli/commands/configCommands.ts +8 -1
  42. package/src/cli/commands/databaseCommands.ts +34 -20
  43. package/src/collections/attributes.ts +195 -150
  44. package/src/collections/indexes.ts +4 -19
  45. package/src/collections/methods.ts +46 -0
  46. package/src/config/ConfigManager.ts +808 -0
  47. package/src/config/index.ts +10 -0
  48. package/src/config/services/ConfigDiscoveryService.ts +463 -0
  49. package/src/config/services/ConfigLoaderService.ts +560 -0
  50. package/src/config/services/ConfigMergeService.ts +386 -0
  51. package/src/config/services/ConfigValidationService.ts +394 -0
  52. package/src/config/services/SessionAuthService.ts +565 -0
  53. package/src/config/services/__tests__/ConfigMergeService.test.ts +351 -0
  54. package/src/config/services/index.ts +29 -0
  55. package/src/interactiveCLI.ts +9 -7
  56. package/src/main.ts +2 -2
  57. package/src/shared/operationQueue.ts +1 -1
  58. package/src/utils/ClientFactory.ts +186 -0
  59. package/src/utils/getClientFromConfig.ts +4 -3
  60. package/src/utils/helperFunctions.ts +27 -7
  61. package/src/utils/yamlConverter.ts +28 -2
  62. package/src/utilsController.ts +99 -187
@@ -518,6 +518,52 @@ export const createOrUpdateCollectionsViaAdapter = async (
518
518
  }
519
519
  }
520
520
 
521
+ // Wait for all attributes to become available before creating indexes
522
+ const allAttrKeys = [
523
+ ...nonRel.map((a: any) => a.key),
524
+ ...rels.filter((a: any) => a.relatedCollection).map((a: any) => a.key)
525
+ ];
526
+
527
+ if (allAttrKeys.length > 0) {
528
+ for (const attrKey of allAttrKeys) {
529
+ const maxWait = 60000; // 60 seconds
530
+ const startTime = Date.now();
531
+ let lastStatus = '';
532
+
533
+ while (Date.now() - startTime < maxWait) {
534
+ try {
535
+ const tableData = await adapter.getTable({ databaseId, tableId });
536
+ const attrs = (tableData as any).attributes || [];
537
+ const attr = attrs.find((a: any) => a.key === attrKey);
538
+
539
+ if (attr) {
540
+ if (attr.status === 'available') {
541
+ break; // Attribute is ready
542
+ }
543
+ if (attr.status === 'failed' || attr.status === 'stuck') {
544
+ throw new Error(`Attribute ${attrKey} failed to create: ${attr.error || 'unknown error'}`);
545
+ }
546
+ // Still processing, continue waiting
547
+ lastStatus = attr.status;
548
+ }
549
+
550
+ await delay(2000); // Check every 2 seconds
551
+ } catch (e) {
552
+ // If we can't check status, assume it's processing and continue
553
+ await delay(2000);
554
+ }
555
+ }
556
+
557
+ // Timeout check
558
+ if (Date.now() - startTime >= maxWait) {
559
+ MessageFormatter.warning(
560
+ `Attribute ${attrKey} did not become available within ${maxWait / 1000}s (last status: ${lastStatus}). Proceeding anyway.`,
561
+ { prefix: 'Attributes' }
562
+ );
563
+ }
564
+ }
565
+ }
566
+
521
567
  // Indexes
522
568
  const idxs = (indexes || []) as any[];
523
569
  for (const idx of idxs) {