@njdamstra/appwrite-utils-cli 1.10.0 → 1.11.0
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.
- package/dist/cli/commands/migrateCommands.d.ts +6 -0
- package/dist/cli/commands/migrateCommands.js +118 -0
- package/dist/collections/attributes.js +83 -0
- package/dist/collections/indexes.js +1 -1
- package/dist/collections/tableOperations.js +35 -0
- package/dist/interactiveCLI.js +7 -1
- package/dist/main.js +56 -0
- package/dist/migrations/appwriteToX.d.ts +96 -0
- package/dist/migrations/dataLoader.d.ts +194 -2
- package/dist/migrations/migrateStrings.d.ts +9 -0
- package/dist/migrations/migrateStrings.js +724 -0
- package/dist/migrations/migrateStringsTypes.d.ts +195 -0
- package/dist/migrations/migrateStringsTypes.js +117 -0
- package/dist/storage/schemas.d.ts +384 -0
- package/package.json +4 -4
- package/src/cli/commands/migrateCommands.ts +157 -0
- package/src/collections/attributes.ts +152 -0
- package/src/collections/indexes.ts +3 -3
- package/src/collections/tableOperations.ts +35 -0
- package/src/functions/methods.ts +2 -2
- package/src/interactiveCLI.ts +9 -3
- package/src/main.ts +69 -0
- package/src/migrations/migrateStrings.ts +1064 -0
- package/src/migrations/migrateStringsTypes.ts +158 -0
|
@@ -91,6 +91,63 @@ export declare const getMigrationCollectionSchemas: () => {
|
|
|
91
91
|
error?: string | undefined;
|
|
92
92
|
xdefault?: string | null | undefined;
|
|
93
93
|
encrypt?: boolean | undefined;
|
|
94
|
+
} | {
|
|
95
|
+
key: string;
|
|
96
|
+
required: boolean;
|
|
97
|
+
type: "varchar";
|
|
98
|
+
size: number;
|
|
99
|
+
array?: boolean | undefined;
|
|
100
|
+
format?: string | undefined;
|
|
101
|
+
status?: string | undefined;
|
|
102
|
+
attributes?: string[] | undefined;
|
|
103
|
+
orders?: string[] | undefined;
|
|
104
|
+
$createdAt?: string | undefined;
|
|
105
|
+
$updatedAt?: string | undefined;
|
|
106
|
+
error?: string | undefined;
|
|
107
|
+
xdefault?: string | null | undefined;
|
|
108
|
+
encrypt?: boolean | undefined;
|
|
109
|
+
} | {
|
|
110
|
+
key: string;
|
|
111
|
+
required: boolean;
|
|
112
|
+
type: "text";
|
|
113
|
+
array?: boolean | undefined;
|
|
114
|
+
format?: string | undefined;
|
|
115
|
+
status?: string | undefined;
|
|
116
|
+
attributes?: string[] | undefined;
|
|
117
|
+
orders?: string[] | undefined;
|
|
118
|
+
$createdAt?: string | undefined;
|
|
119
|
+
$updatedAt?: string | undefined;
|
|
120
|
+
error?: string | undefined;
|
|
121
|
+
xdefault?: string | null | undefined;
|
|
122
|
+
encrypt?: boolean | undefined;
|
|
123
|
+
} | {
|
|
124
|
+
key: string;
|
|
125
|
+
required: boolean;
|
|
126
|
+
type: "mediumtext";
|
|
127
|
+
array?: boolean | undefined;
|
|
128
|
+
format?: string | undefined;
|
|
129
|
+
status?: string | undefined;
|
|
130
|
+
attributes?: string[] | undefined;
|
|
131
|
+
orders?: string[] | undefined;
|
|
132
|
+
$createdAt?: string | undefined;
|
|
133
|
+
$updatedAt?: string | undefined;
|
|
134
|
+
error?: string | undefined;
|
|
135
|
+
xdefault?: string | null | undefined;
|
|
136
|
+
encrypt?: boolean | undefined;
|
|
137
|
+
} | {
|
|
138
|
+
key: string;
|
|
139
|
+
required: boolean;
|
|
140
|
+
type: "longtext";
|
|
141
|
+
array?: boolean | undefined;
|
|
142
|
+
format?: string | undefined;
|
|
143
|
+
status?: string | undefined;
|
|
144
|
+
attributes?: string[] | undefined;
|
|
145
|
+
orders?: string[] | undefined;
|
|
146
|
+
$createdAt?: string | undefined;
|
|
147
|
+
$updatedAt?: string | undefined;
|
|
148
|
+
error?: string | undefined;
|
|
149
|
+
xdefault?: string | null | undefined;
|
|
150
|
+
encrypt?: boolean | undefined;
|
|
94
151
|
} | {
|
|
95
152
|
key: string;
|
|
96
153
|
required: boolean;
|
|
@@ -215,6 +272,45 @@ export declare const getMigrationCollectionSchemas: () => {
|
|
|
215
272
|
$updatedAt?: string | undefined;
|
|
216
273
|
error?: string | undefined;
|
|
217
274
|
xdefault?: string | null | undefined;
|
|
275
|
+
} | {
|
|
276
|
+
key: string;
|
|
277
|
+
required: boolean;
|
|
278
|
+
type: "point";
|
|
279
|
+
array?: boolean | undefined;
|
|
280
|
+
format?: string | undefined;
|
|
281
|
+
status?: string | undefined;
|
|
282
|
+
attributes?: string[] | undefined;
|
|
283
|
+
orders?: string[] | undefined;
|
|
284
|
+
$createdAt?: string | undefined;
|
|
285
|
+
$updatedAt?: string | undefined;
|
|
286
|
+
error?: string | undefined;
|
|
287
|
+
xdefault?: number[] | null | undefined;
|
|
288
|
+
} | {
|
|
289
|
+
key: string;
|
|
290
|
+
required: boolean;
|
|
291
|
+
type: "line";
|
|
292
|
+
array?: boolean | undefined;
|
|
293
|
+
format?: string | undefined;
|
|
294
|
+
status?: string | undefined;
|
|
295
|
+
attributes?: string[] | undefined;
|
|
296
|
+
orders?: string[] | undefined;
|
|
297
|
+
$createdAt?: string | undefined;
|
|
298
|
+
$updatedAt?: string | undefined;
|
|
299
|
+
error?: string | undefined;
|
|
300
|
+
xdefault?: number[][] | null | undefined;
|
|
301
|
+
} | {
|
|
302
|
+
key: string;
|
|
303
|
+
required: boolean;
|
|
304
|
+
type: "polygon";
|
|
305
|
+
array?: boolean | undefined;
|
|
306
|
+
format?: string | undefined;
|
|
307
|
+
status?: string | undefined;
|
|
308
|
+
attributes?: string[] | undefined;
|
|
309
|
+
orders?: string[] | undefined;
|
|
310
|
+
$createdAt?: string | undefined;
|
|
311
|
+
$updatedAt?: string | undefined;
|
|
312
|
+
error?: string | undefined;
|
|
313
|
+
xdefault?: number[][][] | null | undefined;
|
|
218
314
|
} | {
|
|
219
315
|
key: string;
|
|
220
316
|
required: boolean;
|
|
@@ -308,6 +404,63 @@ export declare const getMigrationCollectionSchemas: () => {
|
|
|
308
404
|
error?: string | undefined;
|
|
309
405
|
xdefault?: string | null | undefined;
|
|
310
406
|
encrypt?: boolean | undefined;
|
|
407
|
+
} | {
|
|
408
|
+
key: string;
|
|
409
|
+
required: boolean;
|
|
410
|
+
type: "varchar";
|
|
411
|
+
size: number;
|
|
412
|
+
array?: boolean | undefined;
|
|
413
|
+
format?: string | undefined;
|
|
414
|
+
status?: string | undefined;
|
|
415
|
+
attributes?: string[] | undefined;
|
|
416
|
+
orders?: string[] | undefined;
|
|
417
|
+
$createdAt?: string | undefined;
|
|
418
|
+
$updatedAt?: string | undefined;
|
|
419
|
+
error?: string | undefined;
|
|
420
|
+
xdefault?: string | null | undefined;
|
|
421
|
+
encrypt?: boolean | undefined;
|
|
422
|
+
} | {
|
|
423
|
+
key: string;
|
|
424
|
+
required: boolean;
|
|
425
|
+
type: "text";
|
|
426
|
+
array?: boolean | undefined;
|
|
427
|
+
format?: string | undefined;
|
|
428
|
+
status?: string | undefined;
|
|
429
|
+
attributes?: string[] | undefined;
|
|
430
|
+
orders?: string[] | undefined;
|
|
431
|
+
$createdAt?: string | undefined;
|
|
432
|
+
$updatedAt?: string | undefined;
|
|
433
|
+
error?: string | undefined;
|
|
434
|
+
xdefault?: string | null | undefined;
|
|
435
|
+
encrypt?: boolean | undefined;
|
|
436
|
+
} | {
|
|
437
|
+
key: string;
|
|
438
|
+
required: boolean;
|
|
439
|
+
type: "mediumtext";
|
|
440
|
+
array?: boolean | undefined;
|
|
441
|
+
format?: string | undefined;
|
|
442
|
+
status?: string | undefined;
|
|
443
|
+
attributes?: string[] | undefined;
|
|
444
|
+
orders?: string[] | undefined;
|
|
445
|
+
$createdAt?: string | undefined;
|
|
446
|
+
$updatedAt?: string | undefined;
|
|
447
|
+
error?: string | undefined;
|
|
448
|
+
xdefault?: string | null | undefined;
|
|
449
|
+
encrypt?: boolean | undefined;
|
|
450
|
+
} | {
|
|
451
|
+
key: string;
|
|
452
|
+
required: boolean;
|
|
453
|
+
type: "longtext";
|
|
454
|
+
array?: boolean | undefined;
|
|
455
|
+
format?: string | undefined;
|
|
456
|
+
status?: string | undefined;
|
|
457
|
+
attributes?: string[] | undefined;
|
|
458
|
+
orders?: string[] | undefined;
|
|
459
|
+
$createdAt?: string | undefined;
|
|
460
|
+
$updatedAt?: string | undefined;
|
|
461
|
+
error?: string | undefined;
|
|
462
|
+
xdefault?: string | null | undefined;
|
|
463
|
+
encrypt?: boolean | undefined;
|
|
311
464
|
} | {
|
|
312
465
|
key: string;
|
|
313
466
|
required: boolean;
|
|
@@ -432,6 +585,45 @@ export declare const getMigrationCollectionSchemas: () => {
|
|
|
432
585
|
$updatedAt?: string | undefined;
|
|
433
586
|
error?: string | undefined;
|
|
434
587
|
xdefault?: string | null | undefined;
|
|
588
|
+
} | {
|
|
589
|
+
key: string;
|
|
590
|
+
required: boolean;
|
|
591
|
+
type: "point";
|
|
592
|
+
array?: boolean | undefined;
|
|
593
|
+
format?: string | undefined;
|
|
594
|
+
status?: string | undefined;
|
|
595
|
+
attributes?: string[] | undefined;
|
|
596
|
+
orders?: string[] | undefined;
|
|
597
|
+
$createdAt?: string | undefined;
|
|
598
|
+
$updatedAt?: string | undefined;
|
|
599
|
+
error?: string | undefined;
|
|
600
|
+
xdefault?: number[] | null | undefined;
|
|
601
|
+
} | {
|
|
602
|
+
key: string;
|
|
603
|
+
required: boolean;
|
|
604
|
+
type: "line";
|
|
605
|
+
array?: boolean | undefined;
|
|
606
|
+
format?: string | undefined;
|
|
607
|
+
status?: string | undefined;
|
|
608
|
+
attributes?: string[] | undefined;
|
|
609
|
+
orders?: string[] | undefined;
|
|
610
|
+
$createdAt?: string | undefined;
|
|
611
|
+
$updatedAt?: string | undefined;
|
|
612
|
+
error?: string | undefined;
|
|
613
|
+
xdefault?: number[][] | null | undefined;
|
|
614
|
+
} | {
|
|
615
|
+
key: string;
|
|
616
|
+
required: boolean;
|
|
617
|
+
type: "polygon";
|
|
618
|
+
array?: boolean | undefined;
|
|
619
|
+
format?: string | undefined;
|
|
620
|
+
status?: string | undefined;
|
|
621
|
+
attributes?: string[] | undefined;
|
|
622
|
+
orders?: string[] | undefined;
|
|
623
|
+
$createdAt?: string | undefined;
|
|
624
|
+
$updatedAt?: string | undefined;
|
|
625
|
+
error?: string | undefined;
|
|
626
|
+
xdefault?: number[][][] | null | undefined;
|
|
435
627
|
} | {
|
|
436
628
|
key: string;
|
|
437
629
|
required: boolean;
|
|
@@ -474,6 +666,63 @@ export declare const getMigrationCollectionSchemas: () => {
|
|
|
474
666
|
error?: string | undefined;
|
|
475
667
|
xdefault?: string | null | undefined;
|
|
476
668
|
encrypt?: boolean | undefined;
|
|
669
|
+
} | {
|
|
670
|
+
key: string;
|
|
671
|
+
required: boolean;
|
|
672
|
+
type: "varchar";
|
|
673
|
+
size: number;
|
|
674
|
+
array?: boolean | undefined;
|
|
675
|
+
format?: string | undefined;
|
|
676
|
+
status?: string | undefined;
|
|
677
|
+
attributes?: string[] | undefined;
|
|
678
|
+
orders?: string[] | undefined;
|
|
679
|
+
$createdAt?: string | undefined;
|
|
680
|
+
$updatedAt?: string | undefined;
|
|
681
|
+
error?: string | undefined;
|
|
682
|
+
xdefault?: string | null | undefined;
|
|
683
|
+
encrypt?: boolean | undefined;
|
|
684
|
+
} | {
|
|
685
|
+
key: string;
|
|
686
|
+
required: boolean;
|
|
687
|
+
type: "text";
|
|
688
|
+
array?: boolean | undefined;
|
|
689
|
+
format?: string | undefined;
|
|
690
|
+
status?: string | undefined;
|
|
691
|
+
attributes?: string[] | undefined;
|
|
692
|
+
orders?: string[] | undefined;
|
|
693
|
+
$createdAt?: string | undefined;
|
|
694
|
+
$updatedAt?: string | undefined;
|
|
695
|
+
error?: string | undefined;
|
|
696
|
+
xdefault?: string | null | undefined;
|
|
697
|
+
encrypt?: boolean | undefined;
|
|
698
|
+
} | {
|
|
699
|
+
key: string;
|
|
700
|
+
required: boolean;
|
|
701
|
+
type: "mediumtext";
|
|
702
|
+
array?: boolean | undefined;
|
|
703
|
+
format?: string | undefined;
|
|
704
|
+
status?: string | undefined;
|
|
705
|
+
attributes?: string[] | undefined;
|
|
706
|
+
orders?: string[] | undefined;
|
|
707
|
+
$createdAt?: string | undefined;
|
|
708
|
+
$updatedAt?: string | undefined;
|
|
709
|
+
error?: string | undefined;
|
|
710
|
+
xdefault?: string | null | undefined;
|
|
711
|
+
encrypt?: boolean | undefined;
|
|
712
|
+
} | {
|
|
713
|
+
key: string;
|
|
714
|
+
required: boolean;
|
|
715
|
+
type: "longtext";
|
|
716
|
+
array?: boolean | undefined;
|
|
717
|
+
format?: string | undefined;
|
|
718
|
+
status?: string | undefined;
|
|
719
|
+
attributes?: string[] | undefined;
|
|
720
|
+
orders?: string[] | undefined;
|
|
721
|
+
$createdAt?: string | undefined;
|
|
722
|
+
$updatedAt?: string | undefined;
|
|
723
|
+
error?: string | undefined;
|
|
724
|
+
xdefault?: string | null | undefined;
|
|
725
|
+
encrypt?: boolean | undefined;
|
|
477
726
|
} | {
|
|
478
727
|
key: string;
|
|
479
728
|
required: boolean;
|
|
@@ -598,6 +847,45 @@ export declare const getMigrationCollectionSchemas: () => {
|
|
|
598
847
|
$updatedAt?: string | undefined;
|
|
599
848
|
error?: string | undefined;
|
|
600
849
|
xdefault?: string | null | undefined;
|
|
850
|
+
} | {
|
|
851
|
+
key: string;
|
|
852
|
+
required: boolean;
|
|
853
|
+
type: "point";
|
|
854
|
+
array?: boolean | undefined;
|
|
855
|
+
format?: string | undefined;
|
|
856
|
+
status?: string | undefined;
|
|
857
|
+
attributes?: string[] | undefined;
|
|
858
|
+
orders?: string[] | undefined;
|
|
859
|
+
$createdAt?: string | undefined;
|
|
860
|
+
$updatedAt?: string | undefined;
|
|
861
|
+
error?: string | undefined;
|
|
862
|
+
xdefault?: number[] | null | undefined;
|
|
863
|
+
} | {
|
|
864
|
+
key: string;
|
|
865
|
+
required: boolean;
|
|
866
|
+
type: "line";
|
|
867
|
+
array?: boolean | undefined;
|
|
868
|
+
format?: string | undefined;
|
|
869
|
+
status?: string | undefined;
|
|
870
|
+
attributes?: string[] | undefined;
|
|
871
|
+
orders?: string[] | undefined;
|
|
872
|
+
$createdAt?: string | undefined;
|
|
873
|
+
$updatedAt?: string | undefined;
|
|
874
|
+
error?: string | undefined;
|
|
875
|
+
xdefault?: number[][] | null | undefined;
|
|
876
|
+
} | {
|
|
877
|
+
key: string;
|
|
878
|
+
required: boolean;
|
|
879
|
+
type: "polygon";
|
|
880
|
+
array?: boolean | undefined;
|
|
881
|
+
format?: string | undefined;
|
|
882
|
+
status?: string | undefined;
|
|
883
|
+
attributes?: string[] | undefined;
|
|
884
|
+
orders?: string[] | undefined;
|
|
885
|
+
$createdAt?: string | undefined;
|
|
886
|
+
$updatedAt?: string | undefined;
|
|
887
|
+
error?: string | undefined;
|
|
888
|
+
xdefault?: number[][][] | null | undefined;
|
|
601
889
|
} | {
|
|
602
890
|
key: string;
|
|
603
891
|
required: boolean;
|
|
@@ -691,6 +979,63 @@ export declare const getMigrationCollectionSchemas: () => {
|
|
|
691
979
|
error?: string | undefined;
|
|
692
980
|
xdefault?: string | null | undefined;
|
|
693
981
|
encrypt?: boolean | undefined;
|
|
982
|
+
} | {
|
|
983
|
+
key: string;
|
|
984
|
+
required: boolean;
|
|
985
|
+
type: "varchar";
|
|
986
|
+
size: number;
|
|
987
|
+
array?: boolean | undefined;
|
|
988
|
+
format?: string | undefined;
|
|
989
|
+
status?: string | undefined;
|
|
990
|
+
attributes?: string[] | undefined;
|
|
991
|
+
orders?: string[] | undefined;
|
|
992
|
+
$createdAt?: string | undefined;
|
|
993
|
+
$updatedAt?: string | undefined;
|
|
994
|
+
error?: string | undefined;
|
|
995
|
+
xdefault?: string | null | undefined;
|
|
996
|
+
encrypt?: boolean | undefined;
|
|
997
|
+
} | {
|
|
998
|
+
key: string;
|
|
999
|
+
required: boolean;
|
|
1000
|
+
type: "text";
|
|
1001
|
+
array?: boolean | undefined;
|
|
1002
|
+
format?: string | undefined;
|
|
1003
|
+
status?: string | undefined;
|
|
1004
|
+
attributes?: string[] | undefined;
|
|
1005
|
+
orders?: string[] | undefined;
|
|
1006
|
+
$createdAt?: string | undefined;
|
|
1007
|
+
$updatedAt?: string | undefined;
|
|
1008
|
+
error?: string | undefined;
|
|
1009
|
+
xdefault?: string | null | undefined;
|
|
1010
|
+
encrypt?: boolean | undefined;
|
|
1011
|
+
} | {
|
|
1012
|
+
key: string;
|
|
1013
|
+
required: boolean;
|
|
1014
|
+
type: "mediumtext";
|
|
1015
|
+
array?: boolean | undefined;
|
|
1016
|
+
format?: string | undefined;
|
|
1017
|
+
status?: string | undefined;
|
|
1018
|
+
attributes?: string[] | undefined;
|
|
1019
|
+
orders?: string[] | undefined;
|
|
1020
|
+
$createdAt?: string | undefined;
|
|
1021
|
+
$updatedAt?: string | undefined;
|
|
1022
|
+
error?: string | undefined;
|
|
1023
|
+
xdefault?: string | null | undefined;
|
|
1024
|
+
encrypt?: boolean | undefined;
|
|
1025
|
+
} | {
|
|
1026
|
+
key: string;
|
|
1027
|
+
required: boolean;
|
|
1028
|
+
type: "longtext";
|
|
1029
|
+
array?: boolean | undefined;
|
|
1030
|
+
format?: string | undefined;
|
|
1031
|
+
status?: string | undefined;
|
|
1032
|
+
attributes?: string[] | undefined;
|
|
1033
|
+
orders?: string[] | undefined;
|
|
1034
|
+
$createdAt?: string | undefined;
|
|
1035
|
+
$updatedAt?: string | undefined;
|
|
1036
|
+
error?: string | undefined;
|
|
1037
|
+
xdefault?: string | null | undefined;
|
|
1038
|
+
encrypt?: boolean | undefined;
|
|
694
1039
|
} | {
|
|
695
1040
|
key: string;
|
|
696
1041
|
required: boolean;
|
|
@@ -815,6 +1160,45 @@ export declare const getMigrationCollectionSchemas: () => {
|
|
|
815
1160
|
$updatedAt?: string | undefined;
|
|
816
1161
|
error?: string | undefined;
|
|
817
1162
|
xdefault?: string | null | undefined;
|
|
1163
|
+
} | {
|
|
1164
|
+
key: string;
|
|
1165
|
+
required: boolean;
|
|
1166
|
+
type: "point";
|
|
1167
|
+
array?: boolean | undefined;
|
|
1168
|
+
format?: string | undefined;
|
|
1169
|
+
status?: string | undefined;
|
|
1170
|
+
attributes?: string[] | undefined;
|
|
1171
|
+
orders?: string[] | undefined;
|
|
1172
|
+
$createdAt?: string | undefined;
|
|
1173
|
+
$updatedAt?: string | undefined;
|
|
1174
|
+
error?: string | undefined;
|
|
1175
|
+
xdefault?: number[] | null | undefined;
|
|
1176
|
+
} | {
|
|
1177
|
+
key: string;
|
|
1178
|
+
required: boolean;
|
|
1179
|
+
type: "line";
|
|
1180
|
+
array?: boolean | undefined;
|
|
1181
|
+
format?: string | undefined;
|
|
1182
|
+
status?: string | undefined;
|
|
1183
|
+
attributes?: string[] | undefined;
|
|
1184
|
+
orders?: string[] | undefined;
|
|
1185
|
+
$createdAt?: string | undefined;
|
|
1186
|
+
$updatedAt?: string | undefined;
|
|
1187
|
+
error?: string | undefined;
|
|
1188
|
+
xdefault?: number[][] | null | undefined;
|
|
1189
|
+
} | {
|
|
1190
|
+
key: string;
|
|
1191
|
+
required: boolean;
|
|
1192
|
+
type: "polygon";
|
|
1193
|
+
array?: boolean | undefined;
|
|
1194
|
+
format?: string | undefined;
|
|
1195
|
+
status?: string | undefined;
|
|
1196
|
+
attributes?: string[] | undefined;
|
|
1197
|
+
orders?: string[] | undefined;
|
|
1198
|
+
$createdAt?: string | undefined;
|
|
1199
|
+
$updatedAt?: string | undefined;
|
|
1200
|
+
error?: string | undefined;
|
|
1201
|
+
xdefault?: number[][][] | null | undefined;
|
|
818
1202
|
} | {
|
|
819
1203
|
key: string;
|
|
820
1204
|
required: boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@njdamstra/appwrite-utils-cli",
|
|
3
3
|
"description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.11.0",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@types/inquirer": "^9.0.8",
|
|
40
40
|
"@types/json-schema": "^7.0.15",
|
|
41
41
|
"@types/yargs": "^17.0.33",
|
|
42
|
-
"@njdamstra/appwrite-utils": "^1.7.
|
|
43
|
-
"@njdamstra/appwrite-utils-helpers": "^0.1.
|
|
42
|
+
"@njdamstra/appwrite-utils": "^1.7.1",
|
|
43
|
+
"@njdamstra/appwrite-utils-helpers": "^0.1.2",
|
|
44
44
|
"chalk": "^5.4.1",
|
|
45
45
|
"cli-progress": "^3.12.0",
|
|
46
46
|
"commander": "^12.1.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"jszip": "^3.10.1",
|
|
54
54
|
"luxon": "^3.6.1",
|
|
55
55
|
"nanostores": "^0.10.3",
|
|
56
|
-
"node-appwrite": "^
|
|
56
|
+
"node-appwrite": "^22.1.2",
|
|
57
57
|
"p-limit": "^6.2.0",
|
|
58
58
|
"papaparse": "^5.5.3",
|
|
59
59
|
"tar": "^7.4.3",
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { MessageFormatter } from "@njdamstra/appwrite-utils-helpers";
|
|
4
|
+
import type { InteractiveCLI } from "../../interactiveCLI.js";
|
|
5
|
+
import {
|
|
6
|
+
analyzeStringAttributes,
|
|
7
|
+
executeMigrationPlan,
|
|
8
|
+
} from "../../migrations/migrateStrings.js";
|
|
9
|
+
import type { AnalyzeOptions, ExecuteOptions } from "../../migrations/migrateStringsTypes.js";
|
|
10
|
+
|
|
11
|
+
export const migrateCommands = {
|
|
12
|
+
async migrateStrings(cli: InteractiveCLI): Promise<void> {
|
|
13
|
+
const { phase } = await inquirer.prompt([
|
|
14
|
+
{
|
|
15
|
+
type: "list",
|
|
16
|
+
name: "phase",
|
|
17
|
+
message: "String attribute migration:",
|
|
18
|
+
choices: [
|
|
19
|
+
{
|
|
20
|
+
name: "Analyze — scan local configs, generate migration plan (YAML)",
|
|
21
|
+
value: "analyze",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "Execute — run a migration plan against Appwrite server",
|
|
25
|
+
value: "execute",
|
|
26
|
+
},
|
|
27
|
+
{ name: "Back", value: "back" },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
if (phase === "back") return;
|
|
33
|
+
if (phase === "analyze") {
|
|
34
|
+
await migrateCommands.analyzePhase(cli);
|
|
35
|
+
} else {
|
|
36
|
+
await migrateCommands.executePhase(cli);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
async analyzePhase(cli: InteractiveCLI): Promise<void> {
|
|
41
|
+
const controller = (cli as any).controller;
|
|
42
|
+
if (!controller?.config) {
|
|
43
|
+
MessageFormatter.error(
|
|
44
|
+
"No configuration loaded. Make sure you have a valid .appwrite config.",
|
|
45
|
+
undefined,
|
|
46
|
+
{ prefix: "Analyze" }
|
|
47
|
+
);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const config = controller.config;
|
|
52
|
+
const collections = [
|
|
53
|
+
...(config.collections || []),
|
|
54
|
+
...(config.tables || []),
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
if (collections.length === 0) {
|
|
58
|
+
MessageFormatter.warning(
|
|
59
|
+
"No collections/tables found in local config. Nothing to analyze.",
|
|
60
|
+
{ prefix: "Analyze" }
|
|
61
|
+
);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Prompt for output path
|
|
66
|
+
const { outputPath } = await inquirer.prompt([
|
|
67
|
+
{
|
|
68
|
+
type: "input",
|
|
69
|
+
name: "outputPath",
|
|
70
|
+
message: "Output path for migration plan:",
|
|
71
|
+
default: path.join(process.cwd(), "migrate-strings-plan.yaml"),
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
const options: AnalyzeOptions = { outputPath };
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
analyzeStringAttributes(config, options);
|
|
79
|
+
MessageFormatter.success(
|
|
80
|
+
"Analysis complete. Review the YAML plan, edit targetType/action as needed, then run Execute.",
|
|
81
|
+
{ prefix: "Analyze" }
|
|
82
|
+
);
|
|
83
|
+
} catch (err: any) {
|
|
84
|
+
MessageFormatter.error(
|
|
85
|
+
`Analysis failed: ${err.message}`,
|
|
86
|
+
undefined,
|
|
87
|
+
{ prefix: "Analyze" }
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
async executePhase(cli: InteractiveCLI): Promise<void> {
|
|
93
|
+
const controller = (cli as any).controller;
|
|
94
|
+
if (!controller?.adapter) {
|
|
95
|
+
MessageFormatter.error(
|
|
96
|
+
"No database adapter available. Ensure a server connection is established.",
|
|
97
|
+
undefined,
|
|
98
|
+
{ prefix: "Execute" }
|
|
99
|
+
);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Prompt for plan path
|
|
104
|
+
const { planPath } = await inquirer.prompt([
|
|
105
|
+
{
|
|
106
|
+
type: "input",
|
|
107
|
+
name: "planPath",
|
|
108
|
+
message: "Path to migration plan YAML:",
|
|
109
|
+
default: path.join(process.cwd(), "migrate-strings-plan.yaml"),
|
|
110
|
+
},
|
|
111
|
+
]);
|
|
112
|
+
|
|
113
|
+
const { keepBackups } = await inquirer.prompt([
|
|
114
|
+
{
|
|
115
|
+
type: "confirm",
|
|
116
|
+
name: "keepBackups",
|
|
117
|
+
message: "Keep backup attributes after migration? (safer, uses more attribute slots)",
|
|
118
|
+
default: true,
|
|
119
|
+
},
|
|
120
|
+
]);
|
|
121
|
+
|
|
122
|
+
const { dryRun } = await inquirer.prompt([
|
|
123
|
+
{
|
|
124
|
+
type: "confirm",
|
|
125
|
+
name: "dryRun",
|
|
126
|
+
message: "Dry run? (no actual changes)",
|
|
127
|
+
default: false,
|
|
128
|
+
},
|
|
129
|
+
]);
|
|
130
|
+
|
|
131
|
+
const options: ExecuteOptions = {
|
|
132
|
+
planPath,
|
|
133
|
+
keepBackups,
|
|
134
|
+
dryRun,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
const results = await executeMigrationPlan(controller.adapter, options);
|
|
139
|
+
if (results.failed > 0) {
|
|
140
|
+
MessageFormatter.warning(
|
|
141
|
+
`Migration completed with ${results.failed} failure(s). Check checkpoint file to resume.`,
|
|
142
|
+
{ prefix: "Execute" }
|
|
143
|
+
);
|
|
144
|
+
} else {
|
|
145
|
+
MessageFormatter.success("Migration completed successfully.", {
|
|
146
|
+
prefix: "Execute",
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
} catch (err: any) {
|
|
150
|
+
MessageFormatter.error(
|
|
151
|
+
`Execution failed: ${err.message}`,
|
|
152
|
+
undefined,
|
|
153
|
+
{ prefix: "Execute" }
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
};
|