@nocobase/plugin-data-source-manager 2.1.0-beta.32 → 2.1.0-beta.33

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.
@@ -8,27 +8,27 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.32",
11
+ "@nocobase/client": "2.1.0-beta.33",
12
12
  "react": "18.2.0",
13
- "@nocobase/plugin-acl": "2.1.0-beta.32",
14
- "@nocobase/utils": "2.1.0-beta.32",
15
- "@nocobase/ai": "2.1.0-beta.32",
16
- "@nocobase/server": "2.1.0-beta.32",
17
- "@nocobase/data-source-manager": "2.1.0-beta.32",
13
+ "@nocobase/plugin-acl": "2.1.0-beta.33",
14
+ "@nocobase/utils": "2.1.0-beta.33",
15
+ "@nocobase/ai": "2.1.0-beta.33",
16
+ "@nocobase/server": "2.1.0-beta.33",
17
+ "@nocobase/data-source-manager": "2.1.0-beta.33",
18
18
  "lodash": "4.18.1",
19
- "@nocobase/acl": "2.1.0-beta.32",
20
- "@nocobase/database": "2.1.0-beta.32",
19
+ "@nocobase/acl": "2.1.0-beta.33",
20
+ "@nocobase/database": "2.1.0-beta.33",
21
21
  "@ant-design/icons": "5.6.1",
22
22
  "antd": "5.24.2",
23
23
  "react-router-dom": "6.30.1",
24
- "@nocobase/flow-engine": "2.1.0-beta.32",
24
+ "@nocobase/flow-engine": "2.1.0-beta.33",
25
25
  "@formily/shared": "2.3.7",
26
26
  "@formily/react": "2.3.7",
27
27
  "react-i18next": "11.18.6",
28
28
  "@emotion/css": "11.13.0",
29
- "@nocobase/actions": "2.1.0-beta.32",
29
+ "@nocobase/actions": "2.1.0-beta.33",
30
30
  "sequelize": "6.35.2",
31
- "@nocobase/test": "2.1.0-beta.32",
31
+ "@nocobase/test": "2.1.0-beta.33",
32
32
  "@formily/antd-v5": "1.2.3",
33
33
  "@formily/core": "2.3.7",
34
34
  "@formily/reactive": "2.3.7",
@@ -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-05-13T05:25:04.478Z"}
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-15T15:54:13.068Z"}
@@ -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
+ });
@@ -52,6 +52,139 @@ declare const _default: {
52
52
  };
53
53
  };
54
54
  };
55
+ '/dataSources/{associatedIndex}/collections:list': {
56
+ get: {
57
+ tags: string[];
58
+ summary: string;
59
+ description: string;
60
+ parameters: ({
61
+ name: string;
62
+ in: string;
63
+ required: boolean;
64
+ description: string;
65
+ schema: {
66
+ type: string;
67
+ additionalProperties?: undefined;
68
+ };
69
+ } | {
70
+ name: string;
71
+ in: string;
72
+ required: boolean;
73
+ description: string;
74
+ schema: {
75
+ type: string;
76
+ additionalProperties: boolean;
77
+ };
78
+ } | {
79
+ name: string;
80
+ in: string;
81
+ required: boolean;
82
+ schema: {
83
+ type: string;
84
+ additionalProperties?: undefined;
85
+ };
86
+ description?: undefined;
87
+ })[];
88
+ responses: {
89
+ 200: {
90
+ description: string;
91
+ content: {
92
+ 'application/json': {
93
+ schema: {
94
+ type: string;
95
+ properties: {
96
+ data: {
97
+ type: string;
98
+ items: {
99
+ $ref: string;
100
+ };
101
+ };
102
+ meta: {
103
+ type: string;
104
+ additionalProperties: boolean;
105
+ };
106
+ };
107
+ };
108
+ };
109
+ };
110
+ };
111
+ };
112
+ };
113
+ };
114
+ '/dataSourcesCollections/{associatedIndex}/fields:list': {
115
+ get: {
116
+ tags: string[];
117
+ summary: string;
118
+ description: string;
119
+ parameters: {
120
+ name: string;
121
+ in: string;
122
+ required: boolean;
123
+ description: string;
124
+ schema: {
125
+ type: string;
126
+ };
127
+ }[];
128
+ responses: {
129
+ 200: {
130
+ description: string;
131
+ content: {
132
+ 'application/json': {
133
+ schema: {
134
+ type: string;
135
+ items: {
136
+ type: string;
137
+ additionalProperties: boolean;
138
+ };
139
+ };
140
+ };
141
+ };
142
+ };
143
+ };
144
+ };
145
+ };
146
+ '/dataSourcesCollections/{associatedIndex}/fields:apply': {
147
+ post: {
148
+ tags: string[];
149
+ summary: string;
150
+ description: string;
151
+ parameters: {
152
+ name: string;
153
+ in: string;
154
+ required: boolean;
155
+ description: string;
156
+ schema: {
157
+ type: string;
158
+ };
159
+ }[];
160
+ requestBody: {
161
+ content: {
162
+ 'application/json': {
163
+ schema: {
164
+ $ref: string;
165
+ };
166
+ };
167
+ };
168
+ };
169
+ responses: {
170
+ 200: {
171
+ description: string;
172
+ content: {
173
+ 'application/json': {
174
+ schema: {
175
+ type: string;
176
+ properties: {
177
+ data: {
178
+ $ref: string;
179
+ };
180
+ };
181
+ };
182
+ };
183
+ };
184
+ };
185
+ };
186
+ };
187
+ };
55
188
  };
