appwrite-utils-cli 0.0.286 → 0.9.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.
Files changed (109) hide show
  1. package/README.md +122 -96
  2. package/dist/collections/attributes.d.ts +4 -0
  3. package/dist/collections/attributes.js +224 -0
  4. package/dist/collections/indexes.d.ts +4 -0
  5. package/dist/collections/indexes.js +27 -0
  6. package/dist/collections/methods.d.ts +16 -0
  7. package/dist/collections/methods.js +216 -0
  8. package/dist/databases/methods.d.ts +6 -0
  9. package/dist/databases/methods.js +33 -0
  10. package/dist/interactiveCLI.d.ts +19 -0
  11. package/dist/interactiveCLI.js +555 -0
  12. package/dist/main.js +227 -62
  13. package/dist/migrations/afterImportActions.js +37 -40
  14. package/dist/migrations/appwriteToX.d.ts +26 -25
  15. package/dist/migrations/appwriteToX.js +42 -6
  16. package/dist/migrations/attributes.js +21 -20
  17. package/dist/migrations/backup.d.ts +93 -87
  18. package/dist/migrations/collections.d.ts +6 -0
  19. package/dist/migrations/collections.js +149 -20
  20. package/dist/migrations/converters.d.ts +2 -18
  21. package/dist/migrations/converters.js +13 -2
  22. package/dist/migrations/dataLoader.d.ts +276 -161
  23. package/dist/migrations/dataLoader.js +535 -292
  24. package/dist/migrations/databases.js +8 -2
  25. package/dist/migrations/helper.d.ts +3 -0
  26. package/dist/migrations/helper.js +21 -0
  27. package/dist/migrations/importController.d.ts +5 -2
  28. package/dist/migrations/importController.js +125 -88
  29. package/dist/migrations/importDataActions.d.ts +9 -1
  30. package/dist/migrations/importDataActions.js +15 -3
  31. package/dist/migrations/indexes.js +3 -2
  32. package/dist/migrations/logging.js +20 -8
  33. package/dist/migrations/migrationHelper.d.ts +9 -4
  34. package/dist/migrations/migrationHelper.js +6 -5
  35. package/dist/migrations/openapi.d.ts +1 -1
  36. package/dist/migrations/openapi.js +33 -18
  37. package/dist/migrations/queue.js +3 -2
  38. package/dist/migrations/relationships.d.ts +2 -2
  39. package/dist/migrations/schemaStrings.js +53 -41
  40. package/dist/migrations/setupDatabase.d.ts +2 -4
  41. package/dist/migrations/setupDatabase.js +24 -105
  42. package/dist/migrations/storage.d.ts +3 -1
  43. package/dist/migrations/storage.js +110 -16
  44. package/dist/migrations/transfer.d.ts +30 -0
  45. package/dist/migrations/transfer.js +337 -0
  46. package/dist/migrations/users.d.ts +2 -1
  47. package/dist/migrations/users.js +78 -43
  48. package/dist/schemas/authUser.d.ts +2 -2
  49. package/dist/storage/methods.d.ts +15 -0
  50. package/dist/storage/methods.js +207 -0
  51. package/dist/storage/schemas.d.ts +687 -0
  52. package/dist/storage/schemas.js +175 -0
  53. package/dist/utils/getClientFromConfig.d.ts +4 -0
  54. package/dist/utils/getClientFromConfig.js +16 -0
  55. package/dist/utils/helperFunctions.d.ts +11 -1
  56. package/dist/utils/helperFunctions.js +38 -0
  57. package/dist/utils/retryFailedPromises.d.ts +2 -0
  58. package/dist/utils/retryFailedPromises.js +21 -0
  59. package/dist/utils/schemaStrings.d.ts +13 -0
  60. package/dist/utils/schemaStrings.js +403 -0
  61. package/dist/utils/setupFiles.js +110 -61
  62. package/dist/utilsController.d.ts +40 -22
  63. package/dist/utilsController.js +164 -84
  64. package/package.json +13 -15
  65. package/src/collections/attributes.ts +483 -0
  66. package/src/collections/indexes.ts +53 -0
  67. package/src/collections/methods.ts +331 -0
  68. package/src/databases/methods.ts +47 -0
  69. package/src/init.ts +64 -64
  70. package/src/interactiveCLI.ts +767 -0
  71. package/src/main.ts +292 -83
  72. package/src/migrations/afterImportActions.ts +553 -490
  73. package/src/migrations/appwriteToX.ts +237 -174
  74. package/src/migrations/attributes.ts +483 -422
  75. package/src/migrations/backup.ts +205 -205
  76. package/src/migrations/collections.ts +545 -300
  77. package/src/migrations/converters.ts +161 -150
  78. package/src/migrations/dataLoader.ts +1615 -1304
  79. package/src/migrations/databases.ts +44 -25
  80. package/src/migrations/dbHelpers.ts +92 -92
  81. package/src/migrations/helper.ts +40 -0
  82. package/src/migrations/importController.ts +448 -384
  83. package/src/migrations/importDataActions.ts +315 -307
  84. package/src/migrations/indexes.ts +40 -37
  85. package/src/migrations/logging.ts +29 -16
  86. package/src/migrations/migrationHelper.ts +207 -201
  87. package/src/migrations/openapi.ts +83 -70
  88. package/src/migrations/queue.ts +118 -119
  89. package/src/migrations/relationships.ts +324 -324
  90. package/src/migrations/schemaStrings.ts +472 -460
  91. package/src/migrations/setupDatabase.ts +118 -219
  92. package/src/migrations/storage.ts +538 -358
  93. package/src/migrations/transfer.ts +608 -0
  94. package/src/migrations/users.ts +362 -285
  95. package/src/migrations/validationRules.ts +63 -63
  96. package/src/schemas/authUser.ts +23 -23
  97. package/src/setup.ts +8 -8
  98. package/src/storage/methods.ts +371 -0
  99. package/src/storage/schemas.ts +205 -0
  100. package/src/types.ts +9 -9
  101. package/src/utils/getClientFromConfig.ts +17 -0
  102. package/src/utils/helperFunctions.ts +181 -127
  103. package/src/utils/index.ts +2 -2
  104. package/src/utils/loadConfigs.ts +59 -59
  105. package/src/utils/retryFailedPromises.ts +27 -0
  106. package/src/utils/schemaStrings.ts +473 -0
  107. package/src/utils/setupFiles.ts +228 -182
  108. package/src/utilsController.ts +325 -194
  109. package/tsconfig.json +37 -37
