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
|
@@ -187,7 +187,17 @@ var TemplateOptions = z.object({
|
|
|
187
187
|
entityId: z.string()
|
|
188
188
|
}),
|
|
189
189
|
service: z.object({
|
|
190
|
-
|
|
190
|
+
namesRecord: z.object({
|
|
191
|
+
fs: z.string(),
|
|
192
|
+
fsPlural: z.string(),
|
|
193
|
+
camel: z.string(),
|
|
194
|
+
camelPlural: z.string(),
|
|
195
|
+
capital: z.string(),
|
|
196
|
+
capitalPlural: z.string(),
|
|
197
|
+
upper: z.string(),
|
|
198
|
+
constant: z.string()
|
|
199
|
+
}),
|
|
200
|
+
modelTsPath: z.string()
|
|
191
201
|
}),
|
|
192
202
|
view_list: z.object({
|
|
193
203
|
entityId: z.string(),
|
|
@@ -765,7 +775,7 @@ function api(options = {}) {
|
|
|
765
775
|
const modelName = target.constructor.name.match(/(.+)Class$/)[1];
|
|
766
776
|
const methodName = propertyKey;
|
|
767
777
|
const defaultPath = `/${inflection.camelize(
|
|
768
|
-
modelName.replace(/Model$/, ""),
|
|
778
|
+
modelName.replace(/Model$/, "").replace(/Frame$/, ""),
|
|
769
779
|
true
|
|
770
780
|
)}/${inflection.camelize(propertyKey, true)}`;
|
|
771
781
|
const api2 = {
|
|
@@ -4005,14 +4015,13 @@ var Template__service = class extends Template {
|
|
|
4005
4015
|
path: `${names.fs}/${names.fs}.service.ts`
|
|
4006
4016
|
};
|
|
4007
4017
|
}
|
|
4008
|
-
render({
|
|
4009
|
-
const names = EntityManager.getNamesFromId(entityId);
|
|
4018
|
+
render({ namesRecord }, apis) {
|
|
4010
4019
|
const { lines, importKeys } = this.getTypeSource(apis);
|
|
4011
4020
|
const hasAxiosProgressEvent = apis.find(
|
|
4012
4021
|
(api2) => (api2.options.clients ?? []).includes("axios-multipart")
|
|
4013
4022
|
);
|
|
4014
4023
|
return {
|
|
4015
|
-
...this.getTargetAndPath(
|
|
4024
|
+
...this.getTargetAndPath(namesRecord),
|
|
4016
4025
|
body: lines.join("\n"),
|
|
4017
4026
|
importKeys: importKeys.filter(
|
|
4018
4027
|
(key) => ["ListResult"].includes(key) === false
|
|
@@ -4099,7 +4108,7 @@ var Template__service = class extends Template {
|
|
|
4099
4108
|
}
|
|
4100
4109
|
}).join("\n");
|
|
4101
4110
|
}).join("\n\n");
|
|
4102
|
-
return `export namespace ${modelName.replace(/Model$/, "Service")} {
|
|
4111
|
+
return `export namespace ${modelName.replace(/Model$/, "Service").replace(/Frame$/, "Service")} {
|
|
4103
4112
|
${methodCodes}
|
|
4104
4113
|
}`;
|
|
4105
4114
|
}).join("\n\n");
|
|
@@ -5348,7 +5357,7 @@ var Syncer = class {
|
|
|
5348
5357
|
console.log("Changed Files: ", diffFiles);
|
|
5349
5358
|
const diffGroups = _13.groupBy(diffFiles, (r) => {
|
|
5350
5359
|
const matched = r.match(
|
|
5351
|
-
/\.(model|types|functions|entity|generated)\.[tj]s/
|
|
5360
|
+
/\.(model|types|functions|entity|generated|frame)\.[tj]s/
|
|
5352
5361
|
);
|
|
5353
5362
|
return matched[1];
|
|
5354
5363
|
});
|
|
@@ -5382,12 +5391,38 @@ var Syncer = class {
|
|
|
5382
5391
|
);
|
|
5383
5392
|
await this.actionSyncFilesToTargets(tsPaths);
|
|
5384
5393
|
}
|
|
5385
|
-
if (diffTypes.includes("model")) {
|
|
5386
|
-
const entityIds = this.getEntityIdFromPath(diffGroups["model"]);
|
|
5394
|
+
if (diffTypes.includes("model") || diffTypes.includes("frame")) {
|
|
5387
5395
|
console.log("// \uC561\uC158: \uC11C\uBE44\uC2A4 \uC0DD\uC131");
|
|
5388
|
-
|
|
5396
|
+
const mergedGroup = [
|
|
5397
|
+
...diffGroups["model"] ?? [],
|
|
5398
|
+
...diffGroups["frame"] ?? []
|
|
5399
|
+
];
|
|
5400
|
+
const params = mergedGroup.map((modelPath) => {
|
|
5401
|
+
if (modelPath.endsWith(".model.js")) {
|
|
5402
|
+
const entityId = this.getEntityIdFromPath([modelPath])[0];
|
|
5403
|
+
return {
|
|
5404
|
+
namesRecord: EntityManager.getNamesFromId(entityId),
|
|
5405
|
+
modelTsPath: path5.join(
|
|
5406
|
+
Sonamu.apiRootPath,
|
|
5407
|
+
modelPath.replace("/dist/", "/src/").replace(".model.js", ".model.ts")
|
|
5408
|
+
)
|
|
5409
|
+
};
|
|
5410
|
+
}
|
|
5411
|
+
if (modelPath.endsWith("frame.js")) {
|
|
5412
|
+
const [, frameName] = modelPath.match(/.+\/(.+)\.frame.js$/) ?? [];
|
|
5413
|
+
return {
|
|
5414
|
+
namesRecord: EntityManager.getNamesFromId(frameName),
|
|
5415
|
+
modelTsPath: path5.join(
|
|
5416
|
+
Sonamu.apiRootPath,
|
|
5417
|
+
modelPath.replace("/dist/", "/src/").replace(".frame.js", ".frame.ts")
|
|
5418
|
+
)
|
|
5419
|
+
};
|
|
5420
|
+
}
|
|
5421
|
+
throw new Error("not reachable");
|
|
5422
|
+
});
|
|
5423
|
+
await this.actionGenerateServices(params);
|
|
5389
5424
|
console.log("// \uC561\uC158: HTTP\uD30C\uC77C \uC0DD\uC131");
|
|
5390
|
-
await this.actionGenerateHttps(
|
|
5425
|
+
await this.actionGenerateHttps();
|
|
5391
5426
|
}
|
|
5392
5427
|
await this.saveChecksums(currentChecksums);
|
|
5393
5428
|
this.isSyncing = false;
|
|
@@ -5408,25 +5443,19 @@ var Syncer = class {
|
|
|
5408
5443
|
this.generateTemplate("generated", {}, { overwrite: true })
|
|
5409
5444
|
])).flat().flat();
|
|
5410
5445
|
}
|
|
5411
|
-
async actionGenerateServices(
|
|
5446
|
+
async actionGenerateServices(paramsArray) {
|
|
5412
5447
|
return (await Promise.all(
|
|
5413
|
-
|
|
5414
|
-
async (
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
entityId
|
|
5418
|
-
},
|
|
5419
|
-
{
|
|
5420
|
-
overwrite: true
|
|
5421
|
-
}
|
|
5422
|
-
)
|
|
5448
|
+
paramsArray.map(
|
|
5449
|
+
async (params) => this.generateTemplate("service", params, {
|
|
5450
|
+
overwrite: true
|
|
5451
|
+
})
|
|
5423
5452
|
)
|
|
5424
5453
|
)).flat().flat();
|
|
5425
5454
|
}
|
|
5426
|
-
async actionGenerateHttps(
|
|
5455
|
+
async actionGenerateHttps() {
|
|
5427
5456
|
const [res] = await this.generateTemplate(
|
|
5428
5457
|
"generated_http",
|
|
5429
|
-
{
|
|
5458
|
+
{},
|
|
5430
5459
|
{ overwrite: true }
|
|
5431
5460
|
);
|
|
5432
5461
|
return res;
|
|
@@ -5482,7 +5511,8 @@ var Syncer = class {
|
|
|
5482
5511
|
generated: Sonamu.apiRootPath + "/src/application/sonamu.generated.ts",
|
|
5483
5512
|
functions: Sonamu.apiRootPath + "/src/application/**/*.functions.ts",
|
|
5484
5513
|
/* compiled-JS 체크 */
|
|
5485
|
-
model: Sonamu.apiRootPath + "/dist/application/**/*.model.js"
|
|
5514
|
+
model: Sonamu.apiRootPath + "/dist/application/**/*.model.js",
|
|
5515
|
+
frame: Sonamu.apiRootPath + "/dist/application/**/*.frame.js"
|
|
5486
5516
|
};
|
|
5487
5517
|
const filePaths = (await Promise.all(
|
|
5488
5518
|
Object.entries(PatternGroup).map(async ([_fileType, pattern]) => {
|
|
@@ -5593,6 +5623,9 @@ var Syncer = class {
|
|
|
5593
5623
|
(method) => method.modelName === api2.modelName && method.methodName === api2.methodName
|
|
5594
5624
|
);
|
|
5595
5625
|
});
|
|
5626
|
+
if (currentModelApis.length === 0) {
|
|
5627
|
+
throw new Error(`\uD604\uC7AC \uD30C\uC77C\uC5D0 \uC0AC\uC804 \uB4F1\uB85D\uB41C API\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. ${filePath}`);
|
|
5628
|
+
}
|
|
5596
5629
|
const extendedApis = currentModelApis.map((api2) => {
|
|
5597
5630
|
const foundMethod = methods.find(
|
|
5598
5631
|
(method) => method.modelName === api2.modelName && method.methodName === api2.methodName
|
|
@@ -5754,7 +5787,7 @@ var Syncer = class {
|
|
|
5754
5787
|
async autoloadApis() {
|
|
5755
5788
|
const pathPattern = path5.join(
|
|
5756
5789
|
Sonamu.apiRootPath,
|
|
5757
|
-
"/src/application/**/*.model.ts"
|
|
5790
|
+
"/src/application/**/*.{model,frame}.ts"
|
|
5758
5791
|
);
|
|
5759
5792
|
const filePaths = await globAsync(pathPattern);
|
|
5760
5793
|
const result = await Promise.all(
|
|
@@ -5766,7 +5799,7 @@ var Syncer = class {
|
|
|
5766
5799
|
async autoloadModels() {
|
|
5767
5800
|
const pathPattern = path5.join(
|
|
5768
5801
|
Sonamu.apiRootPath,
|
|
5769
|
-
"dist/application/**/*.model.js"
|
|
5802
|
+
"dist/application/**/*.{model,frame}.js"
|
|
5770
5803
|
);
|
|
5771
5804
|
const filePaths = (await globAsync(pathPattern)).filter((path9) => {
|
|
5772
5805
|
const srcPath = path9.replace("/dist/", "/src/").replace(".js", ".ts");
|
|
@@ -5775,7 +5808,9 @@ var Syncer = class {
|
|
|
5775
5808
|
const modules = await importMultiple(filePaths);
|
|
5776
5809
|
const functions = modules.map(({ imported }) => Object.entries(imported)).flat();
|
|
5777
5810
|
this.models = Object.fromEntries(
|
|
5778
|
-
functions.filter(
|
|
5811
|
+
functions.filter(
|
|
5812
|
+
([name]) => name.endsWith("Model") || name.endsWith("Frame")
|
|
5813
|
+
)
|
|
5779
5814
|
);
|
|
5780
5815
|
return this.models;
|
|
5781
5816
|
}
|
|
@@ -5842,18 +5877,12 @@ var Syncer = class {
|
|
|
5842
5877
|
async renderTemplate(key, options) {
|
|
5843
5878
|
const template = this.getTemplate(key);
|
|
5844
5879
|
let extra = [];
|
|
5845
|
-
if (
|
|
5846
|
-
|
|
5847
|
-
|
|
5880
|
+
if (key === "service") {
|
|
5881
|
+
const { modelTsPath } = options;
|
|
5882
|
+
extra = [await this.readApisFromFile(modelTsPath)];
|
|
5883
|
+
} else if (["model", "view_list", "view_form"].includes(key)) {
|
|
5848
5884
|
const entityId = options.entityId;
|
|
5849
|
-
if (key === "
|
|
5850
|
-
const entity = EntityManager.get(entityId);
|
|
5851
|
-
const modelTsPath = `${path5.join(
|
|
5852
|
-
Sonamu.apiRootPath,
|
|
5853
|
-
"/src/application"
|
|
5854
|
-
)}/${entity.names.fs}/${entity.names.fs}.model.ts`;
|
|
5855
|
-
extra = [await this.readApisFromFile(modelTsPath)];
|
|
5856
|
-
} else if (key === "view_list" || key === "model") {
|
|
5885
|
+
if (key === "view_list" || key === "model") {
|
|
5857
5886
|
const columnsNode = await this.getColumnsNode(entityId, "A");
|
|
5858
5887
|
const listParamsZodType = await this.getZodTypeById(
|
|
5859
5888
|
`${entityId}ListParams`
|
|
@@ -7540,4 +7569,4 @@ export {
|
|
|
7540
7569
|
isTest,
|
|
7541
7570
|
Sonamu
|
|
7542
7571
|
};
|
|
7543
|
-
//# sourceMappingURL=chunk-
|
|
7572
|
+
//# sourceMappingURL=chunk-GUV6I64Y.mjs.map
|