56
189
  components: {
57
190
  schemas: {
@@ -116,6 +249,77 @@ declare const _default: {
116
249
  };
117
250
  additionalProperties: boolean;
118
251
  };
252
+ DataSourceFieldApplyInput: {
253
+ type: string;
254
+ required: string[];
255
+ properties: {
256
+ dataSourceKey: {
257
+ type: string;
258
+ description: string;
259
+ };
260
+ collectionName: {
261
+ type: string;
262
+ description: string;
263
+ };
264
+ name: {
265
+ type: string;
266
+ };
267
+ title: {
268
+ type: string;
269
+ };
270
+ interface: {
271
+ type: string;
272
+ description: string;
273
+ };
274
+ type: {
275
+ type: string;
276
+ description: string;
277
+ };
278
+ target: {
279
+ type: string;
280
+ };
281
+ foreignKey: {
282
+ type: string;
283
+ };
284
+ sourceKey: {
285
+ type: string;
286
+ };
287
+ targetKey: {
288
+ type: string;
289
+ };
290
+ through: {
291
+ type: string;
292
+ };
293
+ otherKey: {
294
+ type: string;
295
+ };
296
+ targetTitleField: {
297
+ type: string;
298
+ };
299
+ titleField: {
300
+ type: string;
301
+ };
302
+ uiSchema: {
303
+ type: string;
304
+ additionalProperties: boolean;
305
+ };
306
+ settings: {
307
+ type: string;
308
+ additionalProperties: boolean;
309
+ };
310
+ };
311
+ additionalProperties: boolean;
312
+ };
313
+ DataSourceFieldApplyResult: {
314
+ type: string;
315
+ properties: {
316
+ data: {
317
+ type: string;
318
+ additionalProperties: boolean;
319
+ };
320
+ };
321
+ additionalProperties: boolean;
322
+ };
119
323
  };
120
324
  };
121
325
  };
@@ -76,6 +76,174 @@ var swagger_default = {
76
76
  }
77
77
  }
78
78
  }
