Skip to content

Commit

Permalink
Merge pull request #2 from zicklag/patch-1
Browse files Browse the repository at this point in the history
feat: add typescript definition file.
  • Loading branch information
anderspitman authored Oct 16, 2024
2 parents 2db2186 + 01306fa commit 38082a2
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
63 changes: 63 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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;

getRecords(opt?: {
domain?: string;
host?: string;
records: [];
}): Promise<NamedropRecord[]>;
createRecords(opt: {
domain: string;
host: string;
records: NamedropRecord[];
}): Promise<void>;
setRecords(opt: {
domain: string;
host: string;
records: NamedropRecord[];
}): Promise<void>;
deleteRecords(opt: {
domain: string;
host: string;
records: NamedropRecord[];
}): Promise<void>;
}

export function setApiUri(uri: string): void;
export function checkAuthFlow(): Promise<Client>;
export function startAuthFlow(req: { scopes: string[] }): Promise<void>;

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;
};
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit 38082a2

Please sign in to comment.