@nocobase/data-source-manager 2.0.0-alpha.21 → 2.0.0-alpha.23

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.
@@ -8,11 +8,12 @@
8
8
  */
9
9
  import { DataSource } from './data-source';
10
10
  import { DataSourceManager } from './data-source-manager';
11
+ import { DataSourceConstructor } from './types';
11
12
  export declare class DataSourceFactory {
12
13
  protected dataSourceManager: DataSourceManager;
13
- collectionTypes: Map<string, typeof DataSource>;
14
+ collectionTypes: Map<string, DataSourceConstructor>;
14
15
  constructor(dataSourceManager: DataSourceManager);
15
- register(type: string, dataSourceClass: typeof DataSource): void;
16
- getClass(type: string): typeof DataSource;
17
- create(type: string, options?: any): DataSource;
16
+ register(type: string, dataSourceClass: DataSourceConstructor): void;
17
+ getClass<T extends DataSource = DataSource>(type: string): DataSourceConstructor<T>;
18
+ create<T extends DataSource = DataSource>(type: string, options?: any): T;
18
19
  }
@@ -43,7 +43,7 @@ const _DataSourceFactory = class _DataSourceFactory {
43
43
  }
44
44
  create(type, options = {}) {
45
45
  var _a;
46
- const klass = this.collectionTypes.get(type);
46
+ const klass = this.getClass(type);
47
47
  if (!klass) {
48
48
  throw new Error(`Data source type "${type}" not found`);
49
49
  }
@@ -10,6 +10,7 @@ import { Logger, LoggerOptions } from '@nocobase/logger';
10
10
  import { ToposortOptions } from '@nocobase/utils';
11
11
  import { DataSource } from './data-source';
12
12
  import { DataSourceFactory } from './data-source-factory';
13
+ import { DataSourceConstructor } from './types';
13
14
  type DataSourceHook = (dataSource: DataSource) => void;
14
15
  type DataSourceManagerOptions = {
15
16
  logger?: LoggerOptions | Logger;
@@ -30,8 +31,8 @@ export declare class DataSourceManager {
30
31
  add(dataSource: DataSource, options?: any): Promise<void>;
31
32
  use(fn: any, options?: ToposortOptions): void;
32
33
  middleware(): (ctx: any, next: any) => Promise<void>;
33
- registerDataSourceType(type: string, DataSourceClass: typeof DataSource): void;
34
- getDataSourceType(type: string): typeof DataSource | undefined;
34
+ registerDataSourceType(type: string, DataSourceClass: DataSourceConstructor): void;
35
+ getDataSourceType(type: string): DataSourceConstructor | undefined;
35
36
  buildDataSourceByType(type: string, options?: any): DataSource;
36
37
  beforeAddDataSource(hook: DataSourceHook): void;
37
38
  afterAddDataSource(hook: DataSourceHook): void;
@@ -0,0 +1,26 @@
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 { Database } from '@nocobase/database';
10
+ import { DatabaseIntrospector } from './database-introspector/database-introspector';
11
+ import { DataSource } from './data-source';
12
+ import { Context } from '@nocobase/actions';
13
+ import { CollectionOptions, FieldOptions } from './types';
14
+ export declare abstract class DatabaseDataSource<T extends DatabaseIntrospector = DatabaseIntrospector> extends DataSource {
15
+ introspector: T;
16
+ createDatabaseIntrospector(db: Database): T;
17
+ abstract readTables(): Promise<any>;
18
+ abstract loadTables(ctx: Context, tables: string[]): Promise<any>;
19
+ mergeWithLoadedCollections(collections: CollectionOptions[], loadedCollections: {
20
+ [name: string]: {
21
+ name: string;
22
+ fields: FieldOptions[];
23
+ };
24
+ }): CollectionOptions[];
25
+ private mergeFieldOptions;
26
+ }
@@ -0,0 +1,106 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var database_data_source_exports = {};
29
+ __export(database_data_source_exports, {
30
+ DatabaseDataSource: () => DatabaseDataSource
31
+ });
32
+ module.exports = __toCommonJS(database_data_source_exports);
33
+ var import_database_introspector = require("./database-introspector/database-introspector");
34
+ var import_postgres_introspector = require("./database-introspector/postgres-introspector");
35
+ var import_mariadb_introspector = require("./database-introspector/mariadb-introspector");
36
+ var import_data_source = require("./data-source");
37
+ const _DatabaseDataSource = class _DatabaseDataSource extends import_data_source.DataSource {
38
+ createDatabaseIntrospector(db) {
39
+ if (db.isPostgresCompatibleDialect()) {
40
+ return new import_postgres_introspector.PostgresIntrospector({
41
+ db
42
+ });
43
+ }
44
+ const dialect = db.sequelize.getDialect();
45
+ switch (dialect) {
46
+ case "mariadb":
47
+ return new import_mariadb_introspector.MariaDBIntrospector({
48
+ db
49
+ });
50
+ default:
51
+ return new import_database_introspector.DatabaseIntrospector({
52
+ db
53
+ });
54
+ }
55
+ }
56
+ mergeWithLoadedCollections(collections, loadedCollections) {
57
+ return collections.map((collection) => {
58
+ const loadedCollection = loadedCollections[collection.name];
59
+ if (!loadedCollection) return collection;
60
+ const collectionFields = collection.fields || [];
61
+ const loadedFieldsObj = Object.fromEntries(
62
+ (loadedCollection.fields || []).map((f) => [f.columnName || f.field || f.name, f])
63
+ );
64
+ const newFields = collectionFields.map((field) => {
65
+ const loadedField = loadedFieldsObj[field.name];
66
+ if (!loadedField) return field;
67
+ if (loadedField.possibleTypes) {
68
+ loadedField.possibleTypes = field.possibleTypes;
69
+ }
70
+ return this.mergeFieldOptions(field, loadedField);
71
+ });
72
+ const loadedAssociationFields = (loadedCollection.fields || []).filter(
73
+ (field) => ["belongsTo", "belongsToMany", "hasMany", "hasOne", "belongsToArray"].includes(field.type)
74
+ );
75
+ newFields.push(...loadedAssociationFields);
76
+ return {
77
+ ...collection,
78
+ ...Object.fromEntries(Object.entries(loadedCollection).filter(([key]) => key !== "fields")),
79
+ fields: newFields
80
+ };
81
+ });
82
+ }
83
+ mergeFieldOptions(fieldOptions, modelOptions) {
84
+ const newOptions = {
85
+ ...fieldOptions,
86
+ ...modelOptions
87
+ };
88
+ if (fieldOptions.rawType && modelOptions.rawType && fieldOptions.rawType !== modelOptions.rawType) {
89
+ newOptions.type = fieldOptions.type;
90
+ newOptions.interface = fieldOptions.interface;
91
+ newOptions.rawType = fieldOptions.rawType;
92
+ }
93
+ for (const key of [.../* @__PURE__ */ new Set([...Object.keys(modelOptions), ...Object.keys(fieldOptions)])]) {
94
+ if (modelOptions[key] === null && fieldOptions[key]) {
95
+ newOptions[key] = fieldOptions[key];
96
+ }
97
+ }
98
+ return newOptions;
99
+ }
100
+ };
101
+ __name(_DatabaseDataSource, "DatabaseDataSource");
102
+ let DatabaseDataSource = _DatabaseDataSource;
103
+ // Annotate the CommonJS export names for ESM import in node:
104
+ 0 && (module.exports = {
105
+ DatabaseDataSource
106
+ });
@@ -0,0 +1,57 @@
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
+ /// <reference types="node" />
10
+ /**
11
+ * This file is part of the NocoBase (R) project.
12
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
13
+ * Authors: NocoBase Team.
14
+ *
15
+ * This program is offered under a commercial license.
16
+ * For more information, see <https://www.nocobase.com/agreement>
17
+ */
18
+ import { Database } from '@nocobase/database';
19
+ import EventEmitter from 'events';
20
+ import { ColumnsDescription } from 'sequelize';
21
+ import { CollectionOptions, FieldInferResult, PartialCollectionOptions, tableInfo } from '../types';
22
+ type GetCollectionOptions = {
23
+ tableInfo: tableInfo;
24
+ localOptions?: PartialCollectionOptions;
25
+ mergedOptions?: PartialCollectionOptions;
26
+ };
27
+ interface DatabaseIntrospectorOptions {
28
+ db: Database;
29
+ typeInterfaceMap?: any;
30
+ }
31
+ export declare class DatabaseIntrospector extends EventEmitter {
32
+ db: Database;
33
+ constructor(options: DatabaseIntrospectorOptions);
34
+ protected getFieldTypeMap(): Record<string, string | Array<string>>;
35
+ protected getTypeInterfaceConfig(type: string): Record<string, any>;
36
+ getTableList(): Promise<string[]>;
37
+ getTableColumnsInfo(tableInfo: tableInfo): Promise<ColumnsDescription>;
38
+ getTableConstraints(tableInfo: tableInfo): Promise<object>;
39
+ getViewList(): Promise<any>;
40
+ excludeViewsOrTables(): any[];
41
+ getTables(options?: any): Promise<string[]>;
42
+ getCollection(options: GetCollectionOptions): Promise<CollectionOptions>;
43
+ tableInfoToCollectionOptions(tableInfo: tableInfo): {
44
+ name: string;
45
+ title: string;
46
+ schema: string;
47
+ tableName: string;
48
+ };
49
+ protected extractTypeFromDefinition(rawType: string): string;
50
+ protected inferFieldTypeByRawType(rawType: string): any;
51
+ protected inferFieldOptionsByRawType(type: string, rawType: string): any;
52
+ protected columnInfoToFieldOptions(columnsInfo: ColumnsDescription, columnName: string, indexes: any): FieldInferResult;
53
+ protected columnAttribute(columnsInfo: ColumnsDescription, columnName: string, indexes: any): any;
54
+ private collectionOptionsByFields;
55
+ private getDefaultInterfaceByType;
56
+ }
57
+ export {};
@@ -0,0 +1,278 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
+ var __export = (target, all) => {
18
+ for (var name in all)
19
+ __defProp(target, name, { get: all[name], enumerable: true });
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (let key of __getOwnPropNames(from))
24
+ if (!__hasOwnProp.call(to, key) && key !== except)
25
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var database_introspector_exports = {};
39
+ __export(database_introspector_exports, {
40
+ DatabaseIntrospector: () => DatabaseIntrospector
41
+ });
42
+ module.exports = __toCommonJS(database_introspector_exports);
43
+ var import_database = require("@nocobase/database");
44
+ var import_events = __toESM(require("events"));
45
+ var import_lodash = __toESM(require("lodash"));
46
+ var import_mathjs = require("mathjs");
47
+ var import_type_interface_map = require("./type-interface-map");
48
+ const _DatabaseIntrospector = class _DatabaseIntrospector extends import_events.default {
49
+ db;
50
+ constructor(options) {
51
+ super();
52
+ this.db = options.db;
53
+ }
54
+ getFieldTypeMap() {
55
+ return import_database.fieldTypeMap[this.db.sequelize.getDialect()];
56
+ }
57
+ getTypeInterfaceConfig(type) {
58
+ return import_type_interface_map.typeInterfaceMap[type] || {};
59
+ }
60
+ async getTableList() {
61
+ return await this.db.sequelize.getQueryInterface().showAllTables();
62
+ }
63
+ async getTableColumnsInfo(tableInfo2) {
64
+ return this.db.sequelize.getQueryInterface().describeTable(tableInfo2);
65
+ }
66
+ async getTableConstraints(tableInfo2) {
67
+ return this.db.sequelize.getQueryInterface().showIndex(tableInfo2.tableName);
68
+ }
69
+ async getViewList() {
70
+ return (await this.db.queryInterface.listViews()).map((view) => view.name);
71
+ }
72
+ excludeViewsOrTables() {
73
+ return [];
74
+ }
75
+ async getTables(options = {}) {
76
+ var _a;
77
+ let tableList = await this.getTableList();
78
+ const views = ((_a = options.views) == null ? void 0 : _a.length) ? options.views : await this.getViewList();
79
+ tableList = tableList.concat(views);
80
+ tableList = tableList.filter((tableName) => {
81
+ return !this.excludeViewsOrTables().includes(tableName);
82
+ });
83
+ if (this.db.options.tablePrefix) {
84
+ tableList = tableList.filter((tableName) => {
85
+ return tableName.startsWith(this.db.options.tablePrefix);
86
+ });
87
+ }
88
+ return tableList;
89
+ }
90
+ async getCollection(options) {
91
+ const { tableInfo: tableInfo2, localOptions = {}, mergedOptions = {} } = options;
92
+ const columnsInfo = await this.getTableColumnsInfo(tableInfo2);
93
+ const constraints = await this.getTableConstraints(tableInfo2);
94
+ const collectionOptions = this.tableInfoToCollectionOptions(tableInfo2);
95
+ try {
96
+ const fields = Object.keys(columnsInfo).map((columnName) => {
97
+ return this.columnInfoToFieldOptions(columnsInfo, columnName, constraints);
98
+ });
99
+ const unsupportedFields = fields.filter((field) => {
100
+ return field.supported === false;
101
+ });
102
+ const supportFields = fields.filter((field) => {
103
+ return field.supported !== false;
104
+ });
105
+ this.db.logger.debug("Processing collection fields", {
106
+ tableName: tableInfo2.tableName,
107
+ totalFields: fields.length,
108
+ supportedFields: supportFields.length,
109
+ unsupportedFields: unsupportedFields.length
110
+ });
111
+ const remoteCollectionInfo = {
112
+ ...collectionOptions,
113
+ ...this.collectionOptionsByFields(supportFields),
114
+ ...localOptions,
115
+ ...mergedOptions,
116
+ fields: supportFields
117
+ };
118
+ if (unsupportedFields.length) {
119
+ remoteCollectionInfo.unsupportedFields = unsupportedFields;
120
+ this.db.logger.debug("Found unsupported fields", {
121
+ tableName: tableInfo2.tableName,
122
+ fields: unsupportedFields.map((f) => ({ name: f.name, type: f.rawType }))
123
+ });
124
+ }
125
+ if (remoteCollectionInfo.view && !remoteCollectionInfo.filterTargetKey && supportFields.find((field) => field.name === "id")) {
126
+ remoteCollectionInfo.filterTargetKey = "id";
127
+ this.db.logger.debug("Set view filterTargetKey to id", {
128
+ tableName: tableInfo2.tableName
129
+ });
130
+ }
131
+ return remoteCollectionInfo;
132
+ } catch (e) {
133
+ this.db.logger.error("Collection introspection error", {
134
+ tableName: tableInfo2.tableName,
135
+ error: e.message,
136
+ stack: e.stack
137
+ });
138
+ throw new Error(`table ${tableInfo2.tableName} introspection error: ${e.message}`, { cause: e });
139
+ }
140
+ }
141
+ tableInfoToCollectionOptions(tableInfo2) {
142
+ const tableName = tableInfo2.tableName;
143
+ let name = tableName;
144
+ if (this.db.options.tablePrefix) {
145
+ name = tableName.replace(this.db.options.tablePrefix, "");
146
+ }
147
+ name = name.replace(/\./g, "_");
148
+ return {
149
+ name,
150
+ title: name,
151
+ schema: tableInfo2.schema,
152
+ tableName
153
+ };
154
+ }
155
+ extractTypeFromDefinition(rawType) {
156
+ const leftParenIndex = rawType.indexOf("(");
157
+ if (leftParenIndex === -1) {
158
+ return rawType.toLowerCase();
159
+ }
160
+ return rawType.substring(0, leftParenIndex).toLowerCase().trim();
161
+ }
162
+ inferFieldTypeByRawType(rawType) {
163
+ const fieldTypeMap2 = this.getFieldTypeMap();
164
+ const queryType = this.extractTypeFromDefinition(rawType);
165
+ const mappedType = fieldTypeMap2[queryType];
166
+ if ((0, import_mathjs.isArray)(mappedType)) {
167
+ return {
168
+ type: mappedType[0],
169
+ possibleTypes: mappedType
170
+ };
171
+ }
172
+ return {
173
+ type: mappedType
174
+ };
175
+ }
176
+ inferFieldOptionsByRawType(type, rawType) {
177
+ const fieldClass = this.db.fieldTypes.get(type);
178
+ if (!fieldClass) {
179
+ return {};
180
+ }
181
+ if (typeof fieldClass.optionsFromRawType === "function") {
182
+ return fieldClass.optionsFromRawType(rawType);
183
+ }
184
+ return {};
185
+ }
186
+ columnInfoToFieldOptions(columnsInfo, columnName, indexes) {
187
+ const columnInfo = columnsInfo[columnName];
188
+ const name = columnName;
189
+ let fieldOptions = {
190
+ ...this.columnAttribute(columnsInfo, columnName, indexes),
191
+ ...this.inferFieldTypeByRawType(columnInfo.type),
192
+ rawType: columnInfo.type,
193
+ name,
194
+ field: columnName
195
+ };
196
+ Object.assign(fieldOptions, this.inferFieldOptionsByRawType(fieldOptions.type, columnInfo.type));
197
+ if (!fieldOptions.type) {
198
+ return {
199
+ rawType: columnInfo.type,
200
+ name,
201
+ field: columnName,
202
+ supported: false
203
+ };
204
+ }
205
+ const interfaceConfig = this.getDefaultInterfaceByType(columnsInfo, columnName, fieldOptions.type);
206
+ if (typeof interfaceConfig === "string") {
207
+ fieldOptions.interface = interfaceConfig;
208
+ } else {
209
+ fieldOptions = {
210
+ ...fieldOptions,
211
+ ...interfaceConfig
212
+ };
213
+ }
214
+ import_lodash.default.set(fieldOptions, "uiSchema.title", columnName);
215
+ return fieldOptions;
216
+ }
217
+ columnAttribute(columnsInfo, columnName, indexes) {
218
+ const columnInfo = columnsInfo[columnName];
219
+ const attr = {
220
+ type: columnInfo.type,
221
+ allowNull: columnInfo.defaultValue ? true : columnInfo.allowNull,
222
+ primaryKey: columnInfo.primaryKey,
223
+ unique: false,
224
+ autoIncrement: columnInfo.autoIncrement,
225
+ description: columnInfo.comment,
226
+ elementType: columnInfo["elementType"]
227
+ };
228
+ if (columnInfo.defaultValue && typeof columnInfo.defaultValue === "string") {
229
+ const isSerial = columnInfo.defaultValue.match(/^nextval\(/);
230
+ const isUUID = columnInfo.defaultValue.match(/^uuid_generate_v4\(/);
231
+ if (isSerial || isUUID) {
232
+ attr.autoIncrement = true;
233
+ }
234
+ }
235
+ for (const index of indexes) {
236
+ if (index.fields.length == 1 && index.fields[0].attribute == columnName && index.unique) {
237
+ attr.unique = true;
238
+ }
239
+ }
240
+ return attr;
241
+ }
242
+ collectionOptionsByFields(fields) {
243
+ const options = {
244
+ timestamps: false,
245
+ autoGenId: false
246
+ };
247
+ const autoIncrementField = fields.find((field) => field.autoIncrement);
248
+ if (autoIncrementField) {
249
+ options.filterTargetKey = autoIncrementField.name;
250
+ }
251
+ const primaryKeys = fields.filter((field) => field.primaryKey);
252
+ if (primaryKeys.length > 1) {
253
+ options.filterTargetKey = primaryKeys.map((field) => field.name);
254
+ }
255
+ if (!options.filterTargetKey && primaryKeys.length == 1) {
256
+ options.filterTargetKey = primaryKeys[0].name;
257
+ }
258
+ const uniques = fields.filter((field) => field.unique);
259
+ if (!options.filterTargetKey && uniques.length == 1) {
260
+ options.filterTargetKey = uniques[0].name;
261
+ }
262
+ return options;
263
+ }
264
+ getDefaultInterfaceByType(columnsInfo, columnName, type) {
265
+ const interfaceConfig = this.getTypeInterfaceConfig(type);
266
+ let interfaceRes = interfaceConfig;
267
+ if (typeof interfaceConfig === "function") {
268
+ interfaceRes = interfaceConfig(columnsInfo[columnName]);
269
+ }
270
+ return interfaceRes;
271
+ }
272
+ };
273
+ __name(_DatabaseIntrospector, "DatabaseIntrospector");
274
+ let DatabaseIntrospector = _DatabaseIntrospector;
275
+ // Annotate the CommonJS export names for ESM import in node:
276
+ 0 && (module.exports = {
277
+ DatabaseIntrospector
278
+ });
@@ -0,0 +1,12 @@
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 { DatabaseIntrospector } from './database-introspector';
10
+ export declare class MariaDBIntrospector extends DatabaseIntrospector {
11
+ getTableList(): Promise<any[]>;
12
+ }
@@ -0,0 +1,47 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var mariadb_introspector_exports = {};
29
+ __export(mariadb_introspector_exports, {
30
+ MariaDBIntrospector: () => MariaDBIntrospector
31
+ });
32
+ module.exports = __toCommonJS(mariadb_introspector_exports);
33
+ var import_database_introspector = require("./database-introspector");
34
+ const _MariaDBIntrospector = class _MariaDBIntrospector extends import_database_introspector.DatabaseIntrospector {
35
+ async getTableList() {
36
+ const tables = await this.db.sequelize.getQueryInterface().showAllTables();
37
+ return tables.map((table) => {
38
+ return table.tableName;
39
+ });
40
+ }
41
+ };
42
+ __name(_MariaDBIntrospector, "MariaDBIntrospector");
43
+ let MariaDBIntrospector = _MariaDBIntrospector;
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ MariaDBIntrospector
47
+ });
@@ -0,0 +1,19 @@
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 { DatabaseIntrospector } from './database-introspector';
10
+ import { ColumnsDescription } from 'sequelize';
11
+ import { tableInfo } from '../types';
12
+ export declare class PostgresIntrospector extends DatabaseIntrospector {
13
+ getTableConstraints(tableInfo: tableInfo): Promise<object>;
14
+ getTableColumnsInfo(tableInfo: tableInfo): Promise<ColumnsDescription>;
15
+ private getPrimaryKeysOfTable;
16
+ protected columnAttribute(columnsInfo: ColumnsDescription, columnName: string, indexes: any): any;
17
+ private getArrayColumnElementType;
18
+ private appendArrayColumnElementType;
19
+ }