@tachybase/database 0.23.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -0
- package/LICENSE +201 -0
- package/lib/collection-factory.d.ts +17 -0
- package/lib/collection-factory.js +52 -0
- package/lib/collection-group-manager.d.ts +26 -0
- package/lib/collection-group-manager.js +57 -0
- package/lib/collection-importer.d.ts +7 -0
- package/lib/collection-importer.js +74 -0
- package/lib/collection.d.ts +138 -0
- package/lib/collection.js +686 -0
- package/lib/database-utils/index.d.ts +9 -0
- package/lib/database-utils/index.js +71 -0
- package/lib/database-utils/traverseJSON.d.ts +10 -0
- package/lib/database-utils/traverseJSON.js +126 -0
- package/lib/database.d.ts +201 -0
- package/lib/database.js +765 -0
- package/lib/decorators/must-have-filter-decorator.d.ts +2 -0
- package/lib/decorators/must-have-filter-decorator.js +38 -0
- package/lib/decorators/target-collection-decorator.d.ts +2 -0
- package/lib/decorators/target-collection-decorator.js +47 -0
- package/lib/decorators/transaction-decorator.d.ts +1 -0
- package/lib/decorators/transaction-decorator.js +88 -0
- package/lib/eager-loading/eager-loading-tree.d.ts +31 -0
- package/lib/eager-loading/eager-loading-tree.js +439 -0
- package/lib/errors/identifier-error.d.ts +3 -0
- package/lib/errors/identifier-error.js +35 -0
- package/lib/errors/zero-column-table-error.d.ts +2 -0
- package/lib/errors/zero-column-table-error.js +31 -0
- package/lib/features/references-map.d.ts +18 -0
- package/lib/features/references-map.js +109 -0
- package/lib/features/referential-integrity-check.d.ts +8 -0
- package/lib/features/referential-integrity-check.js +83 -0
- package/lib/field-repository/array-field-repository.d.ts +28 -0
- package/lib/field-repository/array-field-repository.js +197 -0
- package/lib/fields/array-field.d.ts +11 -0
- package/lib/fields/array-field.js +57 -0
- package/lib/fields/belongs-to-field.d.ts +17 -0
- package/lib/fields/belongs-to-field.js +154 -0
- package/lib/fields/belongs-to-many-field.d.ts +20 -0
- package/lib/fields/belongs-to-many-field.js +187 -0
- package/lib/fields/boolean-field.d.ts +8 -0
- package/lib/fields/boolean-field.js +36 -0
- package/lib/fields/context-field.d.ts +14 -0
- package/lib/fields/context-field.js +70 -0
- package/lib/fields/date-field.d.ts +13 -0
- package/lib/fields/date-field.js +64 -0
- package/lib/fields/field.d.ts +43 -0
- package/lib/fields/field.js +156 -0
- package/lib/fields/has-inverse-field.d.ts +4 -0
- package/lib/fields/has-inverse-field.js +15 -0
- package/lib/fields/has-many-field.d.ts +68 -0
- package/lib/fields/has-many-field.js +156 -0
- package/lib/fields/has-one-field.d.ts +68 -0
- package/lib/fields/has-one-field.js +150 -0
- package/lib/fields/index.d.ts +46 -0
- package/lib/fields/index.js +65 -0
- package/lib/fields/json-field.d.ts +14 -0
- package/lib/fields/json-field.js +54 -0
- package/lib/fields/nanoid-field.d.ts +13 -0
- package/lib/fields/nanoid-field.js +58 -0
- package/lib/fields/number-field.d.ts +41 -0
- package/lib/fields/number-field.js +85 -0
- package/lib/fields/password-field.d.ts +21 -0
- package/lib/fields/password-field.js +95 -0
- package/lib/fields/radio-field.d.ts +16 -0
- package/lib/fields/radio-field.js +66 -0
- package/lib/fields/relation-field.d.ts +21 -0
- package/lib/fields/relation-field.js +79 -0
- package/lib/fields/set-field.d.ts +10 -0
- package/lib/fields/set-field.js +46 -0
- package/lib/fields/sort-field.d.ts +16 -0
- package/lib/fields/sort-field.js +187 -0
- package/lib/fields/string-field.d.ts +8 -0
- package/lib/fields/string-field.js +36 -0
- package/lib/fields/text-field.d.ts +8 -0
- package/lib/fields/text-field.js +36 -0
- package/lib/fields/time-field.d.ts +8 -0
- package/lib/fields/time-field.js +36 -0
- package/lib/fields/uid-field.d.ts +13 -0
- package/lib/fields/uid-field.js +63 -0
- package/lib/fields/uuid-field.d.ts +9 -0
- package/lib/fields/uuid-field.js +45 -0
- package/lib/fields/virtual-field.d.ts +8 -0
- package/lib/fields/virtual-field.js +36 -0
- package/lib/filter-match.d.ts +1 -0
- package/lib/filter-match.js +66 -0
- package/lib/filter-parser.d.ts +21 -0
- package/lib/filter-parser.js +230 -0
- package/lib/helpers.d.ts +3 -0
- package/lib/helpers.js +167 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +114 -0
- package/lib/inherited-collection.d.ts +14 -0
- package/lib/inherited-collection.js +138 -0
- package/lib/inherited-map.d.ts +21 -0
- package/lib/inherited-map.js +113 -0
- package/lib/inherited-sync-runner.d.ts +4 -0
- package/lib/inherited-sync-runner.js +175 -0
- package/lib/listeners/adjacency-list.d.ts +2 -0
- package/lib/listeners/adjacency-list.js +42 -0
- package/lib/listeners/append-child-collection-name-after-repository-find.d.ts +6 -0
- package/lib/listeners/append-child-collection-name-after-repository-find.js +66 -0
- package/lib/listeners/index.d.ts +2 -0
- package/lib/listeners/index.js +33 -0
- package/lib/magic-attribute-model.d.ts +8 -0
- package/lib/magic-attribute-model.js +203 -0
- package/lib/migration.d.ts +35 -0
- package/lib/migration.js +103 -0
- package/lib/mock-database.d.ts +25 -0
- package/lib/mock-database.js +126 -0
- package/lib/model-hook.d.ts +12 -0
- package/lib/model-hook.js +92 -0
- package/lib/model.d.ts +23 -0
- package/lib/model.js +152 -0
- package/lib/operators/array.d.ts +2 -0
- package/lib/operators/array.js +158 -0
- package/lib/operators/association.d.ts +2 -0
- package/lib/operators/association.js +35 -0
- package/lib/operators/boolean.d.ts +2 -0
- package/lib/operators/boolean.js +38 -0
- package/lib/operators/child-collection.d.ts +2 -0
- package/lib/operators/child-collection.js +67 -0
- package/lib/operators/date.d.ts +2 -0
- package/lib/operators/date.js +140 -0
- package/lib/operators/empty.d.ts +5 -0
- package/lib/operators/empty.js +89 -0
- package/lib/operators/eq.d.ts +2 -0
- package/lib/operators/eq.js +35 -0
- package/lib/operators/index.d.ts +5 -0
- package/lib/operators/index.js +56 -0
- package/lib/operators/jsonb.d.ts +2 -0
- package/lib/operators/jsonb.js +50 -0
- package/lib/operators/ne.d.ts +2 -0
- package/lib/operators/ne.js +40 -0
- package/lib/operators/notIn.d.ts +2 -0
- package/lib/operators/notIn.js +33 -0
- package/lib/operators/string.d.ts +2 -0
- package/lib/operators/string.js +109 -0
- package/lib/operators/utils.d.ts +4 -0
- package/lib/operators/utils.js +40 -0
- package/lib/options-parser.d.ts +37 -0
- package/lib/options-parser.js +332 -0
- package/lib/playground.d.ts +1 -0
- package/lib/playground.js +43 -0
- package/lib/query-interface/mysql-query-interface.d.ts +35 -0
- package/lib/query-interface/mysql-query-interface.js +122 -0
- package/lib/query-interface/postgres-query-interface.d.ts +32 -0
- package/lib/query-interface/postgres-query-interface.js +189 -0
- package/lib/query-interface/query-interface-builder.d.ts +2 -0
- package/lib/query-interface/query-interface-builder.js +46 -0
- package/lib/query-interface/query-interface.d.ts +42 -0
- package/lib/query-interface/query-interface.js +46 -0
- package/lib/query-interface/sqlite-query-interface.d.ts +35 -0
- package/lib/query-interface/sqlite-query-interface.js +131 -0
- package/lib/relation-repository/belongs-to-many-repository.d.ts +21 -0
- package/lib/relation-repository/belongs-to-many-repository.js +280 -0
- package/lib/relation-repository/belongs-to-repository.d.ts +6 -0
- package/lib/relation-repository/belongs-to-repository.js +39 -0
- package/lib/relation-repository/hasmany-repository.d.ts +10 -0
- package/lib/relation-repository/hasmany-repository.js +182 -0
- package/lib/relation-repository/hasone-repository.d.ts +6 -0
- package/lib/relation-repository/hasone-repository.js +39 -0
- package/lib/relation-repository/multiple-relation-repository.d.ts +20 -0
- package/lib/relation-repository/multiple-relation-repository.js +229 -0
- package/lib/relation-repository/relation-repository.d.ts +29 -0
- package/lib/relation-repository/relation-repository.js +202 -0
- package/lib/relation-repository/single-relation-repository.d.ts +25 -0
- package/lib/relation-repository/single-relation-repository.js +162 -0
- package/lib/relation-repository/types.d.ts +7 -0
- package/lib/relation-repository/types.js +15 -0
- package/lib/repositories/tree-repository/adjacency-list-repository.d.ts +18 -0
- package/lib/repositories/tree-repository/adjacency-list-repository.js +183 -0
- package/lib/repositories/view-repository.d.ts +3 -0
- package/lib/repositories/view-repository.js +32 -0
- package/lib/repository.d.ts +206 -0
- package/lib/repository.js +597 -0
- package/lib/sql-collection/index.d.ts +2 -0
- package/lib/sql-collection/index.js +23 -0
- package/lib/sql-collection/query-generator.d.ts +10 -0
- package/lib/sql-collection/query-generator.js +70 -0
- package/lib/sql-collection/sql-collection.d.ts +7 -0
- package/lib/sql-collection/sql-collection.js +69 -0
- package/lib/sql-collection/sql-model.d.ts +16 -0
- package/lib/sql-collection/sql-model.js +168 -0
- package/lib/sql-parser/index.d.ts +10 -0
- package/lib/sql-parser/index.js +10699 -0
- package/lib/sql-parser/postgres.d.ts +10 -0
- package/lib/sql-parser/postgres.js +31506 -0
- package/lib/sql-parser/sql.pegjs +1297 -0
- package/lib/sync-runner.d.ts +30 -0
- package/lib/sync-runner.js +277 -0
- package/lib/types.d.ts +49 -0
- package/lib/types.js +15 -0
- package/lib/update-associations.d.ts +60 -0
- package/lib/update-associations.js +405 -0
- package/lib/update-guard.d.ts +28 -0
- package/lib/update-guard.js +202 -0
- package/lib/utils.d.ts +7 -0
- package/lib/utils.js +127 -0
- package/lib/value-parsers/array-value-parser.d.ts +8 -0
- package/lib/value-parsers/array-value-parser.js +58 -0
- package/lib/value-parsers/base-value-parser.d.ts +12 -0
- package/lib/value-parsers/base-value-parser.js +63 -0
- package/lib/value-parsers/boolean-value-parser.d.ts +4 -0
- package/lib/value-parsers/boolean-value-parser.js +52 -0
- package/lib/value-parsers/date-value-parser.d.ts +5 -0
- package/lib/value-parsers/date-value-parser.js +88 -0
- package/lib/value-parsers/index.d.ts +12 -0
- package/lib/value-parsers/index.js +78 -0
- package/lib/value-parsers/json-value-parser.d.ts +4 -0
- package/lib/value-parsers/json-value-parser.js +47 -0
- package/lib/value-parsers/number-value-parser.d.ts +4 -0
- package/lib/value-parsers/number-value-parser.js +58 -0
- package/lib/value-parsers/string-value-parser.d.ts +8 -0
- package/lib/value-parsers/string-value-parser.js +64 -0
- package/lib/value-parsers/to-many-value-parser.d.ts +13 -0
- package/lib/value-parsers/to-many-value-parser.js +108 -0
- package/lib/value-parsers/to-one-value-parser.d.ts +4 -0
- package/lib/value-parsers/to-one-value-parser.js +48 -0
- package/lib/view/field-type-map.d.ts +97 -0
- package/lib/view/field-type-map.js +90 -0
- package/lib/view/view-inference.d.ts +32 -0
- package/lib/view/view-inference.js +146 -0
- package/lib/view-collection.d.ts +6 -0
- package/lib/view-collection.js +45 -0
- package/package.json +38 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var fields_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(fields_exports);
|
|
17
|
+
__reExport(fields_exports, require("./array-field"), module.exports);
|
|
18
|
+
__reExport(fields_exports, require("./belongs-to-field"), module.exports);
|
|
19
|
+
__reExport(fields_exports, require("./belongs-to-many-field"), module.exports);
|
|
20
|
+
__reExport(fields_exports, require("./boolean-field"), module.exports);
|
|
21
|
+
__reExport(fields_exports, require("./context-field"), module.exports);
|
|
22
|
+
__reExport(fields_exports, require("./date-field"), module.exports);
|
|
23
|
+
__reExport(fields_exports, require("./field"), module.exports);
|
|
24
|
+
__reExport(fields_exports, require("./has-many-field"), module.exports);
|
|
25
|
+
__reExport(fields_exports, require("./has-one-field"), module.exports);
|
|
26
|
+
__reExport(fields_exports, require("./json-field"), module.exports);
|
|
27
|
+
__reExport(fields_exports, require("./number-field"), module.exports);
|
|
28
|
+
__reExport(fields_exports, require("./password-field"), module.exports);
|
|
29
|
+
__reExport(fields_exports, require("./radio-field"), module.exports);
|
|
30
|
+
__reExport(fields_exports, require("./relation-field"), module.exports);
|
|
31
|
+
__reExport(fields_exports, require("./set-field"), module.exports);
|
|
32
|
+
__reExport(fields_exports, require("./sort-field"), module.exports);
|
|
33
|
+
__reExport(fields_exports, require("./string-field"), module.exports);
|
|
34
|
+
__reExport(fields_exports, require("./text-field"), module.exports);
|
|
35
|
+
__reExport(fields_exports, require("./time-field"), module.exports);
|
|
36
|
+
__reExport(fields_exports, require("./uid-field"), module.exports);
|
|
37
|
+
__reExport(fields_exports, require("./uuid-field"), module.exports);
|
|
38
|
+
__reExport(fields_exports, require("./virtual-field"), module.exports);
|
|
39
|
+
__reExport(fields_exports, require("./nanoid-field"), module.exports);
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
...require("./array-field"),
|
|
43
|
+
...require("./belongs-to-field"),
|
|
44
|
+
...require("./belongs-to-many-field"),
|
|
45
|
+
...require("./boolean-field"),
|
|
46
|
+
...require("./context-field"),
|
|
47
|
+
...require("./date-field"),
|
|
48
|
+
...require("./field"),
|
|
49
|
+
...require("./has-many-field"),
|
|
50
|
+
...require("./has-one-field"),
|
|
51
|
+
...require("./json-field"),
|
|
52
|
+
...require("./number-field"),
|
|
53
|
+
...require("./password-field"),
|
|
54
|
+
...require("./radio-field"),
|
|
55
|
+
...require("./relation-field"),
|
|
56
|
+
...require("./set-field"),
|
|
57
|
+
...require("./sort-field"),
|
|
58
|
+
...require("./string-field"),
|
|
59
|
+
...require("./text-field"),
|
|
60
|
+
...require("./time-field"),
|
|
61
|
+
...require("./uid-field"),
|
|
62
|
+
...require("./uuid-field"),
|
|
63
|
+
...require("./virtual-field"),
|
|
64
|
+
...require("./nanoid-field")
|
|
65
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
import { BaseColumnFieldOptions, Field } from './field';
|
|
3
|
+
export declare class JsonField extends Field {
|
|
4
|
+
get dataType(): DataTypes.AbstractDataTypeConstructor;
|
|
5
|
+
}
|
|
6
|
+
export interface JsonFieldOptions extends BaseColumnFieldOptions {
|
|
7
|
+
type: 'json';
|
|
8
|
+
}
|
|
9
|
+
export declare class JsonbField extends Field {
|
|
10
|
+
get dataType(): DataTypes.AbstractDataTypeConstructor;
|
|
11
|
+
}
|
|
12
|
+
export interface JsonbFieldOptions extends BaseColumnFieldOptions {
|
|
13
|
+
type: 'jsonb';
|
|
14
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var json_field_exports = {};
|
|
20
|
+
__export(json_field_exports, {
|
|
21
|
+
JsonField: () => JsonField,
|
|
22
|
+
JsonbField: () => JsonbField
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(json_field_exports);
|
|
25
|
+
var import_sequelize = require("sequelize");
|
|
26
|
+
var import_field = require("./field");
|
|
27
|
+
const _JsonField = class _JsonField extends import_field.Field {
|
|
28
|
+
get dataType() {
|
|
29
|
+
const dialect = this.context.database.sequelize.getDialect();
|
|
30
|
+
const { jsonb } = this.options;
|
|
31
|
+
if (dialect === "postgres" && jsonb) {
|
|
32
|
+
return import_sequelize.DataTypes.JSONB;
|
|
33
|
+
}
|
|
34
|
+
return import_sequelize.DataTypes.JSON;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
__name(_JsonField, "JsonField");
|
|
38
|
+
let JsonField = _JsonField;
|
|
39
|
+
const _JsonbField = class _JsonbField extends import_field.Field {
|
|
40
|
+
get dataType() {
|
|
41
|
+
const dialect = this.context.database.sequelize.getDialect();
|
|
42
|
+
if (dialect === "postgres") {
|
|
43
|
+
return import_sequelize.DataTypes.JSONB;
|
|
44
|
+
}
|
|
45
|
+
return import_sequelize.DataTypes.JSON;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
__name(_JsonbField, "JsonbField");
|
|
49
|
+
let JsonbField = _JsonbField;
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
JsonField,
|
|
53
|
+
JsonbField
|
|
54
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
import { BaseColumnFieldOptions, Field } from './field';
|
|
3
|
+
export declare class NanoidField extends Field {
|
|
4
|
+
get dataType(): DataTypes.StringDataTypeConstructor;
|
|
5
|
+
init(): void;
|
|
6
|
+
bind(): void;
|
|
7
|
+
unbind(): void;
|
|
8
|
+
}
|
|
9
|
+
export interface NanoidFieldOptions extends BaseColumnFieldOptions {
|
|
10
|
+
type: 'nanoid';
|
|
11
|
+
size?: number;
|
|
12
|
+
customAlphabet?: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var nanoid_field_exports = {};
|
|
20
|
+
__export(nanoid_field_exports, {
|
|
21
|
+
NanoidField: () => NanoidField
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(nanoid_field_exports);
|
|
24
|
+
var import_nanoid = require("nanoid");
|
|
25
|
+
var import_sequelize = require("sequelize");
|
|
26
|
+
var import_field = require("./field");
|
|
27
|
+
const DEFAULT_SIZE = 12;
|
|
28
|
+
const _NanoidField = class _NanoidField extends import_field.Field {
|
|
29
|
+
get dataType() {
|
|
30
|
+
return import_sequelize.DataTypes.STRING;
|
|
31
|
+
}
|
|
32
|
+
init() {
|
|
33
|
+
const { name, size, customAlphabet: customAlphabetOptions } = this.options;
|
|
34
|
+
this.listener = async (instance) => {
|
|
35
|
+
const value = instance.get(name);
|
|
36
|
+
if (!value) {
|
|
37
|
+
const nanoIdFunc = customAlphabetOptions ? (0, import_nanoid.customAlphabet)(customAlphabetOptions) : import_nanoid.nanoid;
|
|
38
|
+
instance.set(name, nanoIdFunc(size || DEFAULT_SIZE));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
bind() {
|
|
43
|
+
super.bind();
|
|
44
|
+
this.on("beforeCreate", this.listener);
|
|
45
|
+
this.on("beforeUpdate", this.listener);
|
|
46
|
+
}
|
|
47
|
+
unbind() {
|
|
48
|
+
super.unbind();
|
|
49
|
+
this.off("beforeCreate", this.listener);
|
|
50
|
+
this.off("beforeUpdate", this.listener);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
__name(_NanoidField, "NanoidField");
|
|
54
|
+
let NanoidField = _NanoidField;
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
NanoidField
|
|
58
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
import { BaseColumnFieldOptions, Field } from './field';
|
|
3
|
+
declare abstract class NumberField extends Field {
|
|
4
|
+
}
|
|
5
|
+
export declare class IntegerField extends NumberField {
|
|
6
|
+
get dataType(): DataTypes.IntegerDataTypeConstructor;
|
|
7
|
+
}
|
|
8
|
+
export interface IntegerFieldOptions extends BaseColumnFieldOptions {
|
|
9
|
+
type: 'integer';
|
|
10
|
+
}
|
|
11
|
+
export declare class BigIntField extends NumberField {
|
|
12
|
+
get dataType(): DataTypes.BigIntDataTypeConstructor;
|
|
13
|
+
}
|
|
14
|
+
export interface BigIntFieldOptions extends BaseColumnFieldOptions {
|
|
15
|
+
type: 'bigInt';
|
|
16
|
+
}
|
|
17
|
+
export declare class FloatField extends NumberField {
|
|
18
|
+
get dataType(): DataTypes.FloatDataTypeConstructor;
|
|
19
|
+
}
|
|
20
|
+
export interface FloatFieldOptions extends BaseColumnFieldOptions {
|
|
21
|
+
type: 'float';
|
|
22
|
+
}
|
|
23
|
+
export declare class DoubleField extends NumberField {
|
|
24
|
+
get dataType(): DataTypes.DoubleDataTypeConstructor;
|
|
25
|
+
}
|
|
26
|
+
export interface DoubleFieldOptions extends BaseColumnFieldOptions {
|
|
27
|
+
type: 'double';
|
|
28
|
+
}
|
|
29
|
+
export declare class RealField extends NumberField {
|
|
30
|
+
get dataType(): DataTypes.RealDataTypeConstructor;
|
|
31
|
+
}
|
|
32
|
+
export interface RealFieldOptions extends BaseColumnFieldOptions {
|
|
33
|
+
type: 'real';
|
|
34
|
+
}
|
|
35
|
+
export declare class DecimalField extends NumberField {
|
|
36
|
+
get dataType(): DataTypes.DecimalDataTypeConstructor;
|
|
37
|
+
}
|
|
38
|
+
export interface DecimalFieldOptions extends BaseColumnFieldOptions {
|
|
39
|
+
type: 'decimal';
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var number_field_exports = {};
|
|
20
|
+
__export(number_field_exports, {
|
|
21
|
+
BigIntField: () => BigIntField,
|
|
22
|
+
DecimalField: () => DecimalField,
|
|
23
|
+
DoubleField: () => DoubleField,
|
|
24
|
+
FloatField: () => FloatField,
|
|
25
|
+
IntegerField: () => IntegerField,
|
|
26
|
+
RealField: () => RealField
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(number_field_exports);
|
|
29
|
+
var import_sequelize = require("sequelize");
|
|
30
|
+
var import_field = require("./field");
|
|
31
|
+
const _NumberField = class _NumberField extends import_field.Field {
|
|
32
|
+
};
|
|
33
|
+
__name(_NumberField, "NumberField");
|
|
34
|
+
let NumberField = _NumberField;
|
|
35
|
+
const _IntegerField = class _IntegerField extends NumberField {
|
|
36
|
+
get dataType() {
|
|
37
|
+
return import_sequelize.DataTypes.INTEGER;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
__name(_IntegerField, "IntegerField");
|
|
41
|
+
let IntegerField = _IntegerField;
|
|
42
|
+
const _BigIntField = class _BigIntField extends NumberField {
|
|
43
|
+
get dataType() {
|
|
44
|
+
return import_sequelize.DataTypes.BIGINT;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
__name(_BigIntField, "BigIntField");
|
|
48
|
+
let BigIntField = _BigIntField;
|
|
49
|
+
const _FloatField = class _FloatField extends NumberField {
|
|
50
|
+
get dataType() {
|
|
51
|
+
return import_sequelize.DataTypes.FLOAT;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
__name(_FloatField, "FloatField");
|
|
55
|
+
let FloatField = _FloatField;
|
|
56
|
+
const _DoubleField = class _DoubleField extends NumberField {
|
|
57
|
+
get dataType() {
|
|
58
|
+
return import_sequelize.DataTypes.DOUBLE;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
__name(_DoubleField, "DoubleField");
|
|
62
|
+
let DoubleField = _DoubleField;
|
|
63
|
+
const _RealField = class _RealField extends NumberField {
|
|
64
|
+
get dataType() {
|
|
65
|
+
return import_sequelize.DataTypes.REAL;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
__name(_RealField, "RealField");
|
|
69
|
+
let RealField = _RealField;
|
|
70
|
+
const _DecimalField = class _DecimalField extends NumberField {
|
|
71
|
+
get dataType() {
|
|
72
|
+
return import_sequelize.DataTypes.DECIMAL;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
__name(_DecimalField, "DecimalField");
|
|
76
|
+
let DecimalField = _DecimalField;
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
BigIntField,
|
|
80
|
+
DecimalField,
|
|
81
|
+
DoubleField,
|
|
82
|
+
FloatField,
|
|
83
|
+
IntegerField,
|
|
84
|
+
RealField
|
|
85
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
import { BaseColumnFieldOptions, Field } from './field';
|
|
3
|
+
export interface PasswordFieldOptions extends BaseColumnFieldOptions {
|
|
4
|
+
type: 'password';
|
|
5
|
+
/**
|
|
6
|
+
* @default 64
|
|
7
|
+
*/
|
|
8
|
+
length?: number;
|
|
9
|
+
/**
|
|
10
|
+
* @default 8
|
|
11
|
+
*/
|
|
12
|
+
randomBytesSize?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class PasswordField extends Field {
|
|
15
|
+
get dataType(): DataTypes.StringDataTypeConstructor;
|
|
16
|
+
verify(password: string, hash: string): Promise<unknown>;
|
|
17
|
+
hash(password: string): Promise<unknown>;
|
|
18
|
+
init(): void;
|
|
19
|
+
bind(): void;
|
|
20
|
+
unbind(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var password_field_exports = {};
|
|
30
|
+
__export(password_field_exports, {
|
|
31
|
+
PasswordField: () => PasswordField
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(password_field_exports);
|
|
34
|
+
var import_crypto = __toESM(require("crypto"));
|
|
35
|
+
var import_sequelize = require("sequelize");
|
|
36
|
+
var import_field = require("./field");
|
|
37
|
+
const _PasswordField = class _PasswordField extends import_field.Field {
|
|
38
|
+
get dataType() {
|
|
39
|
+
return import_sequelize.DataTypes.STRING;
|
|
40
|
+
}
|
|
41
|
+
async verify(password, hash) {
|
|
42
|
+
password = password || "";
|
|
43
|
+
hash = hash || "";
|
|
44
|
+
const { length = 64, randomBytesSize = 8 } = this.options;
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
const salt = hash.substring(0, randomBytesSize * 2);
|
|
47
|
+
const key = hash.substring(randomBytesSize * 2);
|
|
48
|
+
import_crypto.default.scrypt(password, salt, length / 2 - randomBytesSize, (err, derivedKey) => {
|
|
49
|
+
if (err) reject(err);
|
|
50
|
+
resolve(key == derivedKey.toString("hex"));
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async hash(password) {
|
|
55
|
+
const { length = 64, randomBytesSize = 8 } = this.options;
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
const salt = import_crypto.default.randomBytes(randomBytesSize).toString("hex");
|
|
58
|
+
import_crypto.default.scrypt(password, salt, length / 2 - randomBytesSize, (err, derivedKey) => {
|
|
59
|
+
if (err) reject(err);
|
|
60
|
+
resolve(salt + derivedKey.toString("hex"));
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
init() {
|
|
65
|
+
const { name } = this.options;
|
|
66
|
+
this.listener = async (model) => {
|
|
67
|
+
if (!model.changed(name)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const value = model.get(name);
|
|
71
|
+
if (value) {
|
|
72
|
+
const hash = await this.hash(value);
|
|
73
|
+
model.set(name, hash);
|
|
74
|
+
} else {
|
|
75
|
+
model.set(name, model.previous(name));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
bind() {
|
|
80
|
+
super.bind();
|
|
81
|
+
this.on("beforeCreate", this.listener);
|
|
82
|
+
this.on("beforeUpdate", this.listener);
|
|
83
|
+
}
|
|
84
|
+
unbind() {
|
|
85
|
+
super.unbind();
|
|
86
|
+
this.off("beforeCreate", this.listener);
|
|
87
|
+
this.off("beforeUpdate", this.listener);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
__name(_PasswordField, "PasswordField");
|
|
91
|
+
let PasswordField = _PasswordField;
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
PasswordField
|
|
95
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
import { BaseColumnFieldOptions, Field } from './field';
|
|
3
|
+
export interface RadioFieldOptions extends BaseColumnFieldOptions {
|
|
4
|
+
type: 'radio';
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 暂时只支持全局,不支持批量
|
|
8
|
+
*/
|
|
9
|
+
export declare class RadioField extends Field {
|
|
10
|
+
get dataType(): DataTypes.AbstractDataTypeConstructor;
|
|
11
|
+
listener: (model: any, { transaction }: {
|
|
12
|
+
transaction: any;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
bind(): void;
|
|
15
|
+
unbind(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var radio_field_exports = {};
|
|
20
|
+
__export(radio_field_exports, {
|
|
21
|
+
RadioField: () => RadioField
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(radio_field_exports);
|
|
24
|
+
var import_sequelize = require("sequelize");
|
|
25
|
+
var import_field = require("./field");
|
|
26
|
+
const _RadioField = class _RadioField extends import_field.Field {
|
|
27
|
+
get dataType() {
|
|
28
|
+
return import_sequelize.DataTypes.BOOLEAN;
|
|
29
|
+
}
|
|
30
|
+
listener = /* @__PURE__ */ __name(async (model, { transaction }) => {
|
|
31
|
+
const { name } = this.options;
|
|
32
|
+
if (!model.changed(name)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const value = model.get(name);
|
|
36
|
+
if (value) {
|
|
37
|
+
const M = this.collection.model;
|
|
38
|
+
await M.update(
|
|
39
|
+
{ [name]: false },
|
|
40
|
+
{
|
|
41
|
+
where: {
|
|
42
|
+
[name]: true
|
|
43
|
+
},
|
|
44
|
+
transaction,
|
|
45
|
+
hooks: false
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}, "listener");
|
|
50
|
+
bind() {
|
|
51
|
+
super.bind();
|
|
52
|
+
this.on("beforeCreate", this.listener);
|
|
53
|
+
this.on("beforeUpdate", this.listener);
|
|
54
|
+
}
|
|
55
|
+
unbind() {
|
|
56
|
+
super.unbind();
|
|
57
|
+
this.off("beforeCreate", this.listener);
|
|
58
|
+
this.off("beforeUpdate", this.listener);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
__name(_RadioField, "RadioField");
|
|
62
|
+
let RadioField = _RadioField;
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
RadioField
|
|
66
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseFieldOptions, Field } from './field';
|
|
2
|
+
export type BaseRelationFieldOptions = BaseFieldOptions;
|
|
3
|
+
export interface MultipleRelationFieldOptions extends BaseRelationFieldOptions {
|
|
4
|
+
sortBy?: string | string[];
|
|
5
|
+
}
|
|
6
|
+
export declare abstract class RelationField extends Field {
|
|
7
|
+
/**
|
|
8
|
+
* target relation name
|
|
9
|
+
*/
|
|
10
|
+
get target(): any;
|
|
11
|
+
get foreignKey(): any;
|
|
12
|
+
get sourceKey(): any;
|
|
13
|
+
get targetKey(): any;
|
|
14
|
+
/**
|
|
15
|
+
* get target model from database by it's name
|
|
16
|
+
* @constructor
|
|
17
|
+
*/
|
|
18
|
+
get TargetModel(): import("sequelize").ModelCtor<import("sequelize").Model<any, any>>;
|
|
19
|
+
keyPairsTypeMatched(type1: any, type2: any): boolean;
|
|
20
|
+
protected clearAccessors(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var relation_field_exports = {};
|
|
20
|
+
__export(relation_field_exports, {
|
|
21
|
+
RelationField: () => RelationField
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(relation_field_exports);
|
|
24
|
+
var import_field = require("./field");
|
|
25
|
+
const _RelationField = class _RelationField extends import_field.Field {
|
|
26
|
+
/**
|
|
27
|
+
* target relation name
|
|
28
|
+
*/
|
|
29
|
+
get target() {
|
|
30
|
+
const { target, name } = this.options;
|
|
31
|
+
return target || name;
|
|
32
|
+
}
|
|
33
|
+
get foreignKey() {
|
|
34
|
+
return this.options.foreignKey;
|
|
35
|
+
}
|
|
36
|
+
get sourceKey() {
|
|
37
|
+
return this.options.sourceKey || this.collection.model.primaryKeyAttribute;
|
|
38
|
+
}
|
|
39
|
+
get targetKey() {
|
|
40
|
+
return this.options.targetKey || this.TargetModel.primaryKeyAttribute;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* get target model from database by it's name
|
|
44
|
+
* @constructor
|
|
45
|
+
*/
|
|
46
|
+
get TargetModel() {
|
|
47
|
+
return this.context.database.sequelize.models[this.target];
|
|
48
|
+
}
|
|
49
|
+
keyPairsTypeMatched(type1, type2) {
|
|
50
|
+
type1 = type1.toLowerCase();
|
|
51
|
+
type2 = type2.toLowerCase();
|
|
52
|
+
const numberTypeGroups = ["integer", "bigint", "decimal", "float", "real", "double", "smallint", "tinyint"];
|
|
53
|
+
const stringTypeGroups = ["string", "char", "text"];
|
|
54
|
+
if (numberTypeGroups.includes(type1) && numberTypeGroups.includes(type2)) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
if (stringTypeGroups.includes(type1) && stringTypeGroups.includes(type2)) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return type1 === type2;
|
|
61
|
+
}
|
|
62
|
+
clearAccessors() {
|
|
63
|
+
const { collection } = this.context;
|
|
64
|
+
const association = collection.model.associations[this.name];
|
|
65
|
+
if (!association) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const accessors = Object.values(association.accessors);
|
|
69
|
+
accessors.forEach((accessor) => {
|
|
70
|
+
delete collection.model.prototype[accessor];
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
__name(_RelationField, "RelationField");
|
|
75
|
+
let RelationField = _RelationField;
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
RelationField
|
|
79
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ArrayField } from './array-field';
|
|
2
|
+
import { BaseColumnFieldOptions } from './field';
|
|
3
|
+
export interface SetFieldOptions extends BaseColumnFieldOptions {
|
|
4
|
+
type: 'set';
|
|
5
|
+
}
|
|
6
|
+
export declare class SetField extends ArrayField {
|
|
7
|
+
beforeSave: (model: any) => void;
|
|
8
|
+
bind(): void;
|
|
9
|
+
unbind(): void;
|
|
10
|
+
}
|