@nocobase/actions 2.1.0-alpha.13 → 2.1.0-alpha.15

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.
@@ -17,3 +17,4 @@ export * from './remove';
17
17
  export * from './toggle';
18
18
  export * from './first-or-create';
19
19
  export * from './update-or-create';
20
+ export * from './query';
@@ -34,6 +34,7 @@ __reExport(actions_exports, require("./remove"), module.exports);
34
34
  __reExport(actions_exports, require("./toggle"), module.exports);
35
35
  __reExport(actions_exports, require("./first-or-create"), module.exports);
36
36
  __reExport(actions_exports, require("./update-or-create"), module.exports);
37
+ __reExport(actions_exports, require("./query"), module.exports);
37
38
  // Annotate the CommonJS export names for ESM import in node:
38
39
  0 && (module.exports = {
39
40
  ...require("./list"),
@@ -46,5 +47,6 @@ __reExport(actions_exports, require("./update-or-create"), module.exports);
46
47
  ...require("./remove"),
47
48
  ...require("./toggle"),
48
49
  ...require("./first-or-create"),
49
- ...require("./update-or-create")
50
+ ...require("./update-or-create"),
51
+ ...require("./query")
50
52
  });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Context } from '..';
10
+ export declare function query(ctx: Context, next: any): Promise<void>;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var query_exports = {};
29
+ __export(query_exports, {
30
+ query: () => query
31
+ });
32
+ module.exports = __toCommonJS(query_exports);
33
+ function getQueryParams(ctx) {
34
+ return { ...ctx.action.params.values };
35
+ }
36
+ __name(getQueryParams, "getQueryParams");
37
+ async function query(ctx, next) {
38
+ var _a, _b, _c;
39
+ const queryParams = getQueryParams(ctx);
40
+ if (ctx.action.sourceId) {
41
+ ctx.throw(400, "Query action does not support association resources");
42
+ }
43
+ if (!((_a = queryParams.measures) == null ? void 0 : _a.length) && !((_b = queryParams.dimensions) == null ? void 0 : _b.length)) {
44
+ ctx.throw(400, "Query action requires at least one measure or dimension");
45
+ }
46
+ const database = ctx.database || ctx.db;
47
+ const repository = database.getRepository(ctx.action.resourceName);
48
+ ctx.body = await repository.query({
49
+ context: ctx,
50
+ ...queryParams,
51
+ timezone: (_c = ctx.get) == null ? void 0 : _c.call(ctx, "x-timezone")
52
+ });
53
+ await next();
54
+ }
55
+ __name(query, "query");
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ query
59
+ });
package/lib/index.js CHANGED
@@ -61,7 +61,8 @@ function registerActions(api) {
61
61
  "update",
62
62
  "move",
63
63
  "firstOrCreate",
64
- "updateOrCreate"
64
+ "updateOrCreate",
65
+ "query"
65
66
  ])
66
67
  );
67
68
  }
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@nocobase/actions",
3
- "version": "2.1.0-alpha.13",
3
+ "version": "2.1.0-alpha.15",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",
8
8
  "dependencies": {
9
- "@nocobase/cache": "2.1.0-alpha.13",
10
- "@nocobase/database": "2.1.0-alpha.13",
11
- "@nocobase/resourcer": "2.1.0-alpha.13"
9
+ "@nocobase/cache": "2.1.0-alpha.15",
10
+ "@nocobase/database": "2.1.0-alpha.15",
11
+ "@nocobase/resourcer": "2.1.0-alpha.15"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/nocobase/nocobase.git",
16
16
  "directory": "packages/actions"
17
17
  },
18
- "gitHead": "2807a8948412d9c235115a31a81a66f7c82dd173"
18
+ "gitHead": "7c86e75b0af4b9f532c8ebf5ef96a7423b0ab60e"
19
19
  }