@ninedeploy/sdk 0.10.6 → 0.16.1

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.
Files changed (129) hide show
  1. package/LICENSE +21 -21
  2. package/dist/apiPath.d.ts +5 -0
  3. package/dist/apiPath.d.ts.map +1 -0
  4. package/dist/apiPath.js +18 -0
  5. package/dist/apiPath.js.map +1 -0
  6. package/dist/client.d.ts +29 -0
  7. package/dist/client.d.ts.map +1 -0
  8. package/dist/client.js +51 -0
  9. package/dist/client.js.map +1 -0
  10. package/dist/databaseImport.d.ts +138 -0
  11. package/dist/databaseImport.d.ts.map +1 -0
  12. package/dist/databaseImport.js +126 -0
  13. package/dist/databaseImport.js.map +1 -0
  14. package/dist/errors.js +1 -1
  15. package/dist/errors.js.map +1 -1
  16. package/dist/index.d.ts +15 -1973
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +9 -641
  19. package/dist/index.js.map +1 -1
  20. package/dist/manifest.d.ts.map +1 -1
  21. package/dist/manifest.js +25 -21
  22. package/dist/manifest.js.map +1 -1
  23. package/dist/resources/auth.d.ts +282 -0
  24. package/dist/resources/auth.d.ts.map +1 -0
  25. package/dist/resources/auth.js +111 -0
  26. package/dist/resources/auth.js.map +1 -0
  27. package/dist/resources/databases.d.ts +178 -0
  28. package/dist/resources/databases.d.ts.map +1 -0
  29. package/dist/resources/databases.js +82 -0
  30. package/dist/resources/databases.js.map +1 -0
  31. package/dist/resources/deploys.d.ts +125 -0
  32. package/dist/resources/deploys.d.ts.map +1 -0
  33. package/dist/resources/deploys.js +46 -0
  34. package/dist/resources/deploys.js.map +1 -0
  35. package/dist/resources/domains.d.ts +109 -0
  36. package/dist/resources/domains.d.ts.map +1 -0
  37. package/dist/resources/domains.js +29 -0
  38. package/dist/resources/domains.js.map +1 -0
  39. package/dist/resources/env.d.ts +55 -0
  40. package/dist/resources/env.d.ts.map +1 -0
  41. package/dist/resources/env.js +33 -0
  42. package/dist/resources/env.js.map +1 -0
  43. package/dist/resources/logs.d.ts +27 -0
  44. package/dist/resources/logs.d.ts.map +1 -0
  45. package/dist/resources/logs.js +18 -0
  46. package/dist/resources/logs.js.map +1 -0
  47. package/dist/resources/network.d.ts +169 -0
  48. package/dist/resources/network.d.ts.map +1 -0
  49. package/dist/resources/network.js +39 -0
  50. package/dist/resources/network.js.map +1 -0
  51. package/dist/resources/plugins.d.ts +42 -0
  52. package/dist/resources/plugins.d.ts.map +1 -0
  53. package/dist/resources/plugins.js +22 -0
  54. package/dist/resources/plugins.js.map +1 -0
  55. package/dist/resources/servers.d.ts +130 -0
  56. package/dist/resources/servers.d.ts.map +1 -0
  57. package/dist/resources/servers.js +37 -0
  58. package/dist/resources/servers.js.map +1 -0
  59. package/dist/resources/services.d.ts +240 -0
  60. package/dist/resources/services.d.ts.map +1 -0
  61. package/dist/resources/services.js +93 -0
  62. package/dist/resources/services.js.map +1 -0
  63. package/dist/resources/settings.d.ts +373 -0
  64. package/dist/resources/settings.d.ts.map +1 -0
  65. package/dist/resources/settings.js +94 -0
  66. package/dist/resources/settings.js.map +1 -0
  67. package/dist/resources/sources.d.ts +87 -0
  68. package/dist/resources/sources.d.ts.map +1 -0
  69. package/dist/resources/sources.js +39 -0
  70. package/dist/resources/sources.js.map +1 -0
  71. package/dist/resources/system.d.ts +240 -0
  72. package/dist/resources/system.d.ts.map +1 -0
  73. package/dist/resources/system.js +86 -0
  74. package/dist/resources/system.js.map +1 -0
  75. package/dist/resources/templates.d.ts +36 -0
  76. package/dist/resources/templates.d.ts.map +1 -0
  77. package/dist/resources/templates.js +17 -0
  78. package/dist/resources/templates.js.map +1 -0
  79. package/dist/resources/terminals.d.ts +60 -0
  80. package/dist/resources/terminals.d.ts.map +1 -0
  81. package/dist/resources/terminals.js +35 -0
  82. package/dist/resources/terminals.js.map +1 -0
  83. package/dist/resources/traefik.d.ts +93 -0
  84. package/dist/resources/traefik.d.ts.map +1 -0
  85. package/dist/resources/traefik.js +39 -0
  86. package/dist/resources/traefik.js.map +1 -0
  87. package/dist/resources/volumes.d.ts +114 -0
  88. package/dist/resources/volumes.d.ts.map +1 -0
  89. package/dist/resources/volumes.js +47 -0
  90. package/dist/resources/volumes.js.map +1 -0
  91. package/dist/terminal.d.ts +98 -0
  92. package/dist/terminal.d.ts.map +1 -0
  93. package/dist/terminal.js +180 -0
  94. package/dist/terminal.js.map +1 -0
  95. package/dist/transport.d.ts +61 -0
  96. package/dist/transport.d.ts.map +1 -0
  97. package/dist/transport.js +90 -0
  98. package/dist/transport.js.map +1 -0
  99. package/dist/types.d.ts +539 -0
  100. package/dist/types.d.ts.map +1 -0
  101. package/dist/types.js +5 -0
  102. package/dist/types.js.map +1 -0
  103. package/package.json +5 -4
  104. package/src/apiPath.ts +23 -0
  105. package/src/client.ts +70 -0
  106. package/src/databaseImport.ts +174 -0
  107. package/src/errors.ts +27 -0
  108. package/src/index.ts +121 -0
  109. package/src/manifest.ts +414 -0
  110. package/src/resources/auth.ts +357 -0
  111. package/src/resources/databases.ts +227 -0
  112. package/src/resources/deploys.ts +161 -0
  113. package/src/resources/domains.ts +149 -0
  114. package/src/resources/env.ts +84 -0
  115. package/src/resources/logs.ts +48 -0
  116. package/src/resources/network.ts +154 -0
  117. package/src/resources/plugins.ts +52 -0
  118. package/src/resources/servers.ts +141 -0
  119. package/src/resources/services.ts +296 -0
  120. package/src/resources/settings.ts +334 -0
  121. package/src/resources/sources.ts +131 -0
  122. package/src/resources/system.ts +281 -0
  123. package/src/resources/templates.ts +55 -0
  124. package/src/resources/terminals.ts +112 -0
  125. package/src/resources/traefik.ts +125 -0
  126. package/src/resources/volumes.ts +138 -0
  127. package/src/terminal.ts +254 -0
  128. package/src/transport.ts +154 -0
  129. package/src/types.ts +588 -0
