appwrite-utils-cli 0.9.64 → 0.9.68

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 CHANGED
@@ -124,6 +124,8 @@ This updated CLI ensures that developers have robust tools at their fingertips t
124
124
 
125
125
  ## Changelog
126
126
 
127
+ - 0.9.68: Temporarily disabled updating Attributes until `updateStringAttribute` is fixed -- it just deletes them now
128
+ - 0.9.65: Temporary fix for Appwrite's `updateStringAttribute` bug
127
129
  - 0.9.64: Fixed string attribute requiring xdefault
128
130
  - 0.9.61: Remove fileURLToPath -- should hopefully fix windows
129
131
  - 0.9.60: Fix init command to repository URL
@@ -4,9 +4,7 @@ import { nameToIdMapping, enqueueOperation } from "./queue.js";
4
4
  import _ from "lodash";
5
5
  import { tryAwaitWithRetry } from "../utils/helperFunctions.js";
6
6
  const attributesSame = (databaseAttribute, configAttribute) => {
7
- return (databaseAttribute.key == configAttribute.key &&
8
- databaseAttribute.type == configAttribute.type &&
9
- databaseAttribute.array == configAttribute.array);
7
+ return databaseAttribute.key === configAttribute.key;
10
8
  };
11
9
  export const createOrUpdateAttribute = async (db, dbId, collection, attribute) => {
12
10
  let action = "create";
@@ -22,50 +20,24 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
22
20
  catch (error) {
23
21
  foundAttribute = undefined;
24
22
  }
25
- if (foundAttribute &&
26
- attributesSame(foundAttribute, attribute) &&
27
- updateEnabled) {
28
- // Check if mutable properties have changed and set action to "update" if necessary
29
- const requiredChanged = "required" in foundAttribute && "required" in attribute
30
- ? foundAttribute.required !== attribute.required
31
- : false;
32
- // const xdefaultChanged =
33
- // "xdefault" in foundAttribute && "xdefault" in attribute
34
- // ? foundAttribute.xdefault !== attribute.xdefault
35
- // : false;
36
- const onDeleteChanged = foundAttribute.type === "relationship" &&
37
- attribute.type === "relationship" &&
38
- "onDelete" in foundAttribute &&
39
- "onDelete" in attribute
40
- ? foundAttribute.onDelete !== attribute.onDelete
41
- : false;
42
- if (requiredChanged || onDeleteChanged) {
43
- console.log(`Required changed: ${requiredChanged}\nOnDelete changed: ${onDeleteChanged}`);
44
- console.log(`Found attribute: ${JSON.stringify(foundAttribute, null, 2)}`);
45
- console.log(`Attribute: ${JSON.stringify(attribute, null, 2)}`);
46
- finalAttribute = {
47
- ...attribute,
48
- ...foundAttribute,
49
- };
50
- action = "update";
51
- }
52
- else {
53
- // If no properties that can be updated have changed, return early
54
- return;
55
- }
23
+ if (foundAttribute && attributesSame(foundAttribute, attribute) && updateEnabled) {
24
+ finalAttribute = {
25
+ ...attribute,
26
+ ...foundAttribute,
27
+ };
28
+ action = "update";
56
29
  }
57
- else if (foundAttribute &&
58
- !attributesSame(foundAttribute, attribute) &&
59
- updateEnabled) {
60
- console.log(`Deleting attribute with same key ${attribute.key} -- but different values -- ${JSON.stringify(attribute, null, 2)} -- ${JSON.stringify(foundAttribute, null, 2)}`);
61
- await db.deleteAttribute(dbId, collection.$id, attribute.key);
62
- // After deletion, you might want to create the attribute anew
30
+ else if (foundAttribute && !attributesSame(foundAttribute, attribute) && updateEnabled) {
31
+ console.log(`Updating attribute with same key ${attribute.key} but different values`);
63
32
  finalAttribute = attribute;
64
- action = "create";
33
+ action = "update";
65
34
  }
66
35
  else if (!updateEnabled && foundAttribute) {
36
+ await db.deleteAttribute(dbId, collection.$id, attribute.key);
37
+ console.log(`Deleted attribute: ${attribute.key} to recreate it (update disabled temporarily)`);
67
38
  return;
68
39
  }
40
+ console.log(`${action}-ing attribute: ${finalAttribute.key}`);
69
41
  // Relationship attribute logic with adjustments
70
42
  let collectionFoundViaRelatedCollection;
71
43
  let relatedCollectionId;
@@ -106,10 +78,10 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
106
78
  switch (finalAttribute.type) {
107
79
  case "string":
108
80
  if (action === "create") {
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));
81
+ await tryAwaitWithRetry(async () => await db.createStringAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.size, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null), finalAttribute.array || false, finalAttribute.encrypted));
110
82
  }
