silgi 0.24.18 → 0.24.19

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.
@@ -0,0 +1,62 @@
1
+ import satisfies from 'semver/functions/satisfies.js';
2
+ import { useSilgi } from 'silgi';
3
+ import { version } from 'silgi/meta';
4
+ import consola from 'consola';
5
+ import { colors } from 'consola/utils';
6
+ import { getProperty } from 'dot-prop';
7
+ import { relative, resolve } from 'pathe';
8
+
9
+ const SEMANTIC_VERSION_RE = /-\d+\.[0-9a-f]+/;
10
+ function normalizeSemanticVersion(version) {
11
+ return version.replace(SEMANTIC_VERSION_RE, "");
12
+ }
13
+ const SILGI_VERSION_RE = /^v/g;
14
+ async function checkSilgiCompatibility(constraints, silgi = useSilgi()) {
15
+ const issues = [];
16
+ if (constraints.silgi) {
17
+ const _silgiVersion = version.replace(SILGI_VERSION_RE, "");
18
+ if (!satisfies(normalizeSemanticVersion(_silgiVersion), constraints.silgi, { includePrerelease: true })) {
19
+ issues.push({
20
+ name: "silgi",
21
+ message: `Silgi version \`${constraints.silgi}\` is required but currently using \`${version}\``
22
+ });
23
+ }
24
+ }
25
+ await silgi.callHook("kit:compatibility", constraints, issues);
26
+ issues.toString = () => issues.map((issue) => ` - [${issue.name}] ${issue.message}`).join("\n");
27
+ return issues;
28
+ }
29
+ function hasInstalledModule(moduleKey, silgi = useSilgi()) {
30
+ const find = silgi.scanModules.find(({ meta }) => meta.configKey === moduleKey);
31
+ return find?.installed ?? false;
32
+ }
33
+
34
+ function prettyPath(p, highlight = true) {
35
+ p = relative(process.cwd(), p);
36
+ return highlight ? colors.cyan(p) : p;
37
+ }
38
+ function resolveSilgiPath(path, silgiCLIOptions, base) {
39
+ if (typeof path !== "string") {
40
+ throw new TypeError(`Invalid path: ${path}`);
41
+ }
42
+ path = _compilePathTemplate(path)(silgiCLIOptions);
43
+ for (const base2 in silgiCLIOptions.alias) {
44
+ if (path.startsWith(base2)) {
45
+ path = silgiCLIOptions.alias[base2] + path.slice(base2.length);
46
+ }
47
+ }
48
+ return resolve(base || silgiCLIOptions.srcDir, path);
49
+ }
50
+ function _compilePathTemplate(contents) {
51
+ return (params) => contents.replace(/\{\{ ?([\w.]+) ?\}\}/g, (_, match) => {
52
+ const val = getProperty(params, match);
53
+ if (!val) {
54
+ consola.warn(
55
+ `cannot resolve template param '${match}' in ${contents.slice(0, 20)}`
56
+ );
57
+ }
58
+ return val || `${match}`;
59
+ });
60
+ }
61
+
62
+ export { checkSilgiCompatibility as c, hasInstalledModule as h, prettyPath as p, resolveSilgiPath as r };
package/dist/cli/dev.mjs CHANGED
@@ -3,52 +3,15 @@ import { watch } from 'chokidar';
3
3
  import { defineCommand, runCommand } from 'citty';
4
4
  import consola from 'consola';
5
5
  import { join } from 'pathe';
6
- import { useSilgiCLI } from 'silgi';
6
+ import { useSilgi, reloadScan, silgiClose } from 'silgi';
7
7
  import { version } from 'silgi/meta';
8
- import { a as silgiCLIIClose } from '../_chunks/routeRules.mjs';
9
8
  import { c as commonArgs, p as prepare } from './prepare.mjs';
10
- import 'unctx';
11
- import 'ufo';
12
- import './writeTypesAndFiles.mjs';
13
- import 'knitwork';
14
- import 'silgi/kit';
9
+ import 'node:child_process';
15
10
  import 'node:fs';
16
- import 'node:fs/promises';
17
- import 'hookable';
18
- import 'silgi/runtime/meta';
19
- import 'unimport';
20
11
  import '@clack/prompts';
21
- import 'dotenv';
22
- import 'mlly';
23
12
  import 'dev-jiti';
