@webiny/api-scheduler 6.5.4-beta.0 → 6.5.4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/domain/SchedulePrivateModel.js.map +1 -1
- package/domain/isValidDate.js.map +1 -1
- package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -1
- package/graphql/SchedulerGraphQLFactory.js.map +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/SchedulePrivateModel.js","sources":["../../src/domain/SchedulePrivateModel.ts"],"sourcesContent":["import { ModelFactory } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\nimport { SCHEDULE_MODEL_ID } from \"~/constants.js\";\n\nclass SchedulePrivateModelImpl implements ModelFactory.Interface {\n public async execute(builder: ModelFactory.Builder) {\n return [\n builder\n .private({\n modelId: SCHEDULE_MODEL_ID,\n name: \"Webiny CMS Schedule\",\n lifecycleEvents: false\n })\n .fields(fields => ({\n namespace: fields.text().label(\"Namespace\"),\n actionType: fields.text().label(\"Action Type\"),\n targetId: fields.text().label(\"Target ID\"),\n scheduledBy: fields\n .object()\n .label(\"Scheduled By\")\n .fields(fields => ({\n id: fields.text().label(\"Identity ID\"),\n displayName: fields.text().label(\"Display Name\"),\n type: fields.text().label(\"Type\")\n })),\n scheduledFor: fields.datetime().label(\"Scheduled For\"),\n title: fields.text().label(\"Title\"),\n error: fields.text().label(\"Error\"),\n payload: fields.json().label(\"Payload\")\n }))\n ];\n }\n}\n\nexport const SchedulePrivateModel = ModelFactory.createImplementation({\n implementation: SchedulePrivateModelImpl,\n dependencies: []\n});\n"],"names":["SchedulePrivateModelImpl","builder","SCHEDULE_MODEL_ID","fields","SchedulePrivateModel","ModelFactory"],"mappings":";;AAGA,MAAMA;IACF,MAAa,QAAQC,OAA6B,EAAE;QAChD,OAAO;YACHA,QACK,OAAO,CAAC;gBACL,SAASC;gBACT,MAAM;gBACN,iBAAiB;YACrB,GACC,MAAM,CAACC,CAAAA,SAAW;oBACf,WAAWA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC/B,YAAYA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAChC,UAAUA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC9B,aAAaA,OACR,MAAM,GACN,KAAK,CAAC,gBACN,MAAM,CAACA,CAAAA,SAAW;4BACf,IAAIA,OAAO,IAAI,GAAG,KAAK,CAAC;4BACxB,aAAaA,OAAO,IAAI,GAAG,KAAK,CAAC;4BACjC,MAAMA,OAAO,IAAI,GAAG,KAAK,CAAC;wBAC9B;
|
|
1
|
+
{"version":3,"file":"domain/SchedulePrivateModel.js","sources":["../../src/domain/SchedulePrivateModel.ts"],"sourcesContent":["import { ModelFactory } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\nimport { SCHEDULE_MODEL_ID } from \"~/constants.js\";\n\nclass SchedulePrivateModelImpl implements ModelFactory.Interface {\n public async execute(builder: ModelFactory.Builder) {\n return [\n builder\n .private({\n modelId: SCHEDULE_MODEL_ID,\n name: \"Webiny CMS Schedule\",\n lifecycleEvents: false\n })\n .fields(fields => ({\n namespace: fields.text().label(\"Namespace\"),\n actionType: fields.text().label(\"Action Type\"),\n targetId: fields.text().label(\"Target ID\"),\n scheduledBy: fields\n .object()\n .label(\"Scheduled By\")\n .fields(fields => ({\n id: fields.text().label(\"Identity ID\"),\n displayName: fields.text().label(\"Display Name\"),\n type: fields.text().label(\"Type\")\n })),\n scheduledFor: fields.datetime().label(\"Scheduled For\"),\n title: fields.text().label(\"Title\"),\n error: fields.text().label(\"Error\"),\n payload: fields.json().label(\"Payload\")\n }))\n ];\n }\n}\n\nexport const SchedulePrivateModel = ModelFactory.createImplementation({\n implementation: SchedulePrivateModelImpl,\n dependencies: []\n});\n"],"names":["SchedulePrivateModelImpl","builder","SCHEDULE_MODEL_ID","fields","SchedulePrivateModel","ModelFactory"],"mappings":";;AAGA,MAAMA;IACF,MAAa,QAAQC,OAA6B,EAAE;QAChD,OAAO;YACHA,QACK,OAAO,CAAC;gBACL,SAASC;gBACT,MAAM;gBACN,iBAAiB;YACrB,GACC,MAAM,CAACC,CAAAA,SAAW;oBACf,WAAWA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC/B,YAAYA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAChC,UAAUA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC9B,aAAaA,OACR,MAAM,GACN,KAAK,CAAC,gBACN,MAAM,CAACA,CAAAA,SAAW;4BACf,IAAIA,OAAO,IAAI,GAAG,KAAK,CAAC;4BACxB,aAAaA,OAAO,IAAI,GAAG,KAAK,CAAC;4BACjC,MAAMA,OAAO,IAAI,GAAG,KAAK,CAAC;wBAC9B,CAAC;oBACL,cAAcA,OAAO,QAAQ,GAAG,KAAK,CAAC;oBACtC,OAAOA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC3B,OAAOA,OAAO,IAAI,GAAG,KAAK,CAAC;oBAC3B,SAASA,OAAO,IAAI,GAAG,KAAK,CAAC;gBACjC,CAAC;SACR;IACL;AACJ;AAEO,MAAMC,uBAAuBC,aAAa,oBAAoB,CAAC;IAClE,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/isValidDate.js","sources":["../../src/domain/isValidDate.ts"],"sourcesContent":["import { SCHEDULE_MIN_FUTURE_SECONDS } from \"~/constants.js\";\n\n/**\n * Check if the provided date is in the future.\n * We need to ensure that the date is at least a SCHEDULE_MIN_FUTURE_MINUTES minutes in the future.\n * Otherwise, we consider it as \"immediate\" and run the action right away.\n */\nexport const isValidDate = (input: Date | null | undefined): input is Date => {\n if (!(input instanceof Date)) {\n return false;\n }\n const minDate = new Date(Date.now() + SCHEDULE_MIN_FUTURE_SECONDS * 1000);\n\n return input.getTime() >= minDate.getTime();\n};\n"],"names":["isValidDate","input","Date","minDate","SCHEDULE_MIN_FUTURE_SECONDS"],"mappings":";AAOO,MAAMA,cAAc,CAACC;IACxB,IAAI,CAAEA,CAAAA,iBAAiBC,
|
|
1
|
+
{"version":3,"file":"domain/isValidDate.js","sources":["../../src/domain/isValidDate.ts"],"sourcesContent":["import { SCHEDULE_MIN_FUTURE_SECONDS } from \"~/constants.js\";\n\n/**\n * Check if the provided date is in the future.\n * We need to ensure that the date is at least a SCHEDULE_MIN_FUTURE_MINUTES minutes in the future.\n * Otherwise, we consider it as \"immediate\" and run the action right away.\n */\nexport const isValidDate = (input: Date | null | undefined): input is Date => {\n if (!(input instanceof Date)) {\n return false;\n }\n const minDate = new Date(Date.now() + SCHEDULE_MIN_FUTURE_SECONDS * 1000);\n\n return input.getTime() >= minDate.getTime();\n};\n"],"names":["isValidDate","input","Date","minDate","SCHEDULE_MIN_FUTURE_SECONDS"],"mappings":";AAOO,MAAMA,cAAc,CAACC;IACxB,IAAI,CAAEA,CAAAA,iBAAiBC,IAAI,GACvB,OAAO;IAEX,MAAMC,UAAU,IAAID,KAAKA,KAAK,GAAG,KAAKE,AAA8B,OAA9BA;IAEtC,OAAOH,MAAM,OAAO,MAAME,QAAQ,OAAO;AAC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/GetScheduledAction/GetScheduledActionUseCase.js","sources":["../../../src/features/GetScheduledAction/GetScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { IScheduledAction, IScheduledActionEntryValues } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport {\n NotAuthorizedError,\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError\n} from \"~/domain/errors.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { SchedulerPermissionsResolver } from \"~/features/permissions/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/exports/api/security.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\n\nclass GetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private model: ScheduledActionModel.Interface,\n private permissionsResolver: SchedulerPermissionsResolver.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n params: UseCaseAbstraction.Params\n ): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>> {\n const { id, namespace } = params;\n const permissions = this.permissionsResolver.forNamespace(namespace);\n if (!(await permissions.canRead({ namespace }))) {\n return Result.fail(new NotAuthorizedError());\n }\n const scheduleId = ScheduledActionIdWithVersion.from(id);\n const entryResult = await this.getEntryByIdUseCase.execute<IScheduledActionEntryValues<T>>(\n this.model,\n scheduleId\n );\n\n if (entryResult.isFail()) {\n if (entryResult.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(scheduleId));\n }\n\n return Result.fail(new ScheduledActionPersistenceError(entryResult.error));\n }\n\n const ownRecordsOnly = await permissions.onlyOwnRecords({ namespace });\n if (ownRecordsOnly) {\n if (entryResult.value.createdBy.id !== this.identityContext.getIdentity().id) {\n return Result.fail(new NotAuthorizedError());\n }\n }\n\n const entry = entryResult.value;\n if (entry.values.namespace !== namespace) {\n return Result.fail(new ScheduledActionNotFoundError(scheduleId));\n }\n const action = ScheduledActionMapper.toAction<T>(entry);\n\n return Result.ok(action);\n }\n}\n\nexport const GetScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetScheduledActionUseCaseImpl,\n dependencies: [\n GetEntryByIdUseCase,\n ScheduledActionModel,\n SchedulerPermissionsResolver,\n IdentityContext\n ]\n});\n"],"names":["GetScheduledActionUseCaseImpl","getEntryByIdUseCase","model","permissionsResolver","identityContext","params","id","namespace","permissions","Result","NotAuthorizedError","scheduleId","ScheduledActionIdWithVersion","entryResult","ScheduledActionNotFoundError","ScheduledActionPersistenceError","ownRecordsOnly","entry","action","ScheduledActionMapper","GetScheduledActionUseCase","UseCaseAbstraction","GetEntryByIdUseCase","ScheduledActionModel","SchedulerPermissionsResolver","IdentityContext"],"mappings":";;;;;;;;;AAgBA,MAAMA;IACF,YACYC,mBAAkD,EAClDC,KAAqC,EACrCC,mBAA2D,EAC3DC,eAA0C,CACpD;aAJUH,mBAAmB,GAAnBA;aACAC,KAAK,GAALA;aACAC,mBAAmB,GAAnBA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,MAAiC,EAC6B;QAC9D,MAAM,EAAEC,EAAE,EAAEC,SAAS,EAAE,GAAGF;QAC1B,MAAMG,cAAc,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAACD;QAC1D,IAAI,CAAE,MAAMC,YAAY,OAAO,CAAC;YAAED;QAAU,IACxC,OAAOE,OAAO,IAAI,CAAC,IAAIC;QAE3B,MAAMC,aAAaC,6BAA6B,IAAI,CAACN;QACrD,MAAMO,cAAc,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CACtD,IAAI,CAAC,KAAK,EACVF;QAGJ,IAAIE,YAAY,MAAM,IAAI;YACtB,IAAIA,AAA2B,yBAA3BA,YAAY,KAAK,CAAC,IAAI,EACtB,OAAOJ,OAAO,IAAI,CAAC,IAAIK,6BAA6BH;YAGxD,OAAOF,OAAO,IAAI,CAAC,IAAIM,gCAAgCF,YAAY,KAAK;QAC5E;QAEA,MAAMG,iBAAiB,MAAMR,YAAY,cAAc,CAAC;YAAED;QAAU;QACpE,IAAIS,gBACA;YAAA,IAAIH,YAAY,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,IAAI,CAAC,eAAe,CAAC,WAAW,GAAG,EAAE,EACxE,OAAOJ,OAAO,IAAI,CAAC,IAAIC;
|
|
1
|
+
{"version":3,"file":"features/GetScheduledAction/GetScheduledActionUseCase.js","sources":["../../../src/features/GetScheduledAction/GetScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { IScheduledAction, IScheduledActionEntryValues } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport {\n NotAuthorizedError,\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError\n} from \"~/domain/errors.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { SchedulerPermissionsResolver } from \"~/features/permissions/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/exports/api/security.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\n\nclass GetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private model: ScheduledActionModel.Interface,\n private permissionsResolver: SchedulerPermissionsResolver.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n params: UseCaseAbstraction.Params\n ): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>> {\n const { id, namespace } = params;\n const permissions = this.permissionsResolver.forNamespace(namespace);\n if (!(await permissions.canRead({ namespace }))) {\n return Result.fail(new NotAuthorizedError());\n }\n const scheduleId = ScheduledActionIdWithVersion.from(id);\n const entryResult = await this.getEntryByIdUseCase.execute<IScheduledActionEntryValues<T>>(\n this.model,\n scheduleId\n );\n\n if (entryResult.isFail()) {\n if (entryResult.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(scheduleId));\n }\n\n return Result.fail(new ScheduledActionPersistenceError(entryResult.error));\n }\n\n const ownRecordsOnly = await permissions.onlyOwnRecords({ namespace });\n if (ownRecordsOnly) {\n if (entryResult.value.createdBy.id !== this.identityContext.getIdentity().id) {\n return Result.fail(new NotAuthorizedError());\n }\n }\n\n const entry = entryResult.value;\n if (entry.values.namespace !== namespace) {\n return Result.fail(new ScheduledActionNotFoundError(scheduleId));\n }\n const action = ScheduledActionMapper.toAction<T>(entry);\n\n return Result.ok(action);\n }\n}\n\nexport const GetScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetScheduledActionUseCaseImpl,\n dependencies: [\n GetEntryByIdUseCase,\n ScheduledActionModel,\n SchedulerPermissionsResolver,\n IdentityContext\n ]\n});\n"],"names":["GetScheduledActionUseCaseImpl","getEntryByIdUseCase","model","permissionsResolver","identityContext","params","id","namespace","permissions","Result","NotAuthorizedError","scheduleId","ScheduledActionIdWithVersion","entryResult","ScheduledActionNotFoundError","ScheduledActionPersistenceError","ownRecordsOnly","entry","action","ScheduledActionMapper","GetScheduledActionUseCase","UseCaseAbstraction","GetEntryByIdUseCase","ScheduledActionModel","SchedulerPermissionsResolver","IdentityContext"],"mappings":";;;;;;;;;AAgBA,MAAMA;IACF,YACYC,mBAAkD,EAClDC,KAAqC,EACrCC,mBAA2D,EAC3DC,eAA0C,CACpD;aAJUH,mBAAmB,GAAnBA;aACAC,KAAK,GAALA;aACAC,mBAAmB,GAAnBA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,MAAiC,EAC6B;QAC9D,MAAM,EAAEC,EAAE,EAAEC,SAAS,EAAE,GAAGF;QAC1B,MAAMG,cAAc,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAACD;QAC1D,IAAI,CAAE,MAAMC,YAAY,OAAO,CAAC;YAAED;QAAU,IACxC,OAAOE,OAAO,IAAI,CAAC,IAAIC;QAE3B,MAAMC,aAAaC,6BAA6B,IAAI,CAACN;QACrD,MAAMO,cAAc,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CACtD,IAAI,CAAC,KAAK,EACVF;QAGJ,IAAIE,YAAY,MAAM,IAAI;YACtB,IAAIA,AAA2B,yBAA3BA,YAAY,KAAK,CAAC,IAAI,EACtB,OAAOJ,OAAO,IAAI,CAAC,IAAIK,6BAA6BH;YAGxD,OAAOF,OAAO,IAAI,CAAC,IAAIM,gCAAgCF,YAAY,KAAK;QAC5E;QAEA,MAAMG,iBAAiB,MAAMR,YAAY,cAAc,CAAC;YAAED;QAAU;QACpE,IAAIS,gBACA;YAAA,IAAIH,YAAY,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,IAAI,CAAC,eAAe,CAAC,WAAW,GAAG,EAAE,EACxE,OAAOJ,OAAO,IAAI,CAAC,IAAIC;QAC1B;QAGL,MAAMO,QAAQJ,YAAY,KAAK;QAC/B,IAAII,MAAM,MAAM,CAAC,SAAS,KAAKV,WAC3B,OAAOE,OAAO,IAAI,CAAC,IAAIK,6BAA6BH;QAExD,MAAMO,SAASC,sBAAsB,QAAQ,CAAIF;QAEjD,OAAOR,OAAO,EAAE,CAACS;IACrB;AACJ;AAEO,MAAME,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBrB;IAChB,cAAc;QACVsB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js","sources":["../../../src/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetTargetScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { IScheduledAction, IScheduledActionEntryValues } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport {\n NotAuthorizedError,\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError\n} from \"~/domain/errors.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { SchedulerPermissionsResolver } from \"~/features/permissions/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/exports/api/security.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\nimport { ScheduledActionId } from \"~/domain/ScheduledActionId.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from \"~/constants.js\";\n\nclass GetTargetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private model: ScheduledActionModel.Interface,\n private permissionsResolver: SchedulerPermissionsResolver.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n params: UseCaseAbstraction.Params\n ): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>> {\n const { id, namespace } = params;\n const permissions = this.permissionsResolver.forNamespace(namespace);\n if (!(await permissions.canRead({ namespace }))) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const entryResult = await this.getRecord<T>(params);\n\n if (entryResult.isFail()) {\n if (entryResult.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(id));\n }\n\n return Result.fail(new ScheduledActionPersistenceError(entryResult.error));\n }\n\n const ownRecordsOnly = await permissions.onlyOwnRecords({ namespace });\n if (ownRecordsOnly) {\n if (entryResult.value.createdBy.id !== this.identityContext.getIdentity().id) {\n return Result.fail(new NotAuthorizedError());\n }\n }\n\n const entry = entryResult.value;\n if (entry.values.namespace !== namespace) {\n return Result.fail(new ScheduledActionNotFoundError(id));\n }\n const action = ScheduledActionMapper.toAction<T>(entry);\n return Result.ok(action);\n }\n\n private async getRecord<T extends GenericRecord>(params: UseCaseAbstraction.Params) {\n const schedulePublishId = ScheduledActionId.from({\n namespace: params.namespace,\n targetId: params.id,\n actionType: SCHEDULED_ACTION_PUBLISH\n });\n const publishResult = await this.getEntryByIdUseCase.execute<\n IScheduledActionEntryValues<T>\n >(this.model, ScheduledActionIdWithVersion.from(schedulePublishId));\n if (publishResult.isOk()) {\n return publishResult;\n }\n const scheduleUnpublishId = ScheduledActionId.from({\n namespace: params.namespace,\n targetId: params.id,\n actionType: SCHEDULED_ACTION_UNPUBLISH\n });\n return this.getEntryByIdUseCase.execute<IScheduledActionEntryValues<T>>(\n this.model,\n ScheduledActionIdWithVersion.from(scheduleUnpublishId)\n );\n }\n}\n\nexport const GetTargetScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetTargetScheduledActionUseCaseImpl,\n dependencies: [\n GetEntryByIdUseCase,\n ScheduledActionModel,\n SchedulerPermissionsResolver,\n IdentityContext\n ]\n});\n"],"names":["GetTargetScheduledActionUseCaseImpl","getEntryByIdUseCase","model","permissionsResolver","identityContext","params","id","namespace","permissions","Result","NotAuthorizedError","entryResult","ScheduledActionNotFoundError","ScheduledActionPersistenceError","ownRecordsOnly","entry","action","ScheduledActionMapper","schedulePublishId","ScheduledActionId","SCHEDULED_ACTION_PUBLISH","publishResult","ScheduledActionIdWithVersion","scheduleUnpublishId","SCHEDULED_ACTION_UNPUBLISH","GetTargetScheduledActionUseCase","UseCaseAbstraction","GetEntryByIdUseCase","ScheduledActionModel","SchedulerPermissionsResolver","IdentityContext"],"mappings":";;;;;;;;;;;AAkBA,MAAMA;IACF,YACYC,mBAAkD,EAClDC,KAAqC,EACrCC,mBAA2D,EAC3DC,eAA0C,CACpD;aAJUH,mBAAmB,GAAnBA;aACAC,KAAK,GAALA;aACAC,mBAAmB,GAAnBA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,MAAiC,EAC6B;QAC9D,MAAM,EAAEC,EAAE,EAAEC,SAAS,EAAE,GAAGF;QAC1B,MAAMG,cAAc,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAACD;QAC1D,IAAI,CAAE,MAAMC,YAAY,OAAO,CAAC;YAAED;QAAU,IACxC,OAAOE,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,cAAc,MAAM,IAAI,CAAC,SAAS,CAAIN;QAE5C,IAAIM,YAAY,MAAM,IAAI;YACtB,IAAIA,AAA2B,yBAA3BA,YAAY,KAAK,CAAC,IAAI,EACtB,OAAOF,OAAO,IAAI,CAAC,IAAIG,6BAA6BN;YAGxD,OAAOG,OAAO,IAAI,CAAC,IAAII,gCAAgCF,YAAY,KAAK;QAC5E;QAEA,MAAMG,iBAAiB,MAAMN,YAAY,cAAc,CAAC;YAAED;QAAU;QACpE,IAAIO,gBACA;YAAA,IAAIH,YAAY,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,IAAI,CAAC,eAAe,CAAC,WAAW,GAAG,EAAE,EACxE,OAAOF,OAAO,IAAI,CAAC,IAAIC;
|
|
1
|
+
{"version":3,"file":"features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js","sources":["../../../src/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetTargetScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { IScheduledAction, IScheduledActionEntryValues } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport {\n NotAuthorizedError,\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError\n} from \"~/domain/errors.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { SchedulerPermissionsResolver } from \"~/features/permissions/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/exports/api/security.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\nimport { ScheduledActionId } from \"~/domain/ScheduledActionId.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from \"~/constants.js\";\n\nclass GetTargetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private model: ScheduledActionModel.Interface,\n private permissionsResolver: SchedulerPermissionsResolver.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n params: UseCaseAbstraction.Params\n ): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>> {\n const { id, namespace } = params;\n const permissions = this.permissionsResolver.forNamespace(namespace);\n if (!(await permissions.canRead({ namespace }))) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const entryResult = await this.getRecord<T>(params);\n\n if (entryResult.isFail()) {\n if (entryResult.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(id));\n }\n\n return Result.fail(new ScheduledActionPersistenceError(entryResult.error));\n }\n\n const ownRecordsOnly = await permissions.onlyOwnRecords({ namespace });\n if (ownRecordsOnly) {\n if (entryResult.value.createdBy.id !== this.identityContext.getIdentity().id) {\n return Result.fail(new NotAuthorizedError());\n }\n }\n\n const entry = entryResult.value;\n if (entry.values.namespace !== namespace) {\n return Result.fail(new ScheduledActionNotFoundError(id));\n }\n const action = ScheduledActionMapper.toAction<T>(entry);\n return Result.ok(action);\n }\n\n private async getRecord<T extends GenericRecord>(params: UseCaseAbstraction.Params) {\n const schedulePublishId = ScheduledActionId.from({\n namespace: params.namespace,\n targetId: params.id,\n actionType: SCHEDULED_ACTION_PUBLISH\n });\n const publishResult = await this.getEntryByIdUseCase.execute<\n IScheduledActionEntryValues<T>\n >(this.model, ScheduledActionIdWithVersion.from(schedulePublishId));\n if (publishResult.isOk()) {\n return publishResult;\n }\n const scheduleUnpublishId = ScheduledActionId.from({\n namespace: params.namespace,\n targetId: params.id,\n actionType: SCHEDULED_ACTION_UNPUBLISH\n });\n return this.getEntryByIdUseCase.execute<IScheduledActionEntryValues<T>>(\n this.model,\n ScheduledActionIdWithVersion.from(scheduleUnpublishId)\n );\n }\n}\n\nexport const GetTargetScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetTargetScheduledActionUseCaseImpl,\n dependencies: [\n GetEntryByIdUseCase,\n ScheduledActionModel,\n SchedulerPermissionsResolver,\n IdentityContext\n ]\n});\n"],"names":["GetTargetScheduledActionUseCaseImpl","getEntryByIdUseCase","model","permissionsResolver","identityContext","params","id","namespace","permissions","Result","NotAuthorizedError","entryResult","ScheduledActionNotFoundError","ScheduledActionPersistenceError","ownRecordsOnly","entry","action","ScheduledActionMapper","schedulePublishId","ScheduledActionId","SCHEDULED_ACTION_PUBLISH","publishResult","ScheduledActionIdWithVersion","scheduleUnpublishId","SCHEDULED_ACTION_UNPUBLISH","GetTargetScheduledActionUseCase","UseCaseAbstraction","GetEntryByIdUseCase","ScheduledActionModel","SchedulerPermissionsResolver","IdentityContext"],"mappings":";;;;;;;;;;;AAkBA,MAAMA;IACF,YACYC,mBAAkD,EAClDC,KAAqC,EACrCC,mBAA2D,EAC3DC,eAA0C,CACpD;aAJUH,mBAAmB,GAAnBA;aACAC,KAAK,GAALA;aACAC,mBAAmB,GAAnBA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,MAAiC,EAC6B;QAC9D,MAAM,EAAEC,EAAE,EAAEC,SAAS,EAAE,GAAGF;QAC1B,MAAMG,cAAc,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAACD;QAC1D,IAAI,CAAE,MAAMC,YAAY,OAAO,CAAC;YAAED;QAAU,IACxC,OAAOE,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,cAAc,MAAM,IAAI,CAAC,SAAS,CAAIN;QAE5C,IAAIM,YAAY,MAAM,IAAI;YACtB,IAAIA,AAA2B,yBAA3BA,YAAY,KAAK,CAAC,IAAI,EACtB,OAAOF,OAAO,IAA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src/graphql/SchedulerGraphQLFactory.ts"],"sourcesContent":["import { GraphQLSchemaBuilder } from \"@webiny/handler-graphql/features/GraphQLSchemaBuilder/abstractions\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/handler-graphql/graphql/abstractions.core.js\";\nimport { GetScheduledActionUseCase } from \"~/features/GetScheduledAction/index.js\";\nimport { ErrorResponse, ListResponse, Response } from \"@webiny/handler-graphql/responses.js\";\nimport { ListScheduledActionsUseCase } from \"~/features/ListScheduledActions/index.js\";\nimport { ScheduleActionUseCase } from \"~/features/ScheduleAction/index.js\";\nimport { CancelScheduledActionUseCase } from \"~/features/CancelScheduledAction/index.js\";\nimport { ScheduledActionNotFoundError } from \"~/domain/errors.js\";\nimport type { Identity, ScheduledActionType } from \"~/shared/abstractions.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\nimport { GetTargetScheduledActionUseCase } from \"~/features/GetTargetScheduledAction/index.js\";\n\ninterface IListScheduledActionsArgs extends ListScheduledActionsUseCase.Params {\n namespace: string;\n}\n\ninterface IScheduleRecordOutput {\n id: string;\n targetId: string;\n namespace: string;\n scheduledBy: Identity;\n publishOn: Date | null;\n unpublishOn: Date | null;\n actionType: ScheduledActionType;\n title: string;\n error: string | null;\n}\n\nexport class SchedulerGraphQL implements CoreGraphQLSchemaFactory.Interface {\n public async execute(\n builder: GraphQLSchemaBuilder.Interface\n ): Promise<GraphQLSchemaBuilder.Interface> {\n builder.addTypeDefs(`\n enum ScheduleRecordType {\n publish\n unpublish\n }\n \n type ScheduleError {\n message: String!\n code: String\n data: JSON\n stack: String\n }\n \n type ScheduleListMeta {\n hasMoreItems: Boolean!\n totalCount: Int!\n cursor: String\n }\n \n type ScheduleIdentity {\n id: String!\n displayName: String\n type: String\n }\n \n type ScheduleRecord {\n id: ID!\n targetId: String!\n namespace: String!\n scheduledBy: ScheduleIdentity!\n publishOn: DateTime\n unpublishOn: DateTime\n actionType: ScheduleRecordType!\n title: String!\n # Error message of the last failed execution.\n error: String\n }\n\n type GetScheduledActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type ListScheduledActionsResponse {\n data: [ScheduleRecord!]\n error: ScheduleError\n meta: ScheduleListMeta\n }\n\n type ScheduleActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type CancelScheduledActionResponse {\n data: Boolean\n error: ScheduleError\n }\n\n input ListScheduledActionsWhereInput {\n targetId: String\n targetId_in: [String!]\n title: String\n title_contains: String\n title_not_contains: String\n actionType: ScheduleRecordType\n actionType_in: [ScheduleRecordType!]\n scheduledBy: String\n scheduledBy_in: [String!]\n scheduledFor: DateTime\n scheduledFor_gte: DateTime\n scheduledFor_lte: DateTime\n }\n\n enum ListScheduledActionsSorter {\n title_ASC\n title_DESC\n scheduledFor_ASC\n scheduledFor_DESC\n }\n \n type SchedulerQuery {\n _empty: String\n }\n \n type SchedulerMutation {\n _empty: String\n }\n\n extend type SchedulerQuery {\n # Fetch scheduled action by its own ID\n getScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n # Fetch scheduled action by target ID\n getTargetScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n listScheduledActions(\n namespace: String!\n where: ListScheduledActionsWhereInput\n sort: [ListScheduledActionsSorter!]\n limit: Int\n after: String\n ): ListScheduledActionsResponse!\n }\n\n extend type SchedulerMutation {\n scheduleAction(\n namespace: String!\n targetId: ID!\n immediately: Boolean\n scheduleFor: DateTime\n actionType: ScheduleRecordType!\n ): ScheduleActionResponse!\n \n cancelScheduledAction(namespace: String!, id: ID!): CancelScheduledActionResponse!\n }\n \n extend type Query {\n scheduler: SchedulerQuery\n }\n \n extend type Mutation {\n scheduler: SchedulerMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n builder.addResolver({\n path: \"Mutation.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n\n builder.addResolver<GetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getScheduledAction\",\n dependencies: [GetScheduledActionUseCase],\n resolver: (useCase: GetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<GetTargetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getTargetScheduledAction\",\n dependencies: [GetTargetScheduledActionUseCase],\n resolver: (useCase: GetTargetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<IListScheduledActionsArgs>({\n path: \"SchedulerQuery.listScheduledActions\",\n dependencies: [ListScheduledActionsUseCase],\n resolver: (useCase: ListScheduledActionsUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute({\n ...args,\n where: {\n ...args.where,\n namespace: args.namespace\n }\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse<IScheduleRecordOutput>(\n result.value.items.map(item => {\n return ScheduledActionMapper.toGraphQL(item);\n }),\n result.value.meta\n );\n };\n }\n });\n\n builder.addResolver<ScheduleActionUseCase.Params>({\n path: \"SchedulerMutation.scheduleAction\",\n dependencies: [ScheduleActionUseCase],\n resolver: (useCase: ScheduleActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<CancelScheduledActionUseCase.Params>({\n path: \"SchedulerMutation.cancelScheduledAction\",\n dependencies: [CancelScheduledActionUseCase],\n resolver: (useCase: CancelScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<boolean>(result.value);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const SchedulerGraphQLFactory = CoreGraphQLSchemaFactory.createImplementation({\n dependencies: [],\n implementation: SchedulerGraphQL\n});\n"],"names":["SchedulerGraphQL","builder","GetScheduledActionUseCase","useCase","args","result","ScheduledActionNotFoundError","Response","ErrorResponse","ScheduledActionMapper","GetTargetScheduledActionUseCase","ListScheduledActionsUseCase","ListResponse","item","ScheduleActionUseCase","CancelScheduledActionUseCase","SchedulerGraphQLFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;;;;;;AA4BO,MAAMA;IACT,MAAa,QACTC,OAAuC,EACA;QACvCA,QAAQ,WAAW,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA4HrB,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IACC,UACI,EAAC;QAGpB;QACAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IACC,UACI,EAAC;QAGpB;QAEAA,QAAQ,WAAW,CAAmC;YAClD,MAAM;YACN,cAAc;gBAACC;aAA0B;YACzC,UAAU,CAACC,UACA,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC;oBAErC,IAAIC,OAAO,MAAM,IAAI;wBACjB,IAAIA,OAAO,KAAK,YAAYC,8BACxB,OAAO,IAAIC,SAAS;wBAExB,OAAO,IAAIC,cAAcH,OAAO,KAAK;oBACzC;oBAEA,O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,WAAW,CAAsC;YACrD,MAAM;YACN,cAAc;gBAACc;aAA6B;YAC5C,UAAU,CAACZ,UACA,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC;oBAErC,IAAIC,OAAO,MAAM,IACb,OAAO,IAAIG,cAAcH,OAAO,KAAK;oBAGzC,OAAO,IAAIE,SAAkBF,OAAO,KAAK;gBAC7C;QAER;QAEA,OAAOJ;IACX;AACJ;AAEO,MAAMe,0BAA0BC,yBAAyB,oBAAoB,CAAC;IACjF,cAAc,EAAE;IAChB,gBAAgBjB;AACpB"}
|
|
1
|
+
{"version":3,"file":"graphql/SchedulerGraphQLFactory.js","sources":["../../src/graphql/SchedulerGraphQLFactory.ts"],"sourcesContent":["import { GraphQLSchemaBuilder } from \"@webiny/handler-graphql/features/GraphQLSchemaBuilder/abstractions\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/handler-graphql/graphql/abstractions.core.js\";\nimport { GetScheduledActionUseCase } from \"~/features/GetScheduledAction/index.js\";\nimport { ErrorResponse, ListResponse, Response } from \"@webiny/handler-graphql/responses.js\";\nimport { ListScheduledActionsUseCase } from \"~/features/ListScheduledActions/index.js\";\nimport { ScheduleActionUseCase } from \"~/features/ScheduleAction/index.js\";\nimport { CancelScheduledActionUseCase } from \"~/features/CancelScheduledAction/index.js\";\nimport { ScheduledActionNotFoundError } from \"~/domain/errors.js\";\nimport type { Identity, ScheduledActionType } from \"~/shared/abstractions.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\nimport { GetTargetScheduledActionUseCase } from \"~/features/GetTargetScheduledAction/index.js\";\n\ninterface IListScheduledActionsArgs extends ListScheduledActionsUseCase.Params {\n namespace: string;\n}\n\ninterface IScheduleRecordOutput {\n id: string;\n targetId: string;\n namespace: string;\n scheduledBy: Identity;\n publishOn: Date | null;\n unpublishOn: Date | null;\n actionType: ScheduledActionType;\n title: string;\n error: string | null;\n}\n\nexport class SchedulerGraphQL implements CoreGraphQLSchemaFactory.Interface {\n public async execute(\n builder: GraphQLSchemaBuilder.Interface\n ): Promise<GraphQLSchemaBuilder.Interface> {\n builder.addTypeDefs(`\n enum ScheduleRecordType {\n publish\n unpublish\n }\n \n type ScheduleError {\n message: String!\n code: String\n data: JSON\n stack: String\n }\n \n type ScheduleListMeta {\n hasMoreItems: Boolean!\n totalCount: Int!\n cursor: String\n }\n \n type ScheduleIdentity {\n id: String!\n displayName: String\n type: String\n }\n \n type ScheduleRecord {\n id: ID!\n targetId: String!\n namespace: String!\n scheduledBy: ScheduleIdentity!\n publishOn: DateTime\n unpublishOn: DateTime\n actionType: ScheduleRecordType!\n title: String!\n # Error message of the last failed execution.\n error: String\n }\n\n type GetScheduledActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type ListScheduledActionsResponse {\n data: [ScheduleRecord!]\n error: ScheduleError\n meta: ScheduleListMeta\n }\n\n type ScheduleActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type CancelScheduledActionResponse {\n data: Boolean\n error: ScheduleError\n }\n\n input ListScheduledActionsWhereInput {\n targetId: String\n targetId_in: [String!]\n title: String\n title_contains: String\n title_not_contains: String\n actionType: ScheduleRecordType\n actionType_in: [ScheduleRecordType!]\n scheduledBy: String\n scheduledBy_in: [String!]\n scheduledFor: DateTime\n scheduledFor_gte: DateTime\n scheduledFor_lte: DateTime\n }\n\n enum ListScheduledActionsSorter {\n title_ASC\n title_DESC\n scheduledFor_ASC\n scheduledFor_DESC\n }\n \n type SchedulerQuery {\n _empty: String\n }\n \n type SchedulerMutation {\n _empty: String\n }\n\n extend type SchedulerQuery {\n # Fetch scheduled action by its own ID\n getScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n # Fetch scheduled action by target ID\n getTargetScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n listScheduledActions(\n namespace: String!\n where: ListScheduledActionsWhereInput\n sort: [ListScheduledActionsSorter!]\n limit: Int\n after: String\n ): ListScheduledActionsResponse!\n }\n\n extend type SchedulerMutation {\n scheduleAction(\n namespace: String!\n targetId: ID!\n immediately: Boolean\n scheduleFor: DateTime\n actionType: ScheduleRecordType!\n ): ScheduleActionResponse!\n \n cancelScheduledAction(namespace: String!, id: ID!): CancelScheduledActionResponse!\n }\n \n extend type Query {\n scheduler: SchedulerQuery\n }\n \n extend type Mutation {\n scheduler: SchedulerMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n builder.addResolver({\n path: \"Mutation.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n\n builder.addResolver<GetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getScheduledAction\",\n dependencies: [GetScheduledActionUseCase],\n resolver: (useCase: GetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<GetTargetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getTargetScheduledAction\",\n dependencies: [GetTargetScheduledActionUseCase],\n resolver: (useCase: GetTargetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<IListScheduledActionsArgs>({\n path: \"SchedulerQuery.listScheduledActions\",\n dependencies: [ListScheduledActionsUseCase],\n resolver: (useCase: ListScheduledActionsUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute({\n ...args,\n where: {\n ...args.where,\n namespace: args.namespace\n }\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse<IScheduleRecordOutput>(\n result.value.items.map(item => {\n return ScheduledActionMapper.toGraphQL(item);\n }),\n result.value.meta\n );\n };\n }\n });\n\n builder.addResolver<ScheduleActionUseCase.Params>({\n path: \"SchedulerMutation.scheduleAction\",\n dependencies: [ScheduleActionUseCase],\n resolver: (useCase: ScheduleActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<CancelScheduledActionUseCase.Params>({\n path: \"SchedulerMutation.cancelScheduledAction\",\n dependencies: [CancelScheduledActionUseCase],\n resolver: (useCase: CancelScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<boolean>(result.value);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const SchedulerGraphQLFactory = CoreGraphQLSchemaFactory.createImplementation({\n dependencies: [],\n implementation: SchedulerGraphQL\n});\n"],"names":["SchedulerGraphQL","builder","GetScheduledActionUseCase","useCase","args","result","ScheduledActionNotFoundError","Response","ErrorResponse","ScheduledActionMapper","GetTargetScheduledActionUseCase","ListScheduledActionsUseCase","ListResponse","item","ScheduleActionUseCase","CancelScheduledActionUseCase","SchedulerGraphQLFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;;;;;;AA4BO,MAAMA;IACT,MAAa,QACTC,OAAuC,EACA;QACvCA,QAAQ,WAAW,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA4HrB,CAAC;QAEDA,QAAQ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IAAIO,aACPP,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAACQ,CAAAA,OACZJ,sBAAsB,SAAS,CAACI,QAE3CR,OAAO,KAAK,CAAC,IAAI;gBAEzB;QAER;QAEAJ,QAAQ,WAAW,CAA+B;YAC9C,MAAM;YACN,cAAc;gBAACa;aAAsB;YACrC,UAAU,CAACX,UACA,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC;oBAErC,IAAIC,OAAO,MAAM,IACb,OAAO,IAAIG,cAAcH,OAAO,KAAK;oBAGzC,OAAO,IAAIE,SACPE,sBAAsB,SAAS,CAACJ,OAAO,KAAK;gBAEpD;QAER;QAEAJ,QAAQ,WAAW,CAAsC;YACrD,MAAM;YACN,cAAc;gBAACc;aAA6B;YAC5C,UAAU,CAACZ,UACA,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC;oBAErC,IAAIC,OAAO,MAAM,IACb,OAAO,IAAIG,cAAcH,OAAO,KAAK;oBAGzC,OAAO,IAAIE,SAAkBF,OAAO,KAAK;gBAC7C;QAER;QAEA,OAAOJ;IACX;AACJ;AAEO,MAAMe,0BAA0BC,yBAAyB,oBAAoB,CAAC;IACjF,cAAc,EAAE;IAChB,gBAAgBjB;AACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-scheduler",
|
|
3
|
-
"version": "6.5.4-beta.
|
|
3
|
+
"version": "6.5.4-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,20 +18,20 @@
|
|
|
18
18
|
"description": "A generic action scheduler.",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webiny/api": "6.5.4-beta.
|
|
22
|
-
"@webiny/api-core": "6.5.4-beta.
|
|
23
|
-
"@webiny/api-headless-cms": "6.5.4-beta.
|
|
24
|
-
"@webiny/feature": "6.5.4-beta.
|
|
25
|
-
"@webiny/handler": "6.5.4-beta.
|
|
26
|
-
"@webiny/handler-graphql": "6.5.4-beta.
|
|
27
|
-
"@webiny/utils": "6.5.4-beta.
|
|
21
|
+
"@webiny/api": "6.5.4-beta.2",
|
|
22
|
+
"@webiny/api-core": "6.5.4-beta.2",
|
|
23
|
+
"@webiny/api-headless-cms": "6.5.4-beta.2",
|
|
24
|
+
"@webiny/feature": "6.5.4-beta.2",
|
|
25
|
+
"@webiny/handler": "6.5.4-beta.2",
|
|
26
|
+
"@webiny/handler-graphql": "6.5.4-beta.2",
|
|
27
|
+
"@webiny/utils": "6.5.4-beta.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@webiny/build-tools": "6.5.4-beta.
|
|
31
|
-
"@webiny/project-utils": "6.5.4-beta.
|
|
30
|
+
"@webiny/build-tools": "6.5.4-beta.2",
|
|
31
|
+
"@webiny/project-utils": "6.5.4-beta.2",
|
|
32
32
|
"rimraf": "6.1.4",
|
|
33
33
|
"typescript": "7.0.2",
|
|
34
|
-
"vitest": "5.1.
|
|
34
|
+
"vitest": "5.1.2"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|