@webiny/api-core 6.4.12-beta.7 → 6.4.12-beta.8
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/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/task/TaskService/abstractions.js.map +1 -1
- package/features/users/AdminUsersFeature.js +2 -0
- package/features/users/AdminUsersFeature.js.map +1 -1
- package/features/users/GetCurrentUser/GetCurrentUserUseCase.d.ts +13 -0
- package/features/users/GetCurrentUser/GetCurrentUserUseCase.js +29 -0
- package/features/users/GetCurrentUser/GetCurrentUserUseCase.js.map +1 -0
- package/features/users/GetCurrentUser/abstractions.d.ts +18 -0
- package/features/users/GetCurrentUser/abstractions.js +5 -0
- package/features/users/GetCurrentUser/abstractions.js.map +1 -0
- package/features/users/GetCurrentUser/feature.d.ts +4 -0
- package/features/users/GetCurrentUser/feature.js +11 -0
- package/features/users/GetCurrentUser/feature.js.map +1 -0
- package/features/users/GetCurrentUser/index.d.ts +1 -0
- package/features/users/GetCurrentUser/index.js +1 -0
- package/graphql/users/user.gql.js +9 -12
- package/graphql/users/user.gql.js.map +1 -1
- package/package.json +17 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/task/TaskDefinition/abstractions.js","sources":["../../../../src/features/task/TaskDefinition/abstractions.ts"],"sourcesContent":["import zod from \"zod\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types\";\nimport type { ITask } from \"~/features/task/TaskService/index.js\";\nimport { TaskController } from \"~/features/task/TaskController/index.js\";\n\nexport type ITaskInput = GenericRecord;\n\nexport interface IResponseError {\n message: string;\n code?: string | null;\n data?: GenericRecord | null;\n stack?: string;\n}\n\nexport interface ITaskOutput {\n error?: IResponseError;\n [key: string]: any;\n}\n\n/**\n * Task run params - ONLY the input data\n * All runtime dependencies come from TaskController (injected separately)\n */\nexport interface ITaskRunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n input: I;\n controller: TaskController.Interface<I, O>;\n}\n\n/**\n * Data for creating a new task\n */\nexport interface ITaskCreateData<I = ITaskInput> {\n definitionId: string;\n name: string;\n input: I;\n parentId?: string;\n}\n\n/**\n * Parameters for onBeforeTrigger lifecycle hook\n */\nexport interface ITaskBeforeTriggerParams<I = ITaskInput> {\n data: ITaskCreateData<I>;\n}\n\n/**\n * Task result status enum\n */\nexport enum TaskResultStatus {\n DONE = \"done\",\n CONTINUE = \"continue\",\n ERROR = \"error\",\n ABORTED = \"aborted\"\n}\n\n/**\n * Specific result types\n */\nexport interface ITaskResultDone<O extends ITaskOutput = ITaskOutput> {\n status: TaskResultStatus.DONE;\n message?: string;\n output?: O;\n}\n\nexport interface ITaskResultContinue<I = ITaskInput> {\n status: TaskResultStatus.CONTINUE;\n input: I;\n wait?: number; // seconds to wait before next iteration\n}\n\nexport interface ITaskResultError {\n status: TaskResultStatus.ERROR;\n error: IResponseError;\n}\n\nexport interface ITaskResultAborted {\n status: TaskResultStatus.ABORTED;\n}\n\nexport type ITaskResult<I = ITaskInput, O extends ITaskOutput = ITaskOutput> =\n | ITaskResultDone<O>\n | ITaskResultContinue<I>\n | ITaskResultError\n | ITaskResultAborted;\n\nexport type ISelfCleanupEvent = \"onSuccess\" | \"onError\" | \"onAbort\";\n\nexport type ISelfCleanup = \"always\" | \"never\" | ISelfCleanupEvent | ISelfCleanupEvent[];\n\nexport type ITaskLifecycleHook<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> = {\n task: ITask<I, O>;\n};\n\n/**\n * Core TaskDefinition - minimal interface\n */\nexport interface ITaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n id: string;\n title: string;\n description?: string;\n maxIterations?: number;\n databaseLogs?: boolean;\n isPrivate?: boolean;\n selfCleanup?: ISelfCleanup;\n\n /**\n * Core run method - receives ONLY input params\n * All runtime dependencies (logging, state management, etc.) come from TaskController\n */\n run(params: ITaskRunParams<I, O>): Promise<ITaskResult<I, O>>;\n\n /**\n * Optional lifecycle hooks - receive task data, no context.\n */\n onBeforeTrigger?(params: ITaskBeforeTriggerParams<I>): Promise<void>;\n onDone?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onError?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onAbort?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onMaxIterations?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n /**\n * Create a validation schema for the task input.\n * This will be used to validate the input before the task is triggered.\n */\n createInputValidation?(\n params: ITaskCreateInputValidationParams\n ): GenericRecord<keyof I, zod.Schema> | zod.Schema;\n}\n\nexport interface ITaskCreateInputValidationParams {\n validator: typeof zod;\n}\n\n/** Define a long-running background task with lifecycle hooks. */\nexport const TaskDefinition = createAbstraction<ITaskDefinition>(\"TaskDefinition\");\n\n/**\n * IRunnableTaskDefinition represents a TaskDefinition after decoration/processing.\n * All optional runtime properties are guaranteed to have values (with defaults applied).\n * Used internally by the task runner to ensure consistent behavior.\n */\nexport interface IRunnableTaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> extends ITaskDefinition<I, O> {\n // Override optional properties to be required with guaranteed values\n isPrivate: boolean;\n databaseLogs: boolean;\n maxIterations: number;\n}\n\nexport namespace TaskDefinition {\n export type Interface<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskDefinition<I, O>;\n\n export type TaskInput = ITaskInput;\n\n export type TaskOutput = ITaskOutput;\n\n export type Runnable<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = IRunnableTaskDefinition<I, O>;\n\n export type RunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskRunParams<I, O>;\n\n export type Result<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskResult<I, O>;\n\n export type Task<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITask<I, O>;\n\n export type ResultDone<O extends ITaskOutput = ITaskOutput> = ITaskResultDone<O>;\n export type ResultContinue<I = ITaskInput> = ITaskResultContinue<I>;\n export type ResultError = ITaskResultError;\n export type ResultAborted = ITaskResultAborted;\n export type CreateInputValidationParams = ITaskCreateInputValidationParams;\n export type TaskCreateData<I = ITaskInput> = ITaskCreateData<I>;\n export type BeforeTriggerParams<I = ITaskInput> = ITaskBeforeTriggerParams<I>;\n export type LifecycleHookParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskLifecycleHook<I, O>;\n\n export type SelfCleanupEvent = ISelfCleanupEvent;\n export type SelfCleanup = ISelfCleanup;\n}\n"],"names":["TaskResultStatus","TaskDefinition","createAbstraction"],"mappings":";AAoDO,IAAKA,gCAAgBA,WAAAA,GAAAA,
|
|
1
|
+
{"version":3,"file":"features/task/TaskDefinition/abstractions.js","sources":["../../../../src/features/task/TaskDefinition/abstractions.ts"],"sourcesContent":["import zod from \"zod\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types\";\nimport type { ITask } from \"~/features/task/TaskService/index.js\";\nimport { TaskController } from \"~/features/task/TaskController/index.js\";\n\nexport type ITaskInput = GenericRecord;\n\nexport interface IResponseError {\n message: string;\n code?: string | null;\n data?: GenericRecord | null;\n stack?: string;\n}\n\nexport interface ITaskOutput {\n error?: IResponseError;\n [key: string]: any;\n}\n\n/**\n * Task run params - ONLY the input data\n * All runtime dependencies come from TaskController (injected separately)\n */\nexport interface ITaskRunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n input: I;\n controller: TaskController.Interface<I, O>;\n}\n\n/**\n * Data for creating a new task\n */\nexport interface ITaskCreateData<I = ITaskInput> {\n definitionId: string;\n name: string;\n input: I;\n parentId?: string;\n}\n\n/**\n * Parameters for onBeforeTrigger lifecycle hook\n */\nexport interface ITaskBeforeTriggerParams<I = ITaskInput> {\n data: ITaskCreateData<I>;\n}\n\n/**\n * Task result status enum\n */\nexport enum TaskResultStatus {\n DONE = \"done\",\n CONTINUE = \"continue\",\n ERROR = \"error\",\n ABORTED = \"aborted\"\n}\n\n/**\n * Specific result types\n */\nexport interface ITaskResultDone<O extends ITaskOutput = ITaskOutput> {\n status: TaskResultStatus.DONE;\n message?: string;\n output?: O;\n}\n\nexport interface ITaskResultContinue<I = ITaskInput> {\n status: TaskResultStatus.CONTINUE;\n input: I;\n wait?: number; // seconds to wait before next iteration\n}\n\nexport interface ITaskResultError {\n status: TaskResultStatus.ERROR;\n error: IResponseError;\n}\n\nexport interface ITaskResultAborted {\n status: TaskResultStatus.ABORTED;\n}\n\nexport type ITaskResult<I = ITaskInput, O extends ITaskOutput = ITaskOutput> =\n | ITaskResultDone<O>\n | ITaskResultContinue<I>\n | ITaskResultError\n | ITaskResultAborted;\n\nexport type ISelfCleanupEvent = \"onSuccess\" | \"onError\" | \"onAbort\";\n\nexport type ISelfCleanup = \"always\" | \"never\" | ISelfCleanupEvent | ISelfCleanupEvent[];\n\nexport type ITaskLifecycleHook<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> = {\n task: ITask<I, O>;\n};\n\n/**\n * Core TaskDefinition - minimal interface\n */\nexport interface ITaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n id: string;\n title: string;\n description?: string;\n maxIterations?: number;\n databaseLogs?: boolean;\n isPrivate?: boolean;\n selfCleanup?: ISelfCleanup;\n\n /**\n * Core run method - receives ONLY input params\n * All runtime dependencies (logging, state management, etc.) come from TaskController\n */\n run(params: ITaskRunParams<I, O>): Promise<ITaskResult<I, O>>;\n\n /**\n * Optional lifecycle hooks - receive task data, no context.\n */\n onBeforeTrigger?(params: ITaskBeforeTriggerParams<I>): Promise<void>;\n onDone?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onError?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onAbort?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onMaxIterations?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n /**\n * Create a validation schema for the task input.\n * This will be used to validate the input before the task is triggered.\n */\n createInputValidation?(\n params: ITaskCreateInputValidationParams\n ): GenericRecord<keyof I, zod.Schema> | zod.Schema;\n}\n\nexport interface ITaskCreateInputValidationParams {\n validator: typeof zod;\n}\n\n/** Define a long-running background task with lifecycle hooks. */\nexport const TaskDefinition = createAbstraction<ITaskDefinition>(\"TaskDefinition\");\n\n/**\n * IRunnableTaskDefinition represents a TaskDefinition after decoration/processing.\n * All optional runtime properties are guaranteed to have values (with defaults applied).\n * Used internally by the task runner to ensure consistent behavior.\n */\nexport interface IRunnableTaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> extends ITaskDefinition<I, O> {\n // Override optional properties to be required with guaranteed values\n isPrivate: boolean;\n databaseLogs: boolean;\n maxIterations: number;\n}\n\nexport namespace TaskDefinition {\n export type Interface<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskDefinition<I, O>;\n\n export type TaskInput = ITaskInput;\n\n export type TaskOutput = ITaskOutput;\n\n export type Runnable<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = IRunnableTaskDefinition<I, O>;\n\n export type RunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskRunParams<I, O>;\n\n export type Result<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskResult<I, O>;\n\n export type Task<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITask<I, O>;\n\n export type ResultDone<O extends ITaskOutput = ITaskOutput> = ITaskResultDone<O>;\n export type ResultContinue<I = ITaskInput> = ITaskResultContinue<I>;\n export type ResultError = ITaskResultError;\n export type ResultAborted = ITaskResultAborted;\n export type CreateInputValidationParams = ITaskCreateInputValidationParams;\n export type TaskCreateData<I = ITaskInput> = ITaskCreateData<I>;\n export type BeforeTriggerParams<I = ITaskInput> = ITaskBeforeTriggerParams<I>;\n export type LifecycleHookParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskLifecycleHook<I, O>;\n\n export type SelfCleanupEvent = ISelfCleanupEvent;\n export type SelfCleanup = ISelfCleanup;\n}\n"],"names":["TaskResultStatus","TaskDefinition","createAbstraction"],"mappings":";AAoDO,IAAKA,gCAAgBA,WAAAA,GAAAA,SAAAA,gBAAAA;;;;;;;AA2FrB,MAAMC,iBAAiBC,kBAAmC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/task/TaskService/abstractions.js","sources":["../../../../src/features/task/TaskService/abstractions.ts"],"sourcesContent":["import { BaseError, createAbstraction, Result } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { type ITaskOutput, TaskDefinition } from \"~/features/task/TaskDefinition/index.js\";\n\n/** Trigger and manage long-running background tasks. */\nexport const TaskService = createAbstraction<ITaskService>(\"TaskService\");\n\nexport namespace TaskService {\n export type Interface = ITaskService;\n /**\n * This is the output of `trigger` and `abort` actions.\n */\n export type GenericOutput = IGenericOutput;\n\n export type TaskInput = TaskDefinition.TaskInput;\n\n export type Task<\n I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITask<I, O>;\n}\n\n// The service info depends on the implementation.\n// We cannot have a more precise type here, since implementation can be anything (AWS, Azure, etc.).\nexport type IServiceInfo = GenericRecord;\n\nexport interface IResponseError {\n message: string;\n code?: string | null;\n data?: GenericRecord | null;\n stack?: string;\n}\n\nexport interface ITaskAbortParams {\n id: string;\n message?: string;\n}\n\nexport interface ITaskService {\n trigger: <\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends IGenericOutput = IGenericOutput\n >(\n params: ITaskTriggerParams<T>\n ) => Promise<Result<ITask<T, O>, BaseError>>;\n abort: <\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends IGenericOutput = IGenericOutput\n >(\n params: ITaskAbortParams\n ) => Promise<Result<ITask<T, O>, BaseError>>;\n fetchServiceInfo: (input: ITask<any, any> | string) => Promise<Result<IServiceInfo, BaseError>>;\n}\n\nexport interface IGenericOutput {\n error?: IResponseError;\n [key: string]:\n | string\n | string[]\n | number\n | boolean\n | undefined\n | Record<string, any>\n | IResponseError;\n}\n\nexport interface ITaskTriggerParams<I = TaskDefinition.TaskInput> {\n parent?: Pick<ITask, \"id\">;\n definition: string;\n name?: string;\n input?: I;\n delay?: number;\n}\n\nexport interface ITaskValues<T = GenericRecord, O extends ITaskOutput = ITaskOutput> {\n startedOn?: string;\n finishedOn?: string;\n eventResponse: GenericRecord | undefined;\n iterations: number;\n parentId?: string;\n name: string;\n taskStatus: TaskDataStatus;\n definitionId: string;\n executionName: string;\n input: T;\n output?: O;\n}\n\nexport interface ITask<T = GenericRecord, O extends ITaskOutput = ITaskOutput> extends ITaskValues<\n T,\n O\n> {\n /**\n * ID without the revision number (for example: #0001).\n */\n id: string;\n createdOn: string;\n savedOn: string;\n createdBy: ITaskIdentity;\n}\n\nexport enum TaskDataStatus {\n PENDING = \"pending\",\n RUNNING = \"running\",\n FAILED = \"failed\",\n SUCCESS = \"success\",\n ABORTED = \"aborted\"\n}\n\nexport interface ITaskIdentity {\n id: string;\n displayName: string;\n type: string;\n}\n"],"names":["TaskService","createAbstraction","TaskDataStatus"],"mappings":";AAKO,MAAMA,cAAcC,kBAAgC;AAgGpD,IAAKC,8BAAcA,WAAAA,GAAAA,
|
|
1
|
+
{"version":3,"file":"features/task/TaskService/abstractions.js","sources":["../../../../src/features/task/TaskService/abstractions.ts"],"sourcesContent":["import { BaseError, createAbstraction, Result } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { type ITaskOutput, TaskDefinition } from \"~/features/task/TaskDefinition/index.js\";\n\n/** Trigger and manage long-running background tasks. */\nexport const TaskService = createAbstraction<ITaskService>(\"TaskService\");\n\nexport namespace TaskService {\n export type Interface = ITaskService;\n /**\n * This is the output of `trigger` and `abort` actions.\n */\n export type GenericOutput = IGenericOutput;\n\n export type TaskInput = TaskDefinition.TaskInput;\n\n export type Task<\n I extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITask<I, O>;\n}\n\n// The service info depends on the implementation.\n// We cannot have a more precise type here, since implementation can be anything (AWS, Azure, etc.).\nexport type IServiceInfo = GenericRecord;\n\nexport interface IResponseError {\n message: string;\n code?: string | null;\n data?: GenericRecord | null;\n stack?: string;\n}\n\nexport interface ITaskAbortParams {\n id: string;\n message?: string;\n}\n\nexport interface ITaskService {\n trigger: <\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends IGenericOutput = IGenericOutput\n >(\n params: ITaskTriggerParams<T>\n ) => Promise<Result<ITask<T, O>, BaseError>>;\n abort: <\n T extends TaskDefinition.TaskInput = TaskDefinition.TaskInput,\n O extends IGenericOutput = IGenericOutput\n >(\n params: ITaskAbortParams\n ) => Promise<Result<ITask<T, O>, BaseError>>;\n fetchServiceInfo: (input: ITask<any, any> | string) => Promise<Result<IServiceInfo, BaseError>>;\n}\n\nexport interface IGenericOutput {\n error?: IResponseError;\n [key: string]:\n | string\n | string[]\n | number\n | boolean\n | undefined\n | Record<string, any>\n | IResponseError;\n}\n\nexport interface ITaskTriggerParams<I = TaskDefinition.TaskInput> {\n parent?: Pick<ITask, \"id\">;\n definition: string;\n name?: string;\n input?: I;\n delay?: number;\n}\n\nexport interface ITaskValues<T = GenericRecord, O extends ITaskOutput = ITaskOutput> {\n startedOn?: string;\n finishedOn?: string;\n eventResponse: GenericRecord | undefined;\n iterations: number;\n parentId?: string;\n name: string;\n taskStatus: TaskDataStatus;\n definitionId: string;\n executionName: string;\n input: T;\n output?: O;\n}\n\nexport interface ITask<T = GenericRecord, O extends ITaskOutput = ITaskOutput> extends ITaskValues<\n T,\n O\n> {\n /**\n * ID without the revision number (for example: #0001).\n */\n id: string;\n createdOn: string;\n savedOn: string;\n createdBy: ITaskIdentity;\n}\n\nexport enum TaskDataStatus {\n PENDING = \"pending\",\n RUNNING = \"running\",\n FAILED = \"failed\",\n SUCCESS = \"success\",\n ABORTED = \"aborted\"\n}\n\nexport interface ITaskIdentity {\n id: string;\n displayName: string;\n type: string;\n}\n"],"names":["TaskService","createAbstraction","TaskDataStatus"],"mappings":";AAKO,MAAMA,cAAcC,kBAAgC;AAgGpD,IAAKC,8BAAcA,WAAAA,GAAAA,SAAAA,cAAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { AdminUsersRepository } from "./shared/AdminUsersRepository.js";
|
|
3
3
|
import { GetUserFeature } from "./GetUser/feature.js";
|
|
4
|
+
import { GetCurrentUserFeature } from "./GetCurrentUser/feature.js";
|
|
4
5
|
import { GetIdentityProfileFeature } from "./GetIdentityProfile/feature.js";
|
|
5
6
|
import { ListUsersFeature } from "./ListUsers/feature.js";
|
|
6
7
|
import { CreateUserFeature } from "./CreateUser/feature.js";
|
|
@@ -14,6 +15,7 @@ const AdminUsersFeature = createFeature({
|
|
|
14
15
|
register (container, storageOperations) {
|
|
15
16
|
container.register(AdminUsersRepository).inSingletonScope();
|
|
16
17
|
GetUserFeature.register(container);
|
|
18
|
+
GetCurrentUserFeature.register(container);
|
|
17
19
|
GetIdentityProfileFeature.register(container);
|
|
18
20
|
ListUsersFeature.register(container);
|
|
19
21
|
ListUserTeamsFeature.register(container);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/users/AdminUsersFeature.js","sources":["../../../src/features/users/AdminUsersFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { AdminUsersRepository } from \"./shared/AdminUsersRepository.js\";\nimport { GetUserFeature } from \"./GetUser/feature.js\";\nimport { GetIdentityProfileFeature } from \"./GetIdentityProfile/feature.js\";\nimport { ListUsersFeature } from \"./ListUsers/feature.js\";\nimport { CreateUserFeature } from \"./CreateUser/feature.js\";\nimport { UpdateUserFeature } from \"./UpdateUser/feature.js\";\nimport { DeleteUserFeature } from \"./DeleteUser/feature.js\";\nimport { ListUserTeamsFeature } from \"./ListUserTeams/feature.js\";\nimport { AdminUsersStorageOperations } from \"./shared/storageAbstractions.js\";\nimport { ExternalIdpUserSyncFeature } from \"./ExternalIdpUserSync/index.js\";\n\nexport const AdminUsersFeature = createFeature<AdminUsersStorageOperations.Interface>({\n name: \"AdminUsers\",\n register(container, storageOperations) {\n // Register repository in singleton scope\n container.register(AdminUsersRepository).inSingletonScope();\n\n // Register all use cases\n GetUserFeature.register(container);\n GetIdentityProfileFeature.register(container);\n ListUsersFeature.register(container);\n ListUserTeamsFeature.register(container);\n CreateUserFeature.register(container);\n UpdateUserFeature.register(container);\n DeleteUserFeature.register(container);\n ExternalIdpUserSyncFeature.register(container);\n\n // Legacy storage ops\n container.registerInstance(AdminUsersStorageOperations, storageOperations);\n }\n});\n"],"names":["AdminUsersFeature","createFeature","container","storageOperations","AdminUsersRepository","GetUserFeature","GetIdentityProfileFeature","ListUsersFeature","ListUserTeamsFeature","CreateUserFeature","UpdateUserFeature","DeleteUserFeature","ExternalIdpUserSyncFeature","AdminUsersStorageOperations"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/users/AdminUsersFeature.js","sources":["../../../src/features/users/AdminUsersFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { AdminUsersRepository } from \"./shared/AdminUsersRepository.js\";\nimport { GetUserFeature } from \"./GetUser/feature.js\";\nimport { GetCurrentUserFeature } from \"./GetCurrentUser/feature.js\";\nimport { GetIdentityProfileFeature } from \"./GetIdentityProfile/feature.js\";\nimport { ListUsersFeature } from \"./ListUsers/feature.js\";\nimport { CreateUserFeature } from \"./CreateUser/feature.js\";\nimport { UpdateUserFeature } from \"./UpdateUser/feature.js\";\nimport { DeleteUserFeature } from \"./DeleteUser/feature.js\";\nimport { ListUserTeamsFeature } from \"./ListUserTeams/feature.js\";\nimport { AdminUsersStorageOperations } from \"./shared/storageAbstractions.js\";\nimport { ExternalIdpUserSyncFeature } from \"./ExternalIdpUserSync/index.js\";\n\nexport const AdminUsersFeature = createFeature<AdminUsersStorageOperations.Interface>({\n name: \"AdminUsers\",\n register(container, storageOperations) {\n // Register repository in singleton scope\n container.register(AdminUsersRepository).inSingletonScope();\n\n // Register all use cases\n GetUserFeature.register(container);\n GetCurrentUserFeature.register(container);\n GetIdentityProfileFeature.register(container);\n ListUsersFeature.register(container);\n ListUserTeamsFeature.register(container);\n CreateUserFeature.register(container);\n UpdateUserFeature.register(container);\n DeleteUserFeature.register(container);\n ExternalIdpUserSyncFeature.register(container);\n\n // Legacy storage ops\n container.registerInstance(AdminUsersStorageOperations, storageOperations);\n }\n});\n"],"names":["AdminUsersFeature","createFeature","container","storageOperations","AdminUsersRepository","GetUserFeature","GetCurrentUserFeature","GetIdentityProfileFeature","ListUsersFeature","ListUserTeamsFeature","CreateUserFeature","UpdateUserFeature","DeleteUserFeature","ExternalIdpUserSyncFeature","AdminUsersStorageOperations"],"mappings":";;;;;;;;;;;;AAaO,MAAMA,oBAAoBC,cAAqD;IAClF,MAAM;IACN,UAASC,SAAS,EAAEC,iBAAiB;QAEjCD,UAAU,QAAQ,CAACE,sBAAsB,gBAAgB;QAGzDC,eAAe,QAAQ,CAACH;QACxBI,sBAAsB,QAAQ,CAACJ;QAC/BK,0BAA0B,QAAQ,CAACL;QACnCM,iBAAiB,QAAQ,CAACN;QAC1BO,qBAAqB,QAAQ,CAACP;QAC9BQ,kBAAkB,QAAQ,CAACR;QAC3BS,kBAAkB,QAAQ,CAACT;QAC3BU,kBAAkB,QAAQ,CAACV;QAC3BW,2BAA2B,QAAQ,CAACX;QAGpCA,UAAU,gBAAgB,CAACY,6BAA6BX;IAC5D;AACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "../../../features/security/IdentityContext/index.js";
|
|
3
|
+
import { GetCurrentUserUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
4
|
+
import { AdminUsersRepository } from "../../../features/users/shared/abstractions.js";
|
|
5
|
+
import type { AdminUser } from "../../../features/users/shared/types.js";
|
|
6
|
+
declare class GetCurrentUserUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
7
|
+
private identityContext;
|
|
8
|
+
private repository;
|
|
9
|
+
constructor(identityContext: IdentityContext.Interface, repository: AdminUsersRepository.Interface);
|
|
10
|
+
execute(): Promise<Result<AdminUser, UseCaseAbstraction.Error>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const GetCurrentUserUseCase: import("@webiny/di").Implementation<typeof GetCurrentUserUseCaseImpl>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Result, createImplementation } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "../../security/IdentityContext/index.js";
|
|
3
|
+
import { GetCurrentUserUseCase } from "./abstractions.js";
|
|
4
|
+
import { AdminUsersRepository } from "../shared/abstractions.js";
|
|
5
|
+
import { NotAuthorizedError } from "../shared/errors.js";
|
|
6
|
+
class GetCurrentUserUseCaseImpl {
|
|
7
|
+
constructor(identityContext, repository){
|
|
8
|
+
this.identityContext = identityContext;
|
|
9
|
+
this.repository = repository;
|
|
10
|
+
}
|
|
11
|
+
async execute() {
|
|
12
|
+
const identity = this.identityContext.getIdentity();
|
|
13
|
+
if (identity.isAnonymous() || !identity.isAdmin()) return Result.fail(new NotAuthorizedError());
|
|
14
|
+
return this.repository.get({
|
|
15
|
+
id: identity.id
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const GetCurrentUserUseCase_GetCurrentUserUseCase = createImplementation({
|
|
20
|
+
abstraction: GetCurrentUserUseCase,
|
|
21
|
+
implementation: GetCurrentUserUseCaseImpl,
|
|
22
|
+
dependencies: [
|
|
23
|
+
IdentityContext,
|
|
24
|
+
AdminUsersRepository
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
export { GetCurrentUserUseCase_GetCurrentUserUseCase as GetCurrentUserUseCase };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=GetCurrentUserUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/users/GetCurrentUser/GetCurrentUserUseCase.js","sources":["../../../../src/features/users/GetCurrentUser/GetCurrentUserUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { GetCurrentUserUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { AdminUsersRepository } from \"~/features/users/shared/abstractions.js\";\nimport { NotAuthorizedError } from \"~/features/users/shared/errors.js\";\nimport type { AdminUser } from \"~/features/users/shared/types.js\";\n\nclass GetCurrentUserUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private repository: AdminUsersRepository.Interface\n ) {}\n\n async execute(): Promise<Result<AdminUser, UseCaseAbstraction.Error>> {\n const identity = this.identityContext.getIdentity();\n if (identity.isAnonymous() || !identity.isAdmin()) {\n return Result.fail(new NotAuthorizedError());\n }\n\n /**\n * An admin may always load their own user record. The `adminUsers.user` permission,\n * which allows loading any user, is not required here.\n */\n return this.repository.get({ id: identity.id });\n }\n}\n\nexport const GetCurrentUserUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: GetCurrentUserUseCaseImpl,\n dependencies: [IdentityContext, AdminUsersRepository]\n});\n"],"names":["GetCurrentUserUseCaseImpl","identityContext","repository","identity","Result","NotAuthorizedError","GetCurrentUserUseCase","createImplementation","UseCaseAbstraction","IdentityContext","AdminUsersRepository"],"mappings":";;;;;AAQA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,UAA0C,CACpD;aAFUD,eAAe,GAAfA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,UAAgE;QAClE,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,IAAIA,SAAS,WAAW,MAAM,CAACA,SAAS,OAAO,IAC3C,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAO3B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,IAAIF,SAAS,EAAE;QAAC;IACjD;AACJ;AAEO,MAAMG,8CAAwBC,qBAAqB;IACtD,aAAaC;IACb,gBAAgBR;IAChB,cAAc;QAACS;QAAiBC;KAAqB;AACzD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { AdminUser } from "../../../features/users/shared/types.js";
|
|
3
|
+
import { AdminUsersRepository } from "../../../features/users/shared/abstractions.js";
|
|
4
|
+
import { NotAuthorizedError } from "../../../features/users/shared/errors.js";
|
|
5
|
+
export interface IGetCurrentUserErrors {
|
|
6
|
+
notAuthorized: NotAuthorizedError;
|
|
7
|
+
}
|
|
8
|
+
type GetCurrentUserError = IGetCurrentUserErrors[keyof IGetCurrentUserErrors] | AdminUsersRepository.Error;
|
|
9
|
+
export interface IGetCurrentUser {
|
|
10
|
+
execute(): Promise<Result<AdminUser, GetCurrentUserError>>;
|
|
11
|
+
}
|
|
12
|
+
/** Retrieve the admin user of the current identity. */
|
|
13
|
+
export declare const GetCurrentUserUseCase: import("@webiny/di").Abstraction<IGetCurrentUser>;
|
|
14
|
+
export declare namespace GetCurrentUserUseCase {
|
|
15
|
+
type Interface = IGetCurrentUser;
|
|
16
|
+
type Error = GetCurrentUserError;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/users/GetCurrentUser/abstractions.js","sources":["../../../../src/features/users/GetCurrentUser/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { AdminUser } from \"~/features/users/shared/types.js\";\nimport { AdminUsersRepository } from \"~/features/users/shared/abstractions.js\";\nimport { NotAuthorizedError } from \"~/features/users/shared/errors.js\";\n\n// Use case specific errors\nexport interface IGetCurrentUserErrors {\n notAuthorized: NotAuthorizedError;\n}\n\n// Combined error type (use case errors + repository errors)\ntype GetCurrentUserError =\n | IGetCurrentUserErrors[keyof IGetCurrentUserErrors]\n | AdminUsersRepository.Error;\n\n// Use case interface\nexport interface IGetCurrentUser {\n execute(): Promise<Result<AdminUser, GetCurrentUserError>>;\n}\n\n/** Retrieve the admin user of the current identity. */\nexport const GetCurrentUserUseCase = createAbstraction<IGetCurrentUser>(\"GetCurrentUserUseCase\");\n\n// Namespace exports\nexport namespace GetCurrentUserUseCase {\n export type Interface = IGetCurrentUser;\n export type Error = GetCurrentUserError;\n}\n"],"names":["GetCurrentUserUseCase","createAbstraction"],"mappings":";AAsBO,MAAMA,wBAAwBC,kBAAmC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { GetCurrentUserUseCase } from "./GetCurrentUserUseCase.js";
|
|
3
|
+
const GetCurrentUserFeature = createFeature({
|
|
4
|
+
name: "GetCurrentUser",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(GetCurrentUserUseCase);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { GetCurrentUserFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/users/GetCurrentUser/feature.js","sources":["../../../../src/features/users/GetCurrentUser/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetCurrentUserUseCase } from \"./GetCurrentUserUseCase.js\";\n\nexport const GetCurrentUserFeature = createFeature({\n name: \"GetCurrentUser\",\n register(container) {\n container.register(GetCurrentUserUseCase);\n }\n});\n"],"names":["GetCurrentUserFeature","createFeature","container","GetCurrentUserUseCase"],"mappings":";;AAGO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ErrorResponse, ListErrorResponse, ListResponse, NotFoundResponse, Response } from "@webiny/handler-graphql/responses.js";
|
|
2
2
|
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js";
|
|
3
3
|
import { GetUserUseCase } from "../../features/users/GetUser/index.js";
|
|
4
|
-
import
|
|
4
|
+
import { GetCurrentUserUseCase } from "../../features/users/GetCurrentUser/index.js";
|
|
5
5
|
import { ListUsersUseCase } from "../../features/users/ListUsers/index.js";
|
|
6
6
|
const emptyResolver = ()=>({});
|
|
7
7
|
const createUsersGraphQL = ()=>[
|
|
@@ -97,7 +97,8 @@ const createUsersGraphQL = ()=>[
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
AdminUsersQuery: {
|
|
100
|
-
getUser: async (_,
|
|
100
|
+
getUser: async (_, args, context)=>{
|
|
101
|
+
const where = args.where ?? {};
|
|
101
102
|
const getUser = context.container.resolve(GetUserUseCase);
|
|
102
103
|
const userResult = await getUser.execute({
|
|
103
104
|
id: where.id,
|
|
@@ -115,22 +116,18 @@ const createUsersGraphQL = ()=>[
|
|
|
115
116
|
return new Response(userResult.value);
|
|
116
117
|
},
|
|
117
118
|
getCurrentUser: async (_, __, context)=>{
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}));
|
|
124
|
-
if (userResponse.isFail()) {
|
|
125
|
-
const error = userResponse.error;
|
|
126
|
-
if ("AdminUser/NotFound" === error.code) return new NotFoundResponse(`User with ID ${identity.id} was not found!`);
|
|
119
|
+
const getCurrentUser = context.container.resolve(GetCurrentUserUseCase);
|
|
120
|
+
const userResult = await getCurrentUser.execute();
|
|
121
|
+
if (userResult.isFail()) {
|
|
122
|
+
const error = userResult.error;
|
|
123
|
+
if ("AdminUser/NotFound" === error.code) return new NotFoundResponse("Current user was not found!");
|
|
127
124
|
return new ErrorResponse({
|
|
128
125
|
message: error.message,
|
|
129
126
|
code: error.code,
|
|
130
127
|
data: error.data
|
|
131
128
|
});
|
|
132
129
|
}
|
|
133
|
-
return new Response(
|
|
130
|
+
return new Response(userResult.value);
|
|
134
131
|
},
|
|
135
132
|
listUsers: async (_, __, context)=>{
|
|
136
133
|
const listUsers = context.container.resolve(ListUsersUseCase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/users/user.gql.js","sources":["../../../src/graphql/users/user.gql.ts"],"sourcesContent":["import {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n NotFoundResponse,\n Response\n} from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { AdminUser } from \"~/types/users.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport NotAuthorizedResponse from \"~/graphql/security/NotAuthorizedResponse.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\n\nconst emptyResolver = () => ({});\n\nexport const createUsersGraphQL = () => {\n return [\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type AdminUsersQuery {\n _empty: String\n }\n\n type AdminUsersMutation {\n _empty: String\n }\n\n extend type Query {\n adminUsers: AdminUsersQuery\n }\n\n extend type Mutation {\n adminUsers: AdminUsersMutation\n }\n\n type AdminUsersCreatedBy {\n id: ID\n displayName: String\n }\n\n type AdminUsersError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AdminUsersBooleanResponse {\n data: Boolean\n error: AdminUsersError\n }\n `,\n resolvers: {\n Query: {\n adminUsers: emptyResolver\n },\n Mutation: {\n adminUsers: emptyResolver\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type AdminUser {\n id: ID!\n displayName: String!\n email: String!\n\n roles: [SecurityRole]\n firstName: String\n lastName: String\n avatar: JSON\n external: Boolean\n createdOn: DateTime\n }\n\n type AdminUsersResponse {\n data: AdminUser\n error: AdminUsersError\n }\n\n type AdminUsersListResponse {\n data: [AdminUser]\n error: AdminUsersError\n }\n\n input AdminUsersGetUserWhereInput {\n id: ID\n email: String\n }\n\n extend type AdminUsersQuery {\n getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse\n getCurrentUser: AdminUsersResponse\n listUsers: AdminUsersListResponse\n }\n `,\n resolvers: {\n AdminUser: {\n roles(user: AdminUser, _, context) {\n if (!user.roles) {\n return null;\n }\n\n return context.security.listRoles({ where: { id_in: user.roles } });\n }\n },\n AdminUsersQuery: {\n getUser: async (_, { where }: any, context) => {\n const getUser = context.container.resolve(GetUserUseCase);\n\n const userResult = await getUser.execute({\n id: where.id,\n email: where.email\n });\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User \"${JSON.stringify(where)}\" was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n },\n getCurrentUser: async (_, __, context) => {\n const identity = context.security.getIdentity();\n\n if (!identity.isAdmin()) {\n throw new NotAuthorizedResponse();\n }\n\n // Current user might not have permissions to execute `getUser` (this method can load any user in the system),\n // but loading your own user record should be allowed. For that reason, let's temporarily disable authorization.\n\n const getUser = context.container.resolve(GetUserUseCase);\n\n const userResponse = await context.security.withoutAuthorization(\n async () => {\n // Get user record using the identity ID.\n return await getUser.execute({ id: identity.id });\n }\n );\n\n if (userResponse.isFail()) {\n const error = userResponse.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User with ID ${identity.id} was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResponse.value);\n },\n listUsers: async (_, __, context) => {\n const listUsers = context.container.resolve(ListUsersUseCase);\n const users = await listUsers.execute();\n\n if (users.isFail()) {\n return new ListErrorResponse(users.error);\n }\n\n return new ListResponse(users.value);\n }\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n extend type AdminUser {\n teams: [SecurityTeam]\n }\n `,\n resolvers: {\n AdminUser: {\n teams(user: AdminUser, _, context) {\n const hasTeams = Array.isArray(user.teams) && user.teams.length > 0;\n if (!hasTeams) {\n return [];\n }\n\n return context.security.listTeams({ where: { id_in: user.teams } });\n }\n }\n }\n })\n ].filter(Boolean);\n};\n"],"names":["emptyResolver","createUsersGraphQL","GraphQLSchemaPlugin","user","_","context","where","getUser","GetUserUseCase","userResult","error","NotFoundResponse","JSON","ErrorResponse","Response","__","identity","NotAuthorizedResponse","userResponse","listUsers","ListUsersUseCase","users","ListErrorResponse","ListResponse","hasTeams","Array","Boolean"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"graphql/users/user.gql.js","sources":["../../../src/graphql/users/user.gql.ts"],"sourcesContent":["import {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n NotFoundResponse,\n Response\n} from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { AdminUser } from \"~/types/users.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport { GetCurrentUserUseCase } from \"~/features/users/GetCurrentUser/index.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\n\nconst emptyResolver = () => ({});\n\nexport const createUsersGraphQL = () => {\n return [\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type AdminUsersQuery {\n _empty: String\n }\n\n type AdminUsersMutation {\n _empty: String\n }\n\n extend type Query {\n adminUsers: AdminUsersQuery\n }\n\n extend type Mutation {\n adminUsers: AdminUsersMutation\n }\n\n type AdminUsersCreatedBy {\n id: ID\n displayName: String\n }\n\n type AdminUsersError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AdminUsersBooleanResponse {\n data: Boolean\n error: AdminUsersError\n }\n `,\n resolvers: {\n Query: {\n adminUsers: emptyResolver\n },\n Mutation: {\n adminUsers: emptyResolver\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type AdminUser {\n id: ID!\n displayName: String!\n email: String!\n\n roles: [SecurityRole]\n firstName: String\n lastName: String\n avatar: JSON\n external: Boolean\n createdOn: DateTime\n }\n\n type AdminUsersResponse {\n data: AdminUser\n error: AdminUsersError\n }\n\n type AdminUsersListResponse {\n data: [AdminUser]\n error: AdminUsersError\n }\n\n input AdminUsersGetUserWhereInput {\n id: ID\n email: String\n }\n\n extend type AdminUsersQuery {\n getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse\n getCurrentUser: AdminUsersResponse\n listUsers: AdminUsersListResponse\n }\n `,\n resolvers: {\n AdminUser: {\n roles(user: AdminUser, _, context) {\n if (!user.roles) {\n return null;\n }\n\n return context.security.listRoles({ where: { id_in: user.roles } });\n }\n },\n AdminUsersQuery: {\n getUser: async (_, args: any, context) => {\n // `where` is optional in the schema.\n const where = args.where ?? {};\n const getUser = context.container.resolve(GetUserUseCase);\n\n const userResult = await getUser.execute({\n id: where.id,\n email: where.email\n });\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User \"${JSON.stringify(where)}\" was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n },\n getCurrentUser: async (_, __, context) => {\n const getCurrentUser = context.container.resolve(GetCurrentUserUseCase);\n\n const userResult = await getCurrentUser.execute();\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\"Current user was not found!\");\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n },\n listUsers: async (_, __, context) => {\n const listUsers = context.container.resolve(ListUsersUseCase);\n const users = await listUsers.execute();\n\n if (users.isFail()) {\n return new ListErrorResponse(users.error);\n }\n\n return new ListResponse(users.value);\n }\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n extend type AdminUser {\n teams: [SecurityTeam]\n }\n `,\n resolvers: {\n AdminUser: {\n teams(user: AdminUser, _, context) {\n const hasTeams = Array.isArray(user.teams) && user.teams.length > 0;\n if (!hasTeams) {\n return [];\n }\n\n return context.security.listTeams({ where: { id_in: user.teams } });\n }\n }\n }\n })\n ].filter(Boolean);\n};\n"],"names":["emptyResolver","createUsersGraphQL","GraphQLSchemaPlugin","user","_","context","args","where","getUser","GetUserUseCase","userResult","error","NotFoundResponse","JSON","ErrorResponse","Response","__","getCurrentUser","GetCurrentUserUseCase","listUsers","ListUsersUseCase","users","ListErrorResponse","ListResponse","hasTeams","Array","Boolean"],"mappings":";;;;;AAcA,MAAMA,gBAAgB,IAAO,EAAC;AAEvB,MAAMC,qBAAqB,IACvB;QACH,IAAIC,oBAAoC;YACpC,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCzB,CAAC;YACD,WAAW;gBACP,OAAO;oBACH,YAAYF;gBAChB;gBACA,UAAU;oBACN,YAAYA;gBAChB;YACJ;QACJ;QACA,IAAIE,oBAAoC;YACpC,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAkCzB,CAAC;YACD,WAAW;gBACP,WAAW;oBACP,OAAMC,IAAe,EAAEC,CAAC,EAAEC,OAAO;wBAC7B,IAAI,CAACF,KAAK,KAAK,EACX,OAAO;wBAGX,OAAOE,QAAQ,QAAQ,CAAC,SAAS,CAAC;4BAAE,OAAO;gCAAE,OAAOF,KAAK,KAAK;4BAAC;wBAAE;oBACrE;gBACJ;gBACA,iBAAiB;oBACb,SAAS,OAAOC,GAAGE,MAAWD;wBAE1B,MAAME,QAAQD,KAAK,KAAK,IAAI,CAAC;wBAC7B,MAAME,UAAUH,QAAQ,SAAS,CAAC,OAAO,CAACI;wBAE1C,MAAMC,aAAa,MAAMF,QAAQ,OAAO,CAAC;4BACrC,IAAID,MAAM,EAAE;4BACZ,OAAOA,MAAM,KAAK;wBACtB;wBAEA,IAAIG,WAAW,MAAM,IAAI;4BACrB,MAAMC,QAAQD,WAAW,KAAK;4BAC9B,IAAIC,AAAe,yBAAfA,MAAM,IAAI,EACV,OAAO,IAAIC,iBACP,CAAC,MAAM,EAAEC,KAAK,SAAS,CAACN,OAAO,gBAAgB,CAAC;4BAIxD,OAAO,IAAIO,cAAc;gCACrB,SAASH,MAAM,OAAO;gCACtB,MAAMA,MAAM,IAAI;gCAChB,MAAMA,MAAM,IAAI;4BACpB;wBACJ;wBAEA,OAAO,IAAII,SAASL,WAAW,KAAK;oBACxC;oBACA,gBAAgB,OAAON,GAAGY,IAAIX;wBAC1B,MAAMY,iBAAiBZ,QAAQ,SAAS,CAAC,OAAO,CAACa;wBAEjD,MAAMR,aAAa,MAAMO,eAAe,OAAO;wBAE/C,IAAIP,WAAW,MAAM,IAAI;4BACrB,MAAMC,QAAQD,WAAW,KAAK;4BAC9B,IAAIC,AAAe,yBAAfA,MAAM,IAAI,EACV,OAAO,IAAIC,iBAAiB;4BAGhC,OAAO,IAAIE,cAAc;gCACrB,SAASH,MAAM,OAAO;gCACtB,MAAMA,MAAM,IAAI;gCAChB,MAAMA,MAAM,IAAI;4BACpB;wBACJ;wBAEA,OAAO,IAAII,SAASL,WAAW,KAAK;oBACxC;oBACA,WAAW,OAAON,GAAGY,IAAIX;wBACrB,MAAMc,YAAYd,QAAQ,SAAS,CAAC,OAAO,CAACe;wBAC5C,MAAMC,QAAQ,MAAMF,UAAU,OAAO;wBAErC,IAAIE,MAAM,MAAM,IACZ,OAAO,IAAIC,kBAAkBD,MAAM,KAAK;wBAG5C,OAAO,IAAIE,aAAaF,MAAM,KAAK;oBACvC;gBACJ;YACJ;QACJ;QACA,IAAInB,oBAAoC;YACpC,UAAwB,CAAC;;;;YAIzB,CAAC;YACD,WAAW;gBACP,WAAW;oBACP,OAAMC,IAAe,EAAEC,CAAC,EAAEC,OAAO;wBAC7B,MAAMmB,WAAWC,MAAM,OAAO,CAACtB,KAAK,KAAK,KAAKA,KAAK,KAAK,CAAC,MAAM,GAAG;wBAClE,IAAI,CAACqB,UACD,OAAO,EAAE;wBAGb,OAAOnB,QAAQ,QAAQ,CAAC,SAAS,CAAC;4BAAE,OAAO;gCAAE,OAAOF,KAAK,KAAK;4BAAC;wBAAE;oBACrE;gBACJ;YACJ;QACJ;KACH,CAAC,MAAM,CAACuB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-core",
|
|
3
|
-
"version": "6.4.12-beta.
|
|
3
|
+
"version": "6.4.12-beta.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,20 +16,20 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@ai-sdk/anthropic": "4.0.99",
|
|
18
18
|
"@ai-sdk/openai": "4.0.111",
|
|
19
|
-
"@webiny/api": "6.4.12-beta.
|
|
19
|
+
"@webiny/api": "6.4.12-beta.8",
|
|
20
20
|
"@webiny/di": "1.1.0",
|
|
21
|
-
"@webiny/error": "6.4.12-beta.
|
|
22
|
-
"@webiny/feature": "6.4.12-beta.
|
|
23
|
-
"@webiny/feature-flags": "6.4.12-beta.
|
|
24
|
-
"@webiny/handler": "6.4.12-beta.
|
|
25
|
-
"@webiny/handler-db": "6.4.12-beta.
|
|
26
|
-
"@webiny/handler-graphql": "6.4.12-beta.
|
|
27
|
-
"@webiny/plugins": "6.4.12-beta.
|
|
28
|
-
"@webiny/utils": "6.4.12-beta.
|
|
29
|
-
"@webiny/wcp": "6.4.12-beta.
|
|
30
|
-
"ai": "7.0.
|
|
21
|
+
"@webiny/error": "6.4.12-beta.8",
|
|
22
|
+
"@webiny/feature": "6.4.12-beta.8",
|
|
23
|
+
"@webiny/feature-flags": "6.4.12-beta.8",
|
|
24
|
+
"@webiny/handler": "6.4.12-beta.8",
|
|
25
|
+
"@webiny/handler-db": "6.4.12-beta.8",
|
|
26
|
+
"@webiny/handler-graphql": "6.4.12-beta.8",
|
|
27
|
+
"@webiny/plugins": "6.4.12-beta.8",
|
|
28
|
+
"@webiny/utils": "6.4.12-beta.8",
|
|
29
|
+
"@webiny/wcp": "6.4.12-beta.8",
|
|
30
|
+
"ai": "7.0.166",
|
|
31
31
|
"dataloader": "2.2.3",
|
|
32
|
-
"jose": "6.2.
|
|
32
|
+
"jose": "6.2.17",
|
|
33
33
|
"jsonwebtoken": "9.0.3",
|
|
34
34
|
"lodash": "4.18.1",
|
|
35
35
|
"minimatch": "11.0.5",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/jsonwebtoken": "9.0.10",
|
|
42
|
-
"@webiny/build-tools": "6.4.12-beta.
|
|
43
|
-
"@webiny/db-dynamodb": "6.4.12-beta.
|
|
44
|
-
"@webiny/handler-aws": "6.4.12-beta.
|
|
45
|
-
"@webiny/project-utils": "6.4.12-beta.
|
|
42
|
+
"@webiny/build-tools": "6.4.12-beta.8",
|
|
43
|
+
"@webiny/db-dynamodb": "6.4.12-beta.8",
|
|
44
|
+
"@webiny/handler-aws": "6.4.12-beta.8",
|
|
45
|
+
"@webiny/project-utils": "6.4.12-beta.8",
|
|
46
46
|
"jest-dynalite": "3.6.1",
|
|
47
47
|
"rimraf": "6.1.4",
|
|
48
48
|
"typescript": "6.0.3",
|