sonamu 0.2.42 → 0.2.44

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/index.js CHANGED
@@ -79,13 +79,13 @@
79
79
 
80
80
 
81
81
 
82
- var _chunkVV6J3XJUjs = require('./chunk-VV6J3XJU.js');
82
+ var _chunkEYNTBWQCjs = require('./chunk-EYNTBWQC.js');
83
83
 
84
84
  // src/exceptions/error-handler.ts
85
85
  function setupErrorHandler(server) {
86
86
  server.setErrorHandler((error, request, reply) => {
87
87
  _nullishCoalesce(error.statusCode, () => ( (error.statusCode = 400)));
88
- if (_chunkVV6J3XJUjs.isSoException.call(void 0, error) && error.payload && Array.isArray(error.payload)) {
88
+ if (_chunkEYNTBWQCjs.isSoException.call(void 0, error) && error.payload && Array.isArray(error.payload)) {
89
89
  const issues = error.payload;
90
90
  const [issue] = issues;
91
91
  const message = `${issue.message} (${issue.path.join("/")})`;
@@ -421,5 +421,5 @@ function unique(columns) {
421
421
 
422
422
 
423
423
 
424
- exports.AlreadyProcessedException = _chunkVV6J3XJUjs.AlreadyProcessedException; exports.ApiParamType = _chunkVV6J3XJUjs.ApiParamType; exports.BadRequestException = _chunkVV6J3XJUjs.BadRequestException; exports.BaseModel = _chunkVV6J3XJUjs.BaseModel; exports.BaseModelClass = _chunkVV6J3XJUjs.BaseModelClass; exports.DB = _chunkVV6J3XJUjs.DB; exports.DuplicateRowException = _chunkVV6J3XJUjs.DuplicateRowException; exports.EntityManager = _chunkVV6J3XJUjs.EntityManager; exports.FixtureManager = _chunkVV6J3XJUjs.FixtureManager; exports.FixtureManagerClass = _chunkVV6J3XJUjs.FixtureManagerClass; exports.GenerateOptions = _chunkVV6J3XJUjs.GenerateOptions; exports.InternalServerErrorException = _chunkVV6J3XJUjs.InternalServerErrorException; exports.Migrator = _chunkVV6J3XJUjs.Migrator; exports.NotFoundException = _chunkVV6J3XJUjs.NotFoundException; exports.PathAndCode = _chunkVV6J3XJUjs.PathAndCode; exports.RenderingNode = _chunkVV6J3XJUjs.RenderingNode; exports.SQLDateTimeString = _chunkVV6J3XJUjs.SQLDateTimeString; exports.ServiceUnavailableException = _chunkVV6J3XJUjs.ServiceUnavailableException; exports.SoException = _chunkVV6J3XJUjs.SoException; exports.Sonamu = _chunkVV6J3XJUjs.Sonamu; exports.SonamuQueryMode = _chunkVV6J3XJUjs.SonamuQueryMode; exports.Syncer = _chunkVV6J3XJUjs.Syncer; exports.TargetNotFoundException = _chunkVV6J3XJUjs.TargetNotFoundException; exports.TemplateKey = _chunkVV6J3XJUjs.TemplateKey; exports.TemplateOptions = _chunkVV6J3XJUjs.TemplateOptions; exports.UnauthorizedException = _chunkVV6J3XJUjs.UnauthorizedException; exports.UpsertBuilder = _chunkVV6J3XJUjs.UpsertBuilder; exports.api = _chunkVV6J3XJUjs.api; exports.apiParamToTsCode = _chunkVV6J3XJUjs.apiParamToTsCode; exports.apiParamTypeToTsType = _chunkVV6J3XJUjs.apiParamTypeToTsType; exports.asArray = asArray; exports.findApiRootPath = _chunkVV6J3XJUjs.findApiRootPath; exports.findAppRootPath = _chunkVV6J3XJUjs.findAppRootPath; exports.getTextTypeLength = _chunkVV6J3XJUjs.getTextTypeLength; exports.getZodObjectFromApi = _chunkVV6J3XJUjs.getZodObjectFromApi; exports.getZodObjectFromApiParams = _chunkVV6J3XJUjs.getZodObjectFromApiParams; exports.getZodTypeFromApiParamType = _chunkVV6J3XJUjs.getZodTypeFromApiParamType; exports.globAsync = _chunkVV6J3XJUjs.globAsync; exports.i = i; exports.importMultiple = _chunkVV6J3XJUjs.importMultiple; exports.isBelongsToOneRelationProp = _chunkVV6J3XJUjs.isBelongsToOneRelationProp; exports.isBigIntegerProp = _chunkVV6J3XJUjs.isBigIntegerProp; exports.isBooleanProp = _chunkVV6J3XJUjs.isBooleanProp; exports.isCustomJoinClause = _chunkVV6J3XJUjs.isCustomJoinClause; exports.isDaemonServer = _chunkVV6J3XJUjs.isDaemonServer; exports.isDateProp = _chunkVV6J3XJUjs.isDateProp; exports.isDateTimeProp = _chunkVV6J3XJUjs.isDateTimeProp; exports.isDecimalProp = _chunkVV6J3XJUjs.isDecimalProp; exports.isDevelopment = _chunkVV6J3XJUjs.isDevelopment; exports.isDoubleProp = _chunkVV6J3XJUjs.isDoubleProp; exports.isEnumProp = _chunkVV6J3XJUjs.isEnumProp; exports.isFloatProp = _chunkVV6J3XJUjs.isFloatProp; exports.isHasManyRelationProp = _chunkVV6J3XJUjs.isHasManyRelationProp; exports.isInDocker = _chunkVV6J3XJUjs.isInDocker; exports.isIntegerProp = _chunkVV6J3XJUjs.isIntegerProp; exports.isJsonProp = _chunkVV6J3XJUjs.isJsonProp; exports.isKnexError = _chunkVV6J3XJUjs.isKnexError; exports.isLocal = _chunkVV6J3XJUjs.isLocal; exports.isManyToManyRelationProp = _chunkVV6J3XJUjs.isManyToManyRelationProp; exports.isOneToOneRelationProp = _chunkVV6J3XJUjs.isOneToOneRelationProp; exports.isProduction = _chunkVV6J3XJUjs.isProduction; exports.isRefField = _chunkVV6J3XJUjs.isRefField; exports.isRelationProp = _chunkVV6J3XJUjs.isRelationProp; exports.isRemote = _chunkVV6J3XJUjs.isRemote; exports.isSoException = _chunkVV6J3XJUjs.isSoException; exports.isStaging = _chunkVV6J3XJUjs.isStaging; exports.isStringProp = _chunkVV6J3XJUjs.isStringProp; exports.isTest = _chunkVV6J3XJUjs.isTest; exports.isTextProp = _chunkVV6J3XJUjs.isTextProp; exports.isTimeProp = _chunkVV6J3XJUjs.isTimeProp; exports.isTimestampProp = _chunkVV6J3XJUjs.isTimestampProp; exports.isUuidProp = _chunkVV6J3XJUjs.isUuidProp; exports.isVirtualProp = _chunkVV6J3XJUjs.isVirtualProp; exports.nonNullable = _chunkVV6J3XJUjs.nonNullable; exports.objToMap = objToMap; exports.p = p; exports.propNodeToZodTypeDef = _chunkVV6J3XJUjs.propNodeToZodTypeDef; exports.propToZodTypeDef = _chunkVV6J3XJUjs.propToZodTypeDef; exports.registeredApis = _chunkVV6J3XJUjs.registeredApis; exports.serializeZodType = _chunkVV6J3XJUjs.serializeZodType; exports.setupErrorHandler = setupErrorHandler; exports.unwrapPromiseOnce = _chunkVV6J3XJUjs.unwrapPromiseOnce; exports.zArrayable = _chunkVV6J3XJUjs.zArrayable; exports.zodTypeToTsTypeDef = _chunkVV6J3XJUjs.zodTypeToTsTypeDef; exports.zodTypeToZodCode = _chunkVV6J3XJUjs.zodTypeToZodCode;
424
+ exports.AlreadyProcessedException = _chunkEYNTBWQCjs.AlreadyProcessedException; exports.ApiParamType = _chunkEYNTBWQCjs.ApiParamType; exports.BadRequestException = _chunkEYNTBWQCjs.BadRequestException; exports.BaseModel = _chunkEYNTBWQCjs.BaseModel; exports.BaseModelClass = _chunkEYNTBWQCjs.BaseModelClass; exports.DB = _chunkEYNTBWQCjs.DB; exports.DuplicateRowException = _chunkEYNTBWQCjs.DuplicateRowException; exports.EntityManager = _chunkEYNTBWQCjs.EntityManager; exports.FixtureManager = _chunkEYNTBWQCjs.FixtureManager; exports.FixtureManagerClass = _chunkEYNTBWQCjs.FixtureManagerClass; exports.GenerateOptions = _chunkEYNTBWQCjs.GenerateOptions; exports.InternalServerErrorException = _chunkEYNTBWQCjs.InternalServerErrorException; exports.Migrator = _chunkEYNTBWQCjs.Migrator; exports.NotFoundException = _chunkEYNTBWQCjs.NotFoundException; exports.PathAndCode = _chunkEYNTBWQCjs.PathAndCode; exports.RenderingNode = _chunkEYNTBWQCjs.RenderingNode; exports.SQLDateTimeString = _chunkEYNTBWQCjs.SQLDateTimeString; exports.ServiceUnavailableException = _chunkEYNTBWQCjs.ServiceUnavailableException; exports.SoException = _chunkEYNTBWQCjs.SoException; exports.Sonamu = _chunkEYNTBWQCjs.Sonamu; exports.SonamuQueryMode = _chunkEYNTBWQCjs.SonamuQueryMode; exports.Syncer = _chunkEYNTBWQCjs.Syncer; exports.TargetNotFoundException = _chunkEYNTBWQCjs.TargetNotFoundException; exports.TemplateKey = _chunkEYNTBWQCjs.TemplateKey; exports.TemplateOptions = _chunkEYNTBWQCjs.TemplateOptions; exports.UnauthorizedException = _chunkEYNTBWQCjs.UnauthorizedException; exports.UpsertBuilder = _chunkEYNTBWQCjs.UpsertBuilder; exports.api = _chunkEYNTBWQCjs.api; exports.apiParamToTsCode = _chunkEYNTBWQCjs.apiParamToTsCode; exports.apiParamTypeToTsType = _chunkEYNTBWQCjs.apiParamTypeToTsType; exports.asArray = asArray; exports.findApiRootPath = _chunkEYNTBWQCjs.findApiRootPath; exports.findAppRootPath = _chunkEYNTBWQCjs.findAppRootPath; exports.getTextTypeLength = _chunkEYNTBWQCjs.getTextTypeLength; exports.getZodObjectFromApi = _chunkEYNTBWQCjs.getZodObjectFromApi; exports.getZodObjectFromApiParams = _chunkEYNTBWQCjs.getZodObjectFromApiParams; exports.getZodTypeFromApiParamType = _chunkEYNTBWQCjs.getZodTypeFromApiParamType; exports.globAsync = _chunkEYNTBWQCjs.globAsync; exports.i = i; exports.importMultiple = _chunkEYNTBWQCjs.importMultiple; exports.isBelongsToOneRelationProp = _chunkEYNTBWQCjs.isBelongsToOneRelationProp; exports.isBigIntegerProp = _chunkEYNTBWQCjs.isBigIntegerProp; exports.isBooleanProp = _chunkEYNTBWQCjs.isBooleanProp; exports.isCustomJoinClause = _chunkEYNTBWQCjs.isCustomJoinClause; exports.isDaemonServer = _chunkEYNTBWQCjs.isDaemonServer; exports.isDateProp = _chunkEYNTBWQCjs.isDateProp; exports.isDateTimeProp = _chunkEYNTBWQCjs.isDateTimeProp; exports.isDecimalProp = _chunkEYNTBWQCjs.isDecimalProp; exports.isDevelopment = _chunkEYNTBWQCjs.isDevelopment; exports.isDoubleProp = _chunkEYNTBWQCjs.isDoubleProp; exports.isEnumProp = _chunkEYNTBWQCjs.isEnumProp; exports.isFloatProp = _chunkEYNTBWQCjs.isFloatProp; exports.isHasManyRelationProp = _chunkEYNTBWQCjs.isHasManyRelationProp; exports.isInDocker = _chunkEYNTBWQCjs.isInDocker; exports.isIntegerProp = _chunkEYNTBWQCjs.isIntegerProp; exports.isJsonProp = _chunkEYNTBWQCjs.isJsonProp; exports.isKnexError = _chunkEYNTBWQCjs.isKnexError; exports.isLocal = _chunkEYNTBWQCjs.isLocal; exports.isManyToManyRelationProp = _chunkEYNTBWQCjs.isManyToManyRelationProp; exports.isOneToOneRelationProp = _chunkEYNTBWQCjs.isOneToOneRelationProp; exports.isProduction = _chunkEYNTBWQCjs.isProduction; exports.isRefField = _chunkEYNTBWQCjs.isRefField; exports.isRelationProp = _chunkEYNTBWQCjs.isRelationProp; exports.isRemote = _chunkEYNTBWQCjs.isRemote; exports.isSoException = _chunkEYNTBWQCjs.isSoException; exports.isStaging = _chunkEYNTBWQCjs.isStaging; exports.isStringProp = _chunkEYNTBWQCjs.isStringProp; exports.isTest = _chunkEYNTBWQCjs.isTest; exports.isTextProp = _chunkEYNTBWQCjs.isTextProp; exports.isTimeProp = _chunkEYNTBWQCjs.isTimeProp; exports.isTimestampProp = _chunkEYNTBWQCjs.isTimestampProp; exports.isUuidProp = _chunkEYNTBWQCjs.isUuidProp; exports.isVirtualProp = _chunkEYNTBWQCjs.isVirtualProp; exports.nonNullable = _chunkEYNTBWQCjs.nonNullable; exports.objToMap = objToMap; exports.p = p; exports.propNodeToZodTypeDef = _chunkEYNTBWQCjs.propNodeToZodTypeDef; exports.propToZodTypeDef = _chunkEYNTBWQCjs.propToZodTypeDef; exports.registeredApis = _chunkEYNTBWQCjs.registeredApis; exports.serializeZodType = _chunkEYNTBWQCjs.serializeZodType; exports.setupErrorHandler = setupErrorHandler; exports.unwrapPromiseOnce = _chunkEYNTBWQCjs.unwrapPromiseOnce; exports.zArrayable = _chunkEYNTBWQCjs.zArrayable; exports.zodTypeToTsTypeDef = _chunkEYNTBWQCjs.zodTypeToTsTypeDef; exports.zodTypeToZodCode = _chunkEYNTBWQCjs.zodTypeToZodCode;
425
425
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -80,7 +80,7 @@ import {
80
80
  zArrayable,
81
81
  zodTypeToTsTypeDef,
82
82
  zodTypeToZodCode
83
- } from "./chunk-34NT3NGL.mjs";
83
+ } from "./chunk-FOD6BJQJ.mjs";
84
84
  import "./chunk-JXJTFHF7.mjs";
85
85
 
86
86
  // src/exceptions/error-handler.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonamu",
3
- "version": "0.2.42",
3
+ "version": "0.2.44",
4
4
  "description": "Sonamu — TypeScript Fullstack API Framework",
5
5
  "keywords": [
6
6
  "typescript",
package/src/api/sonamu.ts CHANGED
@@ -16,6 +16,7 @@ import { findApiRootPath } from "../utils/utils";
16
16
  import path from "path";
17
17
  import fs from "fs-extra";
18
18
  import { ApiDecoratorOptions } from "./decorators";
19
+ import { attachOnDuplicateUpdate } from "../database/knex-plugins/knex-on-duplicate-update";
19
20
 
20
21
  export type SonamuConfig = {
21
22
  api: {
@@ -138,6 +139,7 @@ class SonamuClass {
138
139
  // DB 로드
139
140
  this.dbConfig = await DB.readKnexfile();
140
141
  !doSilent && console.log(chalk.green("DB Config Loaded!"));
142
+ attachOnDuplicateUpdate();
141
143
 
142
144
  // Entity 로드
143
145
  await EntityManager.autoload(doSilent);
@@ -1,8 +1,6 @@
1
1
  import { DateTime } from "luxon";
2
2
  import { Knex } from "knex";
3
3
  import _ from "lodash";
4
- import { attachOnDuplicateUpdate } from "./knex-plugins/knex-on-duplicate-update";
5
- _.once(() => attachOnDuplicateUpdate());
6
4
  import { DBPreset, DB } from "./db";
7
5
  import { isCustomJoinClause, SubsetQuery } from "../types/types";
8
6
  import { BaseListParams } from "../utils/model";
@@ -1,41 +1,45 @@
1
1
  import knex from "knex";
2
2
 
3
3
  export function attachOnDuplicateUpdate() {
4
- knex.QueryBuilder.extend("onDuplicateUpdate", function (...columns) {
5
- if (columns.length === 0) {
6
- // 업데이트 컬럼이 없으면 onDuplicateUpdate 구문 처리 패스
7
- const { sql: originalSQL, bindings: originalBindings } = this.toSQL();
8
- return this.client.raw(originalSQL, originalBindings);
9
- }
4
+ try {
5
+ knex.QueryBuilder.extend("onDuplicateUpdate", function (...columns) {
6
+ if (columns.length === 0) {
7
+ // 업데이트 컬럼이 없으면 onDuplicateUpdate 구문 처리 패스
8
+ const { sql: originalSQL, bindings: originalBindings } = this.toSQL();
9
+ return this.client.raw(originalSQL, originalBindings);
10
+ }
10
11
 
11
- const { placeholders, bindings } = columns.reduce(
12
- (result, column) => {
13
- if (typeof column === "string") {
14
- result.placeholders.push(`?? = Values(??)`);
15
- result.bindings.push(column, column);
16
- } else if (column && typeof column === "object") {
17
- Object.keys(column).forEach((key) => {
18
- result.placeholders.push(`?? = ?`);
19
- result.bindings.push(key, column[key]);
20
- });
21
- } else {
22
- throw new Error(
23
- "onDuplicateUpdate error: expected column name to be string or object."
24
- );
25
- }
12
+ const { placeholders, bindings } = columns.reduce(
13
+ (result, column) => {
14
+ if (typeof column === "string") {
15
+ result.placeholders.push(`?? = Values(??)`);
16
+ result.bindings.push(column, column);
17
+ } else if (column && typeof column === "object") {
18
+ Object.keys(column).forEach((key) => {
19
+ result.placeholders.push(`?? = ?`);
20
+ result.bindings.push(key, column[key]);
21
+ });
22
+ } else {
23
+ throw new Error(
24
+ "onDuplicateUpdate error: expected column name to be string or object."
25
+ );
26
+ }
26
27
 
27
- return result;
28
- },
29
- { placeholders: [], bindings: [] }
30
- );
28
+ return result;
29
+ },
30
+ { placeholders: [], bindings: [] }
31
+ );
31
32
 
32
- const { sql: originalSQL, bindings: originalBindings } = this.toSQL();
33
+ const { sql: originalSQL, bindings: originalBindings } = this.toSQL();
33
34
 
34
- const newBindings = [...originalBindings, ...bindings];
35
+ const newBindings = [...originalBindings, ...bindings];
35
36
 
36
- return this.client.raw(
37
- `${originalSQL} ON DUPLICATE KEY UPDATE ${placeholders.join(", ")}`,
38
- newBindings
39
- );
40
- });
37
+ return this.client.raw(
38
+ `${originalSQL} ON DUPLICATE KEY UPDATE ${placeholders.join(", ")}`,
39
+ newBindings
40
+ );
41
+ });
42
+ } catch {
43
+ // ignored
44
+ }
41
45
  }
package/tsup.config.js CHANGED
@@ -19,11 +19,26 @@ export default defineConfig({
19
19
  }
20
20
  },
21
21
  external: [
22
- "zod",
22
+ "chalk",
23
+ "dotenv",
24
+ "fast-deep-equal",
23
25
  "fastify",
26
+ "fs-extra",
27
+ "glob",
24
28
  "inflection",
29
+ "knex",
30
+ "lodash",
31
+ "luxon",
32
+ "mysql2",
33
+ "node-sql-parser",
34
+ "prompts",
35
+ "qs",
36
+ "tsicli",
37
+ "uuid",
38
+ "zod",
39
+ "prettier",
25
40
  "source-map-support",
41
+ "tsup",
26
42
  "typescript",
27
- "prettier",
28
43
  ],
29
44
  });