Skip to content

Commit

Permalink
distにタイプ定義を追加・corepack install
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid committed Nov 8, 2024
1 parent d141e15 commit 96d8d4a
Show file tree
Hide file tree
Showing 30 changed files with 239 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ COPY --chown=summaly:summaly . ./

ENV NODE_ENV=production

RUN pnpm i --frozen-lockfile --aggregate-output
RUN pnpm install fastify-cli

RUN corepack pack
RUN corepack install \
&& pnpm i --frozen-lockfile --aggregate-output \
&& pnpm install fastify-cli \
&& corepack pack

ENV COREPACK_ENABLE_NETWORK=0
ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so
ENV MALLOC_CONF=background_thread:true,metadata_thp:auto,dirty_decay_ms:30000,muzzy_decay_ms:30000

Expand Down
13 changes: 13 additions & 0 deletions dist/general.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { URL } from 'node:url';
import type { default as Summary } from './summary.js';
export type GeneralScrapingOptions = {
lang?: string | null;
userAgent?: string;
responseTimeout?: number;
operationTimeout?: number;
contentLengthLimit?: number;
contentLengthRequired?: boolean;
};
declare const _default: (_url: URL | string, opts?: GeneralScrapingOptions) => Promise<Summary | null>;
export default _default;
//# sourceMappingURL=general.d.ts.map
1 change: 1 addition & 0 deletions dist/general.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* summaly
* https://github.com/misskey-dev/summaly
*/
import type { FastifyInstance } from 'fastify';
import type * as Got from 'got';
import type { SummalyPlugin } from './iplugin.js';
import type { SummalyResult } from './summary.js';
export * from './iplugin.js';
export type SummalyOptions = {
/**
* Accept-Language for the request
*/
lang?: string | null;
/**
* Whether follow redirects
*/
followRedirects?: boolean;
/**
* Custom Plugins
*/
plugins?: SummalyPlugin[];
/**
* Custom HTTP agent
*/
agent?: Got.Agents;
/**
* User-Agent for the request
*/
userAgent?: string;
/**
* Response timeout.
* Set timeouts for each phase, such as host name resolution and socket communication.
*/
responseTimeout?: number;
/**
* Operation timeout.
* Set the timeout from the start to the end of the request.
*/
operationTimeout?: number;
/**
* Maximum content length.
* If set to true, an error will occur if the content-length value returned from the other server is larger than this parameter (or if the received body size exceeds this parameter).
*/
contentLengthLimit?: number;
/**
* Content length required.
* If set to true, it will be an error if the other server does not return content-length.
*/
contentLengthRequired?: boolean;
};
export declare const summalyDefaultOptions: SummalyOptions;
/**
* Summarize an web page
*/
export declare const summaly: (url: string, options?: SummalyOptions) => Promise<SummalyResult>;
export default function (fastify: FastifyInstance, options: SummalyOptions, done: (err?: Error) => void): void;
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions dist/iplugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { URL } from 'node:url';
import type { GeneralScrapingOptions } from '@/general.js';
import type Summary from './summary.js';
export interface SummalyPlugin {
test: (url: URL) => boolean;
summarize: (url: URL, opts?: GeneralScrapingOptions) => Promise<Summary | null>;
}
//# sourceMappingURL=iplugin.d.ts.map
1 change: 1 addition & 0 deletions dist/iplugin.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/plugins/_.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { SummalyPlugin } from '@/iplugin.js';
export declare const plugins: SummalyPlugin[];
//# sourceMappingURL=_.d.ts.map
1 change: 1 addition & 0 deletions dist/plugins/_.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions dist/plugins/amazon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { URL } from 'node:url';
import type summary from '../summary.js';
export declare function test(url: URL): boolean;
export declare function summarize(url: URL): Promise<summary>;
//# sourceMappingURL=amazon.d.ts.map
1 change: 1 addition & 0 deletions dist/plugins/amazon.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/plugins/bluesky.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type summary from '../summary.js';
export declare function test(url: URL): boolean;
export declare function summarize(url: URL): Promise<summary>;
//# sourceMappingURL=bluesky.d.ts.map
1 change: 1 addition & 0 deletions dist/plugins/bluesky.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions dist/plugins/branchio-deeplinks.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { URL } from 'node:url';
import { type GeneralScrapingOptions } from '../general.js';
import type Summary from '../summary.js';
export declare function test(url: URL): boolean;
export declare function summarize(url: URL, opts?: GeneralScrapingOptions): Promise<Summary | null>;
//# sourceMappingURL=branchio-deeplinks.d.ts.map
1 change: 1 addition & 0 deletions dist/plugins/branchio-deeplinks.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions dist/plugins/wikipedia.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { URL } from 'node:url';
import type summary from '../summary.js';
export declare function test(url: URL): boolean;
export declare function summarize(url: URL): Promise<summary>;
//# sourceMappingURL=wikipedia.d.ts.map
1 change: 1 addition & 0 deletions dist/plugins/wikipedia.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions dist/summary.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
type Summary = {
/**
* The title of that web page
*/
title: string | null;
/**
* The url of the icon of that web page
*/
icon: string | null;
/**
* The description of that web page
*/
description: string | null;
/**
* The url of the thumbnail of that web page
*/
thumbnail: string | null;
/**
* The name of site of that web page
*/
sitename: string | null;
/**
* The player of that web page
*/
player: Player;
/**
* Possibly sensitive
*/
sensitive?: boolean;
/**
* The url of the ActivityPub representation of that web page
*/
activityPub: string | null;
};
export type SummalyResult = Summary & {
/**
* The actual url of that web page
*/
url: string;
};
export default Summary;
export type Player = {
/**
* The url of the player
*/
url: string | null;
/**
* The width of the player
*/
width: number | null;
/**
* The height of the player
*/
height: number | null;
/**
* The allowed permissions of the iframe
*/
allow: string[];
};
//# sourceMappingURL=summary.d.ts.map
1 change: 1 addition & 0 deletions dist/summary.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/utils/cleanup-title.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default function (_title: string, _siteName?: string | null): string;
//# sourceMappingURL=cleanup-title.d.ts.map
1 change: 1 addition & 0 deletions dist/utils/cleanup-title.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/utils/clip.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default function (_s: string | null | undefined, max: number): string;
//# sourceMappingURL=clip.d.ts.map
1 change: 1 addition & 0 deletions dist/utils/clip.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions dist/utils/encoding.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type * as Got from 'got';
/**
* Detect HTML encoding
* @param response Response
* @returns encoding
*/
export declare function detectEncoding(response: Got.Response<string>): string;
export declare function toUtf8(body: Buffer, encoding: string): string;
//# sourceMappingURL=encoding.d.ts.map
1 change: 1 addition & 0 deletions dist/utils/encoding.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions dist/utils/got.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as cheerio from 'cheerio';
import * as Got from 'got';
export declare let agent: Got.Agents;
export declare function setAgent(_agent: Got.Agents): void;
export type GotOptions = {
url: string;
method: 'GET' | 'POST' | 'HEAD';
body?: string;
headers: Record<string, string | undefined>;
typeFilter?: RegExp;
responseTimeout?: number;
operationTimeout?: number;
contentLengthLimit?: number;
contentLengthRequired?: boolean;
};
export declare const DEFAULT_RESPONSE_TIMEOUT: number;
export declare const DEFAULT_OPERATION_TIMEOUT: number;
export declare const DEFAULT_MAX_RESPONSE_SIZE: number;
export declare const DEFAULT_BOT_UA: string;
export declare function scpaping(url: string, opts?: {
lang?: string;
userAgent?: string;
responseTimeout?: number;
operationTimeout?: number;
contentLengthLimit?: number;
contentLengthRequired?: boolean;
}): Promise<{
body: string;
$: cheerio.CheerioAPI;
response: Got.Response<string>;
}>;
export declare function get(url: string): Promise<string>;
export declare function head(url: string): Promise<Got.Response<string>>;
//# sourceMappingURL=got.d.ts.map
1 change: 1 addition & 0 deletions dist/utils/got.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions dist/utils/status-error.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export declare class StatusError extends Error {
name: string;
statusCode?: number;
statusMessage?: string;
isPermanentError: boolean;
constructor(message: string, statusCode?: number, statusMessage?: string);
}
//# sourceMappingURL=status-error.d.ts.map
1 change: 1 addition & 0 deletions dist/utils/status-error.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"packageManager": "[email protected]",
"files": ["dist", "LICENSE"],
"scripts": {
"build": "swc src -d dist -D --strip-leading-paths",
"build": "pnpm run build:swc && pnpm run build:dts",
"build:swc": "swc src -d dist -D --strip-leading-paths",
"build:dts": "tsc --outDir dist --declaration true --emitDeclarationOnly true --declarationMap true",
"clean": "node scripts/clean.cjs",
"format": "biome check --write",
"check": "pnpm run build && biome check",
Expand Down

0 comments on commit 96d8d4a

Please sign in to comment.