silgi 0.0.8 → 0.0.10
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/chunks/generate.mjs +31 -27
- package/dist/cli/index.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/plugins/openapi.d.mts +1 -1
- package/dist/plugins/openapi.d.ts +1 -1
- package/dist/plugins/scalar.d.mts +1 -1
- package/dist/plugins/scalar.d.ts +1 -1
- package/dist/shared/{silgi.BmG_a4Ft.d.mts → silgi.D5qK9QOm.d.mts} +1 -0
- package/dist/shared/{silgi.BmG_a4Ft.d.ts → silgi.D5qK9QOm.d.ts} +1 -0
- package/package.json +2 -2
package/dist/chunks/generate.mjs
CHANGED
|
@@ -169,7 +169,7 @@ class TypescriptGenerator {
|
|
|
169
169
|
const name = pascalCase(`${scope}_${schema.serviceName}SilgiZodSchemaType`);
|
|
170
170
|
zodInterfacesImports.push(`import type { SilgiZodSchema as ${name} } from '${schema.path}'`);
|
|
171
171
|
shareds.push({
|
|
172
|
-
type: "
|
|
172
|
+
type: "interface",
|
|
173
173
|
from: "zod",
|
|
174
174
|
key: schema.serviceName,
|
|
175
175
|
value: name
|
|
@@ -195,7 +195,7 @@ class TypescriptGenerator {
|
|
|
195
195
|
const name = pascalCase(`${scope}_${schema.serviceName}SilgiServiceType`);
|
|
196
196
|
importsString.push(`import type { SilgiService as ${name} } from '${schema.path}'`);
|
|
197
197
|
services.push({
|
|
198
|
-
type: "
|
|
198
|
+
type: "interface",
|
|
199
199
|
from: "service",
|
|
200
200
|
key: schema.serviceName,
|
|
201
201
|
value: name
|
|
@@ -215,7 +215,7 @@ class TypescriptGenerator {
|
|
|
215
215
|
const name = pascalCase(`${scope}_${uniqueIdentifier}SilgiContextType`);
|
|
216
216
|
importsString.push(`import type { SilgiContext as ${name} } from '${schema.path}'`);
|
|
217
217
|
context.push({
|
|
218
|
-
type: "
|
|
218
|
+
type: "interface",
|
|
219
219
|
from: "context",
|
|
220
220
|
key: scope,
|
|
221
221
|
value: name,
|
|
@@ -244,7 +244,7 @@ class TypescriptGenerator {
|
|
|
244
244
|
const name = pascalCase(`${scope}_${schema.serviceName}SilgiGlobalSharedType`);
|
|
245
245
|
importsString.push(`import type { SilgiGlobalShared as ${name} } from '${schema.path}'`);
|
|
246
246
|
shareds.push({
|
|
247
|
-
type: "
|
|
247
|
+
type: "interface",
|
|
248
248
|
from: "shared",
|
|
249
249
|
key: schema.serviceName,
|
|
250
250
|
value: name,
|
|
@@ -266,8 +266,8 @@ class TypescriptGenerator {
|
|
|
266
266
|
const services = [];
|
|
267
267
|
const modules = [];
|
|
268
268
|
const moduleConfig = [];
|
|
269
|
-
if (moduleData.methodsConfig
|
|
270
|
-
if (moduleData.methodsConfig.silgiMethodConfig?.length > 0) {
|
|
269
|
+
if (moduleData.methodsConfig) {
|
|
270
|
+
if (moduleData.methodsConfig.silgiMethodConfig && moduleData.methodsConfig.silgiMethodConfig?.length > 0) {
|
|
271
271
|
moduleData.methodsConfig.silgiMethodConfig.forEach((schema) => {
|
|
272
272
|
const name = camelCase(`${module}_${schema.serviceName}silgiMethodConfig`);
|
|
273
273
|
importsString.push(`import { silgiMethodConfig as ${name} } from '${schema.path}'`);
|
|
@@ -284,7 +284,7 @@ class TypescriptGenerator {
|
|
|
284
284
|
const name = pascalCase(`${module}_${schema.serviceName}SilgiMethodConfigType`);
|
|
285
285
|
importsString.push(`import type { SilgiMethodConfig as ${name} } from '${schema.path}'`);
|
|
286
286
|
methodsConfig.push({
|
|
287
|
-
type: "
|
|
287
|
+
type: "interface",
|
|
288
288
|
from: "methodsConfig",
|
|
289
289
|
key: schema.serviceName,
|
|
290
290
|
value: name
|
|
@@ -305,7 +305,7 @@ class TypescriptGenerator {
|
|
|
305
305
|
const name = pascalCase(`${module}_${uniqueIdentifier}SilgiContextType`);
|
|
306
306
|
importsString.push(`import type { SilgiContext as ${name} } from '${schema.path}'`);
|
|
307
307
|
context.push({
|
|
308
|
-
type: "
|
|
308
|
+
type: "interface",
|
|
309
309
|
from: "context",
|
|
310
310
|
key: module,
|
|
311
311
|
value: name
|
|
@@ -343,7 +343,7 @@ class TypescriptGenerator {
|
|
|
343
343
|
const name = pascalCase(`${module}_${schema.serviceName}SilgiServiceType`);
|
|
344
344
|
importsString.push(`import type { SilgiService as ${name} } from '${schema.path}'`);
|
|
345
345
|
services.push({
|
|
346
|
-
type: "
|
|
346
|
+
type: "interface",
|
|
347
347
|
from: "service",
|
|
348
348
|
key: schema.serviceName,
|
|
349
349
|
value: name
|
|
@@ -365,7 +365,7 @@ class TypescriptGenerator {
|
|
|
365
365
|
const name = pascalCase(`${module}_${schema.serviceName}SilgiModuleConfigType`);
|
|
366
366
|
importsString.push(`import type { SilgiModuleConfig as ${name} } from '${schema.path}'`);
|
|
367
367
|
moduleConfig.push({
|
|
368
|
-
type: "
|
|
368
|
+
type: "interface",
|
|
369
369
|
from: "moduleConfig",
|
|
370
370
|
key: schema.serviceName,
|
|
371
371
|
value: name
|
|
@@ -406,7 +406,7 @@ declare module 'silgi' {
|
|
|
406
406
|
${scopeDatas.some((scope) => scope.services.length > 0) ? `scopes: {
|
|
407
407
|
${scopeDatas.filter((scope) => scope.services.length > 0).map((scopeData) => {
|
|
408
408
|
const services = scopeData.services.map((shared) => {
|
|
409
|
-
if (shared.type === "
|
|
409
|
+
if (shared.type === "interface") {
|
|
410
410
|
return `${shared.key}: ${shared.value}`;
|
|
411
411
|
}
|
|
412
412
|
}).filter(Boolean).join("\n");
|
|
@@ -419,7 +419,7 @@ declare module 'silgi' {
|
|
|
419
419
|
${scopeDatas.some((scope) => scope.shareds.length > 0) ? `shared: {
|
|
420
420
|
${scopeDatas.map((scopeData) => {
|
|
421
421
|
const zodShared = scopeData.shareds.filter((shared) => shared.from === "zod").map((shared) => {
|
|
422
|
-
if (shared.type === "
|
|
422
|
+
if (shared.type === "interface") {
|
|
423
423
|
return `${shared.key}: ${shared.value}`;
|
|
424
424
|
}
|
|
425
425
|
}).filter(Boolean).join("\n");
|
|
@@ -435,7 +435,7 @@ declare module 'silgi' {
|
|
|
435
435
|
${modulesData.some((module) => module.methodsConfig.length > 0) ? `plugins: {
|
|
436
436
|
${modulesData.map((moduleData) => {
|
|
437
437
|
const methodsConfig = moduleData.methodsConfig.map((shared) => {
|
|
438
|
-
if (shared.type === "
|
|
438
|
+
if (shared.type === "interface") {
|
|
439
439
|
return `${shared.value}`;
|
|
440
440
|
}
|
|
441
441
|
}).filter(Boolean).join("\n");
|
|
@@ -446,7 +446,7 @@ declare module 'silgi' {
|
|
|
446
446
|
|
|
447
447
|
type ExtendDefaultContext = ${[...scopeDatas, ...modulesData].some((item) => item.context?.length > 0) ? [...scopeDatas, ...modulesData].filter((item) => item.context?.length > 0).map((item) => {
|
|
448
448
|
return item.context.map((shared) => {
|
|
449
|
-
if (shared.type === "
|
|
449
|
+
if (shared.type === "interface") {
|
|
450
450
|
return shared.value;
|
|
451
451
|
}
|
|
452
452
|
}).filter(Boolean).join(" & ");
|
|
@@ -732,6 +732,7 @@ class SchemaManager {
|
|
|
732
732
|
const absoluteFilePath = resolve(config.rootDir, filePath);
|
|
733
733
|
let relativePath = makeRelativePath(config._silgi.outputDirTS, absoluteFilePath);
|
|
734
734
|
relativePath = cleanPath(relativePath, config.removeExtensions);
|
|
735
|
+
consola.log("\u{1F4C1} Scanning module:", relativePath);
|
|
735
736
|
if (stats.isDirectory()) {
|
|
736
737
|
await scan(filePath);
|
|
737
738
|
} else if (file.endsWith(".ts")) {
|
|
@@ -809,7 +810,7 @@ class SchemaManager {
|
|
|
809
810
|
});
|
|
810
811
|
}
|
|
811
812
|
}
|
|
812
|
-
consola.log("\u{1F4C1} Scanning module:", this.
|
|
813
|
+
consola.log("\u{1F4C1} Scanning module:", Object.keys(this.modulesSchema).length);
|
|
813
814
|
}
|
|
814
815
|
}
|
|
815
816
|
} catch (error) {
|
|
@@ -885,18 +886,21 @@ async function generate$1(config) {
|
|
|
885
886
|
await schemaManager.generateOutput();
|
|
886
887
|
await schemaManager.generateClientOutput();
|
|
887
888
|
consola.success("Schema generation completed successfully");
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
889
|
+
try {
|
|
890
|
+
const eslint = new ESLint({
|
|
891
|
+
fix: true,
|
|
892
|
+
cwd: mergeConfig.rootDir,
|
|
893
|
+
baseConfig: await antfu({ typescript: true })
|
|
894
|
+
});
|
|
895
|
+
const results = await eslint.lintFiles([
|
|
896
|
+
mergeConfig._silgi.outputDirTS,
|
|
897
|
+
mergeConfig._silgi.outputDirClientTS
|
|
898
|
+
]);
|
|
899
|
+
await ESLint.outputFixes(results);
|
|
900
|
+
const formatter = await eslint.loadFormatter("stylish");
|
|
901
|
+
formatter.format(results);
|
|
902
|
+
} catch {
|
|
903
|
+
}
|
|
900
904
|
} catch (error) {
|
|
901
905
|
consola.error("Schema generation failed:", error);
|
|
902
906
|
process.exit(1);
|
package/dist/cli/index.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DefaultContext, a as DefaultInterface, E as ExtractScope, S as ServicePluginConfig, b as ServiceMethod, c as ExtractShared, C as CacheScope, d as CacheKeyGenerator, M as MethodPluginConfig, e as ServiceExecutor, O as OmitSilgiOptions, I as InitSilgi, P as PergelPlugin, f as Silgi } from './shared/silgi.
|
|
2
|
-
export { h as DefaultHooks, g as InitializedCreateScope, k as SchemaGenerated, i as SilgiDefaultContext, j as SilgiDefaultInterface } from './shared/silgi.
|
|
1
|
+
import { D as DefaultContext, a as DefaultInterface, E as ExtractScope, S as ServicePluginConfig, b as ServiceMethod, c as ExtractShared, C as CacheScope, d as CacheKeyGenerator, M as MethodPluginConfig, e as ServiceExecutor, O as OmitSilgiOptions, I as InitSilgi, P as PergelPlugin, f as Silgi } from './shared/silgi.D5qK9QOm.mjs';
|
|
2
|
+
export { h as DefaultHooks, g as InitializedCreateScope, k as SchemaGenerated, i as SilgiDefaultContext, j as SilgiDefaultInterface } from './shared/silgi.D5qK9QOm.mjs';
|
|
3
3
|
import * as unctx from 'unctx';
|
|
4
4
|
import 'consola';
|
|
5
5
|
import 'h3';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DefaultContext, a as DefaultInterface, E as ExtractScope, S as ServicePluginConfig, b as ServiceMethod, c as ExtractShared, C as CacheScope, d as CacheKeyGenerator, M as MethodPluginConfig, e as ServiceExecutor, O as OmitSilgiOptions, I as InitSilgi, P as PergelPlugin, f as Silgi } from './shared/silgi.
|
|
2
|
-
export { h as DefaultHooks, g as InitializedCreateScope, k as SchemaGenerated, i as SilgiDefaultContext, j as SilgiDefaultInterface } from './shared/silgi.
|
|
1
|
+
import { D as DefaultContext, a as DefaultInterface, E as ExtractScope, S as ServicePluginConfig, b as ServiceMethod, c as ExtractShared, C as CacheScope, d as CacheKeyGenerator, M as MethodPluginConfig, e as ServiceExecutor, O as OmitSilgiOptions, I as InitSilgi, P as PergelPlugin, f as Silgi } from './shared/silgi.D5qK9QOm.js';
|
|
2
|
+
export { h as DefaultHooks, g as InitializedCreateScope, k as SchemaGenerated, i as SilgiDefaultContext, j as SilgiDefaultInterface } from './shared/silgi.D5qK9QOm.js';
|
|
3
3
|
import * as unctx from 'unctx';
|
|
4
4
|
import 'consola';
|
|
5
5
|
import 'h3';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
2
|
import { SchemaObject, ServerObject, OpenAPIObject } from 'openapi3-ts/oas31';
|
|
3
|
-
import { P as PergelPlugin, D as DefaultContext, a as DefaultInterface, I as InitSilgi } from '../shared/silgi.
|
|
3
|
+
import { P as PergelPlugin, D as DefaultContext, a as DefaultInterface, I as InitSilgi } from '../shared/silgi.D5qK9QOm.mjs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import 'consola';
|
|
6
6
|
import 'h3';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
|
|
2
2
|
import { SchemaObject, ServerObject, OpenAPIObject } from 'openapi3-ts/oas31';
|
|
3
|
-
import { P as PergelPlugin, D as DefaultContext, a as DefaultInterface, I as InitSilgi } from '../shared/silgi.
|
|
3
|
+
import { P as PergelPlugin, D as DefaultContext, a as DefaultInterface, I as InitSilgi } from '../shared/silgi.D5qK9QOm.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import 'consola';
|
|
6
6
|
import 'h3';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PergelPlugin, D as DefaultContext, a as DefaultInterface } from '../shared/silgi.
|
|
1
|
+
import { P as PergelPlugin, D as DefaultContext, a as DefaultInterface } from '../shared/silgi.D5qK9QOm.mjs';
|
|
2
2
|
import 'consola';
|
|
3
3
|
import 'h3';
|
|
4
4
|
import 'zod';
|
package/dist/plugins/scalar.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ interface PergelPlugin<TContext extends DefaultContext = DefaultContext, TInterf
|
|
|
45
45
|
shared?: boolean;
|
|
46
46
|
services?: boolean;
|
|
47
47
|
methodConfig?: boolean;
|
|
48
|
+
moduleConfig?: boolean;
|
|
48
49
|
};
|
|
49
50
|
readonly priority?: PluginPriority;
|
|
50
51
|
readonly dependencies?: ReadonlyArray<keyof ExtractPluginConfig<TInterface>>;
|
|
@@ -45,6 +45,7 @@ interface PergelPlugin<TContext extends DefaultContext = DefaultContext, TInterf
|
|
|
45
45
|
shared?: boolean;
|
|
46
46
|
services?: boolean;
|
|
47
47
|
methodConfig?: boolean;
|
|
48
|
+
moduleConfig?: boolean;
|
|
48
49
|
};
|
|
49
50
|
readonly priority?: PluginPriority;
|
|
50
51
|
readonly dependencies?: ReadonlyArray<keyof ExtractPluginConfig<TInterface>>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"import": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"unbuild": "^3.0.1",
|
|
69
|
-
"silgi": "0.0.
|
|
69
|
+
"silgi": "0.0.10"
|
|
70
70
|
},
|
|
71
71
|
"resolutions": {
|
|
72
72
|
"silgi": "workspace:*"
|