@webiny/api-headless-cms-scheduler 6.5.2-beta.6 → 6.5.3-beta.0
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.
|
@@ -3,7 +3,6 @@ import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/
|
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
4
4
|
import { GetPublishedEntriesByIdsUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetPublishedEntriesByIds";
|
|
5
5
|
import { PublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/PublishEntry";
|
|
6
|
-
import { UnpublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry";
|
|
7
6
|
import { RepublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/RepublishEntry";
|
|
8
7
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
9
8
|
import type { IScheduledActionPayload } from "../../types.js";
|
|
@@ -13,19 +12,17 @@ import type { IScheduledActionPayload } from "../../types.js";
|
|
|
13
12
|
* Handles the "Publish" action for CMS entries with namespace pattern: Cms/Entry/{modelId}
|
|
14
13
|
*
|
|
15
14
|
* Publishing logic:
|
|
16
|
-
* 1. If
|
|
17
|
-
* 2.
|
|
18
|
-
* 3. If a different revision is published -> unpublish old, publish new
|
|
15
|
+
* 1. If the same revision is already published -> republish it
|
|
16
|
+
* 2. Otherwise -> publish it (storage marks the previously published revision as unpublished)
|
|
19
17
|
*/
|
|
20
18
|
declare class PublishEntryActionHandlerImpl implements ScheduledActionHandler.Interface {
|
|
21
19
|
private getModelUseCase;
|
|
22
20
|
private getEntryByIdUseCase;
|
|
23
21
|
private getPublishedEntriesByIdsUseCase;
|
|
24
22
|
private publishEntryUseCase;
|
|
25
|
-
private unpublishEntryUseCase;
|
|
26
23
|
private republishEntryUseCase;
|
|
27
24
|
private identityContext;
|
|
28
|
-
constructor(getModelUseCase: GetModelUseCase.Interface, getEntryByIdUseCase: GetEntryByIdUseCase.Interface, getPublishedEntriesByIdsUseCase: GetPublishedEntriesByIdsUseCase.Interface, publishEntryUseCase: PublishEntryUseCase.Interface,
|
|
25
|
+
constructor(getModelUseCase: GetModelUseCase.Interface, getEntryByIdUseCase: GetEntryByIdUseCase.Interface, getPublishedEntriesByIdsUseCase: GetPublishedEntriesByIdsUseCase.Interface, publishEntryUseCase: PublishEntryUseCase.Interface, republishEntryUseCase: RepublishEntryUseCase.Interface, identityContext: IdentityContext.Interface);
|
|
29
26
|
canHandle(namespace: string, actionType: ScheduledActionType): boolean;
|
|
30
27
|
handle(action: IScheduledAction<IScheduledActionPayload>): Promise<void>;
|
|
31
28
|
}
|
|
@@ -3,17 +3,15 @@ import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/
|
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
4
4
|
import { GetPublishedEntriesByIdsUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetPublishedEntriesByIds";
|
|
5
5
|
import { PublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/PublishEntry";
|
|
6
|
-
import { UnpublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UnpublishEntry";
|
|
7
6
|
import { RepublishEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/RepublishEntry";
|
|
8
7
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
9
8
|
import { extractModelIdFromNamespace } from "../../utils/namespace.js";
|
|
10
9
|
class PublishEntryActionHandlerImpl {
|
|
11
|
-
constructor(getModelUseCase, getEntryByIdUseCase, getPublishedEntriesByIdsUseCase, publishEntryUseCase,
|
|
10
|
+
constructor(getModelUseCase, getEntryByIdUseCase, getPublishedEntriesByIdsUseCase, publishEntryUseCase, republishEntryUseCase, identityContext){
|
|
12
11
|
this.getModelUseCase = getModelUseCase;
|
|
13
12
|
this.getEntryByIdUseCase = getEntryByIdUseCase;
|
|
14
13
|
this.getPublishedEntriesByIdsUseCase = getPublishedEntriesByIdsUseCase;
|
|
15
14
|
this.publishEntryUseCase = publishEntryUseCase;
|
|
16
|
-
this.unpublishEntryUseCase = unpublishEntryUseCase;
|
|
17
15
|
this.republishEntryUseCase = republishEntryUseCase;
|
|
18
16
|
this.identityContext = identityContext;
|
|
19
17
|
}
|
|
@@ -47,15 +45,7 @@ class PublishEntryActionHandlerImpl {
|
|
|
47
45
|
throw new Error("Failed to check published entries");
|
|
48
46
|
}
|
|
49
47
|
const [publishedTargetEntry] = publishedEntriesResult.value;
|
|
50
|
-
if (
|
|
51
|
-
const publishResult = await this.publishEntryUseCase.execute(model, targetEntry.id);
|
|
52
|
-
if (publishResult.isFail()) {
|
|
53
|
-
console.error(`Failed to publish entry "${action.targetId}":`, publishResult.error);
|
|
54
|
-
throw new Error(`Failed to publish entry: ${action.targetId}`);
|
|
55
|
-
}
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (publishedTargetEntry.id === targetEntry.id) {
|
|
48
|
+
if (publishedTargetEntry?.id === targetEntry.id) {
|
|
59
49
|
const republishResult = await this.republishEntryUseCase.execute(model, targetEntry.id);
|
|
60
50
|
if (republishResult.isFail()) {
|
|
61
51
|
console.error(`Failed to republish entry "${action.targetId}":`, republishResult.error);
|
|
@@ -63,11 +53,6 @@ class PublishEntryActionHandlerImpl {
|
|
|
63
53
|
}
|
|
64
54
|
return;
|
|
65
55
|
}
|
|
66
|
-
const unpublishResult = await this.unpublishEntryUseCase.execute(model, publishedTargetEntry.id);
|
|
67
|
-
if (unpublishResult.isFail()) {
|
|
68
|
-
console.error(`Failed to unpublish old revision "${publishedTargetEntry.id}":`, unpublishResult.error);
|
|
69
|
-
throw new Error(`Failed to unpublish old revision: ${publishedTargetEntry.id}`);
|
|
70
|
-
}
|
|
71
56
|
const publishResult = await this.publishEntryUseCase.execute(model, targetEntry.id);
|
|
72
57
|
if (publishResult.isFail()) {
|
|
73
58
|
console.error(`Failed to publish entry "${action.targetId}":`, publishResult.error);
|
|
@@ -82,7 +67,6 @@ const PublishEntryActionHandler = ScheduledActionHandler.createImplementation({
|
|
|
82
67
|
GetEntryByIdUseCase,
|
|
83
68
|
GetPublishedEntriesByIdsUseCase,
|
|
84
69
|
PublishEntryUseCase,
|
|
85
|
-
UnpublishEntryUseCase,
|
|
86
70
|
RepublishEntryUseCase,
|
|
87
71
|
IdentityContext
|
|
88
72
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/PublishActionHandler/PublishEntryActionHandler.js","sources":["../../../src/features/PublishActionHandler/PublishEntryActionHandler.ts"],"sourcesContent":["import {\n ScheduledActionHandler,\n ScheduledActionType,\n type IScheduledAction,\n ScheduledActionTypePublish\n} from \"@webiny/api-scheduler/exports/api/scheduler.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { GetPublishedEntriesByIdsUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetPublishedEntriesByIds\";\nimport { PublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/PublishEntry\";\nimport { UnpublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UnpublishEntry\";\nimport { RepublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/RepublishEntry\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { IScheduledActionPayload } from \"~/types.js\";\nimport { extractModelIdFromNamespace } from \"~/utils/namespace.js\";\n\n/**\n * Handler for publishing CMS entries\n *\n * Handles the \"Publish\" action for CMS entries with namespace pattern: Cms/Entry/{modelId}\n *\n * Publishing logic:\n * 1. If entry is not published -> publish it\n * 2. If the same revision is already published -> republish it\n * 3. If a different revision is published -> unpublish old, publish new\n */\nclass PublishEntryActionHandlerImpl implements ScheduledActionHandler.Interface {\n constructor(\n private getModelUseCase: GetModelUseCase.Interface,\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private getPublishedEntriesByIdsUseCase: GetPublishedEntriesByIdsUseCase.Interface,\n private publishEntryUseCase: PublishEntryUseCase.Interface,\n private unpublishEntryUseCase: UnpublishEntryUseCase.Interface,\n private republishEntryUseCase: RepublishEntryUseCase.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n public canHandle(namespace: string, actionType: ScheduledActionType): boolean {\n const modelId = extractModelIdFromNamespace(namespace);\n if (!modelId) {\n return false;\n }\n return actionType === ScheduledActionTypePublish;\n }\n\n public async handle(action: IScheduledAction<IScheduledActionPayload>): Promise<void> {\n const { payload } = action;\n\n const modelId = payload.modelId;\n\n // Fetch the model\n const modelResult = await this.getModelUseCase.execute(modelId);\n if (modelResult.isFail()) {\n console.error(\n `Failed to get model \"${modelId}\" for scheduled publish action:`,\n modelResult.error,\n {\n identity: this.identityContext.getIdentity()\n }\n );\n throw new Error(`Model not found: ${modelId}`);\n }\n\n const model = modelResult.value;\n\n // Fetch the target entry\n const targetEntryResult = await this.getEntryByIdUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, action.targetId);\n if (targetEntryResult.isFail()) {\n console.error(\n `Failed to get entry \"${action.targetId}\" for scheduled publish action:`,\n targetEntryResult.error\n );\n throw new Error(`Entry not found: ${action.targetId}`);\n }\n\n const targetEntry = targetEntryResult.value;\n\n // Get published entries\n const publishedEntriesResult = await this.getPublishedEntriesByIdsUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, [targetEntry.id]);\n\n if (publishedEntriesResult.isFail()) {\n console.error(\n `Failed to get published entries for \"${targetEntry.id}\":`,\n publishedEntriesResult.error\n );\n throw new Error(`Failed to check published entries`);\n }\n\n const [publishedTargetEntry] = publishedEntriesResult.value;\n\n /**\n * Scenario 1: Entry has no published revision -> publish it\n */\n if (!publishedTargetEntry) {\n const publishResult = await this.publishEntryUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, targetEntry.id);\n if (publishResult.isFail()) {\n console.error(`Failed to publish entry \"${action.targetId}\":`, publishResult.error);\n throw new Error(`Failed to publish entry: ${action.targetId}`);\n }\n return;\n }\n\n /**\n * Scenario 2: Target entry is already published (same revision) -> republish it\n */\n if (publishedTargetEntry.id === targetEntry.id) {\n const republishResult = await this.republishEntryUseCase.execute(model, targetEntry.id);\n if (republishResult.isFail()) {\n console.error(\n `Failed to republish entry \"${action.targetId}\":`,\n republishResult.error\n );\n throw new Error(`Failed to republish entry: ${action.targetId}`);\n }\n return;\n }\n\n /**\n * Scenario 3: A different revision is published -> unpublish old, publish new\n */\n const unpublishResult = await this.unpublishEntryUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, publishedTargetEntry.id);\n if (unpublishResult.isFail()) {\n console.error(\n `Failed to unpublish old revision \"${publishedTargetEntry.id}\":`,\n unpublishResult.error\n );\n throw new Error(`Failed to unpublish old revision: ${publishedTargetEntry.id}`);\n }\n\n const publishResult = await this.publishEntryUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, targetEntry.id);\n if (publishResult.isFail()) {\n console.error(`Failed to publish entry \"${action.targetId}\":`, publishResult.error);\n throw new Error(`Failed to publish entry: ${action.targetId}`);\n }\n }\n}\n\nexport const PublishEntryActionHandler = ScheduledActionHandler.createImplementation({\n implementation: PublishEntryActionHandlerImpl,\n dependencies: [\n GetModelUseCase,\n GetEntryByIdUseCase,\n GetPublishedEntriesByIdsUseCase,\n PublishEntryUseCase,\n UnpublishEntryUseCase,\n RepublishEntryUseCase,\n IdentityContext\n ]\n});\n"],"names":["PublishEntryActionHandlerImpl","getModelUseCase","getEntryByIdUseCase","getPublishedEntriesByIdsUseCase","publishEntryUseCase","unpublishEntryUseCase","republishEntryUseCase","identityContext","namespace","actionType","modelId","extractModelIdFromNamespace","ScheduledActionTypePublish","action","payload","modelResult","console","Error","model","targetEntryResult","targetEntry","publishedEntriesResult","publishedTargetEntry","publishResult","republishResult","unpublishResult","PublishEntryActionHandler","ScheduledActionHandler","GetModelUseCase","GetEntryByIdUseCase","GetPublishedEntriesByIdsUseCase","PublishEntryUseCase","UnpublishEntryUseCase","RepublishEntryUseCase","IdentityContext"],"mappings":";;;;;;;;;AA0BA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,mBAAkD,EAClDC,+BAA0E,EAC1EC,mBAAkD,EAClDC,qBAAsD,EACtDC,qBAAsD,EACtDC,eAA0C,CACpD;aAPUN,eAAe,GAAfA;aACAC,mBAAmB,GAAnBA;aACAC,+BAA+B,GAA/BA;aACAC,mBAAmB,GAAnBA;aACAC,qBAAqB,GAArBA;aACAC,qBAAqB,GAArBA;aACAC,eAAe,GAAfA;IACT;IAEI,UAAUC,SAAiB,EAAEC,UAA+B,EAAW;QAC1E,MAAMC,UAAUC,4BAA4BH;QAC5C,IAAI,CAACE,SACD,OAAO;QAEX,OAAOD,eAAeG;IAC1B;IAEA,MAAa,OAAOC,MAAiD,EAAiB;QAClF,MAAM,EAAEC,OAAO,EAAE,GAAGD;QAEpB,MAAMH,UAAUI,QAAQ,OAAO;QAG/B,MAAMC,cAAc,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAACL;QACvD,IAAIK,YAAY,MAAM,IAAI;YACtBC,QAAQ,KAAK,CACT,CAAC,qBAAqB,EAAEN,QAAQ,+BAA+B,CAAC,EAChEK,YAAY,KAAK,EACjB;gBACI,UAAU,IAAI,CAAC,eAAe,CAAC,WAAW;YAC9C;YAEJ,MAAM,IAAIE,MAAM,CAAC,iBAAiB,EAAEP,SAAS;QACjD;QAEA,MAAMQ,QAAQH,YAAY,KAAK;QAG/B,MAAMI,oBAAoB,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAE9DD,OAAOL,OAAO,QAAQ;QACxB,IAAIM,kBAAkB,MAAM,IAAI;YAC5BH,QAAQ,KAAK,CACT,CAAC,qBAAqB,EAAEH,OAAO,QAAQ,CAAC,+BA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B,EAAE;QAChC,IAAIG,gBAAgB,MAAM,IAAI;YAC1BT,QAAQ,KAAK,CACT,CAAC,kCAAkC,EAAEM,qBAAqB,EAAE,CAAC,EAAE,CAAC,EAChEG,gBAAgB,KAAK;YAEzB,MAAM,IAAIR,MAAM,CAAC,kCAAkC,EAAEK,qBAAqB,EAAE,EAAE;QAClF;QAEA,MAAMC,gBAAgB,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAE1DL,OAAOE,YAAY,EAAE;QACvB,IAAIG,cAAc,MAAM,IAAI;YACxBP,QAAQ,KAAK,CAAC,CAAC,yBAAyB,EAAEH,OAAO,QAAQ,CAAC,EAAE,CAAC,EAAEU,cAAc,KAAK;YAClF,MAAM,IAAIN,MAAM,CAAC,yBAAyB,EAAEJ,OAAO,QAAQ,EAAE;QACjE;IACJ;AACJ;AAEO,MAAMa,4BAA4BC,uBAAuB,oBAAoB,CAAC;IACjF,gBAAgB3B;IAChB,cAAc;QACV4B;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
1
|
+
{"version":3,"file":"features/PublishActionHandler/PublishEntryActionHandler.js","sources":["../../../src/features/PublishActionHandler/PublishEntryActionHandler.ts"],"sourcesContent":["import {\n ScheduledActionHandler,\n ScheduledActionType,\n type IScheduledAction,\n ScheduledActionTypePublish\n} from \"@webiny/api-scheduler/exports/api/scheduler.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { GetPublishedEntriesByIdsUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetPublishedEntriesByIds\";\nimport { PublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/PublishEntry\";\nimport { RepublishEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/RepublishEntry\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { IScheduledActionPayload } from \"~/types.js\";\nimport { extractModelIdFromNamespace } from \"~/utils/namespace.js\";\n\n/**\n * Handler for publishing CMS entries\n *\n * Handles the \"Publish\" action for CMS entries with namespace pattern: Cms/Entry/{modelId}\n *\n * Publishing logic:\n * 1. If the same revision is already published -> republish it\n * 2. Otherwise -> publish it (storage marks the previously published revision as unpublished)\n */\nclass PublishEntryActionHandlerImpl implements ScheduledActionHandler.Interface {\n constructor(\n private getModelUseCase: GetModelUseCase.Interface,\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private getPublishedEntriesByIdsUseCase: GetPublishedEntriesByIdsUseCase.Interface,\n private publishEntryUseCase: PublishEntryUseCase.Interface,\n private republishEntryUseCase: RepublishEntryUseCase.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n public canHandle(namespace: string, actionType: ScheduledActionType): boolean {\n const modelId = extractModelIdFromNamespace(namespace);\n if (!modelId) {\n return false;\n }\n return actionType === ScheduledActionTypePublish;\n }\n\n public async handle(action: IScheduledAction<IScheduledActionPayload>): Promise<void> {\n const { payload } = action;\n\n const modelId = payload.modelId;\n\n // Fetch the model\n const modelResult = await this.getModelUseCase.execute(modelId);\n if (modelResult.isFail()) {\n console.error(\n `Failed to get model \"${modelId}\" for scheduled publish action:`,\n modelResult.error,\n {\n identity: this.identityContext.getIdentity()\n }\n );\n throw new Error(`Model not found: ${modelId}`);\n }\n\n const model = modelResult.value;\n\n // Fetch the target entry\n const targetEntryResult = await this.getEntryByIdUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, action.targetId);\n if (targetEntryResult.isFail()) {\n console.error(\n `Failed to get entry \"${action.targetId}\" for scheduled publish action:`,\n targetEntryResult.error\n );\n throw new Error(`Entry not found: ${action.targetId}`);\n }\n\n const targetEntry = targetEntryResult.value;\n\n // Get published entries\n const publishedEntriesResult = await this.getPublishedEntriesByIdsUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, [targetEntry.id]);\n\n if (publishedEntriesResult.isFail()) {\n console.error(\n `Failed to get published entries for \"${targetEntry.id}\":`,\n publishedEntriesResult.error\n );\n throw new Error(`Failed to check published entries`);\n }\n\n const [publishedTargetEntry] = publishedEntriesResult.value;\n\n /**\n * Target revision is already published -> republish it.\n */\n if (publishedTargetEntry?.id === targetEntry.id) {\n const republishResult = await this.republishEntryUseCase.execute(model, targetEntry.id);\n if (republishResult.isFail()) {\n console.error(\n `Failed to republish entry \"${action.targetId}\":`,\n republishResult.error\n );\n throw new Error(`Failed to republish entry: ${action.targetId}`);\n }\n return;\n }\n\n /**\n * No revision or a different revision is published -> publish the target revision.\n *\n * Do not unpublish the currently published revision first. Publishing marks the previously\n * published revision as unpublished in the same storage write. A separate unpublish leaves\n * the entry with no published revision when the publish fails.\n */\n const publishResult = await this.publishEntryUseCase.execute<\n IScheduledAction<IScheduledActionPayload>\n >(model, targetEntry.id);\n if (publishResult.isFail()) {\n console.error(`Failed to publish entry \"${action.targetId}\":`, publishResult.error);\n throw new Error(`Failed to publish entry: ${action.targetId}`);\n }\n }\n}\n\nexport const PublishEntryActionHandler = ScheduledActionHandler.createImplementation({\n implementation: PublishEntryActionHandlerImpl,\n dependencies: [\n GetModelUseCase,\n GetEntryByIdUseCase,\n GetPublishedEntriesByIdsUseCase,\n PublishEntryUseCase,\n RepublishEntryUseCase,\n IdentityContext\n ]\n});\n"],"names":["PublishEntryActionHandlerImpl","getModelUseCase","getEntryByIdUseCase","getPublishedEntriesByIdsUseCase","publishEntryUseCase","republishEntryUseCase","identityContext","namespace","actionType","modelId","extractModelIdFromNamespace","ScheduledActionTypePublish","action","payload","modelResult","console","Error","model","targetEntryResult","targetEntry","publishedEntriesResult","publishedTargetEntry","republishResult","publishResult","PublishEntryActionHandler","ScheduledActionHandler","GetModelUseCase","GetEntryByIdUseCase","GetPublishedEntriesByIdsUseCase","PublishEntryUseCase","RepublishEntryUseCase","IdentityContext"],"mappings":";;;;;;;;AAwBA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,mBAAkD,E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,IAAI;YACjCL,QAAQ,KAAK,CACT,CAAC,qCAAqC,EAAEI,YAAY,EAAE,CAAC,EAAE,CAAC,EAC1DC,uBAAuB,KAAK;YAEhC,MAAM,IAAIJ,MAAM;QACpB;QAEA,MAAM,CAACK,qBAAqB,GAAGD,uBAAuB,KAAK;QAK3D,IAAIC,sBAAsB,OAAOF,YAAY,EAAE,EAAE;YAC7C,MAAMG,kBAAkB,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAACL,OAAOE,YAAY,EAAE;YACtF,IAAIG,gBAAgB,MAAM,IAAI;gBAC1BP,QAAQ,KAAK,CACT,CAAC,2BAA2B,EAAEH,OAAO,QAAQ,CAAC,EAAE,CAAC,EACjDU,gBAAgB,KAAK;gBAEzB,MAAM,IAAIN,MAAM,CAAC,2BAA2B,EAAEJ,OAAO,QAAQ,EAAE;YACnE;YACA;QACJ;QASA,MAAMW,gBAAgB,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAE1DN,OAAOE,YAAY,EAAE;QACvB,IAAII,cAAc,MAAM,IAAI;YACxBR,QAAQ,KAAK,CAAC,CAAC,yBAAyB,EAAEH,OAAO,QAAQ,CAAC,EAAE,CAAC,EAAEW,cAAc,KAAK;YAClF,MAAM,IAAIP,MAAM,CAAC,yBAAyB,EAAEJ,OAAO,QAAQ,EAAE;QACjE;IACJ;AACJ;AAEO,MAAMY,4BAA4BC,uBAAuB,oBAAoB,CAAC;IACjF,gBAAgBzB;IAChB,cAAc;QACV0B;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-scheduler",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.3-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -17,23 +17,23 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@webiny/api": "6.5.
|
|
21
|
-
"@webiny/api-headless-cms": "6.5.
|
|
22
|
-
"@webiny/api-scheduler": "6.5.
|
|
23
|
-
"@webiny/feature": "6.5.
|
|
24
|
-
"@webiny/handler-graphql": "6.5.
|
|
20
|
+
"@webiny/api": "6.5.3-beta.0",
|
|
21
|
+
"@webiny/api-headless-cms": "6.5.3-beta.0",
|
|
22
|
+
"@webiny/api-scheduler": "6.5.3-beta.0",
|
|
23
|
+
"@webiny/feature": "6.5.3-beta.0",
|
|
24
|
+
"@webiny/handler-graphql": "6.5.3-beta.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@webiny/api-core": "6.5.
|
|
28
|
-
"@webiny/api-opensearch": "6.5.
|
|
29
|
-
"@webiny/build-tools": "6.5.
|
|
30
|
-
"@webiny/handler": "6.5.
|
|
31
|
-
"@webiny/handler-aws": "6.5.
|
|
32
|
-
"@webiny/plugins": "6.5.
|
|
33
|
-
"@webiny/project-utils": "6.5.
|
|
34
|
-
"@webiny/wcp": "6.5.
|
|
27
|
+
"@webiny/api-core": "6.5.3-beta.0",
|
|
28
|
+
"@webiny/api-opensearch": "6.5.3-beta.0",
|
|
29
|
+
"@webiny/build-tools": "6.5.3-beta.0",
|
|
30
|
+
"@webiny/handler": "6.5.3-beta.0",
|
|
31
|
+
"@webiny/handler-aws": "6.5.3-beta.0",
|
|
32
|
+
"@webiny/plugins": "6.5.3-beta.0",
|
|
33
|
+
"@webiny/project-utils": "6.5.3-beta.0",
|
|
34
|
+
"@webiny/wcp": "6.5.3-beta.0",
|
|
35
35
|
"typescript": "7.0.2",
|
|
36
|
-
"vitest": "5.1.
|
|
36
|
+
"vitest": "5.1.1"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|