sonamu 0.2.45 → 0.2.47

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.d.ts CHANGED
@@ -400,16 +400,28 @@ declare const TemplateOptions: z.ZodObject<{
400
400
  parentId: z.ZodOptional<z.ZodString>;
401
401
  title: z.ZodString;
402
402
  table: z.ZodOptional<z.ZodString>;
403
+ props: z.ZodOptional<z.ZodArray<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, "many">>;
404
+ indexes: z.ZodOptional<z.ZodArray<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, "many">>;
405
+ subsets: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
406
+ enums: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
403
407
  }, "strip", z.ZodTypeAny, {
404
408
  entityId: string;
405
409
  title: string;
406
410
  parentId?: string | undefined;
407
411
  table?: string | undefined;
412
+ props?: {}[] | undefined;
413
+ indexes?: {}[] | undefined;
414
+ subsets?: {} | undefined;
415
+ enums?: {} | undefined;
408
416
  }, {
409
417
  entityId: string;
410
418
  title: string;
411
419
  parentId?: string | undefined;
412
420
  table?: string | undefined;
421
+ props?: {}[] | undefined;
422
+ indexes?: {}[] | undefined;
423
+ subsets?: {} | undefined;
424
+ enums?: {} | undefined;
413
425
  }>;
414
426
  init_types: z.ZodObject<{
415
427
  entityId: z.ZodString;
@@ -571,6 +583,10 @@ declare const TemplateOptions: z.ZodObject<{
571
583
  title: string;
572
584
  parentId?: string | undefined;
573
585
  table?: string | undefined;
586
+ props?: {}[] | undefined;
587
+ indexes?: {}[] | undefined;
588
+ subsets?: {} | undefined;
589
+ enums?: {} | undefined;
574
590
  };
575
591
  init_types: {
576
592
  entityId: string;
@@ -638,6 +654,10 @@ declare const TemplateOptions: z.ZodObject<{
638
654
  title: string;
639
655
  parentId?: string | undefined;
640
656
  table?: string | undefined;
657
+ props?: {}[] | undefined;
658
+ indexes?: {}[] | undefined;
659
+ subsets?: {} | undefined;
660
+ enums?: {} | undefined;
641
661
  };
642
662
  init_types: {
643
663
  entityId: string;
@@ -967,7 +987,9 @@ declare class Syncer {
967
987
  resolveRenderType(key: string, zodType: z.ZodTypeAny): RenderingNode["renderType"];
968
988
  zodTypeToRenderingNode(zodType: z.ZodTypeAny, baseKey?: string): RenderingNode;
969
989
  getColumnsNode(entityId: string, subsetKey: string): Promise<RenderingNode>;
970
- createEntity(entityId: string, parentId?: string, table?: string, title?: string): Promise<void>;
990
+ createEntity(form: Omit<TemplateOptions["entity"], "title"> & {
991
+ title?: string;
992
+ }): Promise<void>;
971
993
  delEntity(entityId: string): Promise<{
972
994
  delPaths: string[];
973
995
  }>;
@@ -1416,4 +1438,4 @@ declare function findAppRootPath(): Promise<string>;
1416
1438
  declare function findApiRootPath(): Promise<string>;
1417
1439
  declare function nonNullable<T>(value: T): value is NonNullable<T>;
1418
1440
 
1419
- export { AlreadyProcessedException, type ApiDecoratorOptions, type ApiParam, ApiParamType, type ArrayOr, BadRequestException, type BaseListParams, BaseModel, BaseModelClass, type BelongsToOneRelationProp, type BigIntegerProp, type BooleanProp, type CommonProp, type Context, type ContextExtend, DB, type DBPreset, type DateProp, type DateTimeProp, type DecimalProp, type DistributiveOmit, type DoubleProp, DuplicateRowException, type EntityIndex, type EntityJson, EntityManager, type EntityNamesRecord, type EntityProp, type EntityPropNode, type EntitySubsetRow, type EnumProp, type EnumsLabel, type EnumsLabelKo, type ExtendedApi, FixtureManager, FixtureManagerClass, type FlattenSubsetRow, type FloatProp, type GenMigrationCode, GenerateOptions, type HasManyRelationProp, type IntegerProp, InternalServerErrorException, type JsonProp, type KnexColumnType, type KnexError, type ListResult, type ManyToManyRelationProp, type MigrationColumn, type MigrationForeign, type MigrationIndex, type MigrationJoinTable, type MigrationSet, type MigrationSetAndJoinTable, type MigrationStatus, Migrator, type MigratorOptions, NotFoundException, type OneToOneRelationProp, PathAndCode, type RelationOn, type RelationProp, type RelationType, type RenderedTemplate, RenderingNode, type SMDInput, SQLDateTimeString, type ServiceClient, ServiceUnavailableException, SoException, Sonamu, type SonamuConfig, type SonamuDBConfig, SonamuQueryMode, type StringProp, type SubsetQuery, Syncer, TargetNotFoundException, TemplateKey, TemplateOptions, type TextProp, type TimeProp, type TimestampProp, type UBRef, UnauthorizedException, UpsertBuilder, type UuidProp, type VirtualProp, api, apiParamToTsCode, apiParamTypeToTsType, asArray, findApiRootPath, findAppRootPath, getTextTypeLength, getZodObjectFromApi, getZodObjectFromApiParams, getZodTypeFromApiParamType, globAsync, i, importMultiple, isBelongsToOneRelationProp, isBigIntegerProp, isBooleanProp, isCustomJoinClause, isDaemonServer, isDateProp, isDateTimeProp, isDecimalProp, isDevelopment, isDoubleProp, isEnumProp, isFloatProp, isHasManyRelationProp, isInDocker, isIntegerProp, isJsonProp, isKnexError, isLocal, isManyToManyRelationProp, isOneToOneRelationProp, isProduction, isRefField, isRelationProp, isRemote, isSoException, isStaging, isStringProp, isTest, isTextProp, isTimeProp, isTimestampProp, isUuidProp, isVirtualProp, nonNullable, objToMap, p, propNodeToZodTypeDef, propToZodTypeDef, registeredApis, serializeZodType, setupErrorHandler, unwrapPromiseOnce, zArrayable, zodTypeToTsTypeDef, zodTypeToZodCode };
1441
+ export { AlreadyProcessedException, type ApiDecoratorOptions, type ApiParam, ApiParamType, type ArrayOr, BadRequestException, type BaseListParams, BaseModel, BaseModelClass, type BelongsToOneRelationProp, type BigIntegerProp, type BooleanProp, type CommonProp, type Context, type ContextExtend, DB, type DBPreset, type DateProp, type DateTimeProp, type DecimalProp, type DistributiveOmit, type DoubleProp, DuplicateRowException, Entity, type EntityIndex, type EntityJson, EntityManager, type EntityNamesRecord, type EntityProp, type EntityPropNode, type EntitySubsetRow, type EnumProp, type EnumsLabel, type EnumsLabelKo, type ExtendedApi, FixtureManager, FixtureManagerClass, type FlattenSubsetRow, type FloatProp, type GenMigrationCode, GenerateOptions, type HasManyRelationProp, type IntegerProp, InternalServerErrorException, type JsonProp, type KnexColumnType, type KnexError, type ListResult, type ManyToManyRelationProp, type MigrationColumn, type MigrationForeign, type MigrationIndex, type MigrationJoinTable, type MigrationSet, type MigrationSetAndJoinTable, type MigrationStatus, Migrator, type MigratorOptions, NotFoundException, type OneToOneRelationProp, PathAndCode, type RelationOn, type RelationProp, type RelationType, type RenderedTemplate, RenderingNode, type SMDInput, SQLDateTimeString, type ServiceClient, ServiceUnavailableException, SoException, Sonamu, type SonamuConfig, type SonamuDBConfig, SonamuQueryMode, type StringProp, type SubsetQuery, Syncer, TargetNotFoundException, TemplateKey, TemplateOptions, type TextProp, type TimeProp, type TimestampProp, type UBRef, UnauthorizedException, UpsertBuilder, type UuidProp, type VirtualProp, api, apiParamToTsCode, apiParamTypeToTsType, asArray, findApiRootPath, findAppRootPath, getTextTypeLength, getZodObjectFromApi, getZodObjectFromApiParams, getZodTypeFromApiParamType, globAsync, i, importMultiple, isBelongsToOneRelationProp, isBigIntegerProp, isBooleanProp, isCustomJoinClause, isDaemonServer, isDateProp, isDateTimeProp, isDecimalProp, isDevelopment, isDoubleProp, isEnumProp, isFloatProp, isHasManyRelationProp, isInDocker, isIntegerProp, isJsonProp, isKnexError, isLocal, isManyToManyRelationProp, isOneToOneRelationProp, isProduction, isRefField, isRelationProp, isRemote, isSoException, isStaging, isStringProp, isTest, isTextProp, isTimeProp, isTimestampProp, isUuidProp, isVirtualProp, nonNullable, objToMap, p, propNodeToZodTypeDef, propToZodTypeDef, registeredApis, serializeZodType, setupErrorHandler, unwrapPromiseOnce, zArrayable, zodTypeToTsTypeDef, zodTypeToZodCode };
package/dist/index.js CHANGED
@@ -79,13 +79,14 @@
79
79
 
80
80
 
81
81
 
82
- var _chunk77XBF27Ljs = require('./chunk-77XBF27L.js');
82
+
83
+ var _chunk5VT5JTY4js = require('./chunk-5VT5JTY4.js');
83
84
 
84
85
  // src/exceptions/error-handler.ts
85
86
  function setupErrorHandler(server) {
86
87
  server.setErrorHandler((error, request, reply) => {
87
88
  _nullishCoalesce(error.statusCode, () => ( (error.statusCode = 400)));
88
- if (_chunk77XBF27Ljs.isSoException.call(void 0, error) && error.payload && Array.isArray(error.payload)) {
89
+ if (_chunk5VT5JTY4js.isSoException.call(void 0, error) && error.payload && Array.isArray(error.payload)) {
89
90
  const issues = error.payload;
90
91
  const [issue] = issues;
91
92
  const message = `${issue.message} (${issue.path.join("/")})`;
@@ -421,5 +422,6 @@ function unique(columns) {
421
422
 
422
423
 
423
424
 
424
- exports.AlreadyProcessedException = _chunk77XBF27Ljs.AlreadyProcessedException; exports.ApiParamType = _chunk77XBF27Ljs.ApiParamType; exports.BadRequestException = _chunk77XBF27Ljs.BadRequestException; exports.BaseModel = _chunk77XBF27Ljs.BaseModel; exports.BaseModelClass = _chunk77XBF27Ljs.BaseModelClass; exports.DB = _chunk77XBF27Ljs.DB; exports.DuplicateRowException = _chunk77XBF27Ljs.DuplicateRowException; exports.EntityManager = _chunk77XBF27Ljs.EntityManager; exports.FixtureManager = _chunk77XBF27Ljs.FixtureManager; exports.FixtureManagerClass = _chunk77XBF27Ljs.FixtureManagerClass; exports.GenerateOptions = _chunk77XBF27Ljs.GenerateOptions; exports.InternalServerErrorException = _chunk77XBF27Ljs.InternalServerErrorException; exports.Migrator = _chunk77XBF27Ljs.Migrator; exports.NotFoundException = _chunk77XBF27Ljs.NotFoundException; exports.PathAndCode = _chunk77XBF27Ljs.PathAndCode; exports.RenderingNode = _chunk77XBF27Ljs.RenderingNode; exports.SQLDateTimeString = _chunk77XBF27Ljs.SQLDateTimeString; exports.ServiceUnavailableException = _chunk77XBF27Ljs.ServiceUnavailableException; exports.SoException = _chunk77XBF27Ljs.SoException; exports.Sonamu = _chunk77XBF27Ljs.Sonamu; exports.SonamuQueryMode = _chunk77XBF27Ljs.SonamuQueryMode; exports.Syncer = _chunk77XBF27Ljs.Syncer; exports.TargetNotFoundException = _chunk77XBF27Ljs.TargetNotFoundException; exports.TemplateKey = _chunk77XBF27Ljs.TemplateKey; exports.TemplateOptions = _chunk77XBF27Ljs.TemplateOptions; exports.UnauthorizedException = _chunk77XBF27Ljs.UnauthorizedException; exports.UpsertBuilder = _chunk77XBF27Ljs.UpsertBuilder; exports.api = _chunk77XBF27Ljs.api; exports.apiParamToTsCode = _chunk77XBF27Ljs.apiParamToTsCode; exports.apiParamTypeToTsType = _chunk77XBF27Ljs.apiParamTypeToTsType; exports.asArray = asArray; exports.findApiRootPath = _chunk77XBF27Ljs.findApiRootPath; exports.findAppRootPath = _chunk77XBF27Ljs.findAppRootPath; exports.getTextTypeLength = _chunk77XBF27Ljs.getTextTypeLength; exports.getZodObjectFromApi = _chunk77XBF27Ljs.getZodObjectFromApi; exports.getZodObjectFromApiParams = _chunk77XBF27Ljs.getZodObjectFromApiParams; exports.getZodTypeFromApiParamType = _chunk77XBF27Ljs.getZodTypeFromApiParamType; exports.globAsync = _chunk77XBF27Ljs.globAsync; exports.i = i; exports.importMultiple = _chunk77XBF27Ljs.importMultiple; exports.isBelongsToOneRelationProp = _chunk77XBF27Ljs.isBelongsToOneRelationProp; exports.isBigIntegerProp = _chunk77XBF27Ljs.isBigIntegerProp; exports.isBooleanProp = _chunk77XBF27Ljs.isBooleanProp; exports.isCustomJoinClause = _chunk77XBF27Ljs.isCustomJoinClause; exports.isDaemonServer = _chunk77XBF27Ljs.isDaemonServer; exports.isDateProp = _chunk77XBF27Ljs.isDateProp; exports.isDateTimeProp = _chunk77XBF27Ljs.isDateTimeProp; exports.isDecimalProp = _chunk77XBF27Ljs.isDecimalProp; exports.isDevelopment = _chunk77XBF27Ljs.isDevelopment; exports.isDoubleProp = _chunk77XBF27Ljs.isDoubleProp; exports.isEnumProp = _chunk77XBF27Ljs.isEnumProp; exports.isFloatProp = _chunk77XBF27Ljs.isFloatProp; exports.isHasManyRelationProp = _chunk77XBF27Ljs.isHasManyRelationProp; exports.isInDocker = _chunk77XBF27Ljs.isInDocker; exports.isIntegerProp = _chunk77XBF27Ljs.isIntegerProp; exports.isJsonProp = _chunk77XBF27Ljs.isJsonProp; exports.isKnexError = _chunk77XBF27Ljs.isKnexError; exports.isLocal = _chunk77XBF27Ljs.isLocal; exports.isManyToManyRelationProp = _chunk77XBF27Ljs.isManyToManyRelationProp; exports.isOneToOneRelationProp = _chunk77XBF27Ljs.isOneToOneRelationProp; exports.isProduction = _chunk77XBF27Ljs.isProduction; exports.isRefField = _chunk77XBF27Ljs.isRefField; exports.isRelationProp = _chunk77XBF27Ljs.isRelationProp; exports.isRemote = _chunk77XBF27Ljs.isRemote; exports.isSoException = _chunk77XBF27Ljs.isSoException; exports.isStaging = _chunk77XBF27Ljs.isStaging; exports.isStringProp = _chunk77XBF27Ljs.isStringProp; exports.isTest = _chunk77XBF27Ljs.isTest; exports.isTextProp = _chunk77XBF27Ljs.isTextProp; exports.isTimeProp = _chunk77XBF27Ljs.isTimeProp; exports.isTimestampProp = _chunk77XBF27Ljs.isTimestampProp; exports.isUuidProp = _chunk77XBF27Ljs.isUuidProp; exports.isVirtualProp = _chunk77XBF27Ljs.isVirtualProp; exports.nonNullable = _chunk77XBF27Ljs.nonNullable; exports.objToMap = objToMap; exports.p = p; exports.propNodeToZodTypeDef = _chunk77XBF27Ljs.propNodeToZodTypeDef; exports.propToZodTypeDef = _chunk77XBF27Ljs.propToZodTypeDef; exports.registeredApis = _chunk77XBF27Ljs.registeredApis; exports.serializeZodType = _chunk77XBF27Ljs.serializeZodType; exports.setupErrorHandler = setupErrorHandler; exports.unwrapPromiseOnce = _chunk77XBF27Ljs.unwrapPromiseOnce; exports.zArrayable = _chunk77XBF27Ljs.zArrayable; exports.zodTypeToTsTypeDef = _chunk77XBF27Ljs.zodTypeToTsTypeDef; exports.zodTypeToZodCode = _chunk77XBF27Ljs.zodTypeToZodCode;
425
+
426
+ exports.AlreadyProcessedException = _chunk5VT5JTY4js.AlreadyProcessedException; exports.ApiParamType = _chunk5VT5JTY4js.ApiParamType; exports.BadRequestException = _chunk5VT5JTY4js.BadRequestException; exports.BaseModel = _chunk5VT5JTY4js.BaseModel; exports.BaseModelClass = _chunk5VT5JTY4js.BaseModelClass; exports.DB = _chunk5VT5JTY4js.DB; exports.DuplicateRowException = _chunk5VT5JTY4js.DuplicateRowException; exports.Entity = _chunk5VT5JTY4js.Entity; exports.EntityManager = _chunk5VT5JTY4js.EntityManager; exports.FixtureManager = _chunk5VT5JTY4js.FixtureManager; exports.FixtureManagerClass = _chunk5VT5JTY4js.FixtureManagerClass; exports.GenerateOptions = _chunk5VT5JTY4js.GenerateOptions; exports.InternalServerErrorException = _chunk5VT5JTY4js.InternalServerErrorException; exports.Migrator = _chunk5VT5JTY4js.Migrator; exports.NotFoundException = _chunk5VT5JTY4js.NotFoundException; exports.PathAndCode = _chunk5VT5JTY4js.PathAndCode; exports.RenderingNode = _chunk5VT5JTY4js.RenderingNode; exports.SQLDateTimeString = _chunk5VT5JTY4js.SQLDateTimeString; exports.ServiceUnavailableException = _chunk5VT5JTY4js.ServiceUnavailableException; exports.SoException = _chunk5VT5JTY4js.SoException; exports.Sonamu = _chunk5VT5JTY4js.Sonamu; exports.SonamuQueryMode = _chunk5VT5JTY4js.SonamuQueryMode; exports.Syncer = _chunk5VT5JTY4js.Syncer; exports.TargetNotFoundException = _chunk5VT5JTY4js.TargetNotFoundException; exports.TemplateKey = _chunk5VT5JTY4js.TemplateKey; exports.TemplateOptions = _chunk5VT5JTY4js.TemplateOptions; exports.UnauthorizedException = _chunk5VT5JTY4js.UnauthorizedException; exports.UpsertBuilder = _chunk5VT5JTY4js.UpsertBuilder; exports.api = _chunk5VT5JTY4js.api; exports.apiParamToTsCode = _chunk5VT5JTY4js.apiParamToTsCode; exports.apiParamTypeToTsType = _chunk5VT5JTY4js.apiParamTypeToTsType; exports.asArray = asArray; exports.findApiRootPath = _chunk5VT5JTY4js.findApiRootPath; exports.findAppRootPath = _chunk5VT5JTY4js.findAppRootPath; exports.getTextTypeLength = _chunk5VT5JTY4js.getTextTypeLength; exports.getZodObjectFromApi = _chunk5VT5JTY4js.getZodObjectFromApi; exports.getZodObjectFromApiParams = _chunk5VT5JTY4js.getZodObjectFromApiParams; exports.getZodTypeFromApiParamType = _chunk5VT5JTY4js.getZodTypeFromApiParamType; exports.globAsync = _chunk5VT5JTY4js.globAsync; exports.i = i; exports.importMultiple = _chunk5VT5JTY4js.importMultiple; exports.isBelongsToOneRelationProp = _chunk5VT5JTY4js.isBelongsToOneRelationProp; exports.isBigIntegerProp = _chunk5VT5JTY4js.isBigIntegerProp; exports.isBooleanProp = _chunk5VT5JTY4js.isBooleanProp; exports.isCustomJoinClause = _chunk5VT5JTY4js.isCustomJoinClause; exports.isDaemonServer = _chunk5VT5JTY4js.isDaemonServer; exports.isDateProp = _chunk5VT5JTY4js.isDateProp; exports.isDateTimeProp = _chunk5VT5JTY4js.isDateTimeProp; exports.isDecimalProp = _chunk5VT5JTY4js.isDecimalProp; exports.isDevelopment = _chunk5VT5JTY4js.isDevelopment; exports.isDoubleProp = _chunk5VT5JTY4js.isDoubleProp; exports.isEnumProp = _chunk5VT5JTY4js.isEnumProp; exports.isFloatProp = _chunk5VT5JTY4js.isFloatProp; exports.isHasManyRelationProp = _chunk5VT5JTY4js.isHasManyRelationProp; exports.isInDocker = _chunk5VT5JTY4js.isInDocker; exports.isIntegerProp = _chunk5VT5JTY4js.isIntegerProp; exports.isJsonProp = _chunk5VT5JTY4js.isJsonProp; exports.isKnexError = _chunk5VT5JTY4js.isKnexError; exports.isLocal = _chunk5VT5JTY4js.isLocal; exports.isManyToManyRelationProp = _chunk5VT5JTY4js.isManyToManyRelationProp; exports.isOneToOneRelationProp = _chunk5VT5JTY4js.isOneToOneRelationProp; exports.isProduction = _chunk5VT5JTY4js.isProduction; exports.isRefField = _chunk5VT5JTY4js.isRefField; exports.isRelationProp = _chunk5VT5JTY4js.isRelationProp; exports.isRemote = _chunk5VT5JTY4js.isRemote; exports.isSoException = _chunk5VT5JTY4js.isSoException; exports.isStaging = _chunk5VT5JTY4js.isStaging; exports.isStringProp = _chunk5VT5JTY4js.isStringProp; exports.isTest = _chunk5VT5JTY4js.isTest; exports.isTextProp = _chunk5VT5JTY4js.isTextProp; exports.isTimeProp = _chunk5VT5JTY4js.isTimeProp; exports.isTimestampProp = _chunk5VT5JTY4js.isTimestampProp; exports.isUuidProp = _chunk5VT5JTY4js.isUuidProp; exports.isVirtualProp = _chunk5VT5JTY4js.isVirtualProp; exports.nonNullable = _chunk5VT5JTY4js.nonNullable; exports.objToMap = objToMap; exports.p = p; exports.propNodeToZodTypeDef = _chunk5VT5JTY4js.propNodeToZodTypeDef; exports.propToZodTypeDef = _chunk5VT5JTY4js.propToZodTypeDef; exports.registeredApis = _chunk5VT5JTY4js.registeredApis; exports.serializeZodType = _chunk5VT5JTY4js.serializeZodType; exports.setupErrorHandler = setupErrorHandler; exports.unwrapPromiseOnce = _chunk5VT5JTY4js.unwrapPromiseOnce; exports.zArrayable = _chunk5VT5JTY4js.zArrayable; exports.zodTypeToTsTypeDef = _chunk5VT5JTY4js.zodTypeToTsTypeDef; exports.zodTypeToZodCode = _chunk5VT5JTY4js.zodTypeToZodCode;
425
427
  //# 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","../src/utils/model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,kBAAkB,QAAyB;AACzD,SAAO,gBAAgB,CAAC,OAAO,SAAS,UAAU;AAChD,UAAM,eAAN,MAAM,aAAe;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;AAE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AAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,QACP,MACA,QACa;AACb,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,WACP,MACA,QACgB;AAChB,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,KAAK,MAAc,QAAmD;AAC7E,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,OACP,MACA,QACY;AACZ,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,MACP,MACA,QACW;AACX,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,WAAW;AAAA,IACX,OAAO;AAAA,IACP,GAAG;AAAA,EACL;AACF;AACA,SAAS,OACP,MACA,QACY;AACZ,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,WAAW;AAAA,IACX,OAAO;AAAA,IACP,GAAG;AAAA,EACL;AACF;AACA,SAAS,QACP,MACA,QACa;AACb,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,WAAW;AAAA,IACX,OAAO;AAAA,IACP,GAAG;AAAA,EACL;AACF;AACA,SAAS,QACP,MACA,QACa;AACb,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,KACP,MACA,QACU;AACV,MAAI,QAAQ,QAAQ,MAAM;AACxB,WAAO,OAAO;AACd,WAAO,YAAY;AAAA,EACrB;AACA,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,SACP,MACA,QACc;AACd,MAAI,QAAQ,QAAQ,MAAM;AACxB,WAAO,OAAO;AACd,WAAO,YAAY;AAAA,EACrB;AACA,SAAO;AAAA,IACL;AAAA,IACA,M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,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","import _ from \"lodash\";\n\nexport type ListResult<T> = {\n rows: T[];\n total?: number;\n};\n\nexport type ArrayOr<T> = T | T[];\n\nexport function asArray<T>(param: T | T[]): T[] {\n if (Array.isArray(param)) {\n return param;\n } else {\n return [param as T] as T[];\n }\n}\n\nexport function objToMap<T>(obj: { [k: string]: T }) {\n const keys = Object.keys(obj);\n if (keys.every((key) => parseInt(key).toString() === key)) {\n return new Map<number, T>(keys.map((key) => [parseInt(key), obj[key]]));\n } else {\n return new Map<string, T>(Object.entries(obj));\n }\n}\n\nexport interface BaseListParams {\n id?: number | number[];\n num?: number;\n page?: number;\n keyword?: string;\n queryMode?: \"list\" | \"count\" | \"both\";\n}\n"]}
1
+ {"version":3,"sources":["../src/exceptions/error-handler.ts","../src/entity/entity-utils.ts","../src/utils/model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,kBAAkB,QAAyB;AACzD,SAAO,gBAAgB,CAAC,OAAO,SAAS,UAAU;AAChD,UAAM,eAAN,MAAM,aAAe;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,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AA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,QACP,MACA,QACa;AACb,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,WACP,MACA,QACgB;AAChB,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,KAAK,MAAc,QAAmD;AAC7E,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,OACP,MACA,QACY;AACZ,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,MACP,MACA,QACW;AACX,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,WAAW;AAAA,IACX,OAAO;AAAA,IACP,GAAG;AAAA,EACL;AACF;AACA,SAAS,OACP,MACA,QACY;AACZ,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,WAAW;AAAA,IACX,OAAO;AAAA,IACP,GAAG;AAAA,EACL;AACF;AACA,SAAS,QACP,MACA,QACa;AACb,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,WAAW;AAAA,IACX,OAAO;AAAA,IACP,GAAG;AAAA,EACL;AACF;AACA,SAAS,QACP,MACA,QACa;AACb,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,KACP,MACA,QACU;AACV,MAAI,QAAQ,QAAQ,MAAM;AACxB,WAAO,OAAO;AACd,WAAO,YAAY;AAAA,EACrB;AACA,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,SACP,MACA,QACc;AACd,MAAI,QAAQ,QAAQ,MAAM;AACxB,WAAO,OAAO;AACd,WAAO,YAAY;AAAA,EACrB;AACA,SAAO;AAAA,IACL;AA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ACwB;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","import _ from \"lodash\";\n\nexport type ListResult<T> = {\n rows: T[];\n total?: number;\n};\n\nexport type ArrayOr<T> = T | T[];\n\nexport function asArray<T>(param: T | T[]): T[] {\n if (Array.isArray(param)) {\n return param;\n } else {\n return [param as T] as T[];\n }\n}\n\nexport function objToMap<T>(obj: { [k: string]: T }) {\n const keys = Object.keys(obj);\n if (keys.every((key) => parseInt(key).toString() === key)) {\n return new Map<number, T>(keys.map((key) => [parseInt(key), obj[key]]));\n } else {\n return new Map<string, T>(Object.entries(obj));\n }\n}\n\nexport interface BaseListParams {\n id?: number | number[];\n num?: number;\n page?: number;\n keyword?: string;\n queryMode?: \"list\" | \"count\" | \"both\";\n}\n"]}
package/package.json CHANGED
@@ -1,26 +1,13 @@
1
1
  {
2
2
  "name": "sonamu",
3
- "version": "0.2.45",
3
+ "version": "0.2.47",
4
4
  "description": "Sonamu — TypeScript Fullstack API Framework",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "framework",
8
8
  "orm"
9
9
  ],
10
- "exports": {
11
- ".": {
12
- "import": {
13
- "types": "./dist/index.d.mts",
14
- "default": "./dist/index.mjs"
15
- },
16
- "require": {
17
- "types": "./dist/index.d.ts",
18
- "default": "./dist/index.js"
19
- }
20
- }
21
- },
22
10
  "main": "./dist/index.js",
23
- "module": "./dist/index.mjs",
24
11
  "scripts": {
25
12
  "dev": "yarn tsc -w -p ./tsconfig.json",
26
13
  "build": "tsup --config ./tsup.config.js"
@@ -35,7 +22,7 @@
35
22
  "type": "git",
36
23
  "url": "https://github.com/ping-alive/sonamu.git"
37
24
  },
38
- "bin": "./dist/bin/cli-wrapper.mjs",
25
+ "bin": "./dist/bin/cli.js",
39
26
  "dependencies": {
40
27
  "chalk": "^4.1.2",
41
28
  "dotenv": "^16.0.2",
@@ -44,7 +31,7 @@
44
31
  "fs-extra": "^10.1.0",
45
32
  "glob": "^8.0.3",
46
33
  "inflection": "^1.13.2",
47
- "knex": "^2.5.1",
34
+ "knex": "^3.1.0",
48
35
  "lodash": "^4.17.21",
49
36
  "luxon": "^3.0.3",
50
37
  "mysql2": "^3.6.1",
@@ -72,9 +59,9 @@
72
59
  "typescript": "^5.2.2"
73
60
  },
74
61
  "peerDependencies": {
75
- "fastify": "^4.5.3",
76
- "knex": "^2.3.0",
77
- "mysql2": "^2.3.3"
62
+ "fastify": "^4.23.2",
63
+ "knex": "^3.1.0",
64
+ "mysql2": "^3.6.1"
78
65
  },
79
66
  "packageManager": "yarn@3.6.3"
80
67
  }
package/src/bin/cli.ts CHANGED
@@ -289,7 +289,7 @@ async function stub_practice(name: string) {
289
289
  }
290
290
 
291
291
  async function stub_entity(entityId: string) {
292
- await Sonamu.syncer.createEntity(entityId);
292
+ await Sonamu.syncer.createEntity({ entityId });
293
293
  }
294
294
 
295
295
  async function scaffold_model(entityId: string) {
@@ -844,6 +844,11 @@ export class Entity {
844
844
  }
845
845
  }
846
846
 
847
+ // 현재 엔티티의 인덱스에서 제외
848
+ EntityManager.get(this.id).indexes.map((index) => {
849
+ index.columns = index.columns.filter((col) => col !== oldName);
850
+ });
851
+
847
852
  // 프롭 삭제
848
853
  this.props.splice(at, 1);
849
854
 
@@ -16,7 +16,10 @@ export function isSoException(err: any): err is SoException {
16
16
  잘못된 매개변수 등 요청사항에 문제가 있는 경우
17
17
  */
18
18
  export class BadRequestException extends SoException {
19
- constructor(public message = "Bad Request", public payload?: unknown) {
19
+ constructor(
20
+ public message = "Bad Request",
21
+ public payload?: unknown
22
+ ) {
20
23
  super(400, message, payload);
21
24
  }
22
25
  }
@@ -25,7 +28,10 @@ export class BadRequestException extends SoException {
25
28
  로그인이 반드시 필요한 케이스에 로그아웃 상태인 경우 / 접근 권한이 없는 요청시
26
29
  */
27
30
  export class UnauthorizedException extends SoException {
28
- constructor(public message = "Unauthorized", public payload?: unknown) {
31
+ constructor(
32
+ public message = "Unauthorized",
33
+ public payload?: unknown
34
+ ) {
29
35
  super(401, message, payload);
30
36
  }
31
37
  }
@@ -34,7 +40,10 @@ export class UnauthorizedException extends SoException {
34
40
  존재하지 않는 레코드에 접근시
35
41
  */
36
42
  export class NotFoundException extends SoException {
37
- constructor(public message = "Not Found", public payload?: unknown) {
43
+ constructor(
44
+ public message = "Not Found",
45
+ public payload?: unknown
46
+ ) {
38
47
  super(404, message, payload);
39
48
  }
40
49
  }
@@ -67,8 +76,11 @@ export class InternalServerErrorException extends SoException {
67
76
  이미 처리함
68
77
  */
69
78
  export class AlreadyProcessedException extends SoException {
70
- constructor(public message = "Already Processed", public payload?: unknown) {
71
- super(641, message, payload);
79
+ constructor(
80
+ public message = "Already Processed",
81
+ public payload?: unknown
82
+ ) {
83
+ super(541, message, payload);
72
84
  }
73
85
  }
74
86
 
@@ -76,8 +88,11 @@ export class AlreadyProcessedException extends SoException {
76
88
  중복 허용하지 않는 케이스에 중복 요청
77
89
  */
78
90
  export class DuplicateRowException extends SoException {
79
- constructor(public message = "Duplicate Row", public payload?: unknown) {
80
- super(642, message, payload);
91
+ constructor(
92
+ public message = "Duplicate Row",
93
+ public payload?: unknown
94
+ ) {
95
+ super(542, message, payload);
81
96
  }
82
97
  }
83
98
 
@@ -85,7 +100,10 @@ export class DuplicateRowException extends SoException {
85
100
  뭔가를 하려고 했으나 대상이 없음
86
101
  */
87
102
  export class TargetNotFoundException extends SoException {
88
- constructor(public message = "Target Not Found", public payload?: unknown) {
89
- super(620, message, payload);
103
+ constructor(
104
+ public message = "Target Not Found",
105
+ public payload?: unknown
106
+ ) {
107
+ super(520, message, payload);
90
108
  }
91
109
  }
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./database/db";
7
7
  export * from "./database/upsert-builder";
8
8
  export * from "./exceptions/error-handler";
9
9
  export * from "./exceptions/so-exceptions";
10
+ export * from "./entity/entity";
10
11
  export * from "./entity/entity-manager";
11
12
  export * from "./entity/entity-utils";
12
13
  export * from "./entity/migrator";
@@ -1023,38 +1023,32 @@ export class Syncer {
1023
1023
  (name) => name !== names.constant
1024
1024
  );
1025
1025
 
1026
- return keys.reduce(
1027
- (result, key) => {
1028
- const tpl = this.getTemplate(key);
1029
- if (key.startsWith("view_enums")) {
1030
- enumsKeys.map((componentId) => {
1031
- const { target, path: p } = tpl.getTargetAndPath(
1032
- names,
1033
- componentId
1034
- );
1035
- result[`${key}__${componentId}`] = fs.existsSync(
1036
- path.join(Sonamu.appRootPath, target, p)
1037
- );
1038
- });
1039
- return result;
1040
- }
1026
+ return keys.reduce((result, key) => {
1027
+ const tpl = this.getTemplate(key);
1028
+ if (key.startsWith("view_enums")) {
1029
+ enumsKeys.map((componentId) => {
1030
+ const { target, path: p } = tpl.getTargetAndPath(names, componentId);
1031
+ result[`${key}__${componentId}`] = fs.existsSync(
1032
+ path.join(Sonamu.appRootPath, target, p)
1033
+ );
1034
+ });
1035
+ return result;
1036
+ }
1041
1037
 
1042
- const { target, path: p } = tpl.getTargetAndPath(names);
1043
- const { targets } = Sonamu.config.sync;
1044
- if (target.includes(":target")) {
1045
- targets.map((t) => {
1046
- result[`${key}__${t}`] = fs.existsSync(
1047
- path.join(Sonamu.appRootPath, target.replace(":target", t), p)
1048
- );
1049
- });
1050
- } else {
1051
- result[key] = fs.existsSync(path.join(Sonamu.appRootPath, target, p));
1052
- }
1038
+ const { target, path: p } = tpl.getTargetAndPath(names);
1039
+ const { targets } = Sonamu.config.sync;
1040
+ if (target.includes(":target")) {
1041
+ targets.map((t) => {
1042
+ result[`${key}__${t}`] = fs.existsSync(
1043
+ path.join(Sonamu.appRootPath, target.replace(":target", t), p)
1044
+ );
1045
+ });
1046
+ } else {
1047
+ result[key] = fs.existsSync(path.join(Sonamu.appRootPath, target, p));
1048
+ }
1053
1049
 
1054
- return result;
1055
- },
1056
- {} as Record<`${TemplateKey}${string}`, boolean>
1057
- );
1050
+ return result;
1051
+ }, {} as Record<`${TemplateKey}${string}`, boolean>);
1058
1052
  }
1059
1053
 
1060
1054
  async getZodTypeById(zodTypeId: string): Promise<z.ZodTypeAny> {
@@ -1099,8 +1093,9 @@ export class Syncer {
1099
1093
  const obj = await propNode.children.reduce(
1100
1094
  async (promise, childPropNode) => {
1101
1095
  const result = await promise;
1102
- result[childPropNode.prop!.name] =
1103
- await this.propNodeToZodType(childPropNode);
1096
+ result[childPropNode.prop!.name] = await this.propNodeToZodType(
1097
+ childPropNode
1098
+ );
1104
1099
  return result;
1105
1100
  },
1106
1101
  {} as any
@@ -1329,21 +1324,13 @@ export class Syncer {
1329
1324
  }
1330
1325
 
1331
1326
  async createEntity(
1332
- entityId: string,
1333
- parentId?: string,
1334
- table?: string,
1335
- title?: string
1327
+ form: Omit<TemplateOptions["entity"], "title"> & { title?: string }
1336
1328
  ) {
1337
- if (!/^[A-Z][a-zA-Z0-9]*$/.test(entityId)) {
1329
+ if (!/^[A-Z][a-zA-Z0-9]*$/.test(form.entityId)) {
1338
1330
  throw new BadRequestException("entityId는 CamelCase 형식이어야 합니다.");
1339
1331
  }
1340
1332
 
1341
- await this.generateTemplate("entity", {
1342
- entityId,
1343
- parentId,
1344
- table,
1345
- title,
1346
- });
1333
+ await this.generateTemplate("entity", form);
1347
1334
 
1348
1335
  // reload entities
1349
1336
  await EntityManager.reload();
@@ -1352,9 +1339,9 @@ export class Syncer {
1352
1339
  await this.actionGenerateSchemas();
1353
1340
 
1354
1341
  // generate types
1355
- if (parentId === undefined) {
1342
+ if (form.parentId === undefined) {
1356
1343
  await this.generateTemplate("init_types", {
1357
- entityId,
1344
+ entityId: form.entityId,
1358
1345
  });
1359
1346
  }
1360
1347
  }
@@ -39,37 +39,39 @@ export class Template__entity extends Template {
39
39
  title: title ?? entityId,
40
40
  parentId,
41
41
  table: table ?? names.fsPlural.replace(/\-/g, "_"),
42
- props: [
43
- { name: "id", type: "integer", unsigned: true, desc: "ID" },
44
- ...(parent
45
- ? [
46
- {
47
- type: "relation",
48
- name: parent.names.camel,
49
- relationType: "BelongsToOne",
50
- with: parentId,
51
- onUpdate: "CASCADE",
52
- onDelete: "CASCADE",
53
- desc: parent.entity.title,
54
- },
55
- ]
56
- : []),
57
- {
58
- name: "created_at",
59
- type: "timestamp",
60
- desc: "등록일시",
61
- dbDefault: "CURRENT_TIMESTAMP",
62
- },
63
- ],
64
- indexes: [],
65
- subsets: {
42
+ props: options.props?.length
43
+ ? options.props
44
+ : [
45
+ { name: "id", type: "integer", unsigned: true, desc: "ID" },
46
+ ...(parent
47
+ ? [
48
+ {
49
+ type: "relation",
50
+ name: parent.names.camel,
51
+ relationType: "BelongsToOne",
52
+ with: parentId,
53
+ onUpdate: "CASCADE",
54
+ onDelete: "CASCADE",
55
+ desc: parent.entity.title,
56
+ },
57
+ ]
58
+ : []),
59
+ {
60
+ name: "created_at",
61
+ type: "timestamp",
62
+ desc: "등록일시",
63
+ dbDefault: "CURRENT_TIMESTAMP",
64
+ },
65
+ ],
66
+ indexes: [...(options.indexes ?? [])],
67
+ subsets: options.subsets ?? {
66
68
  ...(parentId
67
69
  ? {}
68
70
  : {
69
71
  A: ["id", "created_at"],
70
72
  }),
71
73
  },
72
- enums: {
74
+ enums: options.enums ?? {
73
75
  ...(parentId
74
76
  ? {}
75
77
  : {
@@ -617,6 +617,10 @@ export const TemplateOptions = z.object({
617
617
  parentId: z.string().optional(),
618
618
  title: z.string(),
619
619
  table: z.string().optional(),
620
+ props: z.array(z.object({})).optional(),
621
+ indexes: z.array(z.object({})).optional(),
622
+ subsets: z.object({}).optional(),
623
+ enums: z.object({}).optional(),
620
624
  }),
621
625
  init_types: z.object({
622
626
  entityId: z.string(),
package/tsup.config.js CHANGED
@@ -4,7 +4,10 @@ import { defineConfig } from "tsup";
4
4
  export default defineConfig({
5
5
  entry: ["src/index.ts", "src/bin/cli.ts", "src/bin/cli-wrapper.ts"],
6
6
  dts: true,
7
- format: ["esm", "cjs"],
7
+ format: [
8
+ // "esm",
9
+ "cjs",
10
+ ],
8
11
  target: "es2020",
9
12
  clean: true,
10
13
  sourcemap: true,
@@ -1 +0,0 @@
1
- #!/usr/bin/env ts-node
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env ts-node
2
- const require = (await import('module')).createRequire(import.meta.url);
3
- import {
4
- __dirname
5
- } from "../chunk-JXJTFHF7.mjs";
6
-
7
- // src/bin/cli-wrapper.ts
8
- import { spawnSync } from "child_process";
9
- import { resolve } from "path";
10
- import { existsSync, readFileSync } from "fs";
11
- var cjsPath = resolve(__dirname, "bin/cli.js");
12
- var esmPath = resolve(__dirname, "bin/cli.mjs");
13
- var isESM = () => {
14
- const packageJsonPath = resolve(process.cwd(), "package.json");
15
- if (existsSync(packageJsonPath)) {
16
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
17
- return packageJson.type === "module";
18
- }
19
- return false;
20
- };
21
- var scriptPath = isESM() ? esmPath : cjsPath;
22
- if (!existsSync(scriptPath)) {
23
- console.error(`Error: Script not found at ${scriptPath}`);
24
- process.exit(1);
25
- }
26
- var result = spawnSync(
27
- process.execPath,
28
- [scriptPath, ...process.argv.slice(2)],
29
- {
30
- stdio: "inherit"
31
- }
32
- );
33
- process.exit(result.status ?? 1);
34
- //# sourceMappingURL=cli-wrapper.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/bin/cli-wrapper.ts"],"sourcesContent":["#!/usr/bin/env ts-node\n\nimport { spawnSync } from \"child_process\";\nimport { resolve } from \"path\";\nimport { existsSync, readFileSync } from \"fs\";\n\nconst cjsPath = resolve(__dirname, \"bin/cli.js\");\nconst esmPath = resolve(__dirname, \"bin/cli.mjs\");\n\nconst isESM = () => {\n const packageJsonPath = resolve(process.cwd(), \"package.json\");\n if (existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\"));\n return packageJson.type === \"module\";\n }\n return false;\n};\n\nconst scriptPath = isESM() ? esmPath : cjsPath;\n\nif (!existsSync(scriptPath)) {\n console.error(`Error: Script not found at ${scriptPath}`);\n process.exit(1);\n}\n\nconst result = spawnSync(\n process.execPath,\n [scriptPath, ...process.argv.slice(2)],\n {\n stdio: \"inherit\",\n }\n);\n\nprocess.exit(result.status ?? 1);\n"],"mappings":";;;;;;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,YAAY,oBAAoB;AAEzC,IAAM,UAAU,QAAQ,WAAW,YAAY;AAC/C,IAAM,UAAU,QAAQ,WAAW,aAAa;AAEhD,IAAM,QAAQ,MAAM;AAClB,QAAM,kBAAkB,QAAQ,QAAQ,IAAI,GAAG,cAAc;AAC7D,MAAI,WAAW,eAAe,GAAG;AAC/B,UAAM,cAAc,KAAK,MAAM,aAAa,iBAAiB,OAAO,CAAC;AACrE,WAAO,YAAY,SAAS;AAAA,EAC9B;AACA,SAAO;AACT;AAEA,IAAM,aAAa,MAAM,IAAI,UAAU;AAEvC,IAAI,CAAC,WAAW,UAAU,GAAG;AAC3B,UAAQ,MAAM,8BAA8B,UAAU,EAAE;AACxD,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,SAAS;AAAA,EACb,QAAQ;AAAA,EACR,CAAC,YAAY,GAAG,QAAQ,KAAK,MAAM,CAAC,CAAC;AAAA,EACrC;AAAA,IACE,OAAO;AAAA,EACT;AACF;AAEA,QAAQ,KAAK,OAAO,UAAU,CAAC;","names":[]}
@@ -1,2 +0,0 @@
1
-
2
- export { }