appwrite-utils-cli 0.9.66 → 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,7 @@ 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
127
128
  - 0.9.65: Temporary fix for Appwrite's `updateStringAttribute` bug
128
129
  - 0.9.64: Fixed string attribute requiring xdefault
129
130
  - 0.9.61: Remove fileURLToPath -- should hopefully fix windows
@@ -9,7 +9,7 @@ const attributesSame = (databaseAttribute, configAttribute) => {
9
9
  export const createOrUpdateAttribute = async (db, dbId, collection, attribute) => {
10
10
  let action = "create";
11
11
  let foundAttribute;
12
- const updateEnabled = true;
12
+ const updateEnabled = false;
13
13
  let finalAttribute = attribute;
14
14
  try {
15
15
  const collectionAttr = collection.attributes.find(
@@ -20,38 +20,24 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
20
20
  catch (error) {
21
21
  foundAttribute = undefined;
22
22
  }
23
- if (foundAttribute && updateEnabled) {
24
- const changedProperties = Object.keys(attribute).filter(key => {
25
- // Only consider properties that are defined and not null in the new attribute
26
- if (attribute[key] !== undefined && attribute[key] !== null && attribute[key] !== '') {
27
- // Check if the property exists in the found attribute and is different
28
- return foundAttribute[key] !== attribute[key];
29
- }
30
- return false;
31
- });
32
- if (changedProperties.length > 0) {
33
- console.log(`Changed properties: ${changedProperties.join(', ')}`);
34
- // Merge the attributes, prioritizing the new attribute's values
35
- finalAttribute = {
36
- ...foundAttribute,
37
- ...attribute,
38
- };
39
- action = "update";
40
- }
41
- else {
42
- // If no properties that can be updated have changed, return early
43
- return;
44
- }
23
+ if (foundAttribute && attributesSame(foundAttribute, attribute) && updateEnabled) {
24
+ finalAttribute = {
25
+ ...attribute,
26
+ ...foundAttribute,
27
+ };
28
+ action = "update";
45
29
  }
46
- else if (!foundAttribute) {
47
- // If the attribute doesn't exist, we'll create it
30
+ else if (foundAttribute && !attributesSame(foundAttribute, attribute) && updateEnabled) {
31
+ console.log(`Updating attribute with same key ${attribute.key} but different values`);
48
32
  finalAttribute = attribute;
49
- action = "create";
33
+ action = "update";
50
34
  }
51
- else if (!updateEnabled) {
52
- // If updates are not enabled and the attribute exists, we do nothing
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)`);
53
38
  return;
54
39
  }
40
+ console.log(`${action}-ing attribute: ${finalAttribute.key}`);
55
41
  // Relationship attribute logic with adjustments
56
42
  let collectionFoundViaRelatedCollection;
57
43
  let relatedCollectionId;
@@ -92,10 +78,10 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
92
78
  switch (finalAttribute.type) {
93
79
  case "string":
94
80
  if (action === "create") {
95
- await tryAwaitWithRetry(async () => await db.createStringAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.size, finalAttribute.required, finalAttribute.xdefault, finalAttribute.array, 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));
96
82
  }
97
83
  else {
98
- await tryAwaitWithRetry(async () => await db.updateStringAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault, finalAttribute.size));
84
+ await tryAwaitWithRetry(async () => await db.updateStringAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : ""), finalAttribute.size));
99
85
  }
100
86
  break;
101
87
  case "integer":
@@ -108,7 +94,7 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
108
94
  BigInt(finalAttribute.max) === BigInt(9223372036854776000)) {
109
95
  delete finalAttribute.max;
110
96
  }
111
- await tryAwaitWithRetry(async () => await db.createIntegerAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.min, finalAttribute.max, finalAttribute.xdefault, 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));
112
98
  }
113
99
  else {
114
100
  if (finalAttribute.min &&
@@ -119,63 +105,63 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
119
105
  BigInt(finalAttribute.max) === BigInt(9223372036854776000)) {
120
106
  delete finalAttribute.max;
121
107
  }
122
- await tryAwaitWithRetry(async () => await db.updateIntegerAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.min, finalAttribute.max, finalAttribute.xdefault));
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)));
123
109
  }
124
110
  break;
125
111
  case "float":
126
112
  if (action === "create") {
127
- await tryAwaitWithRetry(async () => await db.createFloatAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.min, finalAttribute.max, finalAttribute.xdefault, 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));
128
114
  }
129
115
  else {
130
- await tryAwaitWithRetry(async () => await db.updateFloatAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.min, finalAttribute.max, finalAttribute.xdefault));
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)));
131
117
  }
132
118
  break;
133
119
  case "boolean":
134
120
  if (action === "create") {
135
- await tryAwaitWithRetry(async () => await db.createBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault, 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));
136
122
  }
137
123
  else {
138
- await tryAwaitWithRetry(async () => await db.updateBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault));
124
+ await tryAwaitWithRetry(async () => await db.updateBooleanAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
139
125
  }
140
126
  break;
141
127
  case "datetime":
142
128
  if (action === "create") {
143
- await tryAwaitWithRetry(async () => await db.createDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault, 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));
144
130
  }
145
131
  else {
146
- await tryAwaitWithRetry(async () => await db.updateDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault));
132
+ await tryAwaitWithRetry(async () => await db.updateDatetimeAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
147
133
  }
148
134
  break;
149
135
  case "email":
150
136
  if (action === "create") {
151
- await tryAwaitWithRetry(async () => await db.createEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault, 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));
152
138
  }
153
139
  else {
154
- await tryAwaitWithRetry(async () => await db.updateEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault));
140
+ await tryAwaitWithRetry(async () => await db.updateEmailAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
155
141
  }
156
142
  break;
157
143
  case "ip":
158
144
  if (action === "create") {
159
- await tryAwaitWithRetry(async () => await db.createIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault, 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));
160
146
  }
161
147
  else {
162
- await tryAwaitWithRetry(async () => await db.updateIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault));
148
+ await tryAwaitWithRetry(async () => await db.updateIpAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
163
149
  }
164
150
  break;
165
151
  case "url":
166
152
  if (action === "create") {
167
- await tryAwaitWithRetry(async () => await db.createUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault, 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));
168
154
  }
169
155
  else {
170
- await tryAwaitWithRetry(async () => await db.updateUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required, finalAttribute.xdefault));
156
+ await tryAwaitWithRetry(async () => await db.updateUrlAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
171
157
  }
172
158
  break;
173
159
  case "enum":
174
160
  if (action === "create") {
175
- await tryAwaitWithRetry(async () => await db.createEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required, finalAttribute.xdefault, 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));
176
162
  }
177
163
  else {
178
- await tryAwaitWithRetry(async () => await db.updateEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required, finalAttribute.xdefault));
164
+ await tryAwaitWithRetry(async () => await db.updateEnumAttribute(dbId, collection.$id, finalAttribute.key, finalAttribute.elements, finalAttribute.required || false, finalAttribute.xdefault || (finalAttribute.required ? undefined : null)));
179
165
  }
180
166
  break;
181
167
  case "relationship":
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.66",
4
+ "version": "0.9.68",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -23,7 +23,7 @@ export const createOrUpdateAttribute = async (
23
23
  ): Promise<void> => {
24
24
  let action = "create";
25
25
  let foundAttribute: Attribute | undefined;
26
- const updateEnabled = true;
26
+ const updateEnabled = false;
27
27
  let finalAttribute: any = attribute;
28
28
  try {
29
29
  const collectionAttr = collection.attributes.find(
@@ -35,38 +35,26 @@ export const createOrUpdateAttribute = async (
35
35
  foundAttribute = undefined;
36
36
  }
37
37
 
38
- if (foundAttribute && updateEnabled) {
39
- const changedProperties = Object.keys(attribute).filter(key => {
40
- // Only consider properties that are defined and not null in the new attribute
41
- if (attribute[key as keyof typeof attribute] !== undefined && attribute[key as keyof typeof attribute] !== null && attribute[key as keyof typeof attribute] !== '') {
42
- // Check if the property exists in the found attribute and is different
43
- return foundAttribute[key as keyof typeof foundAttribute] !== attribute[key as keyof typeof attribute];
44
- }
45
- return false;
46
- });
47
-
48
- if (changedProperties.length > 0) {
49
- console.log(`Changed properties: ${changedProperties.join(', ')}`);
50
-
51
- // Merge the attributes, prioritizing the new attribute's values
52
- finalAttribute = {
53
- ...foundAttribute,
54
- ...attribute,
55
- };
56
- action = "update";
57
- } else {
58
- // If no properties that can be updated have changed, return early
59
- return;
60
- }
61
- } else if (!foundAttribute) {
62
- // If the attribute doesn't exist, we'll create it
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) {
45
+ console.log(
46
+ `Updating attribute with same key ${attribute.key} but different values`
47
+ );
63
48
  finalAttribute = attribute;
64
- action = "create";
65
- } else if (!updateEnabled) {
66
- // If updates are not enabled and the attribute exists, we do nothing
49
+ action = "update";
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)`);
67
53
  return;
68
54
  }
69
55
 
56
+ console.log(`${action}-ing attribute: ${finalAttribute.key}`);
57
+
70
58
  // Relationship attribute logic with adjustments
71
59
  let collectionFoundViaRelatedCollection: Models.Collection | undefined;
72
60
  let relatedCollectionId: string | undefined;
@@ -122,9 +110,9 @@ export const createOrUpdateAttribute = async (
122
110
  collection.$id,
123
111
  finalAttribute.key,
124
112
  finalAttribute.size,
125
- finalAttribute.required,
126
- finalAttribute.xdefault,
127
- finalAttribute.array,
113
+ finalAttribute.required || false,
114
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
115
+ finalAttribute.array || false,
128
116
  finalAttribute.encrypted
129
117
  )
130
118
  );
@@ -135,8 +123,8 @@ export const createOrUpdateAttribute = async (
135
123
  dbId,
136
124
  collection.$id,
137
125
  finalAttribute.key,
138
- finalAttribute.required,
139
- finalAttribute.xdefault,
126
+ finalAttribute.required || false,
127
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : ""),
140
128
  finalAttribute.size
141
129
  )
142
130
  );
@@ -162,11 +150,11 @@ export const createOrUpdateAttribute = async (
162
150
  dbId,
163
151
  collection.$id,
164
152
  finalAttribute.key,
165
- finalAttribute.required,
166
- finalAttribute.min,
167
- finalAttribute.max,
168
- finalAttribute.xdefault,
169
- finalAttribute.array
153
+ finalAttribute.required || false,
154
+ finalAttribute.min || -2147483647,
155
+ finalAttribute.max || 2147483647,
156
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : ""),
157
+ finalAttribute.array || false
170
158
  )
