@badrap/libapp
Advanced tools
Comparing version 0.1.7 to 0.2.0
{ | ||
"name": "@badrap/libapp", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"extensions": [ | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode" | ||
], | ||
"postCreateCommand": "npm ci", | ||
"remoteUser": "node", | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached", | ||
"workspaceFolder": "/workspace", | ||
"mounts": [ | ||
"type=volume,target=/workspace/node_modules", | ||
"type=volume,target=/workspace/dist" | ||
] | ||
"name": "@badrap/libapp", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"postCreateCommand": "npm ci", | ||
"remoteUser": "node", | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached", | ||
"workspaceFolder": "/workspace", | ||
"mounts": [ | ||
"type=volume,target=/workspace/node_modules", | ||
"type=volume,target=/workspace/dist" | ||
], | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
} | ||
} |
{ | ||
"eslint.validate": ["javascript", "typescript"], | ||
"explorer.excludeGitIgnore": true, | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"eslint.format.enable": true, | ||
"typescript.tsdk": "./node_modules/typescript/lib", | ||
"editor.formatOnSave": true, | ||
"editor.tabSize": 2, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"[javascript][typescript][javascriptreact][typescriptreact]": { | ||
"eslint.format.enable": true, | ||
"explorer.excludeGitIgnore": true, | ||
"[json][jsonc]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[javascript][javascriptreact][typescript][typescriptreact]": { | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint" | ||
} | ||
} |
@@ -39,3 +39,2 @@ "use strict"; | ||
async requestWithEtag(options) { | ||
var _a; | ||
let pathname = this.baseUrl.pathname + `/app/${joinPath(options.path)}`; | ||
@@ -61,3 +60,3 @@ pathname = pathname.replace(/\/+/g, "/"); | ||
await response.body.dump(); | ||
throw new HTTPError(response.statusCode, (_a = node_http_1.STATUS_CODES[response.statusCode]) !== null && _a !== void 0 ? _a : ""); | ||
throw new HTTPError(response.statusCode, node_http_1.STATUS_CODES[response.statusCode] ?? ""); | ||
} | ||
@@ -67,3 +66,3 @@ const etag = getHeader(response.headers, "etag"); | ||
let json = undefined; | ||
if (!/^application\/json\s*(;|$)/.test(contentType !== null && contentType !== void 0 ? contentType : "")) { | ||
if (!/^application\/json\s*(;|$)/.test(contentType ?? "")) { | ||
await response.body.dump(); | ||
@@ -70,0 +69,0 @@ } |
@@ -41,3 +41,3 @@ "use strict"; | ||
this.client = new client_js_1.Client(apiUrl, apiToken); | ||
this.stateType = stateType !== null && stateType !== void 0 ? stateType : v.record(); | ||
this.stateType = stateType ?? v.record(); | ||
this.experimentalKv = new kv_js_1.Kv(this.client); | ||
@@ -117,3 +117,3 @@ } | ||
async updateInstallation(installationId, callback, options) { | ||
const { maxRetries = Infinity } = options !== null && options !== void 0 ? options : {}; | ||
const { maxRetries = Infinity } = options ?? {}; | ||
for (let i = 0; i <= maxRetries; i++) { | ||
@@ -177,5 +177,5 @@ const { body, etag } = await this.client.requestWithEtag({ | ||
name, | ||
title: config === null || config === void 0 ? void 0 : config.title, | ||
summary_template: config === null || config === void 0 ? void 0 : config.summaryTemplate, | ||
details_template: config === null || config === void 0 ? void 0 : config.detailsTemplate, | ||
title: config?.title, | ||
summary_template: config?.summaryTemplate, | ||
details_template: config?.detailsTemplate, | ||
}, | ||
@@ -193,5 +193,5 @@ }); | ||
json: { | ||
title: config === null || config === void 0 ? void 0 : config.title, | ||
summary_template: config === null || config === void 0 ? void 0 : config.summaryTemplate, | ||
details_template: config === null || config === void 0 ? void 0 : config.detailsTemplate, | ||
title: config?.title, | ||
summary_template: config?.summaryTemplate, | ||
details_template: config?.detailsTemplate, | ||
}, | ||
@@ -198,0 +198,0 @@ }); |
@@ -62,3 +62,3 @@ "use strict"; | ||
async *list(selector, options) { | ||
let { limit } = options !== null && options !== void 0 ? options : {}; | ||
let { limit } = options ?? {}; | ||
let cursor = undefined; | ||
@@ -65,0 +65,0 @@ while (limit === undefined || limit > 0) { |
{ | ||
"name": "@badrap/libapp", | ||
"version": "0.1.7", | ||
"version": "0.2.0", | ||
"description": "TypeScript helpers for creating Badrap apps", | ||
@@ -9,2 +9,5 @@ "repository": { | ||
}, | ||
"engines": { | ||
"node": ">= 16" | ||
}, | ||
"main": "dist/index.js", | ||
@@ -37,15 +40,15 @@ "exports": { | ||
"devDependencies": { | ||
"@types/node": "^18.14.6", | ||
"@typescript-eslint/eslint-plugin": "^5.54.1", | ||
"@typescript-eslint/parser": "^5.54.1", | ||
"eslint": "^8.35.0", | ||
"eslint-config-prettier": "^8.7.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"prettier": "^2.8.4", | ||
"typescript": "^5.1.6" | ||
"@types/node": "^20.6.0", | ||
"@typescript-eslint/eslint-plugin": "^6.6.0", | ||
"@typescript-eslint/parser": "^6.6.0", | ||
"eslint": "^8.49.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"prettier": "^3.0.3", | ||
"typescript": "^5.2.2" | ||
}, | ||
"dependencies": { | ||
"@badrap/valita": "^0.2.1", | ||
"undici": "^5.22.1" | ||
"@badrap/valita": "^0.3.0", | ||
"undici": "^5.24.0" | ||
} | ||
} |
@@ -6,3 +6,6 @@ import type { Infer, Type } from "@badrap/valita"; | ||
export class HTTPError extends Error { | ||
constructor(readonly statusCode: number, readonly statusText: string) { | ||
constructor( | ||
readonly statusCode: number, | ||
readonly statusText: string, | ||
) { | ||
super(`HTTP status code ${statusCode} (${statusText})`); | ||
@@ -35,3 +38,3 @@ Object.setPrototypeOf(this, new.target.prototype); | ||
headers: Record<string, string | string[] | undefined>, | ||
name: "etag" | "content-type" | ||
name: "etag" | "content-type", | ||
): string | undefined { | ||
@@ -57,3 +60,3 @@ const value = headers[name]; | ||
async requestWithEtag<T extends Type>( | ||
options: RequestOptions<T> | ||
options: RequestOptions<T>, | ||
): Promise<{ body: Infer<T>; etag?: string }> { | ||
@@ -85,3 +88,3 @@ let pathname = this.baseUrl.pathname + `/app/${joinPath(options.path)}`; | ||
response.statusCode, | ||
STATUS_CODES[response.statusCode] ?? "" | ||
STATUS_CODES[response.statusCode] ?? "", | ||
); | ||
@@ -88,0 +91,0 @@ } |
@@ -36,3 +36,3 @@ import * as v from "@badrap/valita"; | ||
export class API< | ||
InstallationState extends Record<string, unknown> = Record<string, unknown> | ||
InstallationState extends Record<string, unknown> = Record<string, unknown>, | ||
> { | ||
@@ -46,3 +46,3 @@ private readonly client: Client; | ||
apiToken: string, | ||
stateType?: v.Type<InstallationState> | ||
stateType?: v.Type<InstallationState>, | ||
) { | ||
@@ -55,3 +55,3 @@ this.client = new Client(apiUrl, apiToken); | ||
async checkAuthToken( | ||
token: string | ||
token: string, | ||
): Promise<{ installationId: string; sessionId: string; expiresAt: number }> { | ||
@@ -114,6 +114,6 @@ const result = await this.client.request({ | ||
v.object({ type: v.literal("team"), name: v.string() }), | ||
v.object({ type: v.literal("user"), email: v.string() }) | ||
v.object({ type: v.literal("user"), email: v.string() }), | ||
) | ||
.optional(), | ||
}) | ||
}), | ||
), | ||
@@ -129,3 +129,3 @@ }); | ||
clientState?: Record<string, unknown>; | ||
} = {} | ||
} = {}, | ||
): Promise<string> { | ||
@@ -145,3 +145,3 @@ return this.client.request({ | ||
async getInstallation( | ||
installationId: string | ||
installationId: string, | ||
): Promise<Installation<InstallationState>> { | ||
@@ -166,3 +166,3 @@ return this.client.request({ | ||
maxRetries?: number; | ||
} | ||
}, | ||
): Promise<Installation<InstallationState>> { | ||
@@ -217,3 +217,3 @@ const { maxRetries = Infinity } = options ?? {}; | ||
async listOwnerAssets( | ||
installationId: string | ||
installationId: string, | ||
): Promise<{ type: "ip" | "email" | "domain"; value: string }[]> { | ||
@@ -228,6 +228,6 @@ return this.client.request({ | ||
v.literal("email"), | ||
v.literal("domain") | ||
v.literal("domain"), | ||
), | ||
value: v.string(), | ||
}) | ||
}), | ||
), | ||
@@ -243,3 +243,3 @@ }); | ||
detailsTemplate?: unknown; | ||
} | ||
}, | ||
): Promise<void> { | ||
@@ -277,3 +277,3 @@ try { | ||
feedName: string, | ||
events: Event[] | ||
events: Event[], | ||
): Promise<void> { | ||
@@ -280,0 +280,0 @@ await this.client.request({ |
@@ -34,4 +34,4 @@ import * as v from "@badrap/valita"; | ||
v.object({ key: Key, value: v.unknown(), versionstamp: v.string() }), | ||
v.object({ key: Key, value: v.null(), versionstamp: v.null() }) | ||
) | ||
v.object({ key: Key, value: v.null(), versionstamp: v.null() }), | ||
), | ||
), | ||
@@ -42,3 +42,3 @@ }); | ||
entries: v.array( | ||
v.object({ key: Key, value: v.unknown(), versionstamp: v.string() }) | ||
v.object({ key: Key, value: v.unknown(), versionstamp: v.string() }), | ||
), | ||
@@ -50,3 +50,3 @@ cursor: v.string().optional(), | ||
v.object({ ok: v.literal(true), versionstamp: v.string() }), | ||
v.object({ ok: v.literal(false) }) | ||
v.object({ ok: v.literal(false) }), | ||
); | ||
@@ -81,3 +81,3 @@ | ||
selector: KvListSelector, | ||
options?: KvListOptions | ||
options?: KvListOptions, | ||
): KvListIterator<unknown> { | ||
@@ -84,0 +84,0 @@ let { limit } = options ?? {}; |
@@ -28,3 +28,3 @@ /* eslint-disable @typescript-eslint/no-namespace */ | ||
type: T, | ||
props: Record<string, unknown> | ||
props: Record<string, unknown>, | ||
): UiNode { | ||
@@ -31,0 +31,0 @@ if (typeof type === "string") { |
{ | ||
"compilerOptions": { | ||
"target": "es2019", | ||
"target": "es2021", | ||
"module": "commonjs", | ||
@@ -5,0 +5,0 @@ "strict": true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1404
60634
+ Added@badrap/valita@0.3.16(transitive)
- Removed@badrap/valita@0.2.10(transitive)
Updated@badrap/valita@^0.3.0
Updatedundici@^5.24.0