silgi 0.14.3 → 0.14.4
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/core/index.d.mts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.mjs +8 -7
- package/dist/kit/index.d.mts +1 -3
- package/dist/kit/index.d.ts +1 -3
- package/dist/kit/index.mjs +1 -1
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/runtime/internal/nitro.mjs +4 -0
- package/dist/types/index.d.mts +75 -75
- package/dist/types/index.d.ts +75 -75
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -257,6 +257,6 @@ declare function useSilgiCLI(): SilgiCLI;
|
|
|
257
257
|
*/
|
|
258
258
|
declare function tryUseSilgiCLI(): SilgiCLI | null;
|
|
259
259
|
|
|
260
|
-
declare function storageMount<T extends
|
|
260
|
+
declare function storageMount<T extends Storage = Storage>(silgi?: Silgi): (base: keyof SilgiStorageBase, driver: Parameters<Storage['mount']>[1]) => T;
|
|
261
261
|
|
|
262
262
|
export { type BaseError, ErrorCategory, ErrorFactory, type ErrorMetadata, ErrorSeverity, HttpStatus, SilgiError, createSchema, createService, createShared, createSilgi, createStorage, getEvent, getEventContext, isBaseError, mergeSchemas, mergeServices, mergeShared, parseURI, silgiCLICtx, silgiCtx, storageMount, tryUseSilgi, tryUseSilgiCLI, useSilgi, useSilgiCLI, useSilgiStorage };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -257,6 +257,6 @@ declare function useSilgiCLI(): SilgiCLI;
|
|
|
257
257
|
*/
|
|
258
258
|
declare function tryUseSilgiCLI(): SilgiCLI | null;
|
|
259
259
|
|
|
260
|
-
declare function storageMount<T extends
|
|
260
|
+
declare function storageMount<T extends Storage = Storage>(silgi?: Silgi): (base: keyof SilgiStorageBase, driver: Parameters<Storage['mount']>[1]) => T;
|
|
261
261
|
|
|
262
262
|
export { type BaseError, ErrorCategory, ErrorFactory, type ErrorMetadata, ErrorSeverity, HttpStatus, SilgiError, createSchema, createService, createShared, createSilgi, createStorage, getEvent, getEventContext, isBaseError, mergeSchemas, mergeServices, mergeShared, parseURI, silgiCLICtx, silgiCtx, storageMount, tryUseSilgi, tryUseSilgiCLI, useSilgi, useSilgiCLI, useSilgiStorage };
|
package/dist/core/index.mjs
CHANGED
|
@@ -558,19 +558,16 @@ async function execute(uriString, input, event, source, queryParams) {
|
|
|
558
558
|
let cached = false;
|
|
559
559
|
let result;
|
|
560
560
|
const handler = silgiCtx.scannedHandlers.get(operation.uri);
|
|
561
|
-
if (event) {
|
|
562
|
-
await silgiCtx.callHook("event:before", event, handler);
|
|
563
|
-
}
|
|
564
561
|
if (!handler) {
|
|
565
562
|
throw ErrorFactory.create({
|
|
566
|
-
message: "
|
|
563
|
+
message: "execute not found",
|
|
567
564
|
httpStatus: HttpStatus.NOT_FOUND,
|
|
568
565
|
context: {
|
|
569
566
|
uri: uriString
|
|
570
567
|
}
|
|
571
568
|
});
|
|
572
569
|
}
|
|
573
|
-
await silgiCtx.callHook("
|
|
570
|
+
await silgiCtx.callHook("execute:before", {
|
|
574
571
|
operation,
|
|
575
572
|
input,
|
|
576
573
|
event,
|
|
@@ -600,7 +597,7 @@ async function execute(uriString, input, event, source, queryParams) {
|
|
|
600
597
|
);
|
|
601
598
|
success = true;
|
|
602
599
|
}
|
|
603
|
-
await silgiCtx.callHook("
|
|
600
|
+
await silgiCtx.callHook("execute:after", {
|
|
604
601
|
operation,
|
|
605
602
|
input,
|
|
606
603
|
event,
|
|
@@ -617,7 +614,7 @@ async function execute(uriString, input, event, source, queryParams) {
|
|
|
617
614
|
}
|
|
618
615
|
return result;
|
|
619
616
|
} catch (err) {
|
|
620
|
-
await silgiCtx.callHook("
|
|
617
|
+
await silgiCtx.callHook("execute:error", {
|
|
621
618
|
input,
|
|
622
619
|
event,
|
|
623
620
|
source,
|
|
@@ -728,6 +725,10 @@ function tryUseSilgiCLI() {
|
|
|
728
725
|
function storageMount(silgi) {
|
|
729
726
|
const _silgi = silgi || useSilgi();
|
|
730
727
|
return (base, driver) => {
|
|
728
|
+
const existingStorage = _silgi.storage.getMount(base);
|
|
729
|
+
if (existingStorage) {
|
|
730
|
+
return existingStorage.driver;
|
|
731
|
+
}
|
|
731
732
|
const storage = _silgi.storage.mount(base, driver);
|
|
732
733
|
return storage;
|
|
733
734
|
};
|
package/dist/kit/index.d.mts
CHANGED
|
@@ -94,9 +94,7 @@ declare function addTemplate<T>(_template: SilgiTemplate<T> | string): ResolvedS
|
|
|
94
94
|
*/
|
|
95
95
|
declare function normalizeTemplate<T>(template: SilgiTemplate<T> | string, buildDir?: string): ResolvedSilgiTemplate<T>;
|
|
96
96
|
|
|
97
|
-
declare function useRequest(event: SilgiEvents):
|
|
98
|
-
originalUrl?: string;
|
|
99
|
-
});
|
|
97
|
+
declare function useRequest(event: SilgiEvents): IncomingMessage;
|
|
100
98
|
declare function getIpAddress(event: SilgiEvents): string | false;
|
|
101
99
|
/**
|
|
102
100
|
* Extract the client's IP address from request headers with high accuracy
|
package/dist/kit/index.d.ts
CHANGED
|
@@ -94,9 +94,7 @@ declare function addTemplate<T>(_template: SilgiTemplate<T> | string): ResolvedS
|
|
|
94
94
|
*/
|
|
95
95
|
declare function normalizeTemplate<T>(template: SilgiTemplate<T> | string, buildDir?: string): ResolvedSilgiTemplate<T>;
|
|
96
96
|
|
|
97
|
-
declare function useRequest(event: SilgiEvents):
|
|
98
|
-
originalUrl?: string;
|
|
99
|
-
});
|
|
97
|
+
declare function useRequest(event: SilgiEvents): IncomingMessage;
|
|
100
98
|
declare function getIpAddress(event: SilgiEvents): string | false;
|
|
101
99
|
/**
|
|
102
100
|
* Extract the client's IP address from request headers with high accuracy
|
package/dist/kit/index.mjs
CHANGED
|
@@ -418,7 +418,7 @@ function useRequest(event) {
|
|
|
418
418
|
if (silgi.options.present === "nuxt" || silgi.options.present === "nitro" || silgi.options.present === "h3") {
|
|
419
419
|
return event.node.req;
|
|
420
420
|
}
|
|
421
|
-
return
|
|
421
|
+
return event;
|
|
422
422
|
}
|
|
423
423
|
function getIpAddress(event) {
|
|
424
424
|
const silgi = useSilgi();
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export default async function addNitroApp(silgiCtx = useSilgi()) {
|
|
|
13
13
|
} else {
|
|
14
14
|
newPath = `${event.path}?method=${event.method}`;
|
|
15
15
|
}
|
|
16
|
+
await silgiCtx.callHook("event:init", event, {
|
|
17
|
+
path: newPath,
|
|
18
|
+
queryParams: query
|
|
19
|
+
});
|
|
16
20
|
const data = await silgiConnect.execute(newPath, {
|
|
17
21
|
...body
|
|
18
22
|
}, void 0, query);
|
package/dist/types/index.d.mts
CHANGED
|
@@ -800,15 +800,71 @@ interface EnvOptions {
|
|
|
800
800
|
envExpansion?: boolean;
|
|
801
801
|
}
|
|
802
802
|
|
|
803
|
-
|
|
804
|
-
|
|
803
|
+
type CustomDriverName = string & {
|
|
804
|
+
_custom?: any;
|
|
805
|
+
};
|
|
806
|
+
interface StorageMounts {
|
|
807
|
+
[path: string]: {
|
|
808
|
+
driver: BuiltinDriverName | CustomDriverName;
|
|
809
|
+
[option: string]: any;
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
interface SilgiStorageBase {
|
|
813
|
+
}
|
|
814
|
+
type StorageKeyGenerator<TInput> = (input: TInput) => string | Promise<string>;
|
|
815
|
+
interface StorageConfig<TInput> {
|
|
816
|
+
options: TransactionOptions;
|
|
817
|
+
base: 'memory' | keyof SilgiStorageBase;
|
|
818
|
+
key?: StorageKeyGenerator<TInput>;
|
|
819
|
+
scope?: 'request' | 'global';
|
|
820
|
+
}
|
|
821
|
+
interface StorageKeyParams<TInput = unknown> {
|
|
822
|
+
operation: SilgiOperation;
|
|
823
|
+
input: TInput;
|
|
824
|
+
requestId?: string;
|
|
825
|
+
keyGenerator?: StorageKeyGenerator<TInput>;
|
|
826
|
+
storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
|
|
805
827
|
}
|
|
806
828
|
|
|
807
|
-
interface
|
|
808
|
-
|
|
809
|
-
|
|
829
|
+
interface SilgiRuntimeShareds extends SilgiRuntimeSharedExtends {
|
|
830
|
+
storage: <T extends StorageValue = StorageValue>(base: StorageConfig<T>['base']) => Storage<T>;
|
|
831
|
+
silgi: SilgiFunction;
|
|
832
|
+
runtimeConfig: SilgiRuntimeConfig;
|
|
833
|
+
}
|
|
834
|
+
interface SilgiRuntimeSharedExtends {
|
|
835
|
+
}
|
|
836
|
+
interface ExtendShared {
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
type EventHandlerResponse<T = undefined> = T extends undefined ? void : void | T | Promise<T>;
|
|
840
|
+
type MethodHandlerType<T> = {
|
|
841
|
+
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
842
|
+
[Method in keyof T[Action]]?: {
|
|
843
|
+
default?: {
|
|
844
|
+
input?: StandardSchemaV1.InferInput<T[Action][Method]['input']> & {
|
|
845
|
+
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
846
|
+
};
|
|
847
|
+
output?: StandardSchemaV1.InferInput<T[Action][Method]['output']>;
|
|
848
|
+
source?: StandardSchemaV1.InferInput<T[Action][Method]['source']>;
|
|
849
|
+
};
|
|
850
|
+
handler: (input: StandardSchemaV1.InferInput<T[Action][Method]['input']> & {
|
|
851
|
+
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
852
|
+
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<T[Action][Method]['source']>) => EventHandlerResponse<StandardSchemaV1.InferOutput<T[Action][Method]['output']>>;
|
|
853
|
+
modules?: Partial<SilgiRuntimeActions>;
|
|
854
|
+
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
855
|
+
};
|
|
856
|
+
} : never;
|
|
857
|
+
};
|
|
858
|
+
interface ResolvedMethodHandlerType {
|
|
859
|
+
input?: Partial<BaseSchemaType<any>>;
|
|
860
|
+
output: Partial<BaseSchemaType<any>>;
|
|
861
|
+
handler: (input: StandardSchemaV1.InferInput<any> & {
|
|
862
|
+
parameters: any;
|
|
863
|
+
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
864
|
+
modules?: Partial<SilgiRuntimeActions>;
|
|
865
|
+
storage?: StorageConfig<StandardSchemaV1.InferInput<any>>;
|
|
866
|
+
execute: (input: StandardSchemaV1.InferInput<any>, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
810
867
|
}
|
|
811
|
-
type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
812
868
|
|
|
813
869
|
type SilgiServiceInterface<T extends BaseSchemaType<StandardSchemaV1>> = {
|
|
814
870
|
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
@@ -889,71 +945,15 @@ interface SilgiConfig extends Partial<Omit<Silgi, 'options'>>, Partial<SilgiRunt
|
|
|
889
945
|
}
|
|
890
946
|
type SilgiFunction = typeof silgi;
|
|
891
947
|
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
};
|
|
895
|
-
interface StorageMounts {
|
|
896
|
-
[path: string]: {
|
|
897
|
-
driver: BuiltinDriverName | CustomDriverName;
|
|
898
|
-
[option: string]: any;
|
|
899
|
-
};
|
|
900
|
-
}
|
|
901
|
-
interface SilgiStorageBase {
|
|
902
|
-
}
|
|
903
|
-
type StorageKeyGenerator<TInput> = (input: TInput) => string | Promise<string>;
|
|
904
|
-
interface StorageConfig<TInput> {
|
|
905
|
-
options: TransactionOptions;
|
|
906
|
-
base: 'memory' | keyof SilgiStorageBase;
|
|
907
|
-
key?: StorageKeyGenerator<TInput>;
|
|
908
|
-
scope?: 'request' | 'global';
|
|
909
|
-
}
|
|
910
|
-
interface StorageKeyParams<TInput = unknown> {
|
|
911
|
-
operation: SilgiOperation;
|
|
912
|
-
input: TInput;
|
|
913
|
-
requestId?: string;
|
|
914
|
-
keyGenerator?: StorageKeyGenerator<TInput>;
|
|
915
|
-
storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
interface SilgiRuntimeShareds extends SilgiRuntimeSharedExtends {
|
|
919
|
-
storage: <T extends StorageValue = StorageValue>(base: StorageConfig<T>['base']) => Storage<T>;
|
|
920
|
-
silgi: SilgiFunction;
|
|
921
|
-
runtimeConfig: SilgiRuntimeConfig;
|
|
922
|
-
}
|
|
923
|
-
interface SilgiRuntimeSharedExtends {
|
|
924
|
-
}
|
|
925
|
-
interface ExtendShared {
|
|
948
|
+
interface SilgiAppPlugin {
|
|
949
|
+
(silgi: Silgi): Promise<void> | void;
|
|
926
950
|
}
|
|
927
951
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
[
|
|
931
|
-
[Method in keyof T[Action]]?: {
|
|
932
|
-
default?: {
|
|
933
|
-
input?: StandardSchemaV1.InferInput<T[Action][Method]['input']> & {
|
|
934
|
-
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
935
|
-
};
|
|
936
|
-
output?: StandardSchemaV1.InferInput<T[Action][Method]['output']>;
|
|
937
|
-
source?: StandardSchemaV1.InferInput<T[Action][Method]['source']>;
|
|
938
|
-
};
|
|
939
|
-
handler: (input: StandardSchemaV1.InferInput<T[Action][Method]['input']> & {
|
|
940
|
-
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
941
|
-
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<T[Action][Method]['source']>) => EventHandlerResponse<StandardSchemaV1.InferOutput<T[Action][Method]['output']>>;
|
|
942
|
-
modules?: Partial<SilgiRuntimeActions>;
|
|
943
|
-
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
944
|
-
};
|
|
945
|
-
} : never;
|
|
946
|
-
};
|
|
947
|
-
interface ResolvedMethodHandlerType {
|
|
948
|
-
input?: Partial<BaseSchemaType<any>>;
|
|
949
|
-
output: Partial<BaseSchemaType<any>>;
|
|
950
|
-
handler: (input: StandardSchemaV1.InferInput<any> & {
|
|
951
|
-
parameters: any;
|
|
952
|
-
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
953
|
-
modules?: Partial<SilgiRuntimeActions>;
|
|
954
|
-
storage?: StorageConfig<StandardSchemaV1.InferInput<any>>;
|
|
955
|
-
execute: (input: StandardSchemaV1.InferInput<any>, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
952
|
+
interface CapturedErrorContext {
|
|
953
|
+
event?: SilgiEvents;
|
|
954
|
+
[key: string]: unknown;
|
|
956
955
|
}
|
|
956
|
+
type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
957
957
|
|
|
958
958
|
/**
|
|
959
959
|
* The listeners to Silgi
|
|
@@ -972,13 +972,13 @@ interface SilgiRuntimeHooks {
|
|
|
972
972
|
*/
|
|
973
973
|
'close': (silgi: Silgi) => HookResult;
|
|
974
974
|
'app:setup:start': (silgi: Silgi) => HookResult;
|
|
975
|
-
'
|
|
976
|
-
'
|
|
977
|
-
'
|
|
978
|
-
'
|
|
979
|
-
'event:
|
|
980
|
-
|
|
981
|
-
|
|
975
|
+
'execute:before': (context: ModuleHookContext) => HookResult;
|
|
976
|
+
'execute:after': (context: ModuleHookContext) => HookResult;
|
|
977
|
+
'execute:error': (context: ModuleHookContext) => HookResult;
|
|
978
|
+
'execute:finally': (context: ModuleHookContext) => HookResult;
|
|
979
|
+
'event:init': (event: SilgiEvents, data: {
|
|
980
|
+
path: string;
|
|
981
|
+
queryParams?: Record<string, string>;
|
|
982
982
|
}) => HookResult;
|
|
983
983
|
'error': CaptureError;
|
|
984
984
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -800,15 +800,71 @@ interface EnvOptions {
|
|
|
800
800
|
envExpansion?: boolean;
|
|
801
801
|
}
|
|
802
802
|
|
|
803
|
-
|
|
804
|
-
|
|
803
|
+
type CustomDriverName = string & {
|
|
804
|
+
_custom?: any;
|
|
805
|
+
};
|
|
806
|
+
interface StorageMounts {
|
|
807
|
+
[path: string]: {
|
|
808
|
+
driver: BuiltinDriverName | CustomDriverName;
|
|
809
|
+
[option: string]: any;
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
interface SilgiStorageBase {
|
|
813
|
+
}
|
|
814
|
+
type StorageKeyGenerator<TInput> = (input: TInput) => string | Promise<string>;
|
|
815
|
+
interface StorageConfig<TInput> {
|
|
816
|
+
options: TransactionOptions;
|
|
817
|
+
base: 'memory' | keyof SilgiStorageBase;
|
|
818
|
+
key?: StorageKeyGenerator<TInput>;
|
|
819
|
+
scope?: 'request' | 'global';
|
|
820
|
+
}
|
|
821
|
+
interface StorageKeyParams<TInput = unknown> {
|
|
822
|
+
operation: SilgiOperation;
|
|
823
|
+
input: TInput;
|
|
824
|
+
requestId?: string;
|
|
825
|
+
keyGenerator?: StorageKeyGenerator<TInput>;
|
|
826
|
+
storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
|
|
805
827
|
}
|
|
806
828
|
|
|
807
|
-
interface
|
|
808
|
-
|
|
809
|
-
|
|
829
|
+
interface SilgiRuntimeShareds extends SilgiRuntimeSharedExtends {
|
|
830
|
+
storage: <T extends StorageValue = StorageValue>(base: StorageConfig<T>['base']) => Storage<T>;
|
|
831
|
+
silgi: SilgiFunction;
|
|
832
|
+
runtimeConfig: SilgiRuntimeConfig;
|
|
833
|
+
}
|
|
834
|
+
interface SilgiRuntimeSharedExtends {
|
|
835
|
+
}
|
|
836
|
+
interface ExtendShared {
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
type EventHandlerResponse<T = undefined> = T extends undefined ? void : void | T | Promise<T>;
|
|
840
|
+
type MethodHandlerType<T> = {
|
|
841
|
+
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
842
|
+
[Method in keyof T[Action]]?: {
|
|
843
|
+
default?: {
|
|
844
|
+
input?: StandardSchemaV1.InferInput<T[Action][Method]['input']> & {
|
|
845
|
+
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
846
|
+
};
|
|
847
|
+
output?: StandardSchemaV1.InferInput<T[Action][Method]['output']>;
|
|
848
|
+
source?: StandardSchemaV1.InferInput<T[Action][Method]['source']>;
|
|
849
|
+
};
|
|
850
|
+
handler: (input: StandardSchemaV1.InferInput<T[Action][Method]['input']> & {
|
|
851
|
+
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
852
|
+
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<T[Action][Method]['source']>) => EventHandlerResponse<StandardSchemaV1.InferOutput<T[Action][Method]['output']>>;
|
|
853
|
+
modules?: Partial<SilgiRuntimeActions>;
|
|
854
|
+
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
855
|
+
};
|
|
856
|
+
} : never;
|
|
857
|
+
};
|
|
858
|
+
interface ResolvedMethodHandlerType {
|
|
859
|
+
input?: Partial<BaseSchemaType<any>>;
|
|
860
|
+
output: Partial<BaseSchemaType<any>>;
|
|
861
|
+
handler: (input: StandardSchemaV1.InferInput<any> & {
|
|
862
|
+
parameters: any;
|
|
863
|
+
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
864
|
+
modules?: Partial<SilgiRuntimeActions>;
|
|
865
|
+
storage?: StorageConfig<StandardSchemaV1.InferInput<any>>;
|
|
866
|
+
execute: (input: StandardSchemaV1.InferInput<any>, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
810
867
|
}
|
|
811
|
-
type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
812
868
|
|
|
813
869
|
type SilgiServiceInterface<T extends BaseSchemaType<StandardSchemaV1>> = {
|
|
814
870
|
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
@@ -889,71 +945,15 @@ interface SilgiConfig extends Partial<Omit<Silgi, 'options'>>, Partial<SilgiRunt
|
|
|
889
945
|
}
|
|
890
946
|
type SilgiFunction = typeof silgi;
|
|
891
947
|
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
};
|
|
895
|
-
interface StorageMounts {
|
|
896
|
-
[path: string]: {
|
|
897
|
-
driver: BuiltinDriverName | CustomDriverName;
|
|
898
|
-
[option: string]: any;
|
|
899
|
-
};
|
|
900
|
-
}
|
|
901
|
-
interface SilgiStorageBase {
|
|
902
|
-
}
|
|
903
|
-
type StorageKeyGenerator<TInput> = (input: TInput) => string | Promise<string>;
|
|
904
|
-
interface StorageConfig<TInput> {
|
|
905
|
-
options: TransactionOptions;
|
|
906
|
-
base: 'memory' | keyof SilgiStorageBase;
|
|
907
|
-
key?: StorageKeyGenerator<TInput>;
|
|
908
|
-
scope?: 'request' | 'global';
|
|
909
|
-
}
|
|
910
|
-
interface StorageKeyParams<TInput = unknown> {
|
|
911
|
-
operation: SilgiOperation;
|
|
912
|
-
input: TInput;
|
|
913
|
-
requestId?: string;
|
|
914
|
-
keyGenerator?: StorageKeyGenerator<TInput>;
|
|
915
|
-
storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
interface SilgiRuntimeShareds extends SilgiRuntimeSharedExtends {
|
|
919
|
-
storage: <T extends StorageValue = StorageValue>(base: StorageConfig<T>['base']) => Storage<T>;
|
|
920
|
-
silgi: SilgiFunction;
|
|
921
|
-
runtimeConfig: SilgiRuntimeConfig;
|
|
922
|
-
}
|
|
923
|
-
interface SilgiRuntimeSharedExtends {
|
|
924
|
-
}
|
|
925
|
-
interface ExtendShared {
|
|
948
|
+
interface SilgiAppPlugin {
|
|
949
|
+
(silgi: Silgi): Promise<void> | void;
|
|
926
950
|
}
|
|
927
951
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
[
|
|
931
|
-
[Method in keyof T[Action]]?: {
|
|
932
|
-
default?: {
|
|
933
|
-
input?: StandardSchemaV1.InferInput<T[Action][Method]['input']> & {
|
|
934
|
-
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
935
|
-
};
|
|
936
|
-
output?: StandardSchemaV1.InferInput<T[Action][Method]['output']>;
|
|
937
|
-
source?: StandardSchemaV1.InferInput<T[Action][Method]['source']>;
|
|
938
|
-
};
|
|
939
|
-
handler: (input: StandardSchemaV1.InferInput<T[Action][Method]['input']> & {
|
|
940
|
-
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
941
|
-
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<T[Action][Method]['source']>) => EventHandlerResponse<StandardSchemaV1.InferOutput<T[Action][Method]['output']>>;
|
|
942
|
-
modules?: Partial<SilgiRuntimeActions>;
|
|
943
|
-
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
944
|
-
};
|
|
945
|
-
} : never;
|
|
946
|
-
};
|
|
947
|
-
interface ResolvedMethodHandlerType {
|
|
948
|
-
input?: Partial<BaseSchemaType<any>>;
|
|
949
|
-
output: Partial<BaseSchemaType<any>>;
|
|
950
|
-
handler: (input: StandardSchemaV1.InferInput<any> & {
|
|
951
|
-
parameters: any;
|
|
952
|
-
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
953
|
-
modules?: Partial<SilgiRuntimeActions>;
|
|
954
|
-
storage?: StorageConfig<StandardSchemaV1.InferInput<any>>;
|
|
955
|
-
execute: (input: StandardSchemaV1.InferInput<any>, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
952
|
+
interface CapturedErrorContext {
|
|
953
|
+
event?: SilgiEvents;
|
|
954
|
+
[key: string]: unknown;
|
|
956
955
|
}
|
|
956
|
+
type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
957
957
|
|
|
958
958
|
/**
|
|
959
959
|
* The listeners to Silgi
|
|
@@ -972,13 +972,13 @@ interface SilgiRuntimeHooks {
|
|
|
972
972
|
*/
|
|
973
973
|
'close': (silgi: Silgi) => HookResult;
|
|
974
974
|
'app:setup:start': (silgi: Silgi) => HookResult;
|
|
975
|
-
'
|
|
976
|
-
'
|
|
977
|
-
'
|
|
978
|
-
'
|
|
979
|
-
'event:
|
|
980
|
-
|
|
981
|
-
|
|
975
|
+
'execute:before': (context: ModuleHookContext) => HookResult;
|
|
976
|
+
'execute:after': (context: ModuleHookContext) => HookResult;
|
|
977
|
+
'execute:error': (context: ModuleHookContext) => HookResult;
|
|
978
|
+
'execute:finally': (context: ModuleHookContext) => HookResult;
|
|
979
|
+
'event:init': (event: SilgiEvents, data: {
|
|
980
|
+
path: string;
|
|
981
|
+
queryParams?: Record<string, string>;
|
|
982
982
|
}) => HookResult;
|
|
983
983
|
'error': CaptureError;
|
|
984
984
|
}
|