@ninedeploy/sdk 0.17.1 → 0.18.4
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/resources/databases.d.ts +2 -1
- package/dist/resources/databases.d.ts.map +1 -1
- package/dist/resources/databases.js +3 -2
- package/dist/resources/databases.js.map +1 -1
- package/dist/resources/deploys.d.ts +18 -1
- package/dist/resources/deploys.d.ts.map +1 -1
- package/dist/resources/deploys.js +1 -0
- package/dist/resources/deploys.js.map +1 -1
- package/dist/resources/logs.d.ts +6 -1
- package/dist/resources/logs.d.ts.map +1 -1
- package/dist/resources/logs.js +3 -0
- package/dist/resources/logs.js.map +1 -1
- package/dist/resources/services.d.ts +14 -13
- package/dist/resources/services.d.ts.map +1 -1
- package/dist/resources/services.js +9 -0
- package/dist/resources/services.js.map +1 -1
- package/dist/resources/system.d.ts +10 -2
- package/dist/resources/system.d.ts.map +1 -1
- package/dist/resources/system.js +13 -1
- package/dist/resources/system.js.map +1 -1
- package/dist/resources/terminals.d.ts.map +1 -1
- package/dist/resources/terminals.js +3 -1
- package/dist/resources/terminals.js.map +1 -1
- package/dist/resources/volumes.d.ts +42 -14
- package/dist/resources/volumes.d.ts.map +1 -1
- package/dist/resources/volumes.js +33 -17
- package/dist/resources/volumes.js.map +1 -1
- package/dist/terminal.d.ts +1 -1
- package/dist/terminal.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/resources/databases.ts +4 -3
- package/src/resources/deploys.ts +16 -3
- package/src/resources/logs.ts +7 -0
- package/src/resources/services.ts +35 -6
- package/src/resources/system.ts +23 -2
- package/src/resources/terminals.ts +3 -1
- package/src/resources/volumes.ts +49 -35
- package/src/terminal.ts +1 -1
package/src/resources/volumes.ts
CHANGED
|
@@ -32,31 +32,31 @@ export interface VolumesApi {
|
|
|
32
32
|
create: (input: VolumeCreateInput) => Promise<VolumeCreateResult>;
|
|
33
33
|
prune: () => Promise<{ ok: boolean; deleted: number; freedBytes: number }>;
|
|
34
34
|
/** File manager: list a directory inside the volume. */
|
|
35
|
-
listFiles: (name: string, path?: string) => Promise<{ path: string; entries: VolumeFileEntry[] }>;
|
|
35
|
+
listFiles: (name: string, path?: string, options?: { serverId?: number }) => Promise<{ path: string; entries: VolumeFileEntry[] }>;
|
|
36
36
|
/** File manager: read a file (base64 content). */
|
|
37
|
-
readFile: (name: string, path: string) => Promise<{ content: string; encoding: 'utf8' | 'base64' }>;
|
|
37
|
+
readFile: (name: string, path: string, options?: { serverId?: number }) => Promise<{ content: string; encoding: 'utf8' | 'base64' }>;
|
|
38
38
|
/** File manager: write/overwrite a file (base64 content). */
|
|
39
|
-
writeFile: (name: string, input: VolumeFileWriteInput) => Promise<{ ok: boolean }>;
|
|
39
|
+
writeFile: (name: string, input: VolumeFileWriteInput, options?: { serverId?: number }) => Promise<{ ok: boolean }>;
|
|
40
40
|
/** File manager: create a directory. */
|
|
41
|
-
mkdir: (name: string, input: VolumePathCreateInput) => Promise<{ ok: boolean }>;
|
|
41
|
+
mkdir: (name: string, input: VolumePathCreateInput, options?: { serverId?: number }) => Promise<{ ok: boolean }>;
|
|
42
42
|
/** File manager: delete a file or directory (recursive). */
|
|
43
|
-
deleteFile: (name: string, path: string) => Promise<void>;
|
|
43
|
+
deleteFile: (name: string, path: string, options?: { serverId?: number }) => Promise<void>;
|
|
44
44
|
};
|
|
45
45
|
containers: {
|
|
46
|
-
inspect: (container: string) => Promise<ContainerInspectData>;
|
|
47
|
-
compose: (container: string) => Promise<ContainerComposeData>;
|
|
46
|
+
inspect: (container: string, options?: { serverId?: number }) => Promise<ContainerInspectData>;
|
|
47
|
+
compose: (container: string, options?: { serverId?: number }) => Promise<ContainerComposeData>;
|
|
48
48
|
/** File manager: list a directory inside the container. */
|
|
49
|
-
listFiles: (container: string, path?: string) => Promise<{ path: string; entries: VolumeFileEntry[] }>;
|
|
49
|
+
listFiles: (container: string, path?: string, options?: { serverId?: number }) => Promise<{ path: string; entries: VolumeFileEntry[] }>;
|
|
50
50
|
/** File manager: read a file (base64 content). */
|
|
51
|
-
readFile: (container: string, path: string) => Promise<{ content: string; encoding: 'utf8' | 'base64' }>;
|
|
51
|
+
readFile: (container: string, path: string, options?: { serverId?: number }) => Promise<{ content: string; encoding: 'utf8' | 'base64' }>;
|
|
52
52
|
/** File manager: write/overwrite a file (base64 content). */
|
|
53
|
-
writeFile: (container: string, input: VolumeFileWriteInput) => Promise<{ ok: boolean }>;
|
|
53
|
+
writeFile: (container: string, input: VolumeFileWriteInput, options?: { serverId?: number }) => Promise<{ ok: boolean }>;
|
|
54
54
|
/** File manager: create a directory. */
|
|
55
|
-
mkdir: (container: string, input: VolumePathCreateInput) => Promise<{ ok: boolean }>;
|
|
56
|
-
makeDir: (container: string, input: VolumePathCreateInput) => Promise<{ ok: boolean }>;
|
|
55
|
+
mkdir: (container: string, input: VolumePathCreateInput, options?: { serverId?: number }) => Promise<{ ok: boolean }>;
|
|
56
|
+
makeDir: (container: string, input: VolumePathCreateInput, options?: { serverId?: number }) => Promise<{ ok: boolean }>;
|
|
57
57
|
/** File manager: delete a file or directory (recursive). */
|
|
58
|
-
deleteFile: (container: string, path: string) => Promise<void>;
|
|
59
|
-
deletePath: (container: string, path: string) => Promise<void>;
|
|
58
|
+
deleteFile: (container: string, path: string, options?: { serverId?: number }) => Promise<void>;
|
|
59
|
+
deletePath: (container: string, path: string, options?: { serverId?: number }) => Promise<void>;
|
|
60
60
|
};
|
|
61
61
|
/** Per-service additional volume attachments. Distinct from the instance-wide
|
|
62
62
|
* `volumes` namespace (which lists every Docker volume on the host). The
|
|
@@ -82,18 +82,32 @@ export interface VolumesApi {
|
|
|
82
82
|
|
|
83
83
|
export function volumesApi(t: Transport): VolumesApi {
|
|
84
84
|
const { get, send, request } = t;
|
|
85
|
+
const volumePath = (name: string, suffix: string, options?: { serverId?: number }) => {
|
|
86
|
+
const id = options?.serverId;
|
|
87
|
+
if (id != null && (!Number.isSafeInteger(id) || id < 1)) throw new TypeError('Invalid volume node id');
|
|
88
|
+
const prefix = id == null ? '/v1/volumes' : `/v1/servers/${id}/volumes`;
|
|
89
|
+
return `${prefix}/${encodeURIComponent(name)}${suffix}`;
|
|
90
|
+
};
|
|
91
|
+
const containerPath = (container: string, suffix: string, options?: { serverId?: number }) => {
|
|
92
|
+
const id = options?.serverId;
|
|
93
|
+
if (id != null && (!Number.isSafeInteger(id) || id < 1)) throw new TypeError('Invalid container node id');
|
|
94
|
+
// An older panel returns 404 for this namespace instead of ignoring a host
|
|
95
|
+
// query and accidentally editing a same-named local container.
|
|
96
|
+
const prefix = id == null ? '/v1/containers' : `/v1/servers/${id}/containers`;
|
|
97
|
+
return `${prefix}/${encodeURIComponent(container)}${suffix}`;
|
|
98
|
+
};
|
|
85
99
|
return {
|
|
86
100
|
volumes: {
|
|
87
101
|
list: (options) => get<VolumeListEntry[]>(apiGetUrl('/v1/volumes', { serverId: options?.serverId })),
|
|
88
102
|
create: (input) => send<VolumeCreateResult>('POST', '/v1/volumes', input),
|
|
89
|
-
listFiles: (name, path = '') =>
|
|
90
|
-
|
|
91
|
-
readFile: (name, path) =>
|
|
92
|
-
|
|
93
|
-
writeFile: (name, input) =>
|
|
94
|
-
mkdir: (name, input) =>
|
|
95
|
-
deleteFile: async (name, path) => {
|
|
96
|
-
await request(
|
|
103
|
+
listFiles: (name, path = '', options) =>
|
|
104
|
+
request<{ path: string; entries: VolumeFileEntry[] }>(`${volumePath(name, '/files', options)}?path=${encodeURIComponent(path)}`, {}, 150_000),
|
|
105
|
+
readFile: (name, path, options) =>
|
|
106
|
+
request<{ content: string; encoding: 'utf8' | 'base64' }>(`${volumePath(name, '/files/content', options)}?path=${encodeURIComponent(path)}`, {}, 150_000),
|
|
107
|
+
writeFile: (name, input, options) => request<{ ok: boolean }>(volumePath(name, '/files', options), { method: 'PUT', body: input }, 150_000),
|
|
108
|
+
mkdir: (name, input, options) => request<{ ok: boolean }>(volumePath(name, '/files/dir', options), { method: 'POST', body: input }, 150_000),
|
|
109
|
+
deleteFile: async (name, path, options) => {
|
|
110
|
+
await request(`${volumePath(name, '/files', options)}?path=${encodeURIComponent(path)}`, { method: 'DELETE' }, 150_000);
|
|
97
111
|
},
|
|
98
112
|
remove: async (name, options) => {
|
|
99
113
|
const node = options?.serverId === undefined ? '' : `?serverId=${options.serverId}`;
|
|
@@ -102,20 +116,20 @@ export function volumesApi(t: Transport): VolumesApi {
|
|
|
102
116
|
prune: () => send<{ ok: boolean; deleted: number; freedBytes: number }>('POST', '/v1/volumes/prune'),
|
|
103
117
|
},
|
|
104
118
|
containers: {
|
|
105
|
-
inspect: (container) => get<ContainerInspectData>(
|
|
106
|
-
compose: (container) => get<ContainerComposeData>(
|
|
107
|
-
listFiles: (container, path = '/') =>
|
|
108
|
-
get<{ path: string; entries: VolumeFileEntry[] }>(
|
|
109
|
-
readFile: (container, path) =>
|
|
110
|
-
get<{ content: string; encoding: 'utf8' | 'base64' }>(
|
|
111
|
-
writeFile: (container, input) => send<{ ok: boolean }>('PUT',
|
|
112
|
-
mkdir: (container, input) => send<{ ok: boolean }>('POST',
|
|
113
|
-
makeDir: (container, input) => send<{ ok: boolean }>('POST',
|
|
114
|
-
deleteFile: async (container, path) => {
|
|
115
|
-
await request(
|
|
119
|
+
inspect: (container, options) => get<ContainerInspectData>(containerPath(container, '/inspect', options)),
|
|
120
|
+
compose: (container, options) => get<ContainerComposeData>(containerPath(container, '/compose', options)),
|
|
121
|
+
listFiles: (container, path = '/', options) =>
|
|
122
|
+
get<{ path: string; entries: VolumeFileEntry[] }>(`${containerPath(container, '/files', options)}?path=${encodeURIComponent(path)}`),
|
|
123
|
+
readFile: (container, path, options) =>
|
|
124
|
+
get<{ content: string; encoding: 'utf8' | 'base64' }>(`${containerPath(container, '/files/content', options)}?path=${encodeURIComponent(path)}`),
|
|
125
|
+
writeFile: (container, input, options) => send<{ ok: boolean }>('PUT', containerPath(container, '/files', options), input),
|
|
126
|
+
mkdir: (container, input, options) => send<{ ok: boolean }>('POST', containerPath(container, '/files/dir', options), input),
|
|
127
|
+
makeDir: (container, input, options) => send<{ ok: boolean }>('POST', containerPath(container, '/files/dir', options), input),
|
|
128
|
+
deleteFile: async (container, path, options) => {
|
|
129
|
+
await request(`${containerPath(container, '/files', options)}?path=${encodeURIComponent(path)}`, { method: 'DELETE' });
|
|
116
130
|
},
|
|
117
|
-
deletePath: async (container, path) => {
|
|
118
|
-
await request(
|
|
131
|
+
deletePath: async (container, path, options) => {
|
|
132
|
+
await request(`${containerPath(container, '/files', options)}?path=${encodeURIComponent(path)}`, { method: 'DELETE' });
|
|
119
133
|
},
|
|
120
134
|
},
|
|
121
135
|
serviceVolumes: {
|
package/src/terminal.ts
CHANGED
|
@@ -103,7 +103,7 @@ export interface TerminalReady {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export interface TerminalHandlers {
|
|
106
|
-
/** The
|
|
106
|
+
/** The terminal transport is ready; buffered input is flushed now. Scripted interactive clients must also wait for their CLI prompt and each command's response. */
|
|
107
107
|
onReady?: (ready: TerminalReady) => void;
|
|
108
108
|
/** Shell output. */
|
|
109
109
|
onData?: (bytes: Uint8Array) => void;
|