@nocobase/plugin-api-doc 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 (52) hide show
  1. package/package.json +2 -2
  2. package/dist/client/Document.d.ts +0 -12
  3. package/dist/client/index.d.ts +0 -14
  4. package/dist/client/index.js +0 -160
  5. package/dist/externalVersion.js +0 -22
  6. package/dist/index.d.ts +0 -9
  7. package/dist/index.js +0 -42
  8. package/dist/locale/en-US.json +0 -5
  9. package/dist/locale/index.d.ts +0 -12
  10. package/dist/locale/index.js +0 -53
  11. package/dist/locale/ko_KR.json +0 -5
  12. package/dist/locale/zh-CN.json +0 -5
  13. package/dist/server/index.d.ts +0 -9
  14. package/dist/server/index.js +0 -42
  15. package/dist/server/server.d.ts +0 -17
  16. package/dist/server/server.js +0 -83
  17. package/dist/server/swagger/base-swagger.d.ts +0 -57
  18. package/dist/server/swagger/base-swagger.js +0 -81
  19. package/dist/server/swagger/collections/components/field-type-map.d.ts +0 -30
  20. package/dist/server/swagger/collections/components/field-type-map.js +0 -66
  21. package/dist/server/swagger/collections/components/index.d.ts +0 -32
  22. package/dist/server/swagger/collections/components/index.js +0 -49
  23. package/dist/server/swagger/collections/components/parameters.d.ts +0 -13
  24. package/dist/server/swagger/collections/components/parameters.js +0 -203
  25. package/dist/server/swagger/collections/components/schemas.d.ts +0 -31
  26. package/dist/server/swagger/collections/components/schemas.js +0 -117
  27. package/dist/server/swagger/collections/index.d.ts +0 -39
  28. package/dist/server/swagger/collections/index.js +0 -52
  29. package/dist/server/swagger/collections/paths/associations/index.d.ts +0 -14
  30. package/dist/server/swagger/collections/paths/associations/index.js +0 -69
  31. package/dist/server/swagger/collections/paths/associations/multiple-association.d.ts +0 -14
  32. package/dist/server/swagger/collections/paths/associations/multiple-association.js +0 -134
  33. package/dist/server/swagger/collections/paths/associations/single-association.d.ts +0 -13
  34. package/dist/server/swagger/collections/paths/associations/single-association.js +0 -114
  35. package/dist/server/swagger/collections/paths/collection.d.ts +0 -209
  36. package/dist/server/swagger/collections/paths/collection.js +0 -371
  37. package/dist/server/swagger/collections/paths/index.d.ts +0 -14
  38. package/dist/server/swagger/collections/paths/index.js +0 -74
  39. package/dist/server/swagger/collections/tags/index.d.ts +0 -14
  40. package/dist/server/swagger/collections/tags/index.js +0 -52
  41. package/dist/server/swagger/constants.d.ts +0 -18
  42. package/dist/server/swagger/constants.js +0 -45
  43. package/dist/server/swagger/helpers.d.ts +0 -179
  44. package/dist/server/swagger/helpers.js +0 -143
  45. package/dist/server/swagger/index.d.ts +0 -57
  46. package/dist/server/swagger/index.js +0 -259
  47. package/dist/server/swagger/loader.d.ts +0 -12
  48. package/dist/server/swagger/loader.js +0 -89
  49. package/dist/server/swagger/merge.d.ts +0 -9
  50. package/dist/server/swagger/merge.js +0 -43
  51. package/dist/swagger.d.ts +0 -51
  52. package/dist/swagger.js +0 -73
