@nocobase/plugin-api-doc 1.2.12-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,114 +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 single_association_exports = {};
28
- __export(single_association_exports, {
29
- default: () => single_association_default
30
- });
31
- module.exports = __toCommonJS(single_association_exports);
32
- var import_multiple_association = require("./multiple-association");
33
- var import_collection = require("../collection");
34
- function removeFilterByTkParams(apiDoc) {
35
- for (const action of Object.values(apiDoc)) {
36
- if (action.parameters) {
37
- action.parameters = action.parameters.filter((param) => {
38
- if (param.$ref) {
39
- return param.$ref !== "#/components/parameters/filterByTk";
40
- }
41
- });
42
- }
43
- }
44
- return apiDoc;
45
- }
46
- const parametersShouldRemove = [
47
- "#/components/parameters/filterByTk",
48
- "#/components/parameters/filter",
49
- "#/components/parameters/sort"
50
- ];
51
- function filterSingleAssociationParams(apiDoc) {
52
- for (const action of Object.values(apiDoc)) {
53
- if (action.parameters) {
54
- action.parameters = action.parameters.filter((param) => {
55
- if (param.$ref) {
56
- return !parametersShouldRemove.includes(param.$ref);
57
- }
58
- });
59
- }
60
- }
61
- return apiDoc;
62
- }
63
- var single_association_default = (collection, relationField) => {
64
- const options = {
65
- collection,
66
- relationField
67
- };
68
- return {
69
- [`/${collection.name}/{collectionIndex}/${relationField.name}:get`]: removeFilterByTkParams(
70
- filterSingleAssociationParams((0, import_multiple_association.appendCollectionIndexParams)((0, import_collection.GetActionTemplate)(options)))
71
- ),
72
- [`/${collection.name}/{collectionIndex}/${relationField.name}:set`]: (0, import_multiple_association.appendCollectionIndexParams)({
73
- post: {
74
- tags: [`${collection.name}.${relationField.name}`],
75
- summary: "Associate a record",
76
- parameters: [
77
- {
78
- name: "tk",
79
- in: "query",
80
- description: "targetKey",
81
- schema: {
82
- type: "string"
83
- }
84
- }
85
- ],
86
- responses: {
87
- "200": {
88
- description: "OK"
89
- }
90
- }
91
- }
92
- }),
93
- [`/${collection.name}/{collectionIndex}/${relationField.name}:remove`]: (0, import_multiple_association.appendCollectionIndexParams)({
94
- post: {
95
- tags: [`${collection.name}.${relationField.name}`],
96
- summary: "Disassociate the relationship record",
97
- responses: {
98
- "200": {
99
- description: "OK"
100
- }
101
- }
102
- }
103
- }),
104
- [`/${collection.name}/{collectionIndex}/${relationField.name}:update`]: removeFilterByTkParams(
105
- filterSingleAssociationParams((0, import_multiple_association.appendCollectionIndexParams)((0, import_collection.UpdateActionTemplate)(options)))
106
- ),
107
- [`/${collection.name}/{collectionIndex}/${relationField.name}:create`]: removeFilterByTkParams(
108
- filterSingleAssociationParams((0, import_multiple_association.appendCollectionIndexParams)((0, import_collection.CreateActionTemplate)(options)))
109
- ),
110
- [`/${collection.name}/{collectionIndex}/${relationField.name}:destroy`]: removeFilterByTkParams(
111
- filterSingleAssociationParams((0, import_multiple_association.appendCollectionIndexParams)((0, import_collection.DestroyActionTemplate)(options)))
112
- )
113
- };
114
- };
@@ -1,209 +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
- type TemplateOptions = {
11
- collection: Collection;
12
- relationField?: RelationField;
13
- };
14
- export declare function relationTypeToString(field: RelationField): any;
15
- export declare function ListActionTemplate({ collection, relationField }: TemplateOptions): {
16
- get: {
17
- tags: string[];
18
- summary: string;
19
- parameters: ({
20
- name: string;
21
- in: string;
22
- description: string;
23
- required: boolean;
24
- schema: {
25
- type: string;
26
- };
27
- $ref?: undefined;
28
- } | {
29
- $ref: string;
30
- name?: undefined;
31
- in?: undefined;
32
- description?: undefined;
33
- required?: undefined;
34
- schema?: undefined;
35
- })[];
36
- responses: {
37
- '200': {
38
- description: string;
39
- content: {
40
- 'application/json': {
41
- schema: {
42
- type: string;
43
- properties: {
44
- data: {
45
- type: string;
46
- items: {
47
- $ref: string;
48
- };
49
- };
50
- meta: {
51
- type: string;
52
- properties: {
53
- count: {
54
- type: string;
55
- description: string;
56
- };
57
- page: {
58
- type: string;
59
- description: string;
60
- };
61
- pageSize: {
62
- type: string;
63
- description: string;
64
- };
65
- totalPage: {
66
- type: string;
67
- description: string;
68
- };
69
- };
70
- };
71
- };
72
- };
73
- };
74
- };
75
- };
76
- };
77
- };
78
- };
79
- export declare function GetActionTemplate(options: TemplateOptions): {
80
- get: {
81
- tags: string[];
82
- summary: string;
83
- parameters: {
84
- $ref: string;
85
- }[];
86
- responses: {
87
- '200': {
88
- description: string;
89
- content: {
90
- 'application/json': {
91
- schema: {
92
- type: string;
93
- properties: {
94
- data: {
95
- $ref: string;
96
- };
97
- };
98
- };
99
- };
100
- };
101
- };
102
- };
103
- };
104
- };
105
- export declare function CreateActionTemplate(options: TemplateOptions): {
106
- post: {
107
- tags: string[];
108
- summary: string;
109
- parameters: {
110
- $ref: string;
111
- }[];
112
- requestBody: {
113
- content: {
114
- 'application/json': {
115
- schema: {
116
- $ref: string;
117
- };
118
- };
119
- };
120
- };
121
- responses: {
122
- '200': {
123
- description: string;
124
- content: {
125
- 'application/json': {
126
- schema: {
127
- type: string;
128
- properties: {
129
- data: {
130
- $ref: string;
131
- };
132
- };
133
- };
134
- };
135
- };
136
- };
137
- };
138
- };
139
- };
140
- export declare function UpdateActionTemplate(options: TemplateOptions): {
141
- post: {
142
- tags: string[];
143
- summary: string;
144
- parameters: {
145
- $ref: string;
146
- }[];
147
- requestBody: {
148
- content: {
149
- 'application/json': {
150
- schema: {
151
- $ref: string;
152
- };
153
- };
154
- };
155
- };
156
- responses: {
157
- '200': {
158
- description: string;
159
- content: {
160
- 'application/json': {
161
- schema: {
162
- type: string;
163
- properties: {
164
- data: {
165
- $ref: string;
166
- };
167
- };
168
- };
169
- };
170
- };
171
- };
172
- };
173
- };
174
- };
175
- export declare function DestroyActionTemplate(options: TemplateOptions): {
176
- post: {
177
- tags: string[];
178
- summary: string;
179
- parameters: {
180
- $ref: string;
181
- }[];
182
- responses: {
183
- '200': {
184
- description: string;
185
- };
186
- };
187
- };
188
- };
189
- export declare function MoveActionTemplate(options: TemplateOptions): {
190
- post: {
191
- tags: string[];
192
- summary: string;
193
- parameters: {
194
- name: string;
195
- in: string;
196
- description: string;
197
- schema: {
198
- type: string;
199
- };
200
- }[];
201
- responses: {
202
- '200': {
203
- description: string;
204
- };
205
- };
206
- };
207
- };
208
- declare const _default: (collection: Collection) => any;
209
- export default _default;
@@ -1,371 +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 collection_exports = {};
28
- __export(collection_exports, {
29
- CreateActionTemplate: () => CreateActionTemplate,
30
- DestroyActionTemplate: () => DestroyActionTemplate,
31
- GetActionTemplate: () => GetActionTemplate,
32
- ListActionTemplate: () => ListActionTemplate,
33
- MoveActionTemplate: () => MoveActionTemplate,
34
- UpdateActionTemplate: () => UpdateActionTemplate,
35
- default: () => collection_default,
36
- relationTypeToString: () => relationTypeToString
37
- });
38
- module.exports = __toCommonJS(collection_exports);
39
- var import_index = require("./index");
40
- function relationTypeToString(field) {
41
- return {
42
- belongsTo: "Many to one",
43
- hasOne: "One to one",
44
- hasMany: "One to many",
45
- belongsToMany: "Many to many"
46
- }[field.type];
47
- }
48
- function ListActionTemplate({ collection, relationField }) {
49
- return {
50
- get: {
51
- tags: [relationField ? `${collection.name}.${relationField.name}` : collection.name],
52
- summary: relationField ? `Return a list of ${relationTypeToString(relationField)} relationship` : `Returns a list of the collection`,
53
- parameters: [
54
- {
55
- name: "page",
56
- in: "query",
57
- description: "page number",
58
- required: false,
59
- schema: {
60
- type: "integer"
61
- }
62
- },
63
- {
64
- name: "pageSize",
65
- in: "query",
66
- description: "page size",
67
- required: false,
68
- schema: {
69
- type: "integer"
70
- }
71
- },
72
- {
73
- $ref: "#/components/parameters/filter"
74
- },
75
- {
76
- $ref: "#/components/parameters/sort"
77
- },
78
- {
79
- $ref: "#/components/parameters/fields"
80
- },
81
- {
82
- $ref: "#/components/parameters/appends"
83
- },
84
- {
85
- $ref: "#/components/parameters/except"
86
- }
87
- ],
88
- responses: {
89
- "200": {
90
- description: "OK",
91
- content: {
92
- "application/json": {
93
- schema: {
94
- type: "object",
95
- properties: {
96
- data: {
97
- type: "array",
98
- items: {
99
- $ref: `#/components/schemas/${collection.name}`
100
- }
101
- },
102
- meta: {
103
- type: "object",
104
- properties: {
105
- count: {
106
- type: "integer",
107
- description: "total count"
108
- },
109
- page: {
110
- type: "integer",
111
- description: "current page"
112
- },
113
- pageSize: {
114
- type: "integer",
115
- description: "items count per page"
116
- },
117
- totalPage: {
118
- type: "integer",
119
- description: "total page"
120
- }
121
- }
122
- }
123
- }
124
- }
125
- }
126
- }
127
- }
128
- }
129
- }
130
- };
131
- }
132
- function GetActionTemplate(options) {
133
- const { collection, relationField } = options;
134
- return {
135
- get: {
136
- tags: [relationField ? `${collection.name}.${relationField.name}` : collection.name],
137
- summary: `Return a record${relationField ? ` of ${relationTypeToString(relationField)}` : ""}`,
138
- parameters: [
139
- {
140
- $ref: "#/components/parameters/filterByTk"
141
- },
142
- {
143
- $ref: "#/components/parameters/filter"
144
- },
145
- {
146
- $ref: "#/components/parameters/sort"
147
- },
148
- {
149
- $ref: "#/components/parameters/fields"
150
- },
151
- {
152
- $ref: "#/components/parameters/appends"
153
- },
154
- {
155
- $ref: "#/components/parameters/except"
156
- }
157
- ],
158
- responses: {
159
- "200": {
160
- description: "OK",
161
- content: {
162
- "application/json": {
163
- schema: {
164
- type: "object",
165
- properties: {
166
- data: {
167
- $ref: `#/components/schemas/${collection.name}`
168
- }
169
- }
170
- }
171
- }
172
- }
173
- }
174
- }
175
- }
176
- };
177
- }
178
- function CreateActionTemplate(options) {
179
- const { collection, relationField } = options;
180
- return {
181
- post: {
182
- tags: [relationField ? `${collection.name}.${relationField.name}` : collection.name],
183
- summary: relationField ? `Create and associate a record` : `Create record`,
184
- parameters: [
185
- {
186
- $ref: "#/components/parameters/whitelist"
187
- },
188
- {
189
- $ref: "#/components/parameters/blacklist"
190
- }
191
- ],
192
- requestBody: {
193
- content: {
194
- "application/json": {
195
- schema: {
196
- $ref: `#/components/schemas/${collection.name}.form`
197
- }
198
- }
199
- }
200
- },
201
- responses: {
202
- "200": {
203
- description: "OK",
204
- content: {
205
- "application/json": {
206
- schema: {
207
- type: "object",
208
- properties: {
209
- data: {
210
- $ref: `#/components/schemas/${collection.name}`
211
- }
212
- }
213
- }
214
- }
215
- }
216
- }
217
- }
218
- }
219
- };
220
- }
221
- function UpdateActionTemplate(options) {
222
- const { collection, relationField } = options;
223
- return {
224
- post: {
225
- tags: [relationField ? `${collection.name}.${relationField.name}` : collection.name],
226
- summary: relationField ? `Update the relationship record` : `Update record`,
227
- parameters: [
228
- {
229
- $ref: "#/components/parameters/filterByTk"
230
- },
231
- {
232
- $ref: "#/components/parameters/filter"
233
- },
234
- {
235
- $ref: "#/components/parameters/whitelist"
236
- },
237
- {
238
- $ref: "#/components/parameters/blacklist"
239
- }
240
- ],
241
- requestBody: {
242
- content: {
243
- "application/json": {
244
- schema: {
245
- $ref: `#/components/schemas/${collection.name}.form`
246
- }
247
- }
248
- }
249
- },
250
- responses: {
251
- "200": {
252
- description: "OK",
253
- content: {
254
- "application/json": {
255
- schema: {
256
- type: "object",
257
- properties: {
258
- data: {
259
- $ref: `#/components/schemas/${collection.name}`
260
- }
261
- }
262
- }
263
- }
264
- }
265
- }
266
- }
267
- }
268
- };
269
- }
270
- function DestroyActionTemplate(options) {
271
- const { collection, relationField } = options;
272
- return {
273
- post: {
274
- tags: [relationField ? `${collection.name}.${relationField.name}` : collection.name],
275
- summary: relationField ? `Destroy and disassociate the relationship record` : `Delete record`,
276
- parameters: [
277
- {
278
- $ref: "#/components/parameters/filterByTk"
279
- },
280
- {
281
- $ref: "#/components/parameters/filter"
282
- }
283
- ],
284
- responses: {
285
- "200": {
286
- description: "OK"
287
- }
288
- }
289
- }
290
- };
291
- }
292
- function MoveActionTemplate(options) {
293
- const { collection, relationField } = options;
294
- return {
295
- post: {
296
- tags: [relationField ? `${collection.name}.${relationField.name}` : collection.name],
297
- summary: relationField ? `Move the relationship record` : `Move record`,
298
- parameters: [
299
- {
300
- name: "sourceId",
301
- in: "query",
302
- description: "source id",
303
- schema: { type: "string" }
304
- },
305
- {
306
- name: "targetId",
307
- in: "query",
308
- description: "move target id",
309
- schema: { type: "string" }
310
- },
311
- {
312
- name: "method",
313
- in: "query",
314
- description: "move method, insertAfter or insertBefore",
315
- schema: { type: "string" }
316
- },
317
- {
318
- name: "sortField",
319
- in: "query",
320
- description: "sort field name, default is sort",
321
- schema: { type: "string" }
322
- },
323
- {
324
- name: "targetScope",
325
- in: "query",
326
- description: "move target scope",
327
- schema: { type: "string" }
328
- },
329
- {
330
- name: "sticky",
331
- in: "query",
332
- description: "sticky to top",
333
- schema: { type: "boolean" }
334
- }
335
- ],
336
- responses: {
337
- "200": {
338
- description: "OK"
339
- }
340
- }
341
- }
342
- };
343
- }
344
- var collection_default = (collection) => {
345
- const options = { collection };
346
- const apiDoc = {
347
- [`/${collection.name}:list`]: ListActionTemplate(options),
348
- [`/${collection.name}:get`]: GetActionTemplate(options)
349
- };
350
- if (!(0, import_index.readOnlyCollection)(collection)) {
351
- Object.assign(apiDoc, {
352
- [`/${collection.name}:create`]: CreateActionTemplate(options),
353
- [`/${collection.name}:update`]: UpdateActionTemplate(options),
354
- [`/${collection.name}:destroy`]: DestroyActionTemplate(options)
355
- });
356
- }
357
- if ((0, import_index.hasSortField)(collection)) {
358
- apiDoc[`/${collection.name}:move`] = MoveActionTemplate(options);
359
- }
360
- return apiDoc;
361
- };
362
- // Annotate the CommonJS export names for ESM import in node:
363
- 0 && (module.exports = {
364
- CreateActionTemplate,
365
- DestroyActionTemplate,
366
- GetActionTemplate,
367
- ListActionTemplate,
368
- MoveActionTemplate,
369
- UpdateActionTemplate,
370
- relationTypeToString
371
- });
@@ -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 } from '@nocobase/database';
10
- declare const _default: (collection: Collection, options: any) => any;
11
- export default _default;
12
- export declare function hasSortField(collection: Collection): boolean;
13
- export declare function readOnlyCollection(collection: Collection): boolean;
14
- export declare function isViewCollection(collection: Collection): boolean;