appwrite-utils
Advanced tools
Comparing version 0.3.9 to 0.3.91
@@ -20,3 +20,3 @@ export { areCollectionNamesSame } from "./functions/collections.js"; | ||
export { indexSchema, type Index, indexesSchema, type Indexes, } from "./schemas/index.js"; | ||
export { type Permission, permissionSchema, type Permissions, permissionsSchema, } from "./schemas/permissions.js"; | ||
export { type Permission, permissionSchema, type Permissions, permissionsSchema, PermissionToAppwritePermission, } from "./schemas/permissions.js"; | ||
export { type IdMapping, idMappingSchema, type IdMappings, idMappingsSchema, } from "./schemas/idMapping.js"; | ||
@@ -23,0 +23,0 @@ export { type AttributeMapping, AttributeMappingSchema, type AttributeMappings, AttributeMappingsSchema, } from "./schemas/attributeMappings.js"; |
@@ -19,3 +19,3 @@ export { areCollectionNamesSame } from "./functions/collections.js"; | ||
export { indexSchema, indexesSchema, } from "./schemas/index.js"; | ||
export { permissionSchema, permissionsSchema, } from "./schemas/permissions.js"; | ||
export { permissionSchema, permissionsSchema, PermissionToAppwritePermission, } from "./schemas/permissions.js"; | ||
export { idMappingSchema, idMappingsSchema, } from "./schemas/idMapping.js"; | ||
@@ -22,0 +22,0 @@ export { AttributeMappingSchema, AttributeMappingsSchema, } from "./schemas/attributeMappings.js"; |
@@ -30,1 +30,2 @@ import { z } from "zod"; | ||
export type Permissions = z.infer<typeof permissionsSchema>; | ||
export declare const PermissionToAppwritePermission: (permissions: Permissions) => string[]; |
@@ -0,1 +1,2 @@ | ||
import { Permission as AppwritePermission } from "appwrite"; | ||
import { z } from "zod"; | ||
@@ -20,1 +21,25 @@ export const permissionSchema = z | ||
export const permissionsSchema = z.array(permissionSchema).optional(); | ||
export const PermissionToAppwritePermission = (permissions) => { | ||
return permissions?.map(p => { | ||
if (typeof p === 'string') { | ||
return p; | ||
} | ||
else { | ||
switch (p.permission) { | ||
case "read": | ||
return AppwritePermission.read(p.target); | ||
case "create": | ||
return AppwritePermission.create(p.target); | ||
case "update": | ||
return AppwritePermission.update(p.target); | ||
case "delete": | ||
return AppwritePermission.delete(p.target); | ||
case "write": | ||
return AppwritePermission.write(p.target); | ||
default: | ||
console.log(`Unknown permission: ${p.permission}`); | ||
return ''; | ||
} | ||
} | ||
}).filter(p => p !== '') || []; | ||
}; |
{ | ||
"name": "appwrite-utils", | ||
"module": "dist/index.js", | ||
"version": "0.3.9", | ||
"version": "0.3.91", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "dist/index.d.ts", |
@@ -75,2 +75,3 @@ # appwrite-utils | ||
- 0.3.91: Updated permissions to include `parsePermissions` which maps my permissions (`target`, `permission` to the Appwrite strings) -- also added `PermissionToAppwritePermission` which converts one of mine (target, permission) to Appwrite | ||
- 0.3.9: Refactored the cli tool to allow for more specificity and configuration | ||
@@ -77,0 +78,0 @@ - 0.3.8: Upgraded some parts of the package, AppwriteConfig typing updated to include buckets, made cli tool interactive |
@@ -83,2 +83,3 @@ import { z } from "zod"; | ||
permissionsSchema, | ||
PermissionToAppwritePermission, | ||
} from "./schemas/permissions.js"; | ||
@@ -85,0 +86,0 @@ export { |
@@ -0,1 +1,2 @@ | ||
import { Permission as AppwritePermission } from "appwrite"; | ||
import { z } from "zod"; | ||
@@ -27,1 +28,25 @@ | ||
export type Permissions = z.infer<typeof permissionsSchema>; | ||
export const PermissionToAppwritePermission = (permissions: Permissions): string[] => { | ||
return permissions?.map(p => { | ||
if (typeof p === 'string') { | ||
return p; | ||
} else { | ||
switch (p.permission) { | ||
case "read": | ||
return AppwritePermission.read(p.target); | ||
case "create": | ||
return AppwritePermission.create(p.target); | ||
case "update": | ||
return AppwritePermission.update(p.target); | ||
case "delete": | ||
return AppwritePermission.delete(p.target); | ||
case "write": | ||
return AppwritePermission.write(p.target); | ||
default: | ||
console.log(`Unknown permission: ${p.permission}`); | ||
return ''; | ||
} | ||
} | ||
}).filter(p => p !== '') || []; | ||
}; |
363300
9433
93