111
83
  else {
112
- await tryAwaitWithRetry(async () => await db.updateStringAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined));
84
+ await tryAwaitWithRetry(async () => await db.updateStringAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : ""), finalAttribute.size));
113
85
  }
114
86
  break;
115
87
  case "integer":
@@ -122,7 +94,7 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
122
94
  BigInt(finalAttribute.max) === BigInt(9223372036854776000)) {
123
95
  delete finalAttribute.max;
124
96
  }
125
- await tryAwaitWithRetry(async () => await db.createIntegerAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min, finalAttribute.max, finalAttribute.xdefault || undefined, finalAttribute.array));
97
+ await tryAwaitWithRetry(async () => await db.createIntegerAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min || -2147483647, finalAttribute.max || 2147483647, finalAttribute.xdefault || (finalAttribute.required ? undefined : ""), finalAttribute.array || false));
126
98
  }
127
99
  else {
128
100
  if (finalAttribute.min &&
@@ -133,63 +105,63 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
133
105
  BigInt(finalAttribute.max) === BigInt(9223372036854776000)) {
134
106
  delete finalAttribute.max;
135
107
  }
136
- await tryAwaitWithRetry(async () => await db.updateIntegerAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min || 0, finalAttribute.max || 2147483647, finalAttribute.xdefault || undefined));
108
+ await tryAwaitWithRetry(async () => await db.updateIntegerAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min || -2147483647, finalAttribute.max || 2147483647, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
137
109
  }
138
110
  break;
139
111
  case "float":
140
112
  if (action === "create") {
141
- await tryAwaitWithRetry(async () => await db.createFloatAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min, finalAttribute.max, finalAttribute.xdefault || undefined, finalAttribute.array));
113
+ await tryAwaitWithRetry(async () => await db.createFloatAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min || -2147483647, finalAttribute.max || 2147483647, finalAttribute.xdefault || (finalAttribute.required ? undefined : null), finalAttribute.array || false));
142
114
  }
143
115
  else {
144
- await tryAwaitWithRetry(async () => await db.updateFloatAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min || 0, finalAttribute.max || 2147483647, finalAttribute.xdefault || undefined));
116
+ await tryAwaitWithRetry(async () => await db.updateFloatAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.min || -2147483647, finalAttribute.max || 2147483647, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
145
117
  }
146
118
  break;
147
119
  case "boolean":
148
120
  if (action === "create") {
149
- await tryAwaitWithRetry(async () => await db.createBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
121
+ await tryAwaitWithRetry(async () => await db.createBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null), finalAttribute.array || false));
150
122
  }
151
123
  else {
152
- await tryAwaitWithRetry(async () => await db.updateBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || null));
124
+ await tryAwaitWithRetry(async () => await db.updateBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
153
125
  }
154
126
  break;
155
127
  case "datetime":
156
128
  if (action === "create") {
157
- await tryAwaitWithRetry(async () => await db.createDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
129
+ await tryAwaitWithRetry(async () => await db.createDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null), finalAttribute.array || false));
158
130
  }
159
131
  else {
160
- await tryAwaitWithRetry(async () => await db.updateDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined));
132
+ await tryAwaitWithRetry(async () => await db.updateDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
161
133
  }
162
134
  break;
163
135
  case "email":
164
136
  if (action === "create") {
165
- await tryAwaitWithRetry(async () => await db.createEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
137
+ await tryAwaitWithRetry(async () => await db.createEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null), finalAttribute.array || false));
166
138
  }
167
139
  else {
168
- await tryAwaitWithRetry(async () => await db.updateEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined));
140
+ await tryAwaitWithRetry(async () => await db.updateEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
169
141
  }
170
142
  break;
171
143
  case "ip":
172
144
  if (action === "create") {
173
- await tryAwaitWithRetry(async () => await db.createIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
145
+ await tryAwaitWithRetry(async () => await db.createIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null), finalAttribute.array || false));
174
146
  }
