resora 0.2.18 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/bin/index.mjs +5 -5
- package/dist/index.cjs +197 -27
- package/dist/index.d.cts +104 -3
- package/dist/index.d.mts +104 -3
- package/dist/index.mjs +189 -28
- package/package.json +6 -3
package/dist/index.d.cts
CHANGED
|
@@ -298,6 +298,47 @@ interface ResoraConfig extends Partial<Omit<Config, 'stubs' | 'cursorMeta' | 'pa
|
|
|
298
298
|
responseStructure?: Partial<Config['responseStructure']>;
|
|
299
299
|
}
|
|
300
300
|
//#endregion
|
|
301
|
+
//#region src/types/plugin.d.ts
|
|
302
|
+
type ResoraPluginUtility = (...args: any[]) => unknown;
|
|
303
|
+
interface ResoraPluginApi {
|
|
304
|
+
runWithCtx: <T>(ctx: unknown, callback: () => T) => T;
|
|
305
|
+
setCtx: (ctx: unknown) => void;
|
|
306
|
+
getCtx: () => unknown;
|
|
307
|
+
registerUtility: (name: string, utility: ResoraPluginUtility) => ResoraPluginUtility;
|
|
308
|
+
getUtility: <T extends ResoraPluginUtility = ResoraPluginUtility>(name: string) => T | undefined;
|
|
309
|
+
getRegisteredPlugins: () => ResoraPlugin[];
|
|
310
|
+
}
|
|
311
|
+
interface SerializePluginEvent<TBody = any, TResource = any> {
|
|
312
|
+
serializer: unknown;
|
|
313
|
+
serializerType: ResponseKind;
|
|
314
|
+
resource: TResource;
|
|
315
|
+
body: TBody;
|
|
316
|
+
}
|
|
317
|
+
interface ResponsePluginEvent<TBody = any> {
|
|
318
|
+
serializer: unknown;
|
|
319
|
+
serializerType: ResponseKind;
|
|
320
|
+
rawResponse?: unknown;
|
|
321
|
+
response?: unknown;
|
|
322
|
+
body: TBody;
|
|
323
|
+
}
|
|
324
|
+
interface SendPluginEvent<TBody = any> {
|
|
325
|
+
response: unknown;
|
|
326
|
+
rawResponse: unknown;
|
|
327
|
+
body: TBody;
|
|
328
|
+
status: number;
|
|
329
|
+
headers: Record<string, string>;
|
|
330
|
+
}
|
|
331
|
+
interface ResoraPlugin {
|
|
332
|
+
name: string;
|
|
333
|
+
setup?: (api: ResoraPluginApi) => void;
|
|
334
|
+
beforeSerialize?: (event: SerializePluginEvent, api: ResoraPluginApi) => void;
|
|
335
|
+
afterSerialize?: (event: SerializePluginEvent, api: ResoraPluginApi) => void;
|
|
336
|
+
beforeResponse?: (event: ResponsePluginEvent, api: ResoraPluginApi) => void;
|
|
337
|
+
afterResponse?: (event: ResponsePluginEvent, api: ResoraPluginApi) => void;
|
|
338
|
+
beforeSend?: (event: SendPluginEvent, api: ResoraPluginApi) => void;
|
|
339
|
+
afterSend?: (event: SendPluginEvent, api: ResoraPluginApi) => void;
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
301
342
|
//#region src/cli/CliApp.d.ts
|
|
302
343
|
declare class CliApp {
|
|
303
344
|
command: Command;
|
|
@@ -529,6 +570,43 @@ declare abstract class BaseSerializer<TResource = any> {
|
|
|
529
570
|
protected abstract resolveCurrentRootKey(): string;
|
|
530
571
|
protected abstract applyMetaToBody(meta: MetaData, rootKey: string): void;
|
|
531
572
|
protected abstract getResourceForMeta(): TResource;
|
|
573
|
+
protected abstract getSerializerType(): ResponseKind;
|
|
574
|
+
protected abstract setBody(body: any): this;
|
|
575
|
+
/**
|
|
576
|
+
* Apply registered plugins for the serialization process, allowing plugins to
|
|
577
|
+
* modify the response body and metadata before the response is sent.
|
|
578
|
+
*
|
|
579
|
+
* @param body
|
|
580
|
+
* @returns
|
|
581
|
+
*/
|
|
582
|
+
protected applySerializePlugins<TBody>(body: TBody): TBody;
|
|
583
|
+
/**
|
|
584
|
+
* Apply registered plugins for the response process, allowing plugins to modify the
|
|
585
|
+
* response body, headers, and status before the response is sent.
|
|
586
|
+
*
|
|
587
|
+
* @param input
|
|
588
|
+
* @returns
|
|
589
|
+
*/
|
|
590
|
+
protected applyResponsePlugins<TBody, TRawResponse, TServerResponse>(input: {
|
|
591
|
+
body: TBody;
|
|
592
|
+
rawResponse?: TRawResponse;
|
|
593
|
+
response?: TServerResponse;
|
|
594
|
+
}): TBody;
|
|
595
|
+
/**
|
|
596
|
+
* Resolve the raw response object from the provided response or the current
|
|
597
|
+
* context, allowing plugins to access and modify the raw response before it is sent.
|
|
598
|
+
*
|
|
599
|
+
* @param response
|
|
600
|
+
* @returns
|
|
601
|
+
*/
|
|
602
|
+
protected resolveRawResponse<TRawResponse>(response?: TRawResponse): TRawResponse | undefined;
|
|
603
|
+
/**
|
|
604
|
+
* Dispatch a body to a raw response object when it exposes a send() transport method.
|
|
605
|
+
*
|
|
606
|
+
* @param raw
|
|
607
|
+
* @param body
|
|
608
|
+
*/
|
|
609
|
+
protected sendRawResponseBody<TBody>(raw: unknown, body: TBody): void;
|
|
532
610
|
/**
|
|
533
611
|
* Add additional metadata to the response. If called without arguments.
|
|
534
612
|
*
|
|
@@ -693,6 +771,7 @@ declare class ResourceCollection<R extends ResourceData[] | Collectible | Collec
|
|
|
693
771
|
* @returns
|
|
694
772
|
*/
|
|
695
773
|
protected getResourceForMeta(): R;
|
|
774
|
+
protected getSerializerType(): "collection";
|
|
696
775
|
/**
|
|
697
776
|
* Get the appropriate key for the response payload based on the current response
|
|
698
777
|
* structure configuration.
|
|
@@ -747,8 +826,8 @@ declare class ResourceCollection<R extends ResourceData[] | Collectible | Collec
|
|
|
747
826
|
/**
|
|
748
827
|
* Promise-like then method to allow chaining with async/await or .then() syntax
|
|
749
828
|
*
|
|
750
|
-
* @param onfulfilled Callback to handle the fulfilled state of the promise
|
|
751
|
-
* @param onrejected Callback to handle the rejected state of the promise
|
|
829
|
+
* @param onfulfilled Callback to handle the fulfilled state of the promise
|
|
830
|
+
* @param onrejected Callback to handle the rejected state of the promise
|
|
752
831
|
* @returns A promise that resolves to the result of the onfulfilled or onrejected callback
|
|
753
832
|
*/
|
|
754
833
|
then<TResult1 = CollectionBody<R>, TResult2 = never>(onfulfilled?: ((value: CollectionBody<R>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
@@ -815,6 +894,7 @@ declare class Resource<R extends ResourceData | NonCollectible = ResourceData> e
|
|
|
815
894
|
protected resolveCurrentRootKey(): string;
|
|
816
895
|
protected applyMetaToBody(meta: MetaData, rootKey: string): void;
|
|
817
896
|
protected getResourceForMeta(): R;
|
|
897
|
+
protected getSerializerType(): "resource";
|
|
818
898
|
private getPayloadKey;
|
|
819
899
|
/**
|
|
820
900
|
* Convert resource to JSON response format
|
|
@@ -935,6 +1015,7 @@ declare class GenericResource<R extends NonCollectible | Collectible | Collectio
|
|
|
935
1015
|
* @returns
|
|
936
1016
|
*/
|
|
937
1017
|
protected getResourceForMeta(): R;
|
|
1018
|
+
protected getSerializerType(): "generic";
|
|
938
1019
|
private getPayloadKey;
|
|
939
1020
|
/**
|
|
940
1021
|
* Convert resource to JSON response format
|
|
@@ -1004,6 +1085,24 @@ declare class GenericResource<R extends NonCollectible | Collectible | Collectio
|
|
|
1004
1085
|
finally(onfinally?: (() => void) | null): Promise<unknown>;
|
|
1005
1086
|
}
|
|
1006
1087
|
//#endregion
|
|
1088
|
+
//#region src/plugins.d.ts
|
|
1089
|
+
type HookEventMap = {
|
|
1090
|
+
beforeSerialize: SerializePluginEvent;
|
|
1091
|
+
afterSerialize: SerializePluginEvent;
|
|
1092
|
+
beforeResponse: ResponsePluginEvent;
|
|
1093
|
+
afterResponse: ResponsePluginEvent;
|
|
1094
|
+
beforeSend: SendPluginEvent;
|
|
1095
|
+
afterSend: SendPluginEvent;
|
|
1096
|
+
};
|
|
1097
|
+
type HookName = keyof HookEventMap;
|
|
1098
|
+
declare const getRegisteredPlugins: () => ResoraPlugin[];
|
|
1099
|
+
declare const registerUtility: (name: string, utility: ResoraPluginUtility) => ResoraPluginUtility;
|
|
1100
|
+
declare const getUtility: <T extends ResoraPluginUtility = ResoraPluginUtility>(name: string) => T | undefined;
|
|
1101
|
+
declare const definePlugin: <T extends ResoraPlugin>(plugin: T) => T;
|
|
1102
|
+
declare const registerPlugin: (plugins: ResoraPlugin | ResoraPlugin[]) => ResoraPlugin[];
|
|
1103
|
+
declare const runPluginHook: <THook extends HookName>(hook: THook, event: HookEventMap[THook]) => HookEventMap[THook];
|
|
1104
|
+
declare const resetPluginsForTests: () => void;
|
|
1105
|
+
//#endregion
|
|
1007
1106
|
//#region src/utilities/case.d.ts
|
|
1008
1107
|
/**
|
|
1009
1108
|
* Splits a string into words based on common delimiters and capitalization patterns.
|
|
@@ -1436,6 +1535,8 @@ declare const setRequestUrl: (url: string | undefined) => void;
|
|
|
1436
1535
|
* @returns The current request URL, or undefined if not set.
|
|
1437
1536
|
*/
|
|
1438
1537
|
declare const getRequestUrl: () => string | undefined;
|
|
1538
|
+
declare const runWithCtx: <T>(ctx: unknown, callback: () => T) => T;
|
|
1539
|
+
declare const getCtx: () => unknown;
|
|
1439
1540
|
/**
|
|
1440
1541
|
* Extracts the request URL pathname (with query string) from an HTTP context.
|
|
1441
1542
|
*
|
|
@@ -1472,4 +1573,4 @@ declare const extractResponseFromCtx: (ctx: unknown) => any | undefined;
|
|
|
1472
1573
|
*/
|
|
1473
1574
|
declare const setCtx: (ctx: unknown) => void;
|
|
1474
1575
|
//#endregion
|
|
1475
|
-
export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CaseStyle, CliApp, Collectible, CollectionBody, CollectionLike, Config, Cursor, GenericBody, GenericResource, InitCommand, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, PaginatorLike, ResoraConfig, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResourceLevelConfig, ResponseData, ResponseDataCollection, ResponseFactory, ResponseFactoryContext, ResponseKind, ResponseStructureConfig, ServerResponse, appendRootProperties, applyRuntimeConfig, buildPaginationExtras, buildResponseEnvelope, createArkormCurrentPageResolver, defineConfig, extractRequestUrl, extractResponseFromCtx, getCaseTransformer, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, getRequestUrl, hasPaginationLink, isArkormLikeCollection, isArkormLikeModel, isPlainObject, loadRuntimeConfig, mergeMetadata, normalizeSerializableData, resetRuntimeConfigForTests, resolveCurrentPage, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, sanitizeConditionalAttributes, setCtx, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, setRequestUrl, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };
|
|
1576
|
+
export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CaseStyle, CliApp, Collectible, CollectionBody, CollectionLike, Config, Cursor, GenericBody, GenericResource, InitCommand, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, PaginatorLike, ResoraConfig, ResoraPlugin, ResoraPluginApi, ResoraPluginUtility, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResourceLevelConfig, ResponseData, ResponseDataCollection, ResponseFactory, ResponseFactoryContext, ResponseKind, ResponsePluginEvent, ResponseStructureConfig, SendPluginEvent, SerializePluginEvent, ServerResponse, appendRootProperties, applyRuntimeConfig, buildPaginationExtras, buildResponseEnvelope, createArkormCurrentPageResolver, defineConfig, definePlugin, extractRequestUrl, extractResponseFromCtx, getCaseTransformer, getCtx, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, getRegisteredPlugins, getRequestUrl, getUtility, hasPaginationLink, isArkormLikeCollection, isArkormLikeModel, isPlainObject, loadRuntimeConfig, mergeMetadata, normalizeSerializableData, registerPlugin, registerUtility, resetPluginsForTests, resetRuntimeConfigForTests, resolveCurrentPage, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, runPluginHook, runWithCtx, sanitizeConditionalAttributes, setCtx, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, setRequestUrl, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };
|
package/dist/index.d.mts
CHANGED
|
@@ -298,6 +298,47 @@ interface ResoraConfig extends Partial<Omit<Config, 'stubs' | 'cursorMeta' | 'pa
|
|
|
298
298
|
responseStructure?: Partial<Config['responseStructure']>;
|
|
299
299
|
}
|
|
300
300
|
//#endregion
|
|
301
|
+
//#region src/types/plugin.d.ts
|
|
302
|
+
type ResoraPluginUtility = (...args: any[]) => unknown;
|
|
303
|
+
interface ResoraPluginApi {
|
|
304
|
+
runWithCtx: <T>(ctx: unknown, callback: () => T) => T;
|
|
305
|
+
setCtx: (ctx: unknown) => void;
|
|
306
|
+
getCtx: () => unknown;
|
|
307
|
+
registerUtility: (name: string, utility: ResoraPluginUtility) => ResoraPluginUtility;
|
|
308
|
+
getUtility: <T extends ResoraPluginUtility = ResoraPluginUtility>(name: string) => T | undefined;
|
|
309
|
+
getRegisteredPlugins: () => ResoraPlugin[];
|
|
310
|
+
}
|
|
311
|
+
interface SerializePluginEvent<TBody = any, TResource = any> {
|
|
312
|
+
serializer: unknown;
|
|
313
|
+
serializerType: ResponseKind;
|
|
314
|
+
resource: TResource;
|
|
315
|
+
body: TBody;
|
|
316
|
+
}
|
|
317
|
+
interface ResponsePluginEvent<TBody = any> {
|
|
318
|
+
serializer: unknown;
|
|
319
|
+
serializerType: ResponseKind;
|
|
320
|
+
rawResponse?: unknown;
|
|
321
|
+
response?: unknown;
|
|
322
|
+
body: TBody;
|
|
323
|
+
}
|
|
324
|
+
interface SendPluginEvent<TBody = any> {
|
|
325
|
+
response: unknown;
|
|
326
|
+
rawResponse: unknown;
|
|
327
|
+
body: TBody;
|
|
328
|
+
status: number;
|
|
329
|
+
headers: Record<string, string>;
|
|
330
|
+
}
|
|
331
|
+
interface ResoraPlugin {
|
|
332
|
+
name: string;
|
|
333
|
+
setup?: (api: ResoraPluginApi) => void;
|
|
334
|
+
beforeSerialize?: (event: SerializePluginEvent, api: ResoraPluginApi) => void;
|
|
335
|
+
afterSerialize?: (event: SerializePluginEvent, api: ResoraPluginApi) => void;
|
|
336
|
+
beforeResponse?: (event: ResponsePluginEvent, api: ResoraPluginApi) => void;
|
|
337
|
+
afterResponse?: (event: ResponsePluginEvent, api: ResoraPluginApi) => void;
|
|
338
|
+
beforeSend?: (event: SendPluginEvent, api: ResoraPluginApi) => void;
|
|
339
|
+
afterSend?: (event: SendPluginEvent, api: ResoraPluginApi) => void;
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
301
342
|
//#region src/cli/CliApp.d.ts
|
|
302
343
|
declare class CliApp {
|
|
303
344
|
command: Command;
|
|
@@ -529,6 +570,43 @@ declare abstract class BaseSerializer<TResource = any> {
|
|
|
529
570
|
protected abstract resolveCurrentRootKey(): string;
|
|
530
571
|
protected abstract applyMetaToBody(meta: MetaData, rootKey: string): void;
|
|
531
572
|
protected abstract getResourceForMeta(): TResource;
|
|
573
|
+
protected abstract getSerializerType(): ResponseKind;
|
|
574
|
+
protected abstract setBody(body: any): this;
|
|
575
|
+
/**
|
|
576
|
+
* Apply registered plugins for the serialization process, allowing plugins to
|
|
577
|
+
* modify the response body and metadata before the response is sent.
|
|
578
|
+
*
|
|
579
|
+
* @param body
|
|
580
|
+
* @returns
|
|
581
|
+
*/
|
|
582
|
+
protected applySerializePlugins<TBody>(body: TBody): TBody;
|
|
583
|
+
/**
|
|
584
|
+
* Apply registered plugins for the response process, allowing plugins to modify the
|
|
585
|
+
* response body, headers, and status before the response is sent.
|
|
586
|
+
*
|
|
587
|
+
* @param input
|
|
588
|
+
* @returns
|
|
589
|
+
*/
|
|
590
|
+
protected applyResponsePlugins<TBody, TRawResponse, TServerResponse>(input: {
|
|
591
|
+
body: TBody;
|
|
592
|
+
rawResponse?: TRawResponse;
|
|
593
|
+
response?: TServerResponse;
|
|
594
|
+
}): TBody;
|
|
595
|
+
/**
|
|
596
|
+
* Resolve the raw response object from the provided response or the current
|
|
597
|
+
* context, allowing plugins to access and modify the raw response before it is sent.
|
|
598
|
+
*
|
|
599
|
+
* @param response
|
|
600
|
+
* @returns
|
|
601
|
+
*/
|
|
602
|
+
protected resolveRawResponse<TRawResponse>(response?: TRawResponse): TRawResponse | undefined;
|
|
603
|
+
/**
|
|
604
|
+
* Dispatch a body to a raw response object when it exposes a send() transport method.
|
|
605
|
+
*
|
|
606
|
+
* @param raw
|
|
607
|
+
* @param body
|
|
608
|
+
*/
|
|
609
|
+
protected sendRawResponseBody<TBody>(raw: unknown, body: TBody): void;
|
|
532
610
|
/**
|
|
533
611
|
* Add additional metadata to the response. If called without arguments.
|
|
534
612
|
*
|
|
@@ -693,6 +771,7 @@ declare class ResourceCollection<R extends ResourceData[] | Collectible | Collec
|
|
|
693
771
|
* @returns
|
|
694
772
|
*/
|
|
695
773
|
protected getResourceForMeta(): R;
|
|
774
|
+
protected getSerializerType(): "collection";
|
|
696
775
|
/**
|
|
697
776
|
* Get the appropriate key for the response payload based on the current response
|
|
698
777
|
* structure configuration.
|
|
@@ -747,8 +826,8 @@ declare class ResourceCollection<R extends ResourceData[] | Collectible | Collec
|
|
|
747
826
|
/**
|
|
748
827
|
* Promise-like then method to allow chaining with async/await or .then() syntax
|
|
749
828
|
*
|
|
750
|
-
* @param onfulfilled Callback to handle the fulfilled state of the promise
|
|
751
|
-
* @param onrejected Callback to handle the rejected state of the promise
|
|
829
|
+
* @param onfulfilled Callback to handle the fulfilled state of the promise
|
|
830
|
+
* @param onrejected Callback to handle the rejected state of the promise
|
|
752
831
|
* @returns A promise that resolves to the result of the onfulfilled or onrejected callback
|
|
753
832
|
*/
|
|
754
833
|
then<TResult1 = CollectionBody<R>, TResult2 = never>(onfulfilled?: ((value: CollectionBody<R>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
@@ -815,6 +894,7 @@ declare class Resource<R extends ResourceData | NonCollectible = ResourceData> e
|
|
|
815
894
|
protected resolveCurrentRootKey(): string;
|
|
816
895
|
protected applyMetaToBody(meta: MetaData, rootKey: string): void;
|
|
817
896
|
protected getResourceForMeta(): R;
|
|
897
|
+
protected getSerializerType(): "resource";
|
|
818
898
|
private getPayloadKey;
|
|
819
899
|
/**
|
|
820
900
|
* Convert resource to JSON response format
|
|
@@ -935,6 +1015,7 @@ declare class GenericResource<R extends NonCollectible | Collectible | Collectio
|
|
|
935
1015
|
* @returns
|
|
936
1016
|
*/
|
|
937
1017
|
protected getResourceForMeta(): R;
|
|
1018
|
+
protected getSerializerType(): "generic";
|
|
938
1019
|
private getPayloadKey;
|
|
939
1020
|
/**
|
|
940
1021
|
* Convert resource to JSON response format
|
|
@@ -1004,6 +1085,24 @@ declare class GenericResource<R extends NonCollectible | Collectible | Collectio
|
|
|
1004
1085
|
finally(onfinally?: (() => void) | null): Promise<unknown>;
|
|
1005
1086
|
}
|
|
1006
1087
|
//#endregion
|
|
1088
|
+
//#region src/plugins.d.ts
|
|
1089
|
+
type HookEventMap = {
|
|
1090
|
+
beforeSerialize: SerializePluginEvent;
|
|
1091
|
+
afterSerialize: SerializePluginEvent;
|
|
1092
|
+
beforeResponse: ResponsePluginEvent;
|
|
1093
|
+
afterResponse: ResponsePluginEvent;
|
|
1094
|
+
beforeSend: SendPluginEvent;
|
|
1095
|
+
afterSend: SendPluginEvent;
|
|
1096
|
+
};
|
|
1097
|
+
type HookName = keyof HookEventMap;
|
|
1098
|
+
declare const getRegisteredPlugins: () => ResoraPlugin[];
|
|
1099
|
+
declare const registerUtility: (name: string, utility: ResoraPluginUtility) => ResoraPluginUtility;
|
|
1100
|
+
declare const getUtility: <T extends ResoraPluginUtility = ResoraPluginUtility>(name: string) => T | undefined;
|
|
1101
|
+
declare const definePlugin: <T extends ResoraPlugin>(plugin: T) => T;
|
|
1102
|
+
declare const registerPlugin: (plugins: ResoraPlugin | ResoraPlugin[]) => ResoraPlugin[];
|
|
1103
|
+
declare const runPluginHook: <THook extends HookName>(hook: THook, event: HookEventMap[THook]) => HookEventMap[THook];
|
|
1104
|
+
declare const resetPluginsForTests: () => void;
|
|
1105
|
+
//#endregion
|
|
1007
1106
|
//#region src/utilities/case.d.ts
|
|
1008
1107
|
/**
|
|
1009
1108
|
* Splits a string into words based on common delimiters and capitalization patterns.
|
|
@@ -1436,6 +1535,8 @@ declare const setRequestUrl: (url: string | undefined) => void;
|
|
|
1436
1535
|
* @returns The current request URL, or undefined if not set.
|
|
1437
1536
|
*/
|
|
1438
1537
|
declare const getRequestUrl: () => string | undefined;
|
|
1538
|
+
declare const runWithCtx: <T>(ctx: unknown, callback: () => T) => T;
|
|
1539
|
+
declare const getCtx: () => unknown;
|
|
1439
1540
|
/**
|
|
1440
1541
|
* Extracts the request URL pathname (with query string) from an HTTP context.
|
|
1441
1542
|
*
|
|
@@ -1472,4 +1573,4 @@ declare const extractResponseFromCtx: (ctx: unknown) => any | undefined;
|
|
|
1472
1573
|
*/
|
|
1473
1574
|
declare const setCtx: (ctx: unknown) => void;
|
|
1474
1575
|
//#endregion
|
|
1475
|
-
export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CaseStyle, CliApp, Collectible, CollectionBody, CollectionLike, Config, Cursor, GenericBody, GenericResource, InitCommand, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, PaginatorLike, ResoraConfig, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResourceLevelConfig, ResponseData, ResponseDataCollection, ResponseFactory, ResponseFactoryContext, ResponseKind, ResponseStructureConfig, ServerResponse, appendRootProperties, applyRuntimeConfig, buildPaginationExtras, buildResponseEnvelope, createArkormCurrentPageResolver, defineConfig, extractRequestUrl, extractResponseFromCtx, getCaseTransformer, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, getRequestUrl, hasPaginationLink, isArkormLikeCollection, isArkormLikeModel, isPlainObject, loadRuntimeConfig, mergeMetadata, normalizeSerializableData, resetRuntimeConfigForTests, resolveCurrentPage, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, sanitizeConditionalAttributes, setCtx, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, setRequestUrl, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };
|
|
1576
|
+
export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CaseStyle, CliApp, Collectible, CollectionBody, CollectionLike, Config, Cursor, GenericBody, GenericResource, InitCommand, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, PaginatorLike, ResoraConfig, ResoraPlugin, ResoraPluginApi, ResoraPluginUtility, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResourceLevelConfig, ResponseData, ResponseDataCollection, ResponseFactory, ResponseFactoryContext, ResponseKind, ResponsePluginEvent, ResponseStructureConfig, SendPluginEvent, SerializePluginEvent, ServerResponse, appendRootProperties, applyRuntimeConfig, buildPaginationExtras, buildResponseEnvelope, createArkormCurrentPageResolver, defineConfig, definePlugin, extractRequestUrl, extractResponseFromCtx, getCaseTransformer, getCtx, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, getRegisteredPlugins, getRequestUrl, getUtility, hasPaginationLink, isArkormLikeCollection, isArkormLikeModel, isPlainObject, loadRuntimeConfig, mergeMetadata, normalizeSerializableData, registerPlugin, registerUtility, resetPluginsForTests, resetRuntimeConfigForTests, resolveCurrentPage, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, runPluginHook, runWithCtx, sanitizeConditionalAttributes, setCtx, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, setRequestUrl, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };
|