@nocobase/database 1.3.39-beta → 1.4.0-alpha

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 (53) hide show
  1. package/lib/collection.d.ts +3 -2
  2. package/lib/collection.js +6 -0
  3. package/lib/database.d.ts +11 -23
  4. package/lib/database.js +21 -42
  5. package/lib/dialects/base-dialect.d.ts +20 -0
  6. package/lib/dialects/base-dialect.js +75 -0
  7. package/lib/dialects/index.d.ts +9 -0
  8. package/lib/dialects/index.js +30 -0
  9. package/lib/dialects/mariadb-dialect.d.ts +17 -0
  10. package/lib/dialects/mariadb-dialect.js +54 -0
  11. package/lib/dialects/mysql-dialect.d.ts +17 -0
  12. package/lib/dialects/mysql-dialect.js +54 -0
  13. package/lib/dialects/postgres-dialect.d.ts +18 -0
  14. package/lib/dialects/postgres-dialect.js +77 -0
  15. package/lib/dialects/sqlite-dialect.d.ts +17 -0
  16. package/lib/dialects/sqlite-dialect.js +51 -0
  17. package/lib/fields/date-field.d.ts +7 -2
  18. package/lib/fields/date-field.js +89 -0
  19. package/lib/fields/date-only-field.d.ts +15 -0
  20. package/lib/fields/date-only-field.js +45 -0
  21. package/lib/fields/datetime-field.d.ts +15 -0
  22. package/lib/fields/datetime-field.js +41 -0
  23. package/lib/fields/datetime-no-tz-field.d.ts +24 -0
  24. package/lib/fields/datetime-no-tz-field.js +128 -0
  25. package/lib/fields/datetime-tz-field.d.ts +15 -0
  26. package/lib/fields/datetime-tz-field.js +41 -0
  27. package/lib/fields/field.d.ts +1 -1
  28. package/lib/fields/field.js +3 -2
  29. package/lib/fields/index.d.ts +10 -1
  30. package/lib/fields/index.js +11 -1
  31. package/lib/fields/unix-timestamp-field.d.ts +22 -0
  32. package/lib/fields/unix-timestamp-field.js +94 -0
  33. package/lib/helpers.d.ts +2 -1
  34. package/lib/helpers.js +16 -49
  35. package/lib/index.d.ts +1 -0
  36. package/lib/index.js +3 -1
  37. package/lib/model.d.ts +1 -0
  38. package/lib/model.js +12 -0
  39. package/lib/operators/date.js +66 -24
  40. package/lib/options-parser.d.ts +1 -0
  41. package/lib/options-parser.js +32 -9
  42. package/lib/query-interface/query-interface-builder.js +3 -0
  43. package/lib/relation-repository/hasmany-repository.js +8 -11
  44. package/lib/relation-repository/multiple-relation-repository.d.ts +1 -0
  45. package/lib/relation-repository/multiple-relation-repository.js +11 -3
  46. package/lib/relation-repository/relation-repository.d.ts +6 -3
  47. package/lib/relation-repository/relation-repository.js +27 -4
  48. package/lib/repository.d.ts +5 -2
  49. package/lib/repository.js +27 -16
  50. package/lib/update-associations.d.ts +2 -1
  51. package/lib/view/field-type-map.d.ts +2 -2
  52. package/lib/view/field-type-map.js +17 -17
  53. package/package.json +4 -4
@@ -38,7 +38,7 @@ export interface CollectionOptions extends Omit<ModelOptions, 'name' | 'hooks'>
38
38
  inherits?: string[] | string;
39
39
  viewName?: string;
40
40
  writableView?: boolean;
41
- filterTargetKey?: string;
41
+ filterTargetKey?: string | string[];
42
42
  fields?: FieldOptions[];
43
43
  model?: string | ModelStatic<Model>;
44
44
  repository?: string | RepositoryType;
@@ -77,7 +77,8 @@ export declare class Collection<TModelAttributes extends {} = any, TCreationAttr
77
77
  model: ModelStatic<Model>;
78
78
  repository: Repository<TModelAttributes, TCreationAttributes>;
79
79
  constructor(options: CollectionOptions, context: CollectionContext);
80
- get filterTargetKey(): string;
80
+ get filterTargetKey(): string | string[];
81
+ isMultiFilterTargetKey(): boolean;
81
82
  get name(): string;
82
83
  get origin(): string;
83
84
  get titleField(): string;