79
+ },
80
+ "/dataSources/{associatedIndex}/collections:list": {
81
+ get: {
82
+ tags: ["dataSources.collections"],
83
+ summary: "List external data source collections",
84
+ description: [
85
+ "List loaded collections in one external data source, including field metadata.",
86
+ "",
87
+ "Use this endpoint to discover external table names before applying relation field metadata."
88
+ ].join("\n"),
89
+ parameters: [
90
+ {
91
+ name: "associatedIndex",
92
+ in: "path",
93
+ required: true,
94
+ description: "External data source key, for example `external`.",
95
+ schema: {
96
+ type: "string"
97
+ }
98
+ },
99
+ {
100
+ name: "filter",
101
+ in: "query",
102
+ required: false,
103
+ description: "Filter object matched against collection options.",
104
+ schema: {
105
+ type: "object",
106
+ additionalProperties: true
107
+ }
108
+ },
109
+ {
110
+ name: "page",
111
+ in: "query",
112
+ required: false,
113
+ schema: {
114
+ type: "integer"
115
+ }
116
+ },
117
+ {
118
+ name: "pageSize",
119
+ in: "query",
120
+ required: false,
121
+ schema: {
122
+ type: "integer"
123
+ }
124
+ },
125
+ {
126
+ name: "paginate",
127
+ in: "query",
128
+ required: false,
129
+ schema: {
130
+ type: "boolean"
131
+ }
132
+ }
133
+ ],
134
+ responses: {
135
+ 200: {
136
+ description: "OK",
137
+ content: {
138
+ "application/json": {
139
+ schema: {
140
+ type: "object",
141
+ properties: {
142
+ data: {
143
+ type: "array",
144
+ items: {
145
+ $ref: "#/components/schemas/DataSourceCollectionInfo"
146
+ }
147
+ },
148
+ meta: {
149
+ type: "object",
150
+ additionalProperties: true
151
+ }
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
159
+ },
160
+ "/dataSourcesCollections/{associatedIndex}/fields:list": {
161
+ get: {
162
+ tags: ["dataSourcesCollections.fields"],
163
+ summary: "List external data source collection fields",
164
+ description: [
165
+ "List loaded field metadata for one external data source collection.",
166
+ "",
167
+ "The associatedIndex path parameter is `<dataSourceKey>.<collectionName>`."
168
+ ].join("\n"),
169
+ parameters: [
170
+ {
171
+ name: "associatedIndex",
172
+ in: "path",
173
+ required: true,
174
+ description: "External data source collection locator, for example `external.orders`.",
175
+ schema: {
176
+ type: "string"
177
+ }
178
+ }
179
+ ],
180
+ responses: {
181
+ 200: {
182
+ description: "OK",
183
+ content: {
184
+ "application/json": {
185
+ schema: {
186
+ type: "array",
187
+ items: {
188
+ type: "object",
189
+ additionalProperties: true
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
195
+ }
196
+ }
197
+ },
198
+ "/dataSourcesCollections/{associatedIndex}/fields:apply": {
199
+ post: {
200
+ tags: ["dataSourcesCollections.fields"],
201
+ summary: "Create or update an external data source field",
202
+ description: [
203
+ "Upsert one external data source field from a compact request body.",
204
+ "",
205
+ "Use this endpoint for external data source field metadata, including relation fields.",
206
+ "The associatedIndex path parameter is `<dataSourceKey>.<collectionName>`.",
207
+ "",
208
+ "Relation fields may use compact interfaces such as `m2o`, `o2m`, `oho`, and `m2m`.",
209
+ "The server fills readable relation key defaults when explicit keys are omitted."
210
+ ].join("\n"),
211
+ parameters: [
212
+ {
213
+ name: "associatedIndex",
214
+ in: "path",
215
+ required: true,
216
+ description: "External data source collection locator, for example `external.orders`.",
217
+ schema: {
218
+ type: "string"
219
+ }
220
+ }
221
+ ],
222
+ requestBody: {
223
+ content: {
224
+ "application/json": {
225
+ schema: { $ref: "#/components/schemas/DataSourceFieldApplyInput" }
226
+ }
227
+ }
228
+ },
229
+ responses: {
230
+ 200: {
231
+ description: "OK",
232
+ content: {
233
+ "application/json": {
234
+ schema: {
235
+ type: "object",
236
+ properties: {
237
+ data: {
238
+ $ref: "#/components/schemas/DataSourceFieldApplyResult"
239
+ }
240
+ }
241
+ }
242
+ }
243
+ }
244
+ }
245
+ }
246
+ }
79
247
  }
80
248
  },
81
249
  components: {
@@ -140,6 +308,77 @@ var swagger_default = {
140
308
  }
141
309
  },
142
310
  additionalProperties: true
311
+ },
312
+ DataSourceFieldApplyInput: {
313
+ type: "object",
314
+ required: ["name"],
315
+ properties: {
316
+ dataSourceKey: {
317
+ type: "string",
318
+ description: "Optional when the path associatedIndex supplies the data source key."
319
+ },
320
+ collectionName: {
321
+ type: "string",
322
+ description: "Optional when the path associatedIndex supplies the collection name."
323
+ },
324
+ name: {
325
+ type: "string"
326
+ },
327
+ title: {
328
+ type: "string"
329
+ },
330
+ interface: {
331
+ type: "string",
332
+ description: "Compact field interface, for example `input`, `m2o`, `o2m`, `oho`, or `m2m`."
333
+ },
334
+ type: {
335
+ type: "string",
336
+ description: "Raw field type. Relation types include `belongsTo`, `hasMany`, `hasOne`, and `belongsToMany`."
337
+ },
338
+ target: {
339
+ type: "string"
340
+ },
341
+ foreignKey: {
342
+ type: "string"
343
+ },
344
+ sourceKey: {
345
+ type: "string"
346
+ },
347
+ targetKey: {
348
+ type: "string"
349
+ },
350
+ through: {
351
+ type: "string"
352
+ },
353
+ otherKey: {
354
+ type: "string"
355
+ },
356
+ targetTitleField: {
357
+ type: "string"
358
+ },
359
+ titleField: {
360
+ type: "string"
361
+ },
362
+ uiSchema: {
363
+ type: "object",
364
+ additionalProperties: true
365
+ },
366
+ settings: {
367
+ type: "object",
368
+ additionalProperties: true
369
+ }
370
+ },
371
+ additionalProperties: true
372
+ },
373
+ DataSourceFieldApplyResult: {
374
+ type: "object",
375
+ properties: {
376
+ data: {
377
+ type: "object",
378
+ additionalProperties: true
379
+ }
380
+ },
381
+ additionalProperties: true
143
382
  }
144
383
  }
145
384
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-data-source-manager",
3
- "version": "2.1.0-beta.32",
3
+ "version": "2.1.0-beta.33",
4
4
  "main": "dist/server/index.js",
5
5
  "displayName": "Data source manager",
6
6
  "displayName.ru-RU": "Менеджер управления источниками данных",
@@ -20,6 +20,6 @@
20
20
  "keywords": [
21
21
  "Data model tools"
22
22
  ],
23
- "gitHead": "659c5efe992da7118d33c768bbd9e837a2c4716f",
23
+ "gitHead": "4815c394e80a264fa8ed619246280923c47aeb72",
24
24
  "license": "Apache-2.0"
25
25
  }