@webiny/api-aco 6.5.2-beta.2 → 6.5.2-beta.3
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/filter/filter.types.js.map +1 -1
- package/folder/folder.gql.js +4 -0
- package/folder/folder.gql.js.map +1 -1
- package/folder/validation.d.ts +8 -0
- package/folder/validation.js +7 -0
- package/folder/validation.js.map +1 -0
- package/package.json +20 -19
- package/types.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter/filter.types.js","sources":["../../src/filter/filter.types.ts"],"sourcesContent":["import type { AcoBaseFields, ListMeta, ListSort } from \"~/types.js\";\n\nexport enum Operation {\n AND = \"AND\",\n OR = \"OR\"\n}\n\nexport interface GroupFilter {\n field: string;\n condition: string;\n value: string;\n}\n\nexport interface Group {\n operation: Operation;\n filters: GroupFilter[];\n}\n\nexport interface Filter extends AcoBaseFields {\n name: string;\n description?: string;\n namespace: string;\n operation: Operation;\n groups: Group[];\n}\n\nexport interface ListFiltersWhere {\n namespace: string;\n}\n\nexport interface ListFiltersParams {\n where: ListFiltersWhere;\n sort?: ListSort;\n limit?: number;\n after?: string | null;\n}\n\nexport type CreateFilterParams = Pick<\n Filter,\n \"id\" | \"name\" | \"description\" | \"namespace\" | \"operation\" | \"groups\"\n>;\n\nexport interface UpdateFilterParams {\n name?: string;\n description?: string;\n namespace?: string;\n operation?: Operation;\n groups?: Group[];\n}\n\nexport interface DeleteFilterParams {\n id: string;\n}\n\nexport interface StorageOperationsGetFilterParams {\n id: string;\n}\n\nexport type StorageOperationsListFiltersParams = ListFiltersParams;\n\nexport interface StorageOperationsCreateFilterParams {\n data: CreateFilterParams;\n}\n\nexport interface StorageOperationsUpdateFilterParams {\n id: string;\n data: UpdateFilterParams;\n}\n\nexport type StorageOperationsDeleteFilterParams = DeleteFilterParams;\n\nexport interface AcoFilterCrud {\n get(id: string): Promise<Filter>;\n list(params: ListFiltersParams): Promise<[Filter[], ListMeta]>;\n create(data: CreateFilterParams): Promise<Filter>;\n update(id: string, data: UpdateFilterParams): Promise<Filter>;\n delete(id: string): Promise<boolean>;\n}\n\nexport interface AcoFilterStorageOperations {\n getFilter(params: StorageOperationsGetFilterParams): Promise<Filter>;\n listFilters(params: StorageOperationsListFiltersParams): Promise<[Filter[], ListMeta]>;\n createFilter(params: StorageOperationsCreateFilterParams): Promise<Filter>;\n updateFilter(params: StorageOperationsUpdateFilterParams): Promise<Filter>;\n deleteFilter(params: StorageOperationsDeleteFilterParams): Promise<boolean>;\n}\n"],"names":["Operation"],"mappings":"AAEO,IAAKA,yBAASA,WAAAA,GAAAA,
|
|
1
|
+
{"version":3,"file":"filter/filter.types.js","sources":["../../src/filter/filter.types.ts"],"sourcesContent":["import type { AcoBaseFields, ListMeta, ListSort } from \"~/types.js\";\n\nexport enum Operation {\n AND = \"AND\",\n OR = \"OR\"\n}\n\nexport interface GroupFilter {\n field: string;\n condition: string;\n value: string;\n}\n\nexport interface Group {\n operation: Operation;\n filters: GroupFilter[];\n}\n\nexport interface Filter extends AcoBaseFields {\n name: string;\n description?: string;\n namespace: string;\n operation: Operation;\n groups: Group[];\n}\n\nexport interface ListFiltersWhere {\n namespace: string;\n}\n\nexport interface ListFiltersParams {\n where: ListFiltersWhere;\n sort?: ListSort;\n limit?: number;\n after?: string | null;\n}\n\nexport type CreateFilterParams = Pick<\n Filter,\n \"id\" | \"name\" | \"description\" | \"namespace\" | \"operation\" | \"groups\"\n>;\n\nexport interface UpdateFilterParams {\n name?: string;\n description?: string;\n namespace?: string;\n operation?: Operation;\n groups?: Group[];\n}\n\nexport interface DeleteFilterParams {\n id: string;\n}\n\nexport interface StorageOperationsGetFilterParams {\n id: string;\n}\n\nexport type StorageOperationsListFiltersParams = ListFiltersParams;\n\nexport interface StorageOperationsCreateFilterParams {\n data: CreateFilterParams;\n}\n\nexport interface StorageOperationsUpdateFilterParams {\n id: string;\n data: UpdateFilterParams;\n}\n\nexport type StorageOperationsDeleteFilterParams = DeleteFilterParams;\n\nexport interface AcoFilterCrud {\n get(id: string): Promise<Filter>;\n list(params: ListFiltersParams): Promise<[Filter[], ListMeta]>;\n create(data: CreateFilterParams): Promise<Filter>;\n update(id: string, data: UpdateFilterParams): Promise<Filter>;\n delete(id: string): Promise<boolean>;\n}\n\nexport interface AcoFilterStorageOperations {\n getFilter(params: StorageOperationsGetFilterParams): Promise<Filter>;\n listFilters(params: StorageOperationsListFiltersParams): Promise<[Filter[], ListMeta]>;\n createFilter(params: StorageOperationsCreateFilterParams): Promise<Filter>;\n updateFilter(params: StorageOperationsUpdateFilterParams): Promise<Filter>;\n deleteFilter(params: StorageOperationsDeleteFilterParams): Promise<boolean>;\n}\n"],"names":["Operation"],"mappings":"AAEO,IAAKA,yBAASA,WAAAA,GAAAA,SAAAA,SAAAA"}
|
package/folder/folder.gql.js
CHANGED
|
@@ -3,6 +3,8 @@ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSche
|
|
|
3
3
|
import { createFolderTypeDefs } from "./createFolderTypeDefs.js";
|
|
4
4
|
import { ensureAuthentication } from "../utils/ensureAuthentication.js";
|
|
5
5
|
import { resolve } from "../utils/resolve.js";
|
|
6
|
+
import { createZodError } from "@webiny/utils";
|
|
7
|
+
import { createFolderValidation } from "./validation.js";
|
|
6
8
|
import { FolderLevelPermissions } from "../features/flp/FolderLevelPermissions/index.js";
|
|
7
9
|
import { GetFolderUseCase } from "../features/folder/GetFolder/abstractions.js";
|
|
8
10
|
import { ListFoldersUseCase } from "../features/folder/ListFolders/abstractions.js";
|
|
@@ -95,6 +97,8 @@ const createFoldersSchema = (params)=>{
|
|
|
95
97
|
AcoMutation: {
|
|
96
98
|
createFolder: async (_, { data }, context)=>resolve(async ()=>{
|
|
97
99
|
ensureAuthentication(context);
|
|
100
|
+
const validation = createFolderValidation.safeParse(data);
|
|
101
|
+
if (!validation.success) throw createZodError(validation.error);
|
|
98
102
|
const createFolderUseCase = context.container.resolve(CreateFolderUseCase);
|
|
99
103
|
const result = await createFolderUseCase.execute(data);
|
|
100
104
|
if (result.isFail()) throw result.error;
|
package/folder/folder.gql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder/folder.gql.js","sources":["../../src/folder/folder.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\n\nimport type { CreateFolderTypeDefsParams } from \"./createFolderTypeDefs.js\";\nimport { createFolderTypeDefs } from \"./createFolderTypeDefs.js\";\nimport { ensureAuthentication } from \"~/utils/ensureAuthentication.js\";\nimport { resolve } from \"~/utils/resolve.js\";\nimport type { AcoContext, Folder } from \"~/types.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/abstractions.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/abstractions.js\";\nimport { CreateFolderUseCase } from \"~/features/folder/CreateFolder/abstractions.js\";\nimport { UpdateFolderUseCase } from \"~/features/folder/UpdateFolder/abstractions.js\";\nimport { DeleteFolderUseCase } from \"~/features/folder/DeleteFolder/abstractions.js\";\nimport { GetFolderHierarchyUseCase } from \"~/features/folder/GetFolderHierarchy/abstractions.js\";\nimport { ListFolderLevelPermissionsTargetsUseCase } from \"~/features/folder/ListFolderLevelPermissionsTargets/abstractions.js\";\nimport { FolderModel } from \"~/domain/folder/abstractions.js\";\nimport { ValuesSelectionGenerator } from \"@webiny/api-headless-cms/features/contentModel/ValuesSelectionGenerator/abstractions.js\";\n\nexport const createFoldersSchema = (params: CreateFolderTypeDefsParams) => {\n const folderGraphQL = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: createFolderTypeDefs(params),\n resolvers: {\n Folder: {\n hasNonInheritedPermissions: (folder: Folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.permissionsIncludeNonInheritedPermissions(folder.permissions ?? []);\n },\n canManageStructure: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderStructure(folder);\n },\n canManagePermissions: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderPermissions(folder);\n },\n canManageContent: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderContent(folder);\n }\n },\n AcoQuery: {\n getFolderModel(_, __, context) {\n return resolve(async () => {\n ensureAuthentication(context);\n const model = context.container.resolve(FolderModel);\n const generator = context.container.resolve(ValuesSelectionGenerator);\n return {\n ...model,\n valuesSelection: generator.generate(model)\n };\n });\n },\n getFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderUseCase = context.container.resolve(GetFolderUseCase);\n const result = await getFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n listFolders: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listFoldersUseCase = context.container.resolve(ListFoldersUseCase);\n const result = await listFoldersUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n const { folders, meta } = result.value;\n return new ListResponse(folders, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n getFolderHierarchy: async (_, args: any, context) => {\n try {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderHierarchyUseCase =\n context.container.resolve(GetFolderHierarchyUseCase);\n const result = await getFolderHierarchyUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listFolderLevelPermissionsTargets: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listTargetsUseCase = context.container.resolve(\n ListFolderLevelPermissionsTargetsUseCase\n );\n const result = await listTargetsUseCase.execute();\n if (result.isFail()) {\n throw result.error;\n }\n const [entries, meta] = result.value;\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n AcoMutation: {\n createFolder: async (_, { data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const createFolderUseCase = context.container.resolve(CreateFolderUseCase);\n const result = await createFolderUseCase.execute(data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n updateFolder: async (_, { id, data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const updateFolderUseCase = context.container.resolve(UpdateFolderUseCase);\n const result = await updateFolderUseCase.execute(id, data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n deleteFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const deleteFolderUseCase = context.container.resolve(DeleteFolderUseCase);\n const result = await deleteFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return true;\n });\n }\n }\n }\n });\n\n folderGraphQL.name = \"aco.graphql.folders\";\n\n return folderGraphQL;\n};\n"],"names":["createFoldersSchema","params","folderGraphQL","GraphQLSchemaPlugin","createFolderTypeDefs","folder","_","context","flp","FolderLevelPermissions","__","resolve","ensureAuthentication","model","FolderModel","generator","ValuesSelectionGenerator","id","getFolderUseCase","GetFolderUseCase","result","args","listFoldersUseCase","ListFoldersUseCase","folders","meta","ListResponse","e","ErrorResponse","getFolderHierarchyUseCase","GetFolderHierarchyUseCase","listTargetsUseCase","ListFolderLevelPermissionsTargetsUseCase","entries","data","createFolderUseCase","CreateFolderUseCase","updateFolderUseCase","UpdateFolderUseCase","deleteFolderUseCase","DeleteFolderUseCase"],"mappings":";;;;;;;;;;;;;;;AAmBO,MAAMA,sBAAsB,CAACC;IAChC,MAAMC,gBAAgB,IAAIC,oBAAgC;QACtD,UAAUC,qBAAqBH;QAC/B,WAAW;YACP,QAAQ;gBACJ,4BAA4B,CAACI,QAAgBC,GAAGC;oBAC5C,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,yCAAyC,CAACH,OA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E,EAAE3B,UAC3BI,QAAQ;wBACXC,qBAAqBL;wBACrB,MAAM8B,sBAAsB9B,QAAQ,SAAS,CAAC,OAAO,CAAC+B;wBACtD,MAAMlB,SAAS,MAAMiB,oBAAoB,OAAO,CAACpB,IAAIiB;wBACrD,IAAId,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAOA,OAAO,KAAK;oBACvB;gBAEJ,cAAc,OAAOd,GAAG,EAAEW,EAAE,EAAE,EAAEV,UACrBI,QAAQ;wBACXC,qBAAqBL;wBACrB,MAAMgC,sBAAsBhC,QAAQ,SAAS,CAAC,OAAO,CAACiC;wBACtD,MAAMpB,SAAS,MAAMmB,oBAAoB,OAAO,CAACtB;wBACjD,IAAIG,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAO;oBACX;YAER;QACJ;IACJ;IAEAlB,cAAc,IAAI,GAAG;IAErB,OAAOA;AACX"}
|
|
1
|
+
{"version":3,"file":"folder/folder.gql.js","sources":["../../src/folder/folder.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\n\nimport type { CreateFolderTypeDefsParams } from \"./createFolderTypeDefs.js\";\nimport { createFolderTypeDefs } from \"./createFolderTypeDefs.js\";\nimport { ensureAuthentication } from \"~/utils/ensureAuthentication.js\";\nimport { resolve } from \"~/utils/resolve.js\";\nimport { createZodError } from \"@webiny/utils\";\nimport { createFolderValidation } from \"./validation.js\";\nimport type { AcoContext, Folder } from \"~/types.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/abstractions.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/abstractions.js\";\nimport { CreateFolderUseCase } from \"~/features/folder/CreateFolder/abstractions.js\";\nimport { UpdateFolderUseCase } from \"~/features/folder/UpdateFolder/abstractions.js\";\nimport { DeleteFolderUseCase } from \"~/features/folder/DeleteFolder/abstractions.js\";\nimport { GetFolderHierarchyUseCase } from \"~/features/folder/GetFolderHierarchy/abstractions.js\";\nimport { ListFolderLevelPermissionsTargetsUseCase } from \"~/features/folder/ListFolderLevelPermissionsTargets/abstractions.js\";\nimport { FolderModel } from \"~/domain/folder/abstractions.js\";\nimport { ValuesSelectionGenerator } from \"@webiny/api-headless-cms/features/contentModel/ValuesSelectionGenerator/abstractions.js\";\n\nexport const createFoldersSchema = (params: CreateFolderTypeDefsParams) => {\n const folderGraphQL = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: createFolderTypeDefs(params),\n resolvers: {\n Folder: {\n hasNonInheritedPermissions: (folder: Folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.permissionsIncludeNonInheritedPermissions(folder.permissions ?? []);\n },\n canManageStructure: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderStructure(folder);\n },\n canManagePermissions: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderPermissions(folder);\n },\n canManageContent: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderContent(folder);\n }\n },\n AcoQuery: {\n getFolderModel(_, __, context) {\n return resolve(async () => {\n ensureAuthentication(context);\n const model = context.container.resolve(FolderModel);\n const generator = context.container.resolve(ValuesSelectionGenerator);\n return {\n ...model,\n valuesSelection: generator.generate(model)\n };\n });\n },\n getFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderUseCase = context.container.resolve(GetFolderUseCase);\n const result = await getFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n listFolders: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listFoldersUseCase = context.container.resolve(ListFoldersUseCase);\n const result = await listFoldersUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n const { folders, meta } = result.value;\n return new ListResponse(folders, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n getFolderHierarchy: async (_, args: any, context) => {\n try {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderHierarchyUseCase =\n context.container.resolve(GetFolderHierarchyUseCase);\n const result = await getFolderHierarchyUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listFolderLevelPermissionsTargets: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listTargetsUseCase = context.container.resolve(\n ListFolderLevelPermissionsTargetsUseCase\n );\n const result = await listTargetsUseCase.execute();\n if (result.isFail()) {\n throw result.error;\n }\n const [entries, meta] = result.value;\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n AcoMutation: {\n createFolder: async (_, { data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const validation = createFolderValidation.safeParse(data);\n if (!validation.success) {\n throw createZodError(validation.error);\n }\n const createFolderUseCase = context.container.resolve(CreateFolderUseCase);\n const result = await createFolderUseCase.execute(data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n updateFolder: async (_, { id, data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const updateFolderUseCase = context.container.resolve(UpdateFolderUseCase);\n const result = await updateFolderUseCase.execute(id, data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n deleteFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const deleteFolderUseCase = context.container.resolve(DeleteFolderUseCase);\n const result = await deleteFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return true;\n });\n }\n }\n }\n });\n\n folderGraphQL.name = \"aco.graphql.folders\";\n\n return folderGraphQL;\n};\n"],"names":["createFoldersSchema","params","folderGraphQL","GraphQLSchemaPlugin","createFolderTypeDefs","folder","_","context","flp","FolderLevelPermissions","__","resolve","ensureAuthentication","model","FolderModel","generator","ValuesSelectionGenerator","id","getFolderUseCase","GetFolderUseCase","result","args","listFoldersUseCase","ListFoldersUseCase","folders","meta","ListResponse","e","ErrorResponse","getFolderHierarchyUseCase","GetFolderHierarchyUseCase","listTargetsUseCase","ListFolderLevelPermissionsTargetsUseCase","entries","data","validation","createFolderValidation","createZodError","createFolderUseCase","CreateFolderUseCase","updateFolderUseCase","UpdateFolderUseCase","deleteFolderUseCase","DeleteFolderUseCase"],"mappings":";;;;;;;;;;;;;;;;;AAqBO,MAAMA,sBAAsB,CAACC;IAChC,MAAMC,gBAAgB,IAAIC,oBAAgC;QACtD,UAAUC,qBAAqBH;QAC/B,WAAW;YACP,QAAQ;gBACJ,4BAA4B,CAACI,QAAgBC,GAAGC;oBAC5C,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,yCAAyC,CAACH,OAAO,WAAW,IAAI,EAAE;gBACjF;gBACA,oBAAoB,CAACA,QAAQC,GAAGC;oBAC5B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,wBAAwB,CAACH;gBACxC;gBACA,sBAAsB,CAACA,QAAQC,GAAGC;oBAC9B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,0BAA0B,CAACH;gBAC1C;gBACA,kBAAkB,CAACA,QAAQC,GAAGC;oBAC1B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,sBAAsB,CAACH;gBACtC;YACJ;YACA,UAAU;gBACN,gBAAeC,CAAC,EAAEI,EAAE,EAAEH,OAAO;oBACzB,OAAOI,QAAQ;wBACXC,qBAAqBL;wBACrB,MAAMM,QAAQN,QAAQ,SAAS,CAAC,OAAO,CAACO;wBACxC,MAAMC,YAAYR,QAAQ,SAAS,CAAC,OAAO,CAACS;wBAC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;IAEAlB,cAAc,IAAI,GAAG;IAErB,OAAOA;AACX"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import zod from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Folder permissions are resolved from the folder type, so the type must be known before anything else runs.
|
|
4
|
+
* The rest of the input is validated by the folder model.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createFolderValidation: zod.ZodObject<{
|
|
7
|
+
type: zod.ZodString;
|
|
8
|
+
}, zod.core.$loose>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folder/validation.js","sources":["../../src/folder/validation.ts"],"sourcesContent":["import zod from \"zod\";\n\n/**\n * Folder permissions are resolved from the folder type, so the type must be known before anything else runs.\n * The rest of the input is validated by the folder model.\n */\nexport const createFolderValidation = zod.looseObject({\n type: zod.string().min(1)\n});\n"],"names":["createFolderValidation","zod"],"mappings":";AAMO,MAAMA,yBAAyBC,IAAI,WAAW,CAAC;IAClD,MAAMA,IAAI,MAAM,GAAG,GAAG,CAAC;AAC3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-aco",
|
|
3
|
-
"version": "6.5.2-beta.
|
|
3
|
+
"version": "6.5.2-beta.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aco:base"
|
|
@@ -21,27 +21,28 @@
|
|
|
21
21
|
".": "./index.js"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@webiny/api": "6.5.2-beta.
|
|
25
|
-
"@webiny/api-core": "6.5.2-beta.
|
|
26
|
-
"@webiny/api-headless-cms": "6.5.2-beta.
|
|
27
|
-
"@webiny/background-tasks": "6.5.2-beta.
|
|
24
|
+
"@webiny/api": "6.5.2-beta.3",
|
|
25
|
+
"@webiny/api-core": "6.5.2-beta.3",
|
|
26
|
+
"@webiny/api-headless-cms": "6.5.2-beta.3",
|
|
27
|
+
"@webiny/background-tasks": "6.5.2-beta.3",
|
|
28
28
|
"@webiny/di": "1.1.0",
|
|
29
|
-
"@webiny/error": "6.5.2-beta.
|
|
30
|
-
"@webiny/feature": "6.5.2-beta.
|
|
31
|
-
"@webiny/handler": "6.5.2-beta.
|
|
32
|
-
"@webiny/handler-graphql": "6.5.2-beta.
|
|
33
|
-
"@webiny/shared-aco": "6.5.2-beta.
|
|
34
|
-
"@webiny/utils": "6.5.2-beta.
|
|
35
|
-
"@webiny/validation": "6.5.2-beta.
|
|
36
|
-
"lodash": "4.18.1"
|
|
29
|
+
"@webiny/error": "6.5.2-beta.3",
|
|
30
|
+
"@webiny/feature": "6.5.2-beta.3",
|
|
31
|
+
"@webiny/handler": "6.5.2-beta.3",
|
|
32
|
+
"@webiny/handler-graphql": "6.5.2-beta.3",
|
|
33
|
+
"@webiny/shared-aco": "6.5.2-beta.3",
|
|
34
|
+
"@webiny/utils": "6.5.2-beta.3",
|
|
35
|
+
"@webiny/validation": "6.5.2-beta.3",
|
|
36
|
+
"lodash": "4.18.1",
|
|
37
|
+
"zod": "4.6.7"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@webiny/api-file-manager": "6.5.2-beta.
|
|
40
|
-
"@webiny/build-tools": "6.5.2-beta.
|
|
41
|
-
"@webiny/handler-aws": "6.5.2-beta.
|
|
42
|
-
"@webiny/plugins": "6.5.2-beta.
|
|
43
|
-
"@webiny/project-utils": "6.5.2-beta.
|
|
44
|
-
"@webiny/wcp": "6.5.2-beta.
|
|
40
|
+
"@webiny/api-file-manager": "6.5.2-beta.3",
|
|
41
|
+
"@webiny/build-tools": "6.5.2-beta.3",
|
|
42
|
+
"@webiny/handler-aws": "6.5.2-beta.3",
|
|
43
|
+
"@webiny/plugins": "6.5.2-beta.3",
|
|
44
|
+
"@webiny/project-utils": "6.5.2-beta.3",
|
|
45
|
+
"@webiny/wcp": "6.5.2-beta.3",
|
|
45
46
|
"graphql": "16.15.0",
|
|
46
47
|
"rimraf": "6.1.4",
|
|
47
48
|
"typescript": "7.0.2",
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { Context as BaseContext } from \"@webiny/handler/types.js\";\nimport type { Context as TasksContext } from \"@webiny/background-tasks/api/types.js\";\nimport type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { AcoFilterCrud, AcoFilterStorageOperations } from \"~/filter/filter.types.js\";\nimport type {\n AcoFolderLevelPermissionsCrud,\n AcoFolderLevelPermissionsStorageOperations\n} from \"~/flp/flp.types.js\";\nimport type { Container } from \"@webiny/di\";\nimport { FolderLevelPermissions } from \"./features/flp/FolderLevelPermissions/index.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\n\nexport * from \"./filter/filter.types.js\";\nexport type * from \"./folder/folder.types.js\";\nexport type * from \"./flp/flp.types.js\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: User;\n modifiedBy: User | null;\n savedBy: User;\n}\n\nexport interface AdvancedContentOrganisation {\n filter: AcoFilterCrud;\n flp: AcoFolderLevelPermissionsCrud;\n}\n\nexport interface CreateAcoParams {\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n folderLevelPermissions: FolderLevelPermissions.Interface;\n container: Container;\n}\n\nexport interface AcoStorageOperations {\n filter: AcoFilterStorageOperations;\n flp: AcoFolderLevelPermissionsStorageOperations;\n}\n\nexport interface AcoContext extends BaseContext, ApiCoreContext, CmsContext, TasksContext {\n aco: AdvancedContentOrganisation;\n}\n"],"names":["ListSortDirection"],"mappings":";AA6BO,IAAKA,0BAAiBA,WAAAA,GAAAA,
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { Context as BaseContext } from \"@webiny/handler/types.js\";\nimport type { Context as TasksContext } from \"@webiny/background-tasks/api/types.js\";\nimport type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { AcoFilterCrud, AcoFilterStorageOperations } from \"~/filter/filter.types.js\";\nimport type {\n AcoFolderLevelPermissionsCrud,\n AcoFolderLevelPermissionsStorageOperations\n} from \"~/flp/flp.types.js\";\nimport type { Container } from \"@webiny/di\";\nimport { FolderLevelPermissions } from \"./features/flp/FolderLevelPermissions/index.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\n\nexport * from \"./filter/filter.types.js\";\nexport type * from \"./folder/folder.types.js\";\nexport type * from \"./flp/flp.types.js\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: User;\n modifiedBy: User | null;\n savedBy: User;\n}\n\nexport interface AdvancedContentOrganisation {\n filter: AcoFilterCrud;\n flp: AcoFolderLevelPermissionsCrud;\n}\n\nexport interface CreateAcoParams {\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n folderLevelPermissions: FolderLevelPermissions.Interface;\n container: Container;\n}\n\nexport interface AcoStorageOperations {\n filter: AcoFilterStorageOperations;\n flp: AcoFolderLevelPermissionsStorageOperations;\n}\n\nexport interface AcoContext extends BaseContext, ApiCoreContext, CmsContext, TasksContext {\n aco: AdvancedContentOrganisation;\n}\n"],"names":["ListSortDirection"],"mappings":";AA6BO,IAAKA,0BAAiBA,WAAAA,GAAAA,SAAAA,iBAAAA"}
|