sonamu 0.4.10 → 0.4.12
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-w9EuyYif.d.ts → base-model-Br6krkwK.d.ts} +1 -1
- package/dist/{base-model-ChAfKHR7.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-C7NTXZWZ.mjs → chunk-FKZK27YL.mjs} +2 -2
- package/dist/{chunk-IPTFUZN2.js → chunk-FYLFH3Q6.js} +100 -100
- package/dist/{chunk-I7O4VXTH.js → chunk-IEMX4VPN.js} +4 -4
- package/dist/{chunk-QT3GBIMP.js → chunk-INTZUNZ6.js} +7 -7
- package/dist/{chunk-IPFCELQ3.mjs → chunk-JQJTQQ7D.mjs} +2 -2
- package/dist/{chunk-EEUCHV4P.mjs → chunk-LNZTU4JC.mjs} +70 -41
- package/dist/chunk-LNZTU4JC.mjs.map +1 -0
- package/dist/{chunk-M6MCZP64.mjs → chunk-NPLUHS5L.mjs} +2 -2
- package/dist/{chunk-E2I4OSFY.js → chunk-ZLFDB43J.js} +70 -41
- package/dist/chunk-ZLFDB43J.js.map +1 -0
- 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 +18 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{model-BF9CDic2.d.ts → model-DWoinpJ7.d.mts} +73 -5
- package/dist/{model-BF9CDic2.d.mts → model-DWoinpJ7.d.ts} +73 -5
- package/package.json +1 -1
- package/src/api/base-frame.ts +14 -0
- package/src/api/decorators.ts +2 -1
- package/src/index.ts +1 -0
- package/src/syncer/syncer.ts +77 -40
- package/src/templates/service.template.ts +4 -6
- package/src/types/types.ts +11 -1
- package/dist/chunk-E2I4OSFY.js.map +0 -1
- package/dist/chunk-EEUCHV4P.mjs.map +0 -1
- /package/dist/{chunk-C7NTXZWZ.mjs.map → chunk-FKZK27YL.mjs.map} +0 -0
- /package/dist/{chunk-IPTFUZN2.js.map → chunk-FYLFH3Q6.js.map} +0 -0
- /package/dist/{chunk-I7O4VXTH.js.map → chunk-IEMX4VPN.js.map} +0 -0
- /package/dist/{chunk-QT3GBIMP.js.map → chunk-INTZUNZ6.js.map} +0 -0
- /package/dist/{chunk-IPFCELQ3.mjs.map → chunk-JQJTQQ7D.mjs.map} +0 -0
- /package/dist/{chunk-M6MCZP64.mjs.map → chunk-NPLUHS5L.mjs.map} +0 -0
|
@@ -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 _chunkIEMX4VPNjs = require('../../../chunk-IEMX4VPN.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkINTZUNZ6js = require('../../../chunk-INTZUNZ6.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkZLFDB43Jjs = require('../../../chunk-ZLFDB43J.js');
|
|
11
11
|
|
|
12
12
|
// src/database/drivers/knex/base-model.ts
|
|
13
|
-
var BaseModelClass = class extends
|
|
13
|
+
var BaseModelClass = class extends _chunkIEMX4VPNjs.BaseModelClassAbstract {
|
|
14
14
|
getDB(which) {
|
|
15
|
-
return
|
|
15
|
+
return _chunkZLFDB43Jjs.DB.getDB(which);
|
|
16
16
|
}
|
|
17
17
|
async destroy() {
|
|
18
|
-
return
|
|
18
|
+
return _chunkZLFDB43Jjs.DB.destroy();
|
|
19
19
|
}
|
|
20
20
|
getUpsertBuilder() {
|
|
21
|
-
return new (0,
|
|
21
|
+
return new (0, _chunkINTZUNZ6js.UpsertBuilder)();
|
|
22
22
|
}
|
|
23
23
|
applyJoins(clonedQb, joins) {
|
|
24
24
|
for (const join of joins) {
|
|
25
|
-
if (
|
|
25
|
+
if (_chunkZLFDB43Jjs.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-JQJTQQ7D.mjs";
|
|
4
4
|
import {
|
|
5
5
|
UpsertBuilder
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NPLUHS5L.mjs";
|
|
7
7
|
import {
|
|
8
8
|
DB,
|
|
9
9
|
isCustomJoinClause
|
|
10
|
-
} from "../../../chunk-
|
|
10
|
+
} from "../../../chunk-LNZTU4JC.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 _chunkIEMX4VPNjs = require('../../../chunk-IEMX4VPN.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkINTZUNZ6js = require('../../../chunk-INTZUNZ6.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkZLFDB43Jjs = require('../../../chunk-ZLFDB43J.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 _chunkIEMX4VPNjs.BaseModelClassAbstract {
|
|
16
16
|
getDB(which) {
|
|
17
|
-
return
|
|
17
|
+
return _chunkZLFDB43Jjs.DB.getDB(which);
|
|
18
18
|
}
|
|
19
19
|
async destroy() {
|
|
20
|
-
return
|
|
20
|
+
return _chunkZLFDB43Jjs.DB.destroy();
|
|
21
21
|
}
|
|
22
22
|
getUpsertBuilder() {
|
|
23
|
-
return new (0,
|
|
23
|
+
return new (0, _chunkINTZUNZ6js.UpsertBuilder)();
|
|
24
24
|
}
|
|
25
25
|
applyJoins(clonedQb, joins) {
|
|
26
26
|
for (const join of joins) {
|
|
27
|
-
if (
|
|
27
|
+
if (_chunkZLFDB43Jjs.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 _chunkI7O4VXTHjs.BaseModelClassAbstract {
|
|
|
48
48
|
if (!column) {
|
|
49
49
|
throw new Error("parseOrderBy: Invalid column");
|
|
50
50
|
}
|
|
51
|
-
const entity =
|
|
51
|
+
const entity = _chunkZLFDB43Jjs.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-JQJTQQ7D.mjs";
|
|
4
4
|
import {
|
|
5
5
|
UpsertBuilder
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NPLUHS5L.mjs";
|
|
7
7
|
import {
|
|
8
8
|
DB,
|
|
9
9
|
EntityManager,
|
|
10
10
|
isCustomJoinClause
|
|
11
|
-
} from "../../../chunk-
|
|
11
|
+
} from "../../../chunk-LNZTU4JC.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 _chunkFYLFH3Q6js = require('./chunk-FYLFH3Q6.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkINTZUNZ6js = require('./chunk-INTZUNZ6.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -88,13 +88,23 @@ var _chunkQT3GBIMPjs = require('./chunk-QT3GBIMP.js');
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
var
|
|
91
|
+
var _chunkZLFDB43Jjs = require('./chunk-ZLFDB43J.js');
|
|
92
|
+
|
|
93
|
+
// src/api/base-frame.ts
|
|
94
|
+
var BaseFrameClass = class {
|
|
95
|
+
getDB(which) {
|
|
96
|
+
return _chunkZLFDB43Jjs.DB.getDB(which);
|
|
97
|
+
}
|
|
98
|
+
getUpsertBuilder() {
|
|
99
|
+
return new (0, _chunkINTZUNZ6js.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 (_chunkZLFDB43Jjs.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("/")})`;
|
|
@@ -317,13 +327,13 @@ var i = {
|
|
|
317
327
|
function index(columns) {
|
|
318
328
|
return {
|
|
319
329
|
type: "index",
|
|
320
|
-
columns:
|
|
330
|
+
columns: _chunkZLFDB43Jjs.asArray.call(void 0, columns)
|
|
321
331
|
};
|
|
322
332
|
}
|
|
323
333
|
function unique(columns) {
|
|
324
334
|
return {
|
|
325
335
|
type: "unique",
|
|
326
|
-
columns:
|
|
336
|
+
columns: _chunkZLFDB43Jjs.asArray.call(void 0, columns)
|
|
327
337
|
};
|
|
328
338
|
}
|
|
329
339
|
|
|
@@ -415,5 +425,6 @@ function unique(columns) {
|
|
|
415
425
|
|
|
416
426
|
|
|
417
427
|
|
|
418
|
-
|
|
428
|
+
|
|
429
|
+
exports.AlreadyProcessedException = _chunkZLFDB43Jjs.AlreadyProcessedException; exports.ApiParamType = _chunkZLFDB43Jjs.ApiParamType; exports.BadRequestException = _chunkZLFDB43Jjs.BadRequestException; exports.BaseFrameClass = BaseFrameClass; exports.DB = _chunkZLFDB43Jjs.DB; exports.DBKnexClass = _chunkZLFDB43Jjs.DBKnexClass; exports.DBKyselyClass = _chunkZLFDB43Jjs.DBKyselyClass; exports.DuplicateRowException = _chunkZLFDB43Jjs.DuplicateRowException; exports.Entity = _chunkZLFDB43Jjs.Entity; exports.EntityManager = _chunkZLFDB43Jjs.EntityManager; exports.FixtureManager = _chunkFYLFH3Q6js.FixtureManager; exports.FixtureManagerClass = _chunkFYLFH3Q6js.FixtureManagerClass; exports.GenerateOptions = _chunkZLFDB43Jjs.GenerateOptions; exports.InternalServerErrorException = _chunkZLFDB43Jjs.InternalServerErrorException; exports.Migrator = _chunkFYLFH3Q6js.Migrator; exports.NotFoundException = _chunkZLFDB43Jjs.NotFoundException; exports.PathAndCode = _chunkZLFDB43Jjs.PathAndCode; exports.RenderingNode = _chunkZLFDB43Jjs.RenderingNode; exports.SQLDateTimeString = _chunkZLFDB43Jjs.SQLDateTimeString; exports.ServiceUnavailableException = _chunkZLFDB43Jjs.ServiceUnavailableException; exports.SoException = _chunkZLFDB43Jjs.SoException; exports.Sonamu = _chunkZLFDB43Jjs.Sonamu; exports.SonamuQueryMode = _chunkZLFDB43Jjs.SonamuQueryMode; exports.Syncer = _chunkZLFDB43Jjs.Syncer; exports.TargetNotFoundException = _chunkZLFDB43Jjs.TargetNotFoundException; exports.TemplateKey = _chunkZLFDB43Jjs.TemplateKey; exports.TemplateOptions = _chunkZLFDB43Jjs.TemplateOptions; exports.UnauthorizedException = _chunkZLFDB43Jjs.UnauthorizedException; exports.UpsertBuilder = _chunkINTZUNZ6js.UpsertBuilder; exports.api = _chunkZLFDB43Jjs.api; exports.apiParamToTsCode = _chunkZLFDB43Jjs.apiParamToTsCode; exports.apiParamTypeToTsType = _chunkZLFDB43Jjs.apiParamTypeToTsType; exports.asArray = _chunkZLFDB43Jjs.asArray; exports.findApiRootPath = _chunkZLFDB43Jjs.findApiRootPath; exports.findAppRootPath = _chunkZLFDB43Jjs.findAppRootPath; exports.getTextTypeLength = _chunkZLFDB43Jjs.getTextTypeLength; exports.getZodObjectFromApi = _chunkZLFDB43Jjs.getZodObjectFromApi; exports.getZodObjectFromApiParams = _chunkZLFDB43Jjs.getZodObjectFromApiParams; exports.getZodTypeFromApiParamType = _chunkZLFDB43Jjs.getZodTypeFromApiParamType; exports.globAsync = _chunkZLFDB43Jjs.globAsync; exports.hydrate = _chunkZLFDB43Jjs.hydrate; exports.i = i; exports.importMultiple = _chunkZLFDB43Jjs.importMultiple; exports.isBelongsToOneRelationProp = _chunkZLFDB43Jjs.isBelongsToOneRelationProp; exports.isBigIntegerProp = _chunkZLFDB43Jjs.isBigIntegerProp; exports.isBooleanProp = _chunkZLFDB43Jjs.isBooleanProp; exports.isCustomJoinClause = _chunkZLFDB43Jjs.isCustomJoinClause; exports.isDaemonServer = _chunkZLFDB43Jjs.isDaemonServer; exports.isDateProp = _chunkZLFDB43Jjs.isDateProp; exports.isDateTimeProp = _chunkZLFDB43Jjs.isDateTimeProp; exports.isDecimalProp = _chunkZLFDB43Jjs.isDecimalProp; exports.isDevelopment = _chunkZLFDB43Jjs.isDevelopment; exports.isDoubleProp = _chunkZLFDB43Jjs.isDoubleProp; exports.isEnumProp = _chunkZLFDB43Jjs.isEnumProp; exports.isFloatProp = _chunkZLFDB43Jjs.isFloatProp; exports.isHasManyRelationProp = _chunkZLFDB43Jjs.isHasManyRelationProp; exports.isInDocker = _chunkZLFDB43Jjs.isInDocker; exports.isIntegerProp = _chunkZLFDB43Jjs.isIntegerProp; exports.isJsonProp = _chunkZLFDB43Jjs.isJsonProp; exports.isKnexError = _chunkZLFDB43Jjs.isKnexError; exports.isKyselyError = _chunkZLFDB43Jjs.isKyselyError; exports.isLocal = _chunkZLFDB43Jjs.isLocal; exports.isManyToManyRelationProp = _chunkZLFDB43Jjs.isManyToManyRelationProp; exports.isOneToOneRelationProp = _chunkZLFDB43Jjs.isOneToOneRelationProp; exports.isProduction = _chunkZLFDB43Jjs.isProduction; exports.isRefField = _chunkINTZUNZ6js.isRefField; exports.isRelationProp = _chunkZLFDB43Jjs.isRelationProp; exports.isRemote = _chunkZLFDB43Jjs.isRemote; exports.isSoException = _chunkZLFDB43Jjs.isSoException; exports.isStaging = _chunkZLFDB43Jjs.isStaging; exports.isStringProp = _chunkZLFDB43Jjs.isStringProp; exports.isTest = _chunkZLFDB43Jjs.isTest; exports.isTextProp = _chunkZLFDB43Jjs.isTextProp; exports.isTimeProp = _chunkZLFDB43Jjs.isTimeProp; exports.isTimestampProp = _chunkZLFDB43Jjs.isTimestampProp; exports.isUuidProp = _chunkZLFDB43Jjs.isUuidProp; exports.isVirtualProp = _chunkZLFDB43Jjs.isVirtualProp; exports.nonNullable = _chunkZLFDB43Jjs.nonNullable; exports.objToMap = _chunkZLFDB43Jjs.objToMap; exports.p = p; exports.propNodeToZodTypeDef = _chunkZLFDB43Jjs.propNodeToZodTypeDef; exports.propToZodTypeDef = _chunkZLFDB43Jjs.propToZodTypeDef; exports.registeredApis = _chunkZLFDB43Jjs.registeredApis; exports.serializeZodType = _chunkZLFDB43Jjs.serializeZodType; exports.setupErrorHandler = setupErrorHandler; exports.unwrapPromiseOnce = _chunkZLFDB43Jjs.unwrapPromiseOnce; exports.zArrayable = _chunkZLFDB43Jjs.zArrayable; exports.zodTypeToTsTypeDef = _chunkZLFDB43Jjs.zodTypeToTsTypeDef; exports.zodTypeToZodCode = _chunkZLFDB43Jjs.zodTypeToZodCode;
|
|
419
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,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 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"]}
|
|
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,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,O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ACb,SAAO;AAAA,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,gBAAiB,OAAO,iBAAiB;AAChD,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 { 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-FKZK27YL.mjs";
|
|
6
6
|
import {
|
|
7
7
|
UpsertBuilder,
|
|
8
8
|
isRefField
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NPLUHS5L.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-LNZTU4JC.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) => {
|
|
@@ -331,6 +341,7 @@ export {
|
|
|
331
341
|
AlreadyProcessedException,
|
|
332
342
|
ApiParamType,
|
|
333
343
|
BadRequestException,
|
|
344
|
+
BaseFrameClass,
|
|
334
345
|
DB,
|
|
335
346
|
DBKnexClass,
|
|
336
347
|
DBKyselyClass,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/exceptions/error-handler.ts","../src/entity/entity-utils.ts"],"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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,kBAAkB,QAAyB;AACzD,SAAO,gBAAgB,CAAC,OAAO,SAAS,UAAU;AAChD,UA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A,EAC1B;AACF;AAEA,SAAS,OAAO,SAAyC;AACvD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,QAAQ,OAAO;AAAA,EAC1B;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/api/base-frame.ts","../src/exceptions/error-handler.ts","../src/entity/entity-utils.ts"],"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"],"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,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,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AAM,SAAS,WAAW,SAAS,IAAI,CAAC;AAAA,IACnD,GAAG;AAAA,EACL;AACF;AACA,SAAS,QACP,MACA,QACa;AACb,SAAO;AAAA,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,gBAAiB,OAAO,iBAAiB;AAChD,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;","names":[]}
|
|
@@ -469,11 +469,59 @@ declare const TemplateOptions: z.ZodObject<{
|
|
|
469
469
|
entityId: string;
|
|
470
470
|
}>;
|
|
471
471
|
service: z.ZodObject<{
|
|
472
|
-
|
|
472
|
+
namesRecord: z.ZodObject<{
|
|
473
|
+
fs: z.ZodString;
|
|
474
|
+
fsPlural: z.ZodString;
|
|
475
|
+
camel: z.ZodString;
|
|
476
|
+
camelPlural: z.ZodString;
|
|
477
|
+
capital: z.ZodString;
|
|
478
|
+
capitalPlural: z.ZodString;
|
|
479
|
+
upper: z.ZodString;
|
|
480
|
+
constant: z.ZodString;
|
|
481
|
+
}, "strip", z.ZodTypeAny, {
|
|
482
|
+
fs: string;
|
|
483
|
+
fsPlural: string;
|
|
484
|
+
camel: string;
|
|
485
|
+
camelPlural: string;
|
|
486
|
+
capital: string;
|
|
487
|
+
capitalPlural: string;
|
|
488
|
+
upper: string;
|
|
489
|
+
constant: string;
|
|
490
|
+
}, {
|
|
491
|
+
fs: string;
|
|
492
|
+
fsPlural: string;
|
|
493
|
+
camel: string;
|
|
494
|
+
camelPlural: string;
|
|
495
|
+
capital: string;
|
|
496
|
+
capitalPlural: string;
|
|
497
|
+
upper: string;
|
|
498
|
+
constant: string;
|
|
499
|
+
}>;
|
|
500
|
+
modelTsPath: z.ZodString;
|
|
473
501
|
}, "strip", z.ZodTypeAny, {
|
|
474
|
-
|
|
502
|
+
namesRecord: {
|
|
503
|
+
fs: string;
|
|
504
|
+
fsPlural: string;
|
|
505
|
+
camel: string;
|
|
506
|
+
camelPlural: string;
|
|
507
|
+
capital: string;
|
|
508
|
+
capitalPlural: string;
|
|
509
|
+
upper: string;
|
|
510
|
+
constant: string;
|
|
511
|
+
};
|
|
512
|
+
modelTsPath: string;
|
|
475
513
|
}, {
|
|
476
|
-
|
|
514
|
+
namesRecord: {
|
|
515
|
+
fs: string;
|
|
516
|
+
fsPlural: string;
|
|
517
|
+
camel: string;
|
|
518
|
+
camelPlural: string;
|
|
519
|
+
capital: string;
|
|
520
|
+
capitalPlural: string;
|
|
521
|
+
upper: string;
|
|
522
|
+
constant: string;
|
|
523
|
+
};
|
|
524
|
+
modelTsPath: string;
|
|
477
525
|
}>;
|
|
478
526
|
view_list: z.ZodObject<{
|
|
479
527
|
entityId: z.ZodString;
|
|
@@ -611,7 +659,17 @@ declare const TemplateOptions: z.ZodObject<{
|
|
|
611
659
|
entityId: string;
|
|
612
660
|
};
|
|
613
661
|
service: {
|
|
614
|
-
|
|
662
|
+
namesRecord: {
|
|
663
|
+
fs: string;
|
|
664
|
+
fsPlural: string;
|
|
665
|
+
camel: string;
|
|
666
|
+
camelPlural: string;
|
|
667
|
+
capital: string;
|
|
668
|
+
capitalPlural: string;
|
|
669
|
+
upper: string;
|
|
670
|
+
constant: string;
|
|
671
|
+
};
|
|
672
|
+
modelTsPath: string;
|
|
615
673
|
};
|
|
616
674
|
view_list: {
|
|
617
675
|
entityId: string;
|
|
@@ -683,7 +741,17 @@ declare const TemplateOptions: z.ZodObject<{
|
|
|
683
741
|
entityId: string;
|
|
684
742
|
};
|
|
685
743
|
service: {
|
|
686
|
-
|
|
744
|
+
namesRecord: {
|
|
745
|
+
fs: string;
|
|
746
|
+
fsPlural: string;
|
|
747
|
+
camel: string;
|
|
748
|
+
camelPlural: string;
|
|
749
|
+
capital: string;
|
|
750
|
+
capitalPlural: string;
|
|
751
|
+
upper: string;
|
|
752
|
+
constant: string;
|
|
753
|
+
};
|
|
754
|
+
modelTsPath: string;
|
|
687
755
|
};
|
|
688
756
|
view_list: {
|
|
689
757
|
entityId: string;
|