@pawabase/client 0.1.4 → 0.3.0
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/README.md +22 -7
- package/dist/cjs/agents.d.ts +87 -0
- package/dist/cjs/agents.d.ts.map +1 -0
- package/dist/cjs/agents.js +153 -0
- package/dist/cjs/agents.js.map +1 -0
- package/dist/cjs/ai.d.ts +5 -0
- package/dist/cjs/ai.d.ts.map +1 -1
- package/dist/cjs/ai.js +7 -0
- package/dist/cjs/ai.js.map +1 -1
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/manage/access.d.ts +1 -59
- package/dist/cjs/manage/access.d.ts.map +1 -1
- package/dist/cjs/manage/access.js +1 -82
- package/dist/cjs/manage/access.js.map +1 -1
- package/dist/cjs/manage/agents.d.ts +76 -0
- package/dist/cjs/manage/agents.d.ts.map +1 -0
- package/dist/cjs/manage/agents.js +89 -0
- package/dist/cjs/manage/agents.js.map +1 -0
- package/dist/cjs/manage/base.d.ts +6 -16
- package/dist/cjs/manage/base.d.ts.map +1 -1
- package/dist/cjs/manage/base.js +11 -11
- package/dist/cjs/manage/base.js.map +1 -1
- package/dist/cjs/manage/data.d.ts +13 -15
- package/dist/cjs/manage/data.d.ts.map +1 -1
- package/dist/cjs/manage/data.js +14 -21
- package/dist/cjs/manage/data.js.map +1 -1
- package/dist/cjs/manage/files.d.ts +5 -0
- package/dist/cjs/manage/files.d.ts.map +1 -1
- package/dist/cjs/manage/files.js +10 -1
- package/dist/cjs/manage/files.js.map +1 -1
- package/dist/cjs/manage/index.d.ts +9 -7
- package/dist/cjs/manage/index.d.ts.map +1 -1
- package/dist/cjs/manage/index.js +11 -8
- package/dist/cjs/manage/index.js.map +1 -1
- package/dist/cjs/manage/lifecycle.d.ts +15 -38
- package/dist/cjs/manage/lifecycle.d.ts.map +1 -1
- package/dist/cjs/manage/lifecycle.js +21 -52
- package/dist/cjs/manage/lifecycle.js.map +1 -1
- package/dist/cjs/manage/mail.d.ts +11 -1
- package/dist/cjs/manage/mail.d.ts.map +1 -1
- package/dist/cjs/manage/mail.js +11 -0
- package/dist/cjs/manage/mail.js.map +1 -1
- package/dist/cjs/manage/observe.d.ts +6 -0
- package/dist/cjs/manage/observe.d.ts.map +1 -1
- package/dist/cjs/manage/observe.js +8 -2
- package/dist/cjs/manage/observe.js.map +1 -1
- package/dist/cjs/realtime.d.ts +68 -0
- package/dist/cjs/realtime.d.ts.map +1 -1
- package/dist/cjs/realtime.js +153 -1
- package/dist/cjs/realtime.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/agents.d.ts +87 -0
- package/dist/esm/agents.d.ts.map +1 -0
- package/dist/esm/agents.js +148 -0
- package/dist/esm/agents.js.map +1 -0
- package/dist/esm/ai.d.ts +5 -0
- package/dist/esm/ai.d.ts.map +1 -1
- package/dist/esm/ai.js +7 -0
- package/dist/esm/ai.js.map +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/manage/access.d.ts +1 -59
- package/dist/esm/manage/access.d.ts.map +1 -1
- package/dist/esm/manage/access.js +0 -80
- package/dist/esm/manage/access.js.map +1 -1
- package/dist/esm/manage/agents.d.ts +76 -0
- package/dist/esm/manage/agents.d.ts.map +1 -0
- package/dist/esm/manage/agents.js +82 -0
- package/dist/esm/manage/agents.js.map +1 -0
- package/dist/esm/manage/base.d.ts +6 -16
- package/dist/esm/manage/base.d.ts.map +1 -1
- package/dist/esm/manage/base.js +11 -11
- package/dist/esm/manage/base.js.map +1 -1
- package/dist/esm/manage/data.d.ts +13 -15
- package/dist/esm/manage/data.d.ts.map +1 -1
- package/dist/esm/manage/data.js +13 -18
- package/dist/esm/manage/data.js.map +1 -1
- package/dist/esm/manage/files.d.ts +5 -0
- package/dist/esm/manage/files.d.ts.map +1 -1
- package/dist/esm/manage/files.js +10 -1
- package/dist/esm/manage/files.js.map +1 -1
- package/dist/esm/manage/index.d.ts +9 -7
- package/dist/esm/manage/index.d.ts.map +1 -1
- package/dist/esm/manage/index.js +14 -11
- package/dist/esm/manage/index.js.map +1 -1
- package/dist/esm/manage/lifecycle.d.ts +15 -38
- package/dist/esm/manage/lifecycle.d.ts.map +1 -1
- package/dist/esm/manage/lifecycle.js +19 -50
- package/dist/esm/manage/lifecycle.js.map +1 -1
- package/dist/esm/manage/mail.d.ts +11 -1
- package/dist/esm/manage/mail.d.ts.map +1 -1
- package/dist/esm/manage/mail.js +12 -1
- package/dist/esm/manage/mail.js.map +1 -1
- package/dist/esm/manage/observe.d.ts +6 -0
- package/dist/esm/manage/observe.d.ts.map +1 -1
- package/dist/esm/manage/observe.js +8 -2
- package/dist/esm/manage/observe.js.map +1 -1
- package/dist/esm/realtime.d.ts +68 -0
- package/dist/esm/realtime.d.ts.map +1 -1
- package/dist/esm/realtime.js +151 -0
- package/dist/esm/realtime.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +2 -2
- package/src/agents.ts +184 -0
- package/src/ai.ts +10 -1
- package/src/index.ts +5 -1
- package/src/manage/access.ts +0 -93
- package/src/manage/agents.ts +98 -0
- package/src/manage/base.ts +11 -11
- package/src/manage/data.ts +14 -19
- package/src/manage/files.ts +12 -1
- package/src/manage/index.ts +14 -11
- package/src/manage/lifecycle.ts +20 -64
- package/src/manage/mail.ts +15 -1
- package/src/manage/observe.ts +9 -2
- package/src/realtime.ts +173 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Definitions, Service, seg, type Api, type Body, type Query } from "./base.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Agents: a model with instructions, tools and knowledge, run on the server with approvals, limits and threads.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* await m.agents.create({ name: "support", model: "chat", instructions: "Answer from the docs.", knowledge: ["docs"] });
|
|
8
|
+
* const run = await m.agents.run("support", "How do I reset a password?");
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export class Agents extends Definitions {
|
|
12
|
+
protected override readonly kind = "agents";
|
|
13
|
+
|
|
14
|
+
/** Run an agent as the studio would. `thread` carries a conversation on; `background` returns before it finishes. */
|
|
15
|
+
run(name: string, input: string, options: { thread?: string; background?: boolean } = {}): Promise<Api> {
|
|
16
|
+
return this.post(seg(this.kind, name, "runs"), { input, thread: options.thread, background: options.background ?? false });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Agent runs: what each did, step by step, and the ones waiting for someone to approve a tool call. */
|
|
21
|
+
export class AgentRuns extends Service {
|
|
22
|
+
/** Newest first. Filter by `agent`, `status` or `thread`. */
|
|
23
|
+
list(options: { agent?: string; status?: string; thread?: string; limit?: number; offset?: number } = {}): Promise<Api> {
|
|
24
|
+
return this.get("/agent-runs", options as Query);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getOne(runId: string): Promise<Api> {
|
|
28
|
+
return this.get(seg("agent-runs", runId));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Approve or decline what a run is waiting on: a decision per call id, and `approve` for any not named. */
|
|
32
|
+
decide(runId: string, options: { decisions?: Record<string, boolean>; approve?: boolean; background?: boolean } = {}): Promise<Api> {
|
|
33
|
+
return this.post(seg("agent-runs", runId, "decide"), { decisions: options.decisions ?? {}, approve: options.approve, background: options.background ?? false });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
remove(runId: string): Promise<Api> {
|
|
37
|
+
return this.del(seg("agent-runs", runId));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The tools an agent can be given, by kind. */
|
|
41
|
+
tools(): Promise<Api> {
|
|
42
|
+
return this.get("/agent-tools");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Knowledge bases: documents split and embedded so agents can search them by meaning and by words. */
|
|
47
|
+
export class KnowledgeBases extends Definitions {
|
|
48
|
+
protected override readonly kind = "knowledge-bases";
|
|
49
|
+
|
|
50
|
+
documents(name: string, options: { limit?: number; offset?: number } = {}): Promise<Api> {
|
|
51
|
+
return this.get(seg(this.kind, name, "documents"), options);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Add text, or a web page to read (`url`). Adding the same `source` again replaces it. */
|
|
55
|
+
addDocument(name: string, input: { text?: string; url?: string; title?: string; source?: string }): Promise<Api> {
|
|
56
|
+
return this.post(seg(this.kind, name, "documents"), { title: input.title ?? "", source: input.source ?? "", text: input.text, url: input.url });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Add a file (PDF, Word, HTML or text). */
|
|
60
|
+
addFile(name: string, file: Blob, options: { title?: string; source?: string; filename?: string } = {}): Promise<Api> {
|
|
61
|
+
const form = new FormData();
|
|
62
|
+
form.append("file", file, options.filename ?? (file as File).name ?? "document");
|
|
63
|
+
if (options.title) form.append("title", options.title);
|
|
64
|
+
if (options.source) form.append("source", options.source);
|
|
65
|
+
return this.post(seg(this.kind, name, "documents"), form);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
removeDocument(name: string, documentId: string): Promise<Api> {
|
|
69
|
+
return this.del(seg(this.kind, name, "documents", documentId));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Split and embed a document again, for one that failed or after changing the base's chunk size. */
|
|
73
|
+
reindexDocument(name: string, documentId: string): Promise<Api> {
|
|
74
|
+
return this.post(seg(this.kind, name, "documents", documentId, "reindex"));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** What an agent would find. */
|
|
78
|
+
search(name: string, query: string, options: { limit?: number } = {}): Promise<Api> {
|
|
79
|
+
return this.post(seg(this.kind, name, "search"), { query, limit: options.limit ?? 5 });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Bring in pages from a Notion connection; pages unchanged since last time are skipped. */
|
|
83
|
+
sync(name: string, connection: string): Promise<Api> {
|
|
84
|
+
return this.post(seg(this.kind, name, "sync"), { connection });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Connections: stored access to outside services (MCP servers, Notion, web search) that agents use as tools. The secret is sealed on arrival. */
|
|
89
|
+
export class Connections extends Definitions {
|
|
90
|
+
protected override readonly kind = "connections";
|
|
91
|
+
|
|
92
|
+
/** Call the service with the stored key and say what was found, or why it could not be reached. */
|
|
93
|
+
test(name: string): Promise<Api> {
|
|
94
|
+
return this.post(seg(this.kind, name, "test"));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type { Body };
|
package/src/manage/base.ts
CHANGED
|
@@ -55,29 +55,29 @@ export class Service {
|
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* A kind of definition an environment holds (`flows`, `policies`, `webhooks`…): list, get, create, replace, remove.
|
|
58
|
-
*
|
|
58
|
+
* A definition is addressed by its name
|
|
59
59
|
* (inbound hooks: their slug).
|
|
60
60
|
*/
|
|
61
61
|
export class Definitions extends Service {
|
|
62
62
|
protected readonly kind: string = "";
|
|
63
63
|
|
|
64
|
-
list(
|
|
65
|
-
return this.get(seg(this.kind)
|
|
64
|
+
list(): Promise<Api> {
|
|
65
|
+
return this.get(seg(this.kind));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
getOne(key: string
|
|
69
|
-
return this.get(seg(this.kind, key)
|
|
68
|
+
getOne(key: string): Promise<Api> {
|
|
69
|
+
return this.get(seg(this.kind, key));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
create(body: Body
|
|
73
|
-
return this.post(seg(this.kind), body
|
|
72
|
+
create(body: Body): Promise<Api> {
|
|
73
|
+
return this.post(seg(this.kind), body);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
replace(key: string, body: Body
|
|
77
|
-
return this.put(seg(this.kind, key), body
|
|
76
|
+
replace(key: string, body: Body): Promise<Api> {
|
|
77
|
+
return this.put(seg(this.kind, key), body);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
remove(key: string
|
|
81
|
-
return this.del(seg(this.kind, key)
|
|
80
|
+
remove(key: string): Promise<Api> {
|
|
81
|
+
return this.del(seg(this.kind, key));
|
|
82
82
|
}
|
|
83
83
|
}
|
package/src/manage/data.ts
CHANGED
|
@@ -110,11 +110,6 @@ export class Schemas extends Definitions {
|
|
|
110
110
|
protected override readonly kind = "schemas";
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
/** Transformers that reshape a field's value on the way out (hide, mask, format). */
|
|
114
|
-
export class Transformers extends Definitions {
|
|
115
|
-
protected override readonly kind = "transformers";
|
|
116
|
-
}
|
|
117
|
-
|
|
118
113
|
/** Custom HTTP routes under `/rest` that run a flow. */
|
|
119
114
|
export class Routes extends Definitions {
|
|
120
115
|
protected override readonly kind = "routes";
|
|
@@ -135,25 +130,25 @@ export class Database extends Service {
|
|
|
135
130
|
return this.get(seg("database", "tables", table, "rows"), { limit: options.limit, offset: options.offset, sort: options.sort, ...options.filters });
|
|
136
131
|
}
|
|
137
132
|
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
return this.
|
|
133
|
+
/** Saved queries: the SQL console's bookmarks. */
|
|
134
|
+
savedQueries(): Promise<Api> {
|
|
135
|
+
return this.get("/database/queries");
|
|
141
136
|
}
|
|
142
|
-
}
|
|
143
137
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
call(method: string, args: unknown[] = [], kwargs: Body = {}, options: { asUser?: Body; branch?: string } = {}): Promise<Api> {
|
|
147
|
-
return this.post("/runtime/call", { method, args, kwargs, as_user: options.asUser ?? null, branch: options.branch ?? null });
|
|
138
|
+
saveQuery(input: { name: string; sql: string; description?: string }): Promise<Api> {
|
|
139
|
+
return this.post("/database/queries", { name: input.name, sql: input.sql, description: input.description ?? "" });
|
|
148
140
|
}
|
|
149
141
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return this.post("/runtime/db", { op, ...fields });
|
|
142
|
+
updateQuery(queryId: string, input: { name: string; sql: string; description?: string }): Promise<Api> {
|
|
143
|
+
return this.put(seg("database", "queries", queryId), { name: input.name, sql: input.sql, description: input.description ?? "" });
|
|
153
144
|
}
|
|
154
145
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
146
|
+
deleteQuery(queryId: string): Promise<Api> {
|
|
147
|
+
return this.del(seg("database", "queries", queryId));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Run one statement. A write needs `allowWrite`; it is audited and clears the environment's caches. */
|
|
151
|
+
query(sql: string, params: unknown[] = [], options: { allowWrite?: boolean } = {}): Promise<Api> {
|
|
152
|
+
return this.post("/database/query", { sql, params, allow_write: options.allowWrite ?? false });
|
|
158
153
|
}
|
|
159
154
|
}
|
package/src/manage/files.ts
CHANGED
|
@@ -64,12 +64,23 @@ export class Buckets extends Definitions {
|
|
|
64
64
|
revokeShare(bucket: string, shareId: string): Promise<Api> {
|
|
65
65
|
return this.del(seg(this.kind, bucket, "shares", shareId));
|
|
66
66
|
}
|
|
67
|
+
|
|
68
|
+
/** Make an empty folder (`prefix` like `reports/2026`). */
|
|
69
|
+
createFolder(bucket: string, prefix: string): Promise<Api> {
|
|
70
|
+
return this.post(seg(this.kind, bucket, "folders"), { prefix });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Remove a folder; it must be empty. */
|
|
74
|
+
deleteFolder(bucket: string, prefix: string): Promise<Api> {
|
|
75
|
+
return this.del(`${seg(this.kind, bucket, "folders")}/${prefix.split("/").filter(Boolean).map(encodeURIComponent).join("/")}`);
|
|
76
|
+
}
|
|
67
77
|
}
|
|
68
78
|
|
|
69
79
|
/** The environment's response cache. */
|
|
70
80
|
export class Cache extends Service {
|
|
81
|
+
/** The project's cache statistics (not scoped to one environment). */
|
|
71
82
|
stats(): Promise<Api> {
|
|
72
|
-
return this.
|
|
83
|
+
return this.project("GET", "/cache");
|
|
73
84
|
}
|
|
74
85
|
|
|
75
86
|
/** Drop cached responses by tag (`resource:posts`) or for whole resources. */
|
package/src/manage/index.ts
CHANGED
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
import type { PawabaseClient } from "../client.js";
|
|
15
15
|
import { ConfigError } from "../errors.js";
|
|
16
16
|
import { isSecretKey } from "../util.js";
|
|
17
|
-
import { Domains,
|
|
17
|
+
import { Domains, Keys, Secrets } from "./access.js";
|
|
18
|
+
import { AgentRuns, Agents, Connections, KnowledgeBases } from "./agents.js";
|
|
18
19
|
import { Ai } from "./ai.js";
|
|
19
20
|
import { Events, Flows, InboundHooks, Jobs, Schedules, Subscriptions, Webhooks } from "./automation.js";
|
|
20
|
-
import { Database, Policies, Resources, Routes,
|
|
21
|
+
import { Database, Policies, Resources, Routes, Schema, Schemas } from "./data.js";
|
|
21
22
|
import { Buckets, Cache } from "./files.js";
|
|
22
|
-
import { Backups, Environments,
|
|
23
|
+
import { Backups, Environments, Versions } from "./lifecycle.js";
|
|
23
24
|
import { Mail, MailTemplates } from "./mail.js";
|
|
24
25
|
import { Alarms, Health, Observability, StatusPage } from "./observe.js";
|
|
25
26
|
import { Dashboards, RealtimeChannels } from "./realtime.js";
|
|
@@ -30,10 +31,8 @@ export class Manage {
|
|
|
30
31
|
readonly schema: Schema;
|
|
31
32
|
readonly policies: Policies;
|
|
32
33
|
readonly schemas: Schemas;
|
|
33
|
-
readonly transformers: Transformers;
|
|
34
34
|
readonly routes: Routes;
|
|
35
35
|
readonly database: Database;
|
|
36
|
-
readonly runtime: Runtime;
|
|
37
36
|
// automation
|
|
38
37
|
readonly flows: Flows;
|
|
39
38
|
readonly schedules: Schedules;
|
|
@@ -54,7 +53,6 @@ export class Manage {
|
|
|
54
53
|
readonly keys: Keys;
|
|
55
54
|
readonly secrets: Secrets;
|
|
56
55
|
readonly domains: Domains;
|
|
57
|
-
readonly firewall: Firewall;
|
|
58
56
|
// observe
|
|
59
57
|
readonly observability: Observability;
|
|
60
58
|
readonly alarms: Alarms;
|
|
@@ -62,9 +60,13 @@ export class Manage {
|
|
|
62
60
|
readonly health: Health;
|
|
63
61
|
// ai
|
|
64
62
|
readonly ai: Ai;
|
|
63
|
+
readonly agents: Agents;
|
|
64
|
+
readonly agentRuns: AgentRuns;
|
|
65
|
+
readonly knowledgeBases: KnowledgeBases;
|
|
66
|
+
readonly connections: Connections;
|
|
65
67
|
// lifecycle
|
|
66
68
|
readonly environments: Environments;
|
|
67
|
-
readonly
|
|
69
|
+
readonly versions: Versions;
|
|
68
70
|
readonly backups: Backups;
|
|
69
71
|
|
|
70
72
|
constructor(
|
|
@@ -76,10 +78,8 @@ export class Manage {
|
|
|
76
78
|
this.schema = new Schema(http, environment);
|
|
77
79
|
this.policies = new Policies(http, environment);
|
|
78
80
|
this.schemas = new Schemas(http, environment);
|
|
79
|
-
this.transformers = new Transformers(http, environment);
|
|
80
81
|
this.routes = new Routes(http, environment);
|
|
81
82
|
this.database = new Database(http, environment);
|
|
82
|
-
this.runtime = new Runtime(http, environment);
|
|
83
83
|
this.flows = new Flows(http, environment);
|
|
84
84
|
this.schedules = new Schedules(http, environment);
|
|
85
85
|
this.subscriptions = new Subscriptions(http, environment);
|
|
@@ -96,14 +96,17 @@ export class Manage {
|
|
|
96
96
|
this.keys = new Keys(http, environment);
|
|
97
97
|
this.secrets = new Secrets(http, environment);
|
|
98
98
|
this.domains = new Domains(http, environment);
|
|
99
|
-
this.firewall = new Firewall(http, environment);
|
|
100
99
|
this.observability = new Observability(http, environment);
|
|
101
100
|
this.alarms = new Alarms(http, environment);
|
|
102
101
|
this.statusPage = new StatusPage(http, environment);
|
|
103
102
|
this.health = new Health(http, environment);
|
|
104
103
|
this.ai = new Ai(http, environment);
|
|
104
|
+
this.agents = new Agents(http, environment);
|
|
105
|
+
this.agentRuns = new AgentRuns(http, environment);
|
|
106
|
+
this.knowledgeBases = new KnowledgeBases(http, environment);
|
|
107
|
+
this.connections = new Connections(http, environment);
|
|
105
108
|
this.environments = new Environments(http, environment);
|
|
106
|
-
this.
|
|
109
|
+
this.versions = new Versions(http, environment);
|
|
107
110
|
this.backups = new Backups(http, environment);
|
|
108
111
|
}
|
|
109
112
|
|
package/src/manage/lifecycle.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Service, seg, type Api, type Body } from "./base.js";
|
|
2
2
|
|
|
3
|
-
type When = Date | string;
|
|
4
|
-
const iso = (value?: When): string | undefined => (value instanceof Date ? value.toISOString() : value);
|
|
5
|
-
|
|
6
3
|
/** The project's environments (`development`, `production`, previews…). Most calls here are not scoped to the client's environment. */
|
|
7
4
|
export class Environments extends Service {
|
|
8
5
|
list(): Promise<Api> {
|
|
@@ -45,9 +42,9 @@ export class Environments extends Service {
|
|
|
45
42
|
return this.del(seg("previews", preview));
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
/** Copy this environment's definitions (never secrets or keys) to `to`. `include` limits the kinds
|
|
49
|
-
promote(to: string, options: { include?: string[] } = {}): Promise<Api> {
|
|
50
|
-
return this.post("/promote", { to, include: options.include });
|
|
45
|
+
/** Copy this environment's definitions (never secrets or keys) to `to`. `include` limits the kinds; `dryRun` only reports what would change. */
|
|
46
|
+
promote(to: string, options: { include?: string[]; dryRun?: boolean } = {}): Promise<Api> {
|
|
47
|
+
return this.post("/promote", { to, include: options.include, dry_run: options.dryRun ?? false });
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
/** Export definitions, roles and settings as a document another project can apply. */
|
|
@@ -66,70 +63,29 @@ export class Environments extends Service {
|
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return this.
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** The branch's definitions as they stand now. */
|
|
80
|
-
draft(branch: string): Promise<Api> {
|
|
81
|
-
return this.get(seg("branches", branch, "draft"));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
merge(branch: string, options: { target?: string; force?: boolean } = {}): Promise<Api> {
|
|
85
|
-
return this.post(seg("branches", branch, "merge"), { target: options.target ?? "main", force: options.force ?? false });
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
revisions(): Promise<Api> {
|
|
89
|
-
return this.get("/revisions");
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
revision(revisionId: string): Promise<Api> {
|
|
93
|
-
return this.get(seg("revisions", revisionId));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** Freeze the branch's draft as a revision. */
|
|
97
|
-
commit(branch: string, message = ""): Promise<Api> {
|
|
98
|
-
return this.post(seg("branches", branch, "revisions"), { message });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
apiVersions(): Promise<Api> {
|
|
102
|
-
return this.get("/api-versions");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
createApiVersion(name: string, options: { isDefault?: boolean } = {}): Promise<Api> {
|
|
106
|
-
return this.post("/api-versions", { name, is_default: options.isDefault ?? false });
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** `status`: draft, active, deprecated, sunset, disabled. */
|
|
110
|
-
updateApiVersion(name: string, changes: { status?: string; isDefault?: boolean; sunsetAt?: When }): Promise<Api> {
|
|
111
|
-
return this.patch(seg("api-versions", name), { status: changes.status, is_default: changes.isDefault, sunset_at: iso(changes.sunsetAt) });
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
rollbackApiVersion(name: string): Promise<Api> {
|
|
115
|
-
return this.post(seg("api-versions", name, "rollback"));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
releases(): Promise<Api> {
|
|
119
|
-
return this.get("/releases");
|
|
66
|
+
/**
|
|
67
|
+
* API versions served side by side. `v1` is always the live API; releasing another environment's definitions as `v2` serves them at
|
|
68
|
+
* `/rest/v2` over this environment's tables, until you retire it.
|
|
69
|
+
*/
|
|
70
|
+
export class Versions extends Service {
|
|
71
|
+
/** The live API first, then every released version. */
|
|
72
|
+
list(): Promise<Api> {
|
|
73
|
+
return this.get("/versions");
|
|
120
74
|
}
|
|
121
75
|
|
|
122
|
-
/**
|
|
123
|
-
|
|
124
|
-
return this.post("/
|
|
76
|
+
/** Whether `fromEnv`'s definitions can be served here as a version, and what would be added or left out. */
|
|
77
|
+
check(fromEnv: string): Promise<Api> {
|
|
78
|
+
return this.post("/versions/check", { from_env: fromEnv });
|
|
125
79
|
}
|
|
126
80
|
|
|
127
|
-
|
|
128
|
-
|
|
81
|
+
/** Serve `fromEnv`'s definitions as `/rest/<name>` (`v2`, `v3`…). A name is never reused. */
|
|
82
|
+
release(name: string, fromEnv: string, options: { notes?: string } = {}): Promise<Api> {
|
|
83
|
+
return this.post("/versions", { name, from_env: fromEnv, notes: options.notes ?? "" });
|
|
129
84
|
}
|
|
130
85
|
|
|
131
|
-
|
|
132
|
-
|
|
86
|
+
/** Stop serving a version. */
|
|
87
|
+
retire(name: string): Promise<Api> {
|
|
88
|
+
return this.post(seg("versions", name, "retire"));
|
|
133
89
|
}
|
|
134
90
|
}
|
|
135
91
|
|
package/src/manage/mail.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import { Definitions, Service, type Api } from "./base.js";
|
|
1
|
+
import { Definitions, Service, seg, type Api, type Body } from "./base.js";
|
|
2
2
|
|
|
3
3
|
/** Templates (subject, HTML, text) for the mail flows and sign-in send. */
|
|
4
4
|
export class MailTemplates extends Definitions {
|
|
5
5
|
protected override readonly kind = "mail-templates";
|
|
6
|
+
|
|
7
|
+
/** Rename a template, keeping its versions. */
|
|
8
|
+
rename(name: string, to: string): Promise<Api> {
|
|
9
|
+
return this.post(seg(this.kind, name, "rename"), { to });
|
|
10
|
+
}
|
|
6
11
|
}
|
|
7
12
|
|
|
8
13
|
export class Mail extends Service {
|
|
14
|
+
/** The brand kit the template editor uses: brand styles, palettes, reusable blocks and folders. */
|
|
15
|
+
kit(): Promise<Api> {
|
|
16
|
+
return this.get("/mail/kit");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
saveKit(kit: { brand?: Body; palettes?: Body[]; blocks?: Body[]; folders?: string[] }): Promise<Api> {
|
|
20
|
+
return this.put("/mail/kit", { brand: kit.brand ?? {}, palettes: kit.palettes ?? [], blocks: kit.blocks ?? [], folders: kit.folders ?? [] });
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
/** The delivery settings in effect (the password is never returned) and whether mail is being delivered. */
|
|
10
24
|
config(): Promise<Api> {
|
|
11
25
|
return this.get("/mail/config");
|
package/src/manage/observe.ts
CHANGED
|
@@ -68,8 +68,9 @@ export class Observability extends Service {
|
|
|
68
68
|
return this.get("/metric-series", { metric, minutes: options.minutes ?? 60, period: options.period, compare: options.comparePrevious ? "previous" : undefined });
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/** The project's background workers (not scoped to one environment). */
|
|
71
72
|
workers(): Promise<Api> {
|
|
72
|
-
return this.
|
|
73
|
+
return this.project("GET", "/workers");
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
/** What the environment is running with. */
|
|
@@ -77,8 +78,14 @@ export class Observability extends Service {
|
|
|
77
78
|
return this.get("/configuration");
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
/** What the project has used against what its plan allows (not scoped to one environment). */
|
|
80
82
|
capacity(): Promise<Api> {
|
|
81
|
-
return this.
|
|
83
|
+
return this.project("GET", "/capacity");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Bytes received and sent over the last `minutes`, and the endpoints, callers and requests that moved the most. */
|
|
87
|
+
bandwidth(options: { minutes?: number } = {}): Promise<Api> {
|
|
88
|
+
return this.get("/observability/bandwidth", options);
|
|
82
89
|
}
|
|
83
90
|
}
|
|
84
91
|
|