From 5fa02090263e26dbd90fc20065fe2ed834ae32ed Mon Sep 17 00:00:00 2001 From: Zicklag Date: Wed, 16 Oct 2024 10:49:57 -0500 Subject: [PATCH 1/3] feat: add typescript definition file. --- index.d.ts | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..3440477 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,63 @@ +declare module 'namedrop-js' { + export const SCOPE_HOSTS: string; + export const SCOPE_MAIL: string; + export const SCOPE_ACME: string; + export const SCOPE_ATPROTO_HANDLE: string; + export const validScopes: string[]; + + export class Client { + constructor(params: { token: string; permission: string; domain: string; host: string }); + + get domain(): string; + get host(): string; + get token(): string; + get permissions(): string; + + async getRecords(opt?: { + domain?: string; + host?: string; + records: []; + }): Promise; + async createRecords(opt: { + domain: string; + host: string; + records: NamedropRecord[]; + }): Promise; + async setRecords(opt: { + domain: string; + host: string; + records: NamedropRecord[]; + }): Promise; + async deleteRecords(opt: { + domain: string; + host: string; + records: NamedropRecord[]; + }): Promise; + } + + export function setApiUri(uri: string): void; + export async function checkAuthFlow(): Promise; + export async function startAuthFlow(req: { scopes: string[] }): Promise; + + export type NamedropScope = + | 'namedrop-hosts' + | 'namedrop-mail' + | 'namedrop-acme' + | 'namedrop-atproto-handle'; + + export type NamedropRecord = { + type: 'A' | 'AAAA' | 'CNAME' | 'TXT' | 'MX' | 'NS' | 'SRV' | 'ANAME'; + value?: string; + domain?: string; + /** + * May contain the `{{host}}` placeholder to substitute for the domain host. + * + * For example you can set a subdomain host with: + * + * example.{{host}} + */ + host?: string; + ttl?: number; + priority?: number; + }; +} From a6ce931e8a4b96af9aeb461fe8a5bcb42510d9fb Mon Sep 17 00:00:00 2001 From: Zicklag Date: Wed, 16 Oct 2024 10:51:19 -0500 Subject: [PATCH 2/3] fix: add types declaration to package.json. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 57742f8..d6dc681 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "type": "module", "version": "0.5.0", "main": "index.js", + "types": "index.d.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, From 01306fab1c330fac20d16976830454ad51d1546c Mon Sep 17 00:00:00 2001 From: Zicklag Date: Wed, 16 Oct 2024 10:53:44 -0500 Subject: [PATCH 3/3] fix: don't use `async` modifier in an ambiant context. --- index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3440477..86371f0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -13,22 +13,22 @@ declare module 'namedrop-js' { get token(): string; get permissions(): string; - async getRecords(opt?: { + getRecords(opt?: { domain?: string; host?: string; records: []; }): Promise; - async createRecords(opt: { + createRecords(opt: { domain: string; host: string; records: NamedropRecord[]; }): Promise; - async setRecords(opt: { + setRecords(opt: { domain: string; host: string; records: NamedropRecord[]; }): Promise; - async deleteRecords(opt: { + deleteRecords(opt: { domain: string; host: string; records: NamedropRecord[]; @@ -36,8 +36,8 @@ declare module 'namedrop-js' { } export function setApiUri(uri: string): void; - export async function checkAuthFlow(): Promise; - export async function startAuthFlow(req: { scopes: string[] }): Promise; + export function checkAuthFlow(): Promise; + export function startAuthFlow(req: { scopes: string[] }): Promise; export type NamedropScope = | 'namedrop-hosts'