175
147
  else {
176
- await tryAwaitWithRetry(async () => await db.updateIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined));
148
+ await tryAwaitWithRetry(async () => await db.updateIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
177
149
  }
178
150
  break;
179
151
  case "url":
180
152
  if (action === "create") {
181
- await tryAwaitWithRetry(async () => await db.createUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
153
+ await tryAwaitWithRetry(async () => await db.createUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null), finalAttribute.array || false));
182
154
  }
183
155
  else {
184
- await tryAwaitWithRetry(async () => await db.updateUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || undefined));
156
+ await tryAwaitWithRetry(async () => await db.updateUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
185
157
  }
186
158
  break;
187
159
  case "enum":
188
160
  if (action === "create") {
189
- await tryAwaitWithRetry(async () => await db.createEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required || false, finalAttribute.xdefault || undefined, finalAttribute.array));
161
+ await tryAwaitWithRetry(async () => await db.createEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null), finalAttribute.array || false));
190
162
  }
191
163
  else {
192
- await tryAwaitWithRetry(async () => await db.updateEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required || false, finalAttribute.xdefault || undefined));
164
+ await tryAwaitWithRetry(async () => await db.updateEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
193
165
  }
194
166
  break;
195
167
  case "relationship":
@@ -105,7 +105,7 @@ export const tryAwaitWithRetry = async (createFunction, attemptNum = 0, throwErr
105
105
  if (throwError) {
106
106
  throw error;
107
107
  }
108
- console.error("Error during retryAwait function: " + error);
108
+ console.error("Error during retryAwait function: ", error);
109
109
  // @ts-ignore
110
110
  return Promise.resolve();
111
111
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "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": "0.9.64",
4
+ "version": "0.9.68",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -12,11 +12,7 @@ const attributesSame = (
12
12
  databaseAttribute: Attribute,
13
13
  configAttribute: Attribute
14
14
  ): boolean => {
15
- return (
16
- databaseAttribute.key == configAttribute.key &&
17
- databaseAttribute.type == configAttribute.type &&
18
- databaseAttribute.array == configAttribute.array
19
- );
15
+ return databaseAttribute.key === configAttribute.key;
20
16
  };
21
17
 
22
18
  export const createOrUpdateAttribute = async (
@@ -39,69 +35,26 @@ export const createOrUpdateAttribute = async (
39
35
  foundAttribute = undefined;
40
36
  }
41
37
 
42
- if (
43
- foundAttribute &&
44
- attributesSame(foundAttribute, attribute) &&
45
- updateEnabled
46
- ) {
47
- // Check if mutable properties have changed and set action to "update" if necessary
48
- const requiredChanged =
49
- "required" in foundAttribute && "required" in attribute
50
- ? foundAttribute.required !== attribute.required
51
- : false;
52
-
53
- // const xdefaultChanged =
54
- // "xdefault" in foundAttribute && "xdefault" in attribute
55
- // ? foundAttribute.xdefault !== attribute.xdefault
56
- // : false;
57
-
58
- const onDeleteChanged =
59
- foundAttribute.type === "relationship" &&
60
- attribute.type === "relationship" &&
61
- "onDelete" in foundAttribute &&
62
- "onDelete" in attribute
63
- ? foundAttribute.onDelete !== attribute.onDelete
64
- : false;
65
-
66
- if (requiredChanged || onDeleteChanged) {
67
- console.log(
68
- `Required changed: ${requiredChanged}\nOnDelete changed: ${onDeleteChanged}`
69
- );
70
- console.log(
71
- `Found attribute: ${JSON.stringify(foundAttribute, null, 2)}`
72
- );
73
- console.log(`Attribute: ${JSON.stringify(attribute, null, 2)}`);
74
- finalAttribute = {
75
- ...attribute,
76
- ...foundAttribute,
77
- };
78
- action = "update";
79
- } else {
80
- // If no properties that can be updated have changed, return early
81
- return;
82
- }
83
- } else if (
84
- foundAttribute &&
85
- !attributesSame(foundAttribute, attribute) &&
86
- updateEnabled
87
- ) {
38
+ if (foundAttribute && attributesSame(foundAttribute, attribute) && updateEnabled) {
39
+ finalAttribute = {
40
+ ...attribute,
41
+ ...foundAttribute,
42
+ };
43
+ action = "update";
44
+ } else if (foundAttribute && !attributesSame(foundAttribute, attribute) && updateEnabled) {
88
45
  console.log(
89
- `Deleting attribute with same key ${
90
- attribute.key
91
- } -- but different values -- ${JSON.stringify(
92
- attribute,
93
- null,
94
- 2
95
- )} -- ${JSON.stringify(foundAttribute, null, 2)}`
46
+ `Updating attribute with same key ${attribute.key} but different values`
96
47
  );
97
- await db.deleteAttribute(dbId, collection.$id, attribute.key);
98
- // After deletion, you might want to create the attribute anew
99
48
  finalAttribute = attribute;
100
- action = "create";
49
+ action = "update";
101
50
  } else if (!updateEnabled && foundAttribute) {
51
+ await db.deleteAttribute(dbId, collection.$id, attribute.key);
52
+ console.log(`Deleted attribute: ${attribute.key} to recreate it (update disabled temporarily)`);
102
53
  return;
103
54
  }
104
55
 
56
+ console.log(`${action}-ing attribute: ${finalAttribute.key}`);
57
+
105
58
  // Relationship attribute logic with adjustments
106
59
  let collectionFoundViaRelatedCollection: Models.Collection | undefined;
107
60
  let relatedCollectionId: string | undefined;
@@ -158,7 +111,7 @@ export const createOrUpdateAttribute = async (
158
111
  finalAttribute.key,
159
112
  finalAttribute.size,
160
113
  finalAttribute.required || false,
161
- finalAttribute.xdefault || undefined,
114
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
162
115
  finalAttribute.array || false,
163
116
  finalAttribute.encrypted
164
117
  )
@@ -171,7 +124,8 @@ export const createOrUpdateAttribute = async (
171
124
  collection.$id,
172
125
  finalAttribute.key,
173
126
  finalAttribute.required || false,
174
- finalAttribute.xdefault || undefined
127
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : ""),
128
+ finalAttribute.size
175
129
  )
176
130
  );
177
131
  }