171
159
  );
172
160
  } else {
@@ -188,10 +176,10 @@ export const createOrUpdateAttribute = async (
188
176
  dbId,
189
177
  collection.$id,
190
178
  finalAttribute.key,
191
- finalAttribute.required,
192
- finalAttribute.min,
193
- finalAttribute.max,
194
- finalAttribute.xdefault
179
+ finalAttribute.required || false,
180
+ finalAttribute.min || -2147483647,
181
+ finalAttribute.max || 2147483647,
182
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
195
183
  )
196
184
  );
197
185
  }
@@ -204,11 +192,11 @@ export const createOrUpdateAttribute = async (
204
192
  dbId,
205
193
  collection.$id,
206
194
  finalAttribute.key,
207
- finalAttribute.required,
208
- finalAttribute.min,
209
- finalAttribute.max,
210
- finalAttribute.xdefault,
211
- finalAttribute.array
195
+ finalAttribute.required || false,
196
+ finalAttribute.min || -2147483647,
197
+ finalAttribute.max || 2147483647,
198
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
199
+ finalAttribute.array || false
212
200
  )
213
201
  );
214
202
  } else {
@@ -218,10 +206,10 @@ export const createOrUpdateAttribute = async (
218
206
  dbId,
219
207
  collection.$id,
220
208
  finalAttribute.key,
221
- finalAttribute.required,
222
- finalAttribute.min,
223
- finalAttribute.max,
224
- finalAttribute.xdefault
209
+ finalAttribute.required || false,
210
+ finalAttribute.min || -2147483647,
211
+ finalAttribute.max || 2147483647,
212
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
225
213
  )
226
214
  );
