@nocobase/server 1.2.13-alpha → 1.3.0-alpha.20240710084543

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.
Files changed (124) hide show
  1. package/package.json +14 -14
  2. package/lib/acl/available-action.d.ts +0 -13
  3. package/lib/acl/available-action.js +0 -71
  4. package/lib/acl/index.d.ts +0 -10
  5. package/lib/acl/index.js +0 -46
  6. package/lib/app-command.d.ts +0 -20
  7. package/lib/app-command.js +0 -82
  8. package/lib/app-supervisor.d.ts +0 -69
  9. package/lib/app-supervisor.js +0 -302
  10. package/lib/application.d.ts +0 -345
  11. package/lib/application.js +0 -876
  12. package/lib/cache/index.d.ts +0 -11
  13. package/lib/cache/index.js +0 -44
  14. package/lib/commands/console.d.ts +0 -11
  15. package/lib/commands/console.js +0 -48
  16. package/lib/commands/create-migration.d.ts +0 -11
  17. package/lib/commands/create-migration.js +0 -79
  18. package/lib/commands/db-auth.d.ts +0 -11
  19. package/lib/commands/db-auth.js +0 -38
  20. package/lib/commands/db-clean.d.ts +0 -11
  21. package/lib/commands/db-clean.js +0 -41
  22. package/lib/commands/db-sync.d.ts +0 -11
  23. package/lib/commands/db-sync.js +0 -50
  24. package/lib/commands/destroy.d.ts +0 -11
  25. package/lib/commands/destroy.js +0 -40
  26. package/lib/commands/index.d.ts +0 -10
  27. package/lib/commands/index.js +0 -82
  28. package/lib/commands/install.d.ts +0 -11
  29. package/lib/commands/install.js +0 -43
  30. package/lib/commands/migrator.d.ts +0 -11
  31. package/lib/commands/migrator.js +0 -41
  32. package/lib/commands/pm.d.ts +0 -11
  33. package/lib/commands/pm.js +0 -98
  34. package/lib/commands/refresh.d.ts +0 -11
  35. package/lib/commands/refresh.js +0 -41
  36. package/lib/commands/restart.d.ts +0 -11
  37. package/lib/commands/restart.js +0 -45
  38. package/lib/commands/start.d.ts +0 -11
  39. package/lib/commands/start.js +0 -85
  40. package/lib/commands/stop.d.ts +0 -11
  41. package/lib/commands/stop.js +0 -44
  42. package/lib/commands/upgrade.d.ts +0 -14
  43. package/lib/commands/upgrade.js +0 -39
  44. package/lib/cron/cron-job-manager.d.ts +0 -22
  45. package/lib/cron/cron-job-manager.js +0 -82
  46. package/lib/errors/application-not-install.d.ts +0 -12
  47. package/lib/errors/application-not-install.js +0 -45
  48. package/lib/errors/handler.d.ts +0 -11
  49. package/lib/errors/handler.js +0 -50
  50. package/lib/errors/plugin-command-error.d.ts +0 -10
  51. package/lib/errors/plugin-command-error.js +0 -40
  52. package/lib/errors/plugin-not-exist.d.ts +0 -10
  53. package/lib/errors/plugin-not-exist.js +0 -40
  54. package/lib/gateway/errors.d.ts +0 -30
  55. package/lib/gateway/errors.js +0 -154
  56. package/lib/gateway/index.d.ts +0 -79
  57. package/lib/gateway/index.js +0 -393
  58. package/lib/gateway/ipc-socket-client.d.ts +0 -27
  59. package/lib/gateway/ipc-socket-client.js +0 -110
  60. package/lib/gateway/ipc-socket-server.d.ts +0 -21
  61. package/lib/gateway/ipc-socket-server.js +0 -150
  62. package/lib/gateway/ws-server.d.ts +0 -36
  63. package/lib/gateway/ws-server.js +0 -196
  64. package/lib/helper.d.ts +0 -18
  65. package/lib/helper.js +0 -193
  66. package/lib/helpers/application-version.d.ts +0 -18
  67. package/lib/helpers/application-version.js +0 -88
  68. package/lib/index.d.ts +0 -17
  69. package/lib/index.js +0 -64
  70. package/lib/locale/index.d.ts +0 -9
  71. package/lib/locale/index.js +0 -30
  72. package/lib/locale/locale.d.ts +0 -38
  73. package/lib/locale/locale.js +0 -174
  74. package/lib/locale/resource.d.ts +0 -9
  75. package/lib/locale/resource.js +0 -87
  76. package/lib/main-data-source.d.ts +0 -12
  77. package/lib/main-data-source.js +0 -57
  78. package/lib/middlewares/data-template.d.ts +0 -10
  79. package/lib/middlewares/data-template.js +0 -146
  80. package/lib/middlewares/data-wrapping.d.ts +0 -11
  81. package/lib/middlewares/data-wrapping.js +0 -100
  82. package/lib/middlewares/i18n.d.ts +0 -9
  83. package/lib/middlewares/i18n.js +0 -53
  84. package/lib/middlewares/index.d.ts +0 -10
  85. package/lib/middlewares/index.js +0 -39
  86. package/lib/middlewares/parse-variables.d.ts +0 -9
  87. package/lib/middlewares/parse-variables.js +0 -95
  88. package/lib/middlewares/validate-filter-params.d.ts +0 -9
  89. package/lib/middlewares/validate-filter-params.js +0 -42
  90. package/lib/migration.d.ts +0 -20
  91. package/lib/migration.js +0 -54
  92. package/lib/migrations/20230912193824-package-name-unique.d.ts +0 -14
  93. package/lib/migrations/20230912193824-package-name-unique.js +0 -59
  94. package/lib/migrations/20230912294620-update-pkg.d.ts +0 -14
  95. package/lib/migrations/20230912294620-update-pkg.js +0 -65
  96. package/lib/migrations/20240106082756-update-plugins.d.ts +0 -14
  97. package/lib/migrations/20240106082756-update-plugins.js +0 -51
  98. package/lib/migrations/20240428235620-rename-plugins.d.ts +0 -14
  99. package/lib/migrations/20240428235620-rename-plugins.js +0 -49
  100. package/lib/plugin-manager/clientStaticUtils.d.ts +0 -31
  101. package/lib/plugin-manager/clientStaticUtils.js +0 -129
  102. package/lib/plugin-manager/constants.d.ts +0 -15
  103. package/lib/plugin-manager/constants.js +0 -135
  104. package/lib/plugin-manager/deps.d.ts +0 -10
  105. package/lib/plugin-manager/deps.js +0 -83
  106. package/lib/plugin-manager/index.d.ts +0 -10
  107. package/lib/plugin-manager/index.js +0 -32
  108. package/lib/plugin-manager/middleware.d.ts +0 -10
  109. package/lib/plugin-manager/middleware.js +0 -45
  110. package/lib/plugin-manager/options/collection.d.ts +0 -10
  111. package/lib/plugin-manager/options/collection.js +0 -47
  112. package/lib/plugin-manager/options/resource.d.ts +0 -23
  113. package/lib/plugin-manager/options/resource.js +0 -186
  114. package/lib/plugin-manager/plugin-manager-repository.d.ts +0 -36
  115. package/lib/plugin-manager/plugin-manager-repository.js +0 -158
  116. package/lib/plugin-manager/plugin-manager.d.ts +0 -206
  117. package/lib/plugin-manager/plugin-manager.js +0 -1100
  118. package/lib/plugin-manager/types.d.ts +0 -23
  119. package/lib/plugin-manager/types.js +0 -24
  120. package/lib/plugin-manager/utils.d.ts +0 -115
  121. package/lib/plugin-manager/utils.js +0 -568
  122. package/lib/plugin.d.ts +0 -99
  123. package/lib/plugin.js +0 -228
  124. package/lib/swagger/index.json +0 -1569
