@nocobase/plugin-data-source-manager 2.1.0-alpha.4 → 2.1.0-alpha.45
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/LICENSE +201 -0
- package/README.md +79 -10
- package/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/ai/ai-employees/orin/ignored.d.ts +10 -0
- package/dist/ai/ai-employees/orin/ignored.js +59 -0
- package/dist/ai/ai-employees/orin/skills/data-modeling/SKILLS.md +245 -0
- package/dist/ai/{tools → ai-employees/orin/skills/data-modeling/tools}/defineCollections.js +47 -1
- package/dist/ai/{tools → ai-employees/orin/skills/data-modeling/tools}/intentRouter.js +1 -1
- package/dist/ai/{tools/data-query → common}/common.js +63 -11
- package/dist/ai/{tools/data-query → common}/utils.d.ts +1 -0
- package/dist/ai/{tools/data-query → common}/utils.js +15 -0
- package/dist/ai/skills/data-metadata/SKILLS.md +108 -0
- package/dist/ai/{tools → skills/data-metadata/tools}/getCollectionMetadata.js +2 -2
- package/dist/ai/{tools → skills/data-metadata/tools}/getCollectionNames.js +2 -2
- package/dist/ai/{tools → skills/data-metadata/tools}/getDataSources.js +2 -2
- package/dist/ai/{tools → skills/data-metadata/tools}/searchFieldMetadata.js +2 -2
- package/dist/ai/skills/data-query/SKILLS.md +246 -0
- package/dist/ai/skills/data-query/tools/dataQuery.js +282 -0
- package/dist/ai/{tools/data-query → skills/data-query/tools}/dataSourceCounting.js +12 -4
- package/dist/ai/skills/data-query/tools/dataSourceQuery.d.ts +10 -0
- package/dist/ai/{tools/data-query → skills/data-query/tools}/dataSourceQuery.js +12 -5
- package/dist/client/271.b3c0013cf976adf0.js +10 -0
- package/dist/client/369.6025f2112454fab1.js +10 -0
- package/dist/client/397.c8c6659cf3f7ac1c.js +10 -0
- package/dist/client/416.197712b8b93033c5.js +10 -0
- package/dist/client/420.0c3e3c9888e0ba31.js +10 -0
- package/dist/client/603.d6022bceb934f5b0.js +10 -0
- package/dist/client/644.b98e4b39058e9c32.js +10 -0
- package/dist/client/936.d5ab7aecb4eb6004.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/167.c72713810e2d0526.js +10 -0
- package/dist/client-v2/426.3cd9f994a3145829.js +10 -0
- package/dist/client-v2/components/DataSourceForm.d.ts +17 -0
- package/dist/client-v2/field-interfaces/index.d.ts +13 -0
- package/dist/client-v2/index.d.ts +12 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/locale.d.ts +11 -0
- package/dist/client-v2/pages/DataSourceCollectionsPage.d.ts +10 -0
- package/dist/client-v2/pages/DataSourcesPage.d.ts +10 -0
- package/dist/client-v2/pages/components/CollectionsPage.d.ts +15 -0
- package/dist/client-v2/pages/components/FieldForm.d.ts +19 -0
- package/dist/client-v2/pages/components/FieldsPage.d.ts +15 -0
- package/dist/client-v2/pages/components/SqlCollectionConfigure.d.ts +62 -0
- package/dist/client-v2/pages/components/ViewCollectionConfigure.d.ts +27 -0
- package/dist/client-v2/pages/components/collectionFieldApi.d.ts +11 -0
- package/dist/client-v2/pages/components/collectionTemplateFieldInterfaces.d.ts +18 -0
- package/dist/client-v2/plugin.d.ts +188 -0
- package/dist/client-v2/runtime.d.ts +12 -0
- package/dist/client-v2/utils/compileLegacyTemplate.d.ts +13 -0
- package/dist/externalVersion.js +17 -13
- package/dist/locale/en-US.json +270 -3
- package/dist/locale/zh-CN.json +270 -3
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/mcp-post-processors.d.ts +24 -0
- package/dist/server/mcp-post-processors.js +158 -0
- package/dist/server/models/data-source.js +3 -13
- package/dist/server/plugin.js +2 -0
- package/dist/server/resourcers/data-sources-collections-fields.d.ts +1 -0
- package/dist/server/resourcers/data-sources-collections-fields.js +9 -0
- package/dist/server/services/external-field-apply.d.ts +23 -0
- package/dist/server/services/external-field-apply.js +208 -0
- package/dist/server/utils.js +6 -1
- package/dist/swagger/index.d.ts +326 -0
- package/dist/swagger/index.js +385 -0
- package/package.json +5 -2
- package/LICENSE.txt +0 -172
- package/dist/client/1a8cce8035a89dd9.js +0 -10
- package/dist/client/276bcf3de74bebd1.js +0 -10
- package/dist/client/2f7a418e7935984d.js +0 -10
- package/dist/client/689d3bec33ad2ec3.js +0 -10
- package/dist/client/d33eb40009bd7ec6.js +0 -10
- package/dist/client/dbf5ddf434ab29c0.js +0 -10
- package/dist/client/f528b165e77e3608.js +0 -10
- package/dist/client/fdae18574fda07af.js +0 -10
- /package/dist/ai/{tools → ai-employees/orin/skills/data-modeling/tools}/defineCollections.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/orin/skills/data-modeling/tools}/intentRouter.d.ts +0 -0
- /package/dist/ai/{tools/data-query → common}/common.d.ts +0 -0
- /package/dist/ai/{tools → skills/data-metadata/tools}/getCollectionMetadata.d.ts +0 -0
- /package/dist/ai/{tools → skills/data-metadata/tools}/getCollectionNames.d.ts +0 -0
- /package/dist/ai/{tools → skills/data-metadata/tools}/getDataSources.d.ts +0 -0
- /package/dist/ai/{tools → skills/data-metadata/tools}/searchFieldMetadata.d.ts +0 -0
- /package/dist/ai/{tools/data-query/dataSourceCounting.d.ts → skills/data-query/tools/dataQuery.d.ts} +0 -0
- /package/dist/ai/{tools/data-query/dataSourceQuery.d.ts → skills/data-query/tools/dataSourceCounting.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"zod","version":"4.3.5","type":"module","license":"MIT","author":"Colin McDonnell <zod@colinhacks.com>","description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"files":["src","**/*.js","**/*.mjs","**/*.cjs","**/*.d.ts","**/*.d.mts","**/*.d.cts","**/package.json"],"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"_lastModified":"2026-
|
|
1
|
+
{"name":"zod","version":"4.3.5","type":"module","license":"MIT","author":"Colin McDonnell <zod@colinhacks.com>","description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"files":["src","**/*.js","**/*.mjs","**/*.cjs","**/*.d.ts","**/*.d.mts","**/*.d.cts","**/package.json"],"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"_lastModified":"2026-05-29T12:50:07.759Z"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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 type { McpToolsManager } from '@nocobase/ai';
|
|
10
|
+
export declare function simplifyDataSourceListResult(result: any): {
|
|
11
|
+
data: any;
|
|
12
|
+
meta: any;
|
|
13
|
+
};
|
|
14
|
+
export declare function simplifyDataSourceCollectionsListResult(result: any): {
|
|
15
|
+
data: any;
|
|
16
|
+
meta: any;
|
|
17
|
+
};
|
|
18
|
+
export declare function simplifyDataSourceFieldsListResult(result: any, options?: {
|
|
19
|
+
args?: Record<string, any>;
|
|
20
|
+
}): {
|
|
21
|
+
data: any;
|
|
22
|
+
meta: any;
|
|
23
|
+
};
|
|
24
|
+
export declare function registerDataSourceManagerMcpPostProcessors(manager: McpToolsManager): void;
|
|
@@ -0,0 +1,158 @@
|
|
|
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var mcp_post_processors_exports = {};
|
|
28
|
+
__export(mcp_post_processors_exports, {
|
|
29
|
+
registerDataSourceManagerMcpPostProcessors: () => registerDataSourceManagerMcpPostProcessors,
|
|
30
|
+
simplifyDataSourceCollectionsListResult: () => simplifyDataSourceCollectionsListResult,
|
|
31
|
+
simplifyDataSourceFieldsListResult: () => simplifyDataSourceFieldsListResult,
|
|
32
|
+
simplifyDataSourceListResult: () => simplifyDataSourceListResult
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(mcp_post_processors_exports);
|
|
35
|
+
function toArray(value) {
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(value == null ? void 0 : value.data)) {
|
|
40
|
+
return value.data;
|
|
41
|
+
}
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
function parseAssociatedIndex(value) {
|
|
45
|
+
if (typeof value !== "string") {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
const separatorIndex = value.indexOf(".");
|
|
49
|
+
if (separatorIndex === -1) {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
dataSourceKey: value.slice(0, separatorIndex),
|
|
54
|
+
collectionName: value.slice(separatorIndex + 1)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function pickDataSourceSummary(item) {
|
|
58
|
+
const summary = {
|
|
59
|
+
displayName: item == null ? void 0 : item.displayName,
|
|
60
|
+
key: item == null ? void 0 : item.key,
|
|
61
|
+
type: item == null ? void 0 : item.type,
|
|
62
|
+
status: item == null ? void 0 : item.status
|
|
63
|
+
};
|
|
64
|
+
if (Array.isArray(item == null ? void 0 : item.collections)) {
|
|
65
|
+
summary.collections = item.collections.map((collection) => {
|
|
66
|
+
const nextCollection = pickCollectionSummary({
|
|
67
|
+
...collection,
|
|
68
|
+
dataSourceKey: (collection == null ? void 0 : collection.dataSourceKey) ?? (item == null ? void 0 : item.key)
|
|
69
|
+
});
|
|
70
|
+
if (Array.isArray(collection == null ? void 0 : collection.fields)) {
|
|
71
|
+
nextCollection.fields = collection.fields.map(
|
|
72
|
+
(field) => pickRemoteFieldSummary(field, {
|
|
73
|
+
dataSourceKey: (collection == null ? void 0 : collection.dataSourceKey) ?? (item == null ? void 0 : item.key),
|
|
74
|
+
collectionName: collection == null ? void 0 : collection.name
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return nextCollection;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return summary;
|
|
82
|
+
}
|
|
83
|
+
function pickCollectionSummary(item) {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
return {
|
|
86
|
+
name: item == null ? void 0 : item.name,
|
|
87
|
+
title: (item == null ? void 0 : item.title) ?? ((_a = item == null ? void 0 : item.options) == null ? void 0 : _a.title) ?? (item == null ? void 0 : item.displayName),
|
|
88
|
+
description: (item == null ? void 0 : item.description) ?? ((_b = item == null ? void 0 : item.options) == null ? void 0 : _b.description),
|
|
89
|
+
dataSourceKey: item == null ? void 0 : item.dataSourceKey
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function pickFieldSummary(item) {
|
|
93
|
+
var _a;
|
|
94
|
+
return {
|
|
95
|
+
name: item == null ? void 0 : item.name,
|
|
96
|
+
type: item == null ? void 0 : item.type,
|
|
97
|
+
title: (_a = item == null ? void 0 : item.uiSchema) == null ? void 0 : _a.title,
|
|
98
|
+
description: item == null ? void 0 : item.description,
|
|
99
|
+
dataSourceKey: item == null ? void 0 : item.dataSourceKey,
|
|
100
|
+
collectionName: item == null ? void 0 : item.collectionName
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function pickRemoteFieldSummary(item, defaults) {
|
|
104
|
+
var _a;
|
|
105
|
+
return {
|
|
106
|
+
name: item == null ? void 0 : item.name,
|
|
107
|
+
type: item == null ? void 0 : item.type,
|
|
108
|
+
title: (_a = item == null ? void 0 : item.uiSchema) == null ? void 0 : _a.title,
|
|
109
|
+
description: item == null ? void 0 : item.description,
|
|
110
|
+
dataSourceKey: item == null ? void 0 : item.dataSourceKey,
|
|
111
|
+
collectionName: item == null ? void 0 : item.collectionName,
|
|
112
|
+
...defaults
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function simplifyDataSourceListResult(result) {
|
|
116
|
+
const items = toArray(result);
|
|
117
|
+
return {
|
|
118
|
+
data: items.map((item) => pickDataSourceSummary(item)),
|
|
119
|
+
meta: result == null ? void 0 : result.meta
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function simplifyDataSourceCollectionsListResult(result) {
|
|
123
|
+
const items = toArray(result);
|
|
124
|
+
return {
|
|
125
|
+
data: items.map((item) => pickCollectionSummary(item)),
|
|
126
|
+
meta: result == null ? void 0 : result.meta
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function simplifyDataSourceFieldsListResult(result, options) {
|
|
130
|
+
var _a;
|
|
131
|
+
const items = toArray(result);
|
|
132
|
+
const defaults = parseAssociatedIndex((_a = options == null ? void 0 : options.args) == null ? void 0 : _a.associatedIndex);
|
|
133
|
+
return {
|
|
134
|
+
data: items.map(
|
|
135
|
+
(item) => (item == null ? void 0 : item.dataSourceKey) || (item == null ? void 0 : item.collectionName) ? pickFieldSummary(item) : pickRemoteFieldSummary(item, defaults)
|
|
136
|
+
),
|
|
137
|
+
meta: result == null ? void 0 : result.meta
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function registerDataSourceManagerMcpPostProcessors(manager) {
|
|
141
|
+
manager.registerToolResultPostProcessor("dataSources", "list", simplifyDataSourceListResult);
|
|
142
|
+
manager.registerToolResultPostProcessor("dataSources", "listEnabled", simplifyDataSourceListResult);
|
|
143
|
+
manager.registerToolResultPostProcessor("dataSources.collections", "list", simplifyDataSourceCollectionsListResult);
|
|
144
|
+
manager.registerToolResultPostProcessor(
|
|
145
|
+
"dataSourcesCollections.fields",
|
|
146
|
+
"list",
|
|
147
|
+
(result, context) => simplifyDataSourceFieldsListResult(result, {
|
|
148
|
+
args: context == null ? void 0 : context.args
|
|
149
|
+
})
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
153
|
+
0 && (module.exports = {
|
|
154
|
+
registerDataSourceManagerMcpPostProcessors,
|
|
155
|
+
simplifyDataSourceCollectionsListResult,
|
|
156
|
+
simplifyDataSourceFieldsListResult,
|
|
157
|
+
simplifyDataSourceListResult
|
|
158
|
+
});
|
|
@@ -7,11 +7,9 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var __create = Object.create;
|
|
11
10
|
var __defProp = Object.defineProperty;
|
|
12
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
14
|
var __export = (target, all) => {
|
|
17
15
|
for (var name in all)
|
|
@@ -25,14 +23,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
25
23
|
}
|
|
26
24
|
return to;
|
|
27
25
|
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
27
|
var data_source_exports = {};
|
|
38
28
|
__export(data_source_exports, {
|
|
@@ -41,7 +31,7 @@ __export(data_source_exports, {
|
|
|
41
31
|
module.exports = __toCommonJS(data_source_exports);
|
|
42
32
|
var import_database = require("@nocobase/database");
|
|
43
33
|
var import_plugin_acl = require("@nocobase/plugin-acl");
|
|
44
|
-
var
|
|
34
|
+
var import_utils = require("@nocobase/utils");
|
|
45
35
|
const availableActions = {
|
|
46
36
|
create: {
|
|
47
37
|
displayName: '{{t("Add new")}}',
|
|
@@ -62,7 +52,7 @@ const availableActions = {
|
|
|
62
52
|
view: {
|
|
63
53
|
displayName: '{{t("View")}}',
|
|
64
54
|
type: "old-data",
|
|
65
|
-
aliases: ["get", "list"],
|
|
55
|
+
aliases: ["get", "list", "query"],
|
|
66
56
|
allowConfigureFields: true
|
|
67
57
|
},
|
|
68
58
|
update: {
|
|
@@ -117,7 +107,7 @@ class DataSourceModel extends import_database.Model {
|
|
|
117
107
|
logger: app.logger.child({ dataSourceKey }),
|
|
118
108
|
sqlLogger: app.sqlLogger.child({ dataSourceKey }),
|
|
119
109
|
cache: app.cache,
|
|
120
|
-
storagePath:
|
|
110
|
+
storagePath: (0, import_utils.storagePathJoin)("cache", "apps", app.name),
|
|
121
111
|
databaseInstance
|
|
122
112
|
});
|
|
123
113
|
dataSource.on("loadingProgress", (progress) => {
|
package/dist/server/plugin.js
CHANGED
|
@@ -57,6 +57,7 @@ var import_data_source = require("./models/data-source");
|
|
|
57
57
|
var import_data_sources_roles_model = require("./models/data-sources-roles-model");
|
|
58
58
|
var import_acl = require("@nocobase/acl");
|
|
59
59
|
var import_load_tables = require("./middlewares/load-tables");
|
|
60
|
+
var import_mcp_post_processors = require("./mcp-post-processors");
|
|
60
61
|
class PluginDataSourceManagerServer extends import_server.Plugin {
|
|
61
62
|
dataSourceErrors = {};
|
|
62
63
|
dataSourceStatus = {};
|
|
@@ -313,6 +314,7 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
|
|
|
313
314
|
await next();
|
|
314
315
|
});
|
|
315
316
|
this.app.resourceManager.use(import_load_tables.loadDataSourceTablesIntoCollections);
|
|
317
|
+
(0, import_mcp_post_processors.registerDataSourceManagerMcpPostProcessors)(this.ai.mcpToolsManager);
|
|
316
318
|
this.app.use(async function handleAppendDataSourceCollection(ctx, next) {
|
|
317
319
|
await next();
|
|
318
320
|
if (!ctx.action) {
|
|
@@ -13,6 +13,7 @@ declare const _default: {
|
|
|
13
13
|
get(ctx: any, next: any): Promise<void>;
|
|
14
14
|
update(ctx: any, next: any): Promise<void>;
|
|
15
15
|
create(ctx: any, next: any): Promise<void>;
|
|
16
|
+
apply(ctx: any, next: any): Promise<void>;
|
|
16
17
|
destroy(ctx: any, next: any): Promise<void>;
|
|
17
18
|
};
|
|
18
19
|
};
|
|
@@ -40,6 +40,7 @@ __export(data_sources_collections_fields_exports, {
|
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(data_sources_collections_fields_exports);
|
|
42
42
|
var import_lodash = __toESM(require("lodash"));
|
|
43
|
+
var import_external_field_apply = require("../services/external-field-apply");
|
|
43
44
|
var data_sources_collections_fields_default = {
|
|
44
45
|
name: "dataSourcesCollections.fields",
|
|
45
46
|
actions: {
|
|
@@ -130,6 +131,14 @@ var data_sources_collections_fields_default = {
|
|
|
130
131
|
ctx.body = fieldRecord.toJSON();
|
|
131
132
|
await next();
|
|
132
133
|
},
|
|
134
|
+
async apply(ctx, next) {
|
|
135
|
+
const rawValues = ctx.action.params.values || ctx.request.body || {};
|
|
136
|
+
const defaults = (0, import_external_field_apply.parseCollectionNameWithDataSourceKey)(ctx.action.params.associatedIndex);
|
|
137
|
+
ctx.body = {
|
|
138
|
+
data: await (0, import_external_field_apply.applyExternalFieldDefinition)(ctx, rawValues, defaults)
|
|
139
|
+
};
|
|
140
|
+
await next();
|
|
141
|
+
},
|
|
133
142
|
async destroy(ctx, next) {
|
|
134
143
|
const { associatedIndex: collectionNameWithDataSourceKey, filterByTk: name } = ctx.action.params;
|
|
135
144
|
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
@@ -0,0 +1,23 @@
|
|
|
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 parseCollectionNameWithDataSourceKey(value?: string): {
|
|
10
|
+
dataSourceKey?: undefined;
|
|
11
|
+
collectionName?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
dataSourceKey: string;
|
|
14
|
+
collectionName: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function normalizeExternalFieldInput(rawValues: any, defaults: {
|
|
17
|
+
dataSourceKey?: string;
|
|
18
|
+
collectionName?: string;
|
|
19
|
+
}): any;
|
|
20
|
+
export declare function applyExternalFieldDefinition(ctx: any, rawValues: any, defaults?: {
|
|
21
|
+
dataSourceKey?: string;
|
|
22
|
+
collectionName?: string;
|
|
23
|
+
}): Promise<any>;
|
|
@@ -0,0 +1,208 @@
|
|
|
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 __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var external_field_apply_exports = {};
|
|
38
|
+
__export(external_field_apply_exports, {
|
|
39
|
+
applyExternalFieldDefinition: () => applyExternalFieldDefinition,
|
|
40
|
+
normalizeExternalFieldInput: () => normalizeExternalFieldInput,
|
|
41
|
+
parseCollectionNameWithDataSourceKey: () => parseCollectionNameWithDataSourceKey
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(external_field_apply_exports);
|
|
44
|
+
var import_lodash = __toESM(require("lodash"));
|
|
45
|
+
var import_sequelize = require("sequelize");
|
|
46
|
+
const RELATION_INTERFACE_TYPE_MAP = {
|
|
47
|
+
m2o: "belongsTo",
|
|
48
|
+
obo: "belongsTo",
|
|
49
|
+
o2m: "hasMany",
|
|
50
|
+
oho: "hasOne",
|
|
51
|
+
m2m: "belongsToMany"
|
|
52
|
+
};
|
|
53
|
+
const RELATION_TYPES = /* @__PURE__ */ new Set(["belongsTo", "hasMany", "hasOne", "belongsToMany"]);
|
|
54
|
+
function parseCollectionNameWithDataSourceKey(value) {
|
|
55
|
+
if (!value) {
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
const separatorIndex = value.indexOf(".");
|
|
59
|
+
if (separatorIndex === -1) {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
dataSourceKey: value.slice(0, separatorIndex),
|
|
64
|
+
collectionName: value.slice(separatorIndex + 1)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function mergeSettings(input = {}) {
|
|
68
|
+
const { settings, ...rest } = input;
|
|
69
|
+
return {
|
|
70
|
+
...settings || {},
|
|
71
|
+
...rest
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function buildRelationKeyName(name, key = "id") {
|
|
75
|
+
return import_sequelize.Utils.camelize([import_sequelize.Utils.singularize(name || ""), key].join("_"));
|
|
76
|
+
}
|
|
77
|
+
function buildThroughName(source, target) {
|
|
78
|
+
return import_sequelize.Utils.camelize(
|
|
79
|
+
[source, target].filter(Boolean).map((name) => String(name).toLowerCase()).sort().join("_")
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
function normalizeExternalFieldInput(rawValues, defaults) {
|
|
83
|
+
var _a;
|
|
84
|
+
const values = mergeSettings(rawValues);
|
|
85
|
+
const dataSourceKey = values.dataSourceKey || defaults.dataSourceKey;
|
|
86
|
+
const collectionName = values.collectionName || defaults.collectionName;
|
|
87
|
+
if (!dataSourceKey) {
|
|
88
|
+
throw new Error("dataSourcesCollections.fields:apply requires dataSourceKey");
|
|
89
|
+
}
|
|
90
|
+
if (!collectionName) {
|
|
91
|
+
throw new Error("dataSourcesCollections.fields:apply requires collectionName");
|
|
92
|
+
}
|
|
93
|
+
if (!values.name) {
|
|
94
|
+
throw new Error("dataSourcesCollections.fields:apply requires name");
|
|
95
|
+
}
|
|
96
|
+
const interfaceType = values.interface;
|
|
97
|
+
const type = values.type || RELATION_INTERFACE_TYPE_MAP[interfaceType];
|
|
98
|
+
const normalized = {
|
|
99
|
+
...values,
|
|
100
|
+
dataSourceKey,
|
|
101
|
+
collectionName,
|
|
102
|
+
type
|
|
103
|
+
};
|
|
104
|
+
if (RELATION_TYPES.has(normalized.type)) {
|
|
105
|
+
if (!normalized.target) {
|
|
106
|
+
throw new Error(`Relation field ${normalized.name} requires target`);
|
|
107
|
+
}
|
|
108
|
+
normalized.interface = normalized.interface || {
|
|
109
|
+
belongsTo: "m2o",
|
|
110
|
+
hasMany: "o2m",
|
|
111
|
+
hasOne: "oho",
|
|
112
|
+
belongsToMany: "m2m"
|
|
113
|
+
}[normalized.type];
|
|
114
|
+
normalized.sourceKey = normalized.sourceKey || "id";
|
|
115
|
+
normalized.targetKey = normalized.targetKey || "id";
|
|
116
|
+
if (normalized.type === "belongsTo") {
|
|
117
|
+
normalized.foreignKey = normalized.foreignKey || buildRelationKeyName(normalized.name, normalized.targetKey);
|
|
118
|
+
}
|
|
119
|
+
if (normalized.type === "hasMany" || normalized.type === "hasOne") {
|
|
120
|
+
normalized.foreignKey = normalized.foreignKey || buildRelationKeyName(collectionName, normalized.sourceKey);
|
|
121
|
+
}
|
|
122
|
+
if (normalized.type === "belongsToMany") {
|
|
123
|
+
normalized.foreignKey = normalized.foreignKey || buildRelationKeyName(collectionName, normalized.sourceKey);
|
|
124
|
+
normalized.otherKey = normalized.otherKey || buildRelationKeyName(normalized.target, normalized.targetKey);
|
|
125
|
+
normalized.through = normalized.through || buildThroughName(collectionName, normalized.target);
|
|
126
|
+
}
|
|
127
|
+
normalized.uiSchema = import_lodash.default.merge(
|
|
128
|
+
{
|
|
129
|
+
type: normalized.type === "belongsTo" || normalized.type === "hasOne" ? "object" : "array",
|
|
130
|
+
title: normalized.title || ((_a = normalized.uiSchema) == null ? void 0 : _a.title) || normalized.name,
|
|
131
|
+
"x-component": "AssociationField",
|
|
132
|
+
"x-component-props": {
|
|
133
|
+
multiple: normalized.type === "hasMany" || normalized.type === "belongsToMany",
|
|
134
|
+
fieldNames: {
|
|
135
|
+
value: normalized.targetKey,
|
|
136
|
+
label: normalized.targetTitleField || normalized.titleField || normalized.targetKey
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
normalized.uiSchema || {}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
delete normalized.settings;
|
|
144
|
+
delete normalized.title;
|
|
145
|
+
delete normalized.titleField;
|
|
146
|
+
delete normalized.targetTitleField;
|
|
147
|
+
return normalized;
|
|
148
|
+
}
|
|
149
|
+
function validateExternalRelationField(values) {
|
|
150
|
+
if (!RELATION_TYPES.has(values.type)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const validatePresent = (name) => {
|
|
154
|
+
if (!values[name]) {
|
|
155
|
+
throw new Error(`"${name}" is required`);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const validatePresents = (names) => names.forEach((name) => validatePresent(name));
|
|
159
|
+
if (values.type === "belongsTo") {
|
|
160
|
+
validatePresents(["foreignKey", "targetKey", "target"]);
|
|
161
|
+
}
|
|
162
|
+
if (values.type === "hasMany" || values.type === "hasOne") {
|
|
163
|
+
validatePresents(["foreignKey", "sourceKey", "target"]);
|
|
164
|
+
}
|
|
165
|
+
if (values.type === "belongsToMany") {
|
|
166
|
+
validatePresents(["foreignKey", "otherKey", "sourceKey", "targetKey", "through", "target"]);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function getFieldOptions(ctx, values) {
|
|
170
|
+
var _a;
|
|
171
|
+
return (_a = ctx.app.dataSourceManager.dataSources.get(values.dataSourceKey).collectionManager.getCollection(values.collectionName).getField(values.name)) == null ? void 0 : _a.options;
|
|
172
|
+
}
|
|
173
|
+
async function applyExternalFieldDefinition(ctx, rawValues, defaults = {}) {
|
|
174
|
+
const values = normalizeExternalFieldInput(rawValues, defaults);
|
|
175
|
+
validateExternalRelationField(values);
|
|
176
|
+
const dataSource = ctx.app.dataSourceManager.dataSources.get(values.dataSourceKey);
|
|
177
|
+
if (!dataSource) {
|
|
178
|
+
throw new Error(`dataSource ${values.dataSourceKey} not found`);
|
|
179
|
+
}
|
|
180
|
+
const collection = dataSource.collectionManager.getCollection(values.collectionName);
|
|
181
|
+
if (!collection) {
|
|
182
|
+
throw new Error(`collection ${values.collectionName} not found in dataSource ${values.dataSourceKey}`);
|
|
183
|
+
}
|
|
184
|
+
const repository = ctx.app.db.getRepository("dataSourcesFields");
|
|
185
|
+
const filter = {
|
|
186
|
+
name: values.name,
|
|
187
|
+
collectionName: values.collectionName,
|
|
188
|
+
dataSourceKey: values.dataSourceKey
|
|
189
|
+
};
|
|
190
|
+
const existing = await repository.findOne({ filter });
|
|
191
|
+
if (existing) {
|
|
192
|
+
await repository.update({
|
|
193
|
+
filter,
|
|
194
|
+
values
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
await repository.create({
|
|
198
|
+
values
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return getFieldOptions(ctx, values);
|
|
202
|
+
}
|
|
203
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
204
|
+
0 && (module.exports = {
|
|
205
|
+
applyExternalFieldDefinition,
|
|
206
|
+
normalizeExternalFieldInput,
|
|
207
|
+
parseCollectionNameWithDataSourceKey
|
|
208
|
+
});
|
package/dist/server/utils.js
CHANGED
|
@@ -30,13 +30,18 @@ __export(utils_exports, {
|
|
|
30
30
|
mergeOptions: () => mergeOptions
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(utils_exports);
|
|
33
|
+
const nullableOverrideConfig = {
|
|
34
|
+
sort: ["scopeKey"]
|
|
35
|
+
};
|
|
33
36
|
function mergeOptions(fieldOptions, modelOptions) {
|
|
34
37
|
const newOptions = {
|
|
35
38
|
...fieldOptions,
|
|
36
39
|
...modelOptions
|
|
37
40
|
};
|
|
41
|
+
const fieldType = modelOptions.type || fieldOptions.type;
|
|
42
|
+
const nullableOverrideKeys = nullableOverrideConfig[fieldType] || [];
|
|
38
43
|
for (const key of Object.keys(modelOptions)) {
|
|
39
|
-
if (modelOptions[key] === null && fieldOptions[key]) {
|
|
44
|
+
if (modelOptions[key] === null && fieldOptions[key] && !nullableOverrideKeys.includes(key)) {
|
|
40
45
|
newOptions[key] = fieldOptions[key];
|
|
41
46
|
}
|
|
42
47
|
}
|