silgi 0.16.0 → 0.16.1
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/index.mjs +1 -1
- package/dist/_chunks/routeRules.mjs +37 -23
- package/dist/cli/dev.mjs +1 -1
- package/dist/cli/prepare.mjs +1 -1
- package/dist/core/index.mjs +1 -0
- package/dist/kit/index.d.mts +2 -2
- package/dist/kit/index.d.ts +2 -2
- package/dist/kit/index.mjs +13 -4
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/types/index.d.mts +10 -2
- package/dist/types/index.d.ts +10 -2
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { withoutTrailingSlash, withLeadingSlash } from 'ufo';
|
|
2
|
+
|
|
1
3
|
function patternToRegex(pattern) {
|
|
2
4
|
let regexStr = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
3
5
|
regexStr = regexStr.replace(/\*\*/g, ".+");
|
|
@@ -6,6 +8,8 @@ function patternToRegex(pattern) {
|
|
|
6
8
|
return new RegExp(`^${regexStr}$`);
|
|
7
9
|
}
|
|
8
10
|
function extractParams(url, pattern) {
|
|
11
|
+
url = withoutTrailingSlash(withLeadingSlash(url));
|
|
12
|
+
pattern = withoutTrailingSlash(withLeadingSlash(pattern));
|
|
9
13
|
if (!pattern.includes(":"))
|
|
10
14
|
return null;
|
|
11
15
|
const paramNames = [];
|
|
@@ -24,11 +28,10 @@ function extractParams(url, pattern) {
|
|
|
24
28
|
return Object.keys(params).length > 0 ? params : null;
|
|
25
29
|
}
|
|
26
30
|
function matchesPattern(url, pattern) {
|
|
31
|
+
url = withoutTrailingSlash(withLeadingSlash(url));
|
|
32
|
+
pattern = withoutTrailingSlash(withLeadingSlash(pattern));
|
|
27
33
|
if (url === pattern)
|
|
28
34
|
return true;
|
|
29
|
-
if (url.endsWith("/") && !pattern.endsWith("/") || !url.endsWith("/") && pattern.endsWith("/")) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
35
|
if (pattern.endsWith("/**")) {
|
|
33
36
|
const basePath = pattern.slice(0, -3);
|
|
34
37
|
return url === basePath || url.startsWith(`${basePath}/`);
|
|
@@ -86,7 +89,11 @@ function createRouteRules() {
|
|
|
86
89
|
return deepClone(_rules);
|
|
87
90
|
}
|
|
88
91
|
function importRules(config) {
|
|
89
|
-
|
|
92
|
+
const normalizedConfig = {};
|
|
93
|
+
for (const pattern in config) {
|
|
94
|
+
normalizedConfig[withoutTrailingSlash(withLeadingSlash(pattern))] = deepClone(config[pattern]);
|
|
95
|
+
}
|
|
96
|
+
_rules = normalizedConfig;
|
|
90
97
|
_rulesModified = true;
|
|
91
98
|
updateMergeRules();
|
|
92
99
|
}
|
|
@@ -94,29 +101,31 @@ function createRouteRules() {
|
|
|
94
101
|
return deepClone(_rules);
|
|
95
102
|
}
|
|
96
103
|
function addRule(pattern, config) {
|
|
97
|
-
_rules[pattern] = deepClone(config);
|
|
104
|
+
_rules[withoutTrailingSlash(withLeadingSlash(pattern))] = deepClone(config);
|
|
98
105
|
_rulesModified = true;
|
|
99
106
|
updateMergeRules();
|
|
100
107
|
}
|
|
101
108
|
function updateRule(pattern, config) {
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
const normalizedPattern = withoutTrailingSlash(withLeadingSlash(pattern));
|
|
110
|
+
if (_rules[normalizedPattern]) {
|
|
111
|
+
_rules[normalizedPattern] = { ..._rules[normalizedPattern], ...deepClone(config) };
|
|
104
112
|
} else {
|
|
105
|
-
_rules[
|
|
113
|
+
_rules[normalizedPattern] = deepClone(config);
|
|
106
114
|
}
|
|
107
115
|
_rulesModified = true;
|
|
108
116
|
updateMergeRules();
|
|
109
117
|
}
|
|
110
118
|
function removeRule(pattern) {
|
|
111
|
-
delete _rules[pattern];
|
|
119
|
+
delete _rules[withoutTrailingSlash(withLeadingSlash(pattern))];
|
|
112
120
|
_rulesModified = true;
|
|
113
121
|
updateMergeRules();
|
|
114
122
|
}
|
|
115
123
|
function matchesRule(url, pattern) {
|
|
116
|
-
return matchesPattern(url, pattern);
|
|
124
|
+
return matchesPattern(withoutTrailingSlash(withLeadingSlash(url)), withoutTrailingSlash(withLeadingSlash(pattern)));
|
|
117
125
|
}
|
|
118
126
|
function getMatchingPatterns(url) {
|
|
119
|
-
|
|
127
|
+
const normalizedUrl = withoutTrailingSlash(withLeadingSlash(url));
|
|
128
|
+
return Object.keys(_rules).filter((pattern) => matchesPattern(normalizedUrl, pattern)).sort((a, b) => {
|
|
120
129
|
if (a === url)
|
|
121
130
|
return -1;
|
|
122
131
|
if (b === url)
|
|
@@ -137,13 +146,14 @@ function createRouteRules() {
|
|
|
137
146
|
});
|
|
138
147
|
}
|
|
139
148
|
function getConfig(url) {
|
|
149
|
+
const normalizedUrl = withoutTrailingSlash(withLeadingSlash(url));
|
|
140
150
|
if (_rulesModified) {
|
|
141
151
|
updateMergeRules();
|
|
142
152
|
}
|
|
143
|
-
if (_mergedRules[
|
|
144
|
-
return deepClone(_mergedRules[
|
|
153
|
+
if (_mergedRules[normalizedUrl]) {
|
|
154
|
+
return deepClone(_mergedRules[normalizedUrl]);
|
|
145
155
|
}
|
|
146
|
-
const patterns = getMatchingPatterns(
|
|
156
|
+
const patterns = getMatchingPatterns(normalizedUrl);
|
|
147
157
|
if (!patterns.length)
|
|
148
158
|
return null;
|
|
149
159
|
const mergedConfig = {};
|
|
@@ -152,11 +162,12 @@ function createRouteRules() {
|
|
|
152
162
|
const patternConfig = _mergedRules[pattern] || _rules[pattern];
|
|
153
163
|
Object.assign(mergedConfig, deepClone(patternConfig));
|
|
154
164
|
}
|
|
155
|
-
_mergedRules[
|
|
165
|
+
_mergedRules[normalizedUrl] = deepClone(mergedConfig);
|
|
156
166
|
return mergedConfig;
|
|
157
167
|
}
|
|
158
168
|
function computeMergedConfig(url, patterns) {
|
|
159
|
-
const
|
|
169
|
+
const normalizedUrl = withoutTrailingSlash(withLeadingSlash(url));
|
|
170
|
+
const matchingPatterns = patterns || getMatchingPatterns(normalizedUrl);
|
|
160
171
|
if (!matchingPatterns.length)
|
|
161
172
|
return {};
|
|
162
173
|
const allPatternsHaveCache = matchingPatterns.every((pattern) => !!_mergedRules[pattern]);
|
|
@@ -166,17 +177,18 @@ function createRouteRules() {
|
|
|
166
177
|
return matchingPatterns.reduceRight((result, pattern) => mergeConfigs(result, deepClone(_rules[pattern])), {});
|
|
167
178
|
}
|
|
168
179
|
function getParams(url, pattern) {
|
|
169
|
-
return extractParams(url, pattern);
|
|
180
|
+
return extractParams(withoutTrailingSlash(withLeadingSlash(url)), withoutTrailingSlash(withLeadingSlash(pattern)));
|
|
170
181
|
}
|
|
171
182
|
function match(url) {
|
|
172
|
-
const
|
|
183
|
+
const normalizedUrl = withoutTrailingSlash(withLeadingSlash(url));
|
|
184
|
+
const patterns = getMatchingPatterns(normalizedUrl);
|
|
173
185
|
if (!patterns.length)
|
|
174
186
|
return null;
|
|
175
187
|
const bestPattern = patterns[0];
|
|
176
188
|
return {
|
|
177
189
|
pattern: bestPattern,
|
|
178
190
|
config: deepClone(_rules[bestPattern]),
|
|
179
|
-
params: getParams(
|
|
191
|
+
params: getParams(normalizedUrl, bestPattern)
|
|
180
192
|
};
|
|
181
193
|
}
|
|
182
194
|
function clear() {
|
|
@@ -193,16 +205,18 @@ function createRouteRules() {
|
|
|
193
205
|
updateMergeRules();
|
|
194
206
|
}
|
|
195
207
|
for (const url of urls) {
|
|
196
|
-
|
|
197
|
-
|
|
208
|
+
const normalizedUrl = withoutTrailingSlash(withLeadingSlash(url));
|
|
209
|
+
if (!_mergedRules[normalizedUrl]) {
|
|
210
|
+
const patterns = getMatchingPatterns(normalizedUrl);
|
|
198
211
|
if (patterns.length) {
|
|
199
|
-
_mergedRules[
|
|
212
|
+
_mergedRules[normalizedUrl] = computeMergedConfig(normalizedUrl, patterns);
|
|
200
213
|
}
|
|
201
214
|
}
|
|
202
215
|
}
|
|
203
216
|
}
|
|
204
217
|
function setMergedRule(url, config) {
|
|
205
|
-
|
|
218
|
+
const normalizedUrl = withoutTrailingSlash(withLeadingSlash(url));
|
|
219
|
+
_mergedRules[normalizedUrl] = deepClone(config);
|
|
206
220
|
if (url.includes("*") || url.includes(":")) {
|
|
207
221
|
_rulesModified = false;
|
|
208
222
|
}
|
package/dist/cli/dev.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import 'silgi/runtime/meta';
|
|
|
16
16
|
import 'silgi/types';
|
|
17
17
|
import 'unimport';
|
|
18
18
|
import '../_chunks/routeRules.mjs';
|
|
19
|
+
import 'ufo';
|
|
19
20
|
import './env.mjs';
|
|
20
21
|
import '@clack/prompts';
|
|
21
22
|
import 'dotenv';
|
|
@@ -23,7 +24,6 @@ import 'mlly';
|
|
|
23
24
|
import 'dev-jiti';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import 'defu';
|
|
26
|
-
import 'ufo';
|
|
27
27
|
import 'globby';
|
|
28
28
|
import 'ignore';
|
|
29
29
|
import '@oxc-parser/wasm';
|
package/dist/cli/prepare.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import 'silgi/runtime/meta';
|
|
|
13
13
|
import 'silgi/types';
|
|
14
14
|
import 'unimport';
|
|
15
15
|
import '../_chunks/routeRules.mjs';
|
|
16
|
+
import 'ufo';
|
|
16
17
|
import './env.mjs';
|
|
17
18
|
import '@clack/prompts';
|
|
18
19
|
import 'dotenv';
|
|
@@ -22,7 +23,6 @@ import './compatibility.mjs';
|
|
|
22
23
|
import 'semver/functions/satisfies.js';
|
|
23
24
|
import 'node:url';
|
|
24
25
|
import 'defu';
|
|
25
|
-
import 'ufo';
|
|
26
26
|
import 'globby';
|
|
27
27
|
import 'ignore';
|
|
28
28
|
import '@oxc-parser/wasm';
|
package/dist/core/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { getContext } from 'unctx';
|
|
|
6
6
|
import { Buffer } from 'node:buffer';
|
|
7
7
|
import { klona } from 'klona';
|
|
8
8
|
import { createStorage as createStorage$1, builtinDrivers, prefixStorage } from 'unstorage';
|
|
9
|
+
import 'ufo';
|
|
9
10
|
|
|
10
11
|
const silgiCtx = getContext("silgi");
|
|
11
12
|
function useSilgi() {
|
package/dist/kit/index.d.mts
CHANGED
|
@@ -52,13 +52,13 @@ declare function serviceParseModule(params: ServiceParseModule): ServiceParseMod
|
|
|
52
52
|
declare function parseServices(silgi: SilgiCLI,
|
|
53
53
|
/**
|
|
54
54
|
* url: /coreApi/basket/post/createBasket
|
|
55
|
-
* pathLength: 4
|
|
55
|
+
* pathLength: 4 or [1, 2, 3, 4] to support multiple path depths
|
|
56
56
|
* 1: coreApi
|
|
57
57
|
* 2: basket
|
|
58
58
|
* 3: post
|
|
59
59
|
* 4: createBasket
|
|
60
60
|
*/
|
|
61
|
-
pathLength?: number, servicesObject?: Record<string, any>, currentPath?: string[]): Record<string, Record<string, any>>;
|
|
61
|
+
pathLength?: number | number[], servicesObject?: Record<string, any>, currentPath?: string[]): Record<string, Record<string, any>>;
|
|
62
62
|
|
|
63
63
|
declare function prettyPath(p: string, highlight?: boolean): string;
|
|
64
64
|
declare function resolveSilgiPath(path: string, silgiCLIOptions: SilgiCLI['options'], base?: string): string;
|
package/dist/kit/index.d.ts
CHANGED
|
@@ -52,13 +52,13 @@ declare function serviceParseModule(params: ServiceParseModule): ServiceParseMod
|
|
|
52
52
|
declare function parseServices(silgi: SilgiCLI,
|
|
53
53
|
/**
|
|
54
54
|
* url: /coreApi/basket/post/createBasket
|
|
55
|
-
* pathLength: 4
|
|
55
|
+
* pathLength: 4 or [1, 2, 3, 4] to support multiple path depths
|
|
56
56
|
* 1: coreApi
|
|
57
57
|
* 2: basket
|
|
58
58
|
* 3: post
|
|
59
59
|
* 4: createBasket
|
|
60
60
|
*/
|
|
61
|
-
pathLength?: number, servicesObject?: Record<string, any>, currentPath?: string[]): Record<string, Record<string, any>>;
|
|
61
|
+
pathLength?: number | number[], servicesObject?: Record<string, any>, currentPath?: string[]): Record<string, Record<string, any>>;
|
|
62
62
|
|
|
63
63
|
declare function prettyPath(p: string, highlight?: boolean): string;
|
|
64
64
|
declare function resolveSilgiPath(path: string, silgiCLIOptions: SilgiCLI['options'], base?: string): string;
|
package/dist/kit/index.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { hash as hash$1 } from 'ohash';
|
|
|
10
10
|
import { camelCase, snakeCase } from 'scule';
|
|
11
11
|
import { useSilgi, tryUseSilgiCLI, useSilgiCLI, tryUseSilgi } from 'silgi/core';
|
|
12
12
|
import { defu } from 'defu';
|
|
13
|
+
import { withLeadingSlash } from 'ufo';
|
|
13
14
|
import { existsSync, promises } from 'node:fs';
|
|
14
15
|
import { fileURLToPath } from 'node:url';
|
|
15
16
|
import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
|
|
@@ -205,22 +206,30 @@ const parseRouteRules = serviceParseModule(({
|
|
|
205
206
|
const routeRules = node.routeRules;
|
|
206
207
|
if (!routeRules)
|
|
207
208
|
return;
|
|
208
|
-
|
|
209
|
+
let removeMethod = basePath.split("/").slice(0, -1).join("/");
|
|
210
|
+
removeMethod = withLeadingSlash(removeMethod);
|
|
211
|
+
if (routeRules.splat)
|
|
212
|
+
removeMethod = `${removeMethod}/*`;
|
|
213
|
+
else if (routeRules.doubleSplat)
|
|
214
|
+
removeMethod = `${removeMethod}/**`;
|
|
215
|
+
removeMethod = removeMethod.replace(/\/{2,}/g, "/");
|
|
216
|
+
delete routeRules.splat;
|
|
217
|
+
delete routeRules.doubleSplat;
|
|
209
218
|
silgi.routeRules.addRule(removeMethod, routeRules);
|
|
210
219
|
});
|
|
211
|
-
function parseServices(silgi, pathLength = 4, servicesObject, currentPath = []) {
|
|
220
|
+
function parseServices(silgi, pathLength = [4, 3, 2, 1], servicesObject, currentPath = []) {
|
|
212
221
|
const modulesURIs = {};
|
|
213
222
|
silgi.options.serviceParseModules.push(parseGraphQLServices);
|
|
214
223
|
silgi.options.serviceParseModules.push(parseRouteRules);
|
|
224
|
+
const pathLengths = Array.isArray(pathLength) ? pathLength : [pathLength];
|
|
215
225
|
function traverse(node, path = []) {
|
|
216
226
|
if (!node || typeof node !== "object")
|
|
217
227
|
return;
|
|
218
|
-
if (path.length
|
|
228
|
+
if (pathLengths.includes(path.length)) {
|
|
219
229
|
const basePath = path.join("/");
|
|
220
230
|
for (const handler of silgi.options.serviceParseModules) {
|
|
221
231
|
handler({ node, basePath, silgi, modulesURIs });
|
|
222
232
|
}
|
|
223
|
-
return;
|
|
224
233
|
}
|
|
225
234
|
for (const key in node) {
|
|
226
235
|
if (!["_type", "fields"].includes(key)) {
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -811,6 +811,8 @@ interface EnvOptions {
|
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
interface DefaultRouteConfig extends SilgiRuntimeRouteRulesConfig {
|
|
814
|
+
splat?: boolean;
|
|
815
|
+
doubleSplat?: boolean;
|
|
814
816
|
[key: string]: any;
|
|
815
817
|
}
|
|
816
818
|
interface DefaultRouteRules extends SilgiRuntimeRouteRules {
|
|
@@ -891,7 +893,11 @@ interface ExtendShared {
|
|
|
891
893
|
|
|
892
894
|
type EventHandlerResponse<T = undefined> = T extends undefined ? void : void | T | Promise<T>;
|
|
893
895
|
type MethodHandlerType<T> = {
|
|
896
|
+
routeRules?: DefaultRouteConfig;
|
|
897
|
+
} & {
|
|
894
898
|
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
899
|
+
routeRules?: DefaultRouteConfig;
|
|
900
|
+
} & {
|
|
895
901
|
[Method in keyof T[Action]]?: {
|
|
896
902
|
default?: {
|
|
897
903
|
input?: StandardSchemaV1.InferInput<T[Action][Method]['input']> & {
|
|
@@ -904,7 +910,7 @@ type MethodHandlerType<T> = {
|
|
|
904
910
|
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
905
911
|
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<T[Action][Method]['source']>) => EventHandlerResponse<StandardSchemaV1.InferOutput<T[Action][Method]['output']>>;
|
|
906
912
|
modules?: Partial<SilgiRuntimeActions>;
|
|
907
|
-
routeRules?:
|
|
913
|
+
routeRules?: DefaultRouteConfig;
|
|
908
914
|
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
909
915
|
};
|
|
910
916
|
} : never;
|
|
@@ -940,6 +946,8 @@ type SilgiServiceInterface<T extends BaseSchemaType<StandardSchemaV1>> = {
|
|
|
940
946
|
};
|
|
941
947
|
type ServiceType<T> = Partial<{
|
|
942
948
|
[Namespace in keyof T]: T[Namespace] extends Record<string, any> ? {
|
|
949
|
+
routeRules?: DefaultRouteConfig;
|
|
950
|
+
} & {
|
|
943
951
|
[Service in keyof T[Namespace]]?: Partial<MethodHandlerType<T[Namespace][Service]>>;
|
|
944
952
|
} : never;
|
|
945
953
|
}>;
|
|
@@ -1123,4 +1131,4 @@ interface ServiceParseModule {
|
|
|
1123
1131
|
|
|
1124
1132
|
declare const autoImportTypes: string[];
|
|
1125
1133
|
|
|
1126
|
-
export { type AppConfig, type Awaitable, type BaseNamespaceType, type BaseSchemaType, type BaseSilgiMethodType, type CaptureError, type CapturedErrorContext, type CommandType, type CreateScope, type DeepPartial, type DefaultHooks, type DefaultNamespaces, type DotenvOptions, type EnvOptions, type EventHandlerResponse, type ExtendContext, type ExtendShared, type ExtractInputFromURI, type ExtractOutputFromURI, type ExtractPathParamsFromURI, type ExtractQueryParamsFromURI, type ExtractSourceFromURI, type FrameworkContext, type GenerateAppOptions, type GraphQLJSON, type HookResult, type ImportItem, type LoadConfigOptions, type MergedRulesCache, type MergedSilgiSchema, type MethodHandlerType, type ModuleDefinition, type ModuleHookContext, type ModuleMeta, type ModuleOptionsCustom, type ModuleSetupInstallResult, type ModuleSetupReturn, type Namespaces, type NitroBuildInfo, type PrepareCore, type RequiredServiceType, type ResolvedMethodHandlerType, type ResolvedModuleMeta, type ResolvedModuleOptions, type ResolvedServiceType, type ResolvedSilgiTemplate, type RouteConfig, type RouteRules, type RouteRulesConfig, type ScanFile, type SchemaPreparationOptions, type ServiceParse, type ServiceParseModule, type ServiceType, type Silgi, type SilgiAppPlugin, type SilgiCLI, type SilgiCLIConfig, type SilgiCLIDynamicConfig, type SilgiCLIHooks, type SilgiCLIOptions, type SilgiCompatibility, type SilgiCompatibilityIssue, type SilgiCompatibilityIssues, type SilgiConfig, type SilgiEvents, type SilgiFrameworkInfo, type SilgiFunction, type SilgiHooks, type SilgiModule, type SilgiModuleInput, type SilgiModuleOptions, type SilgiNamespaces, type SilgiOperation, type SilgiOptions, type SilgiPreset, type SilgiPresetMeta, type SilgiRouteRules, type SilgiRouterTypes, type SilgiRuntimeActions, type SilgiRuntimeConfig, type SilgiRuntimeContext, type SilgiRuntimeHooks, type SilgiRuntimeMethods, type SilgiRuntimeOptions, type SilgiRuntimeRouteRules, type SilgiRuntimeRouteRulesConfig, type SilgiRuntimeSharedExtends, type SilgiRuntimeShareds, type SilgiSchema, type SilgiServiceInterface, type SilgiStorageBase, type SilgiTemplate, type SilgiURIs, type StorageConfig, type StorageKeyGenerator, type StorageKeyParams, type StorageMounts, type TSReference, type URIsTypes, autoImportTypes };
|
|
1134
|
+
export { type AppConfig, type Awaitable, type BaseNamespaceType, type BaseSchemaType, type BaseSilgiMethodType, type CaptureError, type CapturedErrorContext, type CommandType, type CreateScope, type DeepPartial, type DefaultHooks, type DefaultNamespaces, type DefaultRouteConfig, type DefaultRouteRules, type DotenvOptions, type EnvOptions, type EventHandlerResponse, type ExtendContext, type ExtendShared, type ExtractInputFromURI, type ExtractOutputFromURI, type ExtractPathParamsFromURI, type ExtractQueryParamsFromURI, type ExtractSourceFromURI, type FrameworkContext, type GenerateAppOptions, type GraphQLJSON, type HookResult, type ImportItem, type LoadConfigOptions, type MergedRulesCache, type MergedSilgiSchema, type MethodHandlerType, type ModuleDefinition, type ModuleHookContext, type ModuleMeta, type ModuleOptionsCustom, type ModuleSetupInstallResult, type ModuleSetupReturn, type Namespaces, type NitroBuildInfo, type PrepareCore, type RequiredServiceType, type ResolvedMethodHandlerType, type ResolvedModuleMeta, type ResolvedModuleOptions, type ResolvedServiceType, type ResolvedSilgiTemplate, type RouteConfig, type RouteRules, type RouteRulesConfig, type ScanFile, type SchemaPreparationOptions, type ServiceParse, type ServiceParseModule, type ServiceType, type Silgi, type SilgiAppPlugin, type SilgiCLI, type SilgiCLIConfig, type SilgiCLIDynamicConfig, type SilgiCLIHooks, type SilgiCLIOptions, type SilgiCompatibility, type SilgiCompatibilityIssue, type SilgiCompatibilityIssues, type SilgiConfig, type SilgiEvents, type SilgiFrameworkInfo, type SilgiFunction, type SilgiHooks, type SilgiModule, type SilgiModuleInput, type SilgiModuleOptions, type SilgiNamespaces, type SilgiOperation, type SilgiOptions, type SilgiPreset, type SilgiPresetMeta, type SilgiRouteRules, type SilgiRouterTypes, type SilgiRuntimeActions, type SilgiRuntimeConfig, type SilgiRuntimeContext, type SilgiRuntimeHooks, type SilgiRuntimeMethods, type SilgiRuntimeOptions, type SilgiRuntimeRouteRules, type SilgiRuntimeRouteRulesConfig, type SilgiRuntimeSharedExtends, type SilgiRuntimeShareds, type SilgiSchema, type SilgiServiceInterface, type SilgiStorageBase, type SilgiTemplate, type SilgiURIs, type StorageConfig, type StorageKeyGenerator, type StorageKeyParams, type StorageMounts, type TSReference, type URIsTypes, autoImportTypes };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -811,6 +811,8 @@ interface EnvOptions {
|
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
interface DefaultRouteConfig extends SilgiRuntimeRouteRulesConfig {
|
|
814
|
+
splat?: boolean;
|
|
815
|
+
doubleSplat?: boolean;
|
|
814
816
|
[key: string]: any;
|
|
815
817
|
}
|
|
816
818
|
interface DefaultRouteRules extends SilgiRuntimeRouteRules {
|
|
@@ -891,7 +893,11 @@ interface ExtendShared {
|
|
|
891
893
|
|
|
892
894
|
type EventHandlerResponse<T = undefined> = T extends undefined ? void : void | T | Promise<T>;
|
|
893
895
|
type MethodHandlerType<T> = {
|
|
896
|
+
routeRules?: DefaultRouteConfig;
|
|
897
|
+
} & {
|
|
894
898
|
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
899
|
+
routeRules?: DefaultRouteConfig;
|
|
900
|
+
} & {
|
|
895
901
|
[Method in keyof T[Action]]?: {
|
|
896
902
|
default?: {
|
|
897
903
|
input?: StandardSchemaV1.InferInput<T[Action][Method]['input']> & {
|
|
@@ -904,7 +910,7 @@ type MethodHandlerType<T> = {
|
|
|
904
910
|
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
905
911
|
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<T[Action][Method]['source']>) => EventHandlerResponse<StandardSchemaV1.InferOutput<T[Action][Method]['output']>>;
|
|
906
912
|
modules?: Partial<SilgiRuntimeActions>;
|
|
907
|
-
routeRules?:
|
|
913
|
+
routeRules?: DefaultRouteConfig;
|
|
908
914
|
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
909
915
|
};
|
|
910
916
|
} : never;
|
|
@@ -940,6 +946,8 @@ type SilgiServiceInterface<T extends BaseSchemaType<StandardSchemaV1>> = {
|
|
|
940
946
|
};
|
|
941
947
|
type ServiceType<T> = Partial<{
|
|
942
948
|
[Namespace in keyof T]: T[Namespace] extends Record<string, any> ? {
|
|
949
|
+
routeRules?: DefaultRouteConfig;
|
|
950
|
+
} & {
|
|
943
951
|
[Service in keyof T[Namespace]]?: Partial<MethodHandlerType<T[Namespace][Service]>>;
|
|
944
952
|
} : never;
|
|
945
953
|
}>;
|
|
@@ -1123,4 +1131,4 @@ interface ServiceParseModule {
|
|
|
1123
1131
|
|
|
1124
1132
|
declare const autoImportTypes: string[];
|
|
1125
1133
|
|
|
1126
|
-
export { type AppConfig, type Awaitable, type BaseNamespaceType, type BaseSchemaType, type BaseSilgiMethodType, type CaptureError, type CapturedErrorContext, type CommandType, type CreateScope, type DeepPartial, type DefaultHooks, type DefaultNamespaces, type DotenvOptions, type EnvOptions, type EventHandlerResponse, type ExtendContext, type ExtendShared, type ExtractInputFromURI, type ExtractOutputFromURI, type ExtractPathParamsFromURI, type ExtractQueryParamsFromURI, type ExtractSourceFromURI, type FrameworkContext, type GenerateAppOptions, type GraphQLJSON, type HookResult, type ImportItem, type LoadConfigOptions, type MergedRulesCache, type MergedSilgiSchema, type MethodHandlerType, type ModuleDefinition, type ModuleHookContext, type ModuleMeta, type ModuleOptionsCustom, type ModuleSetupInstallResult, type ModuleSetupReturn, type Namespaces, type NitroBuildInfo, type PrepareCore, type RequiredServiceType, type ResolvedMethodHandlerType, type ResolvedModuleMeta, type ResolvedModuleOptions, type ResolvedServiceType, type ResolvedSilgiTemplate, type RouteConfig, type RouteRules, type RouteRulesConfig, type ScanFile, type SchemaPreparationOptions, type ServiceParse, type ServiceParseModule, type ServiceType, type Silgi, type SilgiAppPlugin, type SilgiCLI, type SilgiCLIConfig, type SilgiCLIDynamicConfig, type SilgiCLIHooks, type SilgiCLIOptions, type SilgiCompatibility, type SilgiCompatibilityIssue, type SilgiCompatibilityIssues, type SilgiConfig, type SilgiEvents, type SilgiFrameworkInfo, type SilgiFunction, type SilgiHooks, type SilgiModule, type SilgiModuleInput, type SilgiModuleOptions, type SilgiNamespaces, type SilgiOperation, type SilgiOptions, type SilgiPreset, type SilgiPresetMeta, type SilgiRouteRules, type SilgiRouterTypes, type SilgiRuntimeActions, type SilgiRuntimeConfig, type SilgiRuntimeContext, type SilgiRuntimeHooks, type SilgiRuntimeMethods, type SilgiRuntimeOptions, type SilgiRuntimeRouteRules, type SilgiRuntimeRouteRulesConfig, type SilgiRuntimeSharedExtends, type SilgiRuntimeShareds, type SilgiSchema, type SilgiServiceInterface, type SilgiStorageBase, type SilgiTemplate, type SilgiURIs, type StorageConfig, type StorageKeyGenerator, type StorageKeyParams, type StorageMounts, type TSReference, type URIsTypes, autoImportTypes };
|
|
1134
|
+
export { type AppConfig, type Awaitable, type BaseNamespaceType, type BaseSchemaType, type BaseSilgiMethodType, type CaptureError, type CapturedErrorContext, type CommandType, type CreateScope, type DeepPartial, type DefaultHooks, type DefaultNamespaces, type DefaultRouteConfig, type DefaultRouteRules, type DotenvOptions, type EnvOptions, type EventHandlerResponse, type ExtendContext, type ExtendShared, type ExtractInputFromURI, type ExtractOutputFromURI, type ExtractPathParamsFromURI, type ExtractQueryParamsFromURI, type ExtractSourceFromURI, type FrameworkContext, type GenerateAppOptions, type GraphQLJSON, type HookResult, type ImportItem, type LoadConfigOptions, type MergedRulesCache, type MergedSilgiSchema, type MethodHandlerType, type ModuleDefinition, type ModuleHookContext, type ModuleMeta, type ModuleOptionsCustom, type ModuleSetupInstallResult, type ModuleSetupReturn, type Namespaces, type NitroBuildInfo, type PrepareCore, type RequiredServiceType, type ResolvedMethodHandlerType, type ResolvedModuleMeta, type ResolvedModuleOptions, type ResolvedServiceType, type ResolvedSilgiTemplate, type RouteConfig, type RouteRules, type RouteRulesConfig, type ScanFile, type SchemaPreparationOptions, type ServiceParse, type ServiceParseModule, type ServiceType, type Silgi, type SilgiAppPlugin, type SilgiCLI, type SilgiCLIConfig, type SilgiCLIDynamicConfig, type SilgiCLIHooks, type SilgiCLIOptions, type SilgiCompatibility, type SilgiCompatibilityIssue, type SilgiCompatibilityIssues, type SilgiConfig, type SilgiEvents, type SilgiFrameworkInfo, type SilgiFunction, type SilgiHooks, type SilgiModule, type SilgiModuleInput, type SilgiModuleOptions, type SilgiNamespaces, type SilgiOperation, type SilgiOptions, type SilgiPreset, type SilgiPresetMeta, type SilgiRouteRules, type SilgiRouterTypes, type SilgiRuntimeActions, type SilgiRuntimeConfig, type SilgiRuntimeContext, type SilgiRuntimeHooks, type SilgiRuntimeMethods, type SilgiRuntimeOptions, type SilgiRuntimeRouteRules, type SilgiRuntimeRouteRulesConfig, type SilgiRuntimeSharedExtends, type SilgiRuntimeShareds, type SilgiSchema, type SilgiServiceInterface, type SilgiStorageBase, type SilgiTemplate, type SilgiURIs, type StorageConfig, type StorageKeyGenerator, type StorageKeyParams, type StorageMounts, type TSReference, type URIsTypes, autoImportTypes };
|