@@ -197,10 +151,10 @@ export const createOrUpdateAttribute = async (
197
151
  collection.$id,
198
152
  finalAttribute.key,
199
153
  finalAttribute.required || false,
200
- finalAttribute.min,
201
- finalAttribute.max,
202
- finalAttribute.xdefault || undefined,
203
- finalAttribute.array
154
+ finalAttribute.min || -2147483647,
155
+ finalAttribute.max || 2147483647,
156
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : ""),
157
+ finalAttribute.array || false
204
158
  )
205
159
  );
206
160
  } else {
@@ -223,9 +177,9 @@ export const createOrUpdateAttribute = async (
223
177
  collection.$id,
224
178
  finalAttribute.key,
225
179
  finalAttribute.required || false,
226
- finalAttribute.min || 0,
180
+ finalAttribute.min || -2147483647,
227
181
  finalAttribute.max || 2147483647,
228
- finalAttribute.xdefault || undefined
182
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
229
183
  )
230
184
  );
231
185
  }
@@ -239,10 +193,10 @@ export const createOrUpdateAttribute = async (
239
193
  collection.$id,
240
194
  finalAttribute.key,
241
195
  finalAttribute.required || false,
242
- finalAttribute.min,
243
- finalAttribute.max,
244
- finalAttribute.xdefault || undefined,
245
- finalAttribute.array
196
+ finalAttribute.min || -2147483647,
197
+ finalAttribute.max || 2147483647,
198
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
199
+ finalAttribute.array || false
246
200
  )
247
201
  );
248
202
  } else {
@@ -253,9 +207,9 @@ export const createOrUpdateAttribute = async (
253
207
  collection.$id,
254
208
  finalAttribute.key,
255
209
  finalAttribute.required || false,
256
- finalAttribute.min || 0,
210
+ finalAttribute.min || -2147483647,
257
211
  finalAttribute.max || 2147483647,
258
- finalAttribute.xdefault || undefined
212
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
259
213
  )
260
214
  );
261
215
  }
@@ -269,8 +223,8 @@ export const createOrUpdateAttribute = async (
269
223
  collection.$id,
270
224
  finalAttribute.key,
271
225
  finalAttribute.required || false,
272
- finalAttribute.xdefault || undefined,
273
- finalAttribute.array
226
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
227
+ finalAttribute.array || false
274
228
  )
