silgi 0.37.36 → 0.37.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/build.mjs +7 -6
- package/dist/cli/index.mjs +1 -1
- package/dist/core/index.d.mts +1 -16
- package/dist/core/index.mjs +4 -8
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/runtime/index.d.mts +1 -1
- package/dist/runtime/index.mjs +1 -1
- package/dist/runtime/internal/config.d.mts +1 -1
- package/dist/runtime/internal/config.mjs +2 -2
- package/dist/types/index.d.mts +21 -35
- package/package.json +1 -1
package/dist/cli/build.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { createHooks, createDebugger } from 'hookable';
|
|
|
3
3
|
import { resolve, join, relative, extname, basename, dirname, isAbsolute } from 'pathe';
|
|
4
4
|
import { useSilgiCLI, replaceRuntimeValues, silgiCLICtx, autoImportTypes } from 'silgi';
|
|
5
5
|
import { isPresents, addTemplate, addCoreFile, genEnsureSafeVar, writeFile, relativeWithDot, hash, removeExtension, resolveAlias, directoryToURL, addImports, baseHeaderBannerComment, normalizeTemplate, useLogger, resolveSilgiPath, hasSilgiModule, toArray, isDirectory } from 'silgi/kit';
|
|
6
|
-
import {
|
|
6
|
+
import { useRuntimeConfig, initRuntimeConfig, sharedRuntimeConfig } from 'silgi/runtime';
|
|
7
7
|
import { runtimeDir } from 'silgi/runtime/meta';
|
|
8
8
|
import { scanExports, createUnimport, toExports } from 'unimport';
|
|
9
9
|
import * as p from '@clack/prompts';
|
|
@@ -1169,7 +1169,7 @@ async function writeScanFiles(silgi) {
|
|
|
1169
1169
|
|
|
1170
1170
|
async function createStorageCLI(silgi) {
|
|
1171
1171
|
const storage = createStorage();
|
|
1172
|
-
const runtime =
|
|
1172
|
+
const runtime = useRuntimeConfig();
|
|
1173
1173
|
const mounts = klona({
|
|
1174
1174
|
...silgi.options.storage,
|
|
1175
1175
|
...silgi.options.devStorage
|
|
@@ -1413,6 +1413,7 @@ async function scanDir(silgi, dir, name) {
|
|
|
1413
1413
|
|
|
1414
1414
|
async function createSilgiCLI(config = {}, opts = {}) {
|
|
1415
1415
|
const options = await loadOptions(config, opts);
|
|
1416
|
+
await prepareEnv(options);
|
|
1416
1417
|
const hooks = createHooks();
|
|
1417
1418
|
const silgi = {
|
|
1418
1419
|
scannedURIs: /* @__PURE__ */ new Map(),
|
|
@@ -1434,9 +1435,9 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1434
1435
|
hook: hooks.hook,
|
|
1435
1436
|
async updateConfig(_config) {
|
|
1436
1437
|
},
|
|
1437
|
-
adapters: {}
|
|
1438
|
+
adapters: {},
|
|
1439
|
+
useLocalConfig: () => useRuntimeConfig(void 0, options.runtimeConfig, true)
|
|
1438
1440
|
};
|
|
1439
|
-
await prepareEnv(options);
|
|
1440
1441
|
sharedRuntimeConfig(silgi.options.runtimeConfig);
|
|
1441
1442
|
if (silgiCLICtx.tryUse()) {
|
|
1442
1443
|
silgiCLICtx.unset();
|
|
@@ -1622,14 +1623,14 @@ async function prepareConfigs(silgi) {
|
|
|
1622
1623
|
await silgi.callHook("prepare:configs.ts", _data);
|
|
1623
1624
|
const importData = [
|
|
1624
1625
|
"import type { SilgiRuntimeOptions, SilgiRuntimeConfig, SilgiOptions } from 'silgi/types'",
|
|
1625
|
-
"import {
|
|
1626
|
+
"import { useRuntimeConfig } from 'silgi/runtime'",
|
|
1626
1627
|
"",
|
|
1627
1628
|
`export const runtimeConfig: SilgiRuntimeConfig = ${genObjectFromRawEntries(
|
|
1628
1629
|
Object.entries(_data.runtimeConfig).map(([key, value]) => [key, genEnsureSafeVar(value)]),
|
|
1629
1630
|
""
|
|
1630
1631
|
)}`,
|
|
1631
1632
|
"",
|
|
1632
|
-
"export const
|
|
1633
|
+
"export const localConfig = useRuntimeConfig(undefined, runtimeConfig)",
|
|
1633
1634
|
""
|
|
1634
1635
|
];
|
|
1635
1636
|
delete _data.runtimeConfig;
|
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -279,8 +279,6 @@ declare function tryUseSilgiCLI(): SilgiCLI | null;
|
|
|
279
279
|
declare function storageMount<T extends Storage = Storage>(silgi?: Silgi): (base: keyof SilgiStorageBase, driver: Parameters<Storage['mount']>[1]) => T;
|
|
280
280
|
|
|
281
281
|
declare function updateRuntimeStorage(runtime: any): void;
|
|
282
|
-
/** Direct access to the silgi context with asyncLocalStorage - see https://github.com/unjs/unctx. */
|
|
283
|
-
declare const getRuntimeCtx: () => SilgiRuntimeConfig | null;
|
|
284
282
|
/**
|
|
285
283
|
* Get access to silgi instance.
|
|
286
284
|
*
|
|
@@ -291,20 +289,7 @@ declare const getRuntimeCtx: () => SilgiRuntimeConfig | null;
|
|
|
291
289
|
* ```
|
|
292
290
|
*/
|
|
293
291
|
declare function useRuntime(): SilgiRuntimeConfig;
|
|
294
|
-
/**
|
|
295
|
-
* Get access to Runtime instance.
|
|
296
|
-
*
|
|
297
|
-
* Returns null if Runtime instance is unavailable.
|
|
298
|
-
* @example
|
|
299
|
-
* ```js
|
|
300
|
-
* const runtime = tryUseRuntime()
|
|
301
|
-
* if (runtime) {
|
|
302
|
-
* // Do something
|
|
303
|
-
* }
|
|
304
|
-
* ```
|
|
305
|
-
*/
|
|
306
|
-
declare function tryUseRuntime(): SilgiRuntimeConfig | null;
|
|
307
292
|
|
|
308
293
|
declare const autoImportTypes: string[];
|
|
309
294
|
|
|
310
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext,
|
|
295
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage };
|
package/dist/core/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createConsola } from 'consola';
|
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
import { createHooks } from 'hookable';
|
|
4
4
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
5
|
-
import {
|
|
5
|
+
import { useRuntimeConfig, sharedRuntimeConfig } from 'silgi/runtime';
|
|
6
6
|
import { getContext, createContext } from 'unctx';
|
|
7
7
|
import { Buffer } from 'node:buffer';
|
|
8
8
|
import { klona } from 'klona';
|
|
@@ -187,7 +187,7 @@ function replaceRuntimeValues(obj, runtime) {
|
|
|
187
187
|
|
|
188
188
|
async function createStorage(silgi) {
|
|
189
189
|
const storage = createStorage$1();
|
|
190
|
-
const runtime =
|
|
190
|
+
const runtime = useRuntimeConfig();
|
|
191
191
|
const mounts = klona({
|
|
192
192
|
...silgi.options.storage,
|
|
193
193
|
...silgi.options.devStorage
|
|
@@ -322,7 +322,7 @@ async function createSilgi(config) {
|
|
|
322
322
|
silgi.shared.storage = (...data) => {
|
|
323
323
|
return useSilgiStorage(...data);
|
|
324
324
|
};
|
|
325
|
-
silgi.shared.useRuntimeConfig =
|
|
325
|
+
silgi.shared.useRuntimeConfig = useRuntimeConfig;
|
|
326
326
|
if (silgiCtx.tryUse()) {
|
|
327
327
|
silgiCtx.unset();
|
|
328
328
|
silgiCtx.set(silgi);
|
|
@@ -976,7 +976,6 @@ function updateRuntimeStorage(runtime) {
|
|
|
976
976
|
asyncRuntimeStorage.set(runtime);
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
|
-
const getRuntimeCtx = () => asyncRuntimeStorage.tryUse();
|
|
980
979
|
function useRuntime() {
|
|
981
980
|
const instance = asyncRuntimeStorage.tryUse();
|
|
982
981
|
if (!instance) {
|
|
@@ -984,9 +983,6 @@ function useRuntime() {
|
|
|
984
983
|
}
|
|
985
984
|
return instance;
|
|
986
985
|
}
|
|
987
|
-
function tryUseRuntime() {
|
|
988
|
-
return asyncRuntimeStorage.tryUse();
|
|
989
|
-
}
|
|
990
986
|
|
|
991
987
|
const autoImportTypes = [
|
|
992
988
|
"ExtractInputFromURI",
|
|
@@ -995,4 +991,4 @@ const autoImportTypes = [
|
|
|
995
991
|
"ExtractQueryParamsFromURI"
|
|
996
992
|
];
|
|
997
993
|
|
|
998
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext,
|
|
994
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext,
|
|
1
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage } from './core/index.mjs';
|
|
2
2
|
import 'silgi/types';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import 'unstorage';
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext,
|
|
1
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage } from './core/index.mjs';
|
|
2
2
|
export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from './_chunks/silgiApp.mjs';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'defu';
|
package/dist/runtime/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { initRuntimeConfig, sharedRuntimeConfig,
|
|
1
|
+
export { initRuntimeConfig, sharedRuntimeConfig, useRuntimeConfig } from "./internal/config.mjs";
|
|
2
2
|
export { defineSilgiPlugin } from "./internal/plugin.mjs";
|
|
3
3
|
export { mergeDeep } from "./internal/defu.mjs";
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { initRuntimeConfig, sharedRuntimeConfig,
|
|
1
|
+
export { initRuntimeConfig, sharedRuntimeConfig, useRuntimeConfig } from "./internal/config.mjs";
|
|
2
2
|
export { defineSilgiPlugin } from "./internal/plugin.mjs";
|
|
3
3
|
export { mergeDeep } from "./internal/defu.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EnvOptions, SilgiEvent, SilgiRuntimeConfig } from 'silgi/types';
|
|
2
2
|
export declare function updateEnvOptions(runtime: SilgiRuntimeConfig): EnvOptions;
|
|
3
3
|
export declare function sharedRuntimeConfig(runtime: SilgiRuntimeConfig, force?: boolean): SilgiRuntimeConfig;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function useRuntimeConfig<T extends SilgiRuntimeConfig>(event?: SilgiEvent, localRuntimeConfig?: SilgiRuntimeConfig, force?: boolean): SilgiRuntimeConfig;
|
|
5
5
|
export declare function initRuntimeConfig(envOptions?: EnvOptions, inlineRuntimeConfig?: Record<string, any>): Readonly<Record<string, any>>;
|
|
6
6
|
export declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void;
|
|
7
7
|
export declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
|
|
@@ -23,9 +23,9 @@ export function sharedRuntimeConfig(runtime, force) {
|
|
|
23
23
|
updateRuntimeStorage(inlineRuntimeConfig);
|
|
24
24
|
return inlineRuntimeConfig;
|
|
25
25
|
}
|
|
26
|
-
export function
|
|
26
|
+
export function useRuntimeConfig(event, localRuntimeConfig, force) {
|
|
27
27
|
if (localRuntimeConfig) {
|
|
28
|
-
return sharedRuntimeConfig(localRuntimeConfig);
|
|
28
|
+
return sharedRuntimeConfig(localRuntimeConfig, force);
|
|
29
29
|
}
|
|
30
30
|
const runtime = useRuntime();
|
|
31
31
|
if (!event) {
|
package/dist/types/index.d.mts
CHANGED
|
@@ -10,15 +10,15 @@ import { PresetName, PresetOptions, PresetNameInput } from 'silgi/presets';
|
|
|
10
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, RouteConfigService as RouteConfigService$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
|
-
import * as h3 from 'h3';
|
|
14
|
-
import { HTTPMethod as HTTPMethod$1, Session, H3Event } from 'h3';
|
|
15
|
-
import * as nitropack_types from 'nitropack/types';
|
|
16
|
-
import { NitroRuntimeConfig } from 'nitropack/types';
|
|
17
13
|
import { Defu } from 'defu';
|
|
18
14
|
import * as next from 'next';
|
|
19
15
|
import { NextConfig } from 'next';
|
|
20
16
|
import { Stats } from 'node:fs';
|
|
17
|
+
import * as h3 from 'h3';
|
|
18
|
+
import { HTTPMethod as HTTPMethod$1, Session } from 'h3';
|
|
19
|
+
import * as nitropack_types from 'nitropack/types';
|
|
21
20
|
import { ESMImport, ESMCodeGenOptions } from 'knitwork';
|
|
21
|
+
import { useRuntimeConfig } from 'silgi/runtime';
|
|
22
22
|
import { Unimport } from 'unimport';
|
|
23
23
|
import { Storage, TransactionOptions, BuiltinDriverName, StorageValue } from 'unstorage';
|
|
24
24
|
import { ServerRequest } from 'srvx';
|
|
@@ -26,10 +26,24 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
|
26
26
|
import { NitroApp } from 'nitropack';
|
|
27
27
|
import { RouterContext } from 'rou3';
|
|
28
28
|
import { silgiFetch } from 'silgi';
|
|
29
|
-
import { useSilgiRuntimeConfig } from 'silgi/runtime';
|
|
30
29
|
import { ProviderName } from 'std-env';
|
|
31
30
|
import { FetchOptions, FetchResponse } from 'ofetch';
|
|
32
31
|
|
|
32
|
+
interface SilgiRuntimeMethods {
|
|
33
|
+
}
|
|
34
|
+
type CommandType = 'run' | 'prepare' | 'install' | 'dev' | 'init';
|
|
35
|
+
interface SilgiRouterTypes {
|
|
36
|
+
}
|
|
37
|
+
interface DefaultHooks {
|
|
38
|
+
}
|
|
39
|
+
type DeepPartial<T> = T extends (...args: any[]) => any ? T : T extends Record<string, any> ? {
|
|
40
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
41
|
+
} : T;
|
|
42
|
+
type DeepRequired<T> = T extends (...args: any[]) => any ? T : T extends Record<string, any> ? {
|
|
43
|
+
[P in keyof T]-?: DeepRequired<T[P]>;
|
|
44
|
+
} : T;
|
|
45
|
+
type Awaitable<T> = T | Promise<T>;
|
|
46
|
+
|
|
33
47
|
interface SilgiCompatibilityIssue {
|
|
34
48
|
name: string;
|
|
35
49
|
message: string;
|
|
@@ -85,6 +99,7 @@ interface SilgiCLI {
|
|
|
85
99
|
callHook: SilgiCLI['hooks']['callHook'];
|
|
86
100
|
addHooks: SilgiCLI['hooks']['addHooks'];
|
|
87
101
|
storage: Storage;
|
|
102
|
+
useLocalConfig: typeof useRuntimeConfig;
|
|
88
103
|
unimport?: Unimport;
|
|
89
104
|
logger: ConsolaInstance;
|
|
90
105
|
close: () => Promise<void>;
|
|
@@ -592,7 +607,7 @@ interface StorageKeyParams<TInput = unknown> {
|
|
|
592
607
|
|
|
593
608
|
interface SilgiRuntimeShareds extends SilgiRuntimeSharedsExtend {
|
|
594
609
|
storage: <T extends StorageValue = StorageValue>(base: StorageConfig<T>['base']) => Storage<T>;
|
|
595
|
-
useRuntimeConfig: typeof
|
|
610
|
+
useRuntimeConfig: typeof useRuntimeConfig;
|
|
596
611
|
$fetch: typeof silgiFetch;
|
|
597
612
|
silgi: Silgi;
|
|
598
613
|
}
|
|
@@ -875,35 +890,6 @@ interface SilgiModule<TOptions extends ModuleOptionsCustom = ModuleOptionsCustom
|
|
|
875
890
|
getMeta?: () => Promise<ModuleMeta>;
|
|
876
891
|
}
|
|
877
892
|
|
|
878
|
-
interface SilgiRuntimeMethods {
|
|
879
|
-
}
|
|
880
|
-
type CommandType = 'run' | 'prepare' | 'install' | 'dev' | 'init';
|
|
881
|
-
interface SilgiRouterTypes {
|
|
882
|
-
}
|
|
883
|
-
interface DefaultHooks {
|
|
884
|
-
}
|
|
885
|
-
type DeepPartial<T> = T extends (...args: any[]) => any ? T : T extends Record<string, any> ? {
|
|
886
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
887
|
-
} : T;
|
|
888
|
-
type DeepRequired<T> = T extends (...args: any[]) => any ? T : T extends Record<string, any> ? {
|
|
889
|
-
[P in keyof T]-?: DeepRequired<T[P]>;
|
|
890
|
-
} : T;
|
|
891
|
-
type Awaitable<T> = T | Promise<T>;
|
|
892
|
-
declare global {
|
|
893
|
-
var $silgiStatus: CommandType;
|
|
894
|
-
var _silgi_runtime: SilgiRuntimeOptions;
|
|
895
|
-
namespace NodeJS {
|
|
896
|
-
interface Global {
|
|
897
|
-
$silgiStatus: CommandType;
|
|
898
|
-
_silgi_runtime: SilgiRuntimeOptions;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
var __silgi__: {
|
|
902
|
-
useRuntimeConfig?: <T extends NitroRuntimeConfig = NitroRuntimeConfig>(event?: H3Event) => T;
|
|
903
|
-
[key: string]: any;
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
|
|
907
893
|
type SilgiPreset = (SilgiCLIConfig & {
|
|
908
894
|
_meta?: SilgiPresetMeta;
|
|
909
895
|
}) | (() => SilgiCLIConfig & {
|