Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
kawikabader committed Jan 13, 2025
1 parent 53edd1b commit 35a2756
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions packages/gasket-data/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@ import type { Gasket, GasketRequest } from '@gasket/core';
import type { IncomingMessage } from 'http';

declare module '@gasket/data' {
/**
* Represents the structure of the Gasket data object.
*/
export interface GasketData {
config?: { [key: string | number]: string | undefined };
config?: Record<string | number, string | undefined>;
}
}

/**
* Function to retrieve Gasket data from the DOM.
* This function is intended to be used on the client side only.
* It retrieves the content of the element with the id 'GasketData' and parses it as JSON.
* Use in the browser to retrieve data injected by the server.
*/
export function gasketData(): GasketData;
/**
* Function to retrieve Gasket data from the DOM.
* This function is intended to be used on the client side only.
* It retrieves the content of the element with the id 'GasketData' and parses it as JSON.
* Use in the browser to retrieve data injected by the server.
*/
export function gasketData(): GasketData;

export function resolveGasketData(gasket: Gasket, req: GasketRequest | IncomingMessage): Promise<GasketData>;
/**
* Function to resolve Gasket data, combining server and request context.
* @param gasket - The Gasket instance.
* @param req - The request object, either a GasketRequest or IncomingMessage.
* @returns A promise resolving to the GasketData object.
*/
export function resolveGasketData(gasket: Gasket, req: GasketRequest | IncomingMessage): Promise<GasketData>;
}

0 comments on commit 35a2756

Please sign in to comment.