@@ -1,203 +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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var parameters_exports = {};
28
- __export(parameters_exports, {
29
- default: () => parameters_default
30
- });
31
- module.exports = __toCommonJS(parameters_exports);
32
- var import_field_type_map = require("./field-type-map");
33
- var parameters_default = (collection) => {
34
- const primaryKey = collection.model.primaryKeyAttribute;
35
- const parameters = {};
36
- if (primaryKey) {
37
- const primaryKeyField = collection.fields.get(primaryKey);
38
- if (!primaryKeyField) {
39
- throw new Error(`primaryKeyField not found: ${primaryKey}, ${collection.name}`);
40
- }
41
- Object.assign(parameters, {
42
- collectionIndex: {
43
- required: true,
44
- name: "collectionIndex",
45
- in: "path",
46
- description: "collection index",
47
- schema: (0, import_field_type_map.getTypeByField)(collection.fields.get(primaryKey))
48
- },
49
- filterByTk: {
50
- name: "filterByTk",
51
- in: "query",
52
- description: "filter by TK(default by ID)",
53
- schema: (0, import_field_type_map.getTypeByField)(collection.fields.get(primaryKey))
54
- },
55
- filterByTks: {
56
- name: "filterByTk",
57
- in: "query",
58
- description: "filter by TKs(default by ID), example: `1,2,3`",
59
- schema: {
60
- type: "array",
61
- items: (0, import_field_type_map.getTypeByField)(collection.fields.get(primaryKey))
62
- }
63
- }
64
- });
65
- }
66
- Object.assign(parameters, {
67
- filter: {
68
- name: "filter",
69
- in: "query",
70
- description: "filter items",
71
- content: {
72
- "application/json": {
73
- schema: {
74
- type: "object"
75
- }
76
- }
77
- }
78
- },
79
- sort: {
80
- name: "sort",
81
- in: "query",
82
- description: "sort items by fields, example: `-field1,-field2,field3`",
83
- schema: {
84
- oneOf: [
85
- {
86
- type: "array",
87
- items: {
88
- type: "string"
89
- },
90
- example: ["-id", "createdAt"]
91
- },
92
- {
93
- type: "string",
94
- example: "-id,createdAt"
95
- }
96
- ]
97
- }
98
- },
99
- fields: {
100
- name: "fields",
101
- in: "query",
102
- description: "select fields, example: `field1,field2`",
103
- schema: {
104
- oneOf: [
105
- {
106
- type: "array",
107
- items: {
108
- type: "string"
109
- },
110
- example: ["id", "createdAt"]
111
- },
112
- {
113
- type: "string",
114
- example: "id,createdAt"
115
- }
116
- ]
117
- }
118
- },
119
- except: {
120
- name: "except",
121
- in: "query",
122
- description: "except fields in results, example: `field1,field2`",
123
- schema: {
124
- oneOf: [
125
- {
126
- type: "array",
127
- items: {
128
- type: "string"
129
- },
130
- example: ["id", "createdAt"]
131
- },
132
- {
133
- type: "string",
134
- example: "id,createdAt"
135
- }
136
- ]
137
- }
138
- },
139
- appends: {
140
- name: "appends",
141
- in: "query",
142
- description: "append associations in results, example: `assoc1,assoc2`",
143
- schema: {
144
- oneOf: [
145
- {
146
- type: "array",
147
- items: {
148
- type: "string"
149
- },
150
- example: ["id", "createdAt"]
151
- },
152
- {
153
- type: "string",
154
- example: "id,createdAt"
155
- }
156
- ]
157
- }
158
- },
159
- whitelist: {
160
- name: "whitelist",
161
- in: "query",
162
- description: "whitelist for fields changes, example: `field1,field2`",
163
- schema: {
164
- oneOf: [
165
- {
166
- type: "array",
167
- items: {
168
- type: "string"
169
- },
170
- example: ["id", "createdAt"]
171
- },
172
- {
173
- type: "string",
174
- example: "id,createdAt"
175
- }
176
- ]
177
- }
178
- },
179
- blacklist: {
180
- name: "blacklist",
181
- in: "query",
182
- description: "blacklist for fields changes, example: `field1,field2`",
183
- schema: {
184
- oneOf: [
185
- {
186
- type: "array",
187
- items: {
188
- type: "string"
189
- },
190
- example: ["id", "createdAt"]
191
- },
192
- {
193
- type: "string",
194
- example: "id,createdAt"
195
- }
196
- ]
197
- }
198
- }
199
- });
200
- return {
201
- parameters
202
- };
203
- };
@@ -1,31 +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 { Collection } from '@nocobase/database';
10
- declare const _default: (collection: Collection, options: any) => {
11
- schemas: {
12
- [x: string]: {
13
- type: string;
14
- properties: {};
15
- allOf?: undefined;
16
- } | {
17
- allOf: ({
18
- $ref: string;
19
- type?: undefined;
20
- properties?: undefined;
21
- } | {
22
- type: string;
23
- properties: any;
24
- $ref?: undefined;
25
- })[];
26
- type?: undefined;
27
- properties?: undefined;
28
- };
29
- };
30
- };
31
- export default _default;
@@ -1,117 +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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var schemas_exports = {};
28
- __export(schemas_exports, {
29
- default: () => schemas_default
30
- });
31
- module.exports = __toCommonJS(schemas_exports);
32
- var import_database = require("@nocobase/database");
33
- var import_field_type_map = require("./field-type-map");
34
- var import_associations = require("../paths/associations");
35
- function getCollectionReadOnlyFields(collection) {
36
- var _a;
37
- const readOnlyFields = [];
38
- const primaryKey = collection.model.primaryKeyAttribute;
39
- if (primaryKey) {
40
- const primaryField = collection.fields.get(primaryKey);
41
- if (primaryField && ((_a = primaryField.options) == null ? void 0 : _a.autoIncrement)) {
42
- readOnlyFields.push(primaryKey);
43
- }
44
- }
45
- for (const [fieldName, field] of collection.fields) {
46
- if (field.type == "sort") {
47
- readOnlyFields.push(fieldName);
48
- continue;
49
- }
50
- if (field.type == "context") {
51
- readOnlyFields.push(fieldName);
52
- continue;
53
- }
54
- if ([
55
- "createdAt",
56
- "updatedAt",
57
- "created_at",
58
- "updated_at",
59
- "sort",
60
- "created_by_id",
61
- "createdById",
62
- "updatedById",
63
- "updated_by_id"
64
- ].includes(fieldName)) {
65
- readOnlyFields.push(fieldName);
66
- continue;
67
- }
68
- }
69
- return readOnlyFields;
70
- }
71
- function collectionToSchema(collection) {
72
- return {
73
- [collection.name]: {
74
- type: "object",
75
- properties: Array.from(collection.fields).filter(([key, value]) => {
76
- return !(value instanceof import_database.RelationField);
77
- }).reduce((obj, [key, value]) => {
78
- obj[key] = {
79
- ...getFieldTypeAttributes(value)
80
- };
81
- return obj;
82
- }, {})
83
- },
84
- [`${collection.name}.form`]: {
85
- allOf: [
86
- {
87
- $ref: `#/components/schemas/${collection.name}`
88
- },
89
- {
90
- type: "object",
91
- properties: getCollectionReadOnlyFields(collection).reduce((obj, key) => {
92
- obj[key] = {
93
- readOnly: true
94
- };
95
- return obj;
96
- }, {})
97
- }
98
- ]
99
- }
100
- };
101
- }
102
- var schemas_default = (collection, options) => {
103
- const associations = (0, import_associations.associationFields)(collection);
104
- const associationsTarget = associations.map((field) => collection.db.getCollection(field.target));
105
- const schemas = collectionToSchema(collection);
106
- if (options.withAssociation) {
107
- for (const target of associationsTarget) {
108
- Object.assign(schemas, collectionToSchema(target));
109
- }
110
- }
111
- return {
112
- schemas
113
- };
114
- };
115
- function getFieldTypeAttributes(field) {
116
- return (0, import_field_type_map.getTypeByField)(field);
117
- }
@@ -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
- import { Collection } from '@nocobase/database';
10
- declare function collectionToSwaggerObject(collection: Collection, options: any): {
11
- paths: any;
12
- components: {
13
- parameters: {};
14
- schemas: {
15
- [x: string]: {
16
- type: string;
17
- properties: {};
18
- allOf?: undefined;
19
- } | {
20
- allOf: ({
21
- $ref: string;
22
- type?: undefined;
23
- properties?: undefined;
24
- } | {
25
- type: string;
26
- properties: any;
27
- $ref?: undefined;
28
- })[];
29
- type?: undefined;
30
- properties?: undefined;
31
- };
32
- };
33
- };
34
- tags: {
35
- name: string;
36
- description: string;
37
- }[];
38
- };
39
- export default collectionToSwaggerObject;
@@ -1,52 +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 __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 collections_exports = {};
38
- __export(collections_exports, {
39
- default: () => collections_default
40
- });
41
- module.exports = __toCommonJS(collections_exports);
42
- var import_paths = __toESM(require("./paths"));
43
- var import_components = __toESM(require("./components"));
44
- var import_tags = __toESM(require("./tags"));
45
- function collectionToSwaggerObject(collection, options) {
46
- return {
47
- paths: (0, import_paths.default)(collection, options),
48
- components: (0, import_components.default)(collection, options),
49
- tags: (0, import_tags.default)(collection, options)
50
- };
51
- }
52
- var collections_default = collectionToSwaggerObject;
@@ -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 { Collection, RelationField } from '@nocobase/database';
10
- declare const _default: (collection: Collection) => {
11
- [x: string]: object;
12
- };
13
- export default _default;
14
- export declare function associationFields(collection: Collection): Array<RelationField>;
@@ -1,69 +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 __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 associations_exports = {};
38
- __export(associations_exports, {
39
- associationFields: () => associationFields,
40
- default: () => associations_default
41
- });
42
- module.exports = __toCommonJS(associations_exports);
43
- var import_database = require("@nocobase/database");
44
- var import_multiple_association = __toESM(require("./multiple-association"));
45
- var import_single_association = __toESM(require("./single-association"));
46
- var import__ = require("..");
47
- var associations_default = (collection) => {
48
- return associationFields(collection).map((field) => {
49
- if (field.type === "belongsToMany" || field.type === "hasMany") {
50
- return (0, import_multiple_association.default)(collection, field);
51
- }
52
- return (0, import_single_association.default)(collection, field);
53
- }).reduce((obj, item) => {
54
- return {
55
- ...obj,
56
- ...item
57
- };
58
- }, {});
59
- };
60
- function associationFields(collection) {
61
- if ((0, import__.isViewCollection)(collection)) {
62
- return [];
63
- }
64
- return Array.from(collection.fields.values()).filter((field) => field instanceof import_database.RelationField).filter((field) => field.name !== "createdBy" && field.name !== "updatedBy");
65
- }
66
- // Annotate the CommonJS export names for ESM import in node:
67
- 0 && (module.exports = {
68
- associationFields
69
- });
@@ -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 { BelongsToManyField, Collection, HasManyField } from '@nocobase/database';
10
- export declare function appendCollectionIndexParams(apiDef: object): object;
11
- declare const _default: (collection: Collection, relationField: HasManyField | BelongsToManyField) => {
12
- [x: string]: object;
13
- };
14
- export default _default;
@@ -1,134 +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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var multiple_association_exports = {};
28
- __export(multiple_association_exports, {
29
- appendCollectionIndexParams: () => appendCollectionIndexParams,
30
- default: () => multiple_association_default
31
- });
32
- module.exports = __toCommonJS(multiple_association_exports);
33
- var import_collection = require("../collection");
34
- var import__ = require("../index");
35
- function appendCollectionIndexParams(apiDef) {
36
- for (const action of Object.keys(apiDef)) {
37
- const parameters = apiDef[action]["parameters"];
38
- if (!parameters) {
39
- apiDef[action]["parameters"] = [];
40
- }
41
- apiDef[action]["parameters"].unshift({
42
- $ref: "#/components/parameters/collectionIndex"
43
- });
44
- }
45
- return apiDef;
46
- }
47
- var multiple_association_default = (collection, relationField) => {
48
- const options = {
49
- collection,
50
- relationField
51
- };
52
- const targetCollection = collection.db.getCollection(relationField.target);
53
- const paths = {
54
- [`/${collection.name}/{collectionIndex}/${relationField.name}:list`]: appendCollectionIndexParams(
55
- (0, import_collection.ListActionTemplate)(options)
56
- ),
57
- [`/${collection.name}/{collectionIndex}/${relationField.name}:get`]: appendCollectionIndexParams(
58
- (0, import_collection.GetActionTemplate)(options)
59
- ),
60
- [`/${collection.name}/{collectionIndex}/${relationField.name}:create`]: appendCollectionIndexParams(
61
- (0, import_collection.CreateActionTemplate)(options)
62
- ),
63
- [`/${collection.name}/{collectionIndex}/${relationField.name}:update`]: appendCollectionIndexParams(
64
- (0, import_collection.UpdateActionTemplate)(options)
65
- ),
66
- [`/${collection.name}/{collectionIndex}/${relationField.name}:destroy`]: appendCollectionIndexParams(
67
- (0, import_collection.DestroyActionTemplate)(options)
68
- ),
69
- [`/${collection.name}/{collectionIndex}/${relationField.name}:set`]: appendCollectionIndexParams({
70
- post: {
71
- tags: [`${collection.name}.${relationField.name}`],
72
- summary: "Set or reset associations",
73
- parameters: [
74
- {
75
- $ref: "#/components/parameters/filterByTk"
76
- },
77
- {
78
- $ref: "#/components/parameters/filterByTks"
79
- }
80
- ],
81
- responses: {
82
- "200": {
83
- description: "OK"
84
- }
85
- }
86
- }
87
- }),
88
- [`/${collection.name}/{collectionIndex}/${relationField.name}:remove`]: appendCollectionIndexParams({
89
- post: {
90
- tags: [`${collection.name}.${relationField.name}`],
91
- summary: "Detach record",
92
- parameters: [
93
- {
94
- $ref: "#/components/parameters/filterByTk"
95
- },
96
- {
97
- $ref: "#/components/parameters/filterByTks"
98
- }
99
- ],
100
- responses: {
101
- "200": {
102
- description: "OK"
103
- }
104
- }
105
- }
106
- }),
107
- [`/${collection.name}/{collectionIndex}/${relationField.name}:toggle`]: appendCollectionIndexParams({
108
- post: {
109
- tags: [`${collection.name}.${relationField.name}`],
110
- summary: "Attach or detach record",
111
- parameters: [
112
- {
113
- $ref: "#/components/parameters/filterByTk"
114
- }
115
- ],
116
- responses: {
117
- "200": {
118
- description: "OK"
119
- }
120
- }
121
- }
122
- })
123
- };
124
- if ((0, import__.hasSortField)(collection)) {
125
- paths[`/${collection.name}/{collectionIndex}/${relationField.name}:move`] = appendCollectionIndexParams(
126
- (0, import_collection.MoveActionTemplate)(options)
127
- );
128
- }
129
- return paths;
130
- };
131
- // Annotate the CommonJS export names for ESM import in node:
132
- 0 && (module.exports = {
133
- appendCollectionIndexParams
134
- });
@@ -1,13 +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 { BelongsToField, Collection, HasOneField } from '@nocobase/database';
10
- declare const _default: (collection: Collection, relationField: HasOneField | BelongsToField) => {
11
- [x: string]: object;
12
- };
13
- export default _default;