appwrite-utils-cli 0.0.285 → 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.
- package/README.md +122 -96
- package/dist/collections/attributes.d.ts +4 -0
- package/dist/collections/attributes.js +224 -0
- package/dist/collections/indexes.d.ts +4 -0
- package/dist/collections/indexes.js +27 -0
- package/dist/collections/methods.d.ts +16 -0
- package/dist/collections/methods.js +216 -0
- package/dist/databases/methods.d.ts +6 -0
- package/dist/databases/methods.js +33 -0
- package/dist/interactiveCLI.d.ts +19 -0
- package/dist/interactiveCLI.js +555 -0
- package/dist/main.js +227 -62
- package/dist/migrations/afterImportActions.js +37 -40
- package/dist/migrations/appwriteToX.d.ts +26 -25
- package/dist/migrations/appwriteToX.js +42 -6
- package/dist/migrations/attributes.js +21 -20
- package/dist/migrations/backup.d.ts +93 -87
- package/dist/migrations/collections.d.ts +6 -0
- package/dist/migrations/collections.js +149 -20
- package/dist/migrations/converters.d.ts +2 -18
- package/dist/migrations/converters.js +13 -2
- package/dist/migrations/dataLoader.d.ts +276 -161
- package/dist/migrations/dataLoader.js +535 -292
- package/dist/migrations/databases.js +8 -2
- package/dist/migrations/helper.d.ts +3 -0
- package/dist/migrations/helper.js +21 -0
- package/dist/migrations/importController.d.ts +5 -2
- package/dist/migrations/importController.js +125 -88
- package/dist/migrations/importDataActions.d.ts +9 -1
- package/dist/migrations/importDataActions.js +15 -3
- package/dist/migrations/indexes.js +3 -2
- package/dist/migrations/logging.js +20 -8
- package/dist/migrations/migrationHelper.d.ts +9 -4
- package/dist/migrations/migrationHelper.js +6 -5
- package/dist/migrations/openapi.d.ts +1 -1
- package/dist/migrations/openapi.js +33 -18
- package/dist/migrations/queue.js +3 -2
- package/dist/migrations/relationships.d.ts +2 -2
- package/dist/migrations/schemaStrings.js +53 -41
- package/dist/migrations/setupDatabase.d.ts +2 -4
- package/dist/migrations/setupDatabase.js +24 -105
- package/dist/migrations/storage.d.ts +3 -1
- package/dist/migrations/storage.js +110 -16
- package/dist/migrations/transfer.d.ts +30 -0
- package/dist/migrations/transfer.js +337 -0
- package/dist/migrations/users.d.ts +2 -1
- package/dist/migrations/users.js +78 -43
- package/dist/schemas/authUser.d.ts +2 -2
- package/dist/storage/methods.d.ts +15 -0
- package/dist/storage/methods.js +207 -0
- package/dist/storage/schemas.d.ts +687 -0
- package/dist/storage/schemas.js +175 -0
- package/dist/utils/getClientFromConfig.d.ts +4 -0
- package/dist/utils/getClientFromConfig.js +16 -0
- package/dist/utils/helperFunctions.d.ts +11 -1
- package/dist/utils/helperFunctions.js +38 -0
- package/dist/utils/retryFailedPromises.d.ts +2 -0
- package/dist/utils/retryFailedPromises.js +21 -0
- package/dist/utils/schemaStrings.d.ts +13 -0
- package/dist/utils/schemaStrings.js +403 -0
- package/dist/utils/setupFiles.js +110 -61
- package/dist/utilsController.d.ts +40 -22
- package/dist/utilsController.js +164 -84
- package/package.json +13 -15
- package/src/collections/attributes.ts +483 -0
- package/src/collections/indexes.ts +53 -0
- package/src/collections/methods.ts +331 -0
- package/src/databases/methods.ts +47 -0
- package/src/init.ts +64 -64
- package/src/interactiveCLI.ts +767 -0
- package/src/main.ts +292 -83
- package/src/migrations/afterImportActions.ts +553 -490
- package/src/migrations/appwriteToX.ts +237 -174
- package/src/migrations/attributes.ts +483 -422
- package/src/migrations/backup.ts +205 -205
- package/src/migrations/collections.ts +545 -300
- package/src/migrations/converters.ts +161 -150
- package/src/migrations/dataLoader.ts +1615 -1304
- package/src/migrations/databases.ts +44 -25
- package/src/migrations/dbHelpers.ts +92 -92
- package/src/migrations/helper.ts +40 -0
- package/src/migrations/importController.ts +448 -384
- package/src/migrations/importDataActions.ts +315 -307
- package/src/migrations/indexes.ts +40 -37
- package/src/migrations/logging.ts +29 -16
- package/src/migrations/migrationHelper.ts +207 -201
- package/src/migrations/openapi.ts +83 -70
- package/src/migrations/queue.ts +118 -119
- package/src/migrations/relationships.ts +324 -324
- package/src/migrations/schemaStrings.ts +472 -460
- package/src/migrations/setupDatabase.ts +118 -219
- package/src/migrations/storage.ts +538 -358
- package/src/migrations/transfer.ts +608 -0
- package/src/migrations/users.ts +362 -285
- package/src/migrations/validationRules.ts +63 -63
- package/src/schemas/authUser.ts +23 -23
- package/src/setup.ts +8 -8
- package/src/storage/methods.ts +371 -0
- package/src/storage/schemas.ts +205 -0
- package/src/types.ts +9 -9
- package/src/utils/getClientFromConfig.ts +17 -0
- package/src/utils/helperFunctions.ts +181 -127
- package/src/utils/index.ts +2 -2
- package/src/utils/loadConfigs.ts +59 -59
- package/src/utils/retryFailedPromises.ts +27 -0
- package/src/utils/schemaStrings.ts +473 -0
- package/src/utils/setupFiles.ts +228 -182
- package/src/utilsController.ts +325 -194
- package/tsconfig.json +37 -37
@@ -1,88 +1,89 @@
|
|
1
|
-
import { type Models } from "node-appwrite";
|
1
|
+
import { Storage, type Models } from "node-appwrite";
|
2
2
|
import { type AppwriteConfig } from "appwrite-utils";
|
3
3
|
export declare class AppwriteToX {
|
4
4
|
config: AppwriteConfig;
|
5
|
+
storage: Storage;
|
5
6
|
updatedConfig: AppwriteConfig;
|
6
7
|
collToAttributeMap: Map<string, ({
|
7
8
|
type: "string";
|
8
9
|
key: string;
|
9
10
|
size: number;
|
11
|
+
format?: string | null | undefined;
|
12
|
+
description?: string | Record<string, string> | undefined;
|
13
|
+
required?: boolean | undefined;
|
10
14
|
array?: boolean | undefined;
|
11
15
|
error?: string | undefined;
|
12
|
-
required?: boolean | undefined;
|
13
16
|
xdefault?: string | null | undefined;
|
14
17
|
encrypted?: boolean | undefined;
|
15
|
-
format?: string | null | undefined;
|
16
|
-
description?: string | Record<string, string> | undefined;
|
17
18
|
} | {
|
18
19
|
type: "integer";
|
19
20
|
key: string;
|
21
|
+
description?: string | Record<string, string> | null | undefined;
|
22
|
+
required?: boolean | undefined;
|
20
23
|
array?: boolean | undefined;
|
21
24
|
error?: string | undefined;
|
22
|
-
required?: boolean | undefined;
|
23
25
|
xdefault?: number | null | undefined;
|
24
|
-
description?: string | Record<string, string> | null | undefined;
|
25
26
|
min?: number | undefined;
|
26
27
|
max?: number | undefined;
|
27
28
|
} | {
|
28
29
|
type: "float";
|
29
30
|
key: string;
|
31
|
+
description?: string | Record<string, string> | null | undefined;
|
32
|
+
required?: boolean | undefined;
|
30
33
|
array?: boolean | undefined;
|
31
34
|
error?: string | undefined;
|
32
|
-
required?: boolean | undefined;
|
33
35
|
xdefault?: number | null | undefined;
|
34
|
-
description?: string | Record<string, string> | null | undefined;
|
35
36
|
min?: number | undefined;
|
36
37
|
max?: number | undefined;
|
37
38
|
} | {
|
38
39
|
type: "boolean";
|
39
40
|
key: string;
|
41
|
+
description?: string | Record<string, string> | null | undefined;
|
42
|
+
required?: boolean | undefined;
|
40
43
|
array?: boolean | undefined;
|
41
44
|
error?: string | undefined;
|
42
|
-
required?: boolean | undefined;
|
43
45
|
xdefault?: boolean | null | undefined;
|
44
|
-
description?: string | Record<string, string> | null | undefined;
|
45
46
|
} | {
|
46
47
|
type: "datetime";
|
47
48
|
key: string;
|
49
|
+
description?: string | Record<string, string> | null | undefined;
|
50
|
+
required?: boolean | undefined;
|
48
51
|
array?: boolean | undefined;
|
49
52
|
error?: string | undefined;
|
50
|
-
required?: boolean | undefined;
|
51
53
|
xdefault?: string | null | undefined;
|
52
|
-
description?: string | Record<string, string> | null | undefined;
|
53
54
|
} | {
|
54
55
|
type: "email";
|
55
56
|
key: string;
|
57
|
+
description?: string | Record<string, string> | null | undefined;
|
58
|
+
required?: boolean | undefined;
|
56
59
|
array?: boolean | undefined;
|
57
60
|
error?: string | undefined;
|
58
|
-
required?: boolean | undefined;
|
59
61
|
xdefault?: string | null | undefined;
|
60
|
-
description?: string | Record<string, string> | null | undefined;
|
61
62
|
} | {
|
62
63
|
type: "ip";
|
63
64
|
key: string;
|
65
|
+
description?: string | Record<string, string> | null | undefined;
|
66
|
+
required?: boolean | undefined;
|
64
67
|
array?: boolean | undefined;
|
65
68
|
error?: string | undefined;
|
66
|
-
required?: boolean | undefined;
|
67
69
|
xdefault?: string | null | undefined;
|
68
|
-
description?: string | Record<string, string> | null | undefined;
|
69
70
|
} | {
|
70
71
|
type: "url";
|
71
72
|
key: string;
|
73
|
+
description?: string | Record<string, string> | null | undefined;
|
74
|
+
required?: boolean | undefined;
|
72
75
|
array?: boolean | undefined;
|
73
76
|
error?: string | undefined;
|
74
|
-
required?: boolean | undefined;
|
75
77
|
xdefault?: string | null | undefined;
|
76
|
-
description?: string | Record<string, string> | null | undefined;
|
77
78
|
} | {
|
78
79
|
type: "enum";
|
79
80
|
key: string;
|
80
81
|
elements: string[];
|
82
|
+
description?: string | Record<string, string> | null | undefined;
|
83
|
+
required?: boolean | undefined;
|
81
84
|
array?: boolean | undefined;
|
82
85
|
error?: string | undefined;
|
83
|
-
required?: boolean | undefined;
|
84
86
|
xdefault?: string | null | undefined;
|
85
|
-
description?: string | Record<string, string> | null | undefined;
|
86
87
|
} | {
|
87
88
|
type: "relationship";
|
88
89
|
key: string;
|
@@ -92,17 +93,17 @@ export declare class AppwriteToX {
|
|
92
93
|
twoWayKey: string;
|
93
94
|
onDelete: "setNull" | "cascade" | "restrict";
|
94
95
|
side: "parent" | "child";
|
96
|
+
description?: string | Record<string, string> | null | undefined;
|
97
|
+
required?: boolean | undefined;
|
95
98
|
array?: boolean | undefined;
|
96
99
|
error?: string | undefined;
|
97
|
-
required?: boolean | undefined;
|
98
|
-
description?: string | Record<string, string> | null | undefined;
|
99
100
|
importMapping?: {
|
100
101
|
originalIdField: string;
|
101
102
|
targetField?: string | undefined;
|
102
103
|
} | undefined;
|
103
104
|
})[]>;
|
104
105
|
appwriteFolderPath: string;
|
105
|
-
constructor(config: AppwriteConfig, appwriteFolderPath: string);
|
106
|
+
constructor(config: AppwriteConfig, appwriteFolderPath: string, storage: Storage);
|
106
107
|
parsePermissionString: (permissionString: string) => {
|
107
108
|
permission: string;
|
108
109
|
target: string;
|
@@ -115,6 +116,6 @@ export declare class AppwriteToX {
|
|
115
116
|
target: string;
|
116
117
|
})[];
|
117
118
|
updateCollectionConfigAttributes: (collection: Models.Collection) => void;
|
118
|
-
appwriteSync(config: AppwriteConfig): Promise<void>;
|
119
|
-
toSchemas(): Promise<void>;
|
119
|
+
appwriteSync(config: AppwriteConfig, databases?: Models.Database[]): Promise<void>;
|
120
|
+
toSchemas(databases?: Models.Database[]): Promise<void>;
|
120
121
|
}
|
@@ -1,17 +1,20 @@
|
|
1
1
|
import { SchemaGenerator } from "./schemaStrings.js";
|
2
|
-
import { Databases, Query } from "node-appwrite";
|
2
|
+
import { Client, Compression, Databases, Query, Storage, } from "node-appwrite";
|
3
3
|
import { fetchAllCollections } from "./collections.js";
|
4
4
|
import { fetchAllDatabases } from "./databases.js";
|
5
5
|
import { CollectionSchema, attributeSchema, AppwriteConfigSchema, permissionsSchema, attributesSchema, indexesSchema, parseAttribute, } from "appwrite-utils";
|
6
6
|
import { getDatabaseFromConfig } from "./afterImportActions.js";
|
7
|
+
import { listBuckets } from "../storage/methods.js";
|
7
8
|
export class AppwriteToX {
|
8
9
|
config;
|
10
|
+
storage;
|
9
11
|
updatedConfig;
|
10
12
|
collToAttributeMap = new Map();
|
11
13
|
appwriteFolderPath;
|
12
|
-
constructor(config, appwriteFolderPath) {
|
14
|
+
constructor(config, appwriteFolderPath, storage) {
|
13
15
|
this.config = config;
|
14
16
|
this.updatedConfig = config;
|
17
|
+
this.storage = storage;
|
15
18
|
this.appwriteFolderPath = appwriteFolderPath;
|
16
19
|
}
|
17
20
|
// Function to parse a single permission string
|
@@ -43,15 +46,36 @@ export class AppwriteToX {
|
|
43
46
|
?.push(attributeParsed);
|
44
47
|
}
|
45
48
|
};
|
46
|
-
async appwriteSync(config) {
|
49
|
+
async appwriteSync(config, databases) {
|
47
50
|
const db = getDatabaseFromConfig(config);
|
48
|
-
|
51
|
+
if (!databases) {
|
52
|
+
databases = await fetchAllDatabases(db);
|
53
|
+
}
|
49
54
|
let updatedConfig = { ...config };
|
55
|
+
// Fetch all buckets
|
56
|
+
const allBuckets = await listBuckets(this.storage);
|
50
57
|
// Loop through each database
|
51
58
|
for (const database of databases) {
|
52
59
|
if (database.name.toLowerCase() === "migrations") {
|
53
60
|
continue;
|
54
61
|
}
|
62
|
+
// Match bucket to database
|
63
|
+
const matchedBucket = allBuckets.buckets.find((bucket) => bucket.$id.toLowerCase().includes(database.$id.toLowerCase()));
|
64
|
+
if (matchedBucket) {
|
65
|
+
const dbConfig = updatedConfig.databases.find((db) => db.$id === database.$id);
|
66
|
+
if (dbConfig) {
|
67
|
+
dbConfig.bucket = {
|
68
|
+
$id: matchedBucket.$id,
|
69
|
+
name: matchedBucket.name,
|
70
|
+
enabled: matchedBucket.enabled,
|
71
|
+
maximumFileSize: matchedBucket.maximumFileSize,
|
72
|
+
allowedFileExtensions: matchedBucket.allowedFileExtensions,
|
73
|
+
compression: matchedBucket.compression,
|
74
|
+
encryption: matchedBucket.encryption,
|
75
|
+
antivirus: matchedBucket.antivirus,
|
76
|
+
};
|
77
|
+
}
|
78
|
+
}
|
55
79
|
const collections = await fetchAllCollections(database.$id, db);
|
56
80
|
// Loop through each collection in the current database
|
57
81
|
if (!updatedConfig.collections) {
|
@@ -117,10 +141,22 @@ export class AppwriteToX {
|
|
117
141
|
}
|
118
142
|
console.log(`Processed ${collections.length} collections in ${database.name}`);
|
119
143
|
}
|
144
|
+
// Add unmatched buckets as global buckets
|
145
|
+
const globalBuckets = allBuckets.buckets.filter((bucket) => !updatedConfig.databases.some((db) => db.bucket && db.bucket.$id === bucket.$id));
|
146
|
+
updatedConfig.buckets = globalBuckets.map((bucket) => ({
|
147
|
+
$id: bucket.$id,
|
148
|
+
name: bucket.name,
|
149
|
+
enabled: bucket.enabled,
|
150
|
+
maximumFileSize: bucket.maximumFileSize,
|
151
|
+
allowedFileExtensions: bucket.allowedFileExtensions,
|
152
|
+
compression: bucket.compression,
|
153
|
+
encryption: bucket.encryption,
|
154
|
+
antivirus: bucket.antivirus,
|
155
|
+
}));
|
120
156
|
this.updatedConfig = updatedConfig;
|
121
157
|
}
|
122
|
-
async toSchemas() {
|
123
|
-
await this.appwriteSync(this.config);
|
158
|
+
async toSchemas(databases) {
|
159
|
+
await this.appwriteSync(this.config, databases);
|
124
160
|
const generator = new SchemaGenerator(this.updatedConfig, this.appwriteFolderPath);
|
125
161
|
generator.updateTsSchemas();
|
126
162
|
generator.generateSchemas();
|
@@ -2,6 +2,7 @@ import { Query } from "node-appwrite";
|
|
2
2
|
import { attributeSchema, parseAttribute, } from "appwrite-utils";
|
3
3
|
import { nameToIdMapping, enqueueOperation } from "./queue.js";
|
4
4
|
import _ from "lodash";
|
5
|
+
import { tryAwaitWithRetry } from "../utils/helperFunctions.js";
|
5
6
|
const attributesSame = (databaseAttribute, configAttribute) => {
|
6
7
|
return (databaseAttribute.key == configAttribute.key &&
|
7
8
|
databaseAttribute.type == configAttribute.type &&
|
@@ -105,10 +106,10 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
|
|
105
106
|
switch (finalAttribute.type) {
|
106
107
|
case "string":
|
107
108
|
if (action === "create") {
|
108
|
-
await db.createStringAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.size, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array || false, finalAttribute.encrypted);
|
109
|
+
await tryAwaitWithRetry(async () => await db.createStringAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.size, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array || false, finalAttribute.encrypted));
|
109
110
|
}
|
110
111
|
else {
|
111
|
-
await db.updateStringAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined);
|
112
|
+
await tryAwaitWithRetry(async () => await db.updateStringAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined));
|
112
113
|
}
|
113
114
|
break;
|
114
115
|
case "integer":
|
@@ -121,7 +122,7 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
|
|
121
122
|
BigInt(finalAttribute.max) === BigInt(9223372036854776000)) {
|
122
123
|
delete finalAttribute.max;
|
123
124
|
}
|
124
|
-
await db.createIntegerAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min, finalAttribute.max, finalAttribute.xdefault || undefined, finalAttribute.array);
|
125
|
+
await tryAwaitWithRetry(async () => await db.createIntegerAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min, finalAttribute.max, finalAttribute.xdefault || undefined, finalAttribute.array));
|
125
126
|
}
|
126
127
|
else {
|
127
128
|
if (finalAttribute.min &&
|
@@ -132,71 +133,71 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
|
|
132
133
|
BigInt(finalAttribute.max) === BigInt(9223372036854776000)) {
|
133
134
|
delete finalAttribute.max;
|
134
135
|
}
|
135
|
-
await db.updateIntegerAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min || 0, finalAttribute.max || 2147483647, finalAttribute.xdefault || undefined);
|
136
|
+
await tryAwaitWithRetry(async () => await db.updateIntegerAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min || 0, finalAttribute.max || 2147483647, finalAttribute.xdefault || undefined));
|
136
137
|
}
|
137
138
|
break;
|
138
139
|
case "float":
|
139
140
|
if (action === "create") {
|
140
|
-
await db.createFloatAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min, finalAttribute.max, finalAttribute.xdefault || undefined, finalAttribute.array);
|
141
|
+
await tryAwaitWithRetry(async () => await db.createFloatAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min, finalAttribute.max, finalAttribute.xdefault || undefined, finalAttribute.array));
|
141
142
|
}
|
142
143
|
else {
|
143
|
-
await db.updateFloatAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min || 0, finalAttribute.max || 2147483647, finalAttribute.xdefault || undefined);
|
144
|
+
await tryAwaitWithRetry(async () => await db.updateFloatAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min || 0, finalAttribute.max || 2147483647, finalAttribute.xdefault || undefined));
|
144
145
|
}
|
145
146
|
break;
|
146
147
|
case "boolean":
|
147
148
|
if (action === "create") {
|
148
|
-
await db.createBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array);
|
149
|
+
await tryAwaitWithRetry(async () => await db.createBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
|
149
150
|
}
|
150
151
|
else {
|
151
|
-
await db.updateBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || null);
|
152
|
+
await tryAwaitWithRetry(async () => await db.updateBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || null));
|
152
153
|
}
|
153
154
|
break;
|
154
155
|
case "datetime":
|
155
156
|
if (action === "create") {
|
156
|
-
await db.createDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array);
|
157
|
+
await tryAwaitWithRetry(async () => await db.createDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
|
157
158
|
}
|
158
159
|
else {
|
159
|
-
await db.updateDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined);
|
160
|
+
await tryAwaitWithRetry(async () => await db.updateDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined));
|
160
161
|
}
|
161
162
|
break;
|
162
163
|
case "email":
|
163
164
|
if (action === "create") {
|
164
|
-
await db.createEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array);
|
165
|
+
await tryAwaitWithRetry(async () => await db.createEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
|
165
166
|
}
|
166
167
|
else {
|
167
|
-
await db.updateEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined);
|
168
|
+
await tryAwaitWithRetry(async () => await db.updateEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined));
|
168
169
|
}
|
169
170
|
break;
|
170
171
|
case "ip":
|
171
172
|
if (action === "create") {
|
172
|
-
await db.createIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array);
|
173
|
+
await tryAwaitWithRetry(async () => await db.createIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
|
173
174
|
}
|
174
175
|
else {
|
175
|
-
await db.updateIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined);
|
176
|
+
await tryAwaitWithRetry(async () => await db.updateIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined));
|
176
177
|
}
|
177
178
|
break;
|
178
179
|
case "url":
|
179
180
|
if (action === "create") {
|
180
|
-
await db.createUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array);
|
181
|
+
await tryAwaitWithRetry(async () => await db.createUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
|
181
182
|
}
|
182
183
|
else {
|
183
|
-
await db.updateUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined);
|
184
|
+
await tryAwaitWithRetry(async () => await db.updateUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined));
|
184
185
|
}
|
185
186
|
break;
|
186
187
|
case "enum":
|
187
188
|
if (action === "create") {
|
188
|
-
await db.createEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array);
|
189
|
+
await tryAwaitWithRetry(async () => await db.createEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
|
189
190
|
}
|
190
191
|
else {
|
191
|
-
await db.updateEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required || false, finalAttribute.xdefault || undefined);
|
192
|
+
await tryAwaitWithRetry(async () => await db.updateEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required || false, finalAttribute.xdefault || undefined));
|
192
193
|
}
|
193
194
|
break;
|
194
195
|
case "relationship":
|
195
196
|
if (action === "create") {
|
196
|
-
await db.createRelationshipAttribute(dbId, collection.$id, relatedCollectionId, finalAttribute.relationType, finalAttribute.twoWay, finalAttribute.key, finalAttribute.twoWayKey, finalAttribute.onDelete);
|
197
|
+
await tryAwaitWithRetry(async () => await db.createRelationshipAttribute(dbId, collection.$id, relatedCollectionId, finalAttribute.relationType, finalAttribute.twoWay, finalAttribute.key, finalAttribute.twoWayKey, finalAttribute.onDelete));
|
197
198
|
}
|
198
199
|
else {
|
199
|
-
await db.updateRelationshipAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.onDelete);
|
200
|
+
await tryAwaitWithRetry(async () => await db.updateRelationshipAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.onDelete));
|
200
201
|
}
|
201
202
|
break;
|
202
203
|
default:
|