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