24
- import './compatibility.mjs';
25
- import 'semver/functions/satisfies.js';
26
- import 'node:url';
27
- import 'defu';
28
- import 'exsolve';
29
- import 'untyped';
30
- import 'globby';
31
- import 'ignore';
32
- import '@oxc-parser/wasm';
33
- import 'klona';
34
- import 'silgi/runtime';
35
- import 'unstorage';
36
- import './types.mjs';
37
- import 'c12';
38
- import 'compatx';
39
- import 'klona/full';
40
- import 'std-env';
41
- import 'consola/utils';
42
- import 'escape-string-regexp';
43
- import 'pkg-types';
44
- import 'pathe/utils';
45
- import 'node:child_process';
46
13
  import 'picocolors';
47
-
48
- async function reloadScan(path, _stats) {
49
- const silgi = useSilgiCLI();
50
- await silgi.callHook("reload:scan", path, _stats);
51
- }
14
+ import './env.mjs';
52
15
 
53
16
  const dev = defineCommand({
54
17
  meta: {
@@ -71,7 +34,7 @@ const dev = defineCommand({
71
34
  await runCommand(prepare, {
72
35
  rawArgs: ["--commands", "run", "--dev", "true"]
73
36
  });
74
- const silgi = useSilgiCLI();
37
+ const silgi = useSilgi();
75
38
  silgi.options.watchOptions.ignored ??= [];
76
39
  silgi.options.watchOptions.ignoreInitial = true;
77
40
  if (Array.isArray(silgi.options.watchOptions.ignored)) {
@@ -120,7 +83,7 @@ const dev = defineCommand({
120
83
  if (watcher) {
121
84
  watcher.close();
122
85
  }
123
- await silgiCLIIClose();
86
+ await silgiClose();
124
87
  process.exit(0);
125
88
  });
126
89
  consola.withTag("silgi").success("Prepare completed");
@@ -0,0 +1,40 @@
1
+ import * as p from '@clack/prompts';
2
+ import { setupDotenv } from 'silgi';
3
+
4
+ let initialized = false;
5
+ async function prepareEnv(silgiConfig) {
6
+ if (initialized)
7
+ return;
8
+ initialized = true;
9
+ const customEnvironments = silgiConfig.environments;
10
+ const environment = silgiConfig.activeEnvironment ? silgiConfig.activeEnvironment : await p.select({
11
+ message: "Select an environment",
12
+ options: customEnvironments?.length > 0 ? customEnvironments.map((env) => ({
13
+ label: env.fileName,
14
+ value: env.fileName
15
+ })) : [
16
+ { label: "Development (.env.dev)", value: "dev" },
17
+ { label: "Docker (.env.docker)", value: "docker" },
18
+ { label: "Staging (.env.staging)", value: "staging" },
19
+ { label: "Testing (.env.testing)", value: "testing" },
20
+ { label: "Production (.env)", value: ".env" }
21
+ ]
22
+ });
23
+ const findEnv = customEnvironments?.find((env) => env.fileName === environment);
24
+ if (findEnv) {
25
+ await setupDotenv({
26
+ cwd: findEnv.cwd || silgiConfig.rootDir,
27
+ interpolate: findEnv.interpolate,
28
+ fileName: findEnv.fileName,
29
+ env: findEnv.env
30
+ });
31
+ } else {
32
+ await setupDotenv({
33
+ cwd: silgiConfig.rootDir,
34
+ interpolate: true,
35
+ fileName: environment === ".env" ? ".env" : `.env.${environment}`
36
+ });
37
+ }
38
+ }
39
+
40
+ export { prepareEnv as p };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.24.18";
4
+ const version = "0.24.19";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -3,45 +3,13 @@ import { readFileSync } from 'node:fs';
3
3
  import { defineCommand, runCommand } from 'citty';
4
4
  import { consola } from 'consola';
5
5
  import { resolve } from 'pathe';
6
+ import { loadOptions } from 'silgi';
6
7
  import { version } from 'silgi/meta';
7
8
  import { c as commonArgs, p as prepare } from './prepare.mjs';
8
- import { l as loadOptions } from './types.mjs';
9
- import './writeTypesAndFiles.mjs';
10
- import 'knitwork';
11
- import 'silgi/kit';
12
- import 'node:fs/promises';
13
- import 'hookable';
14
- import 'silgi';
15
- import 'silgi/runtime/meta';
16
- import 'unimport';
17
- import '../_chunks/routeRules.mjs';
18
- import 'unctx';
19
- import 'ufo';
20
9
  import '@clack/prompts';
21
- import 'dotenv';
22
- import 'mlly';
23
10
  import 'dev-jiti';
24
- import './compatibility.mjs';
25
- import 'semver/functions/satisfies.js';
26
- import 'node:url';
27
- import 'defu';
28
- import 'exsolve';
29
- import 'untyped';
30
- import 'globby';
31
- import 'ignore';
32
- import '@oxc-parser/wasm';
33
- import 'klona';
34
- import 'silgi/runtime';
35
- import 'unstorage';
36
- import 'pathe/utils';
37
11
  import 'picocolors';
38
- import 'c12';
39
- import 'compatx';
40
- import 'klona/full';
41
- import 'std-env';
42
- import 'consola/utils';
43
- import 'escape-string-regexp';
44
- import 'pkg-types';
12
+ import './env.mjs';
45
13
 
46
14
  const install = defineCommand({
47
15
  meta: {
@@ -1,16 +1,14 @@
1
1
  import { defineCommand, runCommand } from 'citty';
2
2
  import { resolve } from 'pathe';
3
+ import { useSilgi, loadOptions, silgiClose, createSilgi, prepare as prepare$2, writeTypesAndFiles, writeCoreFile, prepareBuild } from 'silgi';
3
4
  import { version } from 'silgi/meta';
4
- import { d as prepareEnv, c as createSilgiCLI, a as prepare$2, b as writeTypesAndFiles, w as writeCoreFile, p as prepareBuild } from './writeTypesAndFiles.mjs';
5
5
  import { execSync } from 'node:child_process';
6
6
  import { readFileSync } from 'node:fs';
7
7
  import * as p from '@clack/prompts';
8
8
  import { consola } from 'consola';
9
9
  import { createJiti } from 'dev-jiti';
10
10
  import color from 'picocolors';
11
- import { useSilgiCLI } from 'silgi';
12
- import { a as silgiCLIIClose } from '../_chunks/routeRules.mjs';
13
- import { l as loadOptions } from './types.mjs';
11
+ import { p as prepareEnv } from './env.mjs';
14
12
 
15
13
  const commonArgs = {
16
14
  dir: {
@@ -53,7 +51,7 @@ const run = defineCommand({
53
51
  consola.error("Silgi not found");
54
52
  return;
55
53
  }
56
- const silgi = useSilgiCLI();
54
+ const silgi = useSilgi();
57
55
  const tags = args.tag?.split(",").map((t) => t.trim());
58
56
  p.intro(color.bold(`Silgi CLI ${color.green(`v${version}`)}`));
59
57
  const silgiConfig = await loadOptions({});
@@ -167,7 +165,7 @@ const run = defineCommand({
167
165
  alias: silgiConfig.alias
168
166
  });
169
167
  let cleanHandler = cmd.handler.handler.replace(/\n/g, "");
170
- cleanHandler = `import { silgiCLICtx } from 'silgi'
168
+ cleanHandler = `import { silgiCtx } from 'silgi'
171
169
  ${cleanHandler}
172
170
  `;
173
171
  await jiti.evalModule(cleanHandler, {
@@ -178,7 +176,7 @@ const run = defineCommand({
178
176
  });
179
177
  }
180
178
  }
181
- await silgiCLIIClose();
179
+ await silgiClose();
182
180
  }
183
181
  });
184
182
 
@@ -218,7 +216,7 @@ const prepare = defineCommand({
218
216
  },
219
217
  async run({ args }) {
220
218
  const rootDir = resolve(args.dir || args._dir || ".");
221
- const silgi = await createSilgiCLI({
219
+ const silgi = await createSilgi({
222
220
  rootDir,
223
221
  dev: args.dev || args.stub,
224
222
  stub: args.stub,
@@ -226,7 +224,7 @@ const prepare = defineCommand({
226
224
  commandType: "prepare",
227
225
  activeEnvironment: args.env
228
226
  });
229
- await prepare$2();
227
+ await prepare$2(silgi);
230
228
  await writeTypesAndFiles(silgi);
231
229
  await writeCoreFile(silgi);
232
230
  await prepareBuild(silgi);
package/dist/index.d.mts CHANGED
@@ -1,8 +1,260 @@
1
- export { BaseError, ErrorCategory, ErrorFactory, ErrorMetadata, ErrorSeverity, HttpStatus, SilgiError, autoImportTypes, createSchema, createService, createShared, createSilgi, createStorage, getEvent, getEventContext, isBaseError, mergeSchemas, mergeServices, mergeShared, parseURI, replaceRuntimeValues, silgi, silgiCLICtx, silgiCtx, storageMount, tryUseSilgi, tryUseSilgiCLI, useSilgi, useSilgiCLI, useSilgiStorage } from './core/index.mjs';
2
- import { SilgiCLI, SilgiCLIConfig, LoadConfigOptions } from 'silgi/types';
3
- import 'unctx';
4
- import '@standard-schema/spec';
5
- import 'unstorage';
1
+ import * as unctx from 'unctx';
2
+ import { Silgi, SilgiCLI, SilgiConfig, SilgiEvents, SilgiFunction, SilgiOperation, MergedSilgiSchema, ServiceType, SilgiSchema, RequiredServiceType, SilgiRuntimeSharedsExtend, SilgiRuntimeContext, DefaultNamespaces, BaseSchemaType, SilgiRuntimeShareds, StorageConfig, SilgiStorageBase, SilgiCLIConfig, LoadConfigOptions, SilgiCLIOptions, DotenvOptions } from 'silgi/types';
3
+ import { StandardSchemaV1 } from '@standard-schema/spec';
4
+ import { Storage, StorageValue } from 'unstorage';
5
+ import { Stats } from 'node:fs';
6
+
7
+ declare const silgiAppCtx: unctx.UseContext<Silgi>;
8
+ declare const silgiCtx: unctx.UseContext<SilgiCLI>;
9
+ declare function useSilgiApp(): Silgi;
10
+ /**
11
+ * Get access to Nuxt instance.
12
+ *
13
+ * Returns null if Nuxt instance is unavailable.
14
+ * @example
15
+ * ```js
16
+ * const silgi = tryUseSilgiApp()
17
+ * if (silgi) {
18
+ * // Do something
19
+ * }
20
+ * ```
21
+ */
22
+ declare function tryUseSilgiApp(): Silgi | null;
23
+ declare function useSilgi(): SilgiCLI;
24
+ declare function silgiClose(): Promise<void>;
25
+ declare function tryUseSilgi(): SilgiCLI | null;
26
+
27
+ declare function createSilgiApp(config: SilgiConfig): Promise<Silgi>;
28
+
29
+ declare function silgi(event?: SilgiEvents | Record<string, any>): SilgiFunction;
30
+
31
+ interface RouteTemplateValidator {
32
+ (value: string): boolean;
33
+ }
34
+ interface RouteTemplateConfig {
35
+ pattern: string;
36
+ validators?: Record<string, RouteTemplateValidator>;
37
+ }
38
+ type URITemplate = string | RouteTemplateConfig;
39
+ declare function parseURI(uri: string, uris: Record<string, URITemplate>): SilgiOperation;
40
+
41
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
42
+ declare function mergeSchemas<T extends MergedSilgiSchema[]>(typesOrArray: [...T] | T): UnionToIntersection<T[number]>;
43
+ declare function mergeServices<T extends ServiceType<SilgiSchema>[]>(servicesOrArray: [...T] | T): RequiredServiceType<SilgiSchema>;
44
+ declare function mergeShared<T extends SilgiRuntimeSharedsExtend[]>(sharedOrArray: [...T] | T): UnionToIntersection<T[number]>;
45
+
46
+ declare function getEvent<T extends SilgiEvents>(event?: SilgiEvents): T;
47
+ declare function getEventContext<T extends SilgiRuntimeContext>(event?: SilgiEvents): T;
48
+
49
+ declare function createSchema<T extends Partial<Record<keyof DefaultNamespaces, Record<string, BaseSchemaType<StandardSchemaV1>>>>>(silgiType: T): {
50
+ [K in keyof T]: {
51
+ [P in keyof T[K]]: T[K][P];
52
+ };
53
+ };
54
+
55
+ declare function createService<T extends SilgiSchema>(variables: ServiceType<T>): ServiceType<T>;
56
+
57
+ declare function createShared(shared: Partial<SilgiRuntimeShareds>): SilgiRuntimeShareds;
58
+
59
+ /**
60
+ * Recursively replaces values starting with 'runtime.' with their actual values from runtime config
61
+ */
62
+ declare function replaceRuntimeValues(obj: any, runtime: any): any;
63
+
64
+ declare function createStorage(silgi: Silgi): Promise<Storage<StorageValue>>;
65
+ declare function useSilgiStorage<T extends StorageValue = StorageValue>(base?: StorageConfig<T>['base'] | (string & {})): Storage<T>;
66
+
67
+ declare enum HttpStatus {
68
+ /** [100] Server has received the request headers and client should proceed to send the request body */
69
+ CONTINUE = 100,
70
+ /** [101] Server is switching protocols according to Upgrade header */
71
+ SWITCHING_PROTOCOLS = 101,
72
+ /** [102] Server is processing the request but no response is available yet */
73
+ PROCESSING = 102,
74
+ /** [103] Server is likely to send a final response with the header fields in the informational response */
75
+ EARLY_HINTS = 103,
76
+ /** [200] Request succeeded and response contains requested data */
77
+ OK = 200,
78
+ /** [201] Request succeeded and new resource has been created */
79
+ CREATED = 201,
80
+ /** [202] Request accepted for processing but processing not completed */
81
+ ACCEPTED = 202,
82
+ /** [203] Request processed successfully but response may be from another source */
83
+ NON_AUTHORITATIVE_INFORMATION = 203,
84
+ /** [204] Request processed successfully but response has no content */
85
+ NO_CONTENT = 204,
86
+ /** [205] Server fulfilled the request and client should reset the document view */
87
+ RESET_CONTENT = 205,
88
+ /** [206] Server delivered only part of the resource due to range header */
89
+ PARTIAL_CONTENT = 206,
90
+ /** [207] Response conveys information about multiple resources for XML messages */
91
+ MULTI_STATUS = 207,
92
+ /** [208] Members of DAV binding have already been enumerated and not included again */
93
+ ALREADY_REPORTED = 208,
94
+ /** [226] Server has fulfilled a GET request, response is result of transformations */
95
+ IM_USED = 226,
96
+ /** [300] Multiple options for the resource from which client may choose */
97
+ MULTIPLE_CHOICES = 300,
98
+ /** [301] Resource permanently moved to new URL */
99
+ MOVED_PERMANENTLY = 301,
100
+ /** [302] Resource temporarily moved to different URL */
101
+ FOUND = 302,
102
+ /** [303] Response to request found at another URL using GET */
103
+ SEE_OTHER = 303,
104
+ /** [304] Resource has not been modified since last requested */
105
+ NOT_MODIFIED = 304,
106
+ /** [305] Deprecated. Resource must be accessed through proxy */
107
+ USE_PROXY = 305,
108
+ /** [307] Resource temporarily moved to different URL, keep method */
109
+ TEMPORARY_REDIRECT = 307,
110
+ /** [308] Resource permanently moved to different URL, keep method */
111
+ PERMANENT_REDIRECT = 308,
112
+ /** [400] Request malformed, syntax error or invalid request */
113
+ BAD_REQUEST = 400,
114
+ /** [401] Request requires user authentication or authorization */
115
+ UNAUTHORIZED = 401,
116
+ /** [402] Reserved for future use, payment required */
117
+ PAYMENT_REQUIRED = 402,
118
+ /** [403] Server understood request but refuses to authorize it */
119
+ FORBIDDEN = 403,
120
+ /** [404] Server cannot find the requested resource */
121
+ NOT_FOUND = 404,
122
+ /** [405] Request method (GET, POST, etc.) not supported for this resource */
123
+ METHOD_NOT_ALLOWED = 405,
124
+ /** [406] Resource cannot generate response matching accept headers */
125
+ NOT_ACCEPTABLE = 406,
126
+ /** [407] Client must first authenticate with the proxy */
127
+ PROXY_AUTHENTICATION_REQUIRED = 407,
128
+ /** [408] Server timed out waiting for the request */
129
+ REQUEST_TIMEOUT = 408,
130
+ /** [409] Request conflicts with current state of the server */
131
+ CONFLICT = 409,
132
+ /** [410] Resource requested is no longer available and will not be available again */
133
+ GONE = 410,
134
+ /** [411] Server requires Content-Length header field */
135
+ LENGTH_REQUIRED = 411,
136
+ /** [412] Precondition given in request headers evaluated to false */
137
+ PRECONDITION_FAILED = 412,
138
+ /** [413] Request entity larger than limits defined by server */
139
+ PAYLOAD_TOO_LARGE = 413,
140
+ /** [414] URI requested by client is longer than server can interpret */
141
+ URI_TOO_LONG = 414,
142
+ /** [415] Media format of requested data not supported by server */
143
+ UNSUPPORTED_MEDIA_TYPE = 415,
144
+ /** [416] Range specified by Range header cannot be fulfilled */
145
+ RANGE_NOT_SATISFIABLE = 416,
146
+ /** [417] Expectation indicated by Expect header cannot be met */
147
+ EXPECTATION_FAILED = 417,
148
+ /** [418] April Fools' joke by RFC 2324 - Server refuses to brew coffee in a teapot */
149
+ IM_A_TEAPOT = 418,
150
+ /** [421] Request directed at a server that is not configured to produce a response */
151
+ MISDIRECTED_REQUEST = 421,
152
+ /** [422] Server understands content type but cannot process contained instructions */
153
+ UNPROCESSABLE_ENTITY = 422,
154
+ /** [423] Requested resource is currently locked */
155
+ LOCKED = 423,
156
+ /** [424] Request failed due to failure of a previous request */
157
+ FAILED_DEPENDENCY = 424,
158
+ /** [425] Server is unwilling to risk processing a request that might be replayed */
159
+ TOO_EARLY = 425,
160
+ /** [426] Server requires client to upgrade to a different protocol */
161
+ UPGRADE_REQUIRED = 426,
162
+ /** [428] Origin server requires request to be conditional */
163
+ PRECONDITION_REQUIRED = 428,
164
+ /** [429] User has sent too many requests in a given time period */
165
+ TOO_MANY_REQUESTS = 429,
166
+ /** [431] Server refusing to process request due to oversized headers */
167
+ REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
168
+ /** [451] Server denies access for legal reasons (e.g., censorship) */
169
+ UNAVAILABLE_FOR_LEGAL_REASONS = 451,
170
+ /** [500] Generic server error, no specific message */
171
+ INTERNAL_SERVER_ERROR = 500,
172
+ /** [501] Server does not recognize method or lacks ability to fulfill */
173
+ NOT_IMPLEMENTED = 501,
174
+ /** [502] Bad response received from upstream server */
175
+ BAD_GATEWAY = 502,
176
+ /** [503] Server temporarily unavailable (overloaded/maintenance) */
177
+ SERVICE_UNAVAILABLE = 503,
178
+ /** [504] Gateway server did not get response from upstream server */
179
+ GATEWAY_TIMEOUT = 504,
180
+ /** [505] Server does not support the HTTP protocol version */
181
+ HTTP_VERSION_NOT_SUPPORTED = 505,
182
+ /** [506] Server has a circular reference in content negotiation */
183
+ VARIANT_ALSO_NEGOTIATES = 506,
184
+ /** [507] Server has insufficient storage to complete request */
185
+ INSUFFICIENT_STORAGE = 507,
186
+ /** [508] Server detected an infinite loop while processing request */
187
+ LOOP_DETECTED = 508,
188
+ /** [510] Further extensions needed for server to fulfill request */
189
+ NOT_EXTENDED = 510,
190
+ /** [511] Client needs to authenticate to gain network access */
191
+ NETWORK_AUTHENTICATION_REQUIRED = 511
192
+ }
193
+ declare enum ErrorSeverity {
194
+ DEBUG = "DEBUG",
195
+ INFO = "INFO",
196
+ WARNING = "WARNING",
197
+ ERROR = "ERROR",
198
+ CRITICAL = "CRITICAL"
199
+ }
200
+ declare enum ErrorCategory {
201
+ AUTHENTICATION = "auth",
202
+ AUTHORIZATION = "authorization",
203
+ VALIDATION = "validation",
204
+ BUSINESS = "business",
205
+ INFRASTRUCTURE = "infrastructure",
206
+ EXTERNAL = "external",
207
+ UNKNOWN = "unknown"
208
+ }
209
+ interface ErrorMetadata {
210
+ timestamp: number;
211
+ correlationId?: string;
212
+ requestId?: string;
213
+ userId?: string;
214
+ path?: string;
215
+ source?: string;
216
+ [key: string]: unknown;
217
+ }
218
+ interface BaseError {
219
+ code: number;
220
+ message: string;
221
+ category: ErrorCategory;
222
+ severity: ErrorSeverity;
223
+ httpStatus: HttpStatus;
224
+ metadata?: ErrorMetadata;
225
+ cause?: Error;
226
+ context?: Record<string, unknown>;
227
+ }
228
+ declare class ErrorFactory {
229
+ private static createMetadata;
230
+ static create(options: Partial<BaseError> & {
231
+ message: string;
232
+ }): SilgiError;
233
+ static authenticationError(message: string, context?: Record<string, unknown>): SilgiError;
234
+ static authorizationError(message: string, context?: Record<string, unknown>): SilgiError;
235
+ static validationError(message: string, context?: Record<string, unknown>): SilgiError;
236
+ static notFoundError(message: string, context?: Record<string, unknown>): SilgiError;
237
+ static internalError(message: string, cause?: Error): SilgiError;
238
+ }
239
+ declare class SilgiError extends Error implements BaseError {
240
+ readonly code: number;
241
+ readonly category: ErrorCategory;
242
+ readonly severity: ErrorSeverity;
243
+ readonly httpStatus: HttpStatus;
244
+ readonly metadata: ErrorMetadata;
245
+ readonly context?: Record<string, unknown>;
246
+ readonly cause?: Error;
247
+ constructor(error: BaseError);
248
+ toString(): string;
249
+ toJSON(): Record<string, unknown>;
250
+ static isError(error: unknown): error is SilgiError;
251
+ static from(error: unknown): SilgiError;
252
+ }
253
+ declare function isBaseError(error: unknown): error is BaseError;
254
+
255
+ declare function storageMount<T extends Storage = Storage>(silgi?: Silgi): (base: keyof SilgiStorageBase, driver: Parameters<Storage['mount']>[1]) => T;
256
+
257
+ declare function loadOptions(configOverrides?: SilgiCLIConfig, opts?: LoadConfigOptions): Promise<SilgiCLIOptions>;
6
258
 
7
259
  /**
8
260
  * Prepares route rules for the build
@@ -11,10 +263,23 @@ declare function prepareBuild(silgi: SilgiCLI): Promise<void>;
11
263
 
12
264
  declare function prepare(_silgi: SilgiCLI): Promise<void>;
13
265
 
14
- declare function createSilgiCLI(config?: SilgiCLIConfig, opts?: LoadConfigOptions): Promise<SilgiCLI>;
266
+ declare function reloadScan(path: string, _stats?: Stats): Promise<void>;
267
+
268
+ type Env = typeof process.env;
269
+ /**
270
+ * Load and interpolate environment variables into `process.env`.
271
+ * If you need more control (or access to the values), consider using `loadDotenv` instead
272
+ *
273
+ */
274
+ declare function setupDotenv(options: DotenvOptions): Promise<Env>;
275
+
276
+ declare function createSilgi(config?: SilgiCLIConfig, opts?: LoadConfigOptions): Promise<SilgiCLI>;
15
277
 
16
278
  declare function writeCoreFile(silgi: SilgiCLI): Promise<void>;
17
279
 
18
280
  declare function writeTypesAndFiles(silgi: SilgiCLI): Promise<void>;
19
281
 
20
- export { createSilgiCLI, prepare, prepareBuild, writeCoreFile, writeTypesAndFiles };
282
+ declare const autoImportTypes: string[];
283
+
284
+ export { ErrorCategory, ErrorFactory, ErrorSeverity, HttpStatus, SilgiError, autoImportTypes, createSchema, createService, createShared, createSilgi, createSilgiApp, createStorage, getEvent, getEventContext, isBaseError, loadOptions, mergeSchemas, mergeServices, mergeShared, parseURI, prepare, prepareBuild, reloadScan, replaceRuntimeValues, setupDotenv, silgi, silgiAppCtx, silgiClose, silgiCtx, storageMount, tryUseSilgi, tryUseSilgiApp, useSilgi, useSilgiApp, useSilgiStorage, writeCoreFile, writeTypesAndFiles };
285
+ export type { BaseError, ErrorMetadata };