@tachybase/plugin-data-source-common 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 (126) hide show
  1. package/.turbo/turbo-build.log +14 -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/features/rest-api/collection-add/AddCollection.d.ts +2 -0
  7. package/dist/client/features/rest-api/collection-add/AddCollectionAction.component.d.ts +2 -0
  8. package/dist/client/features/rest-api/collection-add/CreateCollection.schema.d.ts +389 -0
  9. package/dist/client/features/rest-api/collection-add/CreateCollection.view.d.ts +2 -0
  10. package/dist/client/features/rest-api/collection-add/PreviewComponent.d.ts +2 -0
  11. package/dist/client/features/rest-api/collection-add/PreviewFields.d.ts +5 -0
  12. package/dist/client/features/rest-api/collection-add/RequestActionItems.provider.d.ts +2 -0
  13. package/dist/client/features/rest-api/collection-add/getSchemaRequestAction.d.ts +57 -0
  14. package/dist/client/features/rest-api/collection-add/useActionCreateCollection.d.ts +3 -0
  15. package/dist/client/features/rest-api/collection-delete/DeleteCollection.d.ts +2 -0
  16. package/dist/client/features/rest-api/collection-delete/DeleteCollectionAction.component.d.ts +5 -0
  17. package/dist/client/features/rest-api/collection-delete/useBulkDestroyActionAndRefreshCM.d.ts +3 -0
  18. package/dist/client/features/rest-api/collection-delete/useDestroyActionAndRefreshCM.d.ts +3 -0
  19. package/dist/client/features/rest-api/collection-edit/EditCollection.d.ts +2 -0
  20. package/dist/client/features/rest-api/collection-edit/EditCollectionAction.component.d.ts +2 -0
  21. package/dist/client/features/rest-api/collection-edit/EditCollectionForm.view.d.ts +2 -0
  22. package/dist/client/features/rest-api/collection-edit/useActionEditCollection.d.ts +3 -0
  23. package/dist/client/features/rest-api/constants/mapListve.d.ts +7 -0
  24. package/dist/client/features/rest-api/constants/requestHeaderList.d.ts +4 -0
  25. package/dist/client/features/rest-api/contexts/RequestForm.context.d.ts +11 -0
  26. package/dist/client/features/rest-api/contexts/ResponseInfo.context.d.ts +12 -0
  27. package/dist/client/features/rest-api/form-data-source/DataSourceSettingsForm.d.ts +2 -0
  28. package/dist/client/features/rest-api/form-data-source/DataSourceSettingsForm.schema.d.ts +172 -0
  29. package/dist/client/features/rest-api/kit.d.ts +4 -0
  30. package/dist/client/features/rest-api/request-configs/debug-area/Debug.provider.d.ts +2 -0
  31. package/dist/client/features/rest-api/request-configs/debug-area/Debug.schema.d.ts +164 -0
  32. package/dist/client/features/rest-api/request-configs/debug-area/Debug.view.d.ts +2 -0
  33. package/dist/client/features/rest-api/request-configs/debug-area/DebugComponent.d.ts +2 -0
  34. package/dist/client/features/rest-api/request-configs/debug-area/components/AlertError.d.ts +2 -0
  35. package/dist/client/features/rest-api/request-configs/debug-area/components/DebugResponse.schema.d.ts +21 -0
  36. package/dist/client/features/rest-api/request-configs/debug-area/components/DebugResponse.view.d.ts +2 -0
  37. package/dist/client/features/rest-api/request-configs/debug-area/components/DebugResponseTabs.d.ts +2 -0
  38. package/dist/client/features/rest-api/request-configs/debug-area/components/DebugResponseTabs.items.d.ts +6 -0
  39. package/dist/client/features/rest-api/request-configs/debug-area/components/ExtractFieldMetadata.d.ts +2 -0
  40. package/dist/client/features/rest-api/request-configs/debug-area/components/Headers.schema.d.ts +60 -0
  41. package/dist/client/features/rest-api/request-configs/debug-area/components/RequestHeaders.view.d.ts +2 -0
  42. package/dist/client/features/rest-api/request-configs/debug-area/components/ResponseBody.schema.d.ts +21 -0
  43. package/dist/client/features/rest-api/request-configs/debug-area/components/ResponseBody.view.d.ts +2 -0
  44. package/dist/client/features/rest-api/request-configs/debug-area/components/ResponseHeaders.view.d.ts +2 -0
  45. package/dist/client/features/rest-api/request-configs/debug-area/components/ResponseTab.d.ts +2 -0
  46. package/dist/client/features/rest-api/request-configs/debug-area/components/ResponseTab.item.d.ts +6 -0
  47. package/dist/client/features/rest-api/request-configs/debug-area/components/TooltipContainer.d.ts +2 -0
  48. package/dist/client/features/rest-api/request-configs/debug-area/schemas/getSchemaAction.d.ts +88 -0
  49. package/dist/client/features/rest-api/request-configs/debug-area/schemas/getSchemaParam.d.ts +1 -0
  50. package/dist/client/features/rest-api/request-configs/debug-area/scopes/useCancelAction.d.ts +3 -0
  51. package/dist/client/features/rest-api/request-configs/debug-area/scopes/useDebugAction.d.ts +3 -0
  52. package/dist/client/features/rest-api/request-configs/method-path/FieldMethod.schema.d.ts +23 -0
  53. package/dist/client/features/rest-api/request-configs/method-path/FieldMethod.view.d.ts +2 -0
  54. package/dist/client/features/rest-api/request-configs/method-path/FieldPath.schema.d.ts +35 -0
  55. package/dist/client/features/rest-api/request-configs/method-path/FieldPath.view.d.ts +2 -0
  56. package/dist/client/features/rest-api/request-configs/method-path/MethodPathComponent.d.ts +2 -0
  57. package/dist/client/features/rest-api/request-configs/request-tab/RequestBody.schema.d.ts +124 -0
  58. package/dist/client/features/rest-api/request-configs/request-tab/RequestBody.view.d.ts +2 -0
  59. package/dist/client/features/rest-api/request-configs/request-tab/RequestHeaders.schema.d.ts +77 -0
  60. package/dist/client/features/rest-api/request-configs/request-tab/RequestHeaders.view.d.ts +2 -0
  61. package/dist/client/features/rest-api/request-configs/request-tab/RequestParams.schema.d.ts +81 -0
  62. package/dist/client/features/rest-api/request-configs/request-tab/RequestParams.view.d.ts +2 -0
  63. package/dist/client/features/rest-api/request-configs/request-tab/RequestTab.d.ts +2 -0
  64. package/dist/client/features/rest-api/request-configs/request-tab/RequestTab.items.d.ts +6 -0
  65. package/dist/client/features/rest-api/request-configs/request-tab/debounceClick.util.d.ts +2 -0
  66. package/dist/client/features/rest-api/request-configs/request-transformer/ResponseTransformerComponent.d.ts +2 -0
  67. package/dist/client/features/rest-api/scopes/useVariableOptions.d.ts +1 -0
  68. package/dist/client/features/rest-api/utils/filterObjectWithMethodAndPath.d.ts +1 -0
  69. package/dist/client/features/rest-api/utils/filterTree.d.ts +1 -0
  70. package/dist/client/features/rest-api/utils/getRequestActions.d.ts +1 -0
  71. package/dist/client/features/rest-api/utils/getRequestValues.d.ts +1 -0
  72. package/dist/client/features/rest-api/utils/responseTransformerAe.d.ts +4 -0
  73. package/dist/client/features/rest-api/utils/setFormValue.d.ts +1 -0
  74. package/dist/client/forms/msql.d.ts +2 -0
  75. package/dist/client/forms/pg.d.ts +2 -0
  76. package/dist/client/index.d.ts +6 -0
  77. package/dist/client/index.js +86 -0
  78. package/dist/client/locale.d.ts +4 -0
  79. package/dist/externalVersion.js +16 -0
  80. package/dist/index.d.ts +2 -0
  81. package/dist/index.js +39 -0
  82. package/dist/locale/en-US.json +32 -0
  83. package/dist/locale/zh-CN.json +32 -0
  84. package/dist/server/http/plugin.d.ts +10 -0
  85. package/dist/server/http/plugin.js +78 -0
  86. package/dist/server/http/services/http-api-repository.d.ts +18 -0
  87. package/dist/server/http/services/http-api-repository.js +125 -0
  88. package/dist/server/http/services/http-collection-manager.d.ts +6 -0
  89. package/dist/server/http/services/http-collection-manager.js +36 -0
  90. package/dist/server/http/services/http-collection.d.ts +7 -0
  91. package/dist/server/http/services/http-collection.js +270 -0
  92. package/dist/server/http/services/http-data-source.d.ts +10 -0
  93. package/dist/server/http/services/http-data-source.js +67 -0
  94. package/dist/server/http/services/http-request-builder.d.ts +3 -0
  95. package/dist/server/http/services/http-request-builder.js +30 -0
  96. package/dist/server/http/services/transform-response.d.ts +1 -0
  97. package/dist/server/http/services/transform-response.js +185 -0
  98. package/dist/server/http/services/type-interface-map.d.ts +182 -0
  99. package/dist/server/http/services/type-interface-map.js +246 -0
  100. package/dist/server/http/services/utils.d.ts +2 -0
  101. package/dist/server/http/services/utils.js +49 -0
  102. package/dist/server/index.d.ts +1 -0
  103. package/dist/server/index.js +33 -0
  104. package/dist/server/mysql/database-introspector.d.ts +27 -0
  105. package/dist/server/mysql/database-introspector.js +254 -0
  106. package/dist/server/mysql/mysql-collection-manager.d.ts +3 -0
  107. package/dist/server/mysql/mysql-collection-manager.js +29 -0
  108. package/dist/server/mysql/mysql-data-source.d.ts +7 -0
  109. package/dist/server/mysql/mysql-data-source.js +111 -0
  110. package/dist/server/mysql/type-interface-map.d.ts +193 -0
  111. package/dist/server/mysql/type-interface-map.js +257 -0
  112. package/dist/server/pg/database-introspector.d.ts +54 -0
  113. package/dist/server/pg/database-introspector.js +286 -0
  114. package/dist/server/pg/postgres-collection-manager.d.ts +3 -0
  115. package/dist/server/pg/postgres-collection-manager.js +29 -0
  116. package/dist/server/pg/postgres-data-source.d.ts +8 -0
  117. package/dist/server/pg/postgres-data-source.js +127 -0
  118. package/dist/server/pg/type-interface-map.d.ts +183 -0
  119. package/dist/server/pg/type-interface-map.js +243 -0
  120. package/dist/server/pg/utils.d.ts +1 -0
  121. package/dist/server/pg/utils.js +48 -0
  122. package/dist/server/plugin.d.ts +13 -0
  123. package/dist/server/plugin.js +60 -0
  124. package/package.json +32 -0
  125. package/server.d.ts +2 -0
  126. package/server.js +1 -0
