@toshicloud/sdk 0.5.1 → 0.6.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/dist/test/fake.js CHANGED
@@ -3,6 +3,7 @@ import { Code, ConnectError, createRouterTransport } from "@connectrpc/connect";
3
3
  import { createToshiClient } from "../client.js";
4
4
  import { CancelJobResponseSchema, CreateJobResponseSchema, CreateSandboxResponseSchema, GetJobResponseSchema, GetSandboxResponseSchema, ListJobsResponseSchema, ListSandboxesResponseSchema, WaitJobResponseSchema, WaitSandboxResponseSchema, WatchJobsResponseSchema, WatchSandboxesResponseSchema, WorkloadService, } from "../gen/toshi/workspace/v1/workloads_pb.js";
5
5
  import { EndReason, EventType, ExecuteResponseSchema, ExecutionExitSchema, ExecutionStartedSchema, JobSchema, JobState, JobStatusSchema, OutputEndSchema, RecordingPolicy, SandboxSchema, SandboxState, SandboxStatusSchema, WatchOutputResponseSchema, } from "../gen/toshi/workspace/v1/workspace_pb.js";
6
+ import { AlarmStore } from "./alarms.js";
6
7
  import { apiMethods, apiPackage, hookOnly as hookOnlyMethods, isApiMethod, procedurePath } from "./procedures.js";
7
8
  /** The token `client` sends. */
8
9
  export const testToken = "test-token";
@@ -93,6 +94,34 @@ const builtinTable = [
93
94
  run: (requests) => fake.executeAnswer(requests),
94
95
  }),
95
96
  ],
97
+ [
98
+ workloadMethod("setServiceAlarm"),
99
+ (fake) => ({ kind: "unary", run: (request) => fake.alarms.set(request) }),
100
+ ],
101
+ [
102
+ workloadMethod("getServiceAlarm"),
103
+ (fake) => ({ kind: "unary", run: (request) => fake.alarms.get(request) }),
104
+ ],
105
+ [
106
+ workloadMethod("listServiceAlarms"),
107
+ (fake) => ({ kind: "unary", run: (request) => fake.alarms.list(request) }),
108
+ ],
109
+ [
110
+ workloadMethod("deleteServiceAlarm"),
111
+ (fake) => ({ kind: "unary", run: (request) => fake.alarms.delete(request) }),
112
+ ],
113
+ [
114
+ workloadMethod("pauseServiceAlarm"),
115
+ (fake) => ({ kind: "unary", run: (request) => fake.alarms.pause(request) }),
116
+ ],
117
+ [
118
+ workloadMethod("resumeServiceAlarm"),
119
+ (fake) => ({ kind: "unary", run: (request) => fake.alarms.resume(request) }),
120
+ ],
121
+ [
122
+ workloadMethod("runServiceAlarmNow"),
123
+ (fake) => ({ kind: "unary", run: (request) => fake.alarms.runNow(request) }),
124
+ ],
96
125
  ];
97
126
  /** The procedures the state machine answers. The coverage test holds it against the API. */
98
127
  export const answeredProcedures = builtinTable.map(([method]) => method);
