Skip to content

Commit 669ab52

Browse files
🤖 Merge PR DefinitelyTyped#72059 Added types for pageclip by @max-programming
1 parent 1df7372 commit 669ab52

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed

types/pageclip/.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!**/*.d.ts
3+
!**/*.d.cts
4+
!**/*.d.mts
5+
!**/*.d.*.ts

types/pageclip/index.d.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import type { CoreOptions, UriOptions, UrlOptions } from "request";
2+
3+
declare class Pageclip {
4+
constructor(token: string, options?: Pageclip.PageclipOptions);
5+
6+
fetch(bucketName?: string): Promise<Pageclip.Response>;
7+
send(bucketName: string, data: Pageclip.SendData): Promise<Pageclip.Response>;
8+
send(data: Pageclip.SendData): Promise<Pageclip.Response>;
9+
10+
private _token: string;
11+
private _base64Token: string;
12+
private _options: Pageclip.PageclipOptions;
13+
14+
private _getBucketName(bucketName?: string): string;
15+
private _request(method: string, url: string, args?: unknown): Promise<Pageclip.Response>;
16+
private _getRequestOptions(method: string, url: string, body?: unknown): CoreOptions & UriOptions & UrlOptions;
17+
private _getHeaders(): Record<string, string>;
18+
}
19+
20+
declare namespace Pageclip {
21+
interface PageclipOptions {
22+
baseURL?: string;
23+
}
24+
25+
type SendData = Record<string, unknown> | Array<Record<string, unknown>>;
26+
27+
interface Item {
28+
itemEid: string;
29+
createdAt: string;
30+
payload: Record<string, unknown>;
31+
}
32+
33+
interface Error {
34+
message: string;
35+
property?: string;
36+
}
37+
38+
interface Response {
39+
status: number;
40+
form: string;
41+
data: Item[];
42+
errors?: Error[];
43+
}
44+
}
45+
46+
export = Pageclip;

types/pageclip/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"private": true,
3+
"name": "@types/pageclip",
4+
"version": "1.0.9999",
5+
"projects": [
6+
"https://github.com/benogle/node-pageclip#readme"
7+
],
8+
"devDependencies": {
9+
"@types/pageclip": "workspace:."
10+
},
11+
"owners": [
12+
{
13+
"name": "Usman S. (Max Programming)",
14+
"githubUsername": "max-programming"
15+
}
16+
],
17+
"dependencies": {
18+
"@types/node": "^22.13.9999",
19+
"@types/request": "^2.48.9999"
20+
}
21+
}

types/pageclip/pageclip-tests.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Pageclip from "pageclip";
2+
3+
const pageclip = new Pageclip("abc123ABC123abc123abc123abc12345");
4+
5+
pageclip.send({ some: "data" }).then((response) => {
6+
console.log(response.status, response.form, response.data);
7+
});
8+
9+
pageclip.send([{ some: "data" }, { some: "otherdata" }]).then((response) => {
10+
console.log(response.status, response.form, response.data);
11+
});
12+
13+
pageclip.send("mailinglist", { email: "[email protected]" }).then((response) => {
14+
console.log(response.status, response.form, response.data);
15+
});
16+
17+
pageclip.fetch().then((response) => {
18+
console.log(response.status, response.form, response.data);
19+
});
20+
21+
pageclip.fetch("mailinglist").then((response) => {
22+
console.log(response.status, response.form, response.data);
23+
});

types/pageclip/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"module": "node16",
4+
"lib": ["es6"],
5+
"noImplicitAny": true,
6+
"noImplicitThis": true,
7+
"strictFunctionTypes": true,
8+
"strictNullChecks": true,
9+
"types": [],
10+
"noEmit": true,
11+
"forceConsistentCasingInFileNames": true
12+
},
13+
"files": ["index.d.ts", "pageclip-tests.ts"]
14+
}

0 commit comments

Comments
 (0)