@@ -0,0 +1,127 @@
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 postgres_data_source_exports = {};
29
+ __export(postgres_data_source_exports, {
30
+ PostgresDataSource: () => PostgresDataSource
31
+ });
32
+ module.exports = __toCommonJS(postgres_data_source_exports);
33
+ var import_data_source = require("@tachybase/data-source");
34
+ var import_database = require("@tachybase/database");
35
+ var import_database_introspector = require("./database-introspector");
36
+ var import_postgres_collection_manager = require("./postgres-collection-manager");
37
+ var import_type_interface_map = __toESM(require("./type-interface-map"));
38
+ class PostgresDataSource extends import_data_source.DataSource {
39
+ static async testConnection(options) {
40
+ const database = new import_database.Database({
41
+ dialect: "postgres",
42
+ ...options
43
+ });
44
+ try {
45
+ await database.sequelize.authenticate();
46
+ if (options.schema) {
47
+ const queryRes = await database.sequelize.query(
48
+ `
49
+ SELECT schema_name
50
+ FROM information_schema.schemata
51
+ WHERE schema_name = $1;
52
+ `,
53
+ {
54
+ bind: [options.schema],
55
+ type: "SELECT"
56
+ }
57
+ );
58
+ if (queryRes.length === 0) {
59
+ throw new Error(`schema ${options.schema} not exists`);
60
+ }
61
+ }
62
+ } catch (e) {
63
+ throw e;
64
+ } finally {
65
+ await database.close();
66
+ }
67
+ return true;
68
+ }
69
+ async load(options) {
70
+ const db = this.collectionManager.db;
71
+ const introspector = new import_database_introspector.DatabaseIntrospector({
72
+ db,
73
+ typeInterfaceMap: import_type_interface_map.default
74
+ });
75
+ introspector.on("loadMessage", ({ message }) => {
76
+ this.emit("loadMessage", { message });
77
+ });
78
+ const { localData } = options;
79
+ const collections = await introspector.getCollections({
80
+ localData
81
+ });
82
+ const delayFields = /* @__PURE__ */ new Map();
83
+ for (const collection of collections) {
84
+ try {
85
+ const fields = collection.fields;
86
+ for (const field of fields) {
87
+ if (field.type === "belongsToMany") {
88
+ if (!delayFields.has(collection.name)) {
89
+ delayFields.set(collection.name, []);
90
+ }
91
+ delayFields.get(collection.name).push(field);
92
+ }
93
+ }
94
+ this.collectionManager.defineCollection({
95
+ ...collection,
96
+ fields: fields.filter((field) => field.type !== "belongsToMany"),
97
+ introspected: true
98
+ });
99
+ } catch (e) {
100
+ db.logger.error(`load collection failed, ${e}`);
101
+ delayFields.delete(collection.name);
102
+ }
103
+ }
104
+ for (const [name, fields] of delayFields.entries()) {
105
+ try {
106
+ for (const field of fields) {
107
+ this.collectionManager.getCollection(name).setField(field.name, field);
108
+ }
109
+ } catch (e) {
110
+ db.logger.error(`load belongs to many field failed, ${e}`);
111
+ }
112
+ }
113
+ }
114
+ createCollectionManager(options) {
115
+ const database = new import_database.Database({
116
+ dialect: "postgres",
117
+ ...options
118
+ });
119
+ return new import_postgres_collection_manager.PostgresCollectionManager({
120
+ database
121
+ });
122
+ }
123
+ }
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ PostgresDataSource
127
+ });
@@ -0,0 +1,183 @@
1
+ declare const typeInterfaceMap: {
2
+ array: string;
3
+ belongsTo: string;
4
+ belongsToMany: string;
5
+ boolean: () => {
6
+ interface: string;
7
+ uiSchema: {
8
+ type: string;
9
+ 'x-component': string;
10
+ };
11
+ };
12
+ context: string;
13
+ date: () => {
14
+ interface: string;
15
+ uiSchema: {
16
+ 'x-component': string;
17
+ 'x-component-props': {
18
+ dateFormat: string;
19
+ showTime: boolean;
20
+ };
21
+ };
22
+ };
23
+ hasMany: string;
24
+ hasOne: string;
25
+ json: () => {
26
+ interface: string;
27
+ uiSchema: {
28
+ 'x-component': string;
29
+ 'x-component-props': {
30
+ autoSize: {
31
+ minRows: number;
32
+ };
33
+ };
34
+ default: any;
35
+ };
36
+ };
37
+ jsonb: () => {
38
+ interface: string;
39
+ uiSchema: {
40
+ 'x-component': string;
41
+ 'x-component-props': {
42
+ autoSize: {
43
+ minRows: number;
44
+ };
45
+ };
46
+ default: any;
47
+ };
48
+ };
49
+ integer: () => {
50
+ interface: string;
51
+ uiSchema: {
52
+ type: string;
53
+ 'x-component': string;
54
+ 'x-component-props': {
55
+ stringMode: boolean;
56
+ step: string;
57
+ };
58
+ 'x-validator': string;
59
+ };
60
+ };
61
+ bigInt: (columnInfo: any) => {
62
+ interface: string;
63
+ uiSchema: {
64
+ 'x-component': string;
65
+ 'x-component-props': {
66
+ style: {
67
+ width: string;
68
+ };
69
+ };
70
+ };
71
+ };
72
+ float: () => {
73
+ interface: string;
74
+ uiSchema: {
75
+ type: string;
76
+ 'x-component': string;
77
+ 'x-component-props': {
78
+ stringMode: boolean;
79
+ step: string;
80
+ };
81
+ };
82
+ };
83
+ double: () => {
84
+ interface: string;
85
+ uiSchema: {
86
+ type: string;
87
+ 'x-component': string;
88
+ 'x-component-props': {
89
+ stringMode: boolean;
90
+ step: string;
91
+ };
92
+ };
93
+ };
94
+ real: () => {
95
+ interface: string;
96
+ uiSchema: {
97
+ type: string;
98
+ 'x-component': string;
99
+ 'x-component-props': {
100
+ stringMode: boolean;
101
+ step: string;
102
+ };
103
+ };
104
+ };
105
+ decimal: () => {
106
+ interface: string;
107
+ uiSchema: {
108
+ type: string;
109
+ 'x-component': string;
110
+ 'x-component-props': {
111
+ stringMode: boolean;
112
+ step: string;
113
+ };
114
+ };
115
+ };
116
+ password: () => {
117
+ interface: string;
118
+ hidden: boolean;
119
+ uiSchema: {
120
+ type: string;
121
+ 'x-component': string;
122
+ };
123
+ };
124
+ radio: string;
125
+ set: string;
126
+ sort: string;
127
+ string: () => {
128
+ interface: string;
129
+ uiSchema: {
130
+ 'x-component': string;
131
+ 'x-component-props': {
132
+ style: {
133
+ width: string;
134
+ };
135
+ };
136
+ };
137
+ };
138
+ text: () => {
139
+ interface: string;
140
+ uiSchema: {
141
+ type: string;
142
+ 'x-component': string;
143
+ };
144
+ };
145
+ time: () => {
146
+ interface: string;
147
+ uiSchema: {
148
+ type: string;
149
+ 'x-component': string;
150
+ 'x-component-props': {
151
+ format: string;
152
+ };
153
+ };
154
+ };
155
+ uid: () => {
156
+ interface: string;
157
+ uiSchema: {
158
+ 'x-component': string;
159
+ 'x-component-props': {
160
+ style: {
161
+ width: string;
162
+ };
163
+ };
164
+ };
165
+ };
166
+ uuid: () => {
167
+ interface: string;
168
+ uiSchema: {
169
+ 'x-component': string;
170
+ 'x-component-props': {
171
+ style: {
172
+ width: string;
173
+ };
174
+ };
175
+ };
176
+ };
177
+ virtual: string;
178
+ point: string;
179
+ polygon: string;
180
+ lineString: string;
181
+ circle: string;
182
+ };
183
+ export default typeInterfaceMap;
@@ -0,0 +1,243 @@
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 type_interface_map_exports = {};
19
+ __export(type_interface_map_exports, {
20
+ default: () => type_interface_map_default
21
+ });
22
+ module.exports = __toCommonJS(type_interface_map_exports);
23
+ const typeInterfaceMap = {
24
+ array: "",
25
+ belongsTo: "",
26
+ belongsToMany: "",
27
+ boolean: () => {
28
+ return {
29
+ interface: "checkbox",
30
+ uiSchema: {
31
+ type: "boolean",
32
+ "x-component": "Checkbox"
33
+ }
34
+ };
35
+ },
36
+ context: "",
37
+ date: () => {
38
+ return {
39
+ interface: "datetime",
40
+ uiSchema: {
41
+ "x-component": "DatePicker",
42
+ "x-component-props": {
43
+ dateFormat: "YYYY-MM-DD",
44
+ showTime: false
45
+ }
46
+ }
47
+ };
48
+ },
49
+ hasMany: "",
50
+ hasOne: "",
51
+ json: () => {
52
+ return {
53
+ interface: "json",
54
+ uiSchema: {
55
+ "x-component": "Input.JSON",
56
+ "x-component-props": {
57
+ autoSize: {
58
+ minRows: 5
59
+ // maxRows: 20,
60
+ }
61
+ },
62
+ default: null
63
+ }
64
+ };
65
+ },
66
+ jsonb: () => {
67
+ return {
68
+ interface: "json",
69
+ uiSchema: {
70
+ "x-component": "Input.JSON",
71
+ "x-component-props": {
72
+ autoSize: {
73
+ minRows: 5
74
+ // maxRows: 20,
75
+ }
76
+ },
77
+ default: null
78
+ }
79
+ };
80
+ },
81
+ integer: () => ({
82
+ interface: "integer",
83
+ // name,
84
+ uiSchema: {
85
+ type: "number",
86
+ // title,
87
+ "x-component": "InputNumber",
88
+ "x-component-props": {
89
+ stringMode: true,
90
+ step: "1"
91
+ },
92
+ "x-validator": "integer"
93
+ }
94
+ }),
95
+ bigInt: (columnInfo) => {
96
+ return {
97
+ interface: "integer",
98
+ uiSchema: {
99
+ "x-component": "InputNumber",
100
+ "x-component-props": {
101
+ style: {
102
+ width: "100%"
103
+ }
104
+ }
105
+ }
106
+ };
107
+ },
108
+ float: () => {
109
+ return {
110
+ interface: "number",
111
+ uiSchema: {
112
+ type: "number",
113
+ // title,
114
+ "x-component": "InputNumber",
115
+ "x-component-props": {
116
+ stringMode: true,
117
+ step: "1"
118
+ }
119
+ }
120
+ };
121
+ },
122
+ double: () => {
123
+ return {
124
+ interface: "number",
125
+ uiSchema: {
126
+ type: "number",
127
+ // title,
128
+ "x-component": "InputNumber",
129
+ "x-component-props": {
130
+ stringMode: true,
131
+ step: "1"
132
+ }
133
+ }
134
+ };
135
+ },
136
+ real: () => {
137
+ return {
138
+ interface: "number",
139
+ uiSchema: {
140
+ type: "number",
141
+ // title,
142
+ "x-component": "InputNumber",
143
+ "x-component-props": {
144
+ stringMode: true,
145
+ step: "1"
146
+ }
147
+ }
148
+ };
149
+ },
150
+ decimal: () => {
151
+ return {
152
+ interface: "number",
153
+ uiSchema: {
154
+ type: "number",
155
+ // title,
156
+ "x-component": "InputNumber",
157
+ "x-component-props": {
158
+ stringMode: true,
159
+ step: "1"
160
+ }
161
+ }
162
+ };
163
+ },
164
+ password: () => ({
165
+ interface: "password",
166
+ hidden: true,
167
+ // name,
168
+ uiSchema: {
169
+ type: "string",
170
+ // title,
171
+ "x-component": "Password"
172
+ }
173
+ }),
174
+ radio: "",
175
+ set: "",
176
+ sort: "",
177
+ string: () => {
178
+ return {
179
+ interface: "input",
180
+ uiSchema: {
181
+ "x-component": "Input",
182
+ "x-component-props": {
183
+ style: {
184
+ width: "100%"
185
+ }
186
+ }
187
+ }
188
+ };
189
+ },
190
+ text: () => {
191
+ return {
192
+ interface: "textarea",
193
+ // name,
194
+ uiSchema: {
195
+ type: "string",
196
+ "x-component": "Input.TextArea"
197
+ }
198
+ };
199
+ },
200
+ time: () => ({
201
+ interface: "time",
202
+ // name,
203
+ uiSchema: {
204
+ type: "string",
205
+ "x-component": "TimePicker",
206
+ "x-component-props": {
207
+ format: "HH:mm:ss"
208
+ }
209
+ }
210
+ }),
211
+ uid: () => {
212
+ return {
213
+ interface: "input",
214
+ uiSchema: {
215
+ "x-component": "Input",
216
+ "x-component-props": {
217
+ style: {
218
+ width: "100%"
219
+ }
220
+ }
221
+ }
222
+ };
223
+ },
224
+ uuid: () => {
225
+ return {
226
+ interface: "uuid",
227
+ uiSchema: {
228
+ "x-component": "Input",
229
+ "x-component-props": {
230
+ style: {
231
+ width: "100%"
232
+ }
233
+ }
234
+ }
235
+ };
236
+ },
237
+ virtual: "",
238
+ point: "",
239
+ polygon: "",
240
+ lineString: "",
241
+ circle: ""
242
+ };
243
+ var type_interface_map_default = typeInterfaceMap;
@@ -0,0 +1 @@
1
+ export declare function showUniqueIndexes(tableInfo2: any): string;
@@ -0,0 +1,48 @@
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 utils_exports = {};
19
+ __export(utils_exports, {
20
+ showUniqueIndexes: () => showUniqueIndexes
21
+ });
22
+ module.exports = __toCommonJS(utils_exports);
23
+ function showUniqueIndexes(tableInfo2) {
24
+ return `
25
+ SELECT
26
+ tc.constraint_schema,
27
+ tc.constraint_name,
28
+ tc.table_name,
29
+ kcu.column_name,
30
+ CASE WHEN (SELECT COUNT(*)
31
+ FROM information_schema.key_column_usage kcu2
32
+ WHERE kcu2.constraint_name = tc.constraint_name
33
+ AND kcu2.table_schema = tc.constraint_schema) = 1 THEN TRUE
34
+ ELSE FALSE END AS is_single_column
35
+ FROM information_schema.table_constraints AS tc
36
+ JOIN information_schema.key_column_usage AS kcu
37
+ ON tc.constraint_name = kcu.constraint_name
38
+ AND tc.table_schema = kcu.table_schema
39
+ WHERE tc.constraint_type = 'UNIQUE'
40
+ AND tc.table_name = '"${tableInfo2.tableName}"'
41
+ AND tc.table_schema = '${tableInfo2.schema || "public"}'
42
+ ORDER BY tc.constraint_name, kcu.column_name;
43
+ `;
44
+ }
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ showUniqueIndexes
48
+ });
@@ -0,0 +1,13 @@
1
+ import Application, { Plugin, PluginOptions } from '@tachybase/server';
2
+ export declare class PluginExternalDataSourceServer extends Plugin {
3
+ constructor(app: Application, options?: PluginOptions);
4
+ afterAdd(): Promise<void>;
5
+ beforeLoad(): Promise<void>;
6
+ beforeEnable(): Promise<void>;
7
+ load(): Promise<void>;
8
+ install(): Promise<void>;
9
+ afterEnable(): Promise<void>;
10
+ afterDisable(): Promise<void>;
11
+ remove(): Promise<void>;
12
+ }
13
+ export default PluginExternalDataSourceServer;
@@ -0,0 +1,60 @@
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 plugin_exports = {};
19
+ __export(plugin_exports, {
20
+ PluginExternalDataSourceServer: () => PluginExternalDataSourceServer,
21
+ default: () => plugin_default
22
+ });
23
+ module.exports = __toCommonJS(plugin_exports);
24
+ var import_server = require("@tachybase/server");
25
+ var import_plugin = require("./http/plugin");
26
+ var import_mysql_data_source = require("./mysql/mysql-data-source");
27
+ var import_postgres_data_source = require("./pg/postgres-data-source");
28
+ class PluginExternalDataSourceServer extends import_server.Plugin {
29
+ constructor(app, options) {
30
+ super(app, options);
31
+ this.addFeature(import_plugin.PluginHttpDatasource);
32
+ }
33
+ async afterAdd() {
34
+ }
35
+ async beforeLoad() {
36
+ this.app.dataSourceManager.factory.register("postgres", import_postgres_data_source.PostgresDataSource);
37
+ this.app.dataSourceManager.factory.register("mysql", import_mysql_data_source.MySQLDataSource);
38
+ }
39
+ async beforeEnable() {
40
+ const plugin = this.pm.get("data-source");
41
+ if (!plugin.enabled) {
42
+ throw new Error(`${this.name} plugin need data source module enabled`);
43
+ }
44
+ }
45
+ async load() {
46
+ }
47
+ async install() {
48
+ }
49
+ async afterEnable() {
50
+ }
51
+ async afterDisable() {
52
+ }
53
+ async remove() {
54
+ }
55
+ }
56
+ var plugin_default = PluginExternalDataSourceServer;
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ PluginExternalDataSourceServer
60
+ });
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@tachybase/plugin-data-source-common",
3
+ "version": "0.23.8",
4
+ "main": "dist/server/index.js",
5
+ "dependencies": {
6
+ "@ant-design/icons": "^5.5.2",
7
+ "antd": "5.22.5",
8
+ "lodash": "^4.17.21",
9
+ "mysql2": "^3.11.5",
10
+ "pg": "^8.13.1",
11
+ "react-i18next": "^15.2.0",
12
+ "react-router-dom": "6.28.1"
13
+ },
14
+ "devDependencies": {
15
+ "@types/lodash": "^4.17.13"
16
+ },
17
+ "peerDependencies": {
18
+ "@tachybase/client": "0.23.8",
19
+ "@tachybase/schema": "0.23.8",
20
+ "@tachybase/database": "0.23.8",
21
+ "@tachybase/components": "0.23.8",
22
+ "@tachybase/utils": "0.23.8",
23
+ "@tachybase/test": "0.23.8",
24
+ "@tachybase/server": "0.23.8",
25
+ "@tachybase/data-source": "0.23.8"
26
+ },
27
+ "description.zh-CN": "支持更多的数据源",
28
+ "displayName.zh-CN": "外部数据源支持",
29
+ "scripts": {
30
+ "build": "tachybase-build --no-dts @tachybase/plugin-data-source-common"
31
+ }
32
+ }