appwrite-utils-cli 0.10.82 → 0.10.83

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.
@@ -16,14 +16,14 @@ import path from "path";
16
16
  import fs from "fs";
17
17
  import { convertObjectByAttributeMappings } from "./converters.js";
18
18
  import { z } from "zod";
19
- import { checkForCollection } from "./collections.js";
19
+ import { checkForCollection } from "../collections/methods.js";
20
20
  import { ID, Users, type Databases } from "node-appwrite";
21
21
  import { logger } from "./logging.js";
22
22
  import { findOrCreateOperation, updateOperation } from "./migrationHelper.js";
23
23
  import { AuthUserCreateSchema } from "../schemas/authUser.js";
24
- import _ from "lodash";
25
24
  import { UsersController } from "./users.js";
26
25
  import { finalizeByAttributeMap } from "../utils/helperFunctions.js";
26
+ import { isEmpty } from "es-toolkit/compat";
27
27
 
28
28
  // Define a schema for the structure of collection import data using Zod for validation
29
29
  export const CollectionImportDataSchema = z.object({
@@ -315,7 +315,7 @@ export class DataLoader {
315
315
  // Find or create an import operation for the collection
316
316
  const collectionImportOperation = await findOrCreateOperation(
317
317
  this.database,
318
- collection.$id,
318
+ collection.$id!,
319
319
  "importData"
320
320
  );
321
321
  // Store the operation ID in the map
@@ -556,7 +556,7 @@ export class DataLoader {
556
556
  // Skip if value to match is missing or empty
557
557
  if (
558
558
  !sourceValue ||
559
- _.isEmpty(sourceValue) ||
559
+ isEmpty(sourceValue) ||
560
560
  sourceValue === null
561
561
  )
562
562
  continue;
@@ -13,7 +13,6 @@ import type {
13
13
  AttributeMappings,
14
14
  } from "appwrite-utils";
15
15
  import type { ImportDataActions } from "./importDataActions.js";
16
- import _ from "lodash";
17
16
  import { areCollectionNamesSame, tryAwaitWithRetry } from "../utils/index.js";
18
17
  import type { SetupOptions } from "../utilsController.js";
19
18
  import { resolveAndUpdateRelationships } from "./relationships.js";
@@ -1,8 +1,7 @@
1
1
  import { Query, type Databases, type Models } from "node-appwrite";
2
2
  import type { Attribute } from "appwrite-utils";
3
3
  import { createOrUpdateAttribute } from "./attributes.js";
4
- import _ from "lodash";
5
- import { fetchAndCacheCollectionByName } from "./collections.js";
4
+ import { fetchAndCacheCollectionByName } from "../collections/methods.js";
6
5
  import { tryAwaitWithRetry } from "../utils/helperFunctions.js";
7
6
 
8
7
  export interface QueuedOperation {
@@ -1,5 +1,5 @@
1
1
  import { Databases, Query, type Models } from "node-appwrite";
2
- import { fetchAllCollections } from "./collections.js";
2
+ import { fetchAllCollections } from "../collections/methods.js";
3
3
  import type {
4
4
  AppwriteConfig,
5
5
  Attribute,
@@ -12,13 +12,14 @@ import {
12
12
  type AuthUser,
13
13
  type AuthUserCreate,
14
14
  } from "../schemas/authUser.js";
15
- import _ from "lodash";
16
15
  import { logger } from "./logging.js";
17
16
  import { splitIntoBatches } from "./migrationHelper.js";
18
17
  import {
19
18
  getAppwriteClient,
20
19
  tryAwaitWithRetry,
21
20
  } from "../utils/helperFunctions.js";
21
+ import { isUndefined } from "es-toolkit/compat";
22
+ import { isEmpty } from "es-toolkit/compat";
22
23
 
23
24
  export class UsersController {
24
25
  private config: AppwriteConfig;
@@ -123,17 +124,17 @@ export class UsersController {
123
124
  `changeMe${item.email?.toLowerCase()}` || `changeMePlease`,
124
125
  item.name || undefined
125
126
  );
126
-
127
+
127
128
  if (item.labels) {
128
129
  await this.users.updateLabels(createdUser.$id, item.labels);
129
130
  }
130
131
  if (item.prefs) {
131
132
  await this.users.updatePrefs(createdUser.$id, item.prefs);
132
133
  }
133
-
134
+
134
135
  return createdUser;
135
136
  }); // Set throwError to true since we want to handle errors
136
-
137
+
137
138
  return user;
138
139
  } catch (e) {
139
140
  if (e instanceof Error) {
@@ -181,8 +182,8 @@ export class UsersController {
181
182
  if (
182
183
  item.email &&
183
184
  item.email !== userToReturn.email &&
184
- !_.isEmpty(item.email) &&
185
- !_.isUndefined(item.email)
185
+ !isEmpty(item.email) &&
186
+ !isUndefined(item.email)
186
187
  ) {
187
188
  const emailExists = await this.users.list([
188
189
  Query.equal("email", item.email),
@@ -213,7 +214,7 @@ export class UsersController {
213
214
  item.phone !== userToReturn.phone &&
214
215
  item.phone.length < 15 &&
215
216
  item.phone.startsWith("+") &&
216
- (_.isUndefined(userToReturn.phone) || _.isEmpty(userToReturn.phone))
217
+ (isUndefined(userToReturn.phone) || isEmpty(userToReturn.phone))
217
218
  ) {
218
219
  const userFoundWithPhone = await this.users.list([
219
220
  Query.equal("phone", item.phone),
@@ -1,17 +1,42 @@
1
- import _ from "lodash";
2
-
1
+ import {
2
+ isNumber,
3
+ isString,
4
+ isBoolean,
5
+ isArray,
6
+ isPlainObject,
7
+ isNull,
8
+ isUndefined,
9
+ isDate,
10
+ isEmpty,
11
+ isInteger,
12
+ isArrayLike,
13
+ isArrayLikeObject,
14
+ isFunction,
15
+ isLength,
16
+ isMap,
17
+ isSet,
18
+ isRegExp,
19
+ isSymbol,
20
+ isObjectLike,
21
+ isSafeInteger,
22
+ isTypedArray,
23
+ isEqual,
24
+ isMatch,
25
+ has,
26
+ get,
27
+ } from "es-toolkit/compat";
3
28
  export interface ValidationRules {
4
29
  [key: string]: (value: any, ...args: any[]) => boolean;
5
30
  }
6
31
 
7
32
  export const validationRules = {
8
- isNumber: (value: any): boolean => _.isNumber(value),
9
- isString: (value: any): boolean => _.isString(value),
10
- isBoolean: (value: any): boolean => _.isBoolean(value),
11
- isArray: (value: any): boolean => _.isArray(value),
33
+ isNumber: (value: any): boolean => isNumber(value),
34
+ isString: (value: any): boolean => isString(value),
35
+ isBoolean: (value: any): boolean => isBoolean(value),
36
+ isArray: (value: any): boolean => isArray(value),
12
37
  isObject: (value: any): boolean =>
13
- _.isObject(value) && !_.isArray(value) && !_.isFunction(value),
14
- isNull: (value: any): boolean => _.isNull(value),
38
+ isPlainObject(value) && !isArray(value) && !isFunction(value),
39
+ isNull: (value: any): boolean => isNull(value),
15
40
  isValidEmail: (value: string): boolean =>
16
41
  value.match(/^[\w\-\.]+@([\w-]+\.)+[\w-]{2,}$/) !== null,
17
42
  isValidPhone: (value: string): boolean =>
@@ -35,29 +60,29 @@ export const validationRules = {
35
60
  value.match(/^\d{4}-\d{2}-\d{2}$/) !== null,
36
61
  isValidTime: (value: string): boolean =>
37
62
  value.match(/^\d{2}:\d{2}(:\d{2})?$/) !== null,
38
- isNullish: (value: any): boolean => _.isNull(value) || _.isUndefined(value),
39
- isUndefined: (value: any): boolean => _.isUndefined(value),
63
+ isNullish: (value: any): boolean => isNull(value) || isUndefined(value),
64
+ isUndefined: (value: any): boolean => isUndefined(value),
40
65
  isDefined: (value: any): boolean =>
41
- !_.isUndefined(value) && !_.isNull(value) && !_.isEmpty(value),
42
- isDate: (value: any): boolean => _.isDate(value),
43
- isEmpty: (value: any): boolean => _.isEmpty(value),
44
- isInteger: (value: any): boolean => _.isInteger(value),
45
- isFloat: (value: any): boolean => _.isNumber(value) && !_.isInteger(value),
46
- isArrayLike: (value: any): boolean => _.isArrayLike(value),
47
- isArrayLikeObject: (value: any): boolean => _.isArrayLikeObject(value),
48
- isFunction: (value: any): boolean => _.isFunction(value),
49
- isLength: (value: any): boolean => _.isLength(value),
50
- isMap: (value: any): boolean => _.isMap(value),
51
- isSet: (value: any): boolean => _.isSet(value),
52
- isRegExp: (value: any): boolean => _.isRegExp(value),
53
- isSymbol: (value: any): boolean => _.isSymbol(value),
54
- isObjectLike: (value: any): boolean => _.isObjectLike(value),
55
- isPlainObject: (value: any): boolean => _.isPlainObject(value),
56
- isSafeInteger: (value: any): boolean => _.isSafeInteger(value),
57
- isTypedArray: (value: any): boolean => _.isTypedArray(value),
58
- isEqual: (value: any, other: any): boolean => _.isEqual(value, other),
59
- isMatch: (object: any, source: any): boolean => _.isMatch(object, source),
60
- has: (object: any, path: string): boolean => _.has(object, path),
66
+ !isUndefined(value) && !isNull(value) && !isEmpty(value),
67
+ isDate: (value: any): boolean => isDate(value),
68
+ isEmpty: (value: any): boolean => isEmpty(value),
69
+ isInteger: (value: any): boolean => isInteger(value),
70
+ isFloat: (value: any): boolean => isNumber(value) && !isInteger(value),
71
+ isArrayLike: (value: any): boolean => isArrayLike(value),
72
+ isArrayLikeObject: (value: any): boolean => isArrayLikeObject(value),
73
+ isFunction: (value: any): boolean => isFunction(value),
74
+ isLength: (value: any): boolean => isLength(value),
75
+ isMap: (value: any): boolean => isMap(value),
76
+ isSet: (value: any): boolean => isSet(value),
77
+ isRegExp: (value: any): boolean => isRegExp(value),
78
+ isSymbol: (value: any): boolean => isSymbol(value),
79
+ isObjectLike: (value: any): boolean => isObjectLike(value),
80
+ isPlainObject: (value: any): boolean => isPlainObject(value),
81
+ isSafeInteger: (value: any): boolean => isSafeInteger(value),
82
+ isTypedArray: (value: any): boolean => isTypedArray(value),
83
+ isEqual: (value: any, other: any): boolean => isEqual(value, other),
84
+ isMatch: (object: any, source: any): boolean => isMatch(object, source),
85
+ has: (object: any, path: string): boolean => has(object, path),
61
86
  get: (object: any, path: string, defaultValue: any): any =>
62
- _.get(object, path, defaultValue),
87
+ get(object, path, defaultValue),
63
88
  };