@meshagent/meshagent 0.39.3 → 0.39.4
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/CHANGELOG.md +7 -0
- package/README.md +134 -21
- package/dist/browser/entrypoint.d.ts +1426 -1464
- package/dist/browser/meshagent-client.js +7 -2
- package/dist/browser/package.json +1 -0
- package/dist/esm/agent-client.js +18 -12
- package/dist/esm/agent.js +26 -18
- package/dist/esm/api_keys.js +21 -11
- package/dist/esm/client.js +13 -7
- package/dist/esm/completer.js +5 -1
- package/dist/esm/containers-client.js +85 -80
- package/dist/esm/datasets-client.js +105 -95
- package/dist/esm/developer-client.js +15 -11
- package/dist/esm/document.js +20 -11
- package/dist/esm/entrypoint.d.ts +1426 -1464
- package/dist/esm/entrypoint.js +12 -1
- package/dist/esm/event-emitter.js +5 -1
- package/dist/esm/helpers.js +23 -15
- package/dist/esm/index.js +49 -33
- package/dist/esm/lk-client.js +12 -7
- package/dist/esm/lk-protocol.js +8 -4
- package/dist/esm/memory-client.js +11 -7
- package/dist/esm/meshagent-client.js +88 -79
- package/dist/esm/messaging-client.js +37 -33
- package/dist/esm/package.json +1 -0
- package/dist/esm/participant-token.js +62 -34
- package/dist/esm/participant.js +9 -3
- package/dist/esm/protocol.js +43 -29
- package/dist/esm/queues-client.js +17 -12
- package/dist/esm/requirement.js +11 -4
- package/dist/esm/response.js +34 -22
- package/dist/esm/room-client.js +134 -129
- package/dist/esm/room-event.js +21 -9
- package/dist/esm/room-server-client.js +18 -13
- package/dist/esm/runtime.js +10 -1
- package/dist/esm/schema.js +18 -9
- package/dist/esm/secrets-client.js +35 -31
- package/dist/esm/services-client.js +13 -9
- package/dist/esm/storage-client.js +38 -32
- package/dist/esm/stream-controller.js +5 -1
- package/dist/esm/sync-client.js +42 -38
- package/dist/esm/tool-content-type.js +5 -1
- package/dist/esm/utils.js +20 -10
- package/dist/esm/version.js +4 -1
- package/dist/node/entrypoint.d.ts +1426 -1464
- package/dist/node/meshagent-client.js +7 -2
- package/dist/node/package.json +1 -0
- package/package.json +1 -1
package/dist/esm/room-event.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RoomLogEvent = exports.FileMovedEvent = exports.FileUpdatedEvent = exports.FileDeletedEvent = exports.FileCreatedEvent = exports.RoomMessageEvent = exports.RoomMessage = exports.RoomStatusEvent = exports.RoomEvent = void 0;
|
|
4
|
+
class RoomEvent {
|
|
2
5
|
}
|
|
3
|
-
|
|
6
|
+
exports.RoomEvent = RoomEvent;
|
|
7
|
+
class RoomStatusEvent extends RoomEvent {
|
|
4
8
|
constructor({ status, message }) {
|
|
5
9
|
super();
|
|
6
10
|
this.status = status;
|
|
@@ -19,7 +23,8 @@ export class RoomStatusEvent extends RoomEvent {
|
|
|
19
23
|
});
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
|
-
|
|
26
|
+
exports.RoomStatusEvent = RoomStatusEvent;
|
|
27
|
+
class RoomMessage {
|
|
23
28
|
constructor({ fromParticipantId, type, message, local = false, attachment }) {
|
|
24
29
|
this.fromParticipantId = fromParticipantId;
|
|
25
30
|
this.type = type;
|
|
@@ -28,7 +33,8 @@ export class RoomMessage {
|
|
|
28
33
|
this.attachment = attachment;
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
|
-
|
|
36
|
+
exports.RoomMessage = RoomMessage;
|
|
37
|
+
class RoomMessageEvent extends RoomEvent {
|
|
32
38
|
constructor({ message }) {
|
|
33
39
|
super();
|
|
34
40
|
this.message = message;
|
|
@@ -40,7 +46,8 @@ export class RoomMessageEvent extends RoomEvent {
|
|
|
40
46
|
return `a message was received ${JSON.stringify(this.message.message)}`;
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
|
-
|
|
49
|
+
exports.RoomMessageEvent = RoomMessageEvent;
|
|
50
|
+
class FileCreatedEvent extends RoomEvent {
|
|
44
51
|
constructor({ path }) {
|
|
45
52
|
super();
|
|
46
53
|
this.path = path;
|
|
@@ -52,7 +59,8 @@ export class FileCreatedEvent extends RoomEvent {
|
|
|
52
59
|
return `a file was created at the path ${this.path}`;
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
|
-
|
|
62
|
+
exports.FileCreatedEvent = FileCreatedEvent;
|
|
63
|
+
class FileDeletedEvent extends RoomEvent {
|
|
56
64
|
constructor({ path, participantId }) {
|
|
57
65
|
super();
|
|
58
66
|
this.path = path;
|
|
@@ -65,7 +73,8 @@ export class FileDeletedEvent extends RoomEvent {
|
|
|
65
73
|
return `a file was deleted at the path ${this.path}`;
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
|
-
|
|
76
|
+
exports.FileDeletedEvent = FileDeletedEvent;
|
|
77
|
+
class FileUpdatedEvent extends RoomEvent {
|
|
69
78
|
constructor({ path, participantId }) {
|
|
70
79
|
super();
|
|
71
80
|
this.path = path;
|
|
@@ -78,7 +87,8 @@ export class FileUpdatedEvent extends RoomEvent {
|
|
|
78
87
|
return `a file was updated at the path ${this.path}`;
|
|
79
88
|
}
|
|
80
89
|
}
|
|
81
|
-
|
|
90
|
+
exports.FileUpdatedEvent = FileUpdatedEvent;
|
|
91
|
+
class FileMovedEvent extends RoomEvent {
|
|
82
92
|
constructor({ sourcePath, destinationPath, participantId, }) {
|
|
83
93
|
super();
|
|
84
94
|
this.sourcePath = sourcePath;
|
|
@@ -92,7 +102,8 @@ export class FileMovedEvent extends RoomEvent {
|
|
|
92
102
|
return `a file was moved from ${this.sourcePath} to ${this.destinationPath}`;
|
|
93
103
|
}
|
|
94
104
|
}
|
|
95
|
-
|
|
105
|
+
exports.FileMovedEvent = FileMovedEvent;
|
|
106
|
+
class RoomLogEvent extends RoomEvent {
|
|
96
107
|
constructor({ type, data }) {
|
|
97
108
|
super();
|
|
98
109
|
this.type = type;
|
|
@@ -105,3 +116,4 @@ export class RoomLogEvent extends RoomEvent {
|
|
|
105
116
|
return JSON.stringify(this.data);
|
|
106
117
|
}
|
|
107
118
|
}
|
|
119
|
+
exports.RoomLogEvent = RoomLogEvent;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MeshDocument = exports.RoomServerException = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const document_1 = require("./document");
|
|
6
|
+
const completer_1 = require("./completer");
|
|
7
|
+
const runtime_1 = require("./runtime");
|
|
8
|
+
class RoomServerException extends Error {
|
|
6
9
|
constructor(message, code, { statusCode, retryable = false, } = {}) {
|
|
7
10
|
super(message);
|
|
8
11
|
this.name = "RoomServerException";
|
|
@@ -11,15 +14,16 @@ export class RoomServerException extends Error {
|
|
|
11
14
|
this.retryable = retryable;
|
|
12
15
|
}
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
exports.RoomServerException = RoomServerException;
|
|
18
|
+
class MeshDocument extends document_1.RuntimeDocument {
|
|
15
19
|
constructor({ schema, sendChangesToBackend }) {
|
|
16
20
|
super({
|
|
17
|
-
id:
|
|
21
|
+
id: (0, uuid_1.v4)(),
|
|
18
22
|
schema,
|
|
19
|
-
sendChanges: (base64) => applyChanges(base64),
|
|
23
|
+
sendChanges: (base64) => (0, runtime_1.applyChanges)(base64),
|
|
20
24
|
sendChangesToBackend,
|
|
21
25
|
});
|
|
22
|
-
this._synchronized = new Completer();
|
|
26
|
+
this._synchronized = new completer_1.Completer();
|
|
23
27
|
this.onSendUpdateToBackend = (base64) => {
|
|
24
28
|
const parsed = JSON.parse(base64);
|
|
25
29
|
if (this.sendChangesToBackend) {
|
|
@@ -30,13 +34,13 @@ export class MeshDocument extends RuntimeDocument {
|
|
|
30
34
|
const parsed = JSON.parse(base64);
|
|
31
35
|
this.receiveChanges(parsed.data);
|
|
32
36
|
};
|
|
33
|
-
registerDocument(this.id, null, false, this.onSendUpdateToBackend, this.onSendUpdateToClient);
|
|
37
|
+
(0, runtime_1.registerDocument)(this.id, null, false, this.onSendUpdateToBackend, this.onSendUpdateToClient);
|
|
34
38
|
}
|
|
35
39
|
getState(vector) {
|
|
36
|
-
return getState(this.id, vector ?? null);
|
|
40
|
+
return (0, runtime_1.getState)(this.id, vector ?? null);
|
|
37
41
|
}
|
|
38
42
|
getStateVector() {
|
|
39
|
-
return getStateVector(this.id);
|
|
43
|
+
return (0, runtime_1.getStateVector)(this.id);
|
|
40
44
|
}
|
|
41
45
|
get synchronized() {
|
|
42
46
|
return this._synchronized.fut;
|
|
@@ -49,6 +53,7 @@ export class MeshDocument extends RuntimeDocument {
|
|
|
49
53
|
}
|
|
50
54
|
dispose() {
|
|
51
55
|
super.dispose();
|
|
52
|
-
unregisterDocument(this.id);
|
|
56
|
+
(0, runtime_1.unregisterDocument)(this.id);
|
|
53
57
|
}
|
|
54
58
|
}
|
|
59
|
+
exports.MeshDocument = MeshDocument;
|
package/dist/esm/runtime.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unregisterDocument = exports.registerDocument = exports.getStateVector = exports.getState = exports.applyChanges = exports.applyBackendChanges = void 0;
|
|
4
|
+
var entrypoint_js_1 = require("./entrypoint.js");
|
|
5
|
+
Object.defineProperty(exports, "applyBackendChanges", { enumerable: true, get: function () { return entrypoint_js_1.applyBackendChanges; } });
|
|
6
|
+
Object.defineProperty(exports, "applyChanges", { enumerable: true, get: function () { return entrypoint_js_1.applyChanges; } });
|
|
7
|
+
Object.defineProperty(exports, "getState", { enumerable: true, get: function () { return entrypoint_js_1.getState; } });
|
|
8
|
+
Object.defineProperty(exports, "getStateVector", { enumerable: true, get: function () { return entrypoint_js_1.getStateVector; } });
|
|
9
|
+
Object.defineProperty(exports, "registerDocument", { enumerable: true, get: function () { return entrypoint_js_1.registerDocument; } });
|
|
10
|
+
Object.defineProperty(exports, "unregisterDocument", { enumerable: true, get: function () { return entrypoint_js_1.unregisterDocument; } });
|
package/dist/esm/schema.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MeshSchema = exports.ElementType = exports.ChildProperty = exports.ValueProperty = exports.ElementProperty = exports.SimpleValue = exports.MeshSchemaValidationException = void 0;
|
|
4
|
+
class MeshSchemaValidationException extends Error {
|
|
2
5
|
constructor(message) {
|
|
3
6
|
super(message);
|
|
4
7
|
this.name = "MeshSchemaValidationException";
|
|
5
8
|
}
|
|
6
9
|
}
|
|
7
|
-
|
|
10
|
+
exports.MeshSchemaValidationException = MeshSchemaValidationException;
|
|
11
|
+
var SimpleValue;
|
|
8
12
|
(function (SimpleValue) {
|
|
9
13
|
SimpleValue["number"] = "number";
|
|
10
14
|
SimpleValue["string"] = "string";
|
|
11
15
|
SimpleValue["nullValue"] = "null";
|
|
12
16
|
SimpleValue["boolean"] = "boolean";
|
|
13
|
-
})(SimpleValue || (SimpleValue = {}));
|
|
17
|
+
})(SimpleValue || (exports.SimpleValue = SimpleValue = {}));
|
|
14
18
|
(function (SimpleValue) {
|
|
15
19
|
function fromString(val) {
|
|
16
20
|
switch (val) {
|
|
@@ -27,14 +31,15 @@ export var SimpleValue;
|
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
SimpleValue.fromString = fromString;
|
|
30
|
-
})(SimpleValue || (SimpleValue = {}));
|
|
31
|
-
|
|
34
|
+
})(SimpleValue || (exports.SimpleValue = SimpleValue = {}));
|
|
35
|
+
class ElementProperty {
|
|
32
36
|
constructor({ name, description }) {
|
|
33
37
|
this.name = name;
|
|
34
38
|
this.description = description;
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
|
-
|
|
41
|
+
exports.ElementProperty = ElementProperty;
|
|
42
|
+
class ValueProperty extends ElementProperty {
|
|
38
43
|
constructor({ name, description, type, enumValues, required = false }) {
|
|
39
44
|
super({ name, description });
|
|
40
45
|
this.type = type;
|
|
@@ -69,7 +74,8 @@ export class ValueProperty extends ElementProperty {
|
|
|
69
74
|
};
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
|
-
|
|
77
|
+
exports.ValueProperty = ValueProperty;
|
|
78
|
+
class ChildProperty extends ElementProperty {
|
|
73
79
|
constructor({ name, description, childTagNames, ordered = false }) {
|
|
74
80
|
super({ name, description });
|
|
75
81
|
this._childTagNames = childTagNames;
|
|
@@ -114,7 +120,8 @@ export class ChildProperty extends ElementProperty {
|
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
|
-
|
|
123
|
+
exports.ChildProperty = ChildProperty;
|
|
124
|
+
class ElementType {
|
|
118
125
|
constructor(params) {
|
|
119
126
|
this._propertyLookup = new Map();
|
|
120
127
|
this._tagName = params.tagName;
|
|
@@ -268,7 +275,8 @@ export class ElementType {
|
|
|
268
275
|
return found;
|
|
269
276
|
}
|
|
270
277
|
}
|
|
271
|
-
|
|
278
|
+
exports.ElementType = ElementType;
|
|
279
|
+
class MeshSchema {
|
|
272
280
|
constructor(params) {
|
|
273
281
|
this.elementsByTagName = {};
|
|
274
282
|
const { rootTagName, elements } = params;
|
|
@@ -332,3 +340,4 @@ export class MeshSchema {
|
|
|
332
340
|
return this._elements;
|
|
333
341
|
}
|
|
334
342
|
}
|
|
343
|
+
exports.MeshSchema = MeshSchema;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecretsClient = void 0;
|
|
4
|
+
const response_1 = require("./response");
|
|
5
|
+
const room_server_client_1 = require("./room-server-client");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
4
7
|
function isRecord(value) {
|
|
5
8
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
9
|
}
|
|
7
|
-
|
|
10
|
+
class SecretsClient {
|
|
8
11
|
constructor({ room, oauthTokenRequestHandler, secretRequestHandler, }) {
|
|
9
12
|
this._oauthRequestHandler = this._handleClientOAuthTokenRequest.bind(this);
|
|
10
13
|
this._secretRequestHandler = this._handleClientSecretRequest.bind(this);
|
|
@@ -15,7 +18,7 @@ export class SecretsClient {
|
|
|
15
18
|
this.client.protocol.addHandler("secrets.request_secret", this._secretRequestHandler);
|
|
16
19
|
}
|
|
17
20
|
unexpectedResponse(operation) {
|
|
18
|
-
return new RoomServerException(`unexpected return type from secrets.${operation}`);
|
|
21
|
+
return new room_server_client_1.RoomServerException(`unexpected return type from secrets.${operation}`);
|
|
19
22
|
}
|
|
20
23
|
async invoke(operation, input) {
|
|
21
24
|
return await this.client.invoke({
|
|
@@ -48,7 +51,7 @@ export class SecretsClient {
|
|
|
48
51
|
};
|
|
49
52
|
}
|
|
50
53
|
parseAccessToken(operation, response) {
|
|
51
|
-
if (!(response instanceof JsonContent)) {
|
|
54
|
+
if (!(response instanceof response_1.JsonContent)) {
|
|
52
55
|
throw this.unexpectedResponse(operation);
|
|
53
56
|
}
|
|
54
57
|
const token = response.json["access_token"];
|
|
@@ -79,25 +82,25 @@ export class SecretsClient {
|
|
|
79
82
|
void messageId;
|
|
80
83
|
void type;
|
|
81
84
|
if (bytes == null) {
|
|
82
|
-
throw new RoomServerException("invalid secrets.request_oauth_token payload");
|
|
85
|
+
throw new room_server_client_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
83
86
|
}
|
|
84
87
|
if (this.oauthTokenRequestHandler == null) {
|
|
85
|
-
throw new RoomServerException("No oauth token handler registered");
|
|
88
|
+
throw new room_server_client_1.RoomServerException("No oauth token handler registered");
|
|
86
89
|
}
|
|
87
|
-
const [request] = unpackMessage(bytes);
|
|
90
|
+
const [request] = (0, utils_1.unpackMessage)(bytes);
|
|
88
91
|
const requestId = request["request_id"];
|
|
89
92
|
const challenge = request["challenge"];
|
|
90
93
|
const requestPayload = request["request"];
|
|
91
94
|
if (typeof requestId !== "string" || !isRecord(requestPayload)) {
|
|
92
|
-
throw new RoomServerException("invalid secrets.request_oauth_token payload");
|
|
95
|
+
throw new room_server_client_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
93
96
|
}
|
|
94
97
|
const oauth = requestPayload["oauth"];
|
|
95
98
|
if (!isRecord(oauth) || typeof oauth["authorization_endpoint"] !== "string" || typeof oauth["token_endpoint"] !== "string") {
|
|
96
|
-
throw new RoomServerException("invalid secrets.request_oauth_token payload");
|
|
99
|
+
throw new room_server_client_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
97
100
|
}
|
|
98
101
|
const scopes = oauth["scopes"];
|
|
99
102
|
if (scopes !== undefined && scopes !== null && (!Array.isArray(scopes) || scopes.some((scope) => typeof scope !== "string"))) {
|
|
100
|
-
throw new RoomServerException("invalid secrets.request_oauth_token payload");
|
|
103
|
+
throw new room_server_client_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
101
104
|
}
|
|
102
105
|
Promise.resolve(this.oauthTokenRequestHandler({
|
|
103
106
|
requestId,
|
|
@@ -117,16 +120,16 @@ export class SecretsClient {
|
|
|
117
120
|
void messageId;
|
|
118
121
|
void type;
|
|
119
122
|
if (bytes == null) {
|
|
120
|
-
throw new RoomServerException("invalid secrets.request_secret payload");
|
|
123
|
+
throw new room_server_client_1.RoomServerException("invalid secrets.request_secret payload");
|
|
121
124
|
}
|
|
122
125
|
if (this.secretRequestHandler == null) {
|
|
123
|
-
throw new RoomServerException("No secret handler registered");
|
|
126
|
+
throw new room_server_client_1.RoomServerException("No secret handler registered");
|
|
124
127
|
}
|
|
125
|
-
const [request] = unpackMessage(bytes);
|
|
128
|
+
const [request] = (0, utils_1.unpackMessage)(bytes);
|
|
126
129
|
const requestId = request["request_id"];
|
|
127
130
|
const requestPayload = request["request"];
|
|
128
131
|
if (typeof requestId !== "string" || !isRecord(requestPayload) || typeof requestPayload["url"] !== "string" || typeof requestPayload["type"] !== "string") {
|
|
129
|
-
throw new RoomServerException("invalid secrets.request_secret payload");
|
|
132
|
+
throw new room_server_client_1.RoomServerException("invalid secrets.request_secret payload");
|
|
130
133
|
}
|
|
131
134
|
Promise.resolve(this.secretRequestHandler({
|
|
132
135
|
requestId,
|
|
@@ -143,7 +146,7 @@ export class SecretsClient {
|
|
|
143
146
|
code,
|
|
144
147
|
error: null,
|
|
145
148
|
});
|
|
146
|
-
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
149
|
+
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
147
150
|
return;
|
|
148
151
|
}
|
|
149
152
|
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
@@ -154,33 +157,33 @@ export class SecretsClient {
|
|
|
154
157
|
code: null,
|
|
155
158
|
error,
|
|
156
159
|
});
|
|
157
|
-
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
160
|
+
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
158
161
|
return;
|
|
159
162
|
}
|
|
160
163
|
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
161
164
|
}
|
|
162
165
|
async provideSecret({ requestId, data, }) {
|
|
163
|
-
const response = await this.invoke("provide_secret", new BinaryContent({
|
|
166
|
+
const response = await this.invoke("provide_secret", new response_1.BinaryContent({
|
|
164
167
|
data,
|
|
165
168
|
headers: {
|
|
166
169
|
request_id: requestId,
|
|
167
170
|
error: null,
|
|
168
171
|
},
|
|
169
172
|
}));
|
|
170
|
-
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
173
|
+
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
171
174
|
return;
|
|
172
175
|
}
|
|
173
176
|
throw this.unexpectedResponse("provide_secret");
|
|
174
177
|
}
|
|
175
178
|
async rejectSecret({ requestId, error, }) {
|
|
176
|
-
const response = await this.invoke("provide_secret", new BinaryContent({
|
|
179
|
+
const response = await this.invoke("provide_secret", new response_1.BinaryContent({
|
|
177
180
|
data: new Uint8Array(0),
|
|
178
181
|
headers: {
|
|
179
182
|
request_id: requestId,
|
|
180
183
|
error,
|
|
181
184
|
},
|
|
182
185
|
}));
|
|
183
|
-
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
186
|
+
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
184
187
|
return;
|
|
185
188
|
}
|
|
186
189
|
throw this.unexpectedResponse("provide_secret");
|
|
@@ -207,7 +210,7 @@ export class SecretsClient {
|
|
|
207
210
|
}
|
|
208
211
|
async listSecrets() {
|
|
209
212
|
const response = await this.invoke("list_secrets", {});
|
|
210
|
-
if (!(response instanceof JsonContent)) {
|
|
213
|
+
if (!(response instanceof response_1.JsonContent)) {
|
|
211
214
|
throw this.unexpectedResponse("list_secrets");
|
|
212
215
|
}
|
|
213
216
|
const secrets = response.json["secrets"];
|
|
@@ -222,7 +225,7 @@ export class SecretsClient {
|
|
|
222
225
|
delegated_to: delegatedTo ?? null,
|
|
223
226
|
for_identity: forIdentity ?? null,
|
|
224
227
|
});
|
|
225
|
-
if (!(response instanceof JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
228
|
+
if (!(response instanceof response_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
226
229
|
throw this.unexpectedResponse("exists");
|
|
227
230
|
}
|
|
228
231
|
return response.json["exists"];
|
|
@@ -232,7 +235,7 @@ export class SecretsClient {
|
|
|
232
235
|
id: secretId,
|
|
233
236
|
delegated_to: delegatedTo ?? null,
|
|
234
237
|
});
|
|
235
|
-
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
238
|
+
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
236
239
|
return;
|
|
237
240
|
}
|
|
238
241
|
throw this.unexpectedResponse("delete_secret");
|
|
@@ -243,7 +246,7 @@ export class SecretsClient {
|
|
|
243
246
|
type,
|
|
244
247
|
delegated_to: delegatedTo ?? null,
|
|
245
248
|
});
|
|
246
|
-
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
249
|
+
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
247
250
|
return;
|
|
248
251
|
}
|
|
249
252
|
throw this.unexpectedResponse("delete_requested_secret");
|
|
@@ -256,13 +259,13 @@ export class SecretsClient {
|
|
|
256
259
|
timeout,
|
|
257
260
|
delegate_to: delegateTo ?? null,
|
|
258
261
|
});
|
|
259
|
-
if (response instanceof FileContent) {
|
|
262
|
+
if (response instanceof response_1.FileContent) {
|
|
260
263
|
return response.data;
|
|
261
264
|
}
|
|
262
265
|
throw this.unexpectedResponse("request_secret");
|
|
263
266
|
}
|
|
264
267
|
async setSecret({ secretId, type, mimeType, name, delegatedTo, forIdentity, data, }) {
|
|
265
|
-
const response = await this.invoke("set_secret", new BinaryContent({
|
|
268
|
+
const response = await this.invoke("set_secret", new response_1.BinaryContent({
|
|
266
269
|
data,
|
|
267
270
|
headers: {
|
|
268
271
|
secret_id: secretId ?? null,
|
|
@@ -273,7 +276,7 @@ export class SecretsClient {
|
|
|
273
276
|
has_data: true,
|
|
274
277
|
},
|
|
275
278
|
}));
|
|
276
|
-
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
279
|
+
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
277
280
|
return;
|
|
278
281
|
}
|
|
279
282
|
throw this.unexpectedResponse("set_secret");
|
|
@@ -285,12 +288,13 @@ export class SecretsClient {
|
|
|
285
288
|
name: name ?? null,
|
|
286
289
|
delegated_to: delegatedTo ?? null,
|
|
287
290
|
});
|
|
288
|
-
if (response instanceof EmptyContent) {
|
|
291
|
+
if (response instanceof response_1.EmptyContent) {
|
|
289
292
|
return null;
|
|
290
293
|
}
|
|
291
|
-
if (response instanceof FileContent) {
|
|
294
|
+
if (response instanceof response_1.FileContent) {
|
|
292
295
|
return response;
|
|
293
296
|
}
|
|
294
297
|
throw this.unexpectedResponse("get_secret");
|
|
295
298
|
}
|
|
296
299
|
}
|
|
300
|
+
exports.SecretsClient = SecretsClient;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServicesClient = void 0;
|
|
4
|
+
const response_1 = require("./response");
|
|
5
|
+
const room_server_client_1 = require("./room-server-client");
|
|
3
6
|
function isRecord(value) {
|
|
4
7
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
8
|
}
|
|
@@ -11,7 +14,7 @@ function toOptionalInteger(value) {
|
|
|
11
14
|
}
|
|
12
15
|
function parseServiceRuntimeState(value) {
|
|
13
16
|
if (!isRecord(value) || typeof value["service_id"] !== "string") {
|
|
14
|
-
throw new RoomServerException("unexpected return type from services.list");
|
|
17
|
+
throw new room_server_client_1.RoomServerException("unexpected return type from services.list");
|
|
15
18
|
}
|
|
16
19
|
const state = value["state"];
|
|
17
20
|
const containerId = value["container_id"];
|
|
@@ -30,21 +33,21 @@ function parseServiceSpecJson(value) {
|
|
|
30
33
|
if (typeof value === "string") {
|
|
31
34
|
const parsed = JSON.parse(value);
|
|
32
35
|
if (!isRecord(parsed)) {
|
|
33
|
-
throw new RoomServerException("unexpected return type from services.list");
|
|
36
|
+
throw new room_server_client_1.RoomServerException("unexpected return type from services.list");
|
|
34
37
|
}
|
|
35
38
|
return parsed;
|
|
36
39
|
}
|
|
37
40
|
if (!isRecord(value)) {
|
|
38
|
-
throw new RoomServerException("unexpected return type from services.list");
|
|
41
|
+
throw new room_server_client_1.RoomServerException("unexpected return type from services.list");
|
|
39
42
|
}
|
|
40
43
|
return value;
|
|
41
44
|
}
|
|
42
|
-
|
|
45
|
+
class ServicesClient {
|
|
43
46
|
constructor({ room }) {
|
|
44
47
|
this.room = room;
|
|
45
48
|
}
|
|
46
49
|
unexpectedResponse(operation) {
|
|
47
|
-
return new RoomServerException(`unexpected return type from services.${operation}`);
|
|
50
|
+
return new room_server_client_1.RoomServerException(`unexpected return type from services.${operation}`);
|
|
48
51
|
}
|
|
49
52
|
async list() {
|
|
50
53
|
return (await this.listWithState()).services;
|
|
@@ -55,7 +58,7 @@ export class ServicesClient {
|
|
|
55
58
|
tool: "list",
|
|
56
59
|
input: {},
|
|
57
60
|
});
|
|
58
|
-
if (!(response instanceof JsonContent)) {
|
|
61
|
+
if (!(response instanceof response_1.JsonContent)) {
|
|
59
62
|
throw this.unexpectedResponse("list");
|
|
60
63
|
}
|
|
61
64
|
const servicesRaw = response.json["services_json"];
|
|
@@ -81,9 +84,10 @@ export class ServicesClient {
|
|
|
81
84
|
service_id: params.serviceId,
|
|
82
85
|
},
|
|
83
86
|
});
|
|
84
|
-
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
87
|
+
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
85
88
|
return;
|
|
86
89
|
}
|
|
87
90
|
throw this.unexpectedResponse("restart");
|
|
88
91
|
}
|
|
89
92
|
}
|
|
93
|
+
exports.ServicesClient = ServicesClient;
|