275
229
  );
276
230
  } else {
@@ -281,7 +235,7 @@ export const createOrUpdateAttribute = async (
281
235
  collection.$id,
282
236
  finalAttribute.key,
283
237
  finalAttribute.required || false,
284
- finalAttribute.xdefault || null
238
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
285
239
  )
286
240
  );
287
241
  }
@@ -295,8 +249,8 @@ export const createOrUpdateAttribute = async (
295
249
  collection.$id,
296
250
  finalAttribute.key,
297
251
  finalAttribute.required || false,
298
- finalAttribute.xdefault || undefined,
299
- finalAttribute.array
252
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
253
+ finalAttribute.array || false
300
254
  )
301
255
  );
302
256
  } else {
@@ -307,7 +261,7 @@ export const createOrUpdateAttribute = async (
307
261
  collection.$id,
308
262
  finalAttribute.key,
309
263
  finalAttribute.required || false,
310
- finalAttribute.xdefault || undefined
264
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
311
265
  )
312
266
  );
313
267
  }
@@ -321,8 +275,8 @@ export const createOrUpdateAttribute = async (
321
275
  collection.$id,
322
276
  finalAttribute.key,
323
277
  finalAttribute.required || false,
324
- finalAttribute.xdefault || undefined,
325
- finalAttribute.array
278
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
279
+ finalAttribute.array || false
326
280
  )
327
281
  );
328
282
  } else {
@@ -333,7 +287,7 @@ export const createOrUpdateAttribute = async (
333
287
  collection.$id,
334
288
  finalAttribute.key,
335
289
  finalAttribute.required || false,
336
- finalAttribute.xdefault || undefined
290
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
337
291
  )
338
292
  );
339
293
  }
@@ -347,8 +301,8 @@ export const createOrUpdateAttribute = async (
347
301
  collection.$id,
348
302
  finalAttribute.key,
349
303
  finalAttribute.required || false,
350
- finalAttribute.xdefault || undefined,
351
- finalAttribute.array
304
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
305
+ finalAttribute.array || false
352
306
  )
353
307
  );
354
308
  } else {
@@ -359,7 +313,7 @@ export const createOrUpdateAttribute = async (
359
313
  collection.$id,
360
314
  finalAttribute.key,
361
315
  finalAttribute.required || false,
362
- finalAttribute.xdefault || undefined
316
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
363
317
  )
364
318
  );
365
319
  }
@@ -373,8 +327,8 @@ export const createOrUpdateAttribute = async (
373
327
  collection.$id,
374
328
  finalAttribute.key,
375
329
  finalAttribute.required || false,
376
- finalAttribute.xdefault || undefined,
377
- finalAttribute.array
330
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
331
+ finalAttribute.array || false
378
332
  )
379
333
  );
380
334
  } else {
@@ -385,7 +339,7 @@ export const createOrUpdateAttribute = async (
385
339
  collection.$id,
386
340
  finalAttribute.key,
387
341
  finalAttribute.required || false,
388
- finalAttribute.xdefault || undefined
342
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
389
343
  )
390
344
  );
391
345
  }
@@ -400,8 +354,8 @@ export const createOrUpdateAttribute = async (
400
354
  finalAttribute.key,
401
355
  finalAttribute.elements,
402
356
  finalAttribute.required || false,
403
- finalAttribute.xdefault || undefined,
404
- finalAttribute.array
357
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
358
+ finalAttribute.array || false
405
359
  )
406
360
  );
407
361
  } else {
@@ -413,7 +367,7 @@ export const createOrUpdateAttribute = async (
413
367
  finalAttribute.key,
414
368
  finalAttribute.elements,
415
369
  finalAttribute.required || false,
416
- finalAttribute.xdefault || undefined
370
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
417
371
  )
418
372
  );
419
373
  }
@@ -163,7 +163,7 @@ export const tryAwaitWithRetry = async <T>(
163
163
  if (throwError) {
164
164
  throw error;
165
165
  }
166
- console.error("Error during retryAwait function: " + error);
166
+ console.error("Error during retryAwait function: ", error);
167
167
  // @ts-ignore
168
168
  return Promise.resolve();
169
169
  }