sonamu 0.4.9 → 0.4.11
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/{base-model-C24du9JT.d.ts → base-model-Br6krkwK.d.ts} +1 -1
- package/dist/{base-model-IZdmwmB5.d.mts → base-model-BvVra-8f.d.mts} +1 -1
- package/dist/bin/cli.js +51 -51
- package/dist/bin/cli.mjs +2 -2
- package/dist/{chunk-OTL37JQ4.mjs → chunk-634GIW42.mjs} +10 -8
- package/dist/chunk-634GIW42.mjs.map +1 -0
- package/dist/{chunk-AK547YMV.mjs → chunk-A2BDNO7E.mjs} +2 -2
- package/dist/{chunk-LD7OHPVK.js → chunk-GUKIIOZI.js} +108 -106
- package/dist/chunk-GUKIIOZI.js.map +1 -0
- package/dist/{chunk-IV7ZWWBN.mjs → chunk-GUV6I64Y.mjs} +69 -40
- package/dist/chunk-GUV6I64Y.mjs.map +1 -0
- package/dist/{chunk-2VEHSKNA.js → chunk-KX4762I3.js} +69 -40
- package/dist/chunk-KX4762I3.js.map +1 -0
- package/dist/{chunk-L3RJSG2K.mjs → chunk-PGPMEMK6.mjs} +2 -2
- package/dist/{chunk-IDNBP4MH.js → chunk-QIHV5UYF.js} +4 -4
- package/dist/{chunk-GHF56FO6.js → chunk-Z53BUBO4.js} +7 -7
- package/dist/database/drivers/knex/base-model.d.mts +2 -2
- package/dist/database/drivers/knex/base-model.d.ts +2 -2
- package/dist/database/drivers/knex/base-model.js +8 -8
- package/dist/database/drivers/knex/base-model.mjs +3 -3
- package/dist/database/drivers/kysely/base-model.d.mts +2 -2
- package/dist/database/drivers/kysely/base-model.d.ts +2 -2
- package/dist/database/drivers/kysely/base-model.js +9 -9
- package/dist/database/drivers/kysely/base-model.mjs +3 -3
- package/dist/index.d.mts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{model-Dbbfpk2X.d.ts → model-DWoinpJ7.d.mts} +79 -9
- package/dist/{model-Dbbfpk2X.d.mts → model-DWoinpJ7.d.ts} +79 -9
- package/package.json +1 -1
- package/src/api/base-frame.ts +14 -0
- package/src/api/decorators.ts +2 -1
- package/src/entity/entity-utils.ts +1 -0
- package/src/entity/migrator.ts +8 -6
- package/src/index.ts +1 -0
- package/src/syncer/syncer.ts +76 -39
- package/src/templates/service.template.ts +4 -6
- package/src/types/types.ts +19 -7
- package/dist/chunk-2VEHSKNA.js.map +0 -1
- package/dist/chunk-IV7ZWWBN.mjs.map +0 -1
- package/dist/chunk-LD7OHPVK.js.map +0 -1
- package/dist/chunk-OTL37JQ4.mjs.map +0 -1
- /package/dist/{chunk-AK547YMV.mjs.map → chunk-A2BDNO7E.mjs.map} +0 -0
- /package/dist/{chunk-L3RJSG2K.mjs.map → chunk-PGPMEMK6.mjs.map} +0 -0
- /package/dist/{chunk-IDNBP4MH.js.map → chunk-QIHV5UYF.js.map} +0 -0
- /package/dist/{chunk-GHF56FO6.js.map → chunk-Z53BUBO4.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DB
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GUV6I64Y.mjs";
|
|
4
4
|
|
|
5
5
|
// src/database/base-model.ts
|
|
6
6
|
import { DateTime } from "luxon";
|
|
@@ -228,4 +228,4 @@ var BaseModelClassAbstract = class {
|
|
|
228
228
|
export {
|
|
229
229
|
BaseModelClassAbstract
|
|
230
230
|
};
|
|
231
|
-
//# sourceMappingURL=chunk-
|
|
231
|
+
//# sourceMappingURL=chunk-PGPMEMK6.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKX4762I3js = require('./chunk-KX4762I3.js');
|
|
4
4
|
|
|
5
5
|
// src/database/base-model.ts
|
|
6
6
|
var _luxon = require('luxon');
|
|
@@ -53,8 +53,8 @@ var BaseModelClassAbstract = (_class = class {constructor() { _class.prototype._
|
|
|
53
53
|
db: _db,
|
|
54
54
|
optimizeCountQuery
|
|
55
55
|
}) {
|
|
56
|
-
const db = _nullishCoalesce(_db, () => (
|
|
57
|
-
const dbClient =
|
|
56
|
+
const db = _nullishCoalesce(_db, () => ( _chunkKX4762I3js.DB.getDB(subset.startsWith("A") ? "w" : "r")));
|
|
57
|
+
const dbClient = _chunkKX4762I3js.DB.toClient(db);
|
|
58
58
|
baseTable = _nullishCoalesce(baseTable, () => ( _inflection2.default.pluralize(_inflection2.default.underscore(this.modelName))));
|
|
59
59
|
const queryMode = _nullishCoalesce(params.queryMode, () => ( (params.id !== void 0 ? "list" : "both")));
|
|
60
60
|
const { select, virtual, joins, loaders } = subsetQuery;
|
|
@@ -228,4 +228,4 @@ var BaseModelClassAbstract = (_class = class {constructor() { _class.prototype._
|
|
|
228
228
|
|
|
229
229
|
|
|
230
230
|
exports.BaseModelClassAbstract = BaseModelClassAbstract;
|
|
231
|
-
//# sourceMappingURL=chunk-
|
|
231
|
+
//# sourceMappingURL=chunk-QIHV5UYF.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkKX4762I3js = require('./chunk-KX4762I3.js');
|
|
6
6
|
|
|
7
7
|
// src/database/upsert-builder.ts
|
|
8
8
|
var _uuid = require('uuid');
|
|
@@ -20,7 +20,7 @@ async function batchUpdate(db, tableName, ids, rows, chunkSize = 50, trx = null)
|
|
|
20
20
|
};
|
|
21
21
|
if (trx) {
|
|
22
22
|
for (const chunk of chunks) {
|
|
23
|
-
await executeUpdate(chunk,
|
|
23
|
+
await executeUpdate(chunk, _chunkKX4762I3js.DB.toClient(trx));
|
|
24
24
|
}
|
|
25
25
|
} else {
|
|
26
26
|
await db.trx(async (newTrx) => {
|
|
@@ -87,7 +87,7 @@ var UpsertBuilder = class {
|
|
|
87
87
|
if (table === void 0) {
|
|
88
88
|
const tableSpec = (() => {
|
|
89
89
|
try {
|
|
90
|
-
return
|
|
90
|
+
return _chunkKX4762I3js.EntityManager.getTableSpec(tableName);
|
|
91
91
|
} catch (e) {
|
|
92
92
|
return null;
|
|
93
93
|
}
|
|
@@ -119,7 +119,7 @@ var UpsertBuilder = class {
|
|
|
119
119
|
return null;
|
|
120
120
|
}
|
|
121
121
|
return uniqueKeyArray.join("---delimiter--");
|
|
122
|
-
}).filter(
|
|
122
|
+
}).filter(_chunkKX4762I3js.nonNullable);
|
|
123
123
|
const uuid = (() => {
|
|
124
124
|
if (uniqueKeys.length > 0) {
|
|
125
125
|
for (const uniqueKey of uniqueKeys) {
|
|
@@ -180,7 +180,7 @@ var UpsertBuilder = class {
|
|
|
180
180
|
)) {
|
|
181
181
|
throw new Error(`${tableName} \uD574\uACB0\uB418\uC9C0 \uC54A\uC740 \uCC38\uC870\uAC00 \uC788\uC2B5\uB2C8\uB2E4.`);
|
|
182
182
|
}
|
|
183
|
-
const wdb =
|
|
183
|
+
const wdb = _chunkKX4762I3js.DB.toClient(_wdb);
|
|
184
184
|
const { references, refTables } = Array.from(this.tables).reduce(
|
|
185
185
|
(r, [, table2]) => {
|
|
186
186
|
const reference = Array.from(table2.references.values()).find(
|
|
@@ -264,7 +264,7 @@ var UpsertBuilder = class {
|
|
|
264
264
|
return row;
|
|
265
265
|
});
|
|
266
266
|
await batchUpdate(
|
|
267
|
-
|
|
267
|
+
_chunkKX4762I3js.DB.toClient(wdb),
|
|
268
268
|
tableName,
|
|
269
269
|
whereColumns,
|
|
270
270
|
rows,
|
|
@@ -277,4 +277,4 @@ var UpsertBuilder = class {
|
|
|
277
277
|
|
|
278
278
|
|
|
279
279
|
exports.isRefField = isRefField; exports.UpsertBuilder = UpsertBuilder;
|
|
280
|
-
//# sourceMappingURL=chunk-
|
|
280
|
+
//# sourceMappingURL=chunk-Z53BUBO4.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Knex } from 'knex';
|
|
2
|
-
import { D as DBPreset, U as UpsertBuilder, K as KnexClient, S as SubsetQuery } from '../../../model-
|
|
3
|
-
import { B as BaseModelClassAbstract } from '../../../base-model-
|
|
2
|
+
import { D as DBPreset, U as UpsertBuilder, K as KnexClient, S as SubsetQuery } from '../../../model-DWoinpJ7.mjs';
|
|
3
|
+
import { B as BaseModelClassAbstract } from '../../../base-model-BvVra-8f.mjs';
|
|
4
4
|
import 'kysely';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'mysql2';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Knex } from 'knex';
|
|
2
|
-
import { D as DBPreset, U as UpsertBuilder, K as KnexClient, S as SubsetQuery } from '../../../model-
|
|
3
|
-
import { B as BaseModelClassAbstract } from '../../../base-model-
|
|
2
|
+
import { D as DBPreset, U as UpsertBuilder, K as KnexClient, S as SubsetQuery } from '../../../model-DWoinpJ7.js';
|
|
3
|
+
import { B as BaseModelClassAbstract } from '../../../base-model-Br6krkwK.js';
|
|
4
4
|
import 'kysely';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'mysql2';
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQIHV5UYFjs = require('../../../chunk-QIHV5UYF.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkZ53BUBO4js = require('../../../chunk-Z53BUBO4.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkKX4762I3js = require('../../../chunk-KX4762I3.js');
|
|
11
11
|
|
|
12
12
|
// src/database/drivers/knex/base-model.ts
|
|
13
|
-
var BaseModelClass = class extends
|
|
13
|
+
var BaseModelClass = class extends _chunkQIHV5UYFjs.BaseModelClassAbstract {
|
|
14
14
|
getDB(which) {
|
|
15
|
-
return
|
|
15
|
+
return _chunkKX4762I3js.DB.getDB(which);
|
|
16
16
|
}
|
|
17
17
|
async destroy() {
|
|
18
|
-
return
|
|
18
|
+
return _chunkKX4762I3js.DB.destroy();
|
|
19
19
|
}
|
|
20
20
|
getUpsertBuilder() {
|
|
21
|
-
return new (0,
|
|
21
|
+
return new (0, _chunkZ53BUBO4js.UpsertBuilder)();
|
|
22
22
|
}
|
|
23
23
|
applyJoins(clonedQb, joins) {
|
|
24
24
|
for (const join of joins) {
|
|
25
|
-
if (
|
|
25
|
+
if (_chunkKX4762I3js.isCustomJoinClause.call(void 0, join)) {
|
|
26
26
|
if (join.join === "inner") {
|
|
27
27
|
clonedQb.qb = clonedQb.qb.innerJoin(
|
|
28
28
|
`${join.table} as ${join.as}`,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseModelClassAbstract
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-PGPMEMK6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
UpsertBuilder
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-A2BDNO7E.mjs";
|
|
7
7
|
import {
|
|
8
8
|
DB,
|
|
9
9
|
isCustomJoinClause
|
|
10
|
-
} from "../../../chunk-
|
|
10
|
+
} from "../../../chunk-GUV6I64Y.mjs";
|
|
11
11
|
import "../../../chunk-PTFDTOJU.mjs";
|
|
12
12
|
|
|
13
13
|
// src/database/drivers/knex/base-model.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Kysely, SelectQueryBuilder } from 'kysely';
|
|
2
|
-
import { D as DBPreset, a as Database, U as UpsertBuilder, b as KyselyClient, S as SubsetQuery } from '../../../model-
|
|
3
|
-
import { B as BaseModelClassAbstract } from '../../../base-model-
|
|
2
|
+
import { D as DBPreset, a as Database, U as UpsertBuilder, b as KyselyClient, S as SubsetQuery } from '../../../model-DWoinpJ7.mjs';
|
|
3
|
+
import { B as BaseModelClassAbstract } from '../../../base-model-BvVra-8f.mjs';
|
|
4
4
|
import { UndirectedOrderByExpression } from 'kysely/dist/cjs/parser/order-by-parser';
|
|
5
5
|
import 'knex';
|
|
6
6
|
import 'zod';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Kysely, SelectQueryBuilder } from 'kysely';
|
|
2
|
-
import { D as DBPreset, a as Database, U as UpsertBuilder, b as KyselyClient, S as SubsetQuery } from '../../../model-
|
|
3
|
-
import { B as BaseModelClassAbstract } from '../../../base-model-
|
|
2
|
+
import { D as DBPreset, a as Database, U as UpsertBuilder, b as KyselyClient, S as SubsetQuery } from '../../../model-DWoinpJ7.js';
|
|
3
|
+
import { B as BaseModelClassAbstract } from '../../../base-model-Br6krkwK.js';
|
|
4
4
|
import { UndirectedOrderByExpression } from 'kysely/dist/cjs/parser/order-by-parser';
|
|
5
5
|
import 'knex';
|
|
6
6
|
import 'zod';
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQIHV5UYFjs = require('../../../chunk-QIHV5UYF.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkZ53BUBO4js = require('../../../chunk-Z53BUBO4.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkKX4762I3js = require('../../../chunk-KX4762I3.js');
|
|
12
12
|
|
|
13
13
|
// src/database/drivers/kysely/base-model.ts
|
|
14
14
|
var _inflection = require('inflection'); var _inflection2 = _interopRequireDefault(_inflection);
|
|
15
|
-
var BaseModelClass = class extends
|
|
15
|
+
var BaseModelClass = class extends _chunkQIHV5UYFjs.BaseModelClassAbstract {
|
|
16
16
|
getDB(which) {
|
|
17
|
-
return
|
|
17
|
+
return _chunkKX4762I3js.DB.getDB(which);
|
|
18
18
|
}
|
|
19
19
|
async destroy() {
|
|
20
|
-
return
|
|
20
|
+
return _chunkKX4762I3js.DB.destroy();
|
|
21
21
|
}
|
|
22
22
|
getUpsertBuilder() {
|
|
23
|
-
return new (0,
|
|
23
|
+
return new (0, _chunkZ53BUBO4js.UpsertBuilder)();
|
|
24
24
|
}
|
|
25
25
|
applyJoins(clonedQb, joins) {
|
|
26
26
|
for (const join of joins) {
|
|
27
|
-
if (
|
|
27
|
+
if (_chunkKX4762I3js.isCustomJoinClause.call(void 0, join)) {
|
|
28
28
|
throw new Error("Custom join clause is not supported in Kysely");
|
|
29
29
|
}
|
|
30
30
|
if (join.join === "inner") {
|
|
@@ -48,7 +48,7 @@ var BaseModelClass = class extends _chunkIDNBP4MHjs.BaseModelClassAbstract {
|
|
|
48
48
|
if (!column) {
|
|
49
49
|
throw new Error("parseOrderBy: Invalid column");
|
|
50
50
|
}
|
|
51
|
-
const entity =
|
|
51
|
+
const entity = _chunkKX4762I3js.EntityManager.get(_inflection2.default.classify(table));
|
|
52
52
|
if (!entity.props.find((p) => p.name === column)) {
|
|
53
53
|
throw new Error("parseOrderBy: \uD604\uC7AC \uC5D4\uD2F0\uD2F0\uC5D0 \uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 \uCEEC\uB7FC\uC785\uB2C8\uB2E4: ");
|
|
54
54
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseModelClassAbstract
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-PGPMEMK6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
UpsertBuilder
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-A2BDNO7E.mjs";
|
|
7
7
|
import {
|
|
8
8
|
DB,
|
|
9
9
|
EntityManager,
|
|
10
10
|
isCustomJoinClause
|
|
11
|
-
} from "../../../chunk-
|
|
11
|
+
} from "../../../chunk-GUV6I64Y.mjs";
|
|
12
12
|
import "../../../chunk-PTFDTOJU.mjs";
|
|
13
13
|
|
|
14
14
|
// src/database/drivers/kysely/base-model.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { A as ApiParamType, e as ApiParam, E as EntityPropNode, T as TextProp, f as EntityProp, R as RelationProp, g as EntityIndex, h as EntityJson, S as SubsetQuery, i as EntitySubsetRow, j as TemplateKey, k as TemplateOptions, P as PathAndCode, G as GenerateOptions, l as RenderingNode, m as SonamuDBConfig, c as DatabaseDriver,
|
|
3
|
-
export { aS as ArrayOr, B as BaseListParams, aj as CommonProp, ac as DatabaseClient, d as DriverSpec, af as EnumsLabel, ag as EnumsLabelKo, ad as Environment, am as FlattenSubsetRow, aO as KnexColumnType, aL as KnexError, aR as ListResult, aP as MigrationJoinTable, aQ as RelationNode, al as RelationOn, ak as RelationType, an as SMDInput, ah as SQLDateTimeString, ae as SonamuDBFullConfig, aK as SonamuQueryMode, a9 as UBRef,
|
|
2
|
+
import { A as ApiParamType, e as ApiParam, E as EntityPropNode, T as TextProp, f as EntityProp, R as RelationProp, g as EntityIndex, h as EntityJson, S as SubsetQuery, i as EntitySubsetRow, j as TemplateKey, k as TemplateOptions, P as PathAndCode, G as GenerateOptions, l as RenderingNode, m as SonamuDBConfig, c as DatabaseDriver, D as DBPreset, U as UpsertBuilder, K as KnexClient, b as KyselyClient, a as Database, n as SonamuDBBaseConfig, o as KnexConfig, p as KyselyConfig, q as KnexGenerator, r as KnexBaseConfig, s as SonamuKnexDBConfig, C as CodeGenerator, M as MigrationColumn, t as MigrationIndex, u as GenMigrationCode, v as MigrationForeign, w as KyselyBaseConfig, x as SonamuKyselyDBConfig, y as DatabaseExtend, I as IntegerProp, z as BigIntegerProp, F as StringProp, H as FloatProp, J as DoubleProp, L as DecimalProp, N as BooleanProp, O as DateProp, Q as DateTimeProp, V as TimeProp, W as TimestampProp, X as JsonProp, Y as UuidProp, Z as EnumProp, _ as VirtualProp, $ as DistributiveOmit, a0 as OneToOneRelationProp, a1 as BelongsToOneRelationProp, a2 as HasManyRelationProp, a3 as ManyToManyRelationProp, a4 as MigrationSet, a5 as MigrationSetAndJoinTable, a6 as FixtureSearchOptions, a7 as FixtureRecord, a8 as FixtureImportResult } from './model-DWoinpJ7.mjs';
|
|
3
|
+
export { aS as ArrayOr, B as BaseListParams, aj as CommonProp, ac as DatabaseClient, d as DriverSpec, af as EnumsLabel, ag as EnumsLabelKo, ad as Environment, am as FlattenSubsetRow, aO as KnexColumnType, aL as KnexError, aR as ListResult, aP as MigrationJoinTable, aQ as RelationNode, al as RelationOn, ak as RelationType, an as SMDInput, ah as SQLDateTimeString, ae as SonamuDBFullConfig, aK as SonamuQueryMode, a9 as UBRef, ab as WhereClause, aT as asArray, aG as isBelongsToOneRelationProp, ap as isBigIntegerProp, aw as isBooleanProp, aJ as isCustomJoinClause, ax as isDateProp, ay as isDateTimeProp, av as isDecimalProp, au as isDoubleProp, as as isEnumProp, at as isFloatProp, aH as isHasManyRelationProp, ao as isIntegerProp, aB as isJsonProp, aM as isKnexError, aN as isKyselyError, aI as isManyToManyRelationProp, aF as isOneToOneRelationProp, aa as isRefField, aE as isRelationProp, ar as isStringProp, aq as isTextProp, az as isTimeProp, aA as isTimestampProp, aC as isUuidProp, aD as isVirtualProp, aU as objToMap, ai as zArrayable } from './model-DWoinpJ7.mjs';
|
|
4
4
|
import { HTTPMethods, FastifyReply, FastifyInstance, FastifyRequest } from 'fastify';
|
|
5
5
|
import { RouteGenericInterface } from 'fastify/types/route';
|
|
6
6
|
import { Server, IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
|
|
@@ -197,8 +197,11 @@ declare class Syncer {
|
|
|
197
197
|
sync(): Promise<void>;
|
|
198
198
|
getEntityIdFromPath(filePaths: string[]): string[];
|
|
199
199
|
actionGenerateSchemas(): Promise<string[]>;
|
|
200
|
-
actionGenerateServices(
|
|
201
|
-
|
|
200
|
+
actionGenerateServices(paramsArray: {
|
|
201
|
+
namesRecord: EntityNamesRecord;
|
|
202
|
+
modelTsPath: string;
|
|
203
|
+
}[]): Promise<string[]>;
|
|
204
|
+
actionGenerateHttps(): Promise<string[]>;
|
|
202
205
|
copyFileWithReplaceCoreToShared(fromPath: string, toPath: string): Promise<void>;
|
|
203
206
|
actionSyncFilesToTargets(tsPaths: string[]): Promise<string[]>;
|
|
204
207
|
getCurrentChecksums(): Promise<PathAndChecksum[]>;
|
|
@@ -339,6 +342,11 @@ declare class SonamuClass {
|
|
|
339
342
|
}
|
|
340
343
|
declare const Sonamu: SonamuClass;
|
|
341
344
|
|
|
345
|
+
declare abstract class BaseFrameClass {
|
|
346
|
+
getDB(which: DBPreset): Knex;
|
|
347
|
+
getUpsertBuilder(): UpsertBuilder<"knex">;
|
|
348
|
+
}
|
|
349
|
+
|
|
342
350
|
declare abstract class DBClass {
|
|
343
351
|
_fullConfig?: SonamuDBConfig;
|
|
344
352
|
set fullConfig(config: SonamuDBConfig);
|
|
@@ -789,4 +797,4 @@ declare function findApiRootPath(): string;
|
|
|
789
797
|
declare function nonNullable<T>(value: T): value is NonNullable<T>;
|
|
790
798
|
declare function hydrate<T>(rows: T[]): T[];
|
|
791
799
|
|
|
792
|
-
export { AlreadyProcessedException, type ApiDecoratorOptions, ApiParam, ApiParamType, BadRequestException, BelongsToOneRelationProp, BigIntegerProp, BooleanProp, type Context, type ContextExtend, DB, DBKnexClass, DBKyselyClass, DBPreset, Database, DatabaseDriver, DatabaseExtend, DateProp, DateTimeProp, DecimalProp, DistributiveOmit, DoubleProp, DuplicateRowException, Entity, EntityIndex, EntityJson, EntityManager, type EntityNamesRecord, EntityProp, EntityPropNode, EntitySubsetRow, EnumProp, type ExtendedApi, FixtureImportResult, FixtureManager, FixtureManagerClass, FixtureRecord, FixtureSearchOptions, FloatProp, GenMigrationCode, GenerateOptions, HasManyRelationProp, IntegerProp, InternalServerErrorException, JsonProp, KnexBaseConfig, KnexConfig, KyselyBaseConfig, KyselyConfig, ManyToManyRelationProp, MigrationColumn, MigrationForeign, MigrationIndex, MigrationSet, MigrationSetAndJoinTable, type MigrationStatus, Migrator, type MigratorOptions, NotFoundException, OneToOneRelationProp, PathAndCode, RelationProp, type RenderedTemplate, RenderingNode, type ServiceClient, ServiceUnavailableException, SoException, Sonamu, type SonamuConfig, SonamuDBBaseConfig, SonamuDBConfig, SonamuKnexDBConfig, SonamuKyselyDBConfig, type SonamuSecrets, StringProp, SubsetQuery, Syncer, TargetNotFoundException, TemplateKey, TemplateOptions, TextProp, TimeProp, TimestampProp, UnauthorizedException, UuidProp, VirtualProp, api, apiParamToTsCode, apiParamTypeToTsType, findApiRootPath, findAppRootPath, getTextTypeLength, getZodObjectFromApi, getZodObjectFromApiParams, getZodTypeFromApiParamType, globAsync, hydrate, i, importMultiple, isDaemonServer, isDevelopment, isInDocker, isLocal, isProduction, isRemote, isSoException, isStaging, isTest, nonNullable, p, propNodeToZodTypeDef, propToZodTypeDef, registeredApis, serializeZodType, setupErrorHandler, unwrapPromiseOnce, zodTypeToTsTypeDef, zodTypeToZodCode };
|
|
800
|
+
export { AlreadyProcessedException, type ApiDecoratorOptions, ApiParam, ApiParamType, BadRequestException, BaseFrameClass, BelongsToOneRelationProp, BigIntegerProp, BooleanProp, type Context, type ContextExtend, DB, DBKnexClass, DBKyselyClass, DBPreset, Database, DatabaseDriver, DatabaseExtend, DateProp, DateTimeProp, DecimalProp, DistributiveOmit, DoubleProp, DuplicateRowException, Entity, EntityIndex, EntityJson, EntityManager, type EntityNamesRecord, EntityProp, EntityPropNode, EntitySubsetRow, EnumProp, type ExtendedApi, FixtureImportResult, FixtureManager, FixtureManagerClass, FixtureRecord, FixtureSearchOptions, FloatProp, GenMigrationCode, GenerateOptions, HasManyRelationProp, IntegerProp, InternalServerErrorException, JsonProp, KnexBaseConfig, KnexConfig, KyselyBaseConfig, KyselyConfig, ManyToManyRelationProp, MigrationColumn, MigrationForeign, MigrationIndex, MigrationSet, MigrationSetAndJoinTable, type MigrationStatus, Migrator, type MigratorOptions, NotFoundException, OneToOneRelationProp, PathAndCode, RelationProp, type RenderedTemplate, RenderingNode, type ServiceClient, ServiceUnavailableException, SoException, Sonamu, type SonamuConfig, SonamuDBBaseConfig, SonamuDBConfig, SonamuKnexDBConfig, SonamuKyselyDBConfig, type SonamuSecrets, StringProp, SubsetQuery, Syncer, TargetNotFoundException, TemplateKey, TemplateOptions, TextProp, TimeProp, TimestampProp, UnauthorizedException, UpsertBuilder, UuidProp, VirtualProp, api, apiParamToTsCode, apiParamTypeToTsType, findApiRootPath, findAppRootPath, getTextTypeLength, getZodObjectFromApi, getZodObjectFromApiParams, getZodTypeFromApiParamType, globAsync, hydrate, i, importMultiple, isDaemonServer, isDevelopment, isInDocker, isLocal, isProduction, isRemote, isSoException, isStaging, isTest, nonNullable, p, propNodeToZodTypeDef, propToZodTypeDef, registeredApis, serializeZodType, setupErrorHandler, unwrapPromiseOnce, zodTypeToTsTypeDef, zodTypeToZodCode };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { A as ApiParamType, e as ApiParam, E as EntityPropNode, T as TextProp, f as EntityProp, R as RelationProp, g as EntityIndex, h as EntityJson, S as SubsetQuery, i as EntitySubsetRow, j as TemplateKey, k as TemplateOptions, P as PathAndCode, G as GenerateOptions, l as RenderingNode, m as SonamuDBConfig, c as DatabaseDriver,
|
|
3
|
-
export { aS as ArrayOr, B as BaseListParams, aj as CommonProp, ac as DatabaseClient, d as DriverSpec, af as EnumsLabel, ag as EnumsLabelKo, ad as Environment, am as FlattenSubsetRow, aO as KnexColumnType, aL as KnexError, aR as ListResult, aP as MigrationJoinTable, aQ as RelationNode, al as RelationOn, ak as RelationType, an as SMDInput, ah as SQLDateTimeString, ae as SonamuDBFullConfig, aK as SonamuQueryMode, a9 as UBRef,
|
|
2
|
+
import { A as ApiParamType, e as ApiParam, E as EntityPropNode, T as TextProp, f as EntityProp, R as RelationProp, g as EntityIndex, h as EntityJson, S as SubsetQuery, i as EntitySubsetRow, j as TemplateKey, k as TemplateOptions, P as PathAndCode, G as GenerateOptions, l as RenderingNode, m as SonamuDBConfig, c as DatabaseDriver, D as DBPreset, U as UpsertBuilder, K as KnexClient, b as KyselyClient, a as Database, n as SonamuDBBaseConfig, o as KnexConfig, p as KyselyConfig, q as KnexGenerator, r as KnexBaseConfig, s as SonamuKnexDBConfig, C as CodeGenerator, M as MigrationColumn, t as MigrationIndex, u as GenMigrationCode, v as MigrationForeign, w as KyselyBaseConfig, x as SonamuKyselyDBConfig, y as DatabaseExtend, I as IntegerProp, z as BigIntegerProp, F as StringProp, H as FloatProp, J as DoubleProp, L as DecimalProp, N as BooleanProp, O as DateProp, Q as DateTimeProp, V as TimeProp, W as TimestampProp, X as JsonProp, Y as UuidProp, Z as EnumProp, _ as VirtualProp, $ as DistributiveOmit, a0 as OneToOneRelationProp, a1 as BelongsToOneRelationProp, a2 as HasManyRelationProp, a3 as ManyToManyRelationProp, a4 as MigrationSet, a5 as MigrationSetAndJoinTable, a6 as FixtureSearchOptions, a7 as FixtureRecord, a8 as FixtureImportResult } from './model-DWoinpJ7.js';
|
|
3
|
+
export { aS as ArrayOr, B as BaseListParams, aj as CommonProp, ac as DatabaseClient, d as DriverSpec, af as EnumsLabel, ag as EnumsLabelKo, ad as Environment, am as FlattenSubsetRow, aO as KnexColumnType, aL as KnexError, aR as ListResult, aP as MigrationJoinTable, aQ as RelationNode, al as RelationOn, ak as RelationType, an as SMDInput, ah as SQLDateTimeString, ae as SonamuDBFullConfig, aK as SonamuQueryMode, a9 as UBRef, ab as WhereClause, aT as asArray, aG as isBelongsToOneRelationProp, ap as isBigIntegerProp, aw as isBooleanProp, aJ as isCustomJoinClause, ax as isDateProp, ay as isDateTimeProp, av as isDecimalProp, au as isDoubleProp, as as isEnumProp, at as isFloatProp, aH as isHasManyRelationProp, ao as isIntegerProp, aB as isJsonProp, aM as isKnexError, aN as isKyselyError, aI as isManyToManyRelationProp, aF as isOneToOneRelationProp, aa as isRefField, aE as isRelationProp, ar as isStringProp, aq as isTextProp, az as isTimeProp, aA as isTimestampProp, aC as isUuidProp, aD as isVirtualProp, aU as objToMap, ai as zArrayable } from './model-DWoinpJ7.js';
|
|
4
4
|
import { HTTPMethods, FastifyReply, FastifyInstance, FastifyRequest } from 'fastify';
|
|
5
5
|
import { RouteGenericInterface } from 'fastify/types/route';
|
|
6
6
|
import { Server, IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
|
|
@@ -197,8 +197,11 @@ declare class Syncer {
|
|
|
197
197
|
sync(): Promise<void>;
|
|
198
198
|
getEntityIdFromPath(filePaths: string[]): string[];
|
|
199
199
|
actionGenerateSchemas(): Promise<string[]>;
|
|
200
|
-
actionGenerateServices(
|
|
201
|
-
|
|
200
|
+
actionGenerateServices(paramsArray: {
|
|
201
|
+
namesRecord: EntityNamesRecord;
|
|
202
|
+
modelTsPath: string;
|
|
203
|
+
}[]): Promise<string[]>;
|
|
204
|
+
actionGenerateHttps(): Promise<string[]>;
|
|
202
205
|
copyFileWithReplaceCoreToShared(fromPath: string, toPath: string): Promise<void>;
|
|
203
206
|
actionSyncFilesToTargets(tsPaths: string[]): Promise<string[]>;
|
|
204
207
|
getCurrentChecksums(): Promise<PathAndChecksum[]>;
|
|
@@ -339,6 +342,11 @@ declare class SonamuClass {
|
|
|
339
342
|
}
|
|
340
343
|
declare const Sonamu: SonamuClass;
|
|
341
344
|
|
|
345
|
+
declare abstract class BaseFrameClass {
|
|
346
|
+
getDB(which: DBPreset): Knex;
|
|
347
|
+
getUpsertBuilder(): UpsertBuilder<"knex">;
|
|
348
|
+
}
|
|
349
|
+
|
|
342
350
|
declare abstract class DBClass {
|
|
343
351
|
_fullConfig?: SonamuDBConfig;
|
|
344
352
|
set fullConfig(config: SonamuDBConfig);
|
|
@@ -789,4 +797,4 @@ declare function findApiRootPath(): string;
|
|
|
789
797
|
declare function nonNullable<T>(value: T): value is NonNullable<T>;
|
|
790
798
|
declare function hydrate<T>(rows: T[]): T[];
|
|
791
799
|
|
|
792
|
-
export { AlreadyProcessedException, type ApiDecoratorOptions, ApiParam, ApiParamType, BadRequestException, BelongsToOneRelationProp, BigIntegerProp, BooleanProp, type Context, type ContextExtend, DB, DBKnexClass, DBKyselyClass, DBPreset, Database, DatabaseDriver, DatabaseExtend, DateProp, DateTimeProp, DecimalProp, DistributiveOmit, DoubleProp, DuplicateRowException, Entity, EntityIndex, EntityJson, EntityManager, type EntityNamesRecord, EntityProp, EntityPropNode, EntitySubsetRow, EnumProp, type ExtendedApi, FixtureImportResult, FixtureManager, FixtureManagerClass, FixtureRecord, FixtureSearchOptions, FloatProp, GenMigrationCode, GenerateOptions, HasManyRelationProp, IntegerProp, InternalServerErrorException, JsonProp, KnexBaseConfig, KnexConfig, KyselyBaseConfig, KyselyConfig, ManyToManyRelationProp, MigrationColumn, MigrationForeign, MigrationIndex, MigrationSet, MigrationSetAndJoinTable, type MigrationStatus, Migrator, type MigratorOptions, NotFoundException, OneToOneRelationProp, PathAndCode, RelationProp, type RenderedTemplate, RenderingNode, type ServiceClient, ServiceUnavailableException, SoException, Sonamu, type SonamuConfig, SonamuDBBaseConfig, SonamuDBConfig, SonamuKnexDBConfig, SonamuKyselyDBConfig, type SonamuSecrets, StringProp, SubsetQuery, Syncer, TargetNotFoundException, TemplateKey, TemplateOptions, TextProp, TimeProp, TimestampProp, UnauthorizedException, UuidProp, VirtualProp, api, apiParamToTsCode, apiParamTypeToTsType, findApiRootPath, findAppRootPath, getTextTypeLength, getZodObjectFromApi, getZodObjectFromApiParams, getZodTypeFromApiParamType, globAsync, hydrate, i, importMultiple, isDaemonServer, isDevelopment, isInDocker, isLocal, isProduction, isRemote, isSoException, isStaging, isTest, nonNullable, p, propNodeToZodTypeDef, propToZodTypeDef, registeredApis, serializeZodType, setupErrorHandler, unwrapPromiseOnce, zodTypeToTsTypeDef, zodTypeToZodCode };
|
|
800
|
+
export { AlreadyProcessedException, type ApiDecoratorOptions, ApiParam, ApiParamType, BadRequestException, BaseFrameClass, BelongsToOneRelationProp, BigIntegerProp, BooleanProp, type Context, type ContextExtend, DB, DBKnexClass, DBKyselyClass, DBPreset, Database, DatabaseDriver, DatabaseExtend, DateProp, DateTimeProp, DecimalProp, DistributiveOmit, DoubleProp, DuplicateRowException, Entity, EntityIndex, EntityJson, EntityManager, type EntityNamesRecord, EntityProp, EntityPropNode, EntitySubsetRow, EnumProp, type ExtendedApi, FixtureImportResult, FixtureManager, FixtureManagerClass, FixtureRecord, FixtureSearchOptions, FloatProp, GenMigrationCode, GenerateOptions, HasManyRelationProp, IntegerProp, InternalServerErrorException, JsonProp, KnexBaseConfig, KnexConfig, KyselyBaseConfig, KyselyConfig, ManyToManyRelationProp, MigrationColumn, MigrationForeign, MigrationIndex, MigrationSet, MigrationSetAndJoinTable, type MigrationStatus, Migrator, type MigratorOptions, NotFoundException, OneToOneRelationProp, PathAndCode, RelationProp, type RenderedTemplate, RenderingNode, type ServiceClient, ServiceUnavailableException, SoException, Sonamu, type SonamuConfig, SonamuDBBaseConfig, SonamuDBConfig, SonamuKnexDBConfig, SonamuKyselyDBConfig, type SonamuSecrets, StringProp, SubsetQuery, Syncer, TargetNotFoundException, TemplateKey, TemplateOptions, TextProp, TimeProp, TimestampProp, UnauthorizedException, UpsertBuilder, UuidProp, VirtualProp, api, apiParamToTsCode, apiParamTypeToTsType, findApiRootPath, findAppRootPath, getTextTypeLength, getZodObjectFromApi, getZodObjectFromApiParams, getZodTypeFromApiParamType, globAsync, hydrate, i, importMultiple, isDaemonServer, isDevelopment, isInDocker, isLocal, isProduction, isRemote, isSoException, isStaging, isTest, nonNullable, p, propNodeToZodTypeDef, propToZodTypeDef, registeredApis, serializeZodType, setupErrorHandler, unwrapPromiseOnce, zodTypeToTsTypeDef, zodTypeToZodCode };
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkGUKIIOZIjs = require('./chunk-GUKIIOZI.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkZ53BUBO4js = require('./chunk-Z53BUBO4.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -88,13 +88,23 @@ var _chunkGHF56FO6js = require('./chunk-GHF56FO6.js');
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
var
|
|
91
|
+
var _chunkKX4762I3js = require('./chunk-KX4762I3.js');
|
|
92
|
+
|
|
93
|
+
// src/api/base-frame.ts
|
|
94
|
+
var BaseFrameClass = class {
|
|
95
|
+
getDB(which) {
|
|
96
|
+
return _chunkKX4762I3js.DB.getDB(which);
|
|
97
|
+
}
|
|
98
|
+
getUpsertBuilder() {
|
|
99
|
+
return new (0, _chunkZ53BUBO4js.UpsertBuilder)();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
92
102
|
|
|
93
103
|
// src/exceptions/error-handler.ts
|
|
94
104
|
function setupErrorHandler(server) {
|
|
95
105
|
server.setErrorHandler((error, request, reply) => {
|
|
96
106
|
error.statusCode ??= 400;
|
|
97
|
-
if (
|
|
107
|
+
if (_chunkKX4762I3js.isSoException.call(void 0, error) && error.payload && Array.isArray(error.payload)) {
|
|
98
108
|
const issues = error.payload;
|
|
99
109
|
const [issue] = issues;
|
|
100
110
|
const message = `${issue.message} (${issue.path.join("/")})`;
|
|
@@ -286,6 +296,7 @@ function relationOneToOne(name, option) {
|
|
|
286
296
|
};
|
|
287
297
|
}
|
|
288
298
|
function relationBelongsToOne(name, option) {
|
|
299
|
+
option.useConstraint = _nullishCoalesce(option.useConstraint, () => ( true));
|
|
289
300
|
return {
|
|
290
301
|
name,
|
|
291
302
|
type: "relation",
|
|
@@ -316,13 +327,13 @@ var i = {
|
|
|
316
327
|
function index(columns) {
|
|
317
328
|
return {
|
|
318
329
|
type: "index",
|
|
319
|
-
columns:
|
|
330
|
+
columns: _chunkKX4762I3js.asArray.call(void 0, columns)
|
|
320
331
|
};
|
|
321
332
|
}
|
|
322
333
|
function unique(columns) {
|
|
323
334
|
return {
|
|
324
335
|
type: "unique",
|
|
325
|
-
columns:
|
|
336
|
+
columns: _chunkKX4762I3js.asArray.call(void 0, columns)
|
|
326
337
|
};
|
|
327
338
|
}
|
|
328
339
|
|
|
@@ -414,5 +425,6 @@ function unique(columns) {
|
|
|
414
425
|
|
|
415
426
|
|
|
416
427
|
|
|
417
|
-
|
|
428
|
+
|
|
429
|
+
exports.AlreadyProcessedException = _chunkKX4762I3js.AlreadyProcessedException; exports.ApiParamType = _chunkKX4762I3js.ApiParamType; exports.BadRequestException = _chunkKX4762I3js.BadRequestException; exports.BaseFrameClass = BaseFrameClass; exports.DB = _chunkKX4762I3js.DB; exports.DBKnexClass = _chunkKX4762I3js.DBKnexClass; exports.DBKyselyClass = _chunkKX4762I3js.DBKyselyClass; exports.DuplicateRowException = _chunkKX4762I3js.DuplicateRowException; exports.Entity = _chunkKX4762I3js.Entity; exports.EntityManager = _chunkKX4762I3js.EntityManager; exports.FixtureManager = _chunkGUKIIOZIjs.FixtureManager; exports.FixtureManagerClass = _chunkGUKIIOZIjs.FixtureManagerClass; exports.GenerateOptions = _chunkKX4762I3js.GenerateOptions; exports.InternalServerErrorException = _chunkKX4762I3js.InternalServerErrorException; exports.Migrator = _chunkGUKIIOZIjs.Migrator; exports.NotFoundException = _chunkKX4762I3js.NotFoundException; exports.PathAndCode = _chunkKX4762I3js.PathAndCode; exports.RenderingNode = _chunkKX4762I3js.RenderingNode; exports.SQLDateTimeString = _chunkKX4762I3js.SQLDateTimeString; exports.ServiceUnavailableException = _chunkKX4762I3js.ServiceUnavailableException; exports.SoException = _chunkKX4762I3js.SoException; exports.Sonamu = _chunkKX4762I3js.Sonamu; exports.SonamuQueryMode = _chunkKX4762I3js.SonamuQueryMode; exports.Syncer = _chunkKX4762I3js.Syncer; exports.TargetNotFoundException = _chunkKX4762I3js.TargetNotFoundException; exports.TemplateKey = _chunkKX4762I3js.TemplateKey; exports.TemplateOptions = _chunkKX4762I3js.TemplateOptions; exports.UnauthorizedException = _chunkKX4762I3js.UnauthorizedException; exports.UpsertBuilder = _chunkZ53BUBO4js.UpsertBuilder; exports.api = _chunkKX4762I3js.api; exports.apiParamToTsCode = _chunkKX4762I3js.apiParamToTsCode; exports.apiParamTypeToTsType = _chunkKX4762I3js.apiParamTypeToTsType; exports.asArray = _chunkKX4762I3js.asArray; exports.findApiRootPath = _chunkKX4762I3js.findApiRootPath; exports.findAppRootPath = _chunkKX4762I3js.findAppRootPath; exports.getTextTypeLength = _chunkKX4762I3js.getTextTypeLength; exports.getZodObjectFromApi = _chunkKX4762I3js.getZodObjectFromApi; exports.getZodObjectFromApiParams = _chunkKX4762I3js.getZodObjectFromApiParams; exports.getZodTypeFromApiParamType = _chunkKX4762I3js.getZodTypeFromApiParamType; exports.globAsync = _chunkKX4762I3js.globAsync; exports.hydrate = _chunkKX4762I3js.hydrate; exports.i = i; exports.importMultiple = _chunkKX4762I3js.importMultiple; exports.isBelongsToOneRelationProp = _chunkKX4762I3js.isBelongsToOneRelationProp; exports.isBigIntegerProp = _chunkKX4762I3js.isBigIntegerProp; exports.isBooleanProp = _chunkKX4762I3js.isBooleanProp; exports.isCustomJoinClause = _chunkKX4762I3js.isCustomJoinClause; exports.isDaemonServer = _chunkKX4762I3js.isDaemonServer; exports.isDateProp = _chunkKX4762I3js.isDateProp; exports.isDateTimeProp = _chunkKX4762I3js.isDateTimeProp; exports.isDecimalProp = _chunkKX4762I3js.isDecimalProp; exports.isDevelopment = _chunkKX4762I3js.isDevelopment; exports.isDoubleProp = _chunkKX4762I3js.isDoubleProp; exports.isEnumProp = _chunkKX4762I3js.isEnumProp; exports.isFloatProp = _chunkKX4762I3js.isFloatProp; exports.isHasManyRelationProp = _chunkKX4762I3js.isHasManyRelationProp; exports.isInDocker = _chunkKX4762I3js.isInDocker; exports.isIntegerProp = _chunkKX4762I3js.isIntegerProp; exports.isJsonProp = _chunkKX4762I3js.isJsonProp; exports.isKnexError = _chunkKX4762I3js.isKnexError; exports.isKyselyError = _chunkKX4762I3js.isKyselyError; exports.isLocal = _chunkKX4762I3js.isLocal; exports.isManyToManyRelationProp = _chunkKX4762I3js.isManyToManyRelationProp; exports.isOneToOneRelationProp = _chunkKX4762I3js.isOneToOneRelationProp; exports.isProduction = _chunkKX4762I3js.isProduction; exports.isRefField = _chunkZ53BUBO4js.isRefField; exports.isRelationProp = _chunkKX4762I3js.isRelationProp; exports.isRemote = _chunkKX4762I3js.isRemote; exports.isSoException = _chunkKX4762I3js.isSoException; exports.isStaging = _chunkKX4762I3js.isStaging; exports.isStringProp = _chunkKX4762I3js.isStringProp; exports.isTest = _chunkKX4762I3js.isTest; exports.isTextProp = _chunkKX4762I3js.isTextProp; exports.isTimeProp = _chunkKX4762I3js.isTimeProp; exports.isTimestampProp = _chunkKX4762I3js.isTimestampProp; exports.isUuidProp = _chunkKX4762I3js.isUuidProp; exports.isVirtualProp = _chunkKX4762I3js.isVirtualProp; exports.nonNullable = _chunkKX4762I3js.nonNullable; exports.objToMap = _chunkKX4762I3js.objToMap; exports.p = p; exports.propNodeToZodTypeDef = _chunkKX4762I3js.propNodeToZodTypeDef; exports.propToZodTypeDef = _chunkKX4762I3js.propToZodTypeDef; exports.registeredApis = _chunkKX4762I3js.registeredApis; exports.serializeZodType = _chunkKX4762I3js.serializeZodType; exports.setupErrorHandler = setupErrorHandler; exports.unwrapPromiseOnce = _chunkKX4762I3js.unwrapPromiseOnce; exports.zArrayable = _chunkKX4762I3js.zArrayable; exports.zodTypeToTsTypeDef = _chunkKX4762I3js.zodTypeToTsTypeDef; exports.zodTypeToZodCode = _chunkKX4762I3js.zodTypeToZodCode;
|
|
418
430
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/exceptions/error-handler.ts","../src/entity/entity-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,kBAAkB,QAAyB;AACzD,SAAO,gBAAgB,CAAC,OAAO,SAAS,UAAU;AAChD,UAAM,eAAe;AAErB,QAAI,cAAc,KAAK,KAAK,MAAM,WAAW,MAAM,QAAQ,MAAM,OAAO,GAAG;AACzE,YAAM,SAAS,MAAM;AACrB,YAAM,CAAC,KAAK,IAAI;AAChB,YAAM,UAAU,GAAG,MAAM,OAAO,KAAK,MAAM,KAAK,KAAK,GAAG,CAAC;AAEzD,cAAQ,IAAI,MAAM,GAAG,MAAM,UAAU,IAAI,OAAO,EAAE;AAClD,YAAM,OAAO,MAAM,cAAc,MAAM,MAAM,aAAa,GAAG,EAAE,KAAK;AAAA,QAClE,MAAM,MAAM;AAAA,QACZ,MAAM,MAAM;AAAA,QACZ;AAAA,QACA,kBAAkB,MAAM;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,cAAQ,IAAI,MAAM,GAAG,MAAM,UAAU,IAAI,MAAM,OAAO,EAAE;A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AA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,iBACP,MACA,QAIsB;AACtB,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,cAAc;AAAA,IACd,GAAG;AAAA,EACL;AACF;AACA,SAAS,qBACP,MACA,QAC0B;AAC1B,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,cAAc;AAAA,IACd,GAAG;AAAA,EACL;AACF;AACA,SAAS,gBACP,MACA,QACqB;AACrB,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,cAAc;AAAA,IACd,GAAG;AAAA,EACL;AACF;AACA,SAAS,mBACP,MACA,QACwB;AACxB,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,cAAc;AAAA,IACd,GAAG;AAAA,EACL;AACF;AAEO,IAAM,IAAI;AAAA,EACf;AAAA,EACA;AACF;AAEA,SAAS,MAAM,SAAyC;AACtD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,QAAQ,OAAO;AAAA,EAC1B;AACF;AAEA,SAAS,OAAO,SAAyC;AACvD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,QAAQ,OAAO;AAAA,EAC1B;AACF","sourcesContent":["import { FastifyInstance } from \"fastify\";\nimport { ZodIssue } from \"zod\";\nimport { isSoException } from \"./so-exceptions\";\n\nexport function setupErrorHandler(server: FastifyInstance) {\n server.setErrorHandler((error, request, reply) => {\n error.statusCode ??= 400;\n\n if (isSoException(error) && error.payload && Array.isArray(error.payload)) {\n const issues = error.payload as ZodIssue[];\n const [issue] = issues;\n const message = `${issue.message} (${issue.path.join(\"/\")})`;\n\n request.log.error(`${error.statusCode} ${message}`);\n reply.status(error.statusCode <= 501 ? error.statusCode : 501).send({\n name: error.name,\n code: error.code,\n message: message,\n validationErrors: error.validation,\n issues,\n });\n } else {\n request.log.error(`${error.statusCode} ${error.message}`);\n reply.status(error.statusCode <= 501 ? error.statusCode : 501).send({\n name: error.name,\n code: error.code,\n message: error.message,\n validationErrors: error.validation,\n });\n }\n });\n}\n","import inflection from \"inflection\";\nimport {\n BelongsToOneRelationProp,\n BigIntegerProp,\n BooleanProp,\n DateProp,\n DateTimeProp,\n DecimalProp,\n DistributiveOmit,\n DoubleProp,\n EnumProp,\n FloatProp,\n HasManyRelationProp,\n IntegerProp,\n JsonProp,\n ManyToManyRelationProp,\n OneToOneRelationProp,\n EntityIndex,\n StringProp,\n TextProp,\n TimeProp,\n TimestampProp,\n UuidProp,\n VirtualProp,\n} from \"../types/types\";\nimport { asArray } from \"../utils/model\";\n\nexport const p = {\n integer,\n bigInteger,\n text,\n string,\n float,\n double,\n decimal,\n boolean,\n date,\n dateTime,\n time,\n timestamp,\n json,\n uuid,\n enums,\n virtual,\n relationOneToOne,\n relationBelongsToOne,\n relationHasMany,\n relationManyToMany,\n};\n\nfunction integer(\n name: string,\n option?: Omit<IntegerProp, \"name\" | \"type\">\n): IntegerProp {\n return {\n name,\n type: \"integer\",\n ...option,\n };\n}\nfunction bigInteger(\n name: string,\n option?: Omit<BigIntegerProp, \"name\" | \"type\">\n): BigIntegerProp {\n return {\n name,\n type: \"bigInteger\",\n ...option,\n };\n}\nfunction text(name: string, option: Omit<TextProp, \"name\" | \"type\">): TextProp {\n return {\n name,\n type: \"text\",\n ...option,\n };\n}\nfunction string(\n name: string,\n option: Omit<StringProp, \"name\" | \"type\">\n): StringProp {\n return {\n name,\n type: \"string\",\n ...option,\n };\n}\nfunction float(\n name: string,\n option?: Omit<FloatProp, \"name\" | \"type\">\n): FloatProp {\n return {\n name,\n type: \"float\",\n precision: 8,\n scale: 2,\n ...option,\n };\n}\nfunction double(\n name: string,\n option?: Omit<DoubleProp, \"name\" | \"type\">\n): DoubleProp {\n return {\n name,\n type: \"double\",\n precision: 8,\n scale: 2,\n ...option,\n };\n}\nfunction decimal(\n name: string,\n option?: Omit<DecimalProp, \"name\" | \"type\">\n): DecimalProp {\n return {\n name,\n type: \"decimal\",\n precision: 8,\n scale: 2,\n ...option,\n };\n}\nfunction boolean(\n name: string,\n option?: Omit<BooleanProp, \"name\" | \"type\">\n): BooleanProp {\n return {\n name,\n type: \"boolean\",\n ...option,\n };\n}\nfunction date(\n name: string,\n option?: Omit<DateProp, \"name\" | \"type\"> & { now?: true }\n): DateProp {\n if (option?.now === true) {\n delete option.now;\n option.dbDefault = \"CURRENT_TIMESTAMP\";\n }\n return {\n name,\n type: \"date\",\n ...option,\n };\n}\nfunction dateTime(\n name: string,\n option?: Omit<DateTimeProp, \"name\" | \"type\"> & { now?: true }\n): DateTimeProp {\n if (option?.now === true) {\n delete option.now;\n option.dbDefault = \"CURRENT_TIMESTAMP\";\n }\n return {\n name,\n type: \"datetime\",\n ...option,\n };\n}\nfunction time(\n name: string,\n option?: Omit<TimeProp, \"name\" | \"type\"> & { now?: true }\n): TimeProp {\n if (option?.now === true) {\n delete option.now;\n option.dbDefault = \"CURRENT_TIMESTAMP\";\n }\n return {\n name,\n type: \"time\",\n ...option,\n };\n}\nfunction timestamp(\n name: string,\n option?: Omit<TimestampProp, \"name\" | \"type\"> & { now?: true }\n): TimestampProp {\n if (option?.now === true) {\n delete option.now;\n option.dbDefault = \"CURRENT_TIMESTAMP\";\n }\n return {\n name,\n type: \"timestamp\",\n ...option,\n };\n}\nfunction json(name: string, option: Omit<JsonProp, \"name\" | \"type\">): JsonProp {\n return {\n name,\n type: \"json\",\n ...option,\n };\n}\nfunction uuid(name: string, option: Omit<UuidProp, \"name\" | \"type\">): UuidProp {\n return {\n name,\n type: \"uuid\",\n ...option,\n };\n}\nfunction enums(\n name: string,\n option: Omit<EnumProp, \"name\" | \"type\" | \"id\"> & { id?: string }\n): EnumProp {\n return {\n name,\n type: \"enum\",\n id: option.id ?? `$Model${inflection.camelize(name)}`,\n ...option,\n };\n}\nfunction virtual(\n name: string,\n option: Omit<VirtualProp, \"name\" | \"type\" | \"dbDefault\" | \"toFilter\">\n): VirtualProp {\n return {\n name,\n type: \"virtual\",\n ...option,\n };\n}\nfunction relationOneToOne(\n name: string,\n option: DistributiveOmit<\n OneToOneRelationProp,\n \"name\" | \"type\" | \"relationType\"\n >\n): OneToOneRelationProp {\n return {\n name,\n type: \"relation\",\n relationType: \"OneToOne\",\n ...option,\n };\n}\nfunction relationBelongsToOne(\n name: string,\n option: Omit<BelongsToOneRelationProp, \"name\" | \"type\" | \"relationType\">\n): BelongsToOneRelationProp {\n return {\n name,\n type: \"relation\",\n relationType: \"BelongsToOne\",\n ...option,\n };\n}\nfunction relationHasMany(\n name: string,\n option: Omit<HasManyRelationProp, \"name\" | \"type\" | \"relationType\">\n): HasManyRelationProp {\n return {\n name,\n type: \"relation\",\n relationType: \"HasMany\",\n ...option,\n };\n}\nfunction relationManyToMany(\n name: string,\n option: Omit<ManyToManyRelationProp, \"name\" | \"type\" | \"relationType\">\n): ManyToManyRelationProp {\n return {\n name,\n type: \"relation\",\n relationType: \"ManyToMany\",\n ...option,\n };\n}\n\nexport const i = {\n index,\n unique,\n};\n\nfunction index(columns: string | string[]): EntityIndex {\n return {\n type: \"index\",\n columns: asArray(columns),\n };\n}\n\nfunction unique(columns: string | string[]): EntityIndex {\n return {\n type: \"unique\",\n columns: asArray(columns),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/base-frame.ts","../src/exceptions/error-handler.ts","../src/entity/entity-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,IAAe,iBAAf,MAA8B;AAAA,EACnC,MAAM,OAAuB;AAC3B,WAAO,GAAG,MAAM,KAAK;AAAA,EACvB;AAAA,EAEA,mBAAmB;AACjB,WAAO,IAAI,cAAsB;AAAA,EACnC;AACF;;;ACTO,SAAS,kBAAkB,QAAyB;AACzD,SAAO,gBAAgB,CAAC,OAAO,SAAS,UAAU;AAChD,UAAM,eAAe;AAErB,QA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A,SAAS,OAAO,SAAyC;AACvD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,QAAQ,OAAO;AAAA,EAC1B;AACF","sourcesContent":["import { Knex } from \"knex\";\nimport { DB } from \"../database/db\";\nimport { DBPreset } from \"../database/types\";\nimport { UpsertBuilder } from \"../database/upsert-builder\";\n\nexport abstract class BaseFrameClass {\n getDB(which: DBPreset): Knex {\n return DB.getDB(which) as Knex;\n }\n\n getUpsertBuilder() {\n return new UpsertBuilder<\"knex\">();\n }\n}\n","import { FastifyInstance } from \"fastify\";\nimport { ZodIssue } from \"zod\";\nimport { isSoException } from \"./so-exceptions\";\n\nexport function setupErrorHandler(server: FastifyInstance) {\n server.setErrorHandler((error, request, reply) => {\n error.statusCode ??= 400;\n\n if (isSoException(error) && error.payload && Array.isArray(error.payload)) {\n const issues = error.payload as ZodIssue[];\n const [issue] = issues;\n const message = `${issue.message} (${issue.path.join(\"/\")})`;\n\n request.log.error(`${error.statusCode} ${message}`);\n reply.status(error.statusCode <= 501 ? error.statusCode : 501).send({\n name: error.name,\n code: error.code,\n message: message,\n validationErrors: error.validation,\n issues,\n });\n } else {\n request.log.error(`${error.statusCode} ${error.message}`);\n reply.status(error.statusCode <= 501 ? error.statusCode : 501).send({\n name: error.name,\n code: error.code,\n message: error.message,\n validationErrors: error.validation,\n });\n }\n });\n}\n","import inflection from \"inflection\";\nimport {\n BelongsToOneRelationProp,\n BigIntegerProp,\n BooleanProp,\n DateProp,\n DateTimeProp,\n DecimalProp,\n DistributiveOmit,\n DoubleProp,\n EnumProp,\n FloatProp,\n HasManyRelationProp,\n IntegerProp,\n JsonProp,\n ManyToManyRelationProp,\n OneToOneRelationProp,\n EntityIndex,\n StringProp,\n TextProp,\n TimeProp,\n TimestampProp,\n UuidProp,\n VirtualProp,\n} from \"../types/types\";\nimport { asArray } from \"../utils/model\";\n\nexport const p = {\n integer,\n bigInteger,\n text,\n string,\n float,\n double,\n decimal,\n boolean,\n date,\n dateTime,\n time,\n timestamp,\n json,\n uuid,\n enums,\n virtual,\n relationOneToOne,\n relationBelongsToOne,\n relationHasMany,\n relationManyToMany,\n};\n\nfunction integer(\n name: string,\n option?: Omit<IntegerProp, \"name\" | \"type\">\n): IntegerProp {\n return {\n name,\n type: \"integer\",\n ...option,\n };\n}\nfunction bigInteger(\n name: string,\n option?: Omit<BigIntegerProp, \"name\" | \"type\">\n): BigIntegerProp {\n return {\n name,\n type: \"bigInteger\",\n ...option,\n };\n}\nfunction text(name: string, option: Omit<TextProp, \"name\" | \"type\">): TextProp {\n return {\n name,\n type: \"text\",\n ...option,\n };\n}\nfunction string(\n name: string,\n option: Omit<StringProp, \"name\" | \"type\">\n): StringProp {\n return {\n name,\n type: \"string\",\n ...option,\n };\n}\nfunction float(\n name: string,\n option?: Omit<FloatProp, \"name\" | \"type\">\n): FloatProp {\n return {\n name,\n type: \"float\",\n precision: 8,\n scale: 2,\n ...option,\n };\n}\nfunction double(\n name: string,\n option?: Omit<DoubleProp, \"name\" | \"type\">\n): DoubleProp {\n return {\n name,\n type: \"double\",\n precision: 8,\n scale: 2,\n ...option,\n };\n}\nfunction decimal(\n name: string,\n option?: Omit<DecimalProp, \"name\" | \"type\">\n): DecimalProp {\n return {\n name,\n type: \"decimal\",\n precision: 8,\n scale: 2,\n ...option,\n };\n}\nfunction boolean(\n name: string,\n option?: Omit<BooleanProp, \"name\" | \"type\">\n): BooleanProp {\n return {\n name,\n type: \"boolean\",\n ...option,\n };\n}\nfunction date(\n name: string,\n option?: Omit<DateProp, \"name\" | \"type\"> & { now?: true }\n): DateProp {\n if (option?.now === true) {\n delete option.now;\n option.dbDefault = \"CURRENT_TIMESTAMP\";\n }\n return {\n name,\n type: \"date\",\n ...option,\n };\n}\nfunction dateTime(\n name: string,\n option?: Omit<DateTimeProp, \"name\" | \"type\"> & { now?: true }\n): DateTimeProp {\n if (option?.now === true) {\n delete option.now;\n option.dbDefault = \"CURRENT_TIMESTAMP\";\n }\n return {\n name,\n type: \"datetime\",\n ...option,\n };\n}\nfunction time(\n name: string,\n option?: Omit<TimeProp, \"name\" | \"type\"> & { now?: true }\n): TimeProp {\n if (option?.now === true) {\n delete option.now;\n option.dbDefault = \"CURRENT_TIMESTAMP\";\n }\n return {\n name,\n type: \"time\",\n ...option,\n };\n}\nfunction timestamp(\n name: string,\n option?: Omit<TimestampProp, \"name\" | \"type\"> & { now?: true }\n): TimestampProp {\n if (option?.now === true) {\n delete option.now;\n option.dbDefault = \"CURRENT_TIMESTAMP\";\n }\n return {\n name,\n type: \"timestamp\",\n ...option,\n };\n}\nfunction json(name: string, option: Omit<JsonProp, \"name\" | \"type\">): JsonProp {\n return {\n name,\n type: \"json\",\n ...option,\n };\n}\nfunction uuid(name: string, option: Omit<UuidProp, \"name\" | \"type\">): UuidProp {\n return {\n name,\n type: \"uuid\",\n ...option,\n };\n}\nfunction enums(\n name: string,\n option: Omit<EnumProp, \"name\" | \"type\" | \"id\"> & { id?: string }\n): EnumProp {\n return {\n name,\n type: \"enum\",\n id: option.id ?? `$Model${inflection.camelize(name)}`,\n ...option,\n };\n}\nfunction virtual(\n name: string,\n option: Omit<VirtualProp, \"name\" | \"type\" | \"dbDefault\" | \"toFilter\">\n): VirtualProp {\n return {\n name,\n type: \"virtual\",\n ...option,\n };\n}\nfunction relationOneToOne(\n name: string,\n option: DistributiveOmit<\n OneToOneRelationProp,\n \"name\" | \"type\" | \"relationType\"\n >\n): OneToOneRelationProp {\n return {\n name,\n type: \"relation\",\n relationType: \"OneToOne\",\n ...option,\n };\n}\nfunction relationBelongsToOne(\n name: string,\n option: Omit<BelongsToOneRelationProp, \"name\" | \"type\" | \"relationType\">\n): BelongsToOneRelationProp {\n option.useConstraint = (option.useConstraint ?? true) as false;\n return {\n name,\n type: \"relation\",\n relationType: \"BelongsToOne\",\n ...option,\n };\n}\nfunction relationHasMany(\n name: string,\n option: Omit<HasManyRelationProp, \"name\" | \"type\" | \"relationType\">\n): HasManyRelationProp {\n return {\n name,\n type: \"relation\",\n relationType: \"HasMany\",\n ...option,\n };\n}\nfunction relationManyToMany(\n name: string,\n option: Omit<ManyToManyRelationProp, \"name\" | \"type\" | \"relationType\">\n): ManyToManyRelationProp {\n return {\n name,\n type: \"relation\",\n relationType: \"ManyToMany\",\n ...option,\n };\n}\n\nexport const i = {\n index,\n unique,\n};\n\nfunction index(columns: string | string[]): EntityIndex {\n return {\n type: \"index\",\n columns: asArray(columns),\n };\n}\n\nfunction unique(columns: string | string[]): EntityIndex {\n return {\n type: \"unique\",\n columns: asArray(columns),\n };\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
FixtureManager,
|
|
3
3
|
FixtureManagerClass,
|
|
4
4
|
Migrator
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-634GIW42.mjs";
|
|
6
6
|
import {
|
|
7
7
|
UpsertBuilder,
|
|
8
8
|
isRefField
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-A2BDNO7E.mjs";
|
|
10
10
|
import {
|
|
11
11
|
AlreadyProcessedException,
|
|
12
12
|
ApiParamType,
|
|
@@ -88,9 +88,19 @@ import {
|
|
|
88
88
|
zArrayable,
|
|
89
89
|
zodTypeToTsTypeDef,
|
|
90
90
|
zodTypeToZodCode
|
|
91
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-GUV6I64Y.mjs";
|
|
92
92
|
import "./chunk-PTFDTOJU.mjs";
|
|
93
93
|
|
|
94
|
+
// src/api/base-frame.ts
|
|
95
|
+
var BaseFrameClass = class {
|
|
96
|
+
getDB(which) {
|
|
97
|
+
return DB.getDB(which);
|
|
98
|
+
}
|
|
99
|
+
getUpsertBuilder() {
|
|
100
|
+
return new UpsertBuilder();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
94
104
|
// src/exceptions/error-handler.ts
|
|
95
105
|
function setupErrorHandler(server) {
|
|
96
106
|
server.setErrorHandler((error, request, reply) => {
|
|
@@ -287,6 +297,7 @@ function relationOneToOne(name, option) {
|
|
|
287
297
|
};
|
|
288
298
|
}
|
|
289
299
|
function relationBelongsToOne(name, option) {
|
|
300
|
+
option.useConstraint = option.useConstraint ?? true;
|
|
290
301
|
return {
|
|
291
302
|
name,
|
|
292
303
|
type: "relation",
|
|
@@ -330,6 +341,7 @@ export {
|
|
|
330
341
|
AlreadyProcessedException,
|
|
331
342
|
ApiParamType,
|
|
332
343
|
BadRequestException,
|
|
344
|
+
BaseFrameClass,
|
|
333
345
|
DB,
|
|
334
346
|
DBKnexClass,
|
|
335
347
|
DBKyselyClass,
|