appwrite-utils
Advanced tools
Comparing version 0.3.7 to 0.3.8
@@ -0,1 +1,2 @@ | ||
import type { AttributeMappings } from "../schemas/attributeMappings.js"; | ||
export interface ConverterFunctions { | ||
@@ -163,21 +164,3 @@ [key: string]: (value: any) => any; | ||
*/ | ||
export declare const convertObjectByAttributeMappings: (obj: Record<string, any>, attributeMappings: { | ||
targetKey: string; | ||
oldKey?: string | undefined; | ||
oldKeys?: string[] | undefined; | ||
valueToSet?: any; | ||
fileData?: { | ||
path: string; | ||
name: string; | ||
} | undefined; | ||
converters?: string[] | undefined; | ||
validationActions?: { | ||
params: string[]; | ||
action: string; | ||
}[] | undefined; | ||
postImportActions?: { | ||
params: (string | Record<string, any>)[]; | ||
action: string; | ||
}[] | undefined; | ||
}[]) => Record<string, any>; | ||
export declare const convertObjectByAttributeMappings: (obj: Record<string, any>, attributeMappings: AttributeMappings) => Record<string, any>; | ||
/** | ||
@@ -184,0 +167,0 @@ * Ensures data conversion without mutating the original input. |
@@ -27,1 +27,2 @@ export { areCollectionNamesSame } from "./functions/collections.js"; | ||
export { tryAwaitWithRetry } from "./functions/helpers.js"; | ||
export { getAppwriteClient } from "./functions/appwriteHelpers.js"; |
@@ -26,1 +26,2 @@ export { areCollectionNamesSame } from "./functions/collections.js"; | ||
export { tryAwaitWithRetry } from "./functions/helpers.js"; | ||
export { getAppwriteClient } from "./functions/appwriteHelpers.js"; |
@@ -8,3 +8,2 @@ import { z } from "zod"; | ||
appwriteClient: z.ZodDefault<z.ZodUnion<[z.ZodAny, z.ZodNull]>>; | ||
enableDevDatabase: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; | ||
enableBackups: z.ZodDefault<z.ZodBoolean>; | ||
@@ -15,3 +14,2 @@ backupInterval: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; | ||
enableMockData: z.ZodDefault<z.ZodBoolean>; | ||
enableWipeOtherDatabases: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; | ||
documentBucketId: z.ZodDefault<z.ZodOptional<z.ZodString>>; | ||
@@ -22,9 +20,152 @@ usersCollectionName: z.ZodDefault<z.ZodOptional<z.ZodString>>; | ||
name: z.ZodString; | ||
bucket: z.ZodOptional<z.ZodObject<{ | ||
$id: z.ZodString; | ||
name: z.ZodString; | ||
permissions: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{ | ||
permission: z.ZodString; | ||
target: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
permission: string; | ||
target: string; | ||
}, { | ||
permission: string; | ||
target: string; | ||
}>, z.ZodEffects<z.ZodString, { | ||
permission: string; | ||
target: string; | ||
}, string>]>, "many">>>; | ||
fileSecurity: z.ZodOptional<z.ZodBoolean>; | ||
enabled: z.ZodOptional<z.ZodBoolean>; | ||
maximumFileSize: z.ZodOptional<z.ZodNumber>; | ||
allowedFileExtensions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
compression: z.ZodOptional<z.ZodEnum<["none", "gzip", "zstd"]>>; | ||
encryption: z.ZodOptional<z.ZodBoolean>; | ||
antivirus: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
name: string; | ||
$id: string; | ||
enabled?: boolean | undefined; | ||
permissions?: ({ | ||
permission: string; | ||
target: string; | ||
} | { | ||
permission: string; | ||
target: string; | ||
})[] | undefined; | ||
fileSecurity?: boolean | undefined; | ||
maximumFileSize?: number | undefined; | ||
allowedFileExtensions?: string[] | undefined; | ||
compression?: "none" | "gzip" | "zstd" | undefined; | ||
encryption?: boolean | undefined; | ||
antivirus?: boolean | undefined; | ||
}, { | ||
name: string; | ||
$id: string; | ||
enabled?: boolean | undefined; | ||
permissions?: (string | { | ||
permission: string; | ||
target: string; | ||
})[] | undefined; | ||
fileSecurity?: boolean | undefined; | ||
maximumFileSize?: number | undefined; | ||
allowedFileExtensions?: string[] | undefined; | ||
compression?: "none" | "gzip" | "zstd" | undefined; | ||
encryption?: boolean | undefined; | ||
antivirus?: boolean | undefined; | ||
}>>; | ||
}, "strip", z.ZodTypeAny, { | ||
name: string; | ||
$id: string; | ||
bucket?: { | ||
name: string; | ||
$id: string; | ||
enabled?: boolean | undefined; | ||
permissions?: ({ | ||
permission: string; | ||
target: string; | ||
} | { | ||
permission: string; | ||
target: string; | ||
})[] | undefined; | ||
fileSecurity?: boolean | undefined; | ||
maximumFileSize?: number | undefined; | ||
allowedFileExtensions?: string[] | undefined; | ||
compression?: "none" | "gzip" | "zstd" | undefined; | ||
encryption?: boolean | undefined; | ||
antivirus?: boolean | undefined; | ||
} | undefined; | ||
}, { | ||
name: string; | ||
$id: string; | ||
bucket?: { | ||
name: string; | ||
$id: string; | ||
enabled?: boolean | undefined; | ||
permissions?: (string | { | ||
permission: string; | ||
target: string; | ||
})[] | undefined; | ||
fileSecurity?: boolean | undefined; | ||
maximumFileSize?: number | undefined; | ||
allowedFileExtensions?: string[] | undefined; | ||
compression?: "none" | "gzip" | "zstd" | undefined; | ||
encryption?: boolean | undefined; | ||
antivirus?: boolean | undefined; | ||
} | undefined; | ||
}>, "many">>>; | ||
buckets: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{ | ||
$id: z.ZodString; | ||
name: z.ZodString; | ||
permissions: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{ | ||
permission: z.ZodString; | ||
target: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
permission: string; | ||
target: string; | ||
}, { | ||
permission: string; | ||
target: string; | ||
}>, z.ZodEffects<z.ZodString, { | ||
permission: string; | ||
target: string; | ||
}, string>]>, "many">>>; | ||
fileSecurity: z.ZodOptional<z.ZodBoolean>; | ||
enabled: z.ZodOptional<z.ZodBoolean>; | ||
maximumFileSize: z.ZodOptional<z.ZodNumber>; | ||
allowedFileExtensions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
compression: z.ZodOptional<z.ZodEnum<["none", "gzip", "zstd"]>>; | ||
encryption: z.ZodOptional<z.ZodBoolean>; | ||
antivirus: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
name: string; | ||
$id: string; | ||
enabled?: boolean | undefined; | ||
permissions?: ({ | ||
permission: string; | ||
target: string; | ||
} | { | ||
permission: string; | ||
target: string; | ||
})[] | undefined; | ||
fileSecurity?: boolean | undefined; | ||
maximumFileSize?: number | undefined; | ||
allowedFileExtensions?: string[] | undefined; | ||
compression?: "none" | "gzip" | "zstd" | undefined; | ||
encryption?: boolean | undefined; | ||
antivirus?: boolean | undefined; | ||
}, { | ||
name: string; | ||
$id: string; | ||
enabled?: boolean | undefined; | ||
permissions?: (string | { | ||
permission: string; | ||
target: string; | ||
})[] | undefined; | ||
fileSecurity?: boolean | undefined; | ||
maximumFileSize?: number | undefined; | ||
allowedFileExtensions?: string[] | undefined; | ||
compression?: "none" | "gzip" | "zstd" | undefined; | ||
encryption?: boolean | undefined; | ||
antivirus?: boolean | undefined; | ||
}>, "many">>>; | ||
collections: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<Omit<{ | ||
@@ -877,3 +1018,2 @@ name: z.ZodString; | ||
appwriteKey: string; | ||
enableDevDatabase: boolean; | ||
enableBackups: boolean; | ||
@@ -884,3 +1024,2 @@ backupInterval: number; | ||
enableMockData: boolean; | ||
enableWipeOtherDatabases: boolean; | ||
documentBucketId: string; | ||
@@ -891,3 +1030,39 @@ usersCollectionName: string; | ||
$id: string; | ||
bucket?: { | ||
name: string; | ||
$id: string; | ||
enabled?: boolean | undefined; | ||
permissions?: ({ | ||
permission: string; | ||
target: string; | ||
} | { | ||
permission: string; | ||
target: string; | ||
})[] | undefined; | ||
fileSecurity?: boolean | undefined; | ||
maximumFileSize?: number | undefined; | ||
allowedFileExtensions?: string[] | undefined; | ||
compression?: "none" | "gzip" | "zstd" | undefined; | ||
encryption?: boolean | undefined; | ||
antivirus?: boolean | undefined; | ||
} | undefined; | ||
}[]; | ||
buckets: { | ||
name: string; | ||
$id: string; | ||
enabled?: boolean | undefined; | ||
permissions?: ({ | ||
permission: string; | ||
target: string; | ||
} | { | ||
permission: string; | ||
target: string; | ||
})[] | undefined; | ||
fileSecurity?: boolean | undefined; | ||
maximumFileSize?: number | undefined; | ||
allowedFileExtensions?: string[] | undefined; | ||
compression?: "none" | "gzip" | "zstd" | undefined; | ||
encryption?: boolean | undefined; | ||
antivirus?: boolean | undefined; | ||
}[]; | ||
appwriteClient?: any; | ||
@@ -1054,3 +1229,2 @@ collections?: { | ||
appwriteClient?: any; | ||
enableDevDatabase?: boolean | undefined; | ||
enableBackups?: boolean | undefined; | ||
@@ -1061,3 +1235,2 @@ backupInterval?: number | undefined; | ||
enableMockData?: boolean | undefined; | ||
enableWipeOtherDatabases?: boolean | undefined; | ||
documentBucketId?: string | undefined; | ||
@@ -1068,3 +1241,33 @@ usersCollectionName?: string | undefined; | ||
$id: string; | ||
bucket?: { | ||
name: string; | ||
$id: string; | ||
enabled?: boolean | undefined; | ||
permissions?: (string | { | ||
permission: string; | ||
target: string; | ||
})[] | undefined; | ||
fileSecurity?: boolean | undefined; | ||
maximumFileSize?: number | undefined; | ||
allowedFileExtensions?: string[] | undefined; | ||
compression?: "none" | "gzip" | "zstd" | undefined; | ||
encryption?: boolean | undefined; | ||
antivirus?: boolean | undefined; | ||
} | undefined; | ||
}[] | undefined; | ||
buckets?: { | ||
name: string; | ||
$id: string; | ||
enabled?: boolean | undefined; | ||
permissions?: (string | { | ||
permission: string; | ||
target: string; | ||
})[] | undefined; | ||
fileSecurity?: boolean | undefined; | ||
maximumFileSize?: number | undefined; | ||
allowedFileExtensions?: string[] | undefined; | ||
compression?: "none" | "gzip" | "zstd" | undefined; | ||
encryption?: boolean | undefined; | ||
antivirus?: boolean | undefined; | ||
}[] | undefined; | ||
collections?: { | ||
@@ -1071,0 +1274,0 @@ name: string; |
import { z } from "zod"; | ||
import { CollectionCreateSchema, } from "./collection.js"; | ||
import { BucketSchema } from "./bucket.js"; | ||
export const AppwriteConfigSchema = z.object({ | ||
@@ -8,7 +9,2 @@ appwriteEndpoint: z.string().default("https://cloud.appwrite.io/v1"), | ||
appwriteClient: z.any().or(z.null()).default(null), | ||
enableDevDatabase: z | ||
.boolean() | ||
.optional() | ||
.default(true) | ||
.describe("Enable development database alongside production database"), | ||
enableBackups: z.boolean().default(true).describe("Enable backups"), | ||
@@ -27,7 +23,2 @@ backupInterval: z | ||
enableMockData: z.boolean().default(false).describe("Enable mock data"), | ||
enableWipeOtherDatabases: z | ||
.boolean() | ||
.optional() | ||
.default(true) | ||
.describe("Enable wiping other databases"), | ||
documentBucketId: z | ||
@@ -47,2 +38,3 @@ .string() | ||
name: z.string(), | ||
bucket: BucketSchema.optional(), | ||
})) | ||
@@ -57,2 +49,7 @@ .optional() | ||
.describe("Databases to create, $id is the id of the database"), | ||
buckets: z | ||
.array(BucketSchema) | ||
.optional() | ||
.default([]) | ||
.describe("Global buckets to create across all databases"), | ||
collections: z | ||
@@ -59,0 +56,0 @@ .array(CollectionCreateSchema) |
{ | ||
"name": "appwrite-utils", | ||
"module": "dist/index.js", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"main": "dist/index.js", | ||
@@ -24,15 +24,17 @@ "types": "dist/index.d.ts", | ||
"devDependencies": { | ||
"@types/bun": "latest" | ||
"@types/bun": "latest", | ||
"@types/yargs": "^17.0.33" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
"typescript": "^5.5.2" | ||
}, | ||
"dependencies": { | ||
"@asteasolutions/zod-to-openapi": "^7.0.0", | ||
"@asteasolutions/zod-to-openapi": "^7.1.1", | ||
"@types/luxon": "^3.4.2", | ||
"appwrite": "^15.0.0", | ||
"luxon": "^3.4.4", | ||
"ulidx": "^2.3.0", | ||
"luxon": "^3.5.0", | ||
"ulidx": "^2.4.0", | ||
"yargs": "^17.7.2", | ||
"zod": "^3.23.8" | ||
} | ||
} |
@@ -75,2 +75,3 @@ # appwrite-utils | ||
- 0.3.8: Upgraded some parts of the package, AppwriteConfig typing updated to include buckets, made cli tool interactive | ||
- 0.3.7: Remove `ulid` to replace with `ulidx` for compatibility | ||
@@ -77,0 +78,0 @@ - 0.3.6: Bump to `appwrite` version |
@@ -110,1 +110,2 @@ import { z } from "zod"; | ||
export { tryAwaitWithRetry } from "./functions/helpers.js"; | ||
export { getAppwriteClient } from "./functions/appwriteHelpers.js"; |
@@ -7,2 +7,3 @@ import { z } from "zod"; | ||
} from "./collection.js"; | ||
import { BucketSchema } from "./bucket.js"; | ||
@@ -14,7 +15,2 @@ export const AppwriteConfigSchema = z.object({ | ||
appwriteClient: z.any().or(z.null()).default(null), | ||
enableDevDatabase: z | ||
.boolean() | ||
.optional() | ||
.default(true) | ||
.describe("Enable development database alongside production database"), | ||
enableBackups: z.boolean().default(true).describe("Enable backups"), | ||
@@ -33,7 +29,2 @@ backupInterval: z | ||
enableMockData: z.boolean().default(false).describe("Enable mock data"), | ||
enableWipeOtherDatabases: z | ||
.boolean() | ||
.optional() | ||
.default(true) | ||
.describe("Enable wiping other databases"), | ||
documentBucketId: z | ||
@@ -56,2 +47,3 @@ .string() | ||
name: z.string(), | ||
bucket: BucketSchema.optional(), | ||
}) | ||
@@ -67,2 +59,8 @@ ) | ||
.describe("Databases to create, $id is the id of the database"), | ||
buckets: z | ||
.array(BucketSchema) | ||
.optional() | ||
.default([]) | ||
.describe("Global buckets to create across all databases"), | ||
collections: z | ||
@@ -69,0 +67,0 @@ .array(CollectionCreateSchema) |
360981
90
9383
91
8
2
+ Addedyargs@^17.7.2
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)
Updatedluxon@^3.5.0
Updatedulidx@^2.4.0