@@ -122,6 +151,8 @@ class FakeToshi {
122
151
  nextSandbox = 0;
123
152
  executions = new Map();
124
153
  nextExecution = 0;
154
+ /** The service alarms the fake holds; `builtinTable` answers from it. */
155
+ alarms = new AlarmStore();
125
156
  constructor() {
126
157
  for (const [method, make] of builtinTable) {
127
158
  this.builtin.set(procedurePath(method), make(this));
@@ -19,8 +19,8 @@
19
19
  * # What the fake answers
20
20
  *
21
21
  * The fake holds one workspace and has no clock: every call answers at once
22
- * with what the test set. It knows the job and the sandbox lifecycle and
23
- * nothing else.
22
+ * with what the test set. It knows the job and the sandbox lifecycle and a
23
+ * service's alarms, and nothing else.
24
24
  *
25
25
  * - `job`, `sandbox` and `execute` set what the fake answers: a job's or a
26
26
  * sandbox's state, and the standard output, the standard error and the exit
@@ -46,6 +46,16 @@
46
46
  * - Execute answers the start message with an execution id, the standard
47
47
  * output, the standard error and the exit code the test set for the sandbox.
48
48
  * It does not read standard input.
49
+ * - SetServiceAlarm, GetServiceAlarm, ListServiceAlarms, DeleteServiceAlarm,
50
+ * PauseServiceAlarm, ResumeServiceAlarm and RunServiceAlarmNow keep alarms
51
+ * for any service ID: the fake holds no services. A set creates an alarm at
52
+ * generation 1, or replaces it at the next generation and resumes it.
53
+ * RunServiceAlarmNow records a manual occurrence, which GetServiceAlarm
54
+ * returns newest first; a run whose request key the fake has already
55
+ * answered returns the same occurrence. With no clock an alarm publishes
56
+ * nothing on its own, a cron alarm has no next instant, and the fake sets no
57
+ * time of its own: an alarm set at an instant has that instant as its next
58
+ * one. An unknown alarm is NOT_FOUND.
49
59
  *
50
60
  * Every other procedure is hook-only. An unhooked procedure the state machine
51
61
  * does not cover answers UNIMPLEMENTED, naming the procedure and the `on` call
@@ -19,8 +19,8 @@
19
19
  * # What the fake answers
20
20
  *
21
21
  * The fake holds one workspace and has no clock: every call answers at once
22
- * with what the test set. It knows the job and the sandbox lifecycle and
23
- * nothing else.
22
+ * with what the test set. It knows the job and the sandbox lifecycle and a
23
+ * service's alarms, and nothing else.
24
24
  *
25
25
  * - `job`, `sandbox` and `execute` set what the fake answers: a job's or a
26
26
  * sandbox's state, and the standard output, the standard error and the exit
@@ -46,6 +46,16 @@
46
46
  * - Execute answers the start message with an execution id, the standard
47
47
  * output, the standard error and the exit code the test set for the sandbox.
48
48
  * It does not read standard input.
49
+ * - SetServiceAlarm, GetServiceAlarm, ListServiceAlarms, DeleteServiceAlarm,
50
+ * PauseServiceAlarm, ResumeServiceAlarm and RunServiceAlarmNow keep alarms
51
+ * for any service ID: the fake holds no services. A set creates an alarm at
52
+ * generation 1, or replaces it at the next generation and resumes it.
53
+ * RunServiceAlarmNow records a manual occurrence, which GetServiceAlarm
54
+ * returns newest first; a run whose request key the fake has already
55
+ * answered returns the same occurrence. With no clock an alarm publishes
56
+ * nothing on its own, a cron alarm has no next instant, and the fake sets no
57
+ * time of its own: an alarm set at an instant has that instant as its next
58
+ * one. An unknown alarm is NOT_FOUND.
49
59
  *
50
60
  * Every other procedure is hook-only. An unhooked procedure the state machine
51
61
  * does not cover answers UNIMPLEMENTED, naming the procedure and the `on` call
@@ -116,6 +116,9 @@ export const hookOnly = [
116
116
  WorkloadService.method.stopService,
117
117
  WorkloadService.method.setServiceMode,
118
118
  WorkloadService.method.wakeService,
119
+ // The fake holds no workloads: the operator's holds are answered by hooks.
120
+ WorkloadService.method.holdWorkload,
121
+ WorkloadService.method.releaseWorkload,
119
122
  WorkloadService.method.holdService,
120
123
  WorkloadService.method.releaseService,
121
124
  WorkloadService.method.listServiceRevisions,
@@ -127,15 +130,7 @@ export const hookOnly = [
127
130
  WorkloadService.method.watchEvents,
128
131
  WorkloadService.method.getOperation,
129
132
  WorkloadService.method.waitOperation,
130
- // The fake holds no services: their alarms and sign-ins are answered by
131
- // hooks.
132
- WorkloadService.method.setServiceAlarm,
133
- WorkloadService.method.getServiceAlarm,
134
- WorkloadService.method.listServiceAlarms,
135
- WorkloadService.method.deleteServiceAlarm,
136
- WorkloadService.method.pauseServiceAlarm,
137
- WorkloadService.method.resumeServiceAlarm,
138
- WorkloadService.method.runServiceAlarmNow,
133
+ // The fake holds no services: their sign-ins are answered by hooks.
139
134
  WorkloadService.method.startServiceSignIn,
140
135
  WorkloadService.method.answerServiceSignIn,
141
136
  WorkloadService.method.cancelServiceSignIn,
@@ -290,6 +285,7 @@ export const hookOnly = [
290
285
  WorkspaceService.method.listWorkspaces,
291
286
  WorkspaceService.method.getWorkspaceBilling,
292
287
  WorkspaceService.method.getWorkspaceStatement,
288
+ WorkspaceService.method.getWorkspaceUpcomingInvoice,
293
289
  WorkspaceService.method.listEgressIPs,
294
290
  WorkspaceService.method.getUsage,
295
291
  WorkspaceService.method.getQueueTimes,
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.5.1";
2
+ export declare const VERSION = "0.6.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.5.1";
2
+ export const VERSION = "0.6.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toshicloud/sdk",
3
- "version": "0.5.1",
3
+ "version": "0.6.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",