package/lib/collection.js CHANGED
@@ -111,6 +111,9 @@ const _Collection = class _Collection extends import_events.EventEmitter {
111
111
  get filterTargetKey() {
112
112
  var _a;
113
113
  const targetKey = (_a = this.options) == null ? void 0 : _a.filterTargetKey;
114
+ if (Array.isArray(targetKey)) {
115
+ return targetKey;
116
+ }
114
117
  if (targetKey && this.model.getAttributes()[targetKey]) {
115
118
  return targetKey;
116
119
  }
@@ -119,6 +122,9 @@ const _Collection = class _Collection extends import_events.EventEmitter {
119
122
  }
120
123
  return this.model.primaryKeyAttribute;
121
124
  }
125
+ isMultiFilterTargetKey() {
126
+ return Array.isArray(this.filterTargetKey) && this.filterTargetKey.length > 1;
127
+ }
122
128
  get name() {
123
129
  return this.options.name;
124
130
  }
package/lib/database.d.ts CHANGED
@@ -28,9 +28,10 @@ import { Model } from './model';
28
28
  import { ModelHook } from './model-hook';
29
29
  import QueryInterface from './query-interface/query-interface';
30
30
  import { RelationRepository } from './relation-repository/relation-repository';
31
- import { Repository } from './repository';
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): 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
@@ -153,8 +141,8 @@ export declare class Database extends EventEmitter implements AsyncEmitter {
153
141
  removeCollection(name: string): Collection<any, any>;
154
142
  getModel<M extends Model>(name: string): ModelStatic<M>;
155
143
  getRepository<R extends Repository>(name: string): R;
156
- getRepository<R extends RelationRepository>(name: string, relationId: string | number): R;
157
- getRepository<R extends ArrayFieldRepository>(name: string, relationId: string | number): R;
144
+ getRepository<R extends RelationRepository>(name: string, relationId: TargetKey): R;
145
+ getRepository<R extends ArrayFieldRepository>(name: string, relationId: TargetKey): R;
158
146
  /**
159
147
  * @internal
160
148
  */
@@ -187,7 +175,7 @@ export declare class Database extends EventEmitter implements AsyncEmitter {
187
175
  /**
188
176
  * @internal
189
177
  */
190
- checkVersion(): Promise<boolean>;
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: {
@@ -159,6 +144,7 @@ const _Database = class _Database extends import_events.EventEmitter {
159
144
  opts.storage = (0, import_path.resolve)(process.cwd(), options.storage);
160
145
  }
161
146
  }
147
+ opts.rawTimezone = opts.timezone;
162
148
  if (options.dialect === "sqlite") {
163
149
  delete opts.timezone;
164
150
  } else if (!opts.timezone) {
@@ -284,18 +270,7 @@ const _Database = class _Database extends import_events.EventEmitter {
284
270
  * @internal
285
271
  */
286
272
  sequelizeOptions(options) {
287
- if (options.dialect === "postgres") {
288
- if (!options.hooks) {
289
- options.hooks = {};
290
- }
291
- if (!options.hooks["afterConnect"]) {
292
- options.hooks["afterConnect"] = [];
293
- }
294
- options.hooks["afterConnect"].push(async (connection) => {
295
- await connection.query("SET search_path TO public;");
296
- });
297
- }
298
- return options;
273
+ return this.dialect.getSequelizeOptions(options);
299
274
  }
300
275
  /**
301
276
  * @internal
@@ -413,6 +388,9 @@ const _Database = class _Database extends import_events.EventEmitter {
413
388
  isMySQLCompatibleDialect() {
414
389
  return this.inDialect("mysql", "mariadb");
415
390
  }
391
+ isPostgresCompatibleDialect() {
392
+ return this.inDialect("postgres");
393
+ }
416
394
  /**
417
395
  * Add collection to database
418
396
  * @param options
@@ -768,6 +746,7 @@ const _Database = class _Database extends import_events.EventEmitter {
768
746
  }
769
747
  };
770
748
  __name(_Database, "Database");
749
+ __publicField(_Database, "dialects", /* @__PURE__ */ new Map());
771
750
  let Database = _Database;
772
751
  function extendCollection(collectionOptions, mergeOptions) {
773
752
  return {
@@ -782,11 +761,11 @@ const defineCollection = /* @__PURE__ */ __name((collectionOptions) => {
782
761
  return collectionOptions;
783
762
  }, "defineCollection");
784
763
  (0, import_utils.applyMixins)(Database, [import_utils.AsyncEmitter]);
764
+ (0, import_helpers.registerDialects)();
785
765
  var database_default = Database;
786
766
  // Annotate the CommonJS export names for ESM import in node:
787
767
  0 && (module.exports = {
788
768
  Database,
789
- DialectVersionAccessors,
790
769
  defineCollection,
791
770
  extend,
792
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
+ }