silgi 0.34.12 → 0.35.0
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/core/index.mjs +1 -1
- package/dist/presets/_all.gen.mjs +2 -0
- package/dist/presets/_types.gen.d.mts +2 -2
- package/dist/presets/hono/preset.d.mts +3 -0
- package/dist/presets/hono/preset.mjs +37 -0
- package/dist/presets/next/preset.mjs +6 -2
- package/dist/runtime/internal/next.d.mts +2 -2
- package/dist/runtime/internal/next.mjs +39 -45
- package/dist/types/index.d.mts +5 -5
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.mjs
CHANGED
|
@@ -263,7 +263,7 @@ async function createSilgi(config) {
|
|
|
263
263
|
routerPrefixs: [],
|
|
264
264
|
schemas: config.schemas ?? {},
|
|
265
265
|
services: config.services ?? {},
|
|
266
|
-
shared: config.shared ??
|
|
266
|
+
shared: config.shared ?? {},
|
|
267
267
|
plugins: config.plugins ?? [],
|
|
268
268
|
framework: config.framework ?? void 0,
|
|
269
269
|
storage: config.options.putStorage ?? void 0,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import _h3 from "./h3/preset.mjs";
|
|
2
|
+
import _hono from "./hono/preset.mjs";
|
|
2
3
|
import _next from "./next/preset.mjs";
|
|
3
4
|
import _nitro from "./nitro/preset.mjs";
|
|
4
5
|
import _npmpackage from "./npmpackage/preset.mjs";
|
|
5
6
|
import _nuxt from "./nuxt/preset.mjs";
|
|
6
7
|
const presets = [
|
|
7
8
|
..._h3,
|
|
9
|
+
..._hono,
|
|
8
10
|
..._next,
|
|
9
11
|
..._nitro,
|
|
10
12
|
..._npmpackage,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface PresetOptions {
|
|
2
2
|
}
|
|
3
3
|
export declare const presetsWithConfig: readonly [];
|
|
4
|
-
export type PresetName = "h3" | "next" | "nitro" | "npm-package" | "nuxt";
|
|
5
|
-
export type PresetNameInput = "h3" | "next" | "nitro" | "npm-package" | "nuxt";
|
|
4
|
+
export type PresetName = "h3" | "hono" | "next" | "nitro" | "npm-package" | "nuxt";
|
|
5
|
+
export type PresetNameInput = "h3" | "hono" | "next" | "nitro" | "npm-package" | "nuxt";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineSilgiPreset } from "silgi/kit";
|
|
2
|
+
const hono = defineSilgiPreset(
|
|
3
|
+
{
|
|
4
|
+
// output: {
|
|
5
|
+
// dir: '{{ rootDir }}/.output',
|
|
6
|
+
// publicDir: '{{ output.dir }}/public',
|
|
7
|
+
// },
|
|
8
|
+
serverDir: "{{ rootDir }}/src/server",
|
|
9
|
+
envOptions: {
|
|
10
|
+
prefix: "HONO_",
|
|
11
|
+
altPrefix: "SILGI_"
|
|
12
|
+
},
|
|
13
|
+
imports: {
|
|
14
|
+
dirs: [
|
|
15
|
+
"!{{ serverDir }}/runtime/**",
|
|
16
|
+
"!{{ serverDir }}/api/**",
|
|
17
|
+
"!{{ serverDir }}/routes/**",
|
|
18
|
+
"!{{ serverDir }}/modules/**",
|
|
19
|
+
"!{{ serverDir }}/assets/**",
|
|
20
|
+
"!{{ serverDir }}/public/**",
|
|
21
|
+
"!{{ silgi.serverDir }}/**"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
hooks: {
|
|
25
|
+
ready: async () => {
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
storages: []
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "hono",
|
|
32
|
+
static: true,
|
|
33
|
+
url: import.meta.url
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
const presets = [hono];
|
|
37
|
+
export default presets;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineSilgiPreset } from "silgi/kit";
|
|
1
|
+
import { addNPMPackage, defineSilgiPreset } from "silgi/kit";
|
|
2
2
|
const next = defineSilgiPreset(
|
|
3
3
|
{
|
|
4
4
|
// output: {
|
|
@@ -8,7 +8,7 @@ const next = defineSilgiPreset(
|
|
|
8
8
|
serverDir: "{{ rootDir }}/src/server",
|
|
9
9
|
envOptions: {
|
|
10
10
|
prefix: "NEXT_",
|
|
11
|
-
altPrefix: "
|
|
11
|
+
altPrefix: "SILGI_"
|
|
12
12
|
},
|
|
13
13
|
imports: {
|
|
14
14
|
dirs: [
|
|
@@ -23,6 +23,10 @@ const next = defineSilgiPreset(
|
|
|
23
23
|
},
|
|
24
24
|
hooks: {
|
|
25
25
|
ready: async () => {
|
|
26
|
+
await addNPMPackage({
|
|
27
|
+
name: "defu",
|
|
28
|
+
isDev: true
|
|
29
|
+
});
|
|
26
30
|
}
|
|
27
31
|
},
|
|
28
32
|
storages: []
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NextApiResponse } from 'next';
|
|
2
2
|
import type { Silgi } from 'silgi/types';
|
|
3
|
-
export declare function addNextApp(silgiContext?: Silgi): (
|
|
3
|
+
export declare function addNextApp(silgiContext?: Silgi): (request: Request) => Promise<void | NextApiResponse<any> | Response>;
|
|
4
4
|
export default addNextApp;
|
|
@@ -1,71 +1,65 @@
|
|
|
1
|
-
import { createError,
|
|
2
|
-
import { getQuery, withoutHost } from "ufo";
|
|
1
|
+
import { createError, getUrlPrefix, isError, silgiFetch, useSilgi } from "silgi";
|
|
3
2
|
export function addNextApp(silgiContext = useSilgi()) {
|
|
4
|
-
return async (
|
|
3
|
+
return async (request) => {
|
|
5
4
|
if (!silgiContext) {
|
|
6
5
|
throw new Error("Silgi context is not defined");
|
|
7
6
|
}
|
|
8
|
-
|
|
7
|
+
const silgiURL = getUrlPrefix(request.url, request.method);
|
|
9
8
|
try {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
const resolvedRoute = await silgiFetch(request);
|
|
10
|
+
if (!resolvedRoute.ok) {
|
|
11
|
+
await silgiContext.callHook("fetch:error", {
|
|
12
|
+
error: new Error(resolvedRoute.statusText),
|
|
13
|
+
url: silgiURL
|
|
14
|
+
});
|
|
15
|
+
silgiContext.captureError(
|
|
16
|
+
silgiContext,
|
|
17
|
+
createError({
|
|
18
|
+
message: resolvedRoute.statusText,
|
|
19
|
+
statusCode: resolvedRoute.status,
|
|
20
|
+
statusMessage: resolvedRoute.statusText
|
|
21
|
+
}),
|
|
22
|
+
{
|
|
23
|
+
url: silgiURL,
|
|
24
|
+
tags: ["execute"]
|
|
25
|
+
}
|
|
26
|
+
);
|
|
26
27
|
throw createError({
|
|
27
|
-
statusCode:
|
|
28
|
-
statusMessage:
|
|
28
|
+
statusCode: resolvedRoute.status,
|
|
29
|
+
statusMessage: resolvedRoute.statusText
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
path: newPath,
|
|
33
|
-
queryParams: query,
|
|
34
|
-
operation
|
|
35
|
-
});
|
|
36
|
-
const data = await silgiConnect.execute(newPath, {
|
|
37
|
-
...body
|
|
38
|
-
}, void 0, query);
|
|
39
|
-
return handleResponse(data, {
|
|
40
|
-
req,
|
|
41
|
-
res,
|
|
42
|
-
context: {},
|
|
43
|
-
url: new URL(req.url || "", "http://localhost")
|
|
44
|
-
}, {
|
|
45
|
-
debug: false
|
|
46
|
-
});
|
|
32
|
+
return resolvedRoute;
|
|
47
33
|
} catch (err) {
|
|
48
34
|
if (isError(err)) {
|
|
35
|
+
throw createError({
|
|
36
|
+
statusCode: 500,
|
|
37
|
+
statusMessage: "Internal Server Error",
|
|
38
|
+
cause: err
|
|
39
|
+
});
|
|
49
40
|
}
|
|
50
|
-
await silgiContext.callHook("
|
|
41
|
+
await silgiContext.callHook("fetch:error", {
|
|
51
42
|
error: err instanceof Error ? err : new Error(String(err)),
|
|
52
|
-
|
|
53
|
-
operation
|
|
54
|
-
// event: event as never,
|
|
43
|
+
url: silgiURL
|
|
55
44
|
});
|
|
56
45
|
silgiContext.captureError(
|
|
57
46
|
silgiContext,
|
|
58
47
|
createError({
|
|
59
48
|
message: err instanceof Error ? err.message : String(err),
|
|
60
49
|
statusCode: 500,
|
|
61
|
-
statusMessage: "Internal Server Error"
|
|
50
|
+
statusMessage: "Internal Server Error",
|
|
51
|
+
cause: err
|
|
62
52
|
}),
|
|
63
53
|
{
|
|
64
|
-
|
|
65
|
-
operation,
|
|
54
|
+
url: silgiURL,
|
|
66
55
|
tags: ["execute"]
|
|
67
56
|
}
|
|
68
57
|
);
|
|
58
|
+
throw createError({
|
|
59
|
+
statusCode: 500,
|
|
60
|
+
message: "Internal Server Error",
|
|
61
|
+
cause: err
|
|
62
|
+
});
|
|
69
63
|
}
|
|
70
64
|
};
|
|
71
65
|
}
|
package/dist/types/index.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ 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 { SilgiRuntimeShareds as SilgiRuntimeShareds$1, ModuleMeta as ModuleMeta$1, SilgiModule as SilgiModule$1, BuildSilgi as BuildSilgi$1, SilgiSchema as SilgiSchema$1, SilgiEvent as SilgiEvent$1, SilgiRuntimeActions as SilgiRuntimeActions$1, StorageConfig as StorageConfig$1, Commands as Commands$1, DotenvOptions as DotenvOptions$1, EnvOptions as EnvOptions$1, SilgiRuntimeConfig as SilgiRuntimeConfig$1, SilgiCLIHooks as SilgiCLIHooks$1, StorageMounts as StorageMounts$1, SilgiTemplate as SilgiTemplate$1, SilgiFrameworkInfo as SilgiFrameworkInfo$1 } from 'silgi/types';
|
|
10
|
+
import { ResolvedServiceDefinition as ResolvedServiceDefinition$1, SilgiRuntimeShareds as SilgiRuntimeShareds$1, ModuleMeta as ModuleMeta$1, SilgiModule as SilgiModule$1, BuildSilgi as BuildSilgi$1, SilgiSchema as SilgiSchema$1, SilgiEvent as SilgiEvent$1, SilgiRuntimeActions as SilgiRuntimeActions$1, StorageConfig as StorageConfig$1, Commands as Commands$1, DotenvOptions as DotenvOptions$1, EnvOptions as EnvOptions$1, SilgiRuntimeConfig as SilgiRuntimeConfig$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
13
|
import * as h3 from 'h3';
|
|
@@ -73,7 +73,7 @@ interface SilgiCLI {
|
|
|
73
73
|
type: 'Parser';
|
|
74
74
|
path?: string;
|
|
75
75
|
}[];
|
|
76
|
-
services: ResolvedServiceDefinition;
|
|
76
|
+
services: ResolvedServiceDefinition$1;
|
|
77
77
|
shareds: SilgiRuntimeShareds$1;
|
|
78
78
|
schemas: Record<string, any>;
|
|
79
79
|
scannedURIs: Map<string, string>;
|
|
@@ -381,7 +381,7 @@ interface ServiceSetup<Schema extends SilgiSchema$1 = SilgiSchema$1, Route exten
|
|
|
381
381
|
* This interface is designed to be compatible with the structure created
|
|
382
382
|
* by the createService function.
|
|
383
383
|
*/
|
|
384
|
-
interface ResolvedServiceDefinition
|
|
384
|
+
interface ResolvedServiceDefinition {
|
|
385
385
|
[routePath: string]: {
|
|
386
386
|
[method: string]: {
|
|
387
387
|
handler: (...args: any[]) => Promise<any>;
|
|
@@ -1013,7 +1013,7 @@ interface Silgi {
|
|
|
1013
1013
|
router: RouterContext<SilgiRoute>;
|
|
1014
1014
|
routerPrefixs: string[];
|
|
1015
1015
|
schemas: ResolvedSchemaDefinition;
|
|
1016
|
-
services: ResolvedServiceDefinition
|
|
1016
|
+
services: ResolvedServiceDefinition;
|
|
1017
1017
|
shared: SilgiRuntimeShareds;
|
|
1018
1018
|
plugins: SilgiAppPlugin[];
|
|
1019
1019
|
framework: FrameworkContext;
|
|
@@ -1188,4 +1188,4 @@ interface GraphQLJSON {
|
|
|
1188
1188
|
references: any;
|
|
1189
1189
|
}
|
|
1190
1190
|
|
|
1191
|
-
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, FrameworkContext, GenImport, GenerateAppOptions, GraphQLJSON, HTTPMethod, HookResult, HttpMethod, LoadConfigOptions, MergeAll, MergedSilgiSchema, MethodSchemas, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition
|
|
1191
|
+
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, FrameworkContext, GenImport, GenerateAppOptions, GraphQLJSON, HTTPMethod, HookResult, HttpMethod, LoadConfigOptions, MergeAll, MergedSilgiSchema, MethodSchemas, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate, RouteConfig, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceHandler, ServiceHandlerInput, ServiceHandlerOutput, ServiceHandlerSource, ServiceMethods, ServiceSetup, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIDynamicConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRoute, SilgiRouterTypes, SilgiRuntimeActions, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiStorageBase, SilgiTemplate, SilgiURL, StandardHTTPMethod, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes, WithPathParams };
|