227
215
  }
@@ -234,9 +222,9 @@ export const createOrUpdateAttribute = async (
234
222
  dbId,
235
223
  collection.$id,
236
224
  finalAttribute.key,
237
- finalAttribute.required,
238
- finalAttribute.xdefault,
239
- finalAttribute.array
225
+ finalAttribute.required || false,
226
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
227
+ finalAttribute.array || false
240
228
  )
241
229
  );
242
230
  } else {
@@ -246,8 +234,8 @@ export const createOrUpdateAttribute = async (
246
234
  dbId,
247
235
  collection.$id,
248
236
  finalAttribute.key,
249
- finalAttribute.required,
250
- finalAttribute.xdefault
237
+ finalAttribute.required || false,
238
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
251
239
  )
252
240
  );
253
241
  }
@@ -260,9 +248,9 @@ export const createOrUpdateAttribute = async (
260
248
  dbId,
261
249
  collection.$id,
262
250
  finalAttribute.key,
263
- finalAttribute.required,
264
- finalAttribute.xdefault,
265
- finalAttribute.array
251
+ finalAttribute.required || false,
252
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
253
+ finalAttribute.array || false
266
254
  )
267
255
  );
268
256
  } else {
@@ -272,8 +260,8 @@ export const createOrUpdateAttribute = async (
272
260
  dbId,
273
261
  collection.$id,
274
262
  finalAttribute.key,
275
- finalAttribute.required,
276
- finalAttribute.xdefault
263
+ finalAttribute.required || false,
264
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
277
265
  )
278
266
  );
