@ambasada/sdk 0.8.7 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +12 -1
- package/dist/platform.js +9 -0
- package/dist/types.d.ts +35 -0
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AmbasadaApps } from "./apps.js";
|
|
2
2
|
import { AmbasadaAuth } from "./auth.js";
|
|
3
|
-
import type { FileOptions, Jwk, StoredFile, StoreList, StoreWrite } from "./types.js";
|
|
3
|
+
import type { FileOptions, Jwk, LogEntry, ProductLogs, StoredFile, StoreList, StoreWrite } from "./types.js";
|
|
4
4
|
export declare const DEFAULT_API_URL = "https://api.ambasada.dev";
|
|
5
5
|
export interface AmbasadaOptions {
|
|
6
6
|
/** Project key (`vk_…` from developer.ambasada.dev, or `ambasada login`). Default: `AMBASADA_API_KEY`. */
|
|
@@ -111,6 +111,17 @@ export declare class Ambasada {
|
|
|
111
111
|
/** Keys (up to 1000, optionally under a prefix) and how much of the 1 MB is used. */
|
|
112
112
|
list: (prefix?: string) => Promise<StoreList>;
|
|
113
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* The app's error log (`ambasada logs`, the Developer app's Logs). Errors in a request are recorded on their own (a
|
|
116
|
+
* 5xx); `report` is for work outside one, like a job's failed attempt (the templates' Jobs object reports each).
|
|
117
|
+
*/
|
|
118
|
+
readonly logs: {
|
|
119
|
+
report: (entry: LogEntry) => Promise<{
|
|
120
|
+
ok: true;
|
|
121
|
+
}>;
|
|
122
|
+
/** The last deploy and recent errors (what `ambasada logs` prints). */
|
|
123
|
+
recent: () => Promise<ProductLogs>;
|
|
124
|
+
};
|
|
114
125
|
}
|
|
115
126
|
export declare function cachedKeys(load: () => Promise<Jwk[]>, ttlMs?: number): () => Promise<Jwk[]>;
|
|
116
127
|
export declare function createAmbasada(options?: AmbasadaOptions): Ambasada;
|
package/dist/platform.js
CHANGED
|
@@ -767,6 +767,15 @@ var Ambasada = class {
|
|
|
767
767
|
/** Keys (up to 1000, optionally under a prefix) and how much of the 1 MB is used. */
|
|
768
768
|
list: (prefix) => this.call("GET", "/v1/store", { query: { prefix } })
|
|
769
769
|
};
|
|
770
|
+
/**
|
|
771
|
+
* The app's error log (`ambasada logs`, the Developer app's Logs). Errors in a request are recorded on their own (a
|
|
772
|
+
* 5xx); `report` is for work outside one, like a job's failed attempt (the templates' Jobs object reports each).
|
|
773
|
+
*/
|
|
774
|
+
logs = {
|
|
775
|
+
report: (entry) => this.call("POST", "/v1/product/logs", { body: entry }),
|
|
776
|
+
/** The last deploy and recent errors (what `ambasada logs` prints). */
|
|
777
|
+
recent: () => this.call("GET", "/v1/product/logs")
|
|
778
|
+
};
|
|
770
779
|
};
|
|
771
780
|
function cachedKeys(load, ttlMs = 10 * 6e4) {
|
|
772
781
|
let cached;
|
package/dist/types.d.ts
CHANGED
|
@@ -38,3 +38,38 @@ export interface StoreWrite {
|
|
|
38
38
|
used_bytes: number;
|
|
39
39
|
limit_bytes: number;
|
|
40
40
|
}
|
|
41
|
+
/** `POST /v1/product/logs`: an error the app reports itself (a job's failed attempt, work outside a request). */
|
|
42
|
+
export interface LogEntry {
|
|
43
|
+
/** Default "error" (counted in `ambasada logs`' errors); "warn" is shown, not counted. */
|
|
44
|
+
level?: "error" | "warn";
|
|
45
|
+
message: string;
|
|
46
|
+
/** The error's stack (its first frames are enough: `ambasada logs` maps them to your source). */
|
|
47
|
+
stack?: string | null;
|
|
48
|
+
/** The job it is about (`story:call_…`), shown as `job <name>`. */
|
|
49
|
+
job?: string;
|
|
50
|
+
}
|
|
51
|
+
/** One recorded error: a request (method, path, status) or a reported one (method `JOB` or `LOG`, path the job). */
|
|
52
|
+
export interface LoggedError {
|
|
53
|
+
at: string;
|
|
54
|
+
status: number | null;
|
|
55
|
+
method: string | null;
|
|
56
|
+
path: string | null;
|
|
57
|
+
message: string | null;
|
|
58
|
+
}
|
|
59
|
+
/** `GET /v1/product/logs`. */
|
|
60
|
+
export interface ProductLogs {
|
|
61
|
+
last_deploy: {
|
|
62
|
+
version: number;
|
|
63
|
+
deployed_at: string;
|
|
64
|
+
smoke: unknown;
|
|
65
|
+
template: string | null;
|
|
66
|
+
} | null;
|
|
67
|
+
errors: {
|
|
68
|
+
hourly: {
|
|
69
|
+
hour: string;
|
|
70
|
+
count: number;
|
|
71
|
+
}[];
|
|
72
|
+
total_24h: number;
|
|
73
|
+
recent: LoggedError[];
|
|
74
|
+
};
|
|
75
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ambasada/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.9",
|
|
4
4
|
"description": "The Ambasada platform SDK: Sign in with Ambasada, mini-app notifications, the project store, files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"node": ">=22"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@ambasada/village": "^0.8.
|
|
30
|
+
"@ambasada/village": "^0.8.9"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^22.20.5",
|