@@ -1,205 +1,205 @@
1
- import { z } from "zod";
2
- import {
3
- attributeSchema,
4
- type Attribute,
5
- parseAttribute,
6
- CollectionCreateSchema,
7
- } from "appwrite-utils";
8
-
9
- export const BackupSchema = z.object({
10
- $id: z.string(),
11
- $createdAt: z.string(),
12
- $updatedAt: z.string(),
13
- database: z.string(),
14
- collections: z.array(z.string()),
15
- documents: z
16
- .array(
17
- z.object({
18
- collectionId: z.string(),
19
- data: z.string(),
20
- })
21
- )
22
- .default([]),
23
- });
24
-
25
- export type Backup = z.infer<typeof BackupSchema>;
26
-
27
- export const BackupCreateSchema = BackupSchema.omit({
28
- $id: true,
29
- $createdAt: true,
30
- $updatedAt: true,
31
- });
32
-
33
- export type BackupCreate = z.infer<typeof BackupCreateSchema>;
34
-
35
- export const BatchSchema = z.object({
36
- $id: z.string(),
37
- $createdAt: z.string(),
38
- $updatedAt: z.string(),
39
- data: z.string().describe("The serialized data for this batch"),
40
- processed: z
41
- .boolean()
42
- .default(false)
43
- .describe("Whether the batch has been processed"),
44
- });
45
-
46
- export type Batch = z.infer<typeof BatchSchema>;
47
-
48
- export const BatchCreateSchema = BatchSchema.omit({
49
- $id: true,
50
- $createdAt: true,
51
- $updatedAt: true,
52
- });
53
-
54
- export type BatchCreate = z.infer<typeof BatchCreateSchema>;
55
-
56
- export const OperationSchema = z.object({
57
- $id: z.string(),
58
- $createdAt: z.string(),
59
- $updatedAt: z.string(),
60
- operationType: z.string(),
61
- collectionId: z.string(),
62
- data: z.any(),
63
- batches: z.array(z.string()).default([]).optional(),
64
- progress: z.number(),
65
- total: z.number(),
66
- error: z.string(),
67
- status: z
68
- .enum([
69
- "pending",
70
- "ready",
71
- "in_progress",
72
- "completed",
73
- "error",
74
- "cancelled",
75
- ])
76
- .default("pending"),
77
- });
78
-
79
- export type Operation = z.infer<typeof OperationSchema>;
80
-
81
- export const OperationCreateSchema = OperationSchema.omit({
82
- $id: true,
83
- $createdAt: true,
84
- $updatedAt: true,
85
- });
86
-
87
- export type OperationCreate = z.infer<typeof OperationCreateSchema>;
88
-
89
- export const getMigrationCollectionSchemas = () => {
90
- const currentOperationsAttributes: Attribute[] = [
91
- parseAttribute({
92
- key: "operationType",
93
- type: "string",
94
- error: "Invalid Operation Type",
95
- size: 50,
96
- required: true,
97
- array: false,
98
- xdefault: null,
99
- }),
100
- attributeSchema.parse({
101
- key: "collectionId",
102
- type: "string",
103
- error: "Invalid Collection Id",
104
- size: 50,
105
- array: false,
106
- xdefault: null,
107
- }),
108
- attributeSchema.parse({
109
- key: "batches",
110
- type: "string",
111
- error: "Invalid Batches",
112
- size: 1073741824,
113
- array: true,
114
- }),
115
- attributeSchema.parse({
116
- key: "data",
117
- type: "string",
118
- error: "Invalid Data",
119
- size: 1073741824,
120
- }),
121
- attributeSchema.parse({
122
- key: "progress",
123
- type: "integer",
124
- error: "Invalid Progress",
125
- required: true,
126
- array: false,
127
- }),
128
- attributeSchema.parse({
129
- key: "total",
130
- type: "integer",
131
- error: "Invalid Total",
132
- required: true,
133
- array: false,
134
- }),
135
- attributeSchema.parse({
136
- key: "error",
137
- type: "string",
138
- error: "Operation Error",
139
- required: false,
140
- array: false,
141
- }),
142
- attributeSchema.parse({
143
- key: "status",
144
- type: "enum",
145
- elements: [
146
- "pending",
147
- "ready",
148
- "in_progress",
149
- "completed",
150
- "error",
151
- "cancelled",
152
- ],
153
- error: "Invalid Status",
154
- array: false,
155
- xdefault: "pending",
156
- }),
157
- ];
158
-
159
- const currentOperationsConfig = CollectionCreateSchema.parse({
160
- name: "CurrentOperations",
161
- enabled: true,
162
- documentSecurity: false,
163
- attributes: [],
164
- indexes: [],
165
- });
166
-
167
- const batchesAttributes: Attribute[] = [
168
- attributeSchema.parse({
169
- key: "data",
170
- type: "string",
171
- size: 1073741824,
172
- error: "Invalid Data",
173
- required: true,
174
- array: false,
175
- }),
176
- attributeSchema.parse({
177
- key: "processed",
178
- type: "boolean",
179
- error: "Invalid Processed",
180
- required: true,
181
- array: false,
182
- xdefault: false,
183
- }),
184
- ];
185
-
186
- const batchesConfig = CollectionCreateSchema.parse({
187
- name: "Batches",
188
- enabled: true,
189
- documentSecurity: false,
190
- attributes: [],
191
- indexes: [],
192
- });
193
-
194
- const toReturn = {
195
- CurrentOperations: {
196
- collection: currentOperationsConfig,
197
- attributes: currentOperationsAttributes,
198
- },
199
- Batches: {
200
- collection: batchesConfig,
201
- attributes: batchesAttributes,
202
- },
203
- };
204
- return toReturn;
205
- };
1
+ import { z } from "zod";
2
+ import {
3
+ attributeSchema,
4
+ type Attribute,
5
+ parseAttribute,
6
+ CollectionCreateSchema,
7
+ } from "appwrite-utils";
8
+
9
+ export const BackupSchema = z.object({
10
+ $id: z.string(),
11
+ $createdAt: z.string(),
12
+ $updatedAt: z.string(),
13
+ database: z.string(),
14
+ collections: z.array(z.string()),
15
+ documents: z
16
+ .array(
17
+ z.object({
18
+ collectionId: z.string(),
19
+ data: z.string(),
20
+ })
21
+ )
22
+ .default([]),
23
+ });
24
+
25
+ export type Backup = z.infer<typeof BackupSchema>;
26
+
27
+ export const BackupCreateSchema = BackupSchema.omit({
28
+ $id: true,
29
+ $createdAt: true,
30
+ $updatedAt: true,
31
+ });
32
+
33
+ export type BackupCreate = z.infer<typeof BackupCreateSchema>;
34
+
35
+ export const BatchSchema = z.object({
36
+ $id: z.string(),
37
+ $createdAt: z.string(),
38
+ $updatedAt: z.string(),
39
+ data: z.string().describe("The serialized data for this batch"),
40
+ processed: z
41
+ .boolean()
42
+ .default(false)
43
+ .describe("Whether the batch has been processed"),
44
+ });
45
+
46
+ export type Batch = z.infer<typeof BatchSchema>;
47
+
48
+ export const BatchCreateSchema = BatchSchema.omit({
49
+ $id: true,
50
+ $createdAt: true,
51
+ $updatedAt: true,
52
+ });
53
+
54
+ export type BatchCreate = z.infer<typeof BatchCreateSchema>;
55
+
56
+ export const OperationSchema = z.object({
57
+ $id: z.string(),
58
+ $createdAt: z.string(),
59
+ $updatedAt: z.string(),
60
+ operationType: z.string(),
61
+ collectionId: z.string(),
62
+ data: z.any(),
63
+ batches: z.array(z.string()).default([]).optional(),
64
+ progress: z.number(),
65
+ total: z.number(),
66
+ error: z.string(),
67
+ status: z
68
+ .enum([
69
+ "pending",
70
+ "ready",
71
+ "in_progress",
72
+ "completed",
73
+ "error",
74
+ "cancelled",
75
+ ])
76
+ .default("pending"),
77
+ });
78
+
79
+ export type Operation = z.infer<typeof OperationSchema>;
80
+
81
+ export const OperationCreateSchema = OperationSchema.omit({
82
+ $id: true,
83
+ $createdAt: true,
84
+ $updatedAt: true,
85
+ });
86
+
87
+ export type OperationCreate = z.infer<typeof OperationCreateSchema>;
88
+
89
+ export const getMigrationCollectionSchemas = () => {
90
+ const currentOperationsAttributes: Attribute[] = [
91
+ parseAttribute({
92
+ key: "operationType",
93
+ type: "string",
94
+ error: "Invalid Operation Type",
95
+ size: 50,
96
+ required: true,
97
+ array: false,
98
+ xdefault: null,
99
+ }),
100
+ attributeSchema.parse({
101
+ key: "collectionId",
102
+ type: "string",
103
+ error: "Invalid Collection Id",
104
+ size: 50,
105
+ array: false,
106
+ xdefault: null,
107
+ }),
108
+ attributeSchema.parse({
109
+ key: "batches",
110
+ type: "string",
111
+ error: "Invalid Batches",
112
+ size: 1073741824,
113
+ array: true,
114
+ }),
115
+ attributeSchema.parse({
116
+ key: "data",
117
+ type: "string",
118
+ error: "Invalid Data",
119
+ size: 1073741824,
120
+ }),
121
+ attributeSchema.parse({
122
+ key: "progress",
123
+ type: "integer",
124
+ error: "Invalid Progress",
125
+ required: true,
126
+ array: false,
127
+ }),
128
+ attributeSchema.parse({
129
+ key: "total",
130
+ type: "integer",
131
+ error: "Invalid Total",
132
+ required: true,
133
+ array: false,
134
+ }),
135
+ attributeSchema.parse({
136
+ key: "error",
137
+ type: "string",
138
+ error: "Operation Error",
139
+ required: false,
140
+ array: false,
141
+ }),
142
+ attributeSchema.parse({
143
+ key: "status",
144
+ type: "enum",
145
+ elements: [
146
+ "pending",
147
+ "ready",
148
+ "in_progress",
149
+ "completed",
150
+ "error",
151
+ "cancelled",
152
+ ],
153
+ error: "Invalid Status",
154
+ array: false,
155
+ xdefault: "pending",
156
+ }),
157
+ ];
158
+
159
+ const currentOperationsConfig = CollectionCreateSchema.parse({
160
+ name: "CurrentOperations",
161
+ enabled: true,
162
+ documentSecurity: false,
163
+ attributes: [],
164
+ indexes: [],
165
+ });
166
+
167
+ const batchesAttributes: Attribute[] = [
168
+ attributeSchema.parse({
169
+ key: "data",
170
+ type: "string",
171
+ size: 1073741824,
172
+ error: "Invalid Data",
173
+ required: true,
174
+ array: false,
175
+ }),
176
+ attributeSchema.parse({
177
+ key: "processed",
178
+ type: "boolean",
179
+ error: "Invalid Processed",
180
+ required: true,
181
+ array: false,
182
+ xdefault: false,
183
+ }),
184
+ ];
185
+
186
+ const batchesConfig = CollectionCreateSchema.parse({
187
+ name: "Batches",
188
+ enabled: true,
189
+ documentSecurity: false,
190
+ attributes: [],
191
+ indexes: [],
192
+ });
193
+
194
+ const toReturn = {
195
+ CurrentOperations: {
196
+ collection: currentOperationsConfig,
197
+ attributes: currentOperationsAttributes,
198
+ },
199
+ Batches: {
200
+ collection: batchesConfig,
201
+ attributes: batchesAttributes,
202
+ },
203
+ };
204
+ return toReturn;
205
+ };