package/dist/index.js CHANGED
@@ -1,643 +1,11 @@
1
- import { NineDeployError } from './errors.js';
2
- export { NineDeployError };
1
+ // @ninedeploy/sdk public entry. Every name below is part of the published API;
2
+ // the implementation lives in the modules it re-exports from (resources/*.ts
3
+ // hold one client surface each, client.ts composes them).
4
+ export { NineDeployError } from './errors.js';
3
5
  export { detectProjectKind, formatManifestYaml, ManifestParseError, ManifestValidationError, parseManifestYaml, starterManifest, buildManifestFromTemplate, } from './manifest.js';
4
- const NO_FETCH = () => Promise.reject(new NineDeployError(0, 'no_fetch', 'No fetch implementation is available'));
5
- /**
6
- * Create a typed NineDeploy API client. Used by both the web dashboard and the CLI.
7
- *
8
- * @example
9
- * const client = createClient({ baseUrl: 'http://localhost:3000', getToken: () => token });
10
- * const services = await client.services.list();
11
- */
12
- export function createClient(opts) {
13
- const baseUrl = opts.baseUrl.replace(/\/$/, '');
14
- const fetchImpl = opts.fetch ?? (globalThis.fetch ?? NO_FETCH);
15
- /** Default per-request budget when the caller does not configure one. */
16
- const DEFAULT_TIMEOUT_MS = 30_000;
17
- async function request(path, init = {}) {
18
- const token = opts.getToken?.();
19
- const headers = { ...(init.headers ?? {}) };
20
- if (token)
21
- headers['Authorization'] = `Bearer ${token}`;
22
- if (init.body !== undefined && headers['Content-Type'] === undefined) {
23
- headers['Content-Type'] = 'application/json';
24
- }
25
- const body = init.body === undefined ? undefined : JSON.stringify(init.body);
26
- const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
27
- // AbortSignal.timeout exists everywhere the SDK runs (Node 17.3+, all
28
- // modern browsers); it is resolved off globalThis and attached opaquely —
29
- // FetchLike's shape stays untouched (widening it with `signal: unknown`
30
- // breaks assigning a real `typeof fetch` at the call sites).
31
- const out = {
32
- method: init.method ?? 'GET',
33
- headers,
34
- body,
35
- };
36
- if (init.credentials !== undefined)
37
- out.credentials = init.credentials;
38
- if (timeoutMs > 0) {
39
- const abort = globalThis.AbortSignal;
40
- if (abort)
41
- out.signal = abort.timeout(timeoutMs);
42
- }
43
- const res = await fetchImpl(`${baseUrl}${path}`, out);
44
- const text = await res.text();
45
- // Guard the parse: proxies (HTML 502 pages, empty bodies) must surface as a
46
- // typed error, not an opaque SyntaxError.
47
- let parsed;
48
- try {
49
- parsed = text ? JSON.parse(text) : undefined;
50
- }
51
- catch {
52
- parsed = undefined;
53
- }
54
- if (!res.ok) {
55
- if (parsed === undefined)
56
- throw new NineDeployError(res.status, 'http_error', `Request failed (${res.status})`);
57
- throw NineDeployError.fromBody(res.status, parsed);
58
- }
59
- // An ok response with an empty/unparseable body (204s, HTML pages from a
60
- // misconfigured proxy) must never resolve to `undefined` — query functions
61
- // built on this client would crash TanStack Query ("Query data cannot be
62
- // undefined"). Empty 2xx bodies resolve to {}; non-JSON bodies surface as
63
- // a typed error so callers see the real problem instead of a crash.
64
- if (parsed === undefined) {
65
- if (text === '')
66
- return {};
67
- throw new NineDeployError(res.status, 'invalid_response', `Expected JSON but received a non-JSON body (status ${res.status})`);
68
- }
69
- return parsed;
70
- }
71
- const get = (path) => request(path);
72
- const send = (method, path, body) => request(path, { method, body });
73
- return {
74
- auth: {
75
- status: () => get('/v1/auth/status'),
76
- introspectToken: () => get('/v1/auth/token'),
77
- setup: (input) => send('POST', '/v1/setup', input),
78
- register: (input) => send('POST', '/v1/auth/register', input),
79
- login: (input) => send('POST', '/v1/auth/login', input),
80
- refresh: (input) => send('POST', '/v1/auth/refresh', input),
81
- /** Revoke this user's outstanding JWTs server-side (tokenVersion bump). */
82
- logout: () => send('POST', '/v1/auth/logout', {}),
83
- changePassword: (input) => send('POST', '/v1/auth/password', input),
84
- forgotPassword: (email) => send('POST', '/v1/auth/forgot-password', { email }),
85
- resetPasswordWithToken: (input) => send('POST', '/v1/auth/reset-password', input),
86
- twoFactor: {
87
- setup: (input) => send('POST', '/v1/auth/2fa/setup', input ?? {}),
88
- enable: (code) => send('POST', '/v1/auth/2fa/enable', { code }),
89
- disable: (input) => send('POST', '/v1/auth/2fa/disable', input),
90
- },
91
- me: () => get('/v1/auth/me'),
92
- tokens: {
93
- create: (input) => send('POST', '/v1/auth/tokens', input ?? {}),
94
- list: () => get('/v1/auth/tokens'),
95
- remove: async (id) => {
96
- await request(`/v1/auth/tokens/${id}`, { method: 'DELETE' });
97
- },
98
- },
99
- passkeys: {
100
- registerOptions: () => send('POST', '/v1/auth/passkey/register/options'),
101
- registerVerify: (input) => send('POST', '/v1/auth/passkey/register/verify', {
102
- name: input.name,
103
- response: input.response,
104
- }),
105
- list: () => get('/v1/auth/passkey'),
106
- remove: async (id) => {
107
- await request(`/v1/auth/passkey/${id}`, { method: 'DELETE' });
108
- },
109
- loginOptions: () => send('POST', '/v1/auth/passkey/login/options'),
110
- loginVerify: (response) => send('POST', '/v1/auth/passkey/login/verify', { response: response }),
111
- },
112
- sessions: {
113
- list: () => get('/v1/auth/sessions'),
114
- revoke: (id) => send('DELETE', `/v1/auth/sessions/${id}`),
115
- },
116
- oidc: {
117
- publicProviders: () => get('/v1/auth/oidc/providers/public'),
118
- link: (slug) => request(`/v1/auth/oidc/${encodeURIComponent(slug)}/link`, { method: 'POST', credentials: 'include' }),
119
- listProviders: () => get('/v1/auth/oidc/providers'),
120
- list: () => get('/v1/auth/oidc/providers'),
121
- createProvider: (input) => send('POST', '/v1/auth/oidc/providers', input),
122
- create: (input) => send('POST', '/v1/auth/oidc/providers', input),
123
- updateProvider: (id, input) => send('PATCH', `/v1/auth/oidc/providers/${id}`, input),
124
- update: (id, input) => send('PATCH', `/v1/auth/oidc/providers/${id}`, input),
125
- deleteProvider: (id) => send('DELETE', `/v1/auth/oidc/providers/${id}`),
126
- delete: (id) => send('DELETE', `/v1/auth/oidc/providers/${id}`),
127
- callback: (slug, payload) => send('POST', `/v1/auth/oidc/${slug}/callback`, payload),
128
- },
129
- },
130
- workspaces: {
131
- list: () => get('/v1/workspaces'),
132
- get: (id) => get(`/v1/workspaces/${id}`),
133
- create: (input) => send('POST', '/v1/workspaces', input),
134
- update: (id, input) => send('PATCH', `/v1/workspaces/${id}`, input),
135
- delete: (id) => send('DELETE', `/v1/workspaces/${id}`),
136
- addMember: (id, input) => send('POST', `/v1/workspaces/${id}/members`, input),
137
- inviteMember: (id, input) => send('POST', `/v1/workspaces/${id}/invitations`, input),
138
- listInvitations: (id) => get(`/v1/workspaces/${id}/invitations`),
139
- revokeInvitation: (id, inviteId) => send('DELETE', `/v1/workspaces/${id}/invitations/${inviteId}`),
140
- previewInvitation: (token) => get(`/v1/invitations/${token}`),
141
- acceptInvitation: (token) => send('POST', `/v1/invitations/${token}/accept`),
142
- updateMemberRole: (id, memberId, input) => send('PATCH', `/v1/workspaces/${id}/members/${memberId}`, input),
143
- removeMember: (id, memberId) => send('DELETE', `/v1/workspaces/${id}/members/${memberId}`),
144
- },
145
- services: {
146
- list: (query) => get(`/v1/services${query ?? ''}`),
147
- get: (id) => get(`/v1/services/${id}`),
148
- create: (input) => send('POST', '/v1/services', input),
149
- update: (id, input) => send('PATCH', `/v1/services/${id}`, input),
150
- composePreview: (input) => send('POST', '/v1/services/compose/preview', input),
151
- remove: async (id) => {
152
- await request(`/v1/services/${id}`, { method: 'DELETE' });
153
- },
154
- stop: (id) => send('POST', `/v1/services/${id}/stop`),
155
- start: (id) => send('POST', `/v1/services/${id}/start`),
156
- restart: (id) => send('POST', `/v1/services/${id}/restart`),
157
- logs: (id) => get(`/v1/services/${id}/logs`),
158
- clone: (id, input) => send('POST', `/v1/services/${id}/clone`, input ?? {}),
159
- exportUrl: (id) => `/v1/services/${id}/export`,
160
- importBundle: (bundle) => send('POST', '/v1/services/import', bundle),
161
- manifest: {
162
- apply: (serviceId, input) => send('POST', `/v1/services/${serviceId}/manifest/apply`, input),
163
- },
164
- },
165
- labels: {
166
- list: (query) => get(`/v1/labels${query ?? ''}`),
167
- create: (input) => send('POST', '/v1/labels', input),
168
- update: (id, input) => send('PATCH', `/v1/labels/${id}`, input),
169
- remove: (id) => send('DELETE', `/v1/labels/${id}`),
170
- },
171
- environments: {
172
- list: () => get('/v1/environments'),
173
- create: (input) => send('POST', '/v1/environments', input),
174
- rename: (id, name) => send('PATCH', `/v1/environments/${id}`, { name }),
175
- remove: (id) => send('DELETE', `/v1/environments/${id}`),
176
- },
177
- ai: {
178
- getConfig: () => get('/v1/ai/config'),
179
- updateConfig: (input) => send('PUT', '/v1/ai/config', input),
180
- diagnose: (serviceId, deploymentId) => send('POST', `/v1/ai/services/${serviceId}/deploys/${deploymentId}/diagnose`),
181
- suggestManifest: (description) => send('POST', '/v1/ai/suggest-manifest', { description }),
182
- },
183
- serviceTags: {
184
- get: (id) => get(`/v1/services/${id}/tags`),
185
- set: (id, input) => send('PUT', `/v1/services/${id}/tags`, input),
186
- },
187
- deploys: {
188
- trigger: (serviceId, input) => send('POST', `/v1/services/${serviceId}/deploys`, input ?? {}),
189
- list: (serviceId) => get(`/v1/services/${serviceId}/deploys`),
190
- queue: (query) => get(`/v1/services/queue${query ? (query.startsWith('?') ? query : `?${query}`) : ''}`),
191
- rollback: (serviceId, deploymentId) => send('POST', `/v1/services/${serviceId}/deploys/${deploymentId}/rollback`),
192
- cancel: (serviceId, deploymentId) => send('POST', `/v1/services/${serviceId}/deploys/${deploymentId}/cancel`),
193
- remove: (serviceId, deploymentId) => send('DELETE', `/v1/services/${serviceId}/deploys/${deploymentId}`),
194
- configDiff: (serviceId, deploymentId) => get(`/v1/services/${serviceId}/deploys/${deploymentId}/diff`),
195
- promote: (serviceId, targetServiceId) => send('POST', `/v1/services/${serviceId}/promote`, { targetServiceId }),
196
- logDownloadUrl: (serviceId, deploymentId) => `/v1/services/${serviceId}/deploys/${deploymentId}/logs/download`,
197
- },
198
- domains: {
199
- list: (serviceId) => get(`/v1/services/${serviceId}/domains`),
200
- create: (serviceId, input) => send('POST', `/v1/services/${serviceId}/domains`, input),
201
- dnsCheck: (serviceId, domainId) => get(`/v1/services/${serviceId}/domains/${domainId}/dns`),
202
- update: (serviceId, domainId, input) => send('PATCH', `/v1/services/${serviceId}/domains/${domainId}`, input),
203
- remove: async (serviceId, domainId) => {
204
- await request(`/v1/services/${serviceId}/domains/${domainId}`, { method: 'DELETE' });
205
- },
206
- all: () => get('/v1/domains'),
207
- setSsl: (domainId, ssl) => send('PATCH', `/v1/domains/${domainId}`, { ssl }),
208
- /** Toggle sticky-session routing (G-28) — sits under `/domains` for legacy compatibility. */
209
- setStickySession: (serviceId, enabled) => send('POST', `/v1/services/${serviceId}/sticky-session`, { enabled }),
210
- transfer: (domainId, input) => send('POST', `/v1/domains/${domainId}/transfer`, input),
211
- previewTransfer: (token) => get(`/v1/domain-transfers/${token}`),
212
- acceptTransfer: (token, input) => send('POST', `/v1/domain-transfers/${token}/accept`, input),
213
- cancelTransfer: (token) => send('POST', `/v1/domain-transfers/${token}/cancel`, {}),
214
- },
215
- domainPresets: {
216
- list: () => get('/v1/domain-presets'),
217
- apply: (input) => send('POST', '/v1/domain-presets/apply', input),
218
- },
219
- configPresets: {
220
- list: () => get('/v1/config-presets'),
221
- get: (id) => get(`/v1/config-presets/${encodeURIComponent(id)}`),
222
- register: (input) => send('POST', '/v1/config-presets', input),
223
- apply: (id, opts) => send('PUT', `/v1/config-presets/${encodeURIComponent(id)}/apply`, opts ?? {}),
224
- remove: (id) => send('DELETE', `/v1/config-presets/${encodeURIComponent(id)}`),
225
- },
226
- metricHistory: {
227
- get: () => get('/v1/metric-history'),
228
- flush: () => send('POST', '/v1/metric-history/flush'),
229
- },
230
- buildCache: {
231
- stats: () => get('/v1/build-cache/stats'),
232
- },
233
- orchestrators: {
234
- list: () => get('/v1/orchestrators'),
235
- stacks: (orchestrator) => get(`/v1/orchestrators/${encodeURIComponent(orchestrator)}/stacks`),
236
- stackStatus: (orchestrator, stack) => get(`/v1/orchestrators/${encodeURIComponent(orchestrator)}/stacks/${encodeURIComponent(stack)}`),
237
- },
238
- branding: {
239
- get: () => get('/v1/branding'),
240
- set: (input) => send('PATCH', '/v1/branding', input),
241
- },
242
- egress: {
243
- list: () => get('/v1/egress'),
244
- set: (input) => send('POST', '/v1/egress', input),
245
- clear: (projectId, driver) => send('DELETE', `/v1/egress/${projectId}${driver ? `?driver=${encodeURIComponent(driver)}` : ''}`),
246
- },
247
- sso: {
248
- listProviders: () => get('/v1/sso/providers'),
249
- addProvider: (input) => send('POST', '/v1/sso/providers', input),
250
- removeProvider: (id) => send('DELETE', `/v1/sso/providers/${id}`),
251
- },
252
- fanout: {
253
- // r201: the route answers `{ targets: [...] }` (like PATCH); the SDK
254
- // typed and returned it as a bare array, so the panel's fan-out card
255
- // called `.map` on an object and crashed whenever it rendered.
256
- get: async (serviceId) => (await get(`/v1/services/${serviceId}/targets`)).targets,
257
- set: (serviceId, serverIds) => send('PATCH', `/v1/services/${serviceId}/targets`, { serverIds }),
258
- },
259
- scim: {
260
- listTokens: () => get('/v1/scim/tokens'),
261
- createToken: (input) => send('POST', '/v1/scim/tokens', input),
262
- revokeToken: (id) => send('DELETE', `/v1/scim/tokens/${id}`),
263
- },
264
- volumes: {
265
- list: () => get('/v1/volumes'),
266
- listFiles: (name, path = '') => get(`/v1/volumes/${encodeURIComponent(name)}/files?path=${encodeURIComponent(path)}`),
267
- readFile: (name, path) => get(`/v1/volumes/${encodeURIComponent(name)}/files/content?path=${encodeURIComponent(path)}`),
268
- writeFile: (name, input) => send('PUT', `/v1/volumes/${encodeURIComponent(name)}/files`, input),
269
- mkdir: (name, input) => send('POST', `/v1/volumes/${encodeURIComponent(name)}/files/dir`, input),
270
- deleteFile: async (name, path) => {
271
- await request(`/v1/volumes/${encodeURIComponent(name)}/files?path=${encodeURIComponent(path)}`, { method: 'DELETE' });
272
- },
273
- remove: async (name) => {
274
- await request(`/v1/volumes/${encodeURIComponent(name)}`, { method: 'DELETE' });
275
- },
276
- prune: () => send('POST', '/v1/volumes/prune'),
277
- },
278
- containers: {
279
- inspect: (container) => get(`/v1/containers/${encodeURIComponent(container)}/inspect`),
280
- compose: (container) => get(`/v1/containers/${encodeURIComponent(container)}/compose`),
281
- listFiles: (container, path = '/') => get(`/v1/containers/${encodeURIComponent(container)}/files?path=${encodeURIComponent(path)}`),
282
- readFile: (container, path) => get(`/v1/containers/${encodeURIComponent(container)}/files/content?path=${encodeURIComponent(path)}`),
283
- writeFile: (container, input) => send('PUT', `/v1/containers/${encodeURIComponent(container)}/files`, input),
284
- mkdir: (container, input) => send('POST', `/v1/containers/${encodeURIComponent(container)}/files/dir`, input),
285
- makeDir: (container, input) => send('POST', `/v1/containers/${encodeURIComponent(container)}/files/dir`, input),
286
- deleteFile: async (container, path) => {
287
- await request(`/v1/containers/${encodeURIComponent(container)}/files?path=${encodeURIComponent(path)}`, { method: 'DELETE' });
288
- },
289
- deletePath: async (container, path) => {
290
- await request(`/v1/containers/${encodeURIComponent(container)}/files?path=${encodeURIComponent(path)}`, { method: 'DELETE' });
291
- },
292
- },
293
- system: {
294
- resources: () => get('/v1/system/resources'),
295
- pruneImages: () => send('POST', '/v1/system/prune-images'),
296
- updateCheck: (force) => get(`/v1/system/update-check${force ? '?force=1' : ''}`),
297
- updateStatus: () => get('/v1/system/update-status'),
298
- updateStart: (version) => send('POST', '/v1/system/update-start', { version }),
299
- exportUrl: () => '/v1/system/export',
300
- dockerEvents: (minutes) => get(`/v1/system/docker-events?minutes=${minutes ?? 60}`),
301
- },
302
- networks: {
303
- list: () => get('/v1/networks'),
304
- create: (input) => send('POST', '/v1/networks', { driver: 'bridge', ...input }),
305
- remove: (name, serverId) => send('DELETE', `/v1/networks/${encodeURIComponent(name)}${serverId != null ? `?serverId=${serverId}` : ''}`),
306
- attach: (input) => send('POST', '/v1/networks/attach', input),
307
- detach: (input) => send('POST', '/v1/networks/detach', input),
308
- },
309
- tunnels: {
310
- list: () => get('/v1/tunnels'),
311
- create: (input) => send('POST', '/v1/tunnels', input),
312
- remove: async (id) => {
313
- await request(`/v1/tunnels/${id}`, { method: 'DELETE' });
314
- },
315
- },
316
- activity: {
317
- list: (query) => {
318
- const parts = [];
319
- if (query?.entity)
320
- parts.push(`entity=${encodeURIComponent(query.entity)}`);
321
- if (query?.action)
322
- parts.push(`action=${encodeURIComponent(query.action)}`);
323
- if (query?.userId)
324
- parts.push(`userId=${query.userId}`);
325
- if (query?.before)
326
- parts.push(`before=${query.before}`);
327
- const qs = parts.join('&');
328
- return get(`/v1/activity${qs ? `?${qs}` : ''}`);
329
- },
330
- },
331
- alerts: {
332
- list: () => get('/v1/alerts'),
333
- create: (input) => send('POST', '/v1/alerts', input),
334
- update: (id, input) => send('PATCH', `/v1/alerts/${id}`, input),
335
- remove: async (id) => {
336
- await request(`/v1/alerts/${id}`, { method: 'DELETE' });
337
- },
338
- },
339
- settings: {
340
- get: () => get('/v1/settings'),
341
- setPanelDomain: (domain) => send('PUT', '/v1/settings/panel-domain', { domain }),
342
- setAllowRegistration: (enabled) => send('PUT', '/v1/settings/allow-registration', { enabled }),
343
- setAcmeEmail: (email) => send('PUT', '/v1/settings/acme-email', { email }),
344
- setTemplatesSource: (source) => send('PUT', '/v1/settings/templates-source', { source }),
345
- setDns: (input) => send('PUT', '/v1/settings/dns', input),
346
- vault: {
347
- get: () => get('/v1/settings/vault'),
348
- set: (input) => send('PUT', '/v1/settings/vault', input),
349
- test: () => send('POST', '/v1/settings/vault/test'),
350
- },
351
- dnsRecords: {
352
- get: () => get('/v1/settings/dns-records'),
353
- set: (input) => send('PUT', '/v1/settings/dns-records', input),
354
- test: () => send('POST', '/v1/settings/dns-records/test'),
355
- },
356
- namecheap: {
357
- get: () => get('/v1/settings/dns-records/namecheap'),
358
- set: (input) => send('PUT', '/v1/settings/dns-records/namecheap', input),
359
- },
360
- masterKey: {
361
- get: () => get('/v1/settings/master-key'),
362
- rotate: () => send('POST', '/v1/settings/master-key/rotate'),
363
- },
364
- },
365
- firewall: {
366
- status: () => get('/v1/firewall'),
367
- toggle: (enabled) => send('POST', '/v1/firewall/toggle', { enabled }),
368
- addRule: (input) => send('POST', '/v1/firewall/rules', input),
369
- deleteRule: (id) => request(`/v1/firewall/rules/${id}`, { method: 'DELETE' }),
370
- applyRecommended: () => send('POST', '/v1/firewall/recommended'),
371
- },
372
- users: {
373
- list: () => get('/v1/users'),
374
- create: (input) => send('POST', '/v1/users', input),
375
- resetPassword: (id, input) => send('PATCH', `/v1/users/${id}/password`, input),
376
- resetLink: (id) => send('POST', `/v1/users/${id}/reset-link`),
377
- setOperator: (id, isOperator) => send('PATCH', `/v1/users/${id}/operator`, { isOperator }),
378
- remove: async (id) => {
379
- await request(`/v1/users/${id}`, { method: 'DELETE' });
380
- },
381
- },
382
- projects: {
383
- list: (query) => get(`/v1/projects${query ?? ''}`),
384
- create: (input) => send('POST', '/v1/projects', input),
385
- update: (id, input) => send('PATCH', `/v1/projects/${id}`, input),
386
- remove: (id) => send('DELETE', `/v1/projects/${id}`),
387
- },
388
- about: {
389
- get: () => get('/v1/about'),
390
- },
391
- notifications: {
392
- listChannels: () => get('/v1/notifications/channels'),
393
- createChannel: (input) => send('POST', '/v1/notifications/channels', input),
394
- updateChannel: (id, input) => send('PATCH', `/v1/notifications/channels/${id}`, input),
395
- removeChannel: async (id) => { await request(`/v1/notifications/channels/${id}`, { method: 'DELETE' }); },
396
- testChannel: (id) => send('POST', `/v1/notifications/channels/${id}/test`),
397
- log: () => get('/v1/notifications/log'),
398
- },
399
- sources: {
400
- list: () => get('/v1/sources'),
401
- create: (input) => send('POST', '/v1/sources', input),
402
- update: (id, input) => send('PATCH', `/v1/sources/${id}`, input),
403
- remove: async (id) => {
404
- await request(`/v1/sources/${id}`, { method: 'DELETE' });
405
- },
406
- repos: (id) => get(`/v1/sources/${id}/repos`),
407
- branches: (id, repo) => get(`/v1/sources/${id}/branches?repo=${encodeURIComponent(repo)}`),
408
- test: (id) => get(`/v1/sources/${id}/test`),
409
- generateDeployKey: (id) => send('POST', `/v1/sources/${id}/generate-deploy-key`),
410
- },
411
- insights: {
412
- analyze: (input) => send('POST', '/v1/insights', input),
413
- get: (serviceId) => get(`/v1/services/${serviceId}/insights`),
414
- refresh: (serviceId) => send('POST', `/v1/services/${serviceId}/insights/refresh`),
415
- },
416
- webhooks: {
417
- list: (serviceId) => get(`/v1/services/${serviceId}/webhooks`),
418
- create: (serviceId, input) => send('POST', `/v1/services/${serviceId}/webhooks`, input ?? {}),
419
- remove: async (serviceId, hookId) => {
420
- await request(`/v1/services/${serviceId}/webhooks/${hookId}`, { method: 'DELETE' });
421
- },
422
- },
423
- databases: {
424
- list: (query) => get(`/v1/databases${query ?? ''}`),
425
- create: (input) => send('POST', '/v1/databases', input),
426
- get: (id) => get(`/v1/databases/${id}`),
427
- remove: async (id, opts) => {
428
- await request(`/v1/databases/${id}${opts?.force ? '?force=true' : ''}`, { method: 'DELETE' });
429
- },
430
- restart: async (id) => {
431
- await request(`/v1/databases/${id}/restart`, { method: 'POST' });
432
- },
433
- stop: async (id) => {
434
- await request(`/v1/databases/${id}/stop`, { method: 'POST' });
435
- },
436
- start: async (id) => {
437
- await request(`/v1/databases/${id}/start`, { method: 'POST' });
438
- },
439
- logs: (id, lines) => get(`/v1/databases/${id}/logs${lines ? `?lines=${lines}` : ''}`),
440
- credentials: (id) => get(`/v1/databases/${id}/credentials`),
441
- setLimits: (id, input) => send('PATCH', `/v1/databases/${id}/limits`, input),
442
- startStudio: (id, port) => send('POST', `/v1/databases/${id}/studio`, { port }),
443
- stopStudio: async (id) => {
444
- await request(`/v1/databases/${id}/studio`, { method: 'DELETE' });
445
- return { ok: true };
446
- },
447
- drillBackup: (id, input) => send('POST', `/v1/databases/${id}/backups/drill`, input),
448
- drills: (id) => get(`/v1/databases/${id}/drills`),
449
- pgbouncerStatus: (id) => get(`/v1/databases/${id}/pgbouncer`),
450
- enablePgbouncer: (id, input) => send('POST', `/v1/databases/${id}/pgbouncer/enable`, input ?? {}),
451
- disablePgbouncer: (id) => send('POST', `/v1/databases/${id}/pgbouncer/disable`, {}),
452
- },
453
- attachments: {
454
- list: (serviceId) => get(`/v1/services/${serviceId}/attachments`),
455
- create: (serviceId, input) => send('POST', `/v1/services/${serviceId}/attachments`, input),
456
- remove: async (serviceId, attachmentId) => {
457
- await request(`/v1/services/${serviceId}/attachments/${attachmentId}`, { method: 'DELETE' });
458
- },
459
- },
460
- serviceVolumes: {
461
- list: (serviceId) => get(`/v1/services/${serviceId}/volumes`),
462
- create: (serviceId, input) => send('POST', `/v1/services/${serviceId}/volumes`, input),
463
- update: (serviceId, attachmentId, input) => send('PATCH', `/v1/services/${serviceId}/volumes/${attachmentId}`, input),
464
- remove: async (serviceId, attachmentId) => {
465
- await request(`/v1/services/${serviceId}/volumes/${attachmentId}`, { method: 'DELETE' });
466
- },
467
- repairConfig: (serviceId, input) => send('POST', `/v1/services/${serviceId}/volumes/config-repair`, input),
468
- },
469
- volumeBackups: {
470
- // Path segments are user-visible names: encode them like the rest of
471
- // the client does, or '?'/'#'/'%' in a volume name rewrite the URL.
472
- list: (volumeName) => get(`/v1/volumes/${encodeURIComponent(volumeName)}/backups`),
473
- create: (volumeName, input) => send('POST', `/v1/volumes/${encodeURIComponent(volumeName)}/backups`, input),
474
- restore: (volumeName, backupId) => send('POST', `/v1/volumes/${encodeURIComponent(volumeName)}/backups/${backupId}/restore`),
475
- downloadUrl: (volumeName, backupId) => `/v1/volumes/${encodeURIComponent(volumeName)}/backups/${backupId}/download`,
476
- },
477
- env: {
478
- list: (serviceId) => get(`/v1/services/${serviceId}/env`),
479
- create: (serviceId, input) => send('POST', `/v1/services/${serviceId}/env`, input),
480
- update: (serviceId, varId, input) => send('PATCH', `/v1/services/${serviceId}/env/${varId}`, input),
481
- remove: async (serviceId, varId) => {
482
- await request(`/v1/services/${serviceId}/env/${varId}`, { method: 'DELETE' });
483
- },
484
- import: (serviceId, content) => send('POST', `/v1/services/${serviceId}/env/import`, { content }),
485
- export: (serviceId) => get(`/v1/services/${serviceId}/env/export`),
486
- search: (q) => get(`/v1/env/search?q=${encodeURIComponent(q)}`),
487
- },
488
- projectEnv: {
489
- list: (projectId) => get(`/v1/projects/${projectId}/env`),
490
- create: (projectId, input) => send('POST', `/v1/projects/${projectId}/env`, input),
491
- update: (projectId, varId, input) => send('PATCH', `/v1/projects/${projectId}/env/${varId}`, input),
492
- remove: async (projectId, varId) => {
493
- await request(`/v1/projects/${projectId}/env/${varId}`, { method: 'DELETE' });
494
- },
495
- },
496
- stats: {
497
- snapshot: () => get('/v1/stats'),
498
- metrics: (serviceId, opts) => get(`/v1/services/${serviceId}/metrics?kind=${opts?.kind ?? 'cpu'}&minutes=${opts?.minutes ?? 60}`),
499
- },
500
- dashboard: {
501
- get: () => get('/v1/dashboard'),
502
- },
503
- topology: {
504
- get: () => get('/v1/topology'),
505
- },
506
- templates: {
507
- list: () => get('/v1/templates'),
508
- get: (id) => get(`/v1/templates/${encodeURIComponent(id)}`),
509
- prepare: (id, input) => send('POST', `/v1/templates/${encodeURIComponent(id)}/prepare`, input ?? {}),
510
- deploy: (id, input) => send('POST', `/v1/templates/${encodeURIComponent(id)}/deploy`, input ?? {}),
511
- community: {
512
- list: () => get('/v1/templates/community'),
513
- import: (content, opts) => send('POST', '/v1/templates/community/import', { content, ...(opts ?? {}) }),
514
- remove: (id) => send('DELETE', `/v1/templates/community/${encodeURIComponent(id)}`),
515
- },
516
- },
517
- backups: {
518
- storage: (databaseId) => get(`/v1/databases/${databaseId}/storage`),
519
- backupNow: (databaseId) => send('POST', `/v1/databases/${databaseId}/backups`),
520
- listForDb: (databaseId) => get(`/v1/databases/${databaseId}/backups`),
521
- restore: (databaseId, backupId) => send('POST', `/v1/databases/${databaseId}/backups/${backupId}/restore`),
522
- list: () => get('/v1/backups'),
523
- remove: async (backupId) => {
524
- await request(`/v1/backups/${backupId}`, { method: 'DELETE' });
525
- },
526
- downloadUrl: (backupId) => `/v1/backups/${backupId}/download`,
527
- },
528
- backupDestinations: {
529
- list: () => get('/v1/backup-destinations'),
530
- create: (input) => send('POST', '/v1/backup-destinations', input),
531
- update: (id, input) => send('PATCH', `/v1/backup-destinations/${id}`, input),
532
- remove: (id) => send('DELETE', `/v1/backup-destinations/${id}`),
533
- test: (id) => send('POST', `/v1/backup-destinations/${id}/test`),
534
- },
535
- jobs: {
536
- list: (serviceId) => get(`/v1/services/${serviceId}/jobs`),
537
- create: (serviceId, input) => send('POST', `/v1/services/${serviceId}/jobs`, input),
538
- update: (serviceId, jobId, input) => send('PATCH', `/v1/services/${serviceId}/jobs/${jobId}`, input),
539
- remove: (serviceId, jobId) => send('DELETE', `/v1/services/${serviceId}/jobs/${jobId}`),
540
- run: (serviceId, jobId) => send('POST', `/v1/services/${serviceId}/jobs/${jobId}/run`),
541
- runs: (serviceId, jobId) => get(`/v1/services/${serviceId}/jobs/${jobId}/runs`),
542
- },
543
- servers: {
544
- list: () => get('/v1/servers'),
545
- create: (input) => send('POST', '/v1/servers', input),
546
- remove: (id, opts) => send('DELETE', `/v1/servers/${id}${opts?.force ? '?force=true' : ''}`),
547
- test: (id) => send('POST', `/v1/servers/${id}/test`),
548
- approve: (id) => send('POST', `/v1/servers/${id}/approve`),
549
- reject: (id) => send('POST', `/v1/servers/${id}/reject`),
550
- sshTest: (input) => send('POST', '/v1/servers/ssh-test', input),
551
- sshBootstrap: (input) => send('POST', '/v1/servers/ssh-bootstrap', input),
552
- bootstrapLogs: (id) => get(`/v1/servers/${id}/bootstrap-logs`),
553
- },
554
- limits: {
555
- setService: (serviceId, input) => send('PATCH', `/v1/services/${serviceId}/limits`, input),
556
- setDatabase: (databaseId, input) => send('PATCH', `/v1/databases/${databaseId}/limits`, input),
557
- },
558
- traefik: {
559
- get: () => get('/v1/traefik'),
560
- status: () => get('/v1/traefik/status'),
561
- certificates: () => get('/v1/traefik/certificates'),
562
- certificateInventory: (opts) => get(
563
- // `!= null` (not truthiness): 0 ("only already-expired") is a real
564
- // threshold and must reach the server, not silently become the
565
- // server-side default of 30.
566
- `/v1/traefik/certificates/inventory${opts?.threshold != null ? `?threshold=${opts.threshold}` : ''}`),
567
- expiringCertificates: (opts) => get(`/v1/traefik/certificates/expiring${opts?.days != null ? `?days=${opts.days}` : ''}`),
568
- logs: (lines = 50) => get(`/v1/traefik/logs?lines=${lines}`),
569
- restart: () => send('POST', '/v1/traefik/restart'),
570
- backupCerts: () => send('POST', '/v1/traefik/backup-certs'),
571
- },
572
- config: {
573
- list: (query) => {
574
- const parts = [];
575
- if (query?.category)
576
- parts.push(`category=${encodeURIComponent(query.category)}`);
577
- if (query?.pluginId)
578
- parts.push(`pluginId=${encodeURIComponent(query.pluginId)}`);
579
- if (query?.reveal)
580
- parts.push('reveal=true');
581
- const qs = parts.length ? `?${parts.join('&')}` : '';
582
- return get(`/v1/config${qs}`);
583
- },
584
- get: (key) => get(`/v1/config/${encodeURIComponent(key)}`),
585
- set: (key, input) => send('POST', `/v1/config/${encodeURIComponent(key)}`, input),
586
- delete: (key) => send('DELETE', `/v1/config/${encodeURIComponent(key)}`),
587
- },
588
- plugins: {
589
- list: () => get('/v1/plugins'),
590
- marketplace: (opts) => get(`/v1/plugins/marketplace${opts?.refresh ? '?refresh=true' : ''}`),
591
- install: (input) => send('POST', '/v1/plugins/install', input),
592
- enable: (id) => send('POST', `/v1/plugins/${encodeURIComponent(id)}/enable`),
593
- disable: (id) => send('POST', `/v1/plugins/${encodeURIComponent(id)}/disable`),
594
- reload: (id) => send('POST', `/v1/plugins/${encodeURIComponent(id)}/reload`),
595
- inspect: (id) => get(`/v1/plugins/${encodeURIComponent(id)}/inspect`),
596
- uninstall: (id) => send('POST', `/v1/plugins/${encodeURIComponent(id)}/uninstall`),
597
- },
598
- menus: {
599
- list: (query) => {
600
- const qs = query?.slot ? `?slot=${encodeURIComponent(query.slot)}` : '';
601
- return get(`/v1/menus${qs}`);
602
- },
603
- },
604
- demo: {
605
- seed: () => send('POST', '/v1/demo/seed'),
606
- },
607
- logDrains: {
608
- list: (query) => {
609
- const qs = query?.serviceId !== undefined ? `?serviceId=${encodeURIComponent(String(query.serviceId))}` : '';
610
- return get(`/v1/log-drains${qs}`);
611
- },
612
- get: (id) => get(`/v1/log-drains/${id}`),
613
- create: (input) => send('POST', '/v1/log-drains', input),
614
- update: (id, input) => send('PATCH', `/v1/log-drains/${id}`, input),
615
- remove: (id) => send('DELETE', `/v1/log-drains/${id}`),
616
- test: (id) => send('POST', `/v1/log-drains/${id}/test`),
617
- search: (input) => send('POST', '/v1/log-drains/search', input),
618
- },
619
- emailTemplates: {
620
- list: (workspaceId) => get(`/v1/workspaces/${workspaceId}/email-templates`),
621
- preview: (workspaceId, name, vars) => send('POST', `/v1/workspaces/${workspaceId}/email-templates/preview`, { name, vars: vars ?? {} }),
622
- set: (workspaceId, name, subject, text) => send('PUT', `/v1/workspaces/${workspaceId}/email-templates/${name}`, { subject, text }),
623
- reset: (workspaceId, name) => send('DELETE', `/v1/workspaces/${workspaceId}/email-templates/${name}`, {}),
624
- },
625
- housekeeping: {
626
- getAutoPrune: () => get('/v1/housekeeping/prune/config'),
627
- updateAutoPrune: (input) => send('PATCH', '/v1/housekeeping/prune/config', input),
628
- runPrune: () => send('POST', '/v1/housekeeping/prune'),
629
- listImages: () => get('/v1/housekeeping/images'),
630
- pruneImages: (input) => send('POST', '/v1/housekeeping/images/prune', input),
631
- },
632
- health: () => get('/health'),
633
- doctor: {
634
- /** Full host scan: dead containers, orphan volumes/networks, row-vs-runtime
635
- * desyncs, dangling images, disk pressure — with guarded repair actions. */
636
- scan: () => get('/v1/doctor'),
637
- /** Execute one finding's repair. The server re-scans and re-locates the
638
- * finding first; a stale finding answers 409 instead of acting. */
639
- fix: (input) => send('POST', '/v1/doctor/fix', input),
640
- },
641
- };
642
- }
6
+ export { DATABASE_IMPORT_FINISHED_STATUSES, } from './databaseImport.js';
7
+ export { apiGetUrl, } from './apiPath.js';
8
+ export { AGENT_SWARM_MANAGER_VAR, } from './types.js';
9
+ export { TERMINAL_SUBPROTOCOL, TERMINAL_TICKET_PREFIX, TERMINAL_INPUT_CHUNK_BYTES, TERMINAL_PENDING_INPUT_MAX, terminalAttachInfo, terminalCloseMessage, connectTerminal, } from './terminal.js';
10
+ export { createClient } from './client.js';
643
11
  //# sourceMappingURL=index.js.map