cosmos-cloud-sdk 0.23.3 → 0.24.0-unstable006

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/index.d.mts CHANGED
@@ -6,6 +6,32 @@ interface ApiResponse<T = any> {
6
6
  }
7
7
  type ApiFetch = (path: string, options?: RequestInit) => Promise<Response>;
8
8
 
9
+ interface ConstellationDevice {
10
+ Nickname: string;
11
+ DeviceName: string;
12
+ IP: string;
13
+ IsLighthouse: boolean;
14
+ IsRelay: boolean;
15
+ Blocked: boolean;
16
+ Fingerprint: string;
17
+ PublicHostname: string;
18
+ Port: string;
19
+ [key: string]: any;
20
+ }
21
+ interface TagMatchNode {
22
+ name: string;
23
+ live: boolean;
24
+ tags: string[];
25
+ }
26
+ interface TagMatchResult {
27
+ tags: string[];
28
+ matched: TagMatchNode[];
29
+ matchedCount: number;
30
+ liveMatchedCount: number;
31
+ totalNodes: number;
32
+ liveNodes: number;
33
+ }
34
+
9
35
  declare function createApiClient(baseUrl?: string, token?: string | null): {
10
36
  apiFetch: ApiFetch;
11
37
  createWs: (path: string) => WebSocket;
@@ -150,19 +176,6 @@ interface OpenIDClient {
150
176
  redirect: string;
151
177
  }
152
178
 
153
- interface ConstellationDevice {
154
- Nickname: string;
155
- DeviceName: string;
156
- IP: string;
157
- IsLighthouse: boolean;
158
- IsRelay: boolean;
159
- Blocked: boolean;
160
- Fingerprint: string;
161
- PublicHostname: string;
162
- Port: string;
163
- [key: string]: any;
164
- }
165
-
166
179
  interface CronJob {
167
180
  Disabled: boolean;
168
181
  Scheduler: string;
@@ -354,6 +367,10 @@ declare function createClient({ baseUrl, token }: {
354
367
  createService: (serviceData: any, onProgress: (line: string) => void) => Promise<ReadableStream>;
355
368
  pullImage: (imageName: string, onProgress: (line: string) => void, ifMissing?: boolean) => Promise<ReadableStream>;
356
369
  autoUpdate: (id: string, toggle: string) => Promise<ApiResponse>;
370
+ lazy: (id: string, toggle: string, opts?: {
371
+ idle?: string;
372
+ startTimeout?: string;
373
+ }) => Promise<ApiResponse>;
357
374
  updateContainerImage: (containerName: string, onProgress: (line: string) => void) => Promise<ReadableStream>;
358
375
  exportContainer: (containerId: string, values: any) => Promise<ApiResponse>;
359
376
  migrateHost: (values: any) => Promise<ApiResponse>;
@@ -391,6 +408,7 @@ declare function createClient({ baseUrl, token }: {
391
408
  Value: string;
392
409
  }) => Promise<ApiResponse>;
393
410
  deleteDNSEntry: (key: string) => Promise<ApiResponse>;
411
+ tagNodes: (tags: string[]) => Promise<ApiResponse<TagMatchResult>>;
394
412
  };
395
413
  metrics: {
396
414
  get: (metarr: string[]) => Promise<ApiResponse>;
package/dist/index.d.ts CHANGED
@@ -6,6 +6,32 @@ interface ApiResponse<T = any> {
6
6
  }
7
7
  type ApiFetch = (path: string, options?: RequestInit) => Promise<Response>;
8
8
 
9
+ interface ConstellationDevice {
10
+ Nickname: string;
11
+ DeviceName: string;
12
+ IP: string;
13
+ IsLighthouse: boolean;
14
+ IsRelay: boolean;
15
+ Blocked: boolean;
16
+ Fingerprint: string;
17
+ PublicHostname: string;
18
+ Port: string;
19
+ [key: string]: any;
20
+ }
21
+ interface TagMatchNode {
22
+ name: string;
23
+ live: boolean;
24
+ tags: string[];
25
+ }
26
+ interface TagMatchResult {
27
+ tags: string[];
28
+ matched: TagMatchNode[];
29
+ matchedCount: number;
30
+ liveMatchedCount: number;
31
+ totalNodes: number;
32
+ liveNodes: number;
33
+ }
34
+
9
35
  declare function createApiClient(baseUrl?: string, token?: string | null): {
10
36
  apiFetch: ApiFetch;
11
37
  createWs: (path: string) => WebSocket;
@@ -150,19 +176,6 @@ interface OpenIDClient {
150
176
  redirect: string;
151
177
  }
152
178
 
153
- interface ConstellationDevice {
154
- Nickname: string;
155
- DeviceName: string;
156
- IP: string;
157
- IsLighthouse: boolean;
158
- IsRelay: boolean;
159
- Blocked: boolean;
160
- Fingerprint: string;
161
- PublicHostname: string;
162
- Port: string;
163
- [key: string]: any;
164
- }
165
-
166
179
  interface CronJob {
167
180
  Disabled: boolean;
168
181
  Scheduler: string;
@@ -354,6 +367,10 @@ declare function createClient({ baseUrl, token }: {
354
367
  createService: (serviceData: any, onProgress: (line: string) => void) => Promise<ReadableStream>;
355
368
  pullImage: (imageName: string, onProgress: (line: string) => void, ifMissing?: boolean) => Promise<ReadableStream>;
356
369
  autoUpdate: (id: string, toggle: string) => Promise<ApiResponse>;
370
+ lazy: (id: string, toggle: string, opts?: {
371
+ idle?: string;
372
+ startTimeout?: string;
373
+ }) => Promise<ApiResponse>;
357
374
  updateContainerImage: (containerName: string, onProgress: (line: string) => void) => Promise<ReadableStream>;
358
375
  exportContainer: (containerId: string, values: any) => Promise<ApiResponse>;
359
376
  migrateHost: (values: any) => Promise<ApiResponse>;
@@ -391,6 +408,7 @@ declare function createClient({ baseUrl, token }: {
391
408
  Value: string;
392
409
  }) => Promise<ApiResponse>;
393
410
  deleteDNSEntry: (key: string) => Promise<ApiResponse>;
411
+ tagNodes: (tags: string[]) => Promise<ApiResponse<TagMatchResult>>;
394
412
  };
395
413
  metrics: {
396
414
  get: (metarr: string[]) => Promise<ApiResponse>;
package/dist/index.js CHANGED
@@ -711,6 +711,18 @@ function createDockerAPI(apiFetch, createWs) {
711
711
  }
712
712
  }));
713
713
  }
714
+ function lazy(id, toggle, opts) {
715
+ const params = new URLSearchParams();
716
+ if (opts && opts.idle) params.set("idle", opts.idle);
717
+ if (opts && opts.startTimeout) params.set("startTimeout", opts.startTimeout);
718
+ const query = params.toString() ? "?" + params.toString() : "";
719
+ return wrap(apiFetch("/cosmos/api/servapps/" + id + "/lazy/" + toggle + query, {
720
+ method: "GET",
721
+ headers: {
722
+ "Content-Type": "application/json"
723
+ }
724
+ }));
725
+ }
714
726
  return {
715
727
  list,
716
728
  get,
@@ -733,6 +745,7 @@ function createDockerAPI(apiFetch, createWs) {
733
745
  createService,
734
746
  pullImage,
735
747
  autoUpdate,
748
+ lazy,
736
749
  updateContainerImage,
737
750
  exportContainer,
738
751
  migrateHost
@@ -947,6 +960,13 @@ function createConstellationAPI(apiFetch) {
947
960
  headers: { "Content-Type": "application/json" }
948
961
  }));
949
962
  }
963
+ function tagNodes(tags) {
964
+ const query = (tags || []).join(",");
965
+ return wrap(apiFetch("/cosmos/api/constellation/tag-nodes?tags=" + encodeURIComponent(query), {
966
+ method: "GET",
967
+ headers: { "Content-Type": "application/json" }
968
+ }), true);
969
+ }
950
970
  return {
951
971
  list,
952
972
  addDevice,
@@ -968,7 +988,8 @@ function createConstellationAPI(apiFetch) {
968
988
  listDNSEntries,
969
989
  createDNSEntry,
970
990
  updateDNSEntry,
971
- deleteDNSEntry
991
+ deleteDNSEntry,
992
+ tagNodes
972
993
  };
973
994
  }
974
995
 
package/dist/index.mjs CHANGED
@@ -685,6 +685,18 @@ function createDockerAPI(apiFetch, createWs) {
685
685
  }
686
686
  }));
