@toshicloud/sdk 0.4.0 → 0.5.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 +44 -3
- package/dist/client.d.ts +7 -2
- package/dist/client.js +9 -3
- package/dist/errors.d.ts +47 -0
- package/dist/errors.js +136 -0
- package/dist/gen/toshi/permission_pb.d.ts +39 -0
- package/dist/gen/toshi/permission_pb.js +42 -0
- package/dist/gen/toshi/workspace/v1/artifacts_pb.d.ts +1 -1
- package/dist/gen/toshi/workspace/v1/artifacts_pb.js +3 -2
- package/dist/gen/toshi/workspace/v1/audit_events_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/channels_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/discovery_pb.d.ts +676 -0
- package/dist/gen/toshi/workspace/v1/discovery_pb.js +182 -0
- package/dist/gen/toshi/workspace/v1/display_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/fillers_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/hostjobs_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/hosts_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/products_pb.d.ts +703 -0
- package/dist/gen/toshi/workspace/v1/products_pb.js +106 -0
- package/dist/gen/toshi/workspace/v1/projects_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/recordings_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/secrets_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/storage_providers_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/tokens_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/volumes_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/webhook_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/workloads_pb.js +2 -1
- package/dist/gen/toshi/workspace/v1/workspace_pb.d.ts +2 -2
- package/dist/gen/toshi/workspace/v1/workspace_pb.js +1 -1
- package/dist/gen/toshi/workspace/v1/workspace_service_pb.js +2 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/interceptors.d.ts +6 -0
- package/dist/interceptors.js +29 -0
- package/dist/retry.js +4 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15,9 +15,11 @@ export * from "./gen/toshi/workspace/v1/hostjobs_pb.js";
|
|
|
15
15
|
export * from "./gen/toshi/workspace/v1/hosts_pb.js";
|
|
16
16
|
export * from "./gen/toshi/workspace/v1/storage_providers_pb.js";
|
|
17
17
|
export * from "./gen/toshi/workspace/v1/tokens_pb.js";
|
|
18
|
+
export * from "./gen/toshi/workspace/v1/products_pb.js";
|
|
19
|
+
export * from "./gen/toshi/workspace/v1/discovery_pb.js";
|
|
18
20
|
export * from "./gen/toshi/workspace/v1/workspace_service_pb.js";
|
|
19
21
|
export { createToshiClient } from "./client.js";
|
|
20
22
|
export { paginate } from "./paginate.js";
|
|
21
|
-
export { ExitError, JobExitError, StreamLostError } from "./errors.js";
|
|
23
|
+
export { ExitError, JobExitError, ProductError, ProductReason, StreamLostError, isProductError } from "./errors.js";
|
|
22
24
|
export { defaultRetryPolicy } from "./retry.js";
|
|
23
25
|
export { VERSION } from "./version.js";
|
package/dist/interceptors.d.ts
CHANGED
|
@@ -17,3 +17,9 @@ export declare function scopeInterceptor(project: string, environment: string):
|
|
|
17
17
|
export declare function keyInterceptor(): Interceptor;
|
|
18
18
|
/** Retries a unary read or keyed write after a transport loss, with full jitter (retry.go:98-186). */
|
|
19
19
|
export declare function retryInterceptor(retry: RetrySetting): Interceptor;
|
|
20
|
+
/**
|
|
21
|
+
* Throws a ProductError in place of a product's refusal, on a unary call and
|
|
22
|
+
* on a stream's messages. It is the outermost interceptor, so the retry and
|
|
23
|
+
* the helpers inside see the ConnectError they always did.
|
|
24
|
+
*/
|
|
25
|
+
export declare function productInterceptor(): Interceptor;
|
package/dist/interceptors.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ScalarType } from "@bufbuild/protobuf";
|
|
2
2
|
import { Code, ConnectError } from "@connectrpc/connect";
|
|
3
3
|
import { backoffDelay, isTransportLoss, newRequestKey, procedurePath, retryClassFor, sleep, } from "./retry.js";
|
|
4
|
+
import { asProductError } from "./errors.js";
|
|
4
5
|
/**
|
|
5
6
|
* Sends `Authorization: Bearer <token>` on every call and stream, on a copy of
|
|
6
7
|
* the request: it is the innermost interceptor, so none outside it sees the
|
|
@@ -193,3 +194,31 @@ function isShared(msg, desc) {
|
|
|
193
194
|
field.scalar === ScalarType.BOOL &&
|
|
194
195
|
msg[field.localName] === true);
|
|
195
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Throws a ProductError in place of a product's refusal, on a unary call and
|
|
199
|
+
* on a stream's messages. It is the outermost interceptor, so the retry and
|
|
200
|
+
* the helpers inside see the ConnectError they always did.
|
|
201
|
+
*/
|
|
202
|
+
export function productInterceptor() {
|
|
203
|
+
return (next) => async (req) => {
|
|
204
|
+
let res;
|
|
205
|
+
try {
|
|
206
|
+
res = await next(req);
|
|
207
|
+
}
|
|
208
|
+
catch (err) {
|
|
209
|
+
throw asProductError(err);
|
|
210
|
+
}
|
|
211
|
+
if (!res.stream) {
|
|
212
|
+
return res;
|
|
213
|
+
}
|
|
214
|
+
return { ...res, message: productStream(res.message) };
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
async function* productStream(messages) {
|
|
218
|
+
try {
|
|
219
|
+
yield* messages;
|
|
220
|
+
}
|
|
221
|
+
catch (err) {
|
|
222
|
+
throw asProductError(err);
|
|
223
|
+
}
|
|
224
|
+
}
|
package/dist/retry.js
CHANGED
|
@@ -159,6 +159,10 @@ const procedureRetryClass = {
|
|
|
159
159
|
"/toshi.workspace.v1.StorageProviderService/CreateStorageProvider": "none",
|
|
160
160
|
"/toshi.workspace.v1.StorageProviderService/CheckStorageProvider": "none",
|
|
161
161
|
"/toshi.workspace.v1.StorageProviderService/DeleteStorageProvider": "none",
|
|
162
|
+
"/toshi.workspace.v1.ProductService/ListProducts": "read",
|
|
163
|
+
"/toshi.workspace.v1.ProductService/UpdateProduct": "none",
|
|
164
|
+
"/toshi.workspace.v1.ProductService/RemoveProduct": "none",
|
|
165
|
+
"/toshi.workspace.v1.DiscoveryService/Discover": "read",
|
|
162
166
|
};
|
|
163
167
|
/** The retry class of a generated procedure path; an unknown path is "none". */
|
|
164
168
|
export function retryClassFor(procedure) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The package version; test/node.test.ts keeps it equal to package.json. */
|
|
2
|
-
export declare const VERSION = "0.
|
|
2
|
+
export declare const VERSION = "0.5.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The package version; test/node.test.ts keeps it equal to package.json. */
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.5.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toshicloud/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "TypeScript client for the Toshi Workspace API",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"packageManager": "pnpm@12.15.0+sha512.b3951d6d6ff4a9f13dc7cf56cd28d2b8eb37dbcc9c68e52e1e1191873ea9f82a017287ab50baadc5ccc494f036c67c0e47eb13608c2fa36f47711b61ea128e61",
|