@@ -1,146 +0,0 @@
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 data_template_exports = {};
29
- __export(data_template_exports, {
30
- dataTemplate: () => dataTemplate
31
- });
32
- module.exports = __toCommonJS(data_template_exports);
33
- const dataTemplate = /* @__PURE__ */ __name(async (ctx, next) => {
34
- const { resourceName, actionName } = ctx.action;
35
- const { isTemplate, fields } = ctx.action.params;
36
- await next();
37
- if (isTemplate && actionName === "get" && fields.length > 0) {
38
- ctx.body = traverseJSON(JSON.parse(JSON.stringify(ctx.body)), {
39
- collection: ctx.db.getCollection(resourceName),
40
- include: fields
41
- });
42
- }
43
- }, "dataTemplate");
44
- const traverseHasMany = /* @__PURE__ */ __name((arr, { collection, exclude = [], include = [] }) => {
45
- if (!arr) {
46
- return arr;
47
- }
48
- return arr.map((item) => traverseJSON(item, { collection, exclude, include }));
49
- }, "traverseHasMany");
50
- const traverseBelongsToMany = /* @__PURE__ */ __name((arr, { collection, exclude = [], through }) => {
51
- if (!arr) {
52
- return arr;
53
- }
54
- const throughCollection = collection.db.getCollection(through);
55
- return arr.map((item) => {
56
- const data = traverseJSON(item[through], { collection: throughCollection, exclude });
57
- if (data && Object.keys(data).length) {
58
- item[through] = data;
59
- } else {
60
- delete item[through];
61
- }
62
- return traverseJSON(item, {
63
- collection,
64
- excludePk: false
65
- });
66
- });
67
- }, "traverseBelongsToMany");
68
- const parseInclude = /* @__PURE__ */ __name((keys) => {
69
- const map = {};
70
- for (const key of keys) {
71
- const args = key.split(".");
72
- const field = args.shift();
73
- map[field] = map[field] || [];
74
- if (args.length) {
75
- map[field].push(args.join("."));
76
- }
77
- }
78
- return map;
79
- }, "parseInclude");
80
- const traverseJSON = /* @__PURE__ */ __name((data, options) => {
81
- if (!data) {
82
- return data;
83
- }
84
- const { collection, exclude = [], include = [], excludePk = true } = options;
85
- const map = parseInclude(include);
86
- const result = {};
87
- for (const key of Object.keys(data || {})) {
88
- const subInclude = map[key];
89
- if (include.length > 0 && !subInclude) {
90
- continue;
91
- }
92
- if (exclude.includes(key)) {
93
- continue;
94
- }
95
- if (["createdAt", "updatedAt", "createdBy", "createdById", "updatedById", "updatedBy"].includes(key)) {
96
- continue;
97
- }
98
- const field = collection.getField(key);
99
- if (!field) {
100
- result[key] = data[key];
101
- continue;
102
- }
103
- if (field.options.primaryKey && excludePk) {
104
- continue;
105
- }
106
- if (field.options.isForeignKey) {
107
- continue;
108
- }
109
- if (["sort", "password", "sequence"].includes(field.type)) {
110
- continue;
111
- }
112
- if (field.type === "hasOne") {
113
- result[key] = traverseJSON(data[key], {
114
- collection: collection.db.getCollection(field.target),
115
- exclude: [field.foreignKey],
116
- include: subInclude
117
- });
118
- } else if (field.type === "hasMany") {
119
- result[key] = traverseHasMany(data[key], {
120
- collection: collection.db.getCollection(field.target),
121
- exclude: [field.foreignKey],
122
- include: subInclude
123
- });
124
- } else if (field.type === "belongsTo") {
125
- result[key] = traverseJSON(data[key], {
126
- collection: collection.db.getCollection(field.target),
127
- // exclude: [field.foreignKey],
128
- include: subInclude,
129
- excludePk: false
130
- });
131
- } else if (field.type === "belongsToMany") {
132
- result[key] = traverseBelongsToMany(data[key], {
133
- collection: collection.db.getCollection(field.target),
134
- exclude: [field.foreignKey, field.otherKey],
135
- through: field.through
136
- });
137
- } else {
138
- result[key] = data[key];
139
- }
140
- }
141
- return result;
142
- }, "traverseJSON");
143
- // Annotate the CommonJS export names for ESM import in node:
144
- 0 && (module.exports = {
145
- dataTemplate
146
- });
@@ -1,11 +0,0 @@
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, Next } from '@nocobase/actions';
10
- export declare function dataWrapping(): (ctx: Context, next: Next) => Promise<void>;
11
- export default dataWrapping;
@@ -1,100 +0,0 @@
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 __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
- var __export = (target, all) => {
18
- for (var name in all)
19
- __defProp(target, name, { get: all[name], enumerable: true });
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") {
23
- for (let key of __getOwnPropNames(from))
24
- if (!__hasOwnProp.call(to, key) && key !== except)
25
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
- }
27
- return to;
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
- // If the importer is in node compatibility mode or this is not an ESM
31
- // file that has been converted to a CommonJS file using a Babel-
32
- // compatible transform (i.e. "__esModule" has not been set), then set
33
- // "default" to the CommonJS "module.exports" for node compatibility.
34
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
- mod
36
- ));
37
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
- var data_wrapping_exports = {};
39
- __export(data_wrapping_exports, {
40
- dataWrapping: () => dataWrapping,
41
- default: () => data_wrapping_default
42
- });
43
- module.exports = __toCommonJS(data_wrapping_exports);
44
- var import_stream = __toESM(require("stream"));
45
- function dataWrapping() {
46
- return /* @__PURE__ */ __name(async function dataWrapping2(ctx, next) {
47
- var _a, _b;
48
- await next();
49
- if (ctx.withoutDataWrapping) {
50
- return;
51
- }
52
- if (ctx.body instanceof import_stream.default.Readable) {
53
- return;
54
- }
55
- if (ctx.body instanceof Buffer) {
56
- return;
57
- }
58
- if (!ctx.body) {
59
- if (((_a = ctx.action) == null ? void 0 : _a.actionName) == "get") {
60
- ctx.status = 200;
61
- }
62
- }
63
- if (Array.isArray(ctx.body)) {
64
- ctx.body = {
65
- data: ctx.body
66
- };
67
- } else {
68
- if (ctx.body) {
69
- const { rows, ...meta } = ctx.body;
70
- if (rows) {
71
- ctx.body = {
72
- data: rows,
73
- meta
74
- };
75
- } else {
76
- ctx.body = {
77
- data: ctx.body
78
- };
79
- if (ctx.bodyMeta) {
80
- ctx.body.meta = ctx.bodyMeta;
81
- }
82
- }
83
- } else if (ctx.action) {
84
- ctx.body = {
85
- data: ctx.body
86
- };
87
- }
88
- }
89
- if (ctx.body && ((_b = ctx.state.messages) == null ? void 0 : _b.length)) {
90
- ctx.body.messages = ctx.state.messages;
91
- }
92
- ctx.dataWrapped = true;
93
- }, "dataWrapping");
94
- }
95
- __name(dataWrapping, "dataWrapping");
96
- var data_wrapping_default = dataWrapping;
97
- // Annotate the CommonJS export names for ESM import in node:
98
- 0 && (module.exports = {
99
- dataWrapping
100
- });
@@ -1,9 +0,0 @@
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
- export declare function i18n(ctx: any, next: any): Promise<void>;
@@ -1,53 +0,0 @@
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 i18n_exports = {};
29
- __export(i18n_exports, {
30
- i18n: () => i18n
31
- });
32
- module.exports = __toCommonJS(i18n_exports);
33
- async function i18n(ctx, next) {
34
- ctx.getCurrentLocale = () => {
35
- const lng2 = ctx.get("X-Locale") || ctx.request.query.locale || ctx.app.i18n.language || ctx.acceptsLanguages().shift() || "en-US";
36
- return lng2;
37
- };
38
- const lng = ctx.getCurrentLocale();
39
- const localeManager = ctx.app.localeManager;
40
- const i18n2 = await localeManager.getI18nInstance(lng);
41
- ctx.i18n = i18n2;
42
- ctx.t = i18n2.t.bind(i18n2);
43
- if (lng !== "*" && lng) {
44
- i18n2.changeLanguage(lng);
45
- await localeManager.loadResourcesByLang(lng);
46
- }
47
- await next();
48
- }
49
- __name(i18n, "i18n");
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- i18n
53
- });
@@ -1,10 +0,0 @@
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
- export * from './data-wrapping';
10
- export { parseVariables } from './parse-variables';
@@ -1,39 +0,0 @@
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 __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var middlewares_exports = {};
29
- __export(middlewares_exports, {
30
- parseVariables: () => import_parse_variables.parseVariables
31
- });
32
- module.exports = __toCommonJS(middlewares_exports);
33
- __reExport(middlewares_exports, require("./data-wrapping"), module.exports);
34
- var import_parse_variables = require("./parse-variables");
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- parseVariables,
38
- ...require("./data-wrapping")
39
- });
@@ -1,9 +0,0 @@
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
- export declare const parseVariables: (ctx: any, next: any) => Promise<any>;
@@ -1,95 +0,0 @@
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 parse_variables_exports = {};
29
- __export(parse_variables_exports, {
30
- parseVariables: () => parseVariables
31
- });
32
- module.exports = __toCommonJS(parse_variables_exports);
33
- var import_utils = require("@nocobase/utils");
34
- function getUser(ctx) {
35
- return async ({ fields }) => {
36
- var _a, _b;
37
- const userFields = fields.filter((f) => f && ctx.db.getFieldByPath("users." + f));
38
- (_a = ctx.logger) == null ? void 0 : _a.info("filter-parse: ", { userFields });
39
- if (!ctx.state.currentUser) {
40
- return;
41
- }
42
- if (!userFields.length) {
43
- return;
44
- }
45
- const user = await ctx.db.getRepository("users").findOne({
46
- filterByTk: ctx.state.currentUser.id,
47
- fields: userFields
48
- });
49
- (_b = ctx.logger) == null ? void 0 : _b.info("filter-parse: ", {
50
- $user: user == null ? void 0 : user.toJSON()
51
- });
52
- return user;
53
- };
54
- }
55
- __name(getUser, "getUser");
56
- function isNumeric(str) {
57
- if (typeof str === "number")
58
- return true;
59
- if (typeof str != "string")
60
- return false;
61
- return !isNaN(str) && !isNaN(parseFloat(str));
62
- }
63
- __name(isNumeric, "isNumeric");
64
- const parseVariables = /* @__PURE__ */ __name(async (ctx, next) => {
65
- const filter = ctx.action.params.filter;
66
- if (!filter) {
67
- return next();
68
- }
69
- ctx.action.params.filter = await (0, import_utils.parseFilter)(filter, {
70
- timezone: ctx.get("x-timezone"),
71
- now: (/* @__PURE__ */ new Date()).toISOString(),
72
- getField: (path) => {
73
- const fieldPath = path.split(".").filter((p) => !p.startsWith("$") && !isNumeric(p)).join(".");
74
- const { resourceName } = ctx.action;
75
- return ctx.db.getFieldByPath(`${resourceName}.${fieldPath}`);
76
- },
77
- vars: {
78
- // @deprecated
79
- $system: {
80
- now: (/* @__PURE__ */ new Date()).toISOString()
81
- },
82
- // @deprecated
83
- $date: (0, import_utils.getDateVars)(),
84
- // 新的命名方式,防止和 formily 内置变量冲突
85
- $nDate: (0, import_utils.getDateVars)(),
86
- $user: getUser(ctx),
87
- $nRole: ctx.state.currentRole
88
- }
89
- });
90
- await next();
91
- }, "parseVariables");
92
- // Annotate the CommonJS export names for ESM import in node:
93
- 0 && (module.exports = {
94
- parseVariables
95
- });
@@ -1,9 +0,0 @@
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
- export default function validateFilterParams(ctx: any, next: any): Promise<void>;
@@ -1,42 +0,0 @@
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 validate_filter_params_exports = {};
29
- __export(validate_filter_params_exports, {
30
- default: () => validateFilterParams
31
- });
32
- module.exports = __toCommonJS(validate_filter_params_exports);
33
- var import_utils = require("@nocobase/utils");
34
- async function validateFilterParams(ctx, next) {
35
- const { params } = ctx.action;
36
- const guardedActions = ["update", "destroy"];
37
- if (params.filter && !(0, import_utils.isValidFilter)(params.filter) && guardedActions.includes(params.actionName)) {
38
- throw new Error(`Invalid filter: ${JSON.stringify(params.filter)}`);
39
- }
40
- await next();
41
- }
42
- __name(validateFilterParams, "validateFilterParams");
@@ -1,20 +0,0 @@
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 { Migration as DbMigration } from '@nocobase/database';
10
- import Application from './application';
11
- import Plugin from './plugin';
12
- import { PluginManager } from './plugin-manager';
13
- export declare class Migration extends DbMigration {
14
- appVersion: string;
15
- pluginVersion: string;
16
- on: string;
17
- get app(): Application<import("./application").DefaultState, import("./application").DefaultContext>;
18
- get pm(): PluginManager;
19
- get plugin(): Plugin<any>;
20
- }
package/lib/migration.js DELETED
@@ -1,54 +0,0 @@
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 migration_exports = {};
29
- __export(migration_exports, {
30
- Migration: () => Migration
31
- });
32
- module.exports = __toCommonJS(migration_exports);
33
- var import_database = require("@nocobase/database");
34
- /* istanbul ignore file -- @preserve */
35
- const _Migration = class _Migration extends import_database.Migration {
36
- appVersion = "";
37
- pluginVersion = "";
38
- on = "afterLoad";
39
- get app() {
40
- return this.context.app;
41
- }
42
- get pm() {
43
- return this.context.app.pm;
44
- }
45
- get plugin() {
46
- return this.context.plugin;
47
- }
48
- };
49
- __name(_Migration, "Migration");
50
- let Migration = _Migration;
51
- // Annotate the CommonJS export names for ESM import in node:
52
- 0 && (module.exports = {
53
- Migration
54
- });
@@ -1,14 +0,0 @@
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 { Migration } from '../migration';
10
- export default class extends Migration {
11
- on: string;
12
- appVersion: string;
13
- up(): Promise<void>;
14
- }