687
687
  }
688
+ function lazy(id, toggle, opts) {
689
+ const params = new URLSearchParams();
690
+ if (opts && opts.idle) params.set("idle", opts.idle);
691
+ if (opts && opts.startTimeout) params.set("startTimeout", opts.startTimeout);
692
+ const query = params.toString() ? "?" + params.toString() : "";
693
+ return wrap(apiFetch("/cosmos/api/servapps/" + id + "/lazy/" + toggle + query, {
694
+ method: "GET",
695
+ headers: {
696
+ "Content-Type": "application/json"
697
+ }
698
+ }));
699
+ }
688
700
  return {
689
701
  list,
690
702
  get,
@@ -707,6 +719,7 @@ function createDockerAPI(apiFetch, createWs) {
707
719
  createService,
708
720
  pullImage,
709
721
  autoUpdate,
722
+ lazy,
710
723
  updateContainerImage,
711
724
  exportContainer,
712
725
  migrateHost
@@ -921,6 +934,13 @@ function createConstellationAPI(apiFetch) {
921
934
  headers: { "Content-Type": "application/json" }
922
935
  }));
923
936
  }
937
+ function tagNodes(tags) {
938
+ const query = (tags || []).join(",");
939
+ return wrap(apiFetch("/cosmos/api/constellation/tag-nodes?tags=" + encodeURIComponent(query), {
940
+ method: "GET",
941
+ headers: { "Content-Type": "application/json" }
942
+ }), true);
943
+ }
924
944
  return {
925
945
  list,
926
946
  addDevice,
@@ -942,7 +962,8 @@ function createConstellationAPI(apiFetch) {
942
962
  listDNSEntries,
943
963
  createDNSEntry,
944
964
  updateDNSEntry,
945
- deleteDNSEntry
965
+ deleteDNSEntry,
966
+ tagNodes
946
967
  };
947
968
  }
948
969
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosmos-cloud-sdk",
3
- "version": "0.23.3",
3
+ "version": "0.24.0-unstable006",
4
4
  "description": "JavaScript/TypeScript SDK for the Cosmos Server API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",