@qvac/registry-client 0.3.0 → 0.4.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 +1 -3
- package/index.d.ts +27 -1
- package/lib/client.js +36 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -139,11 +139,9 @@ The package includes a CLI for querying and downloading models from the registry
|
|
|
139
139
|
|
|
140
140
|
### Install
|
|
141
141
|
|
|
142
|
-
The package is hosted on npm.
|
|
142
|
+
The package is hosted on npm. Install globally:
|
|
143
143
|
|
|
144
144
|
```bash
|
|
145
|
-
echo "@qvac:registry=https://registry.npmjs.org" >> ~/.npmrc
|
|
146
|
-
echo "//registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN" >> ~/.npmrc
|
|
147
145
|
npm install -g @qvac/registry-client
|
|
148
146
|
```
|
|
149
147
|
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import ReadyResource = require('ready-resource')
|
|
2
|
+
|
|
3
|
+
export interface LifecycleLogOptions {
|
|
4
|
+
log?: (msg: string) => Promise<void> | void
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
export interface QVACBlobBinding {
|
|
2
8
|
coreKey: Buffer | string
|
|
3
9
|
blockOffset: number
|
|
@@ -41,6 +47,8 @@ export interface QVACDownloadOptions {
|
|
|
41
47
|
timeout?: number
|
|
42
48
|
peerTimeout?: number
|
|
43
49
|
outputFile?: string
|
|
50
|
+
onProgress?: (progress: { downloaded: number, total: number, cachedBlocks: number, totalBlocks: number }) => void
|
|
51
|
+
signal?: AbortSignal
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
export interface QVACBlobDownloadOptions {
|
|
@@ -78,11 +86,29 @@ export interface FindByParams {
|
|
|
78
86
|
includeDeprecated?: boolean
|
|
79
87
|
}
|
|
80
88
|
|
|
81
|
-
export
|
|
89
|
+
export interface LifecycleSwarmHandle {
|
|
90
|
+
readonly suspended: boolean
|
|
91
|
+
suspend (opts?: LifecycleLogOptions): Promise<void>
|
|
92
|
+
resume (opts?: LifecycleLogOptions): Promise<void>
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface LifecycleStoreHandle {
|
|
96
|
+
suspend (opts?: LifecycleLogOptions): Promise<void>
|
|
97
|
+
resume (): Promise<void>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class QVACRegistryClient extends ReadyResource {
|
|
82
101
|
constructor (opts?: QVACRegistryClientOptions)
|
|
83
102
|
|
|
103
|
+
/** Valid only while the client remains open. Cached handles become stale after close(). */
|
|
104
|
+
readonly corestore: LifecycleStoreHandle | null
|
|
105
|
+
/** Valid only while the client remains open. Cached handles become stale after close(). */
|
|
106
|
+
readonly hyperswarm: LifecycleSwarmHandle | null
|
|
107
|
+
|
|
84
108
|
ready (): Promise<void>
|
|
85
109
|
close (): Promise<void>
|
|
110
|
+
suspend (opts?: LifecycleLogOptions): Promise<void>
|
|
111
|
+
resume (opts?: LifecycleLogOptions): Promise<void>
|
|
86
112
|
|
|
87
113
|
getModel (path: string, source: string): Promise<QVACModelEntry | null>
|
|
88
114
|
downloadModel (path: string, source: string, options?: QVACDownloadOptions): Promise<QVACDownloadResult>
|
package/lib/client.js
CHANGED
|
@@ -526,6 +526,42 @@ class QVACRegistryClient extends ReadyResource {
|
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
528
|
|
|
529
|
+
async suspend (opts = {}) {
|
|
530
|
+
this.logger.debug('suspend called')
|
|
531
|
+
|
|
532
|
+
if (!this.opened || this.closing) {
|
|
533
|
+
this.logger.debug('Skipping suspend while client is not open or is closing')
|
|
534
|
+
return
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if (this.hyperswarm && !this.hyperswarm.suspended) {
|
|
538
|
+
await this.hyperswarm.suspend(opts)
|
|
539
|
+
}
|
|
540
|
+
if (this.corestore) {
|
|
541
|
+
await this.corestore.suspend(opts)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
this.logger.debug('QVACRegistryClient suspended')
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
async resume (opts = {}) {
|
|
548
|
+
this.logger.debug('resume called')
|
|
549
|
+
|
|
550
|
+
if (!this.opened || this.closing) {
|
|
551
|
+
this.logger.debug('Skipping resume while client is not open or is closing')
|
|
552
|
+
return
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (this.corestore) {
|
|
556
|
+
await this.corestore.resume()
|
|
557
|
+
}
|
|
558
|
+
if (this.hyperswarm && this.hyperswarm.suspended) {
|
|
559
|
+
await this.hyperswarm.resume(opts)
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
this.logger.debug('QVACRegistryClient resumed')
|
|
563
|
+
}
|
|
564
|
+
|
|
529
565
|
async _close () {
|
|
530
566
|
this.logger.debug('_close called')
|
|
531
567
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/registry-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "QVAC Registry client library for read-only queries via Hyperswarm",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@qvac/error": "^0.1.0",
|
|
56
|
-
"@qvac/registry-schema": "^0.1.
|
|
56
|
+
"@qvac/registry-schema": "^0.1.2",
|
|
57
57
|
"b4a": "^1.6.7",
|
|
58
58
|
"bare-fs": "^4.5.2",
|
|
59
59
|
"bare-os": "^3.6.2",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"corestore": "^7.4.5",
|
|
63
63
|
"hyperblobs": "^2.8.0",
|
|
64
64
|
"hypercore-id-encoding": "^1.3.0",
|
|
65
|
-
"hyperdb": "^4.16.1",
|
|
66
65
|
"hypercore-stats": "^2.4.0",
|
|
66
|
+
"hyperdb": "^4.16.1",
|
|
67
67
|
"hyperswarm": "^4.14.0",
|
|
68
68
|
"hyperswarm-stats": "^1.3.0",
|
|
69
69
|
"paparam": "^1.10.0",
|