silgi 0.29.36 → 0.29.38
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/cli/index.mjs +1 -1
- package/dist/cli/silgi.mjs +3 -7
- package/dist/kit/index.d.mts +25 -3
- package/dist/kit/index.mjs +24 -2
- package/dist/types/index.d.mts +8 -4
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/cli/silgi.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { generateDTS } from 'apiful/openapi';
|
|
2
2
|
import consola$1, { consola } from 'consola';
|
|
3
3
|
import { join, resolve, dirname, relative, isAbsolute, basename, extname } from 'pathe';
|
|
4
|
-
import { hasSilgiModule, addTemplate, normalizeTemplate, useLogger, genEnsureSafeVar, baseHeaderBannerComment, addImports, hash, toArray, writeFile, relativeWithDot, isDirectory, isPresents, addCoreFile, resolveAlias as resolveAlias$1, directoryToURL, hasError, parseServices, resolveSilgiPath } from 'silgi/kit';
|
|
4
|
+
import { hasSilgiModule, addTemplate, normalizeTemplate, useLogger, genEnsureSafeVar, baseHeaderBannerComment, addImports, hash, toArray, writeFile, relativeWithDot, isDirectory, isPresents, addCoreFile, resolveAlias as resolveAlias$1, directoryToURL, hasError, removeExtension, parseServices, resolveSilgiPath } from 'silgi/kit';
|
|
5
5
|
import { mkdirSync, existsSync, writeFileSync, promises, readFileSync } from 'node:fs';
|
|
6
6
|
import { readdir, readFile } from 'node:fs/promises';
|
|
7
7
|
import { genAugmentation, genObjectFromRawEntries, genImport, genTypeImport, genObjectFromRaw, genObjectFromValues } from 'knitwork';
|
|
@@ -1860,10 +1860,8 @@ async function scanExportFile(silgi) {
|
|
|
1860
1860
|
if (type === "schema") {
|
|
1861
1861
|
options.schemas.push(_name);
|
|
1862
1862
|
}
|
|
1863
|
-
const relativePath = relativeWithDot(silgi.options.silgi.serverDir, path);
|
|
1864
|
-
const isExtension = silgi.options.typescript.removeFileExtension ? relativePath.replace(/\.+$/, "") : relativePath;
|
|
1865
1863
|
options.addImportItem({
|
|
1866
|
-
specifier:
|
|
1864
|
+
specifier: removeExtension(relativeWithDot(silgi.options.silgi.serverDir, path)),
|
|
1867
1865
|
imports: [
|
|
1868
1866
|
{
|
|
1869
1867
|
name: exportName,
|
|
@@ -1890,8 +1888,6 @@ async function scanExportFile(silgi) {
|
|
|
1890
1888
|
value: _name
|
|
1891
1889
|
});
|
|
1892
1890
|
}
|
|
1893
|
-
const relativePath = relativeWithDot(silgi.options.silgi.serverDir, path);
|
|
1894
|
-
const isExtension = silgi.options.typescript.removeFileExtension ? relativePath.replace(/\.+$/, "") : relativePath;
|
|
1895
1891
|
options.addImportItem({
|
|
1896
1892
|
imports: [
|
|
1897
1893
|
{
|
|
@@ -1899,7 +1895,7 @@ async function scanExportFile(silgi) {
|
|
|
1899
1895
|
as: _name
|
|
1900
1896
|
}
|
|
1901
1897
|
],
|
|
1902
|
-
specifier:
|
|
1898
|
+
specifier: removeExtension(relativeWithDot(silgi.options.build.typesDir, path))
|
|
1903
1899
|
});
|
|
1904
1900
|
}
|
|
1905
1901
|
});
|
package/dist/kit/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Commands, SilgiCLIHooks, GenImport, SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, SilgiTemplate, ResolvedSilgiTemplate, SilgiEvents } from 'silgi/types';
|
|
1
|
+
import { Commands, SilgiCLIHooks, GenImport, DefineFrameworkOptions, SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, SilgiTemplate, ResolvedSilgiTemplate, SilgiEvents } from 'silgi/types';
|
|
2
|
+
import { PresetName } from 'silgi/presets';
|
|
2
3
|
import { Buffer } from 'node:buffer';
|
|
3
4
|
import { ConsolaOptions, ConsolaInstance } from 'consola';
|
|
4
5
|
import * as rfc6902 from 'rfc6902';
|
|
5
6
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
6
|
-
import { PresetName } from 'silgi/presets';
|
|
7
7
|
|
|
8
8
|
declare function addCommands(data: Commands | Commands[]): Promise<void>;
|
|
9
9
|
|
|
@@ -34,6 +34,27 @@ declare function addNPMPackage(data: {
|
|
|
34
34
|
when?: boolean;
|
|
35
35
|
}): Promise<void>;
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Define a framework handler with proper type safety using a fluent API
|
|
39
|
+
*
|
|
40
|
+
* @param preset The framework preset to use
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const h3Handler = defineFramework('h3').build((options) => {
|
|
44
|
+
* // Type-safe access to h3 router
|
|
45
|
+
* const router = options.framework
|
|
46
|
+
* // Implementation here
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function defineFramework<T extends PresetName>(preset: T): {
|
|
51
|
+
/**
|
|
52
|
+
* Build the framework handler
|
|
53
|
+
* @param callback The callback function that will receive typed options
|
|
54
|
+
*/
|
|
55
|
+
build(callback: (options: DefineFrameworkOptions<T>) => void): (options: DefineFrameworkOptions<T>) => void;
|
|
56
|
+
};
|
|
57
|
+
|
|
37
58
|
declare function hasError(type: SilgiCLI['errors'][0]['type'], silgi?: SilgiCLI): boolean;
|
|
38
59
|
|
|
39
60
|
declare function directoryToURL(dir: string): URL;
|
|
@@ -313,6 +334,7 @@ declare const baseHeaderBannerComment: string[];
|
|
|
313
334
|
declare function processFilePath(src: string): string;
|
|
314
335
|
declare function isPresents(names: PresetName[]): boolean;
|
|
315
336
|
declare function isRuntimePresents(names: PresetName[]): boolean;
|
|
337
|
+
declare function removeExtension(filePath: string): string;
|
|
316
338
|
|
|
317
|
-
export { MODE_RE, MigrationStatus, addCommands, addCoreFile, addImports, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory, isH3, isNitro, isNuxt, isPresents, isRuntimePresents, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
|
|
339
|
+
export { MODE_RE, MigrationStatus, addCommands, addCoreFile, addImports, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineFramework, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory, isH3, isNitro, isNuxt, isPresents, isRuntimePresents, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, removeExtension, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
|
|
318
340
|
export type { FunctionConfig, JsonPatch, MigrationData, MigrationInfo, MigrationOptions, MigrationResult };
|
package/dist/kit/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as useSilgiCLI$1 } from '../_chunks/silgiApp.mjs';
|
|
2
|
-
import { relative, resolve, dirname, join, normalize, isAbsolute, parse, basename } from 'pathe';
|
|
2
|
+
import { relative, extname, resolve, dirname, join, normalize, isAbsolute, parse, basename } from 'pathe';
|
|
3
3
|
import { useSilgiCLI, useSilgi, tryUseSilgiCLI } from 'silgi';
|
|
4
4
|
import { toArray as toArray$1, hash as hash$2 } from 'silgi/kit';
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
@@ -68,6 +68,14 @@ function isRuntimePresents(names) {
|
|
|
68
68
|
const silgi = useSilgi();
|
|
69
69
|
return names.includes(silgi.options.present);
|
|
70
70
|
}
|
|
71
|
+
function removeExtension(filePath) {
|
|
72
|
+
const silgi = useSilgiCLI();
|
|
73
|
+
if (silgi.options.typescript.removeFileExtension) {
|
|
74
|
+
const ext = extname(filePath);
|
|
75
|
+
return ext ? filePath.slice(0, -ext.length) : filePath;
|
|
76
|
+
}
|
|
77
|
+
return filePath;
|
|
78
|
+
}
|
|
71
79
|
|
|
72
80
|
async function addCommands(data) {
|
|
73
81
|
useSilgiCLI$1().hook("prepare:commands", (commads) => {
|
|
@@ -181,6 +189,20 @@ async function addNPMPackage(data) {
|
|
|
181
189
|
}
|
|
182
190
|
}
|
|
183
191
|
|
|
192
|
+
function defineFramework(preset) {
|
|
193
|
+
return {
|
|
194
|
+
/**
|
|
195
|
+
* Build the framework handler
|
|
196
|
+
* @param callback The callback function that will receive typed options
|
|
197
|
+
*/
|
|
198
|
+
build(callback) {
|
|
199
|
+
return function handler(options) {
|
|
200
|
+
callback(options);
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
184
206
|
function hasError(type, silgi) {
|
|
185
207
|
silgi = silgi ?? tryUseSilgiCLI() ?? void 0;
|
|
186
208
|
if (silgi && silgi.errors.some((error) => error.type === type)) {
|
|
@@ -1045,4 +1067,4 @@ function isValidIp(ip) {
|
|
|
1045
1067
|
return false;
|
|
1046
1068
|
}
|
|
1047
1069
|
|
|
1048
|
-
export { MODE_RE, MigrationStatus, addCommands, addCoreFile, addImports, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, isPresents, isRuntimePresents, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
|
|
1070
|
+
export { MODE_RE, MigrationStatus, addCommands, addCoreFile, addImports, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineFramework, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, isPresents, isRuntimePresents, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, removeExtension, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -7,11 +7,11 @@ import { Hookable, NestedHooks } from 'hookable';
|
|
|
7
7
|
import { Ignore, Options } from 'ignore';
|
|
8
8
|
import { TSConfig } from 'pkg-types';
|
|
9
9
|
import { PresetName, PresetOptions, PresetNameInput } from 'silgi/presets';
|
|
10
|
-
import { ResolvedServiceType as ResolvedServiceType$1, SilgiRuntimeShareds as SilgiRuntimeShareds$1, SilgiRuntimeOptions as SilgiRuntimeOptions$1, RouteRules as RouteRules$1, ModuleMeta as ModuleMeta$1, SilgiModule as SilgiModule$1, Commands as Commands$1, SilgiRouteRules as SilgiRouteRules$1, DotenvOptions as DotenvOptions$1, EnvOptions as EnvOptions$1, SilgiRuntimeConfig as SilgiRuntimeConfig$1, ServiceParseModule as ServiceParseModule$1, SilgiCLIHooks as SilgiCLIHooks$1, StorageMounts as StorageMounts$1, SilgiTemplate as SilgiTemplate$1, SilgiFrameworkInfo as SilgiFrameworkInfo$1 } from 'silgi/types';
|
|
10
|
+
import { ResolvedServiceType as ResolvedServiceType$1, SilgiRuntimeShareds as SilgiRuntimeShareds$1, SilgiRuntimeOptions as SilgiRuntimeOptions$1, RouteRules as RouteRules$1, ModuleMeta as ModuleMeta$1, SilgiModule as SilgiModule$1, BuildSilgi as BuildSilgi$1, Commands as Commands$1, SilgiRouteRules as SilgiRouteRules$1, DotenvOptions as DotenvOptions$1, EnvOptions as EnvOptions$1, SilgiRuntimeConfig as SilgiRuntimeConfig$1, ServiceParseModule as ServiceParseModule$1, SilgiCLIHooks as SilgiCLIHooks$1, StorageMounts as StorageMounts$1, SilgiTemplate as SilgiTemplate$1, SilgiFrameworkInfo as SilgiFrameworkInfo$1 } from 'silgi/types';
|
|
11
11
|
import { Adapter, TablesSchema, InferModelTypes } from 'unadapter/types';
|
|
12
12
|
import { UnimportPluginOptions } from 'unimport/unplugin';
|
|
13
|
-
import { H3Event } from 'h3';
|
|
14
|
-
import { NitroRuntimeConfig } from 'nitropack/types';
|
|
13
|
+
import { Router, H3Event } from 'h3';
|
|
14
|
+
import { NitroApp, NitroRuntimeConfig } from 'nitropack/types';
|
|
15
15
|
import { Defu } from 'defu';
|
|
16
16
|
import { Stats } from 'node:fs';
|
|
17
17
|
import { ESMImport, ESMCodeGenOptions } from 'knitwork';
|
|
@@ -153,6 +153,10 @@ interface GenImport {
|
|
|
153
153
|
imports: ESMImport | ESMImport[];
|
|
154
154
|
options?: ESMCodeGenOptions;
|
|
155
155
|
}
|
|
156
|
+
type Framework<T extends PresetName> = T extends 'nitro' ? NitroApp : T extends 'nuxt' ? NitroApp : T extends 'h3' ? Router : never;
|
|
157
|
+
interface DefineFrameworkOptions<T extends PresetName> extends Omit<BuildSilgi$1, 'framework'> {
|
|
158
|
+
framework: Framework<T>;
|
|
159
|
+
}
|
|
156
160
|
|
|
157
161
|
interface SilgiCLIHooks extends SilgiHooks {
|
|
158
162
|
/**
|
|
@@ -1182,4 +1186,4 @@ interface ServiceParseModule {
|
|
|
1182
1186
|
(params: ServiceParse): Awaited<void> | void;
|
|
1183
1187
|
}
|
|
1184
1188
|
|
|
1185
|
-
export type { AllPaths, AppConfig, Awaitable, BaseNamespaceType, BaseSchemaType, BaseSilgiMethodType, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CreateScope, DeepPartial, DeepRequired, DefaultHooks, DefaultNamespaces, DefaultRouteConfig, DefaultRouteRules, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractInputFromURI, ExtractOutputFromURI, ExtractPathParams, ExtractPathParamsFromURI, ExtractQueryParamsFromURI, ExtractSourceFromURI, FrameworkContext, GenImport, GenerateAppOptions, GraphQLJSON, HookResult, HttpMethod, LoadConfigOptions, MergedSilgiSchema, MethodHandlerType, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, Namespaces, NitroBuildInfo, RequiredServiceType, ResolvedMethodHandlerType, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedServiceType, ResolvedSilgiTemplate, RouteRules, RouterParams, ScanFile, ServiceParse, ServiceParseModule, ServiceType, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIDynamicConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvents, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiFunction, SilgiHooks, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiNamespaces, SilgiOperation, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRouteRules, SilgiRouterTypes, SilgiRuntimeActions, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeRouteRules, SilgiRuntimeRouteRulesConfig, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiServiceInterface, SilgiStorageBase, SilgiTemplate, SilgiURIs, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes, URIsTypes };
|
|
1189
|
+
export type { AllPaths, AppConfig, Awaitable, BaseNamespaceType, BaseSchemaType, BaseSilgiMethodType, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CreateScope, DeepPartial, DeepRequired, DefaultHooks, DefaultNamespaces, DefaultRouteConfig, DefaultRouteRules, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractInputFromURI, ExtractOutputFromURI, ExtractPathParams, ExtractPathParamsFromURI, ExtractQueryParamsFromURI, ExtractSourceFromURI, FrameworkContext, GenImport, GenerateAppOptions, GraphQLJSON, HookResult, HttpMethod, LoadConfigOptions, MergedSilgiSchema, MethodHandlerType, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, Namespaces, NitroBuildInfo, RequiredServiceType, ResolvedMethodHandlerType, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedServiceType, ResolvedSilgiTemplate, RouteRules, RouterParams, ScanFile, ServiceParse, ServiceParseModule, ServiceType, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIDynamicConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvents, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiFunction, SilgiHooks, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiNamespaces, SilgiOperation, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRouteRules, SilgiRouterTypes, SilgiRuntimeActions, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeRouteRules, SilgiRuntimeRouteRulesConfig, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiServiceInterface, SilgiStorageBase, SilgiTemplate, SilgiURIs, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes, URIsTypes };
|