sonamu 0.4.10 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{base-model-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-634GIW42.mjs} +2 -2
- package/dist/{chunk-M6MCZP64.mjs → chunk-A2BDNO7E.mjs} +2 -2
- package/dist/{chunk-IPTFUZN2.js → chunk-GUKIIOZI.js} +100 -100
- package/dist/{chunk-EEUCHV4P.mjs → chunk-GUV6I64Y.mjs} +69 -40
- package/dist/chunk-GUV6I64Y.mjs.map +1 -0
- package/dist/{chunk-E2I4OSFY.js → chunk-KX4762I3.js} +69 -40
- package/dist/chunk-KX4762I3.js.map +1 -0
- package/dist/{chunk-IPFCELQ3.mjs → chunk-PGPMEMK6.mjs} +2 -2
- package/dist/{chunk-I7O4VXTH.js → chunk-QIHV5UYF.js} +4 -4
- package/dist/{chunk-QT3GBIMP.js → chunk-Z53BUBO4.js} +7 -7
- package/dist/database/drivers/knex/base-model.d.mts +2 -2
- package/dist/database/drivers/knex/base-model.d.ts +2 -2
- package/dist/database/drivers/knex/base-model.js +8 -8
- package/dist/database/drivers/knex/base-model.mjs +3 -3
- package/dist/database/drivers/kysely/base-model.d.mts +2 -2
- package/dist/database/drivers/kysely/base-model.d.ts +2 -2
- package/dist/database/drivers/kysely/base-model.js +9 -9
- package/dist/database/drivers/kysely/base-model.mjs +3 -3
- package/dist/index.d.mts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +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 +76 -39
- 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-634GIW42.mjs.map} +0 -0
- /package/dist/{chunk-M6MCZP64.mjs.map → chunk-A2BDNO7E.mjs.map} +0 -0
- /package/dist/{chunk-IPTFUZN2.js.map → chunk-GUKIIOZI.js.map} +0 -0
- /package/dist/{chunk-IPFCELQ3.mjs.map → chunk-PGPMEMK6.mjs.map} +0 -0
- /package/dist/{chunk-I7O4VXTH.js.map → chunk-QIHV5UYF.js.map} +0 -0
- /package/dist/{chunk-QT3GBIMP.js.map → chunk-Z53BUBO4.js.map} +0 -0
|
@@ -189,7 +189,17 @@ var TemplateOptions = _zod.z.object({
|
|
|
189
189
|
entityId: _zod.z.string()
|
|
190
190
|
}),
|
|
191
191
|
service: _zod.z.object({
|
|
192
|
-
|
|
192
|
+
namesRecord: _zod.z.object({
|
|
193
|
+
fs: _zod.z.string(),
|
|
194
|
+
fsPlural: _zod.z.string(),
|
|
195
|
+
camel: _zod.z.string(),
|
|
196
|
+
camelPlural: _zod.z.string(),
|
|
197
|
+
capital: _zod.z.string(),
|
|
198
|
+
capitalPlural: _zod.z.string(),
|
|
199
|
+
upper: _zod.z.string(),
|
|
200
|
+
constant: _zod.z.string()
|
|
201
|
+
}),
|
|
202
|
+
modelTsPath: _zod.z.string()
|
|
193
203
|
}),
|
|
194
204
|
view_list: _zod.z.object({
|
|
195
205
|
entityId: _zod.z.string(),
|
|
@@ -767,7 +777,7 @@ function api(options = {}) {
|
|
|
767
777
|
const modelName = target.constructor.name.match(/(.+)Class$/)[1];
|
|
768
778
|
const methodName = propertyKey;
|
|
769
779
|
const defaultPath = `/${_inflection2.default.camelize(
|
|
770
|
-
modelName.replace(/Model$/, ""),
|
|
780
|
+
modelName.replace(/Model$/, "").replace(/Frame$/, ""),
|
|
771
781
|
true
|
|
772
782
|
)}/${_inflection2.default.camelize(propertyKey, true)}`;
|
|
773
783
|
const api2 = {
|
|
@@ -4007,14 +4017,13 @@ var Template__service = class extends Template {
|
|
|
4007
4017
|
path: `${names.fs}/${names.fs}.service.ts`
|
|
4008
4018
|
};
|
|
4009
4019
|
}
|
|
4010
|
-
render({
|
|
4011
|
-
const names = EntityManager.getNamesFromId(entityId);
|
|
4020
|
+
render({ namesRecord }, apis) {
|
|
4012
4021
|
const { lines, importKeys } = this.getTypeSource(apis);
|
|
4013
4022
|
const hasAxiosProgressEvent = apis.find(
|
|
4014
4023
|
(api2) => (_nullishCoalesce(api2.options.clients, () => ( []))).includes("axios-multipart")
|
|
4015
4024
|
);
|
|
4016
4025
|
return {
|
|
4017
|
-
...this.getTargetAndPath(
|
|
4026
|
+
...this.getTargetAndPath(namesRecord),
|
|
4018
4027
|
body: lines.join("\n"),
|
|
4019
4028
|
importKeys: importKeys.filter(
|
|
4020
4029
|
(key) => ["ListResult"].includes(key) === false
|
|
@@ -4101,7 +4110,7 @@ var Template__service = class extends Template {
|
|
|
4101
4110
|
}
|
|
4102
4111
|
}).join("\n");
|
|
4103
4112
|
}).join("\n\n");
|
|
4104
|
-
return `export namespace ${modelName.replace(/Model$/, "Service")} {
|
|
4113
|
+
return `export namespace ${modelName.replace(/Model$/, "Service").replace(/Frame$/, "Service")} {
|
|
4105
4114
|
${methodCodes}
|
|
4106
4115
|
}`;
|
|
4107
4116
|
}).join("\n\n");
|
|
@@ -5350,7 +5359,7 @@ var Syncer = (_class4 = class {
|
|
|
5350
5359
|
console.log("Changed Files: ", diffFiles);
|
|
5351
5360
|
const diffGroups = _lodash2.default.groupBy(diffFiles, (r) => {
|
|
5352
5361
|
const matched = r.match(
|
|
5353
|
-
/\.(model|types|functions|entity|generated)\.[tj]s/
|
|
5362
|
+
/\.(model|types|functions|entity|generated|frame)\.[tj]s/
|
|
5354
5363
|
);
|
|
5355
5364
|
return matched[1];
|
|
5356
5365
|
});
|
|
@@ -5384,12 +5393,38 @@ var Syncer = (_class4 = class {
|
|
|
5384
5393
|
);
|
|
5385
5394
|
await this.actionSyncFilesToTargets(tsPaths);
|
|
5386
5395
|
}
|
|
5387
|
-
if (diffTypes.includes("model")) {
|
|
5388
|
-
const entityIds = this.getEntityIdFromPath(diffGroups["model"]);
|
|
5396
|
+
if (diffTypes.includes("model") || diffTypes.includes("frame")) {
|
|
5389
5397
|
console.log("// \uC561\uC158: \uC11C\uBE44\uC2A4 \uC0DD\uC131");
|
|
5390
|
-
|
|
5398
|
+
const mergedGroup = [
|
|
5399
|
+
..._nullishCoalesce(diffGroups["model"], () => ( [])),
|
|
5400
|
+
..._nullishCoalesce(diffGroups["frame"], () => ( []))
|
|
5401
|
+
];
|
|
5402
|
+
const params = mergedGroup.map((modelPath) => {
|
|
5403
|
+
if (modelPath.endsWith(".model.js")) {
|
|
5404
|
+
const entityId = this.getEntityIdFromPath([modelPath])[0];
|
|
5405
|
+
return {
|
|
5406
|
+
namesRecord: EntityManager.getNamesFromId(entityId),
|
|
5407
|
+
modelTsPath: _path2.default.join(
|
|
5408
|
+
Sonamu.apiRootPath,
|
|
5409
|
+
modelPath.replace("/dist/", "/src/").replace(".model.js", ".model.ts")
|
|
5410
|
+
)
|
|
5411
|
+
};
|
|
5412
|
+
}
|
|
5413
|
+
if (modelPath.endsWith("frame.js")) {
|
|
5414
|
+
const [, frameName] = _nullishCoalesce(modelPath.match(/.+\/(.+)\.frame.js$/), () => ( []));
|
|
5415
|
+
return {
|
|
5416
|
+
namesRecord: EntityManager.getNamesFromId(frameName),
|
|
5417
|
+
modelTsPath: _path2.default.join(
|
|
5418
|
+
Sonamu.apiRootPath,
|
|
5419
|
+
modelPath.replace("/dist/", "/src/").replace(".frame.js", ".frame.ts")
|
|
5420
|
+
)
|
|
5421
|
+
};
|
|
5422
|
+
}
|
|
5423
|
+
throw new Error("not reachable");
|
|
5424
|
+
});
|
|
5425
|
+
await this.actionGenerateServices(params);
|
|
5391
5426
|
console.log("// \uC561\uC158: HTTP\uD30C\uC77C \uC0DD\uC131");
|
|
5392
|
-
await this.actionGenerateHttps(
|
|
5427
|
+
await this.actionGenerateHttps();
|
|
5393
5428
|
}
|
|
5394
5429
|
await this.saveChecksums(currentChecksums);
|
|
5395
5430
|
this.isSyncing = false;
|
|
@@ -5410,25 +5445,19 @@ var Syncer = (_class4 = class {
|
|
|
5410
5445
|
this.generateTemplate("generated", {}, { overwrite: true })
|
|
5411
5446
|
])).flat().flat();
|
|
5412
5447
|
}
|
|
5413
|
-
async actionGenerateServices(
|
|
5448
|
+
async actionGenerateServices(paramsArray) {
|
|
5414
5449
|
return (await Promise.all(
|
|
5415
|
-
|
|
5416
|
-
async (
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
entityId
|
|
5420
|
-
},
|
|
5421
|
-
{
|
|
5422
|
-
overwrite: true
|
|
5423
|
-
}
|
|
5424
|
-
)
|
|
5450
|
+
paramsArray.map(
|
|
5451
|
+
async (params) => this.generateTemplate("service", params, {
|
|
5452
|
+
overwrite: true
|
|
5453
|
+
})
|
|
5425
5454
|
)
|
|
5426
5455
|
)).flat().flat();
|
|
5427
5456
|
}
|
|
5428
|
-
async actionGenerateHttps(
|
|
5457
|
+
async actionGenerateHttps() {
|
|
5429
5458
|
const [res] = await this.generateTemplate(
|
|
5430
5459
|
"generated_http",
|
|
5431
|
-
{
|
|
5460
|
+
{},
|
|
5432
5461
|
{ overwrite: true }
|
|
5433
5462
|
);
|
|
5434
5463
|
return res;
|
|
@@ -5484,7 +5513,8 @@ var Syncer = (_class4 = class {
|
|
|
5484
5513
|
generated: Sonamu.apiRootPath + "/src/application/sonamu.generated.ts",
|
|
5485
5514
|
functions: Sonamu.apiRootPath + "/src/application/**/*.functions.ts",
|
|
5486
5515
|
/* compiled-JS 체크 */
|
|
5487
|
-
model: Sonamu.apiRootPath + "/dist/application/**/*.model.js"
|
|
5516
|
+
model: Sonamu.apiRootPath + "/dist/application/**/*.model.js",
|
|
5517
|
+
frame: Sonamu.apiRootPath + "/dist/application/**/*.frame.js"
|
|
5488
5518
|
};
|
|
5489
5519
|
const filePaths = (await Promise.all(
|
|
5490
5520
|
Object.entries(PatternGroup).map(async ([_fileType, pattern]) => {
|
|
@@ -5595,6 +5625,9 @@ var Syncer = (_class4 = class {
|
|
|
5595
5625
|
(method) => method.modelName === api2.modelName && method.methodName === api2.methodName
|
|
5596
5626
|
);
|
|
5597
5627
|
});
|
|
5628
|
+
if (currentModelApis.length === 0) {
|
|
5629
|
+
throw new Error(`\uD604\uC7AC \uD30C\uC77C\uC5D0 \uC0AC\uC804 \uB4F1\uB85D\uB41C API\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. ${filePath}`);
|
|
5630
|
+
}
|
|
5598
5631
|
const extendedApis = currentModelApis.map((api2) => {
|
|
5599
5632
|
const foundMethod = methods.find(
|
|
5600
5633
|
(method) => method.modelName === api2.modelName && method.methodName === api2.methodName
|
|
@@ -5756,7 +5789,7 @@ var Syncer = (_class4 = class {
|
|
|
5756
5789
|
async autoloadApis() {
|
|
5757
5790
|
const pathPattern = _path2.default.join(
|
|
5758
5791
|
Sonamu.apiRootPath,
|
|
5759
|
-
"/src/application/**/*.model.ts"
|
|
5792
|
+
"/src/application/**/*.{model,frame}.ts"
|
|
5760
5793
|
);
|
|
5761
5794
|
const filePaths = await globAsync(pathPattern);
|
|
5762
5795
|
const result = await Promise.all(
|
|
@@ -5768,7 +5801,7 @@ var Syncer = (_class4 = class {
|
|
|
5768
5801
|
async autoloadModels() {
|
|
5769
5802
|
const pathPattern = _path2.default.join(
|
|
5770
5803
|
Sonamu.apiRootPath,
|
|
5771
|
-
"dist/application/**/*.model.js"
|
|
5804
|
+
"dist/application/**/*.{model,frame}.js"
|
|
5772
5805
|
);
|
|
5773
5806
|
const filePaths = (await globAsync(pathPattern)).filter((path9) => {
|
|
5774
5807
|
const srcPath = path9.replace("/dist/", "/src/").replace(".js", ".ts");
|
|
@@ -5777,7 +5810,9 @@ var Syncer = (_class4 = class {
|
|
|
5777
5810
|
const modules = await importMultiple(filePaths);
|
|
5778
5811
|
const functions = modules.map(({ imported }) => Object.entries(imported)).flat();
|
|
5779
5812
|
this.models = Object.fromEntries(
|
|
5780
|
-
functions.filter(
|
|
5813
|
+
functions.filter(
|
|
5814
|
+
([name]) => name.endsWith("Model") || name.endsWith("Frame")
|
|
5815
|
+
)
|
|
5781
5816
|
);
|
|
5782
5817
|
return this.models;
|
|
5783
5818
|
}
|
|
@@ -5844,18 +5879,12 @@ var Syncer = (_class4 = class {
|
|
|
5844
5879
|
async renderTemplate(key, options) {
|
|
5845
5880
|
const template = this.getTemplate(key);
|
|
5846
5881
|
let extra = [];
|
|
5847
|
-
if (
|
|
5848
|
-
|
|
5849
|
-
|
|
5882
|
+
if (key === "service") {
|
|
5883
|
+
const { modelTsPath } = options;
|
|
5884
|
+
extra = [await this.readApisFromFile(modelTsPath)];
|
|
5885
|
+
} else if (["model", "view_list", "view_form"].includes(key)) {
|
|
5850
5886
|
const entityId = options.entityId;
|
|
5851
|
-
if (key === "
|
|
5852
|
-
const entity = EntityManager.get(entityId);
|
|
5853
|
-
const modelTsPath = `${_path2.default.join(
|
|
5854
|
-
Sonamu.apiRootPath,
|
|
5855
|
-
"/src/application"
|
|
5856
|
-
)}/${entity.names.fs}/${entity.names.fs}.model.ts`;
|
|
5857
|
-
extra = [await this.readApisFromFile(modelTsPath)];
|
|
5858
|
-
} else if (key === "view_list" || key === "model") {
|
|
5887
|
+
if (key === "view_list" || key === "model") {
|
|
5859
5888
|
const columnsNode = await this.getColumnsNode(entityId, "A");
|
|
5860
5889
|
const listParamsZodType = await this.getZodTypeById(
|
|
5861
5890
|
`${entityId}ListParams`
|
|
@@ -7542,4 +7571,4 @@ var Entity = (_class7 = class {
|
|
|
7542
7571
|
|
|
7543
7572
|
|
|
7544
7573
|
exports.SQLDateTimeString = SQLDateTimeString; exports.zArrayable = zArrayable; exports.isIntegerProp = isIntegerProp; exports.isBigIntegerProp = isBigIntegerProp; exports.isTextProp = isTextProp; exports.isStringProp = isStringProp; exports.isEnumProp = isEnumProp; exports.isFloatProp = isFloatProp; exports.isDoubleProp = isDoubleProp; exports.isDecimalProp = isDecimalProp; exports.isBooleanProp = isBooleanProp; exports.isDateProp = isDateProp; exports.isDateTimeProp = isDateTimeProp; exports.isTimeProp = isTimeProp; exports.isTimestampProp = isTimestampProp; exports.isJsonProp = isJsonProp; exports.isUuidProp = isUuidProp; exports.isVirtualProp = isVirtualProp; exports.isRelationProp = isRelationProp; exports.isOneToOneRelationProp = isOneToOneRelationProp; exports.isBelongsToOneRelationProp = isBelongsToOneRelationProp; exports.isHasManyRelationProp = isHasManyRelationProp; exports.isManyToManyRelationProp = isManyToManyRelationProp; exports.isCustomJoinClause = isCustomJoinClause; exports.SonamuQueryMode = SonamuQueryMode; exports.isKnexError = isKnexError; exports.isKyselyError = isKyselyError; exports.ApiParamType = ApiParamType; exports.RenderingNode = RenderingNode; exports.TemplateOptions = TemplateOptions; exports.TemplateKey = TemplateKey; exports.GenerateOptions = GenerateOptions; exports.PathAndCode = PathAndCode; exports.getZodObjectFromApi = getZodObjectFromApi; exports.getZodObjectFromApiParams = getZodObjectFromApiParams; exports.getZodTypeFromApiParamType = getZodTypeFromApiParamType; exports.propNodeToZodTypeDef = propNodeToZodTypeDef; exports.getTextTypeLength = getTextTypeLength; exports.propToZodTypeDef = propToZodTypeDef; exports.zodTypeToZodCode = zodTypeToZodCode; exports.apiParamToTsCode = apiParamToTsCode; exports.apiParamTypeToTsType = apiParamTypeToTsType; exports.unwrapPromiseOnce = unwrapPromiseOnce; exports.serializeZodType = serializeZodType; exports.zodTypeToTsTypeDef = zodTypeToTsTypeDef; exports.registeredApis = registeredApis; exports.api = api; exports.SoException = SoException; exports.isSoException = isSoException; exports.BadRequestException = BadRequestException; exports.UnauthorizedException = UnauthorizedException; exports.NotFoundException = NotFoundException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.InternalServerErrorException = InternalServerErrorException; exports.AlreadyProcessedException = AlreadyProcessedException; exports.DuplicateRowException = DuplicateRowException; exports.TargetNotFoundException = TargetNotFoundException; exports.globAsync = globAsync; exports.importMultiple = importMultiple; exports.findAppRootPath = findAppRootPath; exports.findApiRootPath = findApiRootPath; exports.nonNullable = nonNullable; exports.hydrate = hydrate; exports.Entity = Entity; exports.EntityManager = EntityManager; exports.asArray = asArray; exports.objToMap = objToMap; exports.KnexClient = KnexClient; exports.KyselyClient = KyselyClient; exports.DBKnexClass = DBKnexClass; exports.DBKyselyClass = DBKyselyClass; exports.DB = DB; exports.Syncer = Syncer; exports.isLocal = isLocal; exports.isRemote = isRemote; exports.isInDocker = isInDocker; exports.isDaemonServer = isDaemonServer; exports.isDevelopment = isDevelopment; exports.isStaging = isStaging; exports.isProduction = isProduction; exports.isTest = isTest; exports.Sonamu = Sonamu;
|
|
7545
|
-
//# sourceMappingURL=chunk-
|
|
7574
|
+
//# sourceMappingURL=chunk-KX4762I3.js.map
|