fib-orm 1.4.2 → 2.1.0
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/License +1 -1
- package/README.md +53 -0
- package/lib/cli/commands/ddlFrom.d.ts +2 -0
- package/lib/cli/commands/ddlFrom.js +75 -0
- package/lib/cli/commands/dumpModel.d.ts +2 -0
- package/lib/cli/commands/dumpModel.js +107 -0
- package/lib/cli/commands/escape.d.ts +2 -0
- package/lib/cli/commands/escape.js +69 -0
- package/lib/cli/commands/spinner.d.ts +2 -0
- package/lib/cli/commands/spinner.js +37 -0
- package/lib/cli/commands/upgrade.d.ts +2 -0
- package/lib/cli/commands/upgrade.js +66 -0
- package/lib/cli/helpers/ddl.d.ts +17 -0
- package/lib/cli/helpers/ddl.js +55 -0
- package/lib/cli/helpers/package.d.ts +25 -0
- package/lib/cli/helpers/package.js +56 -0
- package/lib/cli/index.d.ts +2 -0
- package/lib/cli/index.js +19 -0
- package/lib/codepoints-map.json +762 -0
- package/lib/db-driver/Typo.d.ts +111 -0
- package/lib/db-driver/Typo.js +2 -0
- package/lib/db-driver/built-ins/base.class.d.ts +91 -0
- package/lib/db-driver/built-ins/base.class.js +187 -0
- package/lib/db-driver/built-ins/driver-dm.d.ts +17 -0
- package/lib/db-driver/built-ins/driver-dm.js +54 -0
- package/lib/db-driver/built-ins/driver-mongodb.d.ts +23 -0
- package/lib/db-driver/built-ins/driver-mongodb.js +47 -0
- package/lib/db-driver/built-ins/driver-mysql.d.ts +17 -0
- package/lib/db-driver/built-ins/driver-mysql.js +38 -0
- package/lib/db-driver/built-ins/driver-postgresql.d.ts +21 -0
- package/lib/db-driver/built-ins/driver-postgresql.js +77 -0
- package/lib/db-driver/built-ins/driver-redis.d.ts +11 -0
- package/lib/db-driver/built-ins/driver-redis.js +36 -0
- package/lib/db-driver/built-ins/driver-sqlite.d.ts +16 -0
- package/lib/db-driver/built-ins/driver-sqlite.js +35 -0
- package/lib/db-driver/index.d.ts +3 -0
- package/lib/db-driver/index.js +5 -0
- package/lib/db-driver/utils.d.ts +14 -0
- package/lib/db-driver/utils.js +187 -0
- package/lib/knex/deps/tarn/dist/PendingOperation.d.ts +12 -0
- package/lib/knex/deps/tarn/dist/PendingOperation.js +48 -0
- package/lib/knex/deps/tarn/dist/Pool.d.ts +97 -0
- package/lib/knex/deps/tarn/dist/Pool.js +516 -0
- package/lib/knex/deps/tarn/dist/PromiseInspection.d.ts +16 -0
- package/lib/knex/deps/tarn/dist/PromiseInspection.js +21 -0
- package/lib/knex/deps/tarn/dist/Resource.d.ts +9 -0
- package/lib/knex/deps/tarn/dist/Resource.js +19 -0
- package/lib/knex/deps/tarn/dist/TimeoutError.d.ts +2 -0
- package/lib/knex/deps/tarn/dist/TimeoutError.js +5 -0
- package/lib/knex/deps/tarn/dist/tarn.d.ts +3 -0
- package/lib/knex/deps/tarn/dist/tarn.js +10 -0
- package/lib/knex/deps/tarn/dist/utils.d.ts +14 -0
- package/lib/knex/deps/tarn/dist/utils.js +60 -0
- package/lib/knex/knex.d.ts +2 -0
- package/lib/knex/knex.js +4 -0
- package/lib/knex/sandbox.d.ts +4 -0
- package/lib/knex/sandbox.js +23 -0
- package/lib/orm/Adapters.d.ts +3 -0
- package/lib/orm/Adapters.js +44 -0
- package/lib/orm/AggregateFunctions.d.ts +3 -0
- package/lib/orm/AggregateFunctions.js +177 -0
- package/lib/orm/Associations/Extend.d.ts +22 -0
- package/lib/orm/Associations/Extend.js +274 -0
- package/lib/orm/Associations/Many.d.ts +16 -0
- package/lib/orm/Associations/Many.js +569 -0
- package/lib/orm/Associations/One.d.ts +16 -0
- package/lib/orm/Associations/One.js +310 -0
- package/lib/orm/Associations/_utils.d.ts +14 -0
- package/lib/orm/Associations/_utils.js +53 -0
- package/lib/orm/ChainFind.d.ts +3 -0
- package/lib/orm/ChainFind.js +328 -0
- package/lib/orm/ChainInstance.d.ts +6 -0
- package/lib/orm/ChainInstance.js +74 -0
- package/lib/orm/Debug.d.ts +2 -0
- package/lib/orm/Debug.js +17 -0
- package/lib/orm/Drivers/DB/base.d.ts +2 -0
- package/lib/orm/Drivers/DB/base.js +4 -0
- package/lib/orm/Drivers/DB/dm.d.ts +9 -0
- package/lib/orm/Drivers/DB/dm.js +24 -0
- package/lib/orm/Drivers/DB/mysql.d.ts +9 -0
- package/lib/orm/Drivers/DB/mysql.js +24 -0
- package/lib/orm/Drivers/DB/postgres.d.ts +9 -0
- package/lib/orm/Drivers/DB/postgres.js +23 -0
- package/lib/orm/Drivers/DB/sqlite3.d.ts +14 -0
- package/lib/orm/Drivers/DB/sqlite3.js +40 -0
- package/lib/orm/Drivers/DML/_ddl-sql.d.ts +3 -0
- package/lib/orm/Drivers/DML/_ddl-sql.js +52 -0
- package/lib/orm/Drivers/DML/_dml-helpers.d.ts +19 -0
- package/lib/orm/Drivers/DML/_dml-helpers.js +51 -0
- package/lib/orm/Drivers/DML/_shared.d.ts +9 -0
- package/lib/orm/Drivers/DML/_shared.js +39 -0
- package/lib/orm/Drivers/DML/_utils.d.ts +8 -0
- package/lib/orm/Drivers/DML/_utils.js +67 -0
- package/lib/orm/Drivers/DML/constants.d.ts +3 -0
- package/lib/orm/Drivers/DML/constants.js +3 -0
- package/lib/orm/Drivers/DML/dm.d.ts +2 -0
- package/lib/orm/Drivers/DML/dm.js +294 -0
- package/lib/orm/Drivers/DML/index.d.ts +4 -0
- package/lib/orm/Drivers/DML/index.js +7 -0
- package/lib/orm/Drivers/DML/mysql.d.ts +2 -0
- package/lib/orm/Drivers/DML/mysql.js +252 -0
- package/lib/orm/Drivers/DML/postgres.d.ts +2 -0
- package/lib/orm/Drivers/DML/postgres.js +277 -0
- package/lib/orm/Drivers/DML/sqlite.d.ts +2 -0
- package/lib/orm/Drivers/DML/sqlite.js +267 -0
- package/lib/orm/Error.d.ts +11 -0
- package/lib/orm/Error.js +41 -0
- package/lib/orm/Helpers.d.ts +35 -0
- package/lib/orm/Helpers.js +234 -0
- package/lib/orm/Hook.d.ts +13 -0
- package/lib/orm/Hook.js +100 -0
- package/lib/orm/Instance.d.ts +2 -0
- package/lib/orm/Instance.js +698 -0
- package/lib/orm/LazyLoad.d.ts +4 -0
- package/lib/orm/LazyLoad.js +76 -0
- package/lib/orm/Model.d.ts +6 -0
- package/lib/orm/Model.js +974 -0
- package/lib/orm/ORM.d.ts +37 -0
- package/lib/orm/ORM.js +242 -0
- package/lib/orm/Patch/fib-cache.d.ts +39 -0
- package/lib/orm/Patch/fib-cache.js +2 -0
- package/lib/orm/Patch/plugin.d.ts +4 -0
- package/lib/orm/Patch/plugin.js +14 -0
- package/lib/orm/Property.d.ts +9 -0
- package/lib/orm/Property.js +71 -0
- package/lib/orm/Settings.d.ts +42 -0
- package/lib/orm/Settings.js +120 -0
- package/lib/orm/Singleton.d.ts +5 -0
- package/lib/orm/Singleton.js +73 -0
- package/lib/orm/Typo/Adapter.d.ts +5 -0
- package/lib/orm/Typo/Adapter.js +2 -0
- package/lib/orm/Typo/DMLDriver.d.ts +209 -0
- package/lib/orm/Typo/DMLDriver.js +2 -0
- package/lib/orm/Typo/Db.d.ts +35 -0
- package/lib/orm/Typo/Db.js +2 -0
- package/lib/orm/Typo/Error.d.ts +29 -0
- package/lib/orm/Typo/Error.js +2 -0
- package/lib/orm/Typo/ORM.d.ts +231 -0
- package/lib/orm/Typo/ORM.js +4 -0
- package/lib/orm/Typo/Validators.d.ts +31 -0
- package/lib/orm/Typo/Validators.js +3 -0
- package/lib/orm/Typo/_common.d.ts +37 -0
- package/lib/orm/Typo/_common.js +2 -0
- package/lib/orm/Typo/assoc.d.ts +221 -0
- package/lib/orm/Typo/assoc.js +2 -0
- package/lib/orm/Typo/hook.d.ts +42 -0
- package/lib/orm/Typo/hook.js +2 -0
- package/lib/orm/Typo/instance.d.ts +156 -0
- package/lib/orm/Typo/instance.js +2 -0
- package/lib/orm/Typo/model.d.ts +311 -0
- package/lib/orm/Typo/model.js +7 -0
- package/lib/orm/Typo/patch.d.ts +31 -0
- package/lib/orm/Typo/patch.js +2 -0
- package/lib/orm/Typo/property.d.ts +57 -0
- package/lib/orm/Typo/property.js +2 -0
- package/lib/orm/Typo/query.d.ts +216 -0
- package/lib/orm/Typo/query.js +2 -0
- package/lib/orm/Typo/settings.d.ts +35 -0
- package/lib/orm/Typo/settings.js +6 -0
- package/lib/orm/Typo/synchronous.d.ts +47 -0
- package/lib/orm/Typo/synchronous.js +2 -0
- package/lib/orm/Utilities.d.ts +178 -0
- package/lib/orm/Utilities.js +975 -0
- package/lib/orm/Validators.d.ts +33 -0
- package/lib/orm/Validators.js +101 -0
- package/lib/orm/Where/common.d.ts +1 -0
- package/lib/orm/Where/common.js +7 -0
- package/lib/orm/Where/filterDate.d.ts +11 -0
- package/lib/orm/Where/filterDate.js +58 -0
- package/lib/orm/index.d.ts +67 -0
- package/lib/orm/index.js +158 -0
- package/lib/orm-core/callback.d.ts +12 -0
- package/lib/orm-core/callback.js +2 -0
- package/lib/orm-core/dialect.d.ts +80 -0
- package/lib/orm-core/dialect.js +2 -0
- package/lib/orm-core/error.d.ts +16 -0
- package/lib/orm-core/error.js +29 -0
- package/lib/orm-core/index.d.ts +6 -0
- package/lib/orm-core/index.js +7 -0
- package/lib/orm-core/sync.d.ts +12 -0
- package/lib/orm-core/sync.js +2 -0
- package/lib/orm-core/utils.d.ts +1 -0
- package/lib/orm-core/utils.js +6 -0
- package/lib/orm-property/Property.d.ts +78 -0
- package/lib/orm-property/Property.js +2 -0
- package/lib/orm-property/Utils.d.ts +9 -0
- package/lib/orm-property/Utils.js +13 -0
- package/lib/orm-property/customTypes.d.ts +2 -0
- package/lib/orm-property/customTypes.js +13 -0
- package/lib/orm-property/index.d.ts +10 -0
- package/lib/orm-property/index.js +23 -0
- package/lib/orm-property/transformer.d.ts +5 -0
- package/lib/orm-property/transformer.js +10 -0
- package/lib/orm-property/transformers/dm.d.ts +29 -0
- package/lib/orm-property/transformers/dm.js +238 -0
- package/lib/orm-property/transformers/index.d.ts +4 -0
- package/lib/orm-property/transformers/index.js +6 -0
- package/lib/orm-property/transformers/mysql.d.ts +101 -0
- package/lib/orm-property/transformers/mysql.js +262 -0
- package/lib/orm-property/transformers/postgresql.d.ts +54 -0
- package/lib/orm-property/transformers/postgresql.js +190 -0
- package/lib/orm-property/transformers/sqlite.d.ts +19 -0
- package/lib/orm-property/transformers/sqlite.js +172 -0
- package/lib/sql-ddl-sync/Dialects/dm.d.ts +39 -0
- package/lib/sql-ddl-sync/Dialects/dm.js +297 -0
- package/lib/sql-ddl-sync/Dialects/index.d.ts +6 -0
- package/lib/sql-ddl-sync/Dialects/index.js +8 -0
- package/lib/sql-ddl-sync/Dialects/mysql.d.ts +38 -0
- package/lib/sql-ddl-sync/Dialects/mysql.js +241 -0
- package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +39 -0
- package/lib/sql-ddl-sync/Dialects/postgresql.js +287 -0
- package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +43 -0
- package/lib/sql-ddl-sync/Dialects/sqlite.js +257 -0
- package/lib/sql-ddl-sync/SQL.d.ts +12 -0
- package/lib/sql-ddl-sync/SQL.js +108 -0
- package/lib/sql-ddl-sync/Typo/Collection.d.ts +13 -0
- package/lib/sql-ddl-sync/Typo/Collection.js +2 -0
- package/lib/sql-ddl-sync/Typo/DbIndex.d.ts +13 -0
- package/lib/sql-ddl-sync/Typo/DbIndex.js +2 -0
- package/lib/sql-ddl-sync/Typo/Dialect.d.ts +81 -0
- package/lib/sql-ddl-sync/Typo/Dialect.js +2 -0
- package/lib/sql-ddl-sync/Typo/Driver.d.ts +53 -0
- package/lib/sql-ddl-sync/Typo/Driver.js +2 -0
- package/lib/sql-ddl-sync/Typo/Query.d.ts +7 -0
- package/lib/sql-ddl-sync/Typo/Query.js +2 -0
- package/lib/sql-ddl-sync/Typo/SQL.d.ts +31 -0
- package/lib/sql-ddl-sync/Typo/SQL.js +2 -0
- package/lib/sql-ddl-sync/Typo/_common.d.ts +29 -0
- package/lib/sql-ddl-sync/Typo/_common.js +2 -0
- package/lib/sql-ddl-sync/Utils.d.ts +39 -0
- package/lib/sql-ddl-sync/Utils.js +217 -0
- package/lib/sql-ddl-sync/index.d.ts +87 -0
- package/lib/sql-ddl-sync/index.js +372 -0
- package/lib/sql-query/Comparators.d.ts +3 -0
- package/lib/sql-query/Comparators.js +95 -0
- package/lib/sql-query/Create.d.ts +35 -0
- package/lib/sql-query/Create.js +78 -0
- package/lib/sql-query/Dialects/dm.d.ts +3 -0
- package/lib/sql-query/Dialects/dm.js +75 -0
- package/lib/sql-query/Dialects/index.d.ts +10 -0
- package/lib/sql-query/Dialects/index.js +13 -0
- package/lib/sql-query/Dialects/mssql.d.ts +3 -0
- package/lib/sql-query/Dialects/mssql.js +74 -0
- package/lib/sql-query/Dialects/mysql.d.ts +3 -0
- package/lib/sql-query/Dialects/mysql.js +101 -0
- package/lib/sql-query/Dialects/postgresql.d.ts +3 -0
- package/lib/sql-query/Dialects/postgresql.js +77 -0
- package/lib/sql-query/Dialects/sqlite.d.ts +3 -0
- package/lib/sql-query/Dialects/sqlite.js +62 -0
- package/lib/sql-query/Helpers.d.ts +37 -0
- package/lib/sql-query/Helpers.js +260 -0
- package/lib/sql-query/Insert.d.ts +12 -0
- package/lib/sql-query/Insert.js +34 -0
- package/lib/sql-query/Query.d.ts +28 -0
- package/lib/sql-query/Query.js +120 -0
- package/lib/sql-query/Remove.d.ts +16 -0
- package/lib/sql-query/Remove.js +94 -0
- package/lib/sql-query/Select.d.ts +62 -0
- package/lib/sql-query/Select.js +534 -0
- package/lib/sql-query/Set.d.ts +4 -0
- package/lib/sql-query/Set.js +16 -0
- package/lib/sql-query/Typo/Aggregation.d.ts +32 -0
- package/lib/sql-query/Typo/Aggregation.js +2 -0
- package/lib/sql-query/Typo/Comparators.d.ts +140 -0
- package/lib/sql-query/Typo/Comparators.js +2 -0
- package/lib/sql-query/Typo/Dialect.d.ts +39 -0
- package/lib/sql-query/Typo/Dialect.js +2 -0
- package/lib/sql-query/Typo/Field.d.ts +8 -0
- package/lib/sql-query/Typo/Field.js +2 -0
- package/lib/sql-query/Typo/Helper.d.ts +4 -0
- package/lib/sql-query/Typo/Helper.js +2 -0
- package/lib/sql-query/Typo/Query-ChainBuilder.d.ts +80 -0
- package/lib/sql-query/Typo/Query-ChainBuilder.js +2 -0
- package/lib/sql-query/Typo/Query.d.ts +34 -0
- package/lib/sql-query/Typo/Query.js +17 -0
- package/lib/sql-query/Typo/Sql.d.ts +143 -0
- package/lib/sql-query/Typo/Sql.js +2 -0
- package/lib/sql-query/Typo/SubQuery.d.ts +39 -0
- package/lib/sql-query/Typo/SubQuery.js +2 -0
- package/lib/sql-query/Typo/index.d.ts +9 -0
- package/lib/sql-query/Typo/index.js +2 -0
- package/lib/sql-query/Update.d.ts +15 -0
- package/lib/sql-query/Update.js +39 -0
- package/lib/sql-query/Where.d.ts +4 -0
- package/lib/sql-query/Where.js +280 -0
- package/package.json +71 -36
- package/.travis.yml +0 -14
- package/@types/index.d.ts +0 -254
- package/@types/orm_mirror/orm.d.ts +0 -275
- package/@types/orm_mirror/sql-query.d.ts +0 -79
- package/Readme.md +0 -843
- package/lib/index.js +0 -13
- package/lib/modules/mysql.js +0 -35
- package/lib/modules/sqlite3.js +0 -27
- package/lib/patch.js +0 -271
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import type { FxOrmHook } from "./hook";
|
|
2
|
+
import type { FxOrmModel } from "./model";
|
|
3
|
+
import type { FxOrmProperty } from "./property";
|
|
4
|
+
import type { FxOrmCommon } from "./_common";
|
|
5
|
+
import type { FxOrmInstance } from "./instance";
|
|
6
|
+
export declare namespace FxOrmAssociation {
|
|
7
|
+
type AssociationType = 'extendsTo' | 'hasOne' | 'hasMany';
|
|
8
|
+
/**
|
|
9
|
+
* @type.function: (model_name: string, idkey: string) => string
|
|
10
|
+
*
|
|
11
|
+
* @string.default: `{model_name}_${idkey}`
|
|
12
|
+
*/
|
|
13
|
+
type AssociationKeyComputation = ((model_name: string, idkey: string) => string) | string;
|
|
14
|
+
interface AssociationDefinitionOptions {
|
|
15
|
+
/**
|
|
16
|
+
* it's also accessor base for `extendsTo`, `hasOne`, `hasMany`,
|
|
17
|
+
*
|
|
18
|
+
* @notice fallback from `acessor` for `hasOne`, `hasMany`
|
|
19
|
+
*/
|
|
20
|
+
name?: string;
|
|
21
|
+
model?: FxOrmModel.Model;
|
|
22
|
+
field?: string | Record<string, FxOrmProperty.NormalizedProperty>;
|
|
23
|
+
__for_extension?: boolean;
|
|
24
|
+
required?: boolean;
|
|
25
|
+
reversed?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* accessor base for `hasOne`, `hasMany`
|
|
28
|
+
*/
|
|
29
|
+
accessor?: string;
|
|
30
|
+
/**
|
|
31
|
+
* accessor base for `hasOne`
|
|
32
|
+
*/
|
|
33
|
+
reverseAccessor?: string;
|
|
34
|
+
autoFetch?: boolean;
|
|
35
|
+
autoFetchLimit?: number;
|
|
36
|
+
getAccessor?: string;
|
|
37
|
+
setAccessor?: string;
|
|
38
|
+
hasAccessor?: string;
|
|
39
|
+
delAccessor?: string;
|
|
40
|
+
addAccessor?: string;
|
|
41
|
+
modelFindByAccessor?: string;
|
|
42
|
+
hooks?: InstanceAssociationItem['hooks'];
|
|
43
|
+
}
|
|
44
|
+
interface AssociationDefinitionOptions_ExtendsTo extends AssociationDefinitionOptions {
|
|
45
|
+
table?: string;
|
|
46
|
+
reverse?: string;
|
|
47
|
+
reverseHooks?: InstanceAssociationItem_HasOne['hooks'];
|
|
48
|
+
}
|
|
49
|
+
interface AssociationDefinitionOptions_HasOne extends AssociationDefinitionOptions {
|
|
50
|
+
reverse?: string;
|
|
51
|
+
reverseHooks?: InstanceAssociationItem_HasOne['hooks'];
|
|
52
|
+
}
|
|
53
|
+
interface AssociationDefinitionOptions_HasMany extends AssociationDefinitionOptions {
|
|
54
|
+
reverse?: string;
|
|
55
|
+
reverseHooks?: AssociationDefinitionOptions_HasMany['hooks'];
|
|
56
|
+
key?: boolean;
|
|
57
|
+
mergeId?: string | Record<string, FxOrmModel.ModelPropertyDefinition>;
|
|
58
|
+
mergeAssocId?: string | Record<string, FxOrmModel.ModelPropertyDefinition>;
|
|
59
|
+
reverseAssociation?: string;
|
|
60
|
+
hooks?: InstanceAssociationItem['hooks'] & {
|
|
61
|
+
beforeAdd?: FxOrmHook.HookActionWithCtxCallback<FxOrmInstance.Instance, __AssocHooksCtx>;
|
|
62
|
+
afterAdd?: FxOrmHook.HookRetOnlyPayloadCallback<FxOrmInstance.Instance, __AssocHooksCtx>;
|
|
63
|
+
/** @deprecated */
|
|
64
|
+
beforeSave?: {
|
|
65
|
+
(next?: FxOrmHook.HookActionNextor): void;
|
|
66
|
+
(extra: any, next?: FxOrmHook.HookActionNextor): void;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
mergeTable?: string;
|
|
70
|
+
association?: string;
|
|
71
|
+
getAccessor?: string;
|
|
72
|
+
setAccessor?: string;
|
|
73
|
+
hasAccessor?: string;
|
|
74
|
+
delAccessor?: string;
|
|
75
|
+
addAccessor?: string;
|
|
76
|
+
}
|
|
77
|
+
interface InstanceAssociationItemHooks {
|
|
78
|
+
beforeSet?: {
|
|
79
|
+
(func: FxOrmHook.HookActionCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any;
|
|
80
|
+
};
|
|
81
|
+
afterSet?: {
|
|
82
|
+
(func: FxOrmHook.HookResultCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any;
|
|
83
|
+
};
|
|
84
|
+
beforeRemove?: {
|
|
85
|
+
(func: FxOrmHook.HookActionCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any;
|
|
86
|
+
};
|
|
87
|
+
afterRemove?: {
|
|
88
|
+
(func: FxOrmHook.HookResultCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any;
|
|
89
|
+
};
|
|
90
|
+
beforeAdd?: {
|
|
91
|
+
(func: FxOrmHook.HookActionCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any;
|
|
92
|
+
};
|
|
93
|
+
afterAdd?: {
|
|
94
|
+
(func: FxOrmHook.HookResultCallback, opts?: FxOrmHook.HookPatchOptions & Record<string, any>): any;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** @internal */
|
|
98
|
+
type __AssocHooksCtx = {
|
|
99
|
+
instance?: FxOrmInstance.Instance;
|
|
100
|
+
association?: FxOrmInstance.Instance;
|
|
101
|
+
associations?: (FxOrmInstance.Instance)[];
|
|
102
|
+
association_ids?: any[];
|
|
103
|
+
removeConditions?: Record<string, any>;
|
|
104
|
+
useChannel?: () => FxOrmHook.HookChannelResults<Function>;
|
|
105
|
+
$ref?: {
|
|
106
|
+
instance?: __AssocHooksCtx['instance'];
|
|
107
|
+
association?: __AssocHooksCtx['association'];
|
|
108
|
+
associations?: __AssocHooksCtx['associations'];
|
|
109
|
+
association_ids?: __AssocHooksCtx['association_ids'];
|
|
110
|
+
removeConditions?: __AssocHooksCtx['removeConditions'];
|
|
111
|
+
useChannel?: __AssocHooksCtx['useChannel'];
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
interface InstanceAssociationItem extends InstanceAssociationItemHooks {
|
|
115
|
+
name: string;
|
|
116
|
+
model: FxOrmModel.Model;
|
|
117
|
+
field: string | Record<string, FxOrmProperty.NormalizedProperty>;
|
|
118
|
+
hooks: {
|
|
119
|
+
beforeSet?: FxOrmCommon.Arraible<FxOrmHook.HookActionWithCtxCallback<FxOrmInstance.Instance, __AssocHooksCtx>>;
|
|
120
|
+
afterSet?: FxOrmCommon.Arraible<FxOrmHook.HookRetOnlyPayloadCallback<FxOrmInstance.Instance, __AssocHooksCtx>>;
|
|
121
|
+
beforeRemove?: FxOrmCommon.Arraible<FxOrmHook.HookActionWithCtxCallback<FxOrmInstance.Instance, __AssocHooksCtx>>;
|
|
122
|
+
afterRemove?: FxOrmCommon.Arraible<FxOrmHook.HookRetOnlyPayloadCallback<FxOrmInstance.Instance, __AssocHooksCtx>>;
|
|
123
|
+
[k: string]: FxOrmCommon.Arraible<FxOrmHook.HookActionWithCtxCallback<FxOrmInstance.Instance, __AssocHooksCtx> | FxOrmHook.HookRetOnlyPayloadCallback<FxOrmInstance.Instance, __AssocHooksCtx>>;
|
|
124
|
+
};
|
|
125
|
+
__for_extension?: boolean;
|
|
126
|
+
getAccessor: string;
|
|
127
|
+
getSyncAccessor: string;
|
|
128
|
+
setAccessor: string;
|
|
129
|
+
setSyncAccessor: string;
|
|
130
|
+
hasAccessor: string;
|
|
131
|
+
hasSyncAccessor: string;
|
|
132
|
+
delAccessor: string;
|
|
133
|
+
delSyncAccessor: string;
|
|
134
|
+
addAccessor?: string;
|
|
135
|
+
addSyncAccessor?: string;
|
|
136
|
+
modelFindByAccessor?: string;
|
|
137
|
+
modelFindBySyncAccessor?: string;
|
|
138
|
+
reversed?: boolean;
|
|
139
|
+
autoFetch: boolean;
|
|
140
|
+
autoFetchLimit: number;
|
|
141
|
+
mapsTo?: FxOrmModel.ModelPropertyDefinition['mapsTo'];
|
|
142
|
+
[k: string]: any;
|
|
143
|
+
}
|
|
144
|
+
type InstanceAssociatedInstance = FxOrmInstance.Instance;
|
|
145
|
+
interface InstanceAssociationItem_ExtendTos extends InstanceAssociationItem {
|
|
146
|
+
table: string;
|
|
147
|
+
reverse?: string;
|
|
148
|
+
modelFindByAccessor: string;
|
|
149
|
+
}
|
|
150
|
+
interface InstanceAssociationItem_HasOne extends InstanceAssociationItem {
|
|
151
|
+
field: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
152
|
+
reverse?: string;
|
|
153
|
+
reverseHooks?: InstanceAssociationItem_HasOne['hooks'];
|
|
154
|
+
accessor?: string;
|
|
155
|
+
reverseAccessor?: string;
|
|
156
|
+
modelFindByAccessor: string;
|
|
157
|
+
required?: boolean;
|
|
158
|
+
__for_extension?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @description information collected from code like:
|
|
162
|
+
*
|
|
163
|
+
* ```js
|
|
164
|
+
* Host.hasMany(Other, {
|
|
165
|
+
* mergeTable: 'merge_table',
|
|
166
|
+
* mergeId: ['host_id'], // optional,
|
|
167
|
+
* mergeAssocId: ['other_id']
|
|
168
|
+
* })
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
interface InstanceAssociationItem_HasMany extends InstanceAssociationItem {
|
|
172
|
+
props: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
173
|
+
mergeTable: string;
|
|
174
|
+
/**
|
|
175
|
+
* @description associated properties linked to Host on merge table
|
|
176
|
+
*/
|
|
177
|
+
mergeId: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
178
|
+
/**
|
|
179
|
+
* @description associated properties linked to Other on merge table
|
|
180
|
+
*/
|
|
181
|
+
mergeAssocId: Record<string, FxOrmProperty.NormalizedProperty>;
|
|
182
|
+
getAccessor: string;
|
|
183
|
+
setAccessor: string;
|
|
184
|
+
hasAccessor: string;
|
|
185
|
+
delAccessor: string;
|
|
186
|
+
addAccessor: string;
|
|
187
|
+
modelFindByAccessor?: string;
|
|
188
|
+
hooks: AssociationDefinitionOptions_HasMany['hooks'];
|
|
189
|
+
}
|
|
190
|
+
interface InstanceAssociationItemInformation {
|
|
191
|
+
changed: boolean;
|
|
192
|
+
value?: InstanceAssociatedInstance;
|
|
193
|
+
data?: InstanceAssociationItem;
|
|
194
|
+
}
|
|
195
|
+
interface ModelAssociationMethod__Options {
|
|
196
|
+
/** @deprecated use `extra_where` directly */
|
|
197
|
+
join_where?: FxOrmModel.ModelQueryConditions__Find;
|
|
198
|
+
/** @internal */
|
|
199
|
+
extra?: FxOrmModel.ModelOptions__Find['extra'];
|
|
200
|
+
/** @internal */
|
|
201
|
+
extra_info?: {
|
|
202
|
+
table: string;
|
|
203
|
+
id: FxOrmModel.Model['id'];
|
|
204
|
+
id_prop: string[];
|
|
205
|
+
assoc_prop: string[];
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
interface ModelAssociationMethod__FindOptions extends FxOrmModel.ModelOptions__Find, ModelAssociationMethod__Options {
|
|
209
|
+
}
|
|
210
|
+
interface ModelAssociationMethod__GetOptions extends FxOrmModel.ModelOptions__Find, ModelAssociationMethod__Options {
|
|
211
|
+
}
|
|
212
|
+
interface ModelAssociationMethod__FindByOptions extends FxOrmModel.ModelOptions__Findby, ModelAssociationMethod__Options {
|
|
213
|
+
}
|
|
214
|
+
interface AccessorOptions_has {
|
|
215
|
+
}
|
|
216
|
+
type AccessorOptions_get = FxOrmCommon.IdType | FxOrmModel.ModelQueryConditions__Find;
|
|
217
|
+
interface AutoFetchInstanceOptions {
|
|
218
|
+
autoFetch?: boolean;
|
|
219
|
+
autoFetchLimit?: number;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FxOrmCommon } from './_common';
|
|
2
|
+
import type { FxOrmInstance } from './instance';
|
|
3
|
+
export declare namespace FxOrmHook {
|
|
4
|
+
export interface HookActionNextor<TTHIS = FxOrmInstance.Instance> {
|
|
5
|
+
(this: TTHIS, err?: Error | null): any;
|
|
6
|
+
}
|
|
7
|
+
export interface HookActionCallback<TTHIS = FxOrmInstance.Instance> {
|
|
8
|
+
(this: TTHIS, next?: HookActionNextor<TTHIS>): any;
|
|
9
|
+
}
|
|
10
|
+
export interface HookActionWithCtxCallback<TTHIS = FxOrmInstance.Instance, TPayload extends Record<string, any> = Record<string, any>> {
|
|
11
|
+
(this: TTHIS, ctx?: TPayload, next?: HookActionNextor<TTHIS>): any;
|
|
12
|
+
}
|
|
13
|
+
export interface HookWait<CTX_SELF = FxOrmInstance.Instance, TNEXT_THIS = any> {
|
|
14
|
+
(self: CTX_SELF, hook: FxOrmCommon.Arraible<HookActionCallback | HookActionWithCtxCallback | FxOrmCommon.Arraible<HookActionCallback | HookActionWithCtxCallback>>, nextor: FxOrmCommon.GenericCallback<TNEXT_THIS>, ctx?: Record<string, any>): void;
|
|
15
|
+
}
|
|
16
|
+
export type HookResultCallback<TTHIS = FxOrmInstance.Instance> = ((this: TTHIS, success?: boolean) => any);
|
|
17
|
+
export type HookRetPayloadCallback<TTHIS = FxOrmInstance.Instance, TPAYLOAD = any, TResult = boolean> = (this: TTHIS, arg1?: TPAYLOAD, success?: TResult) => any;
|
|
18
|
+
export type HookRetOnlyPayloadCallback<TTHIS = FxOrmInstance.Instance, TPAYLOAD = any> = (this: TTHIS, arg1?: TPAYLOAD) => any;
|
|
19
|
+
export interface HookTrigger<CTX_SELF = FxOrmInstance.Instance, RESULT_TYPE = boolean> {
|
|
20
|
+
(self: CTX_SELF, cur: FxOrmCommon.Arraible<HookResultCallback | HookRetPayloadCallback>, _?: RESULT_TYPE, ...args: any): void;
|
|
21
|
+
}
|
|
22
|
+
export interface HookPatchOptions {
|
|
23
|
+
/**
|
|
24
|
+
* @default false
|
|
25
|
+
* 'prepend': prepend old oldhook to new hook
|
|
26
|
+
* 'append': append old oldhook to new hook
|
|
27
|
+
* undefined: overwrite oldhook
|
|
28
|
+
*/
|
|
29
|
+
oldhook?: 'prepend' | 'append' | 'initial' | 'overwrite' | undefined;
|
|
30
|
+
}
|
|
31
|
+
export interface HookChannel<FTYPE = Function> {
|
|
32
|
+
(name: string, handler: FTYPE): HookChannelResults;
|
|
33
|
+
(handler: FTYPE): HookChannelResults;
|
|
34
|
+
(name?: string): HookChannelResults;
|
|
35
|
+
}
|
|
36
|
+
type HookTuple<FTYPE = Function> = [FTYPE, (fn: FTYPE, ...args: any) => any];
|
|
37
|
+
export interface HookChannelResults<FTYPE = Function> extends HookTuple<FTYPE> {
|
|
38
|
+
run: (...args: any) => any;
|
|
39
|
+
set: (fn: Function, ...args: any) => any;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { FxOrmAssociation } from "./assoc";
|
|
2
|
+
import type { FxOrmDMLDriver } from "./DMLDriver";
|
|
3
|
+
import type { FxOrmHook } from "./hook";
|
|
4
|
+
import type { FxOrmModel } from "./model";
|
|
5
|
+
import type { FxOrmProperty } from "./property";
|
|
6
|
+
import type { FxOrmValidators } from "./Validators";
|
|
7
|
+
import type { FxOrmCommon } from "./_common";
|
|
8
|
+
import type { FxOrmError } from "./Error";
|
|
9
|
+
export declare namespace FxOrmInstance {
|
|
10
|
+
export interface InstanceDataPayload {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface CreateOptions {
|
|
14
|
+
autoFetch?: boolean;
|
|
15
|
+
autoFetchLimit?: number;
|
|
16
|
+
cascadeRemove?: boolean;
|
|
17
|
+
uid?: string;
|
|
18
|
+
isNew?: boolean;
|
|
19
|
+
isShell?: boolean;
|
|
20
|
+
autoSave?: boolean;
|
|
21
|
+
extra?: InstanceConstructorOptions['extra'];
|
|
22
|
+
extra_info?: InstanceConstructorOptions['extra_info'];
|
|
23
|
+
}
|
|
24
|
+
export interface SaveOptions {
|
|
25
|
+
saveAssociations?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface InstanceConstructorOptions {
|
|
28
|
+
table: string;
|
|
29
|
+
keys?: FxOrmModel.ModelConstructorOptions['keys'];
|
|
30
|
+
originalKeyValues?: InstanceDataPayload;
|
|
31
|
+
data?: InstanceDataPayload;
|
|
32
|
+
/**
|
|
33
|
+
* @description changes records
|
|
34
|
+
*/
|
|
35
|
+
changes?: string[];
|
|
36
|
+
extra?: string[] | Record<string, FxOrmProperty.NormalizedProperty>;
|
|
37
|
+
extra_info?: {
|
|
38
|
+
table: string;
|
|
39
|
+
id: string[];
|
|
40
|
+
id_prop: string[];
|
|
41
|
+
assoc_prop: string[];
|
|
42
|
+
};
|
|
43
|
+
isNew?: boolean;
|
|
44
|
+
isShell?: boolean;
|
|
45
|
+
autoSave?: FxOrmModel.ModelConstructorOptions['autoSave'];
|
|
46
|
+
methods?: FxOrmModel.ModelConstructorOptions['methods'];
|
|
47
|
+
/**
|
|
48
|
+
* @description all key properties of the instance, determined by the model
|
|
49
|
+
*/
|
|
50
|
+
keyProperties: FxOrmProperty.NormalizedProperty[];
|
|
51
|
+
validations: FxOrmValidators.IValidatorHash;
|
|
52
|
+
hooks: FxOrmModel.ModelConstructorOptions['hooks'];
|
|
53
|
+
one_associations: FxOrmAssociation.InstanceAssociationItem_HasOne[];
|
|
54
|
+
many_associations: FxOrmAssociation.InstanceAssociationItem_HasMany[];
|
|
55
|
+
extend_associations: FxOrmAssociation.InstanceAssociationItem_ExtendTos[];
|
|
56
|
+
association_properties: string[];
|
|
57
|
+
uid: FxOrmDMLDriver.DriverUidType;
|
|
58
|
+
driver: FxOrmDMLDriver.DMLDriver;
|
|
59
|
+
/**
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
__setupAssociations: (instance: Instance) => void;
|
|
63
|
+
fieldToPropertyMap: FxOrmProperty.FieldToPropertyMapType;
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
events?: {
|
|
68
|
+
[k: string]: FxOrmCommon.GenericCallback<any>;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface InnerInstanceRuntimeData extends InstanceConstructorOptions {
|
|
72
|
+
associations?: {
|
|
73
|
+
[key: string]: FxOrmAssociation.InstanceAssociationItemInformation;
|
|
74
|
+
};
|
|
75
|
+
extrachanges: string[];
|
|
76
|
+
/** @internal */
|
|
77
|
+
__validationData: Record<string, FxOrmError.ExtendedError[]>;
|
|
78
|
+
}
|
|
79
|
+
type __AddThisToMethods<TMethods extends Record<string, (...args: any) => any>> = TMethods extends void ? {} : {
|
|
80
|
+
[P in keyof TMethods]: (...args: Parameters<TMethods[P]>) => ReturnType<TMethods[P]>;
|
|
81
|
+
};
|
|
82
|
+
export type InstanceConstructor = new (model: FxOrmModel.Model, opts: InstanceConstructorOptions) => FxOrmInstance.Instance;
|
|
83
|
+
export type InstanceEventType = 'ready' | 'save' | 'beforeRemove' | 'remove';
|
|
84
|
+
export type Instance<TProperties extends Record<string, FieldRuntimeType> = Record<string, FieldRuntimeType>, Methods extends Record<string, (...args: any) => any> = Record<string, (...args: any) => any>> = {
|
|
85
|
+
on(event: InstanceEventType | string, callback: FxOrmCommon.GenericCallback<any>): Instance;
|
|
86
|
+
$on: Class_EventEmitter['on'];
|
|
87
|
+
$off: Class_EventEmitter['off'];
|
|
88
|
+
$emit: Class_EventEmitter['emit'];
|
|
89
|
+
validate(callback: FxOrmCommon.ValidatorCallback): void;
|
|
90
|
+
validateSync(): false | FxOrmError.ExtendedError[];
|
|
91
|
+
save(callback?: FxOrmCommon.VoidCallback): Instance;
|
|
92
|
+
save(data: InstanceDataPayload, callback?: FxOrmCommon.VoidCallback): Instance;
|
|
93
|
+
save(data: InstanceDataPayload, options: SaveOptions, callback?: FxOrmCommon.VoidCallback): Instance;
|
|
94
|
+
saveSync(data?: FxOrmInstance.InstanceDataPayload, options?: FxOrmInstance.SaveOptions): FxOrmInstance.Instance;
|
|
95
|
+
saved(): boolean;
|
|
96
|
+
remove(callback?: FxOrmCommon.VoidCallback): Instance;
|
|
97
|
+
removeSync(): void;
|
|
98
|
+
/**
|
|
99
|
+
* @noenum
|
|
100
|
+
*/
|
|
101
|
+
isInstance: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* @noenum
|
|
104
|
+
*/
|
|
105
|
+
isPersisted(): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* @noenum
|
|
108
|
+
*/
|
|
109
|
+
isShell(): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* @noenum
|
|
112
|
+
*/
|
|
113
|
+
set: (path: string | string[], value: any) => void;
|
|
114
|
+
markAsDirty: (propName: string) => void;
|
|
115
|
+
dirtyProperties: {
|
|
116
|
+
[key: string]: any;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* @internal
|
|
120
|
+
* @noenum
|
|
121
|
+
*/
|
|
122
|
+
__singleton_uid(): string | number;
|
|
123
|
+
/**
|
|
124
|
+
* @internal
|
|
125
|
+
* @noenum
|
|
126
|
+
*/
|
|
127
|
+
__instRtd?: InnerInstanceRuntimeData;
|
|
128
|
+
/**
|
|
129
|
+
* @noenum
|
|
130
|
+
*/
|
|
131
|
+
model(): FxOrmModel.Model<TProperties, Methods>;
|
|
132
|
+
/**
|
|
133
|
+
* @internal
|
|
134
|
+
*
|
|
135
|
+
* @warn only valid in corresponding hook
|
|
136
|
+
*/
|
|
137
|
+
readonly $hookRef: {
|
|
138
|
+
create: {
|
|
139
|
+
instance: Instance;
|
|
140
|
+
useChannel: FxOrmHook.HookChannel;
|
|
141
|
+
};
|
|
142
|
+
save: {
|
|
143
|
+
instance: Instance;
|
|
144
|
+
useChannel: FxOrmHook.HookChannel;
|
|
145
|
+
};
|
|
146
|
+
remove: {
|
|
147
|
+
instance: Instance;
|
|
148
|
+
useChannel: FxOrmHook.HookChannel;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
} & TProperties & __AddThisToMethods<Methods> & {
|
|
152
|
+
[key: string]: any;
|
|
153
|
+
};
|
|
154
|
+
export type FieldRuntimeType = number | string | boolean | Date | object;
|
|
155
|
+
export {};
|
|
156
|
+
}
|