@meshagent/meshagent 0.24.6 → 0.25.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/CHANGELOG.md +4 -2
- package/dist/browser/database-client.d.ts +10 -0
- package/dist/browser/database-client.js +14 -0
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.js +1 -0
- package/dist/browser/room-client.d.ts +2 -0
- package/dist/browser/room-client.js +2 -0
- package/dist/browser/secrets-client.d.ts +36 -0
- package/dist/browser/secrets-client.js +81 -0
- package/dist/esm/database-client.d.ts +10 -0
- package/dist/esm/database-client.js +14 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/room-client.d.ts +2 -0
- package/dist/esm/room-client.js +2 -0
- package/dist/esm/secrets-client.d.ts +36 -0
- package/dist/esm/secrets-client.js +77 -0
- package/dist/node/database-client.d.ts +10 -0
- package/dist/node/database-client.js +14 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/room-client.d.ts +2 -0
- package/dist/node/room-client.js +2 -0
- package/dist/node/secrets-client.d.ts +36 -0
- package/dist/node/secrets-client.js +81 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
## [0.
|
|
2
|
-
-
|
|
1
|
+
## [0.25.0]
|
|
2
|
+
- Added SQL query support with TableRef and typed params in the database client.
|
|
3
|
+
- Added a SecretsClient on RoomClient (set/get/list/delete, including `for_identity` support).
|
|
4
|
+
- Exported the secrets client from the package entrypoint.
|
|
3
5
|
|
|
4
6
|
## [0.24.5]
|
|
5
7
|
- Stability
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { RoomClient } from "./room-client";
|
|
2
2
|
import { DataType } from "./data-types";
|
|
3
3
|
export type CreateMode = "create" | "overwrite" | "create_if_not_exists";
|
|
4
|
+
export interface TableRef {
|
|
5
|
+
name: string;
|
|
6
|
+
namespace?: string[];
|
|
7
|
+
alias?: string;
|
|
8
|
+
}
|
|
4
9
|
export declare class DatabaseClient {
|
|
5
10
|
private room;
|
|
6
11
|
constructor({ room }: {
|
|
@@ -50,6 +55,11 @@ export declare class DatabaseClient {
|
|
|
50
55
|
on: string;
|
|
51
56
|
records: any;
|
|
52
57
|
}): Promise<void>;
|
|
58
|
+
sql({ query, tables, params }: {
|
|
59
|
+
query: string;
|
|
60
|
+
tables: TableRef[];
|
|
61
|
+
params?: Record<string, any>;
|
|
62
|
+
}): Promise<Array<Record<string, any>>>;
|
|
53
63
|
search({ table, text, vector, where, limit, select }: {
|
|
54
64
|
table: string;
|
|
55
65
|
text?: string;
|
|
@@ -62,6 +62,20 @@ class DatabaseClient {
|
|
|
62
62
|
async merge({ table, on, records }) {
|
|
63
63
|
await this.room.sendRequest("database.merge", { table, on, records });
|
|
64
64
|
}
|
|
65
|
+
async sql({ query, tables, params }) {
|
|
66
|
+
const payload = {
|
|
67
|
+
query,
|
|
68
|
+
tables,
|
|
69
|
+
params,
|
|
70
|
+
};
|
|
71
|
+
const response = await this.room.sendRequest("database.sql", payload);
|
|
72
|
+
if (response instanceof response_1.JsonResponse) {
|
|
73
|
+
if (response?.json?.results) {
|
|
74
|
+
return response.json.results;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
65
79
|
async search({ table, text, vector, where, limit, select }) {
|
|
66
80
|
let whereClause = where;
|
|
67
81
|
if (where && typeof where === "object" && !Array.isArray(where)) {
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from './room-server-client';
|
|
|
21
21
|
export * from './runtime';
|
|
22
22
|
export * from './schema';
|
|
23
23
|
export * from './storage-client';
|
|
24
|
+
export * from './secrets-client';
|
|
24
25
|
export * from './stream-controller';
|
|
25
26
|
export * from './sync-client';
|
|
26
27
|
export * from './api_keys';
|
package/dist/browser/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __exportStar(require("./room-server-client"), exports);
|
|
|
37
37
|
__exportStar(require("./runtime"), exports);
|
|
38
38
|
__exportStar(require("./schema"), exports);
|
|
39
39
|
__exportStar(require("./storage-client"), exports);
|
|
40
|
+
__exportStar(require("./secrets-client"), exports);
|
|
40
41
|
__exportStar(require("./stream-controller"), exports);
|
|
41
42
|
__exportStar(require("./sync-client"), exports);
|
|
42
43
|
__exportStar(require("./api_keys"), exports);
|
|
@@ -7,6 +7,7 @@ import { MessagingClient } from "./messaging-client";
|
|
|
7
7
|
import { QueuesClient } from "./queues-client";
|
|
8
8
|
import { DatabaseClient } from "./database-client";
|
|
9
9
|
import { AgentsClient } from "./agent-client";
|
|
10
|
+
import { SecretsClient } from "./secrets-client";
|
|
10
11
|
import { RoomEvent } from "./room-event";
|
|
11
12
|
import { Response } from "./response";
|
|
12
13
|
interface RequestHeader {
|
|
@@ -21,6 +22,7 @@ export declare class RoomClient {
|
|
|
21
22
|
readonly queues: QueuesClient;
|
|
22
23
|
readonly database: DatabaseClient;
|
|
23
24
|
readonly agents: AgentsClient;
|
|
25
|
+
readonly secrets: SecretsClient;
|
|
24
26
|
private _pendingRequests;
|
|
25
27
|
private _ready;
|
|
26
28
|
private _localParticipant;
|
|
@@ -12,6 +12,7 @@ const messaging_client_1 = require("./messaging-client");
|
|
|
12
12
|
const queues_client_1 = require("./queues-client");
|
|
13
13
|
const database_client_1 = require("./database-client");
|
|
14
14
|
const agent_client_1 = require("./agent-client");
|
|
15
|
+
const secrets_client_1 = require("./secrets-client");
|
|
15
16
|
const response_1 = require("./response");
|
|
16
17
|
class RoomClient {
|
|
17
18
|
constructor({ protocol }) {
|
|
@@ -30,6 +31,7 @@ class RoomClient {
|
|
|
30
31
|
this.queues = new queues_client_1.QueuesClient({ room: this });
|
|
31
32
|
this.database = new database_client_1.DatabaseClient({ room: this });
|
|
32
33
|
this.agents = new agent_client_1.AgentsClient({ room: this });
|
|
34
|
+
this.secrets = new secrets_client_1.SecretsClient({ room: this });
|
|
33
35
|
}
|
|
34
36
|
get localParticipant() {
|
|
35
37
|
return this._localParticipant;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RoomClient } from "./room-client";
|
|
2
|
+
import { FileResponse } from "./response";
|
|
3
|
+
export interface SecretInfo {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
delegatedTo?: string | null;
|
|
8
|
+
}
|
|
9
|
+
export declare class SecretsClient {
|
|
10
|
+
private client;
|
|
11
|
+
constructor({ room }: {
|
|
12
|
+
room: RoomClient;
|
|
13
|
+
});
|
|
14
|
+
setSecret({ secretId, data, mimeType, name, delegatedTo, forIdentity, }: {
|
|
15
|
+
secretId: string;
|
|
16
|
+
data: Uint8Array;
|
|
17
|
+
mimeType?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
delegatedTo?: string;
|
|
20
|
+
forIdentity?: string;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
getSecret({ secretId, delegatedTo, }: {
|
|
23
|
+
secretId: string;
|
|
24
|
+
delegatedTo?: string;
|
|
25
|
+
}): Promise<FileResponse | null>;
|
|
26
|
+
listSecrets(): Promise<SecretInfo[]>;
|
|
27
|
+
deleteSecret({ secretId, delegatedTo, }: {
|
|
28
|
+
secretId: string;
|
|
29
|
+
delegatedTo?: string;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
deleteRequestedSecret({ url, type, delegatedTo, }: {
|
|
32
|
+
url: string;
|
|
33
|
+
type: string;
|
|
34
|
+
delegatedTo?: string;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecretsClient = void 0;
|
|
4
|
+
const response_1 = require("./response");
|
|
5
|
+
class SecretsClient {
|
|
6
|
+
constructor({ room }) {
|
|
7
|
+
this.client = room;
|
|
8
|
+
}
|
|
9
|
+
async setSecret({ secretId, data, mimeType, name, delegatedTo, forIdentity, }) {
|
|
10
|
+
const req = {
|
|
11
|
+
secret_id: secretId,
|
|
12
|
+
};
|
|
13
|
+
if (mimeType)
|
|
14
|
+
req.type = mimeType;
|
|
15
|
+
if (name)
|
|
16
|
+
req.name = name;
|
|
17
|
+
if (delegatedTo)
|
|
18
|
+
req.delegated_to = delegatedTo;
|
|
19
|
+
if (forIdentity)
|
|
20
|
+
req.for_identity = forIdentity;
|
|
21
|
+
const response = await this.client.sendRequest("secrets.set_secret", req, data);
|
|
22
|
+
if (response instanceof response_1.EmptyResponse || response instanceof response_1.JsonResponse) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
throw new Error("Invalid response received, expected EmptyResponse or JsonResponse");
|
|
26
|
+
}
|
|
27
|
+
async getSecret({ secretId, delegatedTo, }) {
|
|
28
|
+
const req = {
|
|
29
|
+
secret_id: secretId,
|
|
30
|
+
};
|
|
31
|
+
if (delegatedTo)
|
|
32
|
+
req.delegated_to = delegatedTo;
|
|
33
|
+
const response = await this.client.sendRequest("secrets.get_secret", req);
|
|
34
|
+
if (response instanceof response_1.EmptyResponse) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if (response instanceof response_1.FileResponse) {
|
|
38
|
+
return response;
|
|
39
|
+
}
|
|
40
|
+
throw new Error("Invalid response received, expected FileResponse or EmptyResponse");
|
|
41
|
+
}
|
|
42
|
+
async listSecrets() {
|
|
43
|
+
const response = await this.client.sendRequest("secrets.list_secrets", {});
|
|
44
|
+
if (!(response instanceof response_1.JsonResponse)) {
|
|
45
|
+
throw new Error("Invalid response received, expected JsonResponse");
|
|
46
|
+
}
|
|
47
|
+
const secrets = Array.isArray(response.json?.secrets) ? response.json.secrets : [];
|
|
48
|
+
return secrets.map((item) => ({
|
|
49
|
+
id: item.id,
|
|
50
|
+
name: item.name,
|
|
51
|
+
type: item.type,
|
|
52
|
+
delegatedTo: item.delegated_to,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
async deleteSecret({ secretId, delegatedTo, }) {
|
|
56
|
+
const req = {
|
|
57
|
+
id: secretId,
|
|
58
|
+
};
|
|
59
|
+
if (delegatedTo)
|
|
60
|
+
req.delegated_to = delegatedTo;
|
|
61
|
+
const response = await this.client.sendRequest("secrets.delete_secret", req);
|
|
62
|
+
if (response instanceof response_1.EmptyResponse || response instanceof response_1.JsonResponse) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
throw new Error("Invalid response received, expected EmptyResponse or JsonResponse");
|
|
66
|
+
}
|
|
67
|
+
async deleteRequestedSecret({ url, type, delegatedTo, }) {
|
|
68
|
+
const req = {
|
|
69
|
+
url,
|
|
70
|
+
type,
|
|
71
|
+
};
|
|
72
|
+
if (delegatedTo)
|
|
73
|
+
req.delegated_to = delegatedTo;
|
|
74
|
+
const response = await this.client.sendRequest("secrets.delete_requested_secret", req);
|
|
75
|
+
if (response instanceof response_1.EmptyResponse || response instanceof response_1.JsonResponse) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
throw new Error("Invalid response received, expected EmptyResponse or JsonResponse");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.SecretsClient = SecretsClient;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { RoomClient } from "./room-client";
|
|
2
2
|
import { DataType } from "./data-types";
|
|
3
3
|
export type CreateMode = "create" | "overwrite" | "create_if_not_exists";
|
|
4
|
+
export interface TableRef {
|
|
5
|
+
name: string;
|
|
6
|
+
namespace?: string[];
|
|
7
|
+
alias?: string;
|
|
8
|
+
}
|
|
4
9
|
export declare class DatabaseClient {
|
|
5
10
|
private room;
|
|
6
11
|
constructor({ room }: {
|
|
@@ -50,6 +55,11 @@ export declare class DatabaseClient {
|
|
|
50
55
|
on: string;
|
|
51
56
|
records: any;
|
|
52
57
|
}): Promise<void>;
|
|
58
|
+
sql({ query, tables, params }: {
|
|
59
|
+
query: string;
|
|
60
|
+
tables: TableRef[];
|
|
61
|
+
params?: Record<string, any>;
|
|
62
|
+
}): Promise<Array<Record<string, any>>>;
|
|
53
63
|
search({ table, text, vector, where, limit, select }: {
|
|
54
64
|
table: string;
|
|
55
65
|
text?: string;
|
|
@@ -59,6 +59,20 @@ export class DatabaseClient {
|
|
|
59
59
|
async merge({ table, on, records }) {
|
|
60
60
|
await this.room.sendRequest("database.merge", { table, on, records });
|
|
61
61
|
}
|
|
62
|
+
async sql({ query, tables, params }) {
|
|
63
|
+
const payload = {
|
|
64
|
+
query,
|
|
65
|
+
tables,
|
|
66
|
+
params,
|
|
67
|
+
};
|
|
68
|
+
const response = await this.room.sendRequest("database.sql", payload);
|
|
69
|
+
if (response instanceof JsonResponse) {
|
|
70
|
+
if (response?.json?.results) {
|
|
71
|
+
return response.json.results;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
62
76
|
async search({ table, text, vector, where, limit, select }) {
|
|
63
77
|
let whereClause = where;
|
|
64
78
|
if (where && typeof where === "object" && !Array.isArray(where)) {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from './room-server-client';
|
|
|
21
21
|
export * from './runtime';
|
|
22
22
|
export * from './schema';
|
|
23
23
|
export * from './storage-client';
|
|
24
|
+
export * from './secrets-client';
|
|
24
25
|
export * from './stream-controller';
|
|
25
26
|
export * from './sync-client';
|
|
26
27
|
export * from './api_keys';
|
package/dist/esm/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export * from './room-server-client';
|
|
|
21
21
|
export * from './runtime';
|
|
22
22
|
export * from './schema';
|
|
23
23
|
export * from './storage-client';
|
|
24
|
+
export * from './secrets-client';
|
|
24
25
|
export * from './stream-controller';
|
|
25
26
|
export * from './sync-client';
|
|
26
27
|
export * from './api_keys';
|
|
@@ -7,6 +7,7 @@ import { MessagingClient } from "./messaging-client";
|
|
|
7
7
|
import { QueuesClient } from "./queues-client";
|
|
8
8
|
import { DatabaseClient } from "./database-client";
|
|
9
9
|
import { AgentsClient } from "./agent-client";
|
|
10
|
+
import { SecretsClient } from "./secrets-client";
|
|
10
11
|
import { RoomEvent } from "./room-event";
|
|
11
12
|
import { Response } from "./response";
|
|
12
13
|
interface RequestHeader {
|
|
@@ -21,6 +22,7 @@ export declare class RoomClient {
|
|
|
21
22
|
readonly queues: QueuesClient;
|
|
22
23
|
readonly database: DatabaseClient;
|
|
23
24
|
readonly agents: AgentsClient;
|
|
25
|
+
readonly secrets: SecretsClient;
|
|
24
26
|
private _pendingRequests;
|
|
25
27
|
private _ready;
|
|
26
28
|
private _localParticipant;
|
package/dist/esm/room-client.js
CHANGED
|
@@ -9,6 +9,7 @@ import { MessagingClient } from "./messaging-client";
|
|
|
9
9
|
import { QueuesClient } from "./queues-client";
|
|
10
10
|
import { DatabaseClient } from "./database-client";
|
|
11
11
|
import { AgentsClient } from "./agent-client";
|
|
12
|
+
import { SecretsClient } from "./secrets-client";
|
|
12
13
|
import { ErrorResponse, unpackResponse } from "./response";
|
|
13
14
|
export class RoomClient {
|
|
14
15
|
constructor({ protocol }) {
|
|
@@ -27,6 +28,7 @@ export class RoomClient {
|
|
|
27
28
|
this.queues = new QueuesClient({ room: this });
|
|
28
29
|
this.database = new DatabaseClient({ room: this });
|
|
29
30
|
this.agents = new AgentsClient({ room: this });
|
|
31
|
+
this.secrets = new SecretsClient({ room: this });
|
|
30
32
|
}
|
|
31
33
|
get localParticipant() {
|
|
32
34
|
return this._localParticipant;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RoomClient } from "./room-client";
|
|
2
|
+
import { FileResponse } from "./response";
|
|
3
|
+
export interface SecretInfo {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
delegatedTo?: string | null;
|
|
8
|
+
}
|
|
9
|
+
export declare class SecretsClient {
|
|
10
|
+
private client;
|
|
11
|
+
constructor({ room }: {
|
|
12
|
+
room: RoomClient;
|
|
13
|
+
});
|
|
14
|
+
setSecret({ secretId, data, mimeType, name, delegatedTo, forIdentity, }: {
|
|
15
|
+
secretId: string;
|
|
16
|
+
data: Uint8Array;
|
|
17
|
+
mimeType?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
delegatedTo?: string;
|
|
20
|
+
forIdentity?: string;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
getSecret({ secretId, delegatedTo, }: {
|
|
23
|
+
secretId: string;
|
|
24
|
+
delegatedTo?: string;
|
|
25
|
+
}): Promise<FileResponse | null>;
|
|
26
|
+
listSecrets(): Promise<SecretInfo[]>;
|
|
27
|
+
deleteSecret({ secretId, delegatedTo, }: {
|
|
28
|
+
secretId: string;
|
|
29
|
+
delegatedTo?: string;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
deleteRequestedSecret({ url, type, delegatedTo, }: {
|
|
32
|
+
url: string;
|
|
33
|
+
type: string;
|
|
34
|
+
delegatedTo?: string;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { EmptyResponse, FileResponse, JsonResponse } from "./response";
|
|
2
|
+
export class SecretsClient {
|
|
3
|
+
constructor({ room }) {
|
|
4
|
+
this.client = room;
|
|
5
|
+
}
|
|
6
|
+
async setSecret({ secretId, data, mimeType, name, delegatedTo, forIdentity, }) {
|
|
7
|
+
const req = {
|
|
8
|
+
secret_id: secretId,
|
|
9
|
+
};
|
|
10
|
+
if (mimeType)
|
|
11
|
+
req.type = mimeType;
|
|
12
|
+
if (name)
|
|
13
|
+
req.name = name;
|
|
14
|
+
if (delegatedTo)
|
|
15
|
+
req.delegated_to = delegatedTo;
|
|
16
|
+
if (forIdentity)
|
|
17
|
+
req.for_identity = forIdentity;
|
|
18
|
+
const response = await this.client.sendRequest("secrets.set_secret", req, data);
|
|
19
|
+
if (response instanceof EmptyResponse || response instanceof JsonResponse) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
throw new Error("Invalid response received, expected EmptyResponse or JsonResponse");
|
|
23
|
+
}
|
|
24
|
+
async getSecret({ secretId, delegatedTo, }) {
|
|
25
|
+
const req = {
|
|
26
|
+
secret_id: secretId,
|
|
27
|
+
};
|
|
28
|
+
if (delegatedTo)
|
|
29
|
+
req.delegated_to = delegatedTo;
|
|
30
|
+
const response = await this.client.sendRequest("secrets.get_secret", req);
|
|
31
|
+
if (response instanceof EmptyResponse) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (response instanceof FileResponse) {
|
|
35
|
+
return response;
|
|
36
|
+
}
|
|
37
|
+
throw new Error("Invalid response received, expected FileResponse or EmptyResponse");
|
|
38
|
+
}
|
|
39
|
+
async listSecrets() {
|
|
40
|
+
const response = await this.client.sendRequest("secrets.list_secrets", {});
|
|
41
|
+
if (!(response instanceof JsonResponse)) {
|
|
42
|
+
throw new Error("Invalid response received, expected JsonResponse");
|
|
43
|
+
}
|
|
44
|
+
const secrets = Array.isArray(response.json?.secrets) ? response.json.secrets : [];
|
|
45
|
+
return secrets.map((item) => ({
|
|
46
|
+
id: item.id,
|
|
47
|
+
name: item.name,
|
|
48
|
+
type: item.type,
|
|
49
|
+
delegatedTo: item.delegated_to,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
async deleteSecret({ secretId, delegatedTo, }) {
|
|
53
|
+
const req = {
|
|
54
|
+
id: secretId,
|
|
55
|
+
};
|
|
56
|
+
if (delegatedTo)
|
|
57
|
+
req.delegated_to = delegatedTo;
|
|
58
|
+
const response = await this.client.sendRequest("secrets.delete_secret", req);
|
|
59
|
+
if (response instanceof EmptyResponse || response instanceof JsonResponse) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
throw new Error("Invalid response received, expected EmptyResponse or JsonResponse");
|
|
63
|
+
}
|
|
64
|
+
async deleteRequestedSecret({ url, type, delegatedTo, }) {
|
|
65
|
+
const req = {
|
|
66
|
+
url,
|
|
67
|
+
type,
|
|
68
|
+
};
|
|
69
|
+
if (delegatedTo)
|
|
70
|
+
req.delegated_to = delegatedTo;
|
|
71
|
+
const response = await this.client.sendRequest("secrets.delete_requested_secret", req);
|
|
72
|
+
if (response instanceof EmptyResponse || response instanceof JsonResponse) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
throw new Error("Invalid response received, expected EmptyResponse or JsonResponse");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { RoomClient } from "./room-client";
|
|
2
2
|
import { DataType } from "./data-types";
|
|
3
3
|
export type CreateMode = "create" | "overwrite" | "create_if_not_exists";
|
|
4
|
+
export interface TableRef {
|
|
5
|
+
name: string;
|
|
6
|
+
namespace?: string[];
|
|
7
|
+
alias?: string;
|
|
8
|
+
}
|
|
4
9
|
export declare class DatabaseClient {
|
|
5
10
|
private room;
|
|
6
11
|
constructor({ room }: {
|
|
@@ -50,6 +55,11 @@ export declare class DatabaseClient {
|
|
|
50
55
|
on: string;
|
|
51
56
|
records: any;
|
|
52
57
|
}): Promise<void>;
|
|
58
|
+
sql({ query, tables, params }: {
|
|
59
|
+
query: string;
|
|
60
|
+
tables: TableRef[];
|
|
61
|
+
params?: Record<string, any>;
|
|
62
|
+
}): Promise<Array<Record<string, any>>>;
|
|
53
63
|
search({ table, text, vector, where, limit, select }: {
|
|
54
64
|
table: string;
|
|
55
65
|
text?: string;
|
|
@@ -62,6 +62,20 @@ class DatabaseClient {
|
|
|
62
62
|
async merge({ table, on, records }) {
|
|
63
63
|
await this.room.sendRequest("database.merge", { table, on, records });
|
|
64
64
|
}
|
|
65
|
+
async sql({ query, tables, params }) {
|
|
66
|
+
const payload = {
|
|
67
|
+
query,
|
|
68
|
+
tables,
|
|
69
|
+
params,
|
|
70
|
+
};
|
|
71
|
+
const response = await this.room.sendRequest("database.sql", payload);
|
|
72
|
+
if (response instanceof response_1.JsonResponse) {
|
|
73
|
+
if (response?.json?.results) {
|
|
74
|
+
return response.json.results;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
65
79
|
async search({ table, text, vector, where, limit, select }) {
|
|
66
80
|
let whereClause = where;
|
|
67
81
|
if (where && typeof where === "object" && !Array.isArray(where)) {
|
package/dist/node/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from './room-server-client';
|
|
|
21
21
|
export * from './runtime';
|
|
22
22
|
export * from './schema';
|
|
23
23
|
export * from './storage-client';
|
|
24
|
+
export * from './secrets-client';
|
|
24
25
|
export * from './stream-controller';
|
|
25
26
|
export * from './sync-client';
|
|
26
27
|
export * from './api_keys';
|
package/dist/node/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __exportStar(require("./room-server-client"), exports);
|
|
|
37
37
|
__exportStar(require("./runtime"), exports);
|
|
38
38
|
__exportStar(require("./schema"), exports);
|
|
39
39
|
__exportStar(require("./storage-client"), exports);
|
|
40
|
+
__exportStar(require("./secrets-client"), exports);
|
|
40
41
|
__exportStar(require("./stream-controller"), exports);
|
|
41
42
|
__exportStar(require("./sync-client"), exports);
|
|
42
43
|
__exportStar(require("./api_keys"), exports);
|
|
@@ -7,6 +7,7 @@ import { MessagingClient } from "./messaging-client";
|
|
|
7
7
|
import { QueuesClient } from "./queues-client";
|
|
8
8
|
import { DatabaseClient } from "./database-client";
|
|
9
9
|
import { AgentsClient } from "./agent-client";
|
|
10
|
+
import { SecretsClient } from "./secrets-client";
|
|
10
11
|
import { RoomEvent } from "./room-event";
|
|
11
12
|
import { Response } from "./response";
|
|
12
13
|
interface RequestHeader {
|
|
@@ -21,6 +22,7 @@ export declare class RoomClient {
|
|
|
21
22
|
readonly queues: QueuesClient;
|
|
22
23
|
readonly database: DatabaseClient;
|
|
23
24
|
readonly agents: AgentsClient;
|
|
25
|
+
readonly secrets: SecretsClient;
|
|
24
26
|
private _pendingRequests;
|
|
25
27
|
private _ready;
|
|
26
28
|
private _localParticipant;
|
package/dist/node/room-client.js
CHANGED
|
@@ -12,6 +12,7 @@ const messaging_client_1 = require("./messaging-client");
|
|
|
12
12
|
const queues_client_1 = require("./queues-client");
|
|
13
13
|
const database_client_1 = require("./database-client");
|
|
14
14
|
const agent_client_1 = require("./agent-client");
|
|
15
|
+
const secrets_client_1 = require("./secrets-client");
|
|
15
16
|
const response_1 = require("./response");
|
|
16
17
|
class RoomClient {
|
|
17
18
|
constructor({ protocol }) {
|
|
@@ -30,6 +31,7 @@ class RoomClient {
|
|
|
30
31
|
this.queues = new queues_client_1.QueuesClient({ room: this });
|
|
31
32
|
this.database = new database_client_1.DatabaseClient({ room: this });
|
|
32
33
|
this.agents = new agent_client_1.AgentsClient({ room: this });
|
|
34
|
+
this.secrets = new secrets_client_1.SecretsClient({ room: this });
|
|
33
35
|
}
|
|
34
36
|
get localParticipant() {
|
|
35
37
|
return this._localParticipant;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RoomClient } from "./room-client";
|
|
2
|
+
import { FileResponse } from "./response";
|
|
3
|
+
export interface SecretInfo {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
delegatedTo?: string | null;
|
|
8
|
+
}
|
|
9
|
+
export declare class SecretsClient {
|
|
10
|
+
private client;
|
|
11
|
+
constructor({ room }: {
|
|
12
|
+
room: RoomClient;
|
|
13
|
+
});
|
|
14
|
+
setSecret({ secretId, data, mimeType, name, delegatedTo, forIdentity, }: {
|
|
15
|
+
secretId: string;
|
|
16
|
+
data: Uint8Array;
|
|
17
|
+
mimeType?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
delegatedTo?: string;
|
|
20
|
+
forIdentity?: string;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
getSecret({ secretId, delegatedTo, }: {
|
|
23
|
+
secretId: string;
|
|
24
|
+
delegatedTo?: string;
|
|
25
|
+
}): Promise<FileResponse | null>;
|
|
26
|
+
listSecrets(): Promise<SecretInfo[]>;
|
|
27
|
+
deleteSecret({ secretId, delegatedTo, }: {
|
|
28
|
+
secretId: string;
|
|
29
|
+
delegatedTo?: string;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
deleteRequestedSecret({ url, type, delegatedTo, }: {
|
|
32
|
+
url: string;
|
|
33
|
+
type: string;
|
|
34
|
+
delegatedTo?: string;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecretsClient = void 0;
|
|
4
|
+
const response_1 = require("./response");
|
|
5
|
+
class SecretsClient {
|
|
6
|
+
constructor({ room }) {
|
|
7
|
+
this.client = room;
|
|
8
|
+
}
|
|
9
|
+
async setSecret({ secretId, data, mimeType, name, delegatedTo, forIdentity, }) {
|
|
10
|
+
const req = {
|
|
11
|
+
secret_id: secretId,
|
|
12
|
+
};
|
|
13
|
+
if (mimeType)
|
|
14
|
+
req.type = mimeType;
|
|
15
|
+
if (name)
|
|
16
|
+
req.name = name;
|
|
17
|
+
if (delegatedTo)
|
|
18
|
+
req.delegated_to = delegatedTo;
|
|
19
|
+
if (forIdentity)
|
|
20
|
+
req.for_identity = forIdentity;
|
|
21
|
+
const response = await this.client.sendRequest("secrets.set_secret", req, data);
|
|
22
|
+
if (response instanceof response_1.EmptyResponse || response instanceof response_1.JsonResponse) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
throw new Error("Invalid response received, expected EmptyResponse or JsonResponse");
|
|
26
|
+
}
|
|
27
|
+
async getSecret({ secretId, delegatedTo, }) {
|
|
28
|
+
const req = {
|
|
29
|
+
secret_id: secretId,
|
|
30
|
+
};
|
|
31
|
+
if (delegatedTo)
|
|
32
|
+
req.delegated_to = delegatedTo;
|
|
33
|
+
const response = await this.client.sendRequest("secrets.get_secret", req);
|
|
34
|
+
if (response instanceof response_1.EmptyResponse) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if (response instanceof response_1.FileResponse) {
|
|
38
|
+
return response;
|
|
39
|
+
}
|
|
40
|
+
throw new Error("Invalid response received, expected FileResponse or EmptyResponse");
|
|
41
|
+
}
|
|
42
|
+
async listSecrets() {
|
|
43
|
+
const response = await this.client.sendRequest("secrets.list_secrets", {});
|
|
44
|
+
if (!(response instanceof response_1.JsonResponse)) {
|
|
45
|
+
throw new Error("Invalid response received, expected JsonResponse");
|
|
46
|
+
}
|
|
47
|
+
const secrets = Array.isArray(response.json?.secrets) ? response.json.secrets : [];
|
|
48
|
+
return secrets.map((item) => ({
|
|
49
|
+
id: item.id,
|
|
50
|
+
name: item.name,
|
|
51
|
+
type: item.type,
|
|
52
|
+
delegatedTo: item.delegated_to,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
async deleteSecret({ secretId, delegatedTo, }) {
|
|
56
|
+
const req = {
|
|
57
|
+
id: secretId,
|
|
58
|
+
};
|
|
59
|
+
if (delegatedTo)
|
|
60
|
+
req.delegated_to = delegatedTo;
|
|
61
|
+
const response = await this.client.sendRequest("secrets.delete_secret", req);
|
|
62
|
+
if (response instanceof response_1.EmptyResponse || response instanceof response_1.JsonResponse) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
throw new Error("Invalid response received, expected EmptyResponse or JsonResponse");
|
|
66
|
+
}
|
|
67
|
+
async deleteRequestedSecret({ url, type, delegatedTo, }) {
|
|
68
|
+
const req = {
|
|
69
|
+
url,
|
|
70
|
+
type,
|
|
71
|
+
};
|
|
72
|
+
if (delegatedTo)
|
|
73
|
+
req.delegated_to = delegatedTo;
|
|
74
|
+
const response = await this.client.sendRequest("secrets.delete_requested_secret", req);
|
|
75
|
+
if (response instanceof response_1.EmptyResponse || response instanceof response_1.JsonResponse) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
throw new Error("Invalid response received, expected EmptyResponse or JsonResponse");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.SecretsClient = SecretsClient;
|