@nocobase/database 1.4.0-alpha.20241023053303 → 1.4.0-alpha.20241024133132
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/lib/database.d.ts +8 -20
- package/lib/database.js +20 -42
- package/lib/dialects/base-dialect.d.ts +20 -0
- package/lib/dialects/base-dialect.js +75 -0
- package/lib/dialects/index.d.ts +9 -0
- package/lib/dialects/index.js +30 -0
- package/lib/dialects/mariadb-dialect.d.ts +17 -0
- package/lib/dialects/mariadb-dialect.js +54 -0
- package/lib/dialects/mysql-dialect.d.ts +17 -0
- package/lib/dialects/mysql-dialect.js +54 -0
- package/lib/dialects/postgres-dialect.d.ts +18 -0
- package/lib/dialects/postgres-dialect.js +77 -0
- package/lib/dialects/sqlite-dialect.d.ts +17 -0
- package/lib/dialects/sqlite-dialect.js +51 -0
- package/lib/helpers.d.ts +2 -1
- package/lib/helpers.js +16 -49
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/query-interface/query-interface-builder.js +3 -0
- package/package.json +4 -4
package/lib/database.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ import { RelationRepository } from './relation-repository/relation-repository';
|
|
|
31
31
|
import { Repository, TargetKey } from './repository';
|
|
32
32
|
import { AfterDefineCollectionListener, BeforeDefineCollectionListener, CreateListener, CreateWithAssociationsListener, DatabaseAfterDefineCollectionEventType, DatabaseAfterRemoveCollectionEventType, DatabaseBeforeDefineCollectionEventType, DatabaseBeforeRemoveCollectionEventType, DestroyListener, EventType, ModelCreateEventTypes, ModelCreateWithAssociationsEventTypes, ModelDestroyEventTypes, ModelSaveEventTypes, ModelSaveWithAssociationsEventTypes, ModelUpdateEventTypes, ModelUpdateWithAssociationsEventTypes, ModelValidateEventTypes, RemoveCollectionListener, SaveListener, SaveWithAssociationsListener, SyncListener, UpdateListener, UpdateWithAssociationsListener, ValidateListener } from './types';
|
|
33
33
|
import { BaseValueParser } from './value-parsers';
|
|
34
|
+
import { BaseDialect } from './dialects/base-dialect';
|
|
34
35
|
export type MergeOptions = merge.Options;
|
|
35
36
|
export interface PendingOptions {
|
|
36
37
|
field: RelationField;
|
|
@@ -65,25 +66,8 @@ export type AddMigrationsOptions = {
|
|
|
65
66
|
directory: string;
|
|
66
67
|
};
|
|
67
68
|
type OperatorFunc = (value: any, ctx?: RegisterOperatorsContext) => any;
|
|
68
|
-
export declare const DialectVersionAccessors: {
|
|
69
|
-
sqlite: {
|
|
70
|
-
sql: string;
|
|
71
|
-
get: (v: string) => string;
|
|
72
|
-
};
|
|
73
|
-
mysql: {
|
|
74
|
-
sql: string;
|
|
75
|
-
get: (v: string) => string;
|
|
76
|
-
};
|
|
77
|
-
mariadb: {
|
|
78
|
-
sql: string;
|
|
79
|
-
get: (v: string) => string;
|
|
80
|
-
};
|
|
81
|
-
postgres: {
|
|
82
|
-
sql: string;
|
|
83
|
-
get: (v: string) => string;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
69
|
export declare class Database extends EventEmitter implements AsyncEmitter {
|
|
70
|
+
static dialects: Map<string, typeof BaseDialect>;
|
|
87
71
|
sequelize: Sequelize;
|
|
88
72
|
migrator: Umzug;
|
|
89
73
|
migrations: Migrations;
|
|
@@ -111,7 +95,10 @@ export declare class Database extends EventEmitter implements AsyncEmitter {
|
|
|
111
95
|
logger: Logger;
|
|
112
96
|
interfaceManager: InterfaceManager;
|
|
113
97
|
collectionFactory: CollectionFactory;
|
|
98
|
+
dialect: BaseDialect;
|
|
114
99
|
emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
|
|
100
|
+
static registerDialect(dialect: typeof BaseDialect): void;
|
|
101
|
+
static getDialect(name: string): typeof BaseDialect;
|
|
115
102
|
constructor(options: DatabaseOptions);
|
|
116
103
|
_instanceId: string;
|
|
117
104
|
get instanceId(): string;
|
|
@@ -128,7 +115,7 @@ export declare class Database extends EventEmitter implements AsyncEmitter {
|
|
|
128
115
|
/**
|
|
129
116
|
* @internal
|
|
130
117
|
*/
|
|
131
|
-
sequelizeOptions(options: any):
|
|
118
|
+
sequelizeOptions(options: any): IDatabaseOptions;
|
|
132
119
|
/**
|
|
133
120
|
* @internal
|
|
134
121
|
*/
|
|
@@ -137,6 +124,7 @@ export declare class Database extends EventEmitter implements AsyncEmitter {
|
|
|
137
124
|
addMigrations(options: AddMigrationsOptions): void;
|
|
138
125
|
inDialect(...dialect: string[]): boolean;
|
|
139
126
|
isMySQLCompatibleDialect(): boolean;
|
|
127
|
+
isPostgresCompatibleDialect(): boolean;
|
|
140
128
|
/**
|
|
141
129
|
* Add collection to database
|
|
142
130
|
* @param options
|
|
@@ -187,7 +175,7 @@ export declare class Database extends EventEmitter implements AsyncEmitter {
|
|
|
187
175
|
/**
|
|
188
176
|
* @internal
|
|
189
177
|
*/
|
|
190
|
-
checkVersion(): Promise<
|
|
178
|
+
checkVersion(): Promise<true | void>;
|
|
191
179
|
/**
|
|
192
180
|
* @internal
|
|
193
181
|
*/
|
package/lib/database.js
CHANGED
|
@@ -13,6 +13,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
13
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
14
|
var __getProtoOf = Object.getPrototypeOf;
|
|
15
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
16
17
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
18
|
var __export = (target, all) => {
|
|
18
19
|
for (var name in all)
|
|
@@ -35,10 +36,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
35
36
|
mod
|
|
36
37
|
));
|
|
37
38
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
38
40
|
var database_exports = {};
|
|
39
41
|
__export(database_exports, {
|
|
40
42
|
Database: () => Database,
|
|
41
|
-
DialectVersionAccessors: () => DialectVersionAccessors,
|
|
42
43
|
default: () => database_default,
|
|
43
44
|
defineCollection: () => defineCollection,
|
|
44
45
|
extend: () => extend,
|
|
@@ -55,7 +56,6 @@ var import_lodash = __toESM(require("lodash"));
|
|
|
55
56
|
var import_nanoid = require("nanoid");
|
|
56
57
|
var import_path = require("path");
|
|
57
58
|
var import_safe_json_stringify = __toESM(require("safe-json-stringify"));
|
|
58
|
-
var import_semver = __toESM(require("semver"));
|
|
59
59
|
var import_sequelize = require("sequelize");
|
|
60
60
|
var import_umzug = require("umzug");
|
|
61
61
|
var import_collection_factory = require("./collection-factory");
|
|
@@ -77,33 +77,6 @@ var import_query_interface_builder = __toESM(require("./query-interface/query-in
|
|
|
77
77
|
var import_utils3 = require("./utils");
|
|
78
78
|
var import_value_parsers = require("./value-parsers");
|
|
79
79
|
var import_view_collection = require("./view-collection");
|
|
80
|
-
const DialectVersionAccessors = {
|
|
81
|
-
sqlite: {
|
|
82
|
-
sql: "select sqlite_version() as version",
|
|
83
|
-
get: /* @__PURE__ */ __name((v) => v, "get")
|
|
84
|
-
},
|
|
85
|
-
mysql: {
|
|
86
|
-
sql: "select version() as version",
|
|
87
|
-
get: /* @__PURE__ */ __name((v) => {
|
|
88
|
-
const m = /([\d+.]+)/.exec(v);
|
|
89
|
-
return m[0];
|
|
90
|
-
}, "get")
|
|
91
|
-
},
|
|
92
|
-
mariadb: {
|
|
93
|
-
sql: "select version() as version",
|
|
94
|
-
get: /* @__PURE__ */ __name((v) => {
|
|
95
|
-
const m = /([\d+.]+)/.exec(v);
|
|
96
|
-
return m[0];
|
|
97
|
-
}, "get")
|
|
98
|
-
},
|
|
99
|
-
postgres: {
|
|
100
|
-
sql: "select version() as version",
|
|
101
|
-
get: /* @__PURE__ */ __name((v) => {
|
|
102
|
-
const m = /([\d+.]+)/.exec(v);
|
|
103
|
-
return import_semver.default.minVersion(m[0]).version;
|
|
104
|
-
}, "get")
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
80
|
const _Database = class _Database extends import_events.EventEmitter {
|
|
108
81
|
sequelize;
|
|
109
82
|
migrator;
|
|
@@ -129,8 +102,20 @@ const _Database = class _Database extends import_events.EventEmitter {
|
|
|
129
102
|
logger;
|
|
130
103
|
interfaceManager = new import_interface_manager.InterfaceManager(this);
|
|
131
104
|
collectionFactory = new import_collection_factory.CollectionFactory(this);
|
|
105
|
+
dialect;
|
|
106
|
+
static registerDialect(dialect) {
|
|
107
|
+
this.dialects.set(dialect.dialectName, dialect);
|
|
108
|
+
}
|
|
109
|
+
static getDialect(name) {
|
|
110
|
+
return this.dialects.get(name);
|
|
111
|
+
}
|
|
132
112
|
constructor(options) {
|
|
133
113
|
super();
|
|
114
|
+
const dialectClass = _Database.getDialect(options.dialect);
|
|
115
|
+
if (!dialectClass) {
|
|
116
|
+
throw new Error(`unsupported dialect ${options.dialect}`);
|
|
117
|
+
}
|
|
118
|
+
this.dialect = new dialectClass();
|
|
134
119
|
const opts = {
|
|
135
120
|
sync: {
|
|
136
121
|
alter: {
|
|
@@ -285,18 +270,7 @@ const _Database = class _Database extends import_events.EventEmitter {
|
|
|
285
270
|
* @internal
|
|
286
271
|
*/
|
|
287
272
|
sequelizeOptions(options) {
|
|
288
|
-
|
|
289
|
-
if (!options.hooks) {
|
|
290
|
-
options.hooks = {};
|
|
291
|
-
}
|
|
292
|
-
if (!options.hooks["afterConnect"]) {
|
|
293
|
-
options.hooks["afterConnect"] = [];
|
|
294
|
-
}
|
|
295
|
-
options.hooks["afterConnect"].push(async (connection) => {
|
|
296
|
-
await connection.query("SET search_path TO public;");
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
return options;
|
|
273
|
+
return this.dialect.getSequelizeOptions(options);
|
|
300
274
|
}
|
|
301
275
|
/**
|
|
302
276
|
* @internal
|
|
@@ -414,6 +388,9 @@ const _Database = class _Database extends import_events.EventEmitter {
|
|
|
414
388
|
isMySQLCompatibleDialect() {
|
|
415
389
|
return this.inDialect("mysql", "mariadb");
|
|
416
390
|
}
|
|
391
|
+
isPostgresCompatibleDialect() {
|
|
392
|
+
return this.inDialect("postgres");
|
|
393
|
+
}
|
|
417
394
|
/**
|
|
418
395
|
* Add collection to database
|
|
419
396
|
* @param options
|
|
@@ -769,6 +746,7 @@ const _Database = class _Database extends import_events.EventEmitter {
|
|
|
769
746
|
}
|
|
770
747
|
};
|
|
771
748
|
__name(_Database, "Database");
|
|
749
|
+
__publicField(_Database, "dialects", /* @__PURE__ */ new Map());
|
|
772
750
|
let Database = _Database;
|
|
773
751
|
function extendCollection(collectionOptions, mergeOptions) {
|
|
774
752
|
return {
|
|
@@ -783,11 +761,11 @@ const defineCollection = /* @__PURE__ */ __name((collectionOptions) => {
|
|
|
783
761
|
return collectionOptions;
|
|
784
762
|
}, "defineCollection");
|
|
785
763
|
(0, import_utils.applyMixins)(Database, [import_utils.AsyncEmitter]);
|
|
764
|
+
(0, import_helpers.registerDialects)();
|
|
786
765
|
var database_default = Database;
|
|
787
766
|
// Annotate the CommonJS export names for ESM import in node:
|
|
788
767
|
0 && (module.exports = {
|
|
789
768
|
Database,
|
|
790
|
-
DialectVersionAccessors,
|
|
791
769
|
defineCollection,
|
|
792
770
|
extend,
|
|
793
771
|
extendCollection
|
|
@@ -0,0 +1,20 @@
|
|
|
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, DatabaseOptions } from '../database';
|
|
10
|
+
export interface DialectVersionGuard {
|
|
11
|
+
sql: string;
|
|
12
|
+
get: (v: string) => string;
|
|
13
|
+
version: string;
|
|
14
|
+
}
|
|
15
|
+
export declare abstract class BaseDialect {
|
|
16
|
+
static dialectName: string;
|
|
17
|
+
getSequelizeOptions(options: DatabaseOptions): import("../database").IDatabaseOptions;
|
|
18
|
+
checkDatabaseVersion(db: Database): Promise<boolean>;
|
|
19
|
+
getVersionGuard(): DialectVersionGuard;
|
|
20
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(from))
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
+
mod
|
|
37
|
+
));
|
|
38
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
40
|
+
var base_dialect_exports = {};
|
|
41
|
+
__export(base_dialect_exports, {
|
|
42
|
+
BaseDialect: () => BaseDialect
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(base_dialect_exports);
|
|
45
|
+
var import_semver = __toESM(require("semver"));
|
|
46
|
+
const _BaseDialect = class _BaseDialect {
|
|
47
|
+
getSequelizeOptions(options) {
|
|
48
|
+
return options;
|
|
49
|
+
}
|
|
50
|
+
async checkDatabaseVersion(db) {
|
|
51
|
+
var _a;
|
|
52
|
+
const versionGuard = this.getVersionGuard();
|
|
53
|
+
const result = await db.sequelize.query(versionGuard.sql, {
|
|
54
|
+
type: "SELECT"
|
|
55
|
+
});
|
|
56
|
+
const version = versionGuard.get((_a = result == null ? void 0 : result[0]) == null ? void 0 : _a.version);
|
|
57
|
+
const versionResult = import_semver.default.satisfies(version, versionGuard.version);
|
|
58
|
+
if (!versionResult) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`to use ${this.constructor.dialectName}, please ensure the version is ${versionGuard.version}, current version is ${version}`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
getVersionGuard() {
|
|
66
|
+
throw new Error("not implemented");
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
__name(_BaseDialect, "BaseDialect");
|
|
70
|
+
__publicField(_BaseDialect, "dialectName");
|
|
71
|
+
let BaseDialect = _BaseDialect;
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
BaseDialect
|
|
75
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export * from './base-dialect';
|
|
@@ -0,0 +1,30 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var dialects_exports = {};
|
|
25
|
+
module.exports = __toCommonJS(dialects_exports);
|
|
26
|
+
__reExport(dialects_exports, require("./base-dialect"), module.exports);
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
...require("./base-dialect")
|
|
30
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { BaseDialect } from './base-dialect';
|
|
10
|
+
export declare class MariadbDialect extends BaseDialect {
|
|
11
|
+
static dialectName: string;
|
|
12
|
+
getVersionGuard(): {
|
|
13
|
+
sql: string;
|
|
14
|
+
get: (v: string) => string;
|
|
15
|
+
version: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
30
|
+
var mariadb_dialect_exports = {};
|
|
31
|
+
__export(mariadb_dialect_exports, {
|
|
32
|
+
MariadbDialect: () => MariadbDialect
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(mariadb_dialect_exports);
|
|
35
|
+
var import_base_dialect = require("./base-dialect");
|
|
36
|
+
const _MariadbDialect = class _MariadbDialect extends import_base_dialect.BaseDialect {
|
|
37
|
+
getVersionGuard() {
|
|
38
|
+
return {
|
|
39
|
+
sql: "select version() as version",
|
|
40
|
+
get: /* @__PURE__ */ __name((v) => {
|
|
41
|
+
const m = /([\d+.]+)/.exec(v);
|
|
42
|
+
return m[0];
|
|
43
|
+
}, "get"),
|
|
44
|
+
version: ">=10.9"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
__name(_MariadbDialect, "MariadbDialect");
|
|
49
|
+
__publicField(_MariadbDialect, "dialectName", "mariadb");
|
|
50
|
+
let MariadbDialect = _MariadbDialect;
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
MariadbDialect
|
|
54
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { BaseDialect } from './base-dialect';
|
|
10
|
+
export declare class MysqlDialect extends BaseDialect {
|
|
11
|
+
static dialectName: string;
|
|
12
|
+
getVersionGuard(): {
|
|
13
|
+
sql: string;
|
|
14
|
+
get: (v: string) => string;
|
|
15
|
+
version: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
30
|
+
var mysql_dialect_exports = {};
|
|
31
|
+
__export(mysql_dialect_exports, {
|
|
32
|
+
MysqlDialect: () => MysqlDialect
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(mysql_dialect_exports);
|
|
35
|
+
var import_base_dialect = require("./base-dialect");
|
|
36
|
+
const _MysqlDialect = class _MysqlDialect extends import_base_dialect.BaseDialect {
|
|
37
|
+
getVersionGuard() {
|
|
38
|
+
return {
|
|
39
|
+
sql: "select version() as version",
|
|
40
|
+
get: /* @__PURE__ */ __name((v) => {
|
|
41
|
+
const m = /([\d+.]+)/.exec(v);
|
|
42
|
+
return m[0];
|
|
43
|
+
}, "get"),
|
|
44
|
+
version: ">=8.0.17"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
__name(_MysqlDialect, "MysqlDialect");
|
|
49
|
+
__publicField(_MysqlDialect, "dialectName", "mysql");
|
|
50
|
+
let MysqlDialect = _MysqlDialect;
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
MysqlDialect
|
|
54
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { BaseDialect } from './base-dialect';
|
|
10
|
+
export declare class PostgresDialect extends BaseDialect {
|
|
11
|
+
static dialectName: string;
|
|
12
|
+
getSequelizeOptions(options: any): any;
|
|
13
|
+
getVersionGuard(): {
|
|
14
|
+
sql: string;
|
|
15
|
+
get: (v: string) => string;
|
|
16
|
+
version: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(from))
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
+
mod
|
|
37
|
+
));
|
|
38
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
40
|
+
var postgres_dialect_exports = {};
|
|
41
|
+
__export(postgres_dialect_exports, {
|
|
42
|
+
PostgresDialect: () => PostgresDialect
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(postgres_dialect_exports);
|
|
45
|
+
var import_semver = __toESM(require("semver"));
|
|
46
|
+
var import_base_dialect = require("./base-dialect");
|
|
47
|
+
const _PostgresDialect = class _PostgresDialect extends import_base_dialect.BaseDialect {
|
|
48
|
+
getSequelizeOptions(options) {
|
|
49
|
+
if (!options.hooks) {
|
|
50
|
+
options.hooks = {};
|
|
51
|
+
}
|
|
52
|
+
if (!options.hooks["afterConnect"]) {
|
|
53
|
+
options.hooks["afterConnect"] = [];
|
|
54
|
+
}
|
|
55
|
+
options.hooks["afterConnect"].push(async (connection) => {
|
|
56
|
+
await connection.query("SET search_path TO public;");
|
|
57
|
+
});
|
|
58
|
+
return options;
|
|
59
|
+
}
|
|
60
|
+
getVersionGuard() {
|
|
61
|
+
return {
|
|
62
|
+
sql: "select version() as version",
|
|
63
|
+
get: /* @__PURE__ */ __name((v) => {
|
|
64
|
+
const m = /([\d+.]+)/.exec(v);
|
|
65
|
+
return import_semver.default.minVersion(m[0]).version;
|
|
66
|
+
}, "get"),
|
|
67
|
+
version: ">=10"
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
__name(_PostgresDialect, "PostgresDialect");
|
|
72
|
+
__publicField(_PostgresDialect, "dialectName", "postgres");
|
|
73
|
+
let PostgresDialect = _PostgresDialect;
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
PostgresDialect
|
|
77
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { BaseDialect } from './base-dialect';
|
|
10
|
+
export declare class SqliteDialect extends BaseDialect {
|
|
11
|
+
static dialectName: string;
|
|
12
|
+
getVersionGuard(): {
|
|
13
|
+
sql: string;
|
|
14
|
+
get: (v: string) => string;
|
|
15
|
+
version: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
30
|
+
var sqlite_dialect_exports = {};
|
|
31
|
+
__export(sqlite_dialect_exports, {
|
|
32
|
+
SqliteDialect: () => SqliteDialect
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(sqlite_dialect_exports);
|
|
35
|
+
var import_base_dialect = require("./base-dialect");
|
|
36
|
+
const _SqliteDialect = class _SqliteDialect extends import_base_dialect.BaseDialect {
|
|
37
|
+
getVersionGuard() {
|
|
38
|
+
return {
|
|
39
|
+
sql: "select sqlite_version() as version",
|
|
40
|
+
get: /* @__PURE__ */ __name((v) => v, "get"),
|
|
41
|
+
version: "3.x"
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
__name(_SqliteDialect, "SqliteDialect");
|
|
46
|
+
__publicField(_SqliteDialect, "dialectName", "sqlite");
|
|
47
|
+
let SqliteDialect = _SqliteDialect;
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
SqliteDialect
|
|
51
|
+
});
|
package/lib/helpers.d.ts
CHANGED
|
@@ -8,4 +8,5 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Database, IDatabaseOptions } from './database';
|
|
10
10
|
export declare function parseDatabaseOptionsFromEnv(): Promise<IDatabaseOptions>;
|
|
11
|
-
export declare function checkDatabaseVersion(db: Database): Promise<
|
|
11
|
+
export declare function checkDatabaseVersion(db: Database): Promise<void>;
|
|
12
|
+
export declare function registerDialects(): void;
|
package/lib/helpers.js
CHANGED
|
@@ -38,11 +38,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
38
38
|
var helpers_exports = {};
|
|
39
39
|
__export(helpers_exports, {
|
|
40
40
|
checkDatabaseVersion: () => checkDatabaseVersion,
|
|
41
|
-
parseDatabaseOptionsFromEnv: () => parseDatabaseOptionsFromEnv
|
|
41
|
+
parseDatabaseOptionsFromEnv: () => parseDatabaseOptionsFromEnv,
|
|
42
|
+
registerDialects: () => registerDialects
|
|
42
43
|
});
|
|
43
44
|
module.exports = __toCommonJS(helpers_exports);
|
|
45
|
+
var import_database = require("./database");
|
|
44
46
|
var import_fs = __toESM(require("fs"));
|
|
45
|
-
var
|
|
47
|
+
var import_mysql_dialect = require("./dialects/mysql-dialect");
|
|
48
|
+
var import_sqlite_dialect = require("./dialects/sqlite-dialect");
|
|
49
|
+
var import_mariadb_dialect = require("./dialects/mariadb-dialect");
|
|
50
|
+
var import_postgres_dialect = require("./dialects/postgres-dialect");
|
|
46
51
|
/* istanbul ignore file -- @preserve */
|
|
47
52
|
function getEnvValue(key, defaultValue) {
|
|
48
53
|
return process.env[key] || defaultValue;
|
|
@@ -121,57 +126,19 @@ function customLogger(queryString, queryObject) {
|
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
128
|
__name(customLogger, "customLogger");
|
|
124
|
-
const dialectVersionAccessors = {
|
|
125
|
-
sqlite: {
|
|
126
|
-
sql: "select sqlite_version() as version",
|
|
127
|
-
get: /* @__PURE__ */ __name((v) => v, "get"),
|
|
128
|
-
version: "3.x"
|
|
129
|
-
},
|
|
130
|
-
mysql: {
|
|
131
|
-
sql: "select version() as version",
|
|
132
|
-
get: /* @__PURE__ */ __name((v) => {
|
|
133
|
-
const m = /([\d+.]+)/.exec(v);
|
|
134
|
-
return m[0];
|
|
135
|
-
}, "get"),
|
|
136
|
-
version: ">=8.0.17"
|
|
137
|
-
},
|
|
138
|
-
mariadb: {
|
|
139
|
-
sql: "select version() as version",
|
|
140
|
-
get: /* @__PURE__ */ __name((v) => {
|
|
141
|
-
const m = /([\d+.]+)/.exec(v);
|
|
142
|
-
return m[0];
|
|
143
|
-
}, "get"),
|
|
144
|
-
version: ">=10.9"
|
|
145
|
-
},
|
|
146
|
-
postgres: {
|
|
147
|
-
sql: "select version() as version",
|
|
148
|
-
get: /* @__PURE__ */ __name((v) => {
|
|
149
|
-
const m = /([\d+.]+)/.exec(v);
|
|
150
|
-
return import_semver.default.minVersion(m[0]).version;
|
|
151
|
-
}, "get"),
|
|
152
|
-
version: ">=10"
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
129
|
async function checkDatabaseVersion(db) {
|
|
156
|
-
|
|
157
|
-
const dialect = db.sequelize.getDialect();
|
|
158
|
-
const accessor = dialectVersionAccessors[dialect];
|
|
159
|
-
if (!accessor) {
|
|
160
|
-
throw new Error(`unsupported dialect ${dialect}`);
|
|
161
|
-
}
|
|
162
|
-
const result = await db.sequelize.query(accessor.sql, {
|
|
163
|
-
type: "SELECT"
|
|
164
|
-
});
|
|
165
|
-
const version = accessor.get((_a = result == null ? void 0 : result[0]) == null ? void 0 : _a.version);
|
|
166
|
-
const versionResult = import_semver.default.satisfies(version, accessor.version);
|
|
167
|
-
if (!versionResult) {
|
|
168
|
-
throw new Error(`to use ${dialect}, please ensure the version is ${accessor.version}`);
|
|
169
|
-
}
|
|
170
|
-
return true;
|
|
130
|
+
await db.dialect.checkDatabaseVersion(db);
|
|
171
131
|
}
|
|
172
132
|
__name(checkDatabaseVersion, "checkDatabaseVersion");
|
|
133
|
+
function registerDialects() {
|
|
134
|
+
[import_sqlite_dialect.SqliteDialect, import_mysql_dialect.MysqlDialect, import_mariadb_dialect.MariadbDialect, import_postgres_dialect.PostgresDialect].forEach((dialect) => {
|
|
135
|
+
import_database.Database.registerDialect(dialect);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
__name(registerDialects, "registerDialects");
|
|
173
139
|
// Annotate the CommonJS export names for ESM import in node:
|
|
174
140
|
0 && (module.exports = {
|
|
175
141
|
checkDatabaseVersion,
|
|
176
|
-
parseDatabaseOptionsFromEnv
|
|
142
|
+
parseDatabaseOptionsFromEnv,
|
|
143
|
+
registerDialects
|
|
177
144
|
});
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -92,6 +92,7 @@ __reExport(src_exports, require("./helpers"), module.exports);
|
|
|
92
92
|
var import_sql_parser = __toESM(require("./sql-parser"));
|
|
93
93
|
__reExport(src_exports, require("./interfaces"), module.exports);
|
|
94
94
|
var import_field_type_map = __toESM(require("./view/field-type-map"));
|
|
95
|
+
__reExport(src_exports, require("./dialects"), module.exports);
|
|
95
96
|
// Annotate the CommonJS export names for ESM import in node:
|
|
96
97
|
0 && (module.exports = {
|
|
97
98
|
BaseError,
|
|
@@ -139,5 +140,6 @@ var import_field_type_map = __toESM(require("./view/field-type-map"));
|
|
|
139
140
|
...require("./view-collection"),
|
|
140
141
|
...require("./view/view-inference"),
|
|
141
142
|
...require("./helpers"),
|
|
142
|
-
...require("./interfaces")
|
|
143
|
+
...require("./interfaces"),
|
|
144
|
+
...require("./dialects")
|
|
143
145
|
});
|
|
@@ -50,6 +50,9 @@ function buildQueryInterface(db) {
|
|
|
50
50
|
postgres: import_postgres_query_interface.default,
|
|
51
51
|
sqlite: import_sqlite_query_interface.default
|
|
52
52
|
};
|
|
53
|
+
if (db.isPostgresCompatibleDialect()) {
|
|
54
|
+
return new import_postgres_query_interface.default(db);
|
|
55
|
+
}
|
|
53
56
|
const dialect = db.options.dialect;
|
|
54
57
|
if (!map[dialect]) {
|
|
55
58
|
return null;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.20241024133132",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"license": "AGPL-3.0",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/logger": "1.4.0-alpha.
|
|
10
|
-
"@nocobase/utils": "1.4.0-alpha.
|
|
9
|
+
"@nocobase/logger": "1.4.0-alpha.20241024133132",
|
|
10
|
+
"@nocobase/utils": "1.4.0-alpha.20241024133132",
|
|
11
11
|
"async-mutex": "^0.3.2",
|
|
12
12
|
"chalk": "^4.1.1",
|
|
13
13
|
"cron-parser": "4.4.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
39
39
|
"directory": "packages/database"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "d127161994b06678d2d41f406fe73221242a1a05"
|
|
42
42
|
}
|