Skip to content

Commit

Permalink
Merge pull request #391 from podium-lib/test-types
Browse files Browse the repository at this point in the history
fix: update dependency typings
  • Loading branch information
wkillerud authored May 14, 2024
2 parents dd2629e + b087fbf commit 6f3da81
Show file tree
Hide file tree
Showing 6 changed files with 1,934 additions and 1,647 deletions.
14 changes: 13 additions & 1 deletion fixup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@
cat >> types/podlet.d.ts <<!EOF
declare global {
namespace Express {
interface Response {
export interface Response {
/**
* Calls the send / write method on the \`http.ServerResponse\` object.
*
* When in development mode this method will wrap the provided fragment in a
* default HTML document before dispatching. When not in development mode, this
* method will just dispatch the fragment.
*
* @example
* app.get(podlet.content(), (req, res) => {
* res.podiumSend('<h1>Hello World</h1>');
* });
*/
podiumSend(fragment: string, ...args: unknown[]): Response;
}
}
Expand Down
15 changes: 3 additions & 12 deletions lib/podlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@

import {
HttpIncoming,
// @ts-ignore
pathnameBuilder,
AssetCss,
AssetJs,
} from '@podium/utils';
// @ts-ignore
import * as schema from '@podium/schemas';
import Metrics from '@metrics/client';
// @ts-ignore
import abslog from 'abslog';
// @ts-ignore
import objobj from 'objobj';
import * as utils from '@podium/utils';
// @ts-ignore
import Proxy from '@podium/proxy';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
Expand All @@ -31,13 +26,9 @@ const pkgJson = fs.readFileSync(
);
const pkg = JSON.parse(pkgJson);

// @ts-ignore
const { template } = utils;

/**
* @typedef {(...args: any) => void} LogFunction
* @typedef {{ trace: LogFunction, debug: LogFunction, info: LogFunction, warn: LogFunction, error: LogFunction, fatal: LogFunction }} AbsLogger
*
* @typedef {Object} PodletOptions
* @property {string} name - (required) podlet name
* @property {string} version - (required) podlet version
Expand All @@ -46,8 +37,8 @@ const { template } = utils;
* @property {string} [content] - path where the podlet content HTML markup is served from (default '/')
* @property {string} [fallback] - path where the podlet fallback HTML markup is served from (default '/fallback')
* @property {boolean} [development] - a boolean flag that, when true, enables additional development setup (default false)
* @property {Console | AbsLogger} [logger] - a logger to use when provided. Can be the console object if console logging is desired but can also be any Log4j compatible logging object as well. Nothing is logged if no logger is provided. (default null)
* @property {import("@podium/proxy").default.PodiumProxyOptions} [proxy] - options that can be provided to configure the @podium/proxy instance used by the podlet. See that module for details.
* @property {import('abslog').AbstractLoggerOptions} [logger] - a logger to use when provided. Can be the console object if console logging is desired but can also be any Log4j compatible logging object as well. Nothing is logged if no logger is provided. (default null)
* @property {import("@podium/proxy").PodiumProxyOptions} [proxy] - options that can be provided to configure the @podium/proxy instance used by the podlet. See that module for details.
*
* @typedef {{ debug: 'true' | 'false', locale: string, deviceType: string, requestedBy: string, mountOrigin: string, mountPathname: string, publicPathname: string }} PodletContext
* @typedef {{ as?: string | false | null, crossorigin?: string | null | boolean, disabled?: boolean | '' | null, hreflang?: string | false | null, title?: string | false | null, media?: string | false | null, rel?: string | false | null, type?: string | false | null, value: string | false | null, data?: Array<{ key: string; value: string }>, strategy?: "beforeInteractive" | "afterInteractive" | "lazy", scope?: "content" | "fallback" | "all", [key: string]: any }} AssetCssLike
Expand Down Expand Up @@ -137,7 +128,7 @@ export default class PodiumPodlet {
* podlet.log.fatal('fatal log to the console')
* ```
*
* @type {AbsLogger}
* @type {import('abslog').ValidLogger}
*/
log;

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "tap --disable-coverage --allow-empty-coverage",
"test": "tap --disable-coverage --allow-empty-coverage && tsc --project tsconfig.test.json",
"types": "tsc --declaration --emitDeclarationOnly && ./fixup.sh"
},
"dependencies": {
"@metrics/client": "2.5.2",
"@podium/proxy": "5.0.14",
"@podium/schemas": "5.0.1",
"@podium/proxy": "5.0.16",
"@podium/schemas": "5.0.2",
"@podium/utils": "5.0.6",
"abslog": "2.4.4",
"ajv": "8.13.0",
Expand All @@ -48,6 +48,7 @@
"@semantic-release/npm": "11.0.3",
"@semantic-release/release-notes-generator": "12.1.0",
"@types/node": "^20.10.3",
"@types/readable-stream": "4.0.14",
"eslint": "8.57.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.1.0",
Expand Down
Loading

0 comments on commit 6f3da81

Please sign in to comment.