@simplysm/orm-common 13.0.99 → 14.0.1
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/dist/create-db-context.d.ts +10 -10
- package/dist/create-db-context.js +312 -276
- package/dist/create-db-context.js.map +1 -6
- package/dist/ddl/column-ddl.d.ts +4 -4
- package/dist/ddl/column-ddl.js +41 -35
- package/dist/ddl/column-ddl.js.map +1 -6
- package/dist/ddl/initialize.d.ts +17 -17
- package/dist/ddl/initialize.js +200 -142
- package/dist/ddl/initialize.js.map +1 -6
- package/dist/ddl/relation-ddl.d.ts +6 -6
- package/dist/ddl/relation-ddl.js +55 -48
- package/dist/ddl/relation-ddl.js.map +1 -6
- package/dist/ddl/schema-ddl.d.ts +4 -4
- package/dist/ddl/schema-ddl.js +21 -15
- package/dist/ddl/schema-ddl.js.map +1 -6
- package/dist/ddl/table-ddl.d.ts +20 -20
- package/dist/ddl/table-ddl.js +139 -93
- package/dist/ddl/table-ddl.js.map +1 -6
- package/dist/define-db-context.js +10 -13
- package/dist/define-db-context.js.map +1 -6
- package/dist/errors/db-transaction-error.d.ts +15 -15
- package/dist/errors/db-transaction-error.d.ts.map +1 -1
- package/dist/errors/db-transaction-error.js +53 -19
- package/dist/errors/db-transaction-error.js.map +1 -6
- package/dist/exec/executable.d.ts +23 -23
- package/dist/exec/executable.js +94 -40
- package/dist/exec/executable.js.map +1 -6
- package/dist/exec/queryable.d.ts +97 -97
- package/dist/exec/queryable.js +1310 -1204
- package/dist/exec/queryable.js.map +1 -6
- package/dist/exec/search-parser.d.ts +31 -31
- package/dist/exec/search-parser.d.ts.map +1 -1
- package/dist/exec/search-parser.js +158 -59
- package/dist/exec/search-parser.js.map +1 -6
- package/dist/expr/expr-unit.d.ts +4 -4
- package/dist/expr/expr-unit.js +24 -18
- package/dist/expr/expr-unit.js.map +1 -6
- package/dist/expr/expr.d.ts +6 -6
- package/dist/expr/expr.js +1872 -1844
- package/dist/expr/expr.js.map +1 -6
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -6
- package/dist/models/system-migration.js +7 -7
- package/dist/models/system-migration.js.map +1 -6
- package/dist/query-builder/base/expr-renderer-base.d.ts +10 -10
- package/dist/query-builder/base/expr-renderer-base.js +27 -21
- package/dist/query-builder/base/expr-renderer-base.js.map +1 -6
- package/dist/query-builder/base/query-builder-base.d.ts +21 -21
- package/dist/query-builder/base/query-builder-base.d.ts.map +1 -1
- package/dist/query-builder/base/query-builder-base.js +90 -80
- package/dist/query-builder/base/query-builder-base.js.map +1 -6
- package/dist/query-builder/mssql/mssql-expr-renderer.d.ts +4 -4
- package/dist/query-builder/mssql/mssql-expr-renderer.d.ts.map +1 -1
- package/dist/query-builder/mssql/mssql-expr-renderer.js +447 -420
- package/dist/query-builder/mssql/mssql-expr-renderer.js.map +1 -6
- package/dist/query-builder/mssql/mssql-query-builder.js +483 -443
- package/dist/query-builder/mssql/mssql-query-builder.js.map +1 -6
- package/dist/query-builder/mysql/mysql-expr-renderer.d.ts +4 -4
- package/dist/query-builder/mysql/mysql-expr-renderer.d.ts.map +1 -1
- package/dist/query-builder/mysql/mysql-expr-renderer.js +451 -419
- package/dist/query-builder/mysql/mysql-expr-renderer.js.map +1 -6
- package/dist/query-builder/mysql/mysql-query-builder.js +570 -479
- package/dist/query-builder/mysql/mysql-query-builder.js.map +1 -6
- package/dist/query-builder/postgresql/postgresql-expr-renderer.d.ts +4 -4
- package/dist/query-builder/postgresql/postgresql-expr-renderer.d.ts.map +1 -1
- package/dist/query-builder/postgresql/postgresql-expr-renderer.js +449 -422
- package/dist/query-builder/postgresql/postgresql-expr-renderer.js.map +1 -6
- package/dist/query-builder/postgresql/postgresql-query-builder.js +511 -460
- package/dist/query-builder/postgresql/postgresql-query-builder.js.map +1 -6
- package/dist/query-builder/query-builder.d.ts +1 -1
- package/dist/query-builder/query-builder.js +13 -13
- package/dist/query-builder/query-builder.js.map +1 -6
- package/dist/schema/factory/column-builder.d.ts +84 -84
- package/dist/schema/factory/column-builder.js +248 -185
- package/dist/schema/factory/column-builder.js.map +1 -6
- package/dist/schema/factory/index-builder.d.ts +38 -38
- package/dist/schema/factory/index-builder.js +144 -85
- package/dist/schema/factory/index-builder.js.map +1 -6
- package/dist/schema/factory/relation-builder.d.ts +91 -91
- package/dist/schema/factory/relation-builder.d.ts.map +1 -1
- package/dist/schema/factory/relation-builder.js +274 -136
- package/dist/schema/factory/relation-builder.js.map +1 -6
- package/dist/schema/procedure-builder.d.ts +51 -51
- package/dist/schema/procedure-builder.d.ts.map +1 -1
- package/dist/schema/procedure-builder.js +205 -131
- package/dist/schema/procedure-builder.js.map +1 -6
- package/dist/schema/table-builder.d.ts +55 -55
- package/dist/schema/table-builder.d.ts.map +1 -1
- package/dist/schema/table-builder.js +274 -205
- package/dist/schema/table-builder.js.map +1 -6
- package/dist/schema/view-builder.d.ts +44 -44
- package/dist/schema/view-builder.d.ts.map +1 -1
- package/dist/schema/view-builder.js +189 -116
- package/dist/schema/view-builder.js.map +1 -6
- package/dist/types/column.js +60 -30
- package/dist/types/column.js.map +1 -6
- package/dist/types/db-context-def.d.ts +9 -9
- package/dist/types/db-context-def.js +2 -1
- package/dist/types/db-context-def.js.map +1 -6
- package/dist/types/db.d.ts +47 -47
- package/dist/types/db.js +15 -5
- package/dist/types/db.js.map +1 -6
- package/dist/types/expr.d.ts +81 -81
- package/dist/types/expr.d.ts.map +1 -1
- package/dist/types/expr.js +3 -1
- package/dist/types/expr.js.map +1 -6
- package/dist/types/query-def.d.ts +46 -46
- package/dist/types/query-def.d.ts.map +1 -1
- package/dist/types/query-def.js +31 -24
- package/dist/types/query-def.js.map +1 -6
- package/dist/utils/result-parser.js +362 -221
- package/dist/utils/result-parser.js.map +1 -6
- package/package.json +5 -7
- package/src/create-db-context.ts +31 -31
- package/src/ddl/column-ddl.ts +4 -4
- package/src/ddl/initialize.ts +38 -38
- package/src/ddl/relation-ddl.ts +6 -6
- package/src/ddl/schema-ddl.ts +4 -4
- package/src/ddl/table-ddl.ts +24 -24
- package/src/errors/db-transaction-error.ts +13 -13
- package/src/exec/executable.ts +25 -25
- package/src/exec/queryable.ts +134 -134
- package/src/exec/search-parser.ts +50 -50
- package/src/expr/expr-unit.ts +4 -4
- package/src/expr/expr.ts +13 -13
- package/src/index.ts +8 -8
- package/src/models/system-migration.ts +1 -1
- package/src/query-builder/base/expr-renderer-base.ts +21 -21
- package/src/query-builder/base/query-builder-base.ts +33 -33
- package/src/query-builder/mssql/mssql-expr-renderer.ts +11 -11
- package/src/query-builder/mssql/mssql-query-builder.ts +11 -11
- package/src/query-builder/mysql/mysql-expr-renderer.ts +15 -15
- package/src/query-builder/mysql/mysql-query-builder.ts +3 -3
- package/src/query-builder/postgresql/postgresql-expr-renderer.ts +9 -9
- package/src/query-builder/postgresql/postgresql-query-builder.ts +7 -7
- package/src/query-builder/query-builder.ts +1 -1
- package/src/schema/factory/column-builder.ts +86 -86
- package/src/schema/factory/index-builder.ts +38 -38
- package/src/schema/factory/relation-builder.ts +93 -93
- package/src/schema/procedure-builder.ts +52 -52
- package/src/schema/table-builder.ts +56 -56
- package/src/schema/view-builder.ts +45 -45
- package/src/types/column.ts +1 -1
- package/src/types/db-context-def.ts +15 -15
- package/src/types/db.ts +50 -50
- package/src/types/expr.ts +103 -103
- package/src/types/query-def.ts +50 -50
- package/src/utils/result-parser.ts +39 -39
- package/README.md +0 -192
- package/docs/core.md +0 -234
- package/docs/expression.md +0 -234
- package/docs/query-builder.md +0 -93
- package/docs/queryable.md +0 -198
- package/docs/schema-builders.md +0 -463
- package/docs/types.md +0 -445
- package/docs/utilities.md +0 -27
- package/tests/db-context/create-db-context.spec.ts +0 -193
- package/tests/db-context/define-db-context.spec.ts +0 -17
- package/tests/ddl/basic.expected.ts +0 -341
- package/tests/ddl/basic.spec.ts +0 -557
- package/tests/ddl/column-builder.expected.ts +0 -310
- package/tests/ddl/column-builder.spec.ts +0 -525
- package/tests/ddl/index-builder.expected.ts +0 -38
- package/tests/ddl/index-builder.spec.ts +0 -148
- package/tests/ddl/procedure-builder.expected.ts +0 -52
- package/tests/ddl/procedure-builder.spec.ts +0 -128
- package/tests/ddl/relation-builder.expected.ts +0 -36
- package/tests/ddl/relation-builder.spec.ts +0 -171
- package/tests/ddl/table-builder.expected.ts +0 -113
- package/tests/ddl/table-builder.spec.ts +0 -399
- package/tests/ddl/view-builder.expected.ts +0 -38
- package/tests/ddl/view-builder.spec.ts +0 -116
- package/tests/dml/delete.expected.ts +0 -96
- package/tests/dml/delete.spec.ts +0 -127
- package/tests/dml/insert.expected.ts +0 -192
- package/tests/dml/insert.spec.ts +0 -210
- package/tests/dml/update.expected.ts +0 -176
- package/tests/dml/update.spec.ts +0 -222
- package/tests/dml/upsert.expected.ts +0 -215
- package/tests/dml/upsert.spec.ts +0 -190
- package/tests/errors/queryable-errors.spec.ts +0 -126
- package/tests/escape.spec.ts +0 -59
- package/tests/examples/pivot.expected.ts +0 -211
- package/tests/examples/pivot.spec.ts +0 -200
- package/tests/examples/sampling.expected.ts +0 -69
- package/tests/examples/sampling.spec.ts +0 -42
- package/tests/examples/unpivot.expected.ts +0 -120
- package/tests/examples/unpivot.spec.ts +0 -161
- package/tests/exec/search-parser.spec.ts +0 -267
- package/tests/executable/basic.expected.ts +0 -18
- package/tests/executable/basic.spec.ts +0 -54
- package/tests/expr/comparison.expected.ts +0 -282
- package/tests/expr/comparison.spec.ts +0 -334
- package/tests/expr/conditional.expected.ts +0 -134
- package/tests/expr/conditional.spec.ts +0 -249
- package/tests/expr/date.expected.ts +0 -332
- package/tests/expr/date.spec.ts +0 -459
- package/tests/expr/math.expected.ts +0 -62
- package/tests/expr/math.spec.ts +0 -59
- package/tests/expr/string.expected.ts +0 -218
- package/tests/expr/string.spec.ts +0 -300
- package/tests/expr/utility.expected.ts +0 -147
- package/tests/expr/utility.spec.ts +0 -155
- package/tests/select/basic.expected.ts +0 -322
- package/tests/select/basic.spec.ts +0 -433
- package/tests/select/filter.expected.ts +0 -357
- package/tests/select/filter.spec.ts +0 -954
- package/tests/select/group.expected.ts +0 -169
- package/tests/select/group.spec.ts +0 -159
- package/tests/select/join.expected.ts +0 -582
- package/tests/select/join.spec.ts +0 -692
- package/tests/select/order.expected.ts +0 -150
- package/tests/select/order.spec.ts +0 -140
- package/tests/select/recursive-cte.expected.ts +0 -244
- package/tests/select/recursive-cte.spec.ts +0 -514
- package/tests/select/result-meta.spec.ts +0 -270
- package/tests/select/subquery.expected.ts +0 -363
- package/tests/select/subquery.spec.ts +0 -441
- package/tests/select/view.expected.ts +0 -155
- package/tests/select/view.spec.ts +0 -235
- package/tests/select/window.expected.ts +0 -345
- package/tests/select/window.spec.ts +0 -433
- package/tests/setup/MockExecutor.ts +0 -18
- package/tests/setup/TestDbContext.ts +0 -59
- package/tests/setup/models/Company.ts +0 -13
- package/tests/setup/models/Employee.ts +0 -10
- package/tests/setup/models/MonthlySales.ts +0 -11
- package/tests/setup/models/Post.ts +0 -16
- package/tests/setup/models/Sales.ts +0 -10
- package/tests/setup/models/User.ts +0 -19
- package/tests/setup/procedure/GetAllUsers.ts +0 -9
- package/tests/setup/procedure/GetUserById.ts +0 -12
- package/tests/setup/test-utils.ts +0 -72
- package/tests/setup/views/ActiveUsers.ts +0 -8
- package/tests/setup/views/UserSummary.ts +0 -11
- package/tests/types/nullable-queryable-record.spec.ts +0 -97
- package/tests/utils/result-parser-perf.spec.ts +0 -143
- package/tests/utils/result-parser.spec.ts +0 -667
|
@@ -3,27 +3,27 @@ import type { IndexBuilder } from "../schema/factory/index-builder";
|
|
|
3
3
|
import type { QueryDef, QueryDefObjectName, AddPrimaryKeyQueryDef, DropPrimaryKeyQueryDef, DropForeignKeyQueryDef, DropIndexQueryDef } from "../types/query-def";
|
|
4
4
|
import type { DbContextBase } from "../types/db-context-def";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* DROP PRIMARY KEY QueryDef 생성
|
|
7
7
|
*/
|
|
8
8
|
export declare function getDropPrimaryKeyQueryDef(table: QueryDefObjectName): DropPrimaryKeyQueryDef;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* ADD PRIMARY KEY QueryDef 생성
|
|
11
11
|
*/
|
|
12
12
|
export declare function getAddPrimaryKeyQueryDef(table: QueryDefObjectName, columns: string[]): AddPrimaryKeyQueryDef;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* ADD FOREIGN KEY QueryDef 생성
|
|
15
15
|
*/
|
|
16
16
|
export declare function getAddForeignKeyQueryDef(db: DbContextBase, table: QueryDefObjectName, relationName: string, relationDef: ForeignKeyBuilder<any, any>): QueryDef;
|
|
17
17
|
/**
|
|
18
|
-
* ADD INDEX QueryDef
|
|
18
|
+
* ADD INDEX QueryDef 생성
|
|
19
19
|
*/
|
|
20
20
|
export declare function getAddIndexQueryDef(table: QueryDefObjectName, indexBuilder: IndexBuilder<string[]>): QueryDef;
|
|
21
21
|
/**
|
|
22
|
-
* DROP FOREIGN KEY QueryDef
|
|
22
|
+
* DROP FOREIGN KEY QueryDef 생성
|
|
23
23
|
*/
|
|
24
24
|
export declare function getDropForeignKeyQueryDef(table: QueryDefObjectName, relationName: string): DropForeignKeyQueryDef;
|
|
25
25
|
/**
|
|
26
|
-
* DROP INDEX QueryDef
|
|
26
|
+
* DROP INDEX QueryDef 생성
|
|
27
27
|
*/
|
|
28
28
|
export declare function getDropIndexQueryDef(table: QueryDefObjectName, columns: string[]): DropIndexQueryDef;
|
|
29
29
|
//# sourceMappingURL=relation-ddl.d.ts.map
|
package/dist/ddl/relation-ddl.js
CHANGED
|
@@ -1,56 +1,63 @@
|
|
|
1
1
|
import { getMatchedPrimaryKeys } from "../exec/queryable.js";
|
|
2
2
|
import { getQueryDefObjectName } from "./table-ddl.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* DROP PRIMARY KEY QueryDef 생성
|
|
5
|
+
*/
|
|
6
|
+
export function getDropPrimaryKeyQueryDef(table) {
|
|
7
|
+
return { type: "dropPrimaryKey", table };
|
|
5
8
|
}
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
/**
|
|
10
|
+
* ADD PRIMARY KEY QueryDef 생성
|
|
11
|
+
*/
|
|
12
|
+
export function getAddPrimaryKeyQueryDef(table, columns) {
|
|
13
|
+
return { type: "addPrimaryKey", table, columns };
|
|
8
14
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
/**
|
|
16
|
+
* ADD FOREIGN KEY QueryDef 생성
|
|
17
|
+
*/
|
|
18
|
+
export function getAddForeignKeyQueryDef(db, table, relationName, relationDef) {
|
|
19
|
+
const targetTable = relationDef.meta.targetFn();
|
|
20
|
+
const fkColumns = relationDef.meta.columns;
|
|
21
|
+
const pk = getMatchedPrimaryKeys(fkColumns, targetTable);
|
|
22
|
+
return {
|
|
23
|
+
type: "addForeignKey",
|
|
24
|
+
table,
|
|
25
|
+
foreignKey: {
|
|
26
|
+
name: `FK_${table.name}_${relationName}`,
|
|
27
|
+
fkColumns,
|
|
28
|
+
targetTable: getQueryDefObjectName(db, targetTable),
|
|
29
|
+
targetPkColumns: pk,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
23
32
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
/**
|
|
34
|
+
* ADD INDEX QueryDef 생성
|
|
35
|
+
*/
|
|
36
|
+
export function getAddIndexQueryDef(table, indexBuilder) {
|
|
37
|
+
const indexMeta = indexBuilder.meta;
|
|
38
|
+
return {
|
|
39
|
+
type: "addIndex",
|
|
40
|
+
table,
|
|
41
|
+
index: {
|
|
42
|
+
name: indexBuilder.meta.name ?? `IDX_${table.name}_${indexMeta.columns.join("_")}`,
|
|
43
|
+
columns: indexMeta.columns.map((col, i) => ({
|
|
44
|
+
name: col,
|
|
45
|
+
orderBy: indexMeta.orderBy?.[i] ?? "ASC",
|
|
46
|
+
})),
|
|
47
|
+
unique: indexMeta.unique,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
41
50
|
}
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
/**
|
|
52
|
+
* DROP FOREIGN KEY QueryDef 생성
|
|
53
|
+
*/
|
|
54
|
+
export function getDropForeignKeyQueryDef(table, relationName) {
|
|
55
|
+
return { type: "dropForeignKey", table, foreignKey: `FK_${table.name}_${relationName}` };
|
|
44
56
|
}
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
/**
|
|
58
|
+
* DROP INDEX QueryDef 생성
|
|
59
|
+
*/
|
|
60
|
+
export function getDropIndexQueryDef(table, columns) {
|
|
61
|
+
return { type: "dropIndex", table, index: `IDX_${table.name}_${columns.join("_")}` };
|
|
47
62
|
}
|
|
48
|
-
|
|
49
|
-
getAddForeignKeyQueryDef,
|
|
50
|
-
getAddIndexQueryDef,
|
|
51
|
-
getAddPrimaryKeyQueryDef,
|
|
52
|
-
getDropForeignKeyQueryDef,
|
|
53
|
-
getDropIndexQueryDef,
|
|
54
|
-
getDropPrimaryKeyQueryDef
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=relation-ddl.js.map
|
|
63
|
+
//# sourceMappingURL=relation-ddl.js.map
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/ddl/relation-ddl.ts"],
|
|
4
|
-
"mappings": "AAWA,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AAK/B,SAAS,0BAA0B,OAAmD;AAC3F,SAAO,EAAE,MAAM,kBAAkB,MAAM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E;YAClF,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC1C,IAAI,EAAE,GAAG;gBACT,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK;aACzC,CAAC,CAAC;YACH,MAAM,EAAE,SAAS,CAAC,MAAM;SACzB;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAyB,EAAE,YAAoB;IACvF,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC,IAAI,IAAI,YAAY,EAAE,EAAE,CAAC;AAC3F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAyB,EAAE,OAAiB;IAC/E,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;AACvF,CAAC"}
|
package/dist/ddl/schema-ddl.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { QueryDefObjectName, ClearSchemaQueryDef, SchemaExistsQueryDef, TruncateQueryDef, SwitchFkQueryDef } from "../types/query-def";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* CLEAR SCHEMA QueryDef 생성
|
|
4
4
|
*/
|
|
5
5
|
export declare function getClearSchemaQueryDef(params: {
|
|
6
6
|
database: string;
|
|
7
7
|
schema?: string;
|
|
8
8
|
}): ClearSchemaQueryDef;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* SCHEMA EXISTS QueryDef 생성
|
|
11
11
|
*/
|
|
12
12
|
export declare function getSchemaExistsQueryDef(database: string, schema?: string): SchemaExistsQueryDef;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* TRUNCATE TABLE QueryDef 생성
|
|
15
15
|
*/
|
|
16
16
|
export declare function getTruncateQueryDef(table: QueryDefObjectName): TruncateQueryDef;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* SWITCH FK QueryDef 생성
|
|
19
19
|
*/
|
|
20
20
|
export declare function getSwitchFkQueryDef(table: QueryDefObjectName, enabled: boolean): SwitchFkQueryDef;
|
|
21
21
|
//# sourceMappingURL=schema-ddl.d.ts.map
|
package/dist/ddl/schema-ddl.js
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* CLEAR SCHEMA QueryDef 생성
|
|
3
|
+
*/
|
|
4
|
+
export function getClearSchemaQueryDef(params) {
|
|
5
|
+
return { type: "clearSchema", database: params.database, schema: params.schema };
|
|
3
6
|
}
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
/**
|
|
8
|
+
* SCHEMA EXISTS QueryDef 생성
|
|
9
|
+
*/
|
|
10
|
+
export function getSchemaExistsQueryDef(database, schema) {
|
|
11
|
+
return { type: "schemaExists", database, schema };
|
|
6
12
|
}
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
/**
|
|
14
|
+
* TRUNCATE TABLE QueryDef 생성
|
|
15
|
+
*/
|
|
16
|
+
export function getTruncateQueryDef(table) {
|
|
17
|
+
return { type: "truncate", table };
|
|
9
18
|
}
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
/**
|
|
20
|
+
* SWITCH FK QueryDef 생성
|
|
21
|
+
*/
|
|
22
|
+
export function getSwitchFkQueryDef(table, enabled) {
|
|
23
|
+
return { type: "switchFk", table, enabled };
|
|
12
24
|
}
|
|
13
|
-
|
|
14
|
-
getClearSchemaQueryDef,
|
|
15
|
-
getSchemaExistsQueryDef,
|
|
16
|
-
getSwitchFkQueryDef,
|
|
17
|
-
getTruncateQueryDef
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=schema-ddl.js.map
|
|
25
|
+
//# sourceMappingURL=schema-ddl.js.map
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/ddl/schema-ddl.ts"],
|
|
4
|
-
"mappings": "AAWO,SAAS,uBAAuB,QAGf;AACtB,SAAO,EAAE,MAAM,eAAe,UAAU,OAAO,UAAU,QAAQ,OAAO,OAAO;AACjF;AAKO,SAAS,wBAAwB,UAAkB,QAAuC;AAC/F,SAAO,EAAE,MAAM,gBAAgB,UAAU,OAAO;AAClD;AAKO,SAAS,oBAAoB,OAA6C;AAC/E,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;AAKO,SAAS,oBACd,OACA,SACkB;AAClB,SAAO,EAAE,MAAM,YAAY,OAAO,QAAQ;AAC5C;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"file":"schema-ddl.js","sourceRoot":"","sources":["..\\..\\src\\ddl\\schema-ddl.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAGtC;IACC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;AACnF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAgB,EAAE,MAAe;IACvE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAyB;IAC3D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAyB,EACzB,OAAgB;IAEhB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC9C,CAAC"}
|
package/dist/ddl/table-ddl.d.ts
CHANGED
|
@@ -4,63 +4,63 @@ import { ProcedureBuilder } from "../schema/procedure-builder";
|
|
|
4
4
|
import type { QueryDef, QueryDefObjectName, DropTableQueryDef, RenameTableQueryDef, DropViewQueryDef, DropProcQueryDef } from "../types/query-def";
|
|
5
5
|
import type { DbContextBase } from "../types/db-context-def";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Builder를 CREATE QueryDef로 변환
|
|
8
8
|
*
|
|
9
|
-
* @param db - DbContext
|
|
9
|
+
* @param db - DbContext 인스턴스
|
|
10
10
|
* @param builder - Table/View/Procedure builder
|
|
11
11
|
* @returns CREATE TABLE/VIEW/PROCEDURE QueryDef
|
|
12
|
-
* @throws {Error}
|
|
12
|
+
* @throws {Error} 알 수 없는 builder 타입일 때
|
|
13
13
|
*/
|
|
14
14
|
export declare function getCreateObjectQueryDef(db: DbContextBase, builder: TableBuilder<any, any> | ViewBuilder<any, any, any> | ProcedureBuilder<any, any>): QueryDef;
|
|
15
15
|
/**
|
|
16
|
-
* CREATE TABLE QueryDef
|
|
16
|
+
* CREATE TABLE QueryDef 생성
|
|
17
17
|
*
|
|
18
|
-
* @param db - DbContext
|
|
18
|
+
* @param db - DbContext 인스턴스
|
|
19
19
|
* @param table - Table builder
|
|
20
20
|
* @returns CREATE TABLE QueryDef
|
|
21
|
-
* @throws {Error}
|
|
21
|
+
* @throws {Error} 테이블에 column이 없을 때
|
|
22
22
|
*/
|
|
23
23
|
export declare function getCreateTableQueryDef(db: DbContextBase, table: TableBuilder<any, any>): QueryDef;
|
|
24
24
|
/**
|
|
25
|
-
* CREATE VIEW QueryDef
|
|
25
|
+
* CREATE VIEW QueryDef 생성
|
|
26
26
|
*
|
|
27
|
-
* @param db - DbContext
|
|
27
|
+
* @param db - DbContext 인스턴스
|
|
28
28
|
* @param view - View builder
|
|
29
29
|
* @returns CREATE VIEW QueryDef
|
|
30
|
-
* @throws {Error}
|
|
30
|
+
* @throws {Error} View에 viewFn이 없을 때
|
|
31
31
|
*/
|
|
32
32
|
export declare function getCreateViewQueryDef(db: DbContextBase, view: ViewBuilder<any, any, any>): QueryDef;
|
|
33
33
|
/**
|
|
34
|
-
* CREATE PROCEDURE QueryDef
|
|
34
|
+
* CREATE PROCEDURE QueryDef 생성
|
|
35
35
|
*
|
|
36
|
-
* @param db - DbContext
|
|
36
|
+
* @param db - DbContext 인스턴스
|
|
37
37
|
* @param procedure - Procedure builder
|
|
38
38
|
* @returns CREATE PROCEDURE QueryDef
|
|
39
|
-
* @throws {Error}
|
|
39
|
+
* @throws {Error} Procedure에 body가 없을 때
|
|
40
40
|
*/
|
|
41
41
|
export declare function getCreateProcQueryDef(db: DbContextBase, procedure: ProcedureBuilder<any, any>): QueryDef;
|
|
42
42
|
/**
|
|
43
|
-
* DROP TABLE QueryDef
|
|
43
|
+
* DROP TABLE QueryDef 생성
|
|
44
44
|
*/
|
|
45
45
|
export declare function getDropTableQueryDef(table: QueryDefObjectName): DropTableQueryDef;
|
|
46
46
|
/**
|
|
47
|
-
* RENAME TABLE QueryDef
|
|
47
|
+
* RENAME TABLE QueryDef 생성
|
|
48
48
|
*/
|
|
49
49
|
export declare function getRenameTableQueryDef(table: QueryDefObjectName, newName: string): RenameTableQueryDef;
|
|
50
50
|
/**
|
|
51
|
-
* DROP VIEW QueryDef
|
|
51
|
+
* DROP VIEW QueryDef 생성
|
|
52
52
|
*/
|
|
53
53
|
export declare function getDropViewQueryDef(view: QueryDefObjectName): DropViewQueryDef;
|
|
54
54
|
/**
|
|
55
|
-
* DROP PROCEDURE QueryDef
|
|
55
|
+
* DROP PROCEDURE QueryDef 생성
|
|
56
56
|
*/
|
|
57
57
|
export declare function getDropProcQueryDef(procedure: QueryDefObjectName): DropProcQueryDef;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* TableBuilder/ViewBuilder를 QueryDefObjectName으로 변환
|
|
60
60
|
*
|
|
61
|
-
* @param db - DbContext
|
|
62
|
-
* @param tableOrView - Table
|
|
63
|
-
* @returns
|
|
61
|
+
* @param db - DbContext 인스턴스
|
|
62
|
+
* @param tableOrView - Table 또는 View builder
|
|
63
|
+
* @returns QueryDef에서 사용할 객체 이름 정보
|
|
64
64
|
*/
|
|
65
65
|
export declare function getQueryDefObjectName(db: DbContextBase, tableOrView: TableBuilder<any, any> | ViewBuilder<any, any, any>): QueryDefObjectName;
|
|
66
66
|
//# sourceMappingURL=table-ddl.d.ts.map
|
package/dist/ddl/table-ddl.js
CHANGED
|
@@ -2,105 +2,151 @@ import { TableBuilder } from "../schema/table-builder.js";
|
|
|
2
2
|
import { ViewBuilder } from "../schema/view-builder.js";
|
|
3
3
|
import { ProcedureBuilder } from "../schema/procedure-builder.js";
|
|
4
4
|
import { obj } from "@simplysm/core-common";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Builder를 CREATE QueryDef로 변환
|
|
7
|
+
*
|
|
8
|
+
* @param db - DbContext 인스턴스
|
|
9
|
+
* @param builder - Table/View/Procedure builder
|
|
10
|
+
* @returns CREATE TABLE/VIEW/PROCEDURE QueryDef
|
|
11
|
+
* @throws {Error} 알 수 없는 builder 타입일 때
|
|
12
|
+
*/
|
|
13
|
+
export function getCreateObjectQueryDef(db, builder) {
|
|
14
|
+
if (builder instanceof TableBuilder) {
|
|
15
|
+
return getCreateTableQueryDef(db, builder);
|
|
16
|
+
}
|
|
17
|
+
else if (builder instanceof ViewBuilder) {
|
|
18
|
+
return getCreateViewQueryDef(db, builder);
|
|
19
|
+
}
|
|
20
|
+
else if (builder instanceof ProcedureBuilder) {
|
|
21
|
+
return getCreateProcQueryDef(db, builder);
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`알 수 없는 builder 타입: ${typeof builder}`);
|
|
14
24
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
/**
|
|
26
|
+
* CREATE TABLE QueryDef 생성
|
|
27
|
+
*
|
|
28
|
+
* @param db - DbContext 인스턴스
|
|
29
|
+
* @param table - Table builder
|
|
30
|
+
* @returns CREATE TABLE QueryDef
|
|
31
|
+
* @throws {Error} 테이블에 column이 없을 때
|
|
32
|
+
*/
|
|
33
|
+
export function getCreateTableQueryDef(db, table) {
|
|
34
|
+
const columns = table.meta.columns;
|
|
35
|
+
if (columns == null) {
|
|
36
|
+
throw new Error(`테이블 '${table.meta.name}'에 column이 없습니다.`);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
type: "createTable",
|
|
40
|
+
table: getQueryDefObjectName(db, table),
|
|
41
|
+
columns: Object.entries(columns).map(([key, col]) => ({
|
|
42
|
+
name: key,
|
|
43
|
+
dataType: col.meta.dataType,
|
|
44
|
+
autoIncrement: col.meta.autoIncrement,
|
|
45
|
+
nullable: col.meta.nullable,
|
|
46
|
+
default: col.meta.default,
|
|
47
|
+
})),
|
|
48
|
+
primaryKey: table.meta.primaryKey,
|
|
49
|
+
};
|
|
32
50
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
/**
|
|
52
|
+
* CREATE VIEW QueryDef 생성
|
|
53
|
+
*
|
|
54
|
+
* @param db - DbContext 인스턴스
|
|
55
|
+
* @param view - View builder
|
|
56
|
+
* @returns CREATE VIEW QueryDef
|
|
57
|
+
* @throws {Error} View에 viewFn이 없을 때
|
|
58
|
+
*/
|
|
59
|
+
export function getCreateViewQueryDef(db, view) {
|
|
60
|
+
if (view.meta.viewFn == null) {
|
|
61
|
+
throw new Error(`View '${view.meta.name}'에 viewFn이 없습니다.`);
|
|
62
|
+
}
|
|
63
|
+
const qr = view.meta.viewFn(db);
|
|
64
|
+
const selectDef = qr.getSelectQueryDef();
|
|
65
|
+
return {
|
|
66
|
+
type: "createView",
|
|
67
|
+
view: {
|
|
68
|
+
database: view.meta.database ?? db.database,
|
|
69
|
+
schema: view.meta.schema ?? db.schema,
|
|
70
|
+
name: view.meta.name,
|
|
71
|
+
},
|
|
72
|
+
queryDef: selectDef,
|
|
73
|
+
};
|
|
48
74
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
/**
|
|
76
|
+
* CREATE PROCEDURE QueryDef 생성
|
|
77
|
+
*
|
|
78
|
+
* @param db - DbContext 인스턴스
|
|
79
|
+
* @param procedure - Procedure builder
|
|
80
|
+
* @returns CREATE PROCEDURE QueryDef
|
|
81
|
+
* @throws {Error} Procedure에 body가 없을 때
|
|
82
|
+
*/
|
|
83
|
+
export function getCreateProcQueryDef(db, procedure) {
|
|
84
|
+
if (procedure.meta.query == null) {
|
|
85
|
+
throw new Error(`Procedure '${procedure.meta.name}'에 body가 없습니다.`);
|
|
86
|
+
}
|
|
87
|
+
const params = procedure.meta.params;
|
|
88
|
+
const returns = procedure.meta.returns;
|
|
89
|
+
return {
|
|
90
|
+
type: "createProc",
|
|
91
|
+
procedure: {
|
|
92
|
+
database: procedure.meta.database ?? db.database,
|
|
93
|
+
schema: procedure.meta.schema ?? db.schema,
|
|
94
|
+
name: procedure.meta.name,
|
|
95
|
+
},
|
|
96
|
+
params: params
|
|
97
|
+
? Object.entries(params).map(([key, col]) => ({
|
|
98
|
+
name: key,
|
|
99
|
+
dataType: col.meta.dataType,
|
|
100
|
+
nullable: col.meta.nullable,
|
|
101
|
+
default: col.meta.default,
|
|
102
|
+
}))
|
|
103
|
+
: undefined,
|
|
104
|
+
returns: returns
|
|
105
|
+
? Object.entries(returns).map(([key, col]) => ({
|
|
106
|
+
name: key,
|
|
107
|
+
dataType: col.meta.dataType,
|
|
108
|
+
nullable: col.meta.nullable,
|
|
109
|
+
}))
|
|
110
|
+
: undefined,
|
|
111
|
+
query: procedure.meta.query,
|
|
112
|
+
};
|
|
75
113
|
}
|
|
76
|
-
|
|
77
|
-
|
|
114
|
+
/**
|
|
115
|
+
* DROP TABLE QueryDef 생성
|
|
116
|
+
*/
|
|
117
|
+
export function getDropTableQueryDef(table) {
|
|
118
|
+
return { type: "dropTable", table };
|
|
78
119
|
}
|
|
79
|
-
|
|
80
|
-
|
|
120
|
+
/**
|
|
121
|
+
* RENAME TABLE QueryDef 생성
|
|
122
|
+
*/
|
|
123
|
+
export function getRenameTableQueryDef(table, newName) {
|
|
124
|
+
return { type: "renameTable", table, newName };
|
|
81
125
|
}
|
|
82
|
-
|
|
83
|
-
|
|
126
|
+
/**
|
|
127
|
+
* DROP VIEW QueryDef 생성
|
|
128
|
+
*/
|
|
129
|
+
export function getDropViewQueryDef(view) {
|
|
130
|
+
return { type: "dropView", view };
|
|
84
131
|
}
|
|
85
|
-
|
|
86
|
-
|
|
132
|
+
/**
|
|
133
|
+
* DROP PROCEDURE QueryDef 생성
|
|
134
|
+
*/
|
|
135
|
+
export function getDropProcQueryDef(procedure) {
|
|
136
|
+
return { type: "dropProc", procedure };
|
|
87
137
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
138
|
+
/**
|
|
139
|
+
* TableBuilder/ViewBuilder를 QueryDefObjectName으로 변환
|
|
140
|
+
*
|
|
141
|
+
* @param db - DbContext 인스턴스
|
|
142
|
+
* @param tableOrView - Table 또는 View builder
|
|
143
|
+
* @returns QueryDef에서 사용할 객체 이름 정보
|
|
144
|
+
*/
|
|
145
|
+
export function getQueryDefObjectName(db, tableOrView) {
|
|
146
|
+
return obj.clearUndefined({
|
|
147
|
+
database: tableOrView.meta.database ?? db.database,
|
|
148
|
+
schema: tableOrView.meta.schema ?? db.schema,
|
|
149
|
+
name: tableOrView.meta.name,
|
|
150
|
+
});
|
|
94
151
|
}
|
|
95
|
-
|
|
96
|
-
getCreateObjectQueryDef,
|
|
97
|
-
getCreateProcQueryDef,
|
|
98
|
-
getCreateTableQueryDef,
|
|
99
|
-
getCreateViewQueryDef,
|
|
100
|
-
getDropProcQueryDef,
|
|
101
|
-
getDropTableQueryDef,
|
|
102
|
-
getDropViewQueryDef,
|
|
103
|
-
getQueryDefObjectName,
|
|
104
|
-
getRenameTableQueryDef
|
|
105
|
-
};
|
|
106
|
-
//# sourceMappingURL=table-ddl.js.map
|
|
152
|
+
//# sourceMappingURL=table-ddl.js.map
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/ddl/table-ddl.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AAWjC,SAAS,WAAW;AAUb,SAAS,wBACd,IACA,SACU;AACV,MAAI,mBAAmB,cAAc;AACnC,WAAO,uBAAuB,IAAI,OAAO;AAAA,EAC3C,WAAW,mBAAmB,aAAa;AACzC,WAAO,sBAAsB,IAAI,OAAO;AAAA,EAC1C,WAAW,mBAAmB,kBAAkB;AAC9C,WAAO,sBAAsB,IAAI,OAAO;AAAA,EAC1C;AAEA,QAAM,IAAI,MAAM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AE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAwB;IAC1D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAA6B;IAC/D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,EAAiB,EACjB,WAAgE;IAEhE,OAAO,GAAG,CAAC,cAAc,CAAC;QACxB,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,QAAQ;QAClD,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,MAAM;QAC5C,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI;KAC5B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { _Migration } from "./models/system-migration.js";
|
|
2
|
-
function defineDbContext(config) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
export function defineDbContext(config) {
|
|
3
|
+
return {
|
|
4
|
+
meta: {
|
|
5
|
+
tables: { ...(config.tables ?? {}), _migration: _Migration },
|
|
6
|
+
views: (config.views ?? {}),
|
|
7
|
+
procedures: (config.procedures ?? {}),
|
|
8
|
+
migrations: config.migrations ?? [],
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
defineDbContext
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=define-db-context.js.map
|
|
12
|
+
//# sourceMappingURL=define-db-context.js.map
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/define-db-context.ts"],
|
|
4
|
-
"mappings": "AAKA,SAAS,kBAAkB;AAEpB,SAAS,gBAId,QAKiF;AACjF,SAAO;AAAA,IACL,MAAM;AAAA,MACJ,QAAQ,EAAE,GAAI,OAAO,UAAU,CAAC,GAAI,YAAY,WAAW;AAAA,MAG3D,OAAQ,OAAO,SAAS,CAAC;AAAA,MACzB,YAAa,OAAO,cAAc,CAAC;AAAA,MACnC,YAAY,OAAO,cAAc,CAAC;AAAA,IACpC;AAAA,EACF;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"file":"define-db-context.js","sourceRoot":"","sources":["..\\src\\define-db-context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,MAAM,UAAU,eAAe,CAI7B,MAKD;IACC,OAAO;QACL,IAAI,EAAE;YACJ,MAAM,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,UAAU,EAEzD;YACD,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAW;YACrC,UAAU,EAAE,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAgB;YACpD,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,EAAE;SACpC;KACF,CAAC;AACJ,CAAC"}
|