deploynest 0.0.1 → 0.0.2

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 CHANGED
@@ -17,7 +17,7 @@ import { DeployNestClient } from "deploynest"
17
17
 
18
18
  const api = new DeployNestClient("https://deploynest.app")
19
19
 
20
- const result = await api.servers.getServers("org_abc123")
20
+ const result = await api.v1.servers.getServers("org_abc123")
21
21
 
22
22
  if (result.success) {
23
23
  console.log(result.servers)
@@ -34,6 +34,17 @@ const api = new DeployNestClient(window.location.origin, {
34
34
  })
35
35
  ```
36
36
 
37
+ ## API versions
38
+
39
+ Resource clients are grouped under version namespaces on `DeployNestClient`. Today only **v1** is available:
40
+
41
+ | Namespace | Client | Methods |
42
+ | -------------------- | ------------- | ----------------------------------------------------------------------- |
43
+ | `api.v1.servers` | Servers | `getServers`, `createServer`, `setupServer`, `deleteServer` |
44
+ | `api.v1.credentials` | Credentials | `getCredentials`, `createCredential`, `generatePrivateKey`, `deleteCredential` |
45
+
46
+ Future API versions will be added alongside `v1` (for example `api.v2`) without breaking existing callers.
47
+
37
48
  ## Configuration
38
49
 
39
50
  ```ts
@@ -1,9 +1,9 @@
1
- import { type BaseClientOptions } from "./base";
2
- export declare class CredentialsClient {
1
+ import { type BaseClientOptions } from "../base";
2
+ export declare class V1CredentialsClient {
3
3
  private readonly base;
4
4
  constructor(baseURL: string, opts: BaseClientOptions);
5
5
  private get client();
6
- getCredentials(organizationId: string): Promise<{
6
+ list(organizationId: string): Promise<{
7
7
  success: boolean;
8
8
  credentials: {
9
9
  id: string;
@@ -19,7 +19,7 @@ export declare class CredentialsClient {
19
19
  message: string;
20
20
  credentials?: undefined;
21
21
  }>;
22
- createCredential(organizationId: string, name: string, privateKey: string): Promise<{
22
+ create(organizationId: string, name: string, privateKey: string): Promise<{
23
23
  success: boolean;
24
24
  credential: {
25
25
  id: `${string}-${string}-${string}-${string}-${string}`;
@@ -44,7 +44,7 @@ export declare class CredentialsClient {
44
44
  message: string;
45
45
  privateKey?: undefined;
46
46
  }>;
47
- deleteCredential(credentialId: string, organizationId: string): Promise<{
47
+ delete(credentialId: string, organizationId: string): Promise<{
48
48
  success: boolean;
49
49
  message?: undefined;
50
50
  } | {
@@ -1,9 +1,9 @@
1
- import { type BaseClientOptions } from "./base";
2
- export declare class ServersClient {
1
+ import { type BaseClientOptions } from "../base";
2
+ export declare class V1ServersClient {
3
3
  private readonly base;
4
4
  constructor(baseURL: string, opts: BaseClientOptions);
5
5
  private get client();
6
- getServers(organizationId: string): Promise<{
6
+ list(organizationId: string): Promise<{
7
7
  success: boolean;
8
8
  servers: {
9
9
  id: string;
@@ -21,7 +21,7 @@ export declare class ServersClient {
21
21
  message: string;
22
22
  servers?: undefined;
23
23
  }>;
24
- createServer(organizationId: string, ip: string, port: number, username: string, privateKeyCredentialId: string): Promise<{
24
+ create(organizationId: string, ip: string, port: number, username: string, privateKeyCredentialId: string): Promise<{
25
25
  success: boolean;
26
26
  server: {
27
27
  id: string;
@@ -39,7 +39,7 @@ export declare class ServersClient {
39
39
  message: string;
40
40
  server?: undefined;
41
41
  }>;
42
- setupServer(serverId: string, organizationId: string): Promise<{
42
+ setup(serverId: string, organizationId: string): Promise<{
43
43
  alreadyInstalled: boolean;
44
44
  dockerVersion: string;
45
45
  log: string[];
@@ -50,7 +50,7 @@ export declare class ServersClient {
50
50
  success: boolean;
51
51
  message: string;
52
52
  }>;
53
- deleteServer(serverId: string, organizationId: string): Promise<{
53
+ delete(serverId: string, organizationId: string): Promise<{
54
54
  success: boolean;
55
55
  message?: undefined;
56
56
  } | {
package/dist/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { type BaseClientOptions } from "~/clients/base";
2
- import { CredentialsClient } from "~/clients/credentials";
3
- import { ServersClient } from "~/clients/servers";
2
+ import { V1CredentialsClient } from "~/clients/v1/credentials";
3
+ import { V1ServersClient } from "~/clients/v1/servers";
4
4
  export type ClientOptions = BaseClientOptions;
5
5
  export declare class DeployNestClient {
6
6
  readonly baseURL: string;
7
- readonly credentials: CredentialsClient;
8
- readonly servers: ServersClient;
7
+ readonly v1: {
8
+ credentials: V1CredentialsClient;
9
+ servers: V1ServersClient;
10
+ };
9
11
  constructor(baseURL?: string, opts?: ClientOptions);
10
12
  }
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ // src/clients/base.ts
2
+ import { hc } from "hono/client";
3
+
1
4
  // src/utils.ts
2
5
  function path(baseURL, path2) {
3
6
  const normalizedBase = baseURL.replace(/\/+$/, "");
@@ -9,7 +12,6 @@ function path(baseURL, path2) {
9
12
  }
10
13
 
11
14
  // src/clients/base.ts
12
- import { hc } from "hono/client";
13
15
  class BaseClient {
14
16
  baseURL;
15
17
  client;
@@ -31,16 +33,16 @@ class BaseClient {
31
33
  }
32
34
  }
33
35
 
34
- // src/clients/credentials.ts
35
- class CredentialsClient {
36
+ // src/clients/v1/credentials.ts
37
+ class V1CredentialsClient {
36
38
  base;
37
39
  constructor(baseURL, opts) {
38
- this.base = new BaseClient(baseURL, "/api/credentials", opts);
40
+ this.base = new BaseClient(baseURL, "/api/v1/credentials", opts);
39
41
  }
40
42
  get client() {
41
43
  return this.base.client;
42
44
  }
43
- async getCredentials(organizationId) {
45
+ async list(organizationId) {
44
46
  const response = await this.client.index.$get({
45
47
  query: {
46
48
  organizationId
@@ -59,7 +61,7 @@ class CredentialsClient {
59
61
  message: data.message
60
62
  };
61
63
  }
62
- async createCredential(organizationId, name, privateKey) {
64
+ async create(organizationId, name, privateKey) {
63
65
  const response = await this.client.index.$post({
64
66
  json: {
65
67
  organizationId,
@@ -95,7 +97,7 @@ class CredentialsClient {
95
97
  message: data.message
96
98
  };
97
99
  }
98
- async deleteCredential(credentialId, organizationId) {
100
+ async delete(credentialId, organizationId) {
99
101
  const response = await this.client[":credentialId"].$delete({
100
102
  param: { credentialId },
101
103
  query: { organizationId }
@@ -111,16 +113,16 @@ class CredentialsClient {
111
113
  }
112
114
  }
113
115
 
114
- // src/clients/servers.ts
115
- class ServersClient {
116
+ // src/clients/v1/servers.ts
117
+ class V1ServersClient {
116
118
  base;
117
119
  constructor(baseURL, opts) {
118
- this.base = new BaseClient(baseURL, "/api/servers", opts);
120
+ this.base = new BaseClient(baseURL, "/api/v1/servers", opts);
119
121
  }
120
122
  get client() {
121
123
  return this.base.client;
122
124
  }
123
- async getServers(organizationId) {
125
+ async list(organizationId) {
124
126
  const response = await this.client.index.$get({
125
127
  query: {
126
128
  organizationId
@@ -139,7 +141,7 @@ class ServersClient {
139
141
  message: data.message
140
142
  };
141
143
  }
142
- async createServer(organizationId, ip, port, username, privateKeyCredentialId) {
144
+ async create(organizationId, ip, port, username, privateKeyCredentialId) {
143
145
  const response = await this.client.index.$post({
144
146
  json: {
145
147
  organizationId,
@@ -162,7 +164,7 @@ class ServersClient {
162
164
  message: data.message
163
165
  };
164
166
  }
165
- async setupServer(serverId, organizationId) {
167
+ async setup(serverId, organizationId) {
166
168
  const response = await this.client[":serverId"].setup.$post({
167
169
  param: { serverId },
168
170
  query: { organizationId }
@@ -180,7 +182,7 @@ class ServersClient {
180
182
  message: data.message
181
183
  };
182
184
  }
183
- async deleteServer(serverId, organizationId) {
185
+ async delete(serverId, organizationId) {
184
186
  const response = await this.client[":serverId"].$delete({
185
187
  param: { serverId },
186
188
  query: { organizationId }
@@ -199,12 +201,13 @@ class ServersClient {
199
201
  // src/index.ts
200
202
  class DeployNestClient {
201
203
  baseURL;
202
- credentials;
203
- servers;
204
- constructor(baseURL = "https://deploynest.app/api", opts = {}) {
204
+ v1;
205
+ constructor(baseURL = "https://deploynest.app", opts = {}) {
205
206
  this.baseURL = baseURL;
206
- this.credentials = new CredentialsClient(baseURL, opts);
207
- this.servers = new ServersClient(baseURL, opts);
207
+ this.v1 = {
208
+ credentials: new V1CredentialsClient(baseURL, opts),
209
+ servers: new V1ServersClient(baseURL, opts)
210
+ };
208
211
  }
209
212
  }
210
213
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deploynest",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "./dist/index.js",
5
5
  "devDependencies": {
6
6
  "@types/bun": "1.3.14",
@@ -1,35 +0,0 @@
1
- // src/utils.ts
2
- function path(baseURL, path2) {
3
- const normalizedBase = baseURL.replace(/\/+$/, "");
4
- const normalizedPath = path2.replace(/^\/+/, "");
5
- if (!normalizedPath) {
6
- return normalizedBase || "/";
7
- }
8
- return `${normalizedBase}/${normalizedPath}`;
9
- }
10
-
11
- // src/clients/base.ts
12
- import { hc } from "hono/client";
13
- class BaseClient {
14
- baseURL;
15
- client;
16
- constructor(baseURL, basePath, opts) {
17
- let headers = {};
18
- if (opts.bearerToken) {
19
- headers.Authorization = `Bearer ${opts.bearerToken}`;
20
- }
21
- if (opts.userAgent) {
22
- headers["User-Agent"] = opts.userAgent;
23
- }
24
- if (Object.keys(headers).length === 0) {
25
- headers = undefined;
26
- }
27
- this.baseURL = path(baseURL, basePath);
28
- this.client = hc(this.baseURL, {
29
- headers
30
- });
31
- }
32
- }
33
- export {
34
- BaseClient
35
- };
@@ -1,115 +0,0 @@
1
- // src/utils.ts
2
- function path(baseURL, path2) {
3
- const normalizedBase = baseURL.replace(/\/+$/, "");
4
- const normalizedPath = path2.replace(/^\/+/, "");
5
- if (!normalizedPath) {
6
- return normalizedBase || "/";
7
- }
8
- return `${normalizedBase}/${normalizedPath}`;
9
- }
10
-
11
- // src/clients/base.ts
12
- import { hc } from "hono/client";
13
- class BaseClient {
14
- baseURL;
15
- client;
16
- constructor(baseURL, basePath, opts) {
17
- let headers = {};
18
- if (opts.bearerToken) {
19
- headers.Authorization = `Bearer ${opts.bearerToken}`;
20
- }
21
- if (opts.userAgent) {
22
- headers["User-Agent"] = opts.userAgent;
23
- }
24
- if (Object.keys(headers).length === 0) {
25
- headers = undefined;
26
- }
27
- this.baseURL = path(baseURL, basePath);
28
- this.client = hc(this.baseURL, {
29
- headers
30
- });
31
- }
32
- }
33
-
34
- // src/clients/credentials.ts
35
- class CredentialsClient {
36
- base;
37
- constructor(baseURL, opts) {
38
- this.base = new BaseClient(baseURL, "/api/credentials", opts);
39
- }
40
- get client() {
41
- return this.base.client;
42
- }
43
- async getCredentials(organizationId) {
44
- const response = await this.client.index.$get({
45
- query: {
46
- organizationId
47
- }
48
- });
49
- if (response.ok) {
50
- const data2 = await response.json();
51
- return {
52
- success: true,
53
- credentials: data2.credentials
54
- };
55
- }
56
- const data = await response.json();
57
- return {
58
- success: false,
59
- message: data.message
60
- };
61
- }
62
- async createCredential(organizationId, name, privateKey) {
63
- const response = await this.client.index.$post({
64
- json: {
65
- organizationId,
66
- name,
67
- privateKey
68
- }
69
- });
70
- if (response.ok) {
71
- const data2 = await response.json();
72
- return {
73
- success: true,
74
- credential: data2.credential
75
- };
76
- }
77
- const data = await response.json();
78
- return {
79
- success: false,
80
- message: data.message
81
- };
82
- }
83
- async generatePrivateKey() {
84
- const response = await this.client["generate-private-key"].$post();
85
- if (response.ok) {
86
- const data2 = await response.json();
87
- return {
88
- success: true,
89
- privateKey: data2.privateKey
90
- };
91
- }
92
- const data = await response.json();
93
- return {
94
- success: false,
95
- message: data.message
96
- };
97
- }
98
- async deleteCredential(credentialId, organizationId) {
99
- const response = await this.client[":credentialId"].$delete({
100
- param: { credentialId },
101
- query: { organizationId }
102
- });
103
- if (response.ok) {
104
- return { success: true };
105
- }
106
- const data = await response.json();
107
- return {
108
- success: false,
109
- message: data.message
110
- };
111
- }
112
- }
113
- export {
114
- CredentialsClient
115
- };
@@ -1,120 +0,0 @@
1
- // src/utils.ts
2
- function path(baseURL, path2) {
3
- const normalizedBase = baseURL.replace(/\/+$/, "");
4
- const normalizedPath = path2.replace(/^\/+/, "");
5
- if (!normalizedPath) {
6
- return normalizedBase || "/";
7
- }
8
- return `${normalizedBase}/${normalizedPath}`;
9
- }
10
-
11
- // src/clients/base.ts
12
- import { hc } from "hono/client";
13
- class BaseClient {
14
- baseURL;
15
- client;
16
- constructor(baseURL, basePath, opts) {
17
- let headers = {};
18
- if (opts.bearerToken) {
19
- headers.Authorization = `Bearer ${opts.bearerToken}`;
20
- }
21
- if (opts.userAgent) {
22
- headers["User-Agent"] = opts.userAgent;
23
- }
24
- if (Object.keys(headers).length === 0) {
25
- headers = undefined;
26
- }
27
- this.baseURL = path(baseURL, basePath);
28
- this.client = hc(this.baseURL, {
29
- headers
30
- });
31
- }
32
- }
33
-
34
- // src/clients/servers.ts
35
- class ServersClient {
36
- base;
37
- constructor(baseURL, opts) {
38
- this.base = new BaseClient(baseURL, "/api/servers", opts);
39
- }
40
- get client() {
41
- return this.base.client;
42
- }
43
- async getServers(organizationId) {
44
- const response = await this.client.index.$get({
45
- query: {
46
- organizationId
47
- }
48
- });
49
- if (response.ok) {
50
- const data2 = await response.json();
51
- return {
52
- success: true,
53
- servers: data2.servers
54
- };
55
- }
56
- const data = await response.json();
57
- return {
58
- success: false,
59
- message: data.message
60
- };
61
- }
62
- async createServer(organizationId, ip, port, username, privateKeyCredentialId) {
63
- const response = await this.client.index.$post({
64
- json: {
65
- organizationId,
66
- ip,
67
- port,
68
- username,
69
- privateKeyCredentialId
70
- }
71
- });
72
- if (response.ok) {
73
- const data2 = await response.json();
74
- return {
75
- success: true,
76
- server: data2.server
77
- };
78
- }
79
- const data = await response.json();
80
- return {
81
- success: false,
82
- message: data.message
83
- };
84
- }
85
- async setupServer(serverId, organizationId) {
86
- const response = await this.client[":serverId"].setup.$post({
87
- param: { serverId },
88
- query: { organizationId }
89
- });
90
- if (response.ok) {
91
- const data2 = await response.json();
92
- return {
93
- success: true,
94
- ...data2
95
- };
96
- }
97
- const data = await response.json();
98
- return {
99
- success: false,
100
- message: data.message
101
- };
102
- }
103
- async deleteServer(serverId, organizationId) {
104
- const response = await this.client[":serverId"].$delete({
105
- param: { serverId },
106
- query: { organizationId }
107
- });
108
- if (response.ok) {
109
- return { success: true };
110
- }
111
- const data = await response.json();
112
- return {
113
- success: false,
114
- message: data.message
115
- };
116
- }
117
- }
118
- export {
119
- ServersClient
120
- };
package/dist/utils.js DELETED
@@ -1,12 +0,0 @@
1
- // src/utils.ts
2
- function path(baseURL, path2) {
3
- const normalizedBase = baseURL.replace(/\/+$/, "");
4
- const normalizedPath = path2.replace(/^\/+/, "");
5
- if (!normalizedPath) {
6
- return normalizedBase || "/";
7
- }
8
- return `${normalizedBase}/${normalizedPath}`;
9
- }
10
- export {
11
- path
12
- };