@webiny/api-headless-cms-bulk-actions-standalone 6.6.0-alpha.4
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/BulkActionsInternalToken.d.ts +8 -0
- package/BulkActionsInternalToken.js +5 -0
- package/BulkActionsInternalToken.js.map +1 -0
- package/EmptyTrashBinRoute.d.ts +27 -0
- package/EmptyTrashBinRoute.js +59 -0
- package/EmptyTrashBinRoute.js.map +1 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/index.d.ts +6 -0
- package/index.js +17 -0
- package/index.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface IBulkActionsInternalToken {
|
|
2
|
+
value: string;
|
|
3
|
+
}
|
|
4
|
+
export declare const BulkActionsInternalToken: import("@webiny/di").Abstraction<IBulkActionsInternalToken>;
|
|
5
|
+
export declare namespace BulkActionsInternalToken {
|
|
6
|
+
type Interface = IBulkActionsInternalToken;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BulkActionsInternalToken.js","sources":["../src/BulkActionsInternalToken.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\ninterface IBulkActionsInternalToken {\n value: string;\n}\n\nexport const BulkActionsInternalToken = createAbstraction<IBulkActionsInternalToken>(\n \"BulkActionsInternalToken\"\n);\n\nexport namespace BulkActionsInternalToken {\n export type Interface = IBulkActionsInternalToken;\n}\n"],"names":["BulkActionsInternalToken","createAbstraction"],"mappings":";AAMO,MAAMA,2BAA2BC,kBACpC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HttpRouteDefinition, HttpRouteHandler } from "@webiny/event-handler-core";
|
|
2
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
3
|
+
import { TaskService } from "@webiny/api-core/features/task/TaskService/abstractions.js";
|
|
4
|
+
import { BulkActionsInternalToken } from "./BulkActionsInternalToken.js";
|
|
5
|
+
declare class EmptyTrashBinRouteImpl implements HttpRouteHandler.Interface {
|
|
6
|
+
private readonly tenantContext;
|
|
7
|
+
private readonly taskService;
|
|
8
|
+
private readonly internalToken;
|
|
9
|
+
constructor(tenantContext: TenantContext.Interface, taskService: TaskService.Interface, internalToken: BulkActionsInternalToken.Interface);
|
|
10
|
+
handle(request: HttpRouteHandler.Request, response: HttpRouteHandler.Response): Promise<import("@webiny/event-handler-core").IHttpResponseBuilder>;
|
|
11
|
+
}
|
|
12
|
+
export declare const EmptyTrashBinRoute: typeof EmptyTrashBinRouteImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-core").IHttpRoute>;
|
|
14
|
+
};
|
|
15
|
+
declare class EmptyTrashBinRouteDefinitionImpl implements HttpRouteDefinition.Interface {
|
|
16
|
+
readonly name = "empty-trash-bin";
|
|
17
|
+
readonly method = "POST";
|
|
18
|
+
readonly path = "/empty-trash-bins";
|
|
19
|
+
readonly handler: typeof EmptyTrashBinRouteImpl & {
|
|
20
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-core").IHttpRoute>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** What the router matches on. Zero dependencies, so building it costs nothing. */
|
|
24
|
+
export declare const EmptyTrashBinRouteDefinition: typeof EmptyTrashBinRouteDefinitionImpl & {
|
|
25
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-core").IHttpRouteDefinition>;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { HttpRouteDefinition, HttpRouteHandler } from "@webiny/event-handler-core";
|
|
2
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
3
|
+
import { TaskService } from "@webiny/api-core/features/task/TaskService/abstractions.js";
|
|
4
|
+
import { BulkActionsInternalToken } from "./BulkActionsInternalToken.js";
|
|
5
|
+
const INTERNAL_HEADER = "x-webiny-bulk-actions-token";
|
|
6
|
+
class EmptyTrashBinRouteImpl {
|
|
7
|
+
constructor(tenantContext, taskService, internalToken){
|
|
8
|
+
this.tenantContext = tenantContext;
|
|
9
|
+
this.taskService = taskService;
|
|
10
|
+
this.internalToken = internalToken;
|
|
11
|
+
}
|
|
12
|
+
async handle(request, response) {
|
|
13
|
+
if (request.headers[INTERNAL_HEADER] !== this.internalToken.value) return response.status(403).json({
|
|
14
|
+
error: "Forbidden."
|
|
15
|
+
});
|
|
16
|
+
try {
|
|
17
|
+
await this.tenantContext.withRootTenant(async ()=>{
|
|
18
|
+
await this.taskService.trigger({
|
|
19
|
+
definition: "hcmsEntriesEmptyTrashBins"
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
return response.json({
|
|
23
|
+
status: "ok"
|
|
24
|
+
});
|
|
25
|
+
} catch (err) {
|
|
26
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
27
|
+
console.error(`Empty trash bin route error: ${message}`);
|
|
28
|
+
return response.status(500).json({
|
|
29
|
+
status: "error",
|
|
30
|
+
error: {
|
|
31
|
+
message
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const EmptyTrashBinRoute = HttpRouteHandler.createImplementation({
|
|
38
|
+
implementation: EmptyTrashBinRouteImpl,
|
|
39
|
+
dependencies: [
|
|
40
|
+
TenantContext,
|
|
41
|
+
TaskService,
|
|
42
|
+
BulkActionsInternalToken
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
class EmptyTrashBinRouteDefinitionImpl {
|
|
46
|
+
constructor(){
|
|
47
|
+
this.name = "empty-trash-bin";
|
|
48
|
+
this.method = "POST";
|
|
49
|
+
this.path = "/empty-trash-bins";
|
|
50
|
+
this.handler = EmptyTrashBinRoute;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const EmptyTrashBinRouteDefinition = HttpRouteDefinition.createImplementation({
|
|
54
|
+
implementation: EmptyTrashBinRouteDefinitionImpl,
|
|
55
|
+
dependencies: []
|
|
56
|
+
});
|
|
57
|
+
export { EmptyTrashBinRoute, EmptyTrashBinRouteDefinition };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=EmptyTrashBinRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmptyTrashBinRoute.js","sources":["../src/EmptyTrashBinRoute.ts"],"sourcesContent":["import { HttpRouteDefinition, HttpRouteHandler } from \"@webiny/event-handler-core\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { TaskService } from \"@webiny/api-core/features/task/TaskService/abstractions.js\";\nimport { BulkActionsInternalToken } from \"./BulkActionsInternalToken.js\";\n\nconst INTERNAL_HEADER = \"x-webiny-bulk-actions-token\";\n\nclass EmptyTrashBinRouteImpl implements HttpRouteHandler.Interface {\n public constructor(\n private readonly tenantContext: TenantContext.Interface,\n private readonly taskService: TaskService.Interface,\n private readonly internalToken: BulkActionsInternalToken.Interface\n ) {}\n\n public async handle(request: HttpRouteHandler.Request, response: HttpRouteHandler.Response) {\n if (request.headers[INTERNAL_HEADER] !== this.internalToken.value) {\n return response.status(403).json({ error: \"Forbidden.\" });\n }\n\n try {\n await this.tenantContext.withRootTenant(async () => {\n await this.taskService.trigger({ definition: \"hcmsEntriesEmptyTrashBins\" });\n });\n\n return response.json({ status: \"ok\" });\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n console.error(`Empty trash bin route error: ${message}`);\n return response.status(500).json({ status: \"error\", error: { message } });\n }\n }\n}\n\nexport const EmptyTrashBinRoute = HttpRouteHandler.createImplementation({\n implementation: EmptyTrashBinRouteImpl,\n dependencies: [TenantContext, TaskService, BulkActionsInternalToken]\n});\n\nclass EmptyTrashBinRouteDefinitionImpl implements HttpRouteDefinition.Interface {\n readonly name = \"empty-trash-bin\";\n readonly method = \"POST\";\n readonly path = \"/empty-trash-bins\";\n readonly handler = EmptyTrashBinRoute;\n}\n\n/** What the router matches on. Zero dependencies, so building it costs nothing. */\nexport const EmptyTrashBinRouteDefinition = HttpRouteDefinition.createImplementation({\n implementation: EmptyTrashBinRouteDefinitionImpl,\n dependencies: []\n});\n"],"names":["INTERNAL_HEADER","EmptyTrashBinRouteImpl","tenantContext","taskService","internalToken","request","response","err","message","Error","String","console","EmptyTrashBinRoute","HttpRouteHandler","TenantContext","TaskService","BulkActionsInternalToken","EmptyTrashBinRouteDefinitionImpl","EmptyTrashBinRouteDefinition","HttpRouteDefinition"],"mappings":";;;;AAKA,MAAMA,kBAAkB;AAExB,MAAMC;IACF,YACqBC,aAAsC,EACtCC,WAAkC,EAClCC,aAAiD,CACpE;aAHmBF,aAAa,GAAbA;aACAC,WAAW,GAAXA;aACAC,aAAa,GAAbA;IAClB;IAEH,MAAa,OAAOC,OAAiC,EAAEC,QAAmC,EAAE;QACxF,IAAID,QAAQ,OAAO,CAACL,gBAAgB,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,EAC7D,OAAOM,SAAS,MAAM,CAAC,KAAK,IAAI,CAAC;YAAE,OAAO;QAAa;QAG3D,IAAI;YACA,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;gBACpC,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;oBAAE,YAAY;gBAA4B;YAC7E;YAEA,OAAOA,SAAS,IAAI,CAAC;gBAAE,QAAQ;YAAK;QACxC,EAAE,OAAOC,KAAK;YACV,MAAMC,UAAUD,eAAeE,QAAQF,IAAI,OAAO,GAAGG,OAAOH;YAC5DI,QAAQ,KAAK,CAAC,CAAC,6BAA6B,EAAEH,SAAS;YACvD,OAAOF,SAAS,MAAM,CAAC,KAAK,IAAI,CAAC;gBAAE,QAAQ;gBAAS,OAAO;oBAAEE;gBAAQ;YAAE;QAC3E;IACJ;AACJ;AAEO,MAAMI,qBAAqBC,iBAAiB,oBAAoB,CAAC;IACpE,gBAAgBZ;IAChB,cAAc;QAACa;QAAeC;QAAaC;KAAyB;AACxE;AAEA,MAAMC;;aACO,IAAI,GAAG;aACP,MAAM,GAAG;aACT,IAAI,GAAG;aACP,OAAO,GAAGL;;AACvB;AAGO,MAAMM,+BAA+BC,oBAAoB,oBAAoB,CAAC;IACjF,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @webiny/api-headless-cms-bulk-actions-standalone
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { EmptyTrashBinRouteDefinition } from "./EmptyTrashBinRoute.js";
|
|
3
|
+
import { uuid } from "@webiny/stdlib";
|
|
4
|
+
import { BulkActionsInternalToken } from "./BulkActionsInternalToken.js";
|
|
5
|
+
const EmptyTrashBinRouteFeature = createFeature({
|
|
6
|
+
name: "BulkActions/EmptyTrashBinRoute",
|
|
7
|
+
register: (container)=>{
|
|
8
|
+
const token = uuid();
|
|
9
|
+
container.registerInstance(BulkActionsInternalToken, {
|
|
10
|
+
value: token
|
|
11
|
+
});
|
|
12
|
+
container.register(EmptyTrashBinRouteDefinition);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export { BulkActionsInternalToken, EmptyTrashBinRouteFeature };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { EmptyTrashBinRouteDefinition } from \"./EmptyTrashBinRoute.js\";\nimport { uuid } from \"@webiny/stdlib\";\nimport { BulkActionsInternalToken } from \"./BulkActionsInternalToken.js\";\n\nexport { BulkActionsInternalToken };\n\nexport const EmptyTrashBinRouteFeature = createFeature({\n name: \"BulkActions/EmptyTrashBinRoute\",\n register: container => {\n const token = uuid();\n container.registerInstance(BulkActionsInternalToken, { value: token });\n container.register(EmptyTrashBinRouteDefinition);\n }\n});\n"],"names":["EmptyTrashBinRouteFeature","createFeature","container","token","uuid","BulkActionsInternalToken","EmptyTrashBinRouteDefinition"],"mappings":";;;;AAOO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAAUC,CAAAA;QACN,MAAMC,QAAQC;QACdF,UAAU,gBAAgB,CAACG,0BAA0B;YAAE,OAAOF;QAAM;QACpED,UAAU,QAAQ,CAACI;IACvB;AACJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/api-headless-cms-bulk-actions-standalone",
|
|
3
|
+
"version": "6.6.0-alpha.4",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
9
|
+
"description": "Standalone-mode handler for Webiny Headless CMS bulk actions (empty trash bin)",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"api-headless-cms-bulk-actions-server:base"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/webiny/webiny-js.git",
|
|
16
|
+
"directory": "packages/api-headless-cms-bulk-actions-standalone"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@webiny/event-handler-core": "6.6.0-alpha.4",
|
|
21
|
+
"@webiny/feature": "6.6.0-alpha.4",
|
|
22
|
+
"@webiny/stdlib": "0.0.17"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@webiny/api-core": "6.6.0-alpha.4",
|
|
26
|
+
"@webiny/build-tools": "6.6.0-alpha.4",
|
|
27
|
+
"@webiny/di": "1.1.0",
|
|
28
|
+
"typescript": "7.0.2",
|
|
29
|
+
"vitest": "4.1.11"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"webiny": {
|
|
35
|
+
"publishFrom": "dist"
|
|
36
|
+
}
|
|
37
|
+
}
|