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