appwrite-utils-cli 1.9.1 → 1.9.2

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.
@@ -2,7 +2,7 @@ import { AppwriteException, Client, Functions, Query, Runtime, } from "node-appw
2
2
  import { join, dirname } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import fs from "node:fs";
5
- import {} from "appwrite-utils";
5
+ import { EventTypeSchema, } from "appwrite-utils";
6
6
  import chalk from "chalk";
7
7
  import { extract as extractTar } from "tar";
8
8
  import { MessageFormatter } from "../shared/messageFormatter.js";
@@ -10,6 +10,7 @@ import { expandTildePath, normalizeFunctionName } from "./pathResolution.js";
10
10
  /**
11
11
  * Validates and filters events array for Appwrite functions
12
12
  * - Filters out empty/invalid strings
13
+ * - Validates against EventTypeSchema
13
14
  * - Limits to 100 items maximum (Appwrite limit)
14
15
  * - Returns empty array if input is invalid
15
16
  */
@@ -17,7 +18,18 @@ const validateEvents = (events) => {
17
18
  if (!events || !Array.isArray(events))
18
19
  return [];
19
20
  return events
20
- .filter(event => event && typeof event === 'string' && event.trim().length > 0)
21
+ .filter(event => {
22
+ if (!event || typeof event !== 'string' || event.trim().length === 0) {
23
+ return false;
24
+ }
25
+ // Validate against EventTypeSchema
26
+ const result = EventTypeSchema.safeParse(event);
27
+ if (!result.success) {
28
+ MessageFormatter.warning(`Invalid event type "${event}" will be filtered out`, { prefix: "Functions" });
29
+ return false;
30
+ }
31
+ return true;
32
+ })
21
33
  .slice(0, 100);
22
34
  };
23
35
  export const listFunctions = async (client, queries, search) => {
@@ -1,5 +1,5 @@
1
1
  import { Client, Functions, Runtime } from "node-appwrite";
2
- import {} from "appwrite-utils";
2
+ import { EventTypeSchema } from "appwrite-utils";
3
3
  import { join, relative, resolve, basename } from "node:path";
4
4
  import fs from "node:fs";
5
5
  import chalk from "chalk";
@@ -9,6 +9,7 @@ import { MessageFormatter } from "./messageFormatter.js";
9
9
  /**
10
10
  * Validates and filters events array for Appwrite functions
11
11
  * - Filters out empty/invalid strings
12
+ * - Validates against EventTypeSchema
12
13
  * - Limits to 100 items maximum (Appwrite limit)
13
14
  * - Returns empty array if input is invalid
14
15
  */
@@ -16,7 +17,18 @@ const validateEvents = (events) => {
16
17
  if (!events || !Array.isArray(events))
17
18
  return [];
18
19
  return events
19
- .filter(event => event && typeof event === 'string' && event.trim().length > 0)
20
+ .filter(event => {
21
+ if (!event || typeof event !== 'string' || event.trim().length === 0) {
22
+ return false;
23
+ }
24
+ // Validate against EventTypeSchema
25
+ const result = EventTypeSchema.safeParse(event);
26
+ if (!result.success) {
27
+ MessageFormatter.warning(`Invalid event type "${event}" will be filtered out`, { prefix: "Functions" });
28
+ return false;
29
+ }
30
+ return true;
31
+ })
20
32
  .slice(0, 100);
21
33
  };
22
34
  // Concurrency limits
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": "1.9.1",
4
+ "version": "1.9.2",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -13,6 +13,7 @@ import {
13
13
  type FunctionScope,
14
14
  type Specification,
15
15
  type Runtime as AppwriteUtilsRuntime,
16
+ EventTypeSchema,
16
17
  } from "appwrite-utils";
17
18
  import chalk from "chalk";
18
19
  import { extract as extractTar } from "tar";
@@ -22,14 +23,26 @@ import { expandTildePath, normalizeFunctionName } from "./pathResolution.js";
22
23
  /**
23
24
  * Validates and filters events array for Appwrite functions
24
25
  * - Filters out empty/invalid strings
26
+ * - Validates against EventTypeSchema
25
27
  * - Limits to 100 items maximum (Appwrite limit)
26
28
  * - Returns empty array if input is invalid
27
29
  */
28
30
  const validateEvents = (events?: string[]): string[] => {
29
31
  if (!events || !Array.isArray(events)) return [];
30
-
32
+
31
33
  return events
32
- .filter(event => event && typeof event === 'string' && event.trim().length > 0)
34
+ .filter(event => {
35
+ if (!event || typeof event !== 'string' || event.trim().length === 0) {
36
+ return false;
37
+ }
38
+ // Validate against EventTypeSchema
39
+ const result = EventTypeSchema.safeParse(event);
40
+ if (!result.success) {
41
+ MessageFormatter.warning(`Invalid event type "${event}" will be filtered out`, { prefix: "Functions" });
42
+ return false;
43
+ }
44
+ return true;
45
+ })
33
46
  .slice(0, 100);
34
47
  };
35
48
 
@@ -1,5 +1,5 @@
1
1
  import { Client, Functions, Runtime, type Models } from "node-appwrite";
2
- import { type AppwriteFunction } from "appwrite-utils";
2
+ import { type AppwriteFunction, EventTypeSchema } from "appwrite-utils";
3
3
  import { join, relative, resolve, basename } from "node:path";
4
4
  import fs from "node:fs";
5
5
  import chalk from "chalk";
@@ -10,14 +10,26 @@ import { MessageFormatter } from "./messageFormatter.js";
10
10
  /**
11
11
  * Validates and filters events array for Appwrite functions
12
12
  * - Filters out empty/invalid strings
13
+ * - Validates against EventTypeSchema
13
14
  * - Limits to 100 items maximum (Appwrite limit)
14
15
  * - Returns empty array if input is invalid
15
16
  */
16
17
  const validateEvents = (events?: string[]): string[] => {
17
18
  if (!events || !Array.isArray(events)) return [];
18
-
19
+
19
20
  return events
20
- .filter(event => event && typeof event === 'string' && event.trim().length > 0)
21
+ .filter(event => {
22
+ if (!event || typeof event !== 'string' || event.trim().length === 0) {
23
+ return false;
24
+ }
25
+ // Validate against EventTypeSchema
26
+ const result = EventTypeSchema.safeParse(event);
27
+ if (!result.success) {
28
+ MessageFormatter.warning(`Invalid event type "${event}" will be filtered out`, { prefix: "Functions" });
29
+ return false;
30
+ }
31
+ return true;
32
+ })
21
33
  .slice(0, 100);
22
34
  };
23
35