279
267
  }
@@ -286,9 +274,9 @@ export const createOrUpdateAttribute = async (
286
274
  dbId,
287
275
  collection.$id,
288
276
  finalAttribute.key,
289
- finalAttribute.required,
290
- finalAttribute.xdefault,
291
- finalAttribute.array
277
+ finalAttribute.required || false,
278
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
279
+ finalAttribute.array || false
292
280
  )
293
281
  );
294
282
  } else {
@@ -298,8 +286,8 @@ export const createOrUpdateAttribute = async (
298
286
  dbId,
299
287
  collection.$id,
300
288
  finalAttribute.key,
301
- finalAttribute.required,
302
- finalAttribute.xdefault
289
+ finalAttribute.required || false,
290
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
303
291
  )
304
292
  );
305
293
  }
@@ -312,9 +300,9 @@ export const createOrUpdateAttribute = async (
312
300
  dbId,
313
301
  collection.$id,
314
302
  finalAttribute.key,
315
- finalAttribute.required,
316
- finalAttribute.xdefault,
317
- finalAttribute.array
303
+ finalAttribute.required || false,
304
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
305
+ finalAttribute.array || false
318
306
  )
319
307
  );
320
308
  } else {
@@ -324,8 +312,8 @@ export const createOrUpdateAttribute = async (
324
312
  dbId,
325
313
  collection.$id,
326
314
  finalAttribute.key,
327
- finalAttribute.required,
328
- finalAttribute.xdefault
315
+ finalAttribute.required || false,
316
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
329
317
  )
330
318
  );
331
319
  }
@@ -338,9 +326,9 @@ export const createOrUpdateAttribute = async (
338
326
  dbId,
339
327
  collection.$id,
340
328
  finalAttribute.key,
341
- finalAttribute.required,
342
- finalAttribute.xdefault,
343
- finalAttribute.array
329
+ finalAttribute.required || false,
330
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
331
+ finalAttribute.array || false
344
332
  )
345
333
  );
346
334
  } else {
@@ -350,8 +338,8 @@ export const createOrUpdateAttribute = async (
350
338
  dbId,
351
339
  collection.$id,
352
340
  finalAttribute.key,
353
- finalAttribute.required,
354
- finalAttribute.xdefault
341
+ finalAttribute.required || false,
342
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
355
343
  )
356
344
  );
357
345
  }
@@ -365,9 +353,9 @@ export const createOrUpdateAttribute = async (
365
353
  collection.$id,
366
354
  finalAttribute.key,
367
355
  finalAttribute.elements,
368
- finalAttribute.required,
369
- finalAttribute.xdefault,
370
- finalAttribute.array
356
+ finalAttribute.required || false,
357
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null),
358
+ finalAttribute.array || false
371
359
  )
372
360
  );
373
361
  } else {
@@ -378,8 +366,8 @@ export const createOrUpdateAttribute = async (
378
366
  collection.$id,
379
367
  finalAttribute.key,
380
368
  finalAttribute.elements,
381
- finalAttribute.required,
382
- finalAttribute.xdefault
369
+ finalAttribute.required || false,
370
+ finalAttribute.xdefault || (finalAttribute.required ? undefined : null)
383
371
  )
384
372
  );
385
373
  }