@meshagent/meshagent-ts-auth 0.44.13 → 0.45.1
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 +8 -0
- package/dist/browser/ma-auth.global.js +1742 -1411
- package/package.json +2 -2
|
@@ -39535,7 +39535,7 @@ ${newlined}
|
|
|
39535
39535
|
"../meshagent-ts/dist/browser/participant-token.js"(exports) {
|
|
39536
39536
|
"use strict";
|
|
39537
39537
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39538
|
-
exports.ParticipantToken = exports.ParticipantGrant = exports.ApiScope = exports.LLMGrant = exports.ServicesGrant = exports.TunnelsGrant = exports.SecretsGrant = exports.
|
|
39538
|
+
exports.ParticipantToken = exports.ParticipantGrant = exports.ApiScope = exports.LLMGrant = exports.ServicesGrant = exports.TunnelsGrant = exports.SecretsGrant = exports.AdminGrant = exports.DeveloperGrant = exports.ContainersGrant = exports.ContainerRegistryGrant = exports.StorageGrant = exports.StoragePathGrant = exports.SyncGrant = exports.SyncPathGrant = exports.MemoryGrant = exports.MemoryEntryGrant = exports.MemoryPermissions = exports.SqliteGrant = exports.SqliteDatabaseGrant = exports.SqliteTableGrant = exports.DatasetGrant = exports.TableGrant = exports.MessagingGrant = exports.QueuesGrant = exports.LivekitGrant = exports.AgentsGrant = void 0;
|
|
39539
39539
|
var jose_1 = (init_webapi(), __toCommonJS(webapi_exports));
|
|
39540
39540
|
var api_keys_js_1 = require_api_keys();
|
|
39541
39541
|
var version_js_1 = require_version();
|
|
@@ -39824,6 +39824,212 @@ ${newlined}
|
|
|
39824
39824
|
}
|
|
39825
39825
|
};
|
|
39826
39826
|
exports.DatasetGrant = DatasetGrant;
|
|
39827
|
+
var SqliteTableGrant = class _SqliteTableGrant {
|
|
39828
|
+
constructor({ database, table, namespace, write, read, alter }) {
|
|
39829
|
+
this.database = database;
|
|
39830
|
+
this.table = table;
|
|
39831
|
+
this.namespace = namespace;
|
|
39832
|
+
this.write = write ?? true;
|
|
39833
|
+
this.read = read ?? true;
|
|
39834
|
+
this.alter = alter ?? false;
|
|
39835
|
+
}
|
|
39836
|
+
toJSON() {
|
|
39837
|
+
const json = {
|
|
39838
|
+
database: this.database,
|
|
39839
|
+
table: this.table
|
|
39840
|
+
};
|
|
39841
|
+
if (this.namespace !== void 0) {
|
|
39842
|
+
json["namespace"] = this.namespace;
|
|
39843
|
+
}
|
|
39844
|
+
if (this.write !== true) {
|
|
39845
|
+
json["write"] = this.write;
|
|
39846
|
+
}
|
|
39847
|
+
if (this.read !== true) {
|
|
39848
|
+
json["read"] = this.read;
|
|
39849
|
+
}
|
|
39850
|
+
if (this.alter !== false) {
|
|
39851
|
+
json["alter"] = this.alter;
|
|
39852
|
+
}
|
|
39853
|
+
return json;
|
|
39854
|
+
}
|
|
39855
|
+
static fromJSON(obj) {
|
|
39856
|
+
if (!isRecord(obj) || typeof obj.database !== "string" || typeof obj.table !== "string") {
|
|
39857
|
+
throw new Error("SqliteTableGrant requires database and table");
|
|
39858
|
+
}
|
|
39859
|
+
return new _SqliteTableGrant({
|
|
39860
|
+
database: obj.database,
|
|
39861
|
+
table: obj.table,
|
|
39862
|
+
namespace: asStringList(obj.namespace),
|
|
39863
|
+
write: obj.write,
|
|
39864
|
+
read: obj.read,
|
|
39865
|
+
alter: obj.alter
|
|
39866
|
+
});
|
|
39867
|
+
}
|
|
39868
|
+
};
|
|
39869
|
+
exports.SqliteTableGrant = SqliteTableGrant;
|
|
39870
|
+
var SqliteDatabaseGrant = class _SqliteDatabaseGrant {
|
|
39871
|
+
constructor({ name, namespace, createTable, drop, inspect, listTables, execute, tables }) {
|
|
39872
|
+
this.name = name;
|
|
39873
|
+
this.namespace = namespace;
|
|
39874
|
+
this.createTable = createTable ?? true;
|
|
39875
|
+
this.drop = drop ?? false;
|
|
39876
|
+
this.inspect = inspect ?? true;
|
|
39877
|
+
this.listTables = listTables ?? true;
|
|
39878
|
+
this.execute = execute ?? true;
|
|
39879
|
+
this.tables = tables;
|
|
39880
|
+
}
|
|
39881
|
+
toJSON() {
|
|
39882
|
+
const json = { name: this.name };
|
|
39883
|
+
if (this.namespace !== void 0) {
|
|
39884
|
+
json["namespace"] = this.namespace;
|
|
39885
|
+
}
|
|
39886
|
+
if (this.createTable !== true) {
|
|
39887
|
+
json["create_table"] = this.createTable;
|
|
39888
|
+
}
|
|
39889
|
+
if (this.drop !== false) {
|
|
39890
|
+
json["drop"] = this.drop;
|
|
39891
|
+
}
|
|
39892
|
+
if (this.inspect !== true) {
|
|
39893
|
+
json["inspect"] = this.inspect;
|
|
39894
|
+
}
|
|
39895
|
+
if (this.listTables !== true) {
|
|
39896
|
+
json["list_tables"] = this.listTables;
|
|
39897
|
+
}
|
|
39898
|
+
if (this.execute !== true) {
|
|
39899
|
+
json["execute"] = this.execute;
|
|
39900
|
+
}
|
|
39901
|
+
if (this.tables !== void 0) {
|
|
39902
|
+
json["tables"] = this.tables.map((tableGrant) => tableGrant.toJSON());
|
|
39903
|
+
}
|
|
39904
|
+
return json;
|
|
39905
|
+
}
|
|
39906
|
+
static fromJSON(obj) {
|
|
39907
|
+
if (!isRecord(obj) || typeof obj.name !== "string") {
|
|
39908
|
+
throw new Error("SqliteDatabaseGrant requires a name");
|
|
39909
|
+
}
|
|
39910
|
+
return new _SqliteDatabaseGrant({
|
|
39911
|
+
name: obj.name,
|
|
39912
|
+
namespace: asStringList(obj.namespace),
|
|
39913
|
+
createTable: obj.create_table ?? obj.createTable,
|
|
39914
|
+
drop: obj.drop,
|
|
39915
|
+
inspect: obj.inspect,
|
|
39916
|
+
listTables: obj.list_tables ?? obj.listTables,
|
|
39917
|
+
execute: obj.execute,
|
|
39918
|
+
tables: Array.isArray(obj.tables) ? obj.tables.map((tableGrant) => SqliteTableGrant.fromJSON(tableGrant)) : void 0
|
|
39919
|
+
});
|
|
39920
|
+
}
|
|
39921
|
+
};
|
|
39922
|
+
exports.SqliteDatabaseGrant = SqliteDatabaseGrant;
|
|
39923
|
+
var SqliteGrant = class _SqliteGrant {
|
|
39924
|
+
constructor({ databases, createDatabase, listDatabases } = {}) {
|
|
39925
|
+
this.databases = databases;
|
|
39926
|
+
this.createDatabase = createDatabase ?? true;
|
|
39927
|
+
this.listDatabases = listDatabases ?? true;
|
|
39928
|
+
}
|
|
39929
|
+
matchingDatabases(database, namespace) {
|
|
39930
|
+
if (this.databases === void 0) {
|
|
39931
|
+
return [];
|
|
39932
|
+
}
|
|
39933
|
+
return this.databases.filter((databaseGrant) => {
|
|
39934
|
+
if (databaseGrant.name !== database) {
|
|
39935
|
+
return false;
|
|
39936
|
+
}
|
|
39937
|
+
if (databaseGrant.namespace === void 0) {
|
|
39938
|
+
return true;
|
|
39939
|
+
}
|
|
39940
|
+
return namespacesEqual(databaseGrant.namespace, namespace);
|
|
39941
|
+
});
|
|
39942
|
+
}
|
|
39943
|
+
matchingTables(database, table, namespace) {
|
|
39944
|
+
return this.matchingDatabases(database, namespace).flatMap((databaseGrant) => databaseGrant.tables ?? []).filter((tableGrant) => {
|
|
39945
|
+
if (tableGrant.database !== database || tableGrant.table !== table) {
|
|
39946
|
+
return false;
|
|
39947
|
+
}
|
|
39948
|
+
if (tableGrant.namespace === void 0) {
|
|
39949
|
+
return true;
|
|
39950
|
+
}
|
|
39951
|
+
return namespacesEqual(tableGrant.namespace, namespace);
|
|
39952
|
+
});
|
|
39953
|
+
}
|
|
39954
|
+
canCreateDatabase() {
|
|
39955
|
+
return this.createDatabase;
|
|
39956
|
+
}
|
|
39957
|
+
canListDatabases() {
|
|
39958
|
+
return this.listDatabases;
|
|
39959
|
+
}
|
|
39960
|
+
canDropDatabase(database, namespace) {
|
|
39961
|
+
if (this.databases === void 0) {
|
|
39962
|
+
return true;
|
|
39963
|
+
}
|
|
39964
|
+
return this.matchingDatabases(database, namespace).some((databaseGrant) => databaseGrant.drop);
|
|
39965
|
+
}
|
|
39966
|
+
canInspectDatabase(database, namespace) {
|
|
39967
|
+
if (this.databases === void 0) {
|
|
39968
|
+
return true;
|
|
39969
|
+
}
|
|
39970
|
+
return this.matchingDatabases(database, namespace).some((databaseGrant) => databaseGrant.inspect);
|
|
39971
|
+
}
|
|
39972
|
+
canListTables(database, namespace) {
|
|
39973
|
+
if (this.databases === void 0) {
|
|
39974
|
+
return true;
|
|
39975
|
+
}
|
|
39976
|
+
return this.matchingDatabases(database, namespace).some((databaseGrant) => databaseGrant.listTables);
|
|
39977
|
+
}
|
|
39978
|
+
canCreateTable(database, namespace) {
|
|
39979
|
+
if (this.databases === void 0) {
|
|
39980
|
+
return true;
|
|
39981
|
+
}
|
|
39982
|
+
return this.matchingDatabases(database, namespace).some((databaseGrant) => databaseGrant.createTable);
|
|
39983
|
+
}
|
|
39984
|
+
canExecute(database, namespace) {
|
|
39985
|
+
if (this.databases === void 0) {
|
|
39986
|
+
return true;
|
|
39987
|
+
}
|
|
39988
|
+
return this.matchingDatabases(database, namespace).some((databaseGrant) => databaseGrant.execute);
|
|
39989
|
+
}
|
|
39990
|
+
canWrite(database, table, namespace) {
|
|
39991
|
+
if (this.databases === void 0) {
|
|
39992
|
+
return true;
|
|
39993
|
+
}
|
|
39994
|
+
return this.matchingTables(database, table, namespace).some((tableGrant) => tableGrant.write);
|
|
39995
|
+
}
|
|
39996
|
+
canRead(database, table, namespace) {
|
|
39997
|
+
if (this.databases === void 0) {
|
|
39998
|
+
return true;
|
|
39999
|
+
}
|
|
40000
|
+
return this.matchingTables(database, table, namespace).some((tableGrant) => tableGrant.read);
|
|
40001
|
+
}
|
|
40002
|
+
canAlter(database, table, namespace) {
|
|
40003
|
+
if (this.databases === void 0) {
|
|
40004
|
+
return true;
|
|
40005
|
+
}
|
|
40006
|
+
return this.matchingTables(database, table, namespace).some((tableGrant) => tableGrant.alter);
|
|
40007
|
+
}
|
|
40008
|
+
toJSON() {
|
|
40009
|
+
const json = {};
|
|
40010
|
+
if (this.databases !== void 0) {
|
|
40011
|
+
json["databases"] = this.databases.map((databaseGrant) => databaseGrant.toJSON());
|
|
40012
|
+
}
|
|
40013
|
+
if (this.createDatabase !== true) {
|
|
40014
|
+
json["create_database"] = this.createDatabase;
|
|
40015
|
+
}
|
|
40016
|
+
if (this.listDatabases !== true) {
|
|
40017
|
+
json["list_databases"] = this.listDatabases;
|
|
40018
|
+
}
|
|
40019
|
+
return json;
|
|
40020
|
+
}
|
|
40021
|
+
static fromJSON(obj) {
|
|
40022
|
+
if (!isRecord(obj)) {
|
|
40023
|
+
return new _SqliteGrant();
|
|
40024
|
+
}
|
|
40025
|
+
return new _SqliteGrant({
|
|
40026
|
+
databases: Array.isArray(obj.databases) ? obj.databases.map((databaseGrant) => SqliteDatabaseGrant.fromJSON(databaseGrant)) : void 0,
|
|
40027
|
+
createDatabase: obj.create_database ?? obj.createDatabase,
|
|
40028
|
+
listDatabases: obj.list_databases ?? obj.listDatabases
|
|
40029
|
+
});
|
|
40030
|
+
}
|
|
40031
|
+
};
|
|
40032
|
+
exports.SqliteGrant = SqliteGrant;
|
|
39827
40033
|
var MemoryPermissions = class _MemoryPermissions {
|
|
39828
40034
|
constructor({ create, drop, inspect, query, upsert, ingest, recall, optimize } = {}) {
|
|
39829
40035
|
this.create = create ?? true;
|
|
@@ -40281,63 +40487,25 @@ ${newlined}
|
|
|
40281
40487
|
}
|
|
40282
40488
|
};
|
|
40283
40489
|
exports.AdminGrant = AdminGrant;
|
|
40284
|
-
var OAuthEndpoint = class _OAuthEndpoint {
|
|
40285
|
-
constructor({ endpoint, clientId }) {
|
|
40286
|
-
this.endpoint = endpoint;
|
|
40287
|
-
this.clientId = clientId;
|
|
40288
|
-
}
|
|
40289
|
-
toJSON() {
|
|
40290
|
-
return {
|
|
40291
|
-
endpoint: this.endpoint,
|
|
40292
|
-
client_id: this.clientId
|
|
40293
|
-
};
|
|
40294
|
-
}
|
|
40295
|
-
static fromJSON(obj) {
|
|
40296
|
-
if (!isRecord(obj) || typeof obj.endpoint !== "string") {
|
|
40297
|
-
throw new Error("OAuthEndpoint requires an endpoint");
|
|
40298
|
-
}
|
|
40299
|
-
const clientId = obj.client_id ?? obj.clientId;
|
|
40300
|
-
if (typeof clientId !== "string") {
|
|
40301
|
-
throw new Error("OAuthEndpoint requires a client_id");
|
|
40302
|
-
}
|
|
40303
|
-
return new _OAuthEndpoint({
|
|
40304
|
-
endpoint: obj.endpoint,
|
|
40305
|
-
clientId
|
|
40306
|
-
});
|
|
40307
|
-
}
|
|
40308
|
-
};
|
|
40309
|
-
exports.OAuthEndpoint = OAuthEndpoint;
|
|
40310
40490
|
var SecretsGrant = class _SecretsGrant {
|
|
40311
|
-
constructor(
|
|
40312
|
-
|
|
40313
|
-
|
|
40314
|
-
|
|
40315
|
-
void connector;
|
|
40316
|
-
if (this.requestOauthToken === void 0) {
|
|
40317
|
-
return true;
|
|
40318
|
-
}
|
|
40319
|
-
const authorizationEndpoint = typeof oauth?.authorization_endpoint === "string" ? oauth.authorization_endpoint.trim() : "";
|
|
40320
|
-
const clientId = typeof oauth?.client_id === "string" ? oauth.client_id.trim() : "";
|
|
40321
|
-
if (authorizationEndpoint === "" || clientId === "") {
|
|
40322
|
-
return false;
|
|
40491
|
+
constructor(options = {}) {
|
|
40492
|
+
const keys = Object.keys(options);
|
|
40493
|
+
if (keys.length > 0) {
|
|
40494
|
+
throw new Error(`unsupported SecretsGrant fields: ${keys.join(", ")}`);
|
|
40323
40495
|
}
|
|
40324
|
-
return this.requestOauthToken.some((endpointGrant) => (endpointGrant.endpoint === authorizationEndpoint || endpointGrant.endpoint.endsWith("*") && authorizationEndpoint.startsWith(endpointGrant.endpoint.slice(0, -1))) && endpointGrant.clientId === clientId);
|
|
40325
40496
|
}
|
|
40326
40497
|
toJSON() {
|
|
40327
|
-
|
|
40328
|
-
if (this.requestOauthToken !== void 0) {
|
|
40329
|
-
json["request_oauth_token"] = this.requestOauthToken.map((endpointGrant) => endpointGrant.toJSON());
|
|
40330
|
-
}
|
|
40331
|
-
return json;
|
|
40498
|
+
return {};
|
|
40332
40499
|
}
|
|
40333
40500
|
static fromJSON(obj) {
|
|
40334
40501
|
if (!isRecord(obj)) {
|
|
40335
40502
|
return new _SecretsGrant();
|
|
40336
40503
|
}
|
|
40337
|
-
const
|
|
40338
|
-
|
|
40339
|
-
|
|
40340
|
-
}
|
|
40504
|
+
const keys = Object.keys(obj);
|
|
40505
|
+
if (keys.length > 0) {
|
|
40506
|
+
throw new Error(`unsupported SecretsGrant fields: ${keys.join(", ")}`);
|
|
40507
|
+
}
|
|
40508
|
+
return new _SecretsGrant();
|
|
40341
40509
|
}
|
|
40342
40510
|
};
|
|
40343
40511
|
exports.SecretsGrant = SecretsGrant;
|
|
@@ -40424,11 +40592,12 @@ ${newlined}
|
|
|
40424
40592
|
};
|
|
40425
40593
|
exports.LLMGrant = LLMGrant;
|
|
40426
40594
|
var ApiScope = class _ApiScope {
|
|
40427
|
-
constructor({ livekit, queues, messaging, dataset, memory, sync, storage, containers, developer, agents, llm, admin, secrets, tunnels, services } = {}) {
|
|
40595
|
+
constructor({ livekit, queues, messaging, dataset, sqlite, memory, sync, storage, containers, developer, agents, llm, admin, secrets, tunnels, services } = {}) {
|
|
40428
40596
|
this.livekit = livekit;
|
|
40429
40597
|
this.queues = queues;
|
|
40430
40598
|
this.messaging = messaging;
|
|
40431
40599
|
this.dataset = dataset;
|
|
40600
|
+
this.sqlite = sqlite;
|
|
40432
40601
|
this.memory = memory;
|
|
40433
40602
|
this.sync = sync;
|
|
40434
40603
|
this.storage = storage;
|
|
@@ -40447,6 +40616,7 @@ ${newlined}
|
|
|
40447
40616
|
queues: new QueuesGrant(),
|
|
40448
40617
|
messaging: new MessagingGrant(),
|
|
40449
40618
|
dataset: new DatasetGrant(),
|
|
40619
|
+
sqlite: new SqliteGrant(),
|
|
40450
40620
|
memory: new MemoryGrant(),
|
|
40451
40621
|
sync: new SyncGrant(),
|
|
40452
40622
|
storage: new StorageGrant(),
|
|
@@ -40463,6 +40633,7 @@ ${newlined}
|
|
|
40463
40633
|
queues: new QueuesGrant(),
|
|
40464
40634
|
messaging: new MessagingGrant(),
|
|
40465
40635
|
dataset: new DatasetGrant(),
|
|
40636
|
+
sqlite: new SqliteGrant(),
|
|
40466
40637
|
memory: new MemoryGrant(),
|
|
40467
40638
|
sync: new SyncGrant(),
|
|
40468
40639
|
storage: new StorageGrant(),
|
|
@@ -40470,7 +40641,6 @@ ${newlined}
|
|
|
40470
40641
|
developer: new DeveloperGrant(),
|
|
40471
40642
|
agents: new AgentsGrant(),
|
|
40472
40643
|
llm: new LLMGrant(),
|
|
40473
|
-
secrets: new SecretsGrant(),
|
|
40474
40644
|
services: new ServicesGrant()
|
|
40475
40645
|
});
|
|
40476
40646
|
}
|
|
@@ -40480,6 +40650,7 @@ ${newlined}
|
|
|
40480
40650
|
queues: new QueuesGrant(),
|
|
40481
40651
|
messaging: new MessagingGrant(),
|
|
40482
40652
|
dataset: new DatasetGrant(),
|
|
40653
|
+
sqlite: new SqliteGrant(),
|
|
40483
40654
|
memory: new MemoryGrant(),
|
|
40484
40655
|
sync: new SyncGrant(),
|
|
40485
40656
|
storage: new StorageGrant(),
|
|
@@ -40488,7 +40659,6 @@ ${newlined}
|
|
|
40488
40659
|
agents: new AgentsGrant(),
|
|
40489
40660
|
llm: new LLMGrant(),
|
|
40490
40661
|
admin: new AdminGrant(),
|
|
40491
|
-
secrets: new SecretsGrant(),
|
|
40492
40662
|
tunnels: new TunnelsGrant(),
|
|
40493
40663
|
services: new ServicesGrant()
|
|
40494
40664
|
});
|
|
@@ -40507,6 +40677,9 @@ ${newlined}
|
|
|
40507
40677
|
if (this.dataset !== void 0) {
|
|
40508
40678
|
json["dataset"] = this.dataset.toJSON();
|
|
40509
40679
|
}
|
|
40680
|
+
if (this.sqlite !== void 0) {
|
|
40681
|
+
json["sqlite"] = this.sqlite.toJSON();
|
|
40682
|
+
}
|
|
40510
40683
|
if (this.memory !== void 0) {
|
|
40511
40684
|
json["memory"] = this.memory.toJSON();
|
|
40512
40685
|
}
|
|
@@ -40552,6 +40725,7 @@ ${newlined}
|
|
|
40552
40725
|
queues: obj.queues ? QueuesGrant.fromJSON(obj.queues) : void 0,
|
|
40553
40726
|
messaging: obj.messaging ? MessagingGrant.fromJSON(obj.messaging) : void 0,
|
|
40554
40727
|
dataset: rawDataset ? DatasetGrant.fromJSON(rawDataset) : void 0,
|
|
40728
|
+
sqlite: obj.sqlite ? SqliteGrant.fromJSON(obj.sqlite) : void 0,
|
|
40555
40729
|
memory: obj.memory ? MemoryGrant.fromJSON(obj.memory) : void 0,
|
|
40556
40730
|
sync: obj.sync ? SyncGrant.fromJSON(obj.sync) : void 0,
|
|
40557
40731
|
storage: obj.storage ? StorageGrant.fromJSON(obj.storage) : void 0,
|
|
@@ -41562,12 +41736,9 @@ ${newlined}
|
|
|
41562
41736
|
"../meshagent-ts/dist/browser/meshagent-client.js"(exports) {
|
|
41563
41737
|
"use strict";
|
|
41564
41738
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41565
|
-
exports.Meshagent = exports.
|
|
41566
|
-
exports.normalizeServiceSpec = normalizeServiceSpec;
|
|
41739
|
+
exports.Meshagent = exports.ServiceTemplateSpec = exports.RoomSession = void 0;
|
|
41567
41740
|
var helpers_js_1 = require_helpers();
|
|
41568
41741
|
var requirement_js_1 = require_requirement();
|
|
41569
|
-
var participant_token_js_1 = require_participant_token();
|
|
41570
|
-
var utils_js_1 = require_utils();
|
|
41571
41742
|
var RoomSession = class {
|
|
41572
41743
|
constructor({ id, roomId, roomName, createdAt, isActive, participants, kind = "room", agentId, agentName }) {
|
|
41573
41744
|
this.id = id;
|
|
@@ -41594,216 +41765,67 @@ ${newlined}
|
|
|
41594
41765
|
}
|
|
41595
41766
|
};
|
|
41596
41767
|
exports.RoomSession = RoomSession;
|
|
41597
|
-
function
|
|
41598
|
-
if (Array.isArray(value)) {
|
|
41599
|
-
return value.map((item) => cloneJsonValue(item));
|
|
41600
|
-
}
|
|
41601
|
-
if (value != null && typeof value === "object") {
|
|
41602
|
-
const result = {};
|
|
41603
|
-
for (const [key, item] of Object.entries(value)) {
|
|
41604
|
-
result[key] = cloneJsonValue(item);
|
|
41605
|
-
}
|
|
41606
|
-
return result;
|
|
41607
|
-
}
|
|
41608
|
-
return value;
|
|
41609
|
-
}
|
|
41610
|
-
function formatTemplateString(value, values) {
|
|
41611
|
-
return value.replace(/\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (token, key) => values[key] ?? token);
|
|
41612
|
-
}
|
|
41613
|
-
function formatJsonValue(value, values) {
|
|
41768
|
+
function applyTemplateValues(value, values) {
|
|
41614
41769
|
if (typeof value === "string") {
|
|
41615
|
-
return
|
|
41770
|
+
return Object.entries(values).reduce((current, [key, replacement]) => current.split(`{${key}}`).join(replacement), value);
|
|
41616
41771
|
}
|
|
41617
41772
|
if (Array.isArray(value)) {
|
|
41618
|
-
return value.map((item) =>
|
|
41773
|
+
return value.map((item) => applyTemplateValues(item, values));
|
|
41619
41774
|
}
|
|
41620
|
-
if (value
|
|
41775
|
+
if (value !== null && typeof value === "object") {
|
|
41621
41776
|
const result = {};
|
|
41622
|
-
for (const [key,
|
|
41623
|
-
result[key] =
|
|
41777
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
41778
|
+
result[key] = applyTemplateValues(entry, values);
|
|
41624
41779
|
}
|
|
41625
41780
|
return result;
|
|
41626
41781
|
}
|
|
41627
41782
|
return value;
|
|
41628
41783
|
}
|
|
41629
|
-
function
|
|
41630
|
-
|
|
41631
|
-
|
|
41632
|
-
|
|
41633
|
-
|
|
41634
|
-
|
|
41635
|
-
|
|
41636
|
-
|
|
41637
|
-
|
|
41638
|
-
|
|
41639
|
-
|
|
41640
|
-
}
|
|
41641
|
-
function normalizeRoomMount(value) {
|
|
41642
|
-
return {
|
|
41643
|
-
path: stringValue(value.path) ?? "",
|
|
41644
|
-
...stringValue(value.subpath) !== void 0 ? { subpath: stringValue(value.subpath) } : {},
|
|
41645
|
-
...booleanValue(value.read_only) !== void 0 ? { read_only: booleanValue(value.read_only) } : {}
|
|
41646
|
-
};
|
|
41647
|
-
}
|
|
41648
|
-
function normalizeProjectMount(value) {
|
|
41649
|
-
return {
|
|
41650
|
-
path: stringValue(value.path) ?? "",
|
|
41651
|
-
...stringValue(value.subpath) !== void 0 ? { subpath: stringValue(value.subpath) } : {},
|
|
41652
|
-
read_only: booleanValue(value.read_only) ?? true
|
|
41653
|
-
};
|
|
41654
|
-
}
|
|
41655
|
-
function normalizeImageMount(value) {
|
|
41656
|
-
return {
|
|
41657
|
-
path: stringValue(value.path) ?? "",
|
|
41658
|
-
...stringValue(value.subpath) !== void 0 ? { subpath: stringValue(value.subpath) } : {},
|
|
41659
|
-
read_only: booleanValue(value.read_only) ?? true,
|
|
41660
|
-
image: stringValue(value.image) ?? ""
|
|
41661
|
-
};
|
|
41662
|
-
}
|
|
41663
|
-
function normalizeFileMount(value) {
|
|
41664
|
-
return {
|
|
41665
|
-
path: stringValue(value.path) ?? "",
|
|
41666
|
-
...stringValue(value.subpath) !== void 0 ? { subpath: stringValue(value.subpath) } : {},
|
|
41667
|
-
read_only: booleanValue(value.read_only) ?? true,
|
|
41668
|
-
text: stringValue(value.text) ?? ""
|
|
41669
|
-
};
|
|
41670
|
-
}
|
|
41671
|
-
function normalizeEmptyDirMount(value) {
|
|
41672
|
-
return {
|
|
41673
|
-
path: stringValue(value.path) ?? "",
|
|
41674
|
-
read_only: booleanValue(value.read_only) ?? false
|
|
41675
|
-
};
|
|
41676
|
-
}
|
|
41677
|
-
function normalizeConfigMount(value) {
|
|
41678
|
-
return {
|
|
41679
|
-
path: stringValue(value.path) ?? "/var/run/meshagent"
|
|
41680
|
-
};
|
|
41681
|
-
}
|
|
41682
|
-
function normalizeContainerMountSpec(value) {
|
|
41683
|
-
const source = objectOrUndefined(value) ?? {};
|
|
41684
|
-
const room = objectArray(source.room)?.map(normalizeRoomMount);
|
|
41685
|
-
const project = objectArray(source.project)?.map(normalizeProjectMount);
|
|
41686
|
-
const images = objectArray(source.images)?.map(normalizeImageMount);
|
|
41687
|
-
const files = objectArray(source.files)?.map(normalizeFileMount);
|
|
41688
|
-
const emptyDirs = objectArray(source.empty_dirs)?.map(normalizeEmptyDirMount);
|
|
41689
|
-
const configs = objectArray(source.configs)?.map(normalizeConfigMount);
|
|
41690
|
-
return {
|
|
41691
|
-
...room !== void 0 ? { room } : {},
|
|
41692
|
-
...project !== void 0 ? { project } : {},
|
|
41693
|
-
...images !== void 0 ? { images } : {},
|
|
41694
|
-
...files !== void 0 ? { files } : {},
|
|
41695
|
-
...emptyDirs !== void 0 ? { empty_dirs: emptyDirs } : {},
|
|
41696
|
-
...configs !== void 0 ? { configs } : {}
|
|
41697
|
-
};
|
|
41698
|
-
}
|
|
41699
|
-
function normalizeAgentSpec(agent, values) {
|
|
41700
|
-
const formatted = formatJsonValue(agent, values);
|
|
41701
|
-
const spec = cloneJsonValue(formatted);
|
|
41702
|
-
if (spec.email != null && spec.email.public == null) {
|
|
41703
|
-
spec.email = { ...spec.email, public: false };
|
|
41704
|
-
}
|
|
41705
|
-
if (spec.channels?.email) {
|
|
41706
|
-
spec.channels = {
|
|
41707
|
-
...spec.channels,
|
|
41708
|
-
email: spec.channels.email.map((channel) => ({
|
|
41709
|
-
...channel,
|
|
41710
|
-
private: channel.private ?? false
|
|
41711
|
-
}))
|
|
41712
|
-
};
|
|
41713
|
-
}
|
|
41714
|
-
if (spec.channels?.messaging) {
|
|
41715
|
-
spec.channels = {
|
|
41716
|
-
...spec.channels,
|
|
41717
|
-
messaging: spec.channels.messaging.map((channel) => ({
|
|
41784
|
+
function normalizeServiceSpec(service) {
|
|
41785
|
+
const storage = service.container?.storage;
|
|
41786
|
+
const agents = service.agents?.map((agent) => ({
|
|
41787
|
+
...agent,
|
|
41788
|
+
email: agent.email == null ? agent.email : {
|
|
41789
|
+
...agent.email,
|
|
41790
|
+
public: agent.email.public ?? false
|
|
41791
|
+
},
|
|
41792
|
+
channels: agent.channels == null ? agent.channels : {
|
|
41793
|
+
...agent.channels,
|
|
41794
|
+
messaging: agent.channels.messaging?.map((channel) => ({
|
|
41718
41795
|
...channel,
|
|
41719
41796
|
protocol: channel.protocol ?? "meshagent.agent-message.v1"
|
|
41720
41797
|
}))
|
|
41721
|
-
}
|
|
41722
|
-
}
|
|
41723
|
-
|
|
41724
|
-
|
|
41725
|
-
|
|
41726
|
-
|
|
41727
|
-
|
|
41728
|
-
|
|
41729
|
-
|
|
41730
|
-
|
|
41731
|
-
|
|
41732
|
-
|
|
41733
|
-
|
|
41798
|
+
}
|
|
41799
|
+
}));
|
|
41800
|
+
const container = service.container == null ? service.container : {
|
|
41801
|
+
...service.container,
|
|
41802
|
+
storage: storage == null ? storage : {
|
|
41803
|
+
...storage,
|
|
41804
|
+
configs: storage.configs?.map((config) => ({
|
|
41805
|
+
...config,
|
|
41806
|
+
path: config.path ?? "/var/run/meshagent"
|
|
41807
|
+
})),
|
|
41808
|
+
files: storage.files?.map((file) => ({
|
|
41809
|
+
...file,
|
|
41810
|
+
read_only: file.read_only ?? true
|
|
41811
|
+
}))
|
|
41812
|
+
}
|
|
41813
|
+
};
|
|
41814
|
+
return { ...service, agents, container };
|
|
41734
41815
|
}
|
|
41735
41816
|
var ServiceTemplateSpec = class _ServiceTemplateSpec {
|
|
41736
|
-
constructor(
|
|
41737
|
-
this.
|
|
41738
|
-
this.kind = kind;
|
|
41739
|
-
this.variables = variables;
|
|
41740
|
-
this.metadata = metadata;
|
|
41741
|
-
this.ports = ports;
|
|
41742
|
-
this.container = container;
|
|
41743
|
-
this.external = external;
|
|
41744
|
-
this.agents = agents;
|
|
41817
|
+
constructor(template) {
|
|
41818
|
+
this.template = template;
|
|
41745
41819
|
}
|
|
41746
41820
|
static fromJson(json) {
|
|
41747
|
-
|
|
41748
|
-
if (metadata === void 0 || typeof metadata.name !== "string") {
|
|
41749
|
-
throw new requirement_js_1.RoomException("Invalid service template payload: missing metadata.name");
|
|
41750
|
-
}
|
|
41751
|
-
return new _ServiceTemplateSpec({
|
|
41752
|
-
version: stringValue(json.version) ?? "v1",
|
|
41753
|
-
kind: stringValue(json.kind) ?? "ServiceTemplate",
|
|
41754
|
-
variables: objectArray(json.variables),
|
|
41755
|
-
metadata: cloneJsonValue(metadata),
|
|
41756
|
-
ports: objectArray(json.ports) ?? [],
|
|
41757
|
-
container: objectOrUndefined(json.container),
|
|
41758
|
-
external: objectOrUndefined(json.external),
|
|
41759
|
-
agents: objectArray(json.agents) ?? []
|
|
41760
|
-
});
|
|
41761
|
-
}
|
|
41762
|
-
toJson() {
|
|
41763
|
-
return {
|
|
41764
|
-
version: this.version,
|
|
41765
|
-
kind: this.kind,
|
|
41766
|
-
...this.variables != null ? { variables: cloneJsonValue(this.variables) } : {},
|
|
41767
|
-
metadata: cloneJsonValue(this.metadata),
|
|
41768
|
-
...this.ports.length > 0 ? { ports: cloneJsonValue(this.ports) } : {},
|
|
41769
|
-
...this.container != null ? { container: cloneJsonValue(this.container) } : {},
|
|
41770
|
-
...this.external != null ? { external: cloneJsonValue(this.external) } : {},
|
|
41771
|
-
...this.agents.length > 0 ? { agents: cloneJsonValue(this.agents) } : {}
|
|
41772
|
-
};
|
|
41821
|
+
return new _ServiceTemplateSpec(json);
|
|
41773
41822
|
}
|
|
41774
41823
|
toServiceSpec({ values = {} } = {}) {
|
|
41775
|
-
const
|
|
41776
|
-
|
|
41777
|
-
|
|
41778
|
-
|
|
41779
|
-
|
|
41780
|
-
ports: cloneJsonValue(this.ports)
|
|
41781
|
-
};
|
|
41782
|
-
if (this.container != null) {
|
|
41783
|
-
const formattedContainer = formatJsonValue(this.container, values);
|
|
41784
|
-
const image = stringValue(formattedContainer.image);
|
|
41785
|
-
if (image === void 0 || image.length === 0) {
|
|
41786
|
-
throw new requirement_js_1.RoomException("ServiceTemplateSpec.image is required to build a ServiceSpec");
|
|
41787
|
-
}
|
|
41788
|
-
service.container = {
|
|
41789
|
-
...booleanValue(formattedContainer.private) !== void 0 ? { private: booleanValue(formattedContainer.private) } : {},
|
|
41790
|
-
...stringValue(formattedContainer.command) !== void 0 ? { command: stringValue(formattedContainer.command) } : {},
|
|
41791
|
-
...stringValue(formattedContainer.working_dir) !== void 0 ? { working_dir: stringValue(formattedContainer.working_dir) } : {},
|
|
41792
|
-
image,
|
|
41793
|
-
...Array.isArray(formattedContainer.environment) ? { environment: formattedContainer.environment } : {},
|
|
41794
|
-
...objectOrUndefined(formattedContainer.storage) !== void 0 ? { storage: normalizeContainerMountSpec(formattedContainer.storage) } : {},
|
|
41795
|
-
...booleanValue(formattedContainer.on_demand) !== void 0 ? { on_demand: booleanValue(formattedContainer.on_demand) } : {},
|
|
41796
|
-
...booleanValue(formattedContainer.writable_root_fs) !== void 0 ? { writable_root_fs: booleanValue(formattedContainer.writable_root_fs) } : {}
|
|
41797
|
-
};
|
|
41798
|
-
}
|
|
41799
|
-
if (this.external != null) {
|
|
41800
|
-
const formattedExternal = formatJsonValue(this.external, values);
|
|
41801
|
-
const url = stringValue(formattedExternal.url);
|
|
41802
|
-
if (url !== void 0) {
|
|
41803
|
-
service.external = { url };
|
|
41804
|
-
}
|
|
41805
|
-
}
|
|
41806
|
-
return normalizeServiceSpec(service);
|
|
41824
|
+
const templated = applyTemplateValues(this.template, values);
|
|
41825
|
+
return normalizeServiceSpec({
|
|
41826
|
+
...templated,
|
|
41827
|
+
kind: "Service"
|
|
41828
|
+
});
|
|
41807
41829
|
}
|
|
41808
41830
|
};
|
|
41809
41831
|
exports.ServiceTemplateSpec = ServiceTemplateSpec;
|
|
@@ -41827,26 +41849,62 @@ ${newlined}
|
|
|
41827
41849
|
}
|
|
41828
41850
|
return value;
|
|
41829
41851
|
}
|
|
41830
|
-
function
|
|
41831
|
-
|
|
41832
|
-
|
|
41852
|
+
function validateServiceSpec(service) {
|
|
41853
|
+
const container = service.container;
|
|
41854
|
+
if (container == null) {
|
|
41855
|
+
return;
|
|
41833
41856
|
}
|
|
41834
|
-
if (
|
|
41835
|
-
|
|
41857
|
+
if (typeof container.run_as === "string") {
|
|
41858
|
+
throw new Error("container.run_as must be an object with an email field");
|
|
41836
41859
|
}
|
|
41837
|
-
|
|
41838
|
-
|
|
41839
|
-
|
|
41840
|
-
|
|
41841
|
-
|
|
41842
|
-
|
|
41843
|
-
|
|
41860
|
+
const environment = container.environment ?? [];
|
|
41861
|
+
const hasSecretEnvironment = environment.some((entry) => entry.secret != null);
|
|
41862
|
+
if (hasSecretEnvironment && container.run_as == null) {
|
|
41863
|
+
throw new Error("container.run_as is required when using SecretValue");
|
|
41864
|
+
}
|
|
41865
|
+
for (const entry of environment) {
|
|
41866
|
+
const secret = entry.secret;
|
|
41867
|
+
if (secret == null) {
|
|
41868
|
+
continue;
|
|
41869
|
+
}
|
|
41870
|
+
const unsupportedFields = Object.keys(secret).filter((key) => key !== "id");
|
|
41871
|
+
if (unsupportedFields.length > 0) {
|
|
41872
|
+
throw new Error(`unsupported SecretValue fields: ${unsupportedFields.join(", ")}`);
|
|
41844
41873
|
}
|
|
41845
|
-
return result;
|
|
41846
41874
|
}
|
|
41847
|
-
|
|
41875
|
+
const pullSecret = container.pull_secret;
|
|
41876
|
+
if (pullSecret != null) {
|
|
41877
|
+
const unsupportedFields = Object.keys(pullSecret).filter((key) => key !== "id");
|
|
41878
|
+
if (unsupportedFields.length > 0) {
|
|
41879
|
+
throw new Error(`unsupported SecretValue fields: ${unsupportedFields.join(", ")}`);
|
|
41880
|
+
}
|
|
41881
|
+
}
|
|
41882
|
+
}
|
|
41883
|
+
var defaultServiceRunAsScopes = ["secrets:proxy"];
|
|
41884
|
+
function normalizeServiceRunAs(runAs) {
|
|
41885
|
+
if (runAs == null) {
|
|
41886
|
+
return runAs;
|
|
41887
|
+
}
|
|
41888
|
+
const email = runAs.email.trim().toLowerCase();
|
|
41889
|
+
if (email.length === 0) {
|
|
41890
|
+
throw new Error("container.run_as.email is required");
|
|
41891
|
+
}
|
|
41892
|
+
const scopes = runAs.scopes == null ? defaultServiceRunAsScopes : runAs.scopes;
|
|
41893
|
+
const normalizedScopes = [];
|
|
41894
|
+
for (const scope of scopes) {
|
|
41895
|
+
const normalized = scope.trim();
|
|
41896
|
+
if (normalized.length === 0 || normalizedScopes.includes(normalized)) {
|
|
41897
|
+
continue;
|
|
41898
|
+
}
|
|
41899
|
+
normalizedScopes.push(normalized);
|
|
41900
|
+
}
|
|
41901
|
+
return {
|
|
41902
|
+
email,
|
|
41903
|
+
scopes: normalizedScopes.length === 0 ? [...defaultServiceRunAsScopes] : normalizedScopes
|
|
41904
|
+
};
|
|
41848
41905
|
}
|
|
41849
41906
|
function serializeServiceSpec(service) {
|
|
41907
|
+
validateServiceSpec(service);
|
|
41850
41908
|
const agents = service.agents?.map((agent) => ({
|
|
41851
41909
|
...agent,
|
|
41852
41910
|
channels: agent.channels == null ? agent.channels : {
|
|
@@ -41857,8 +41915,13 @@ ${newlined}
|
|
|
41857
41915
|
}))
|
|
41858
41916
|
}
|
|
41859
41917
|
}));
|
|
41918
|
+
const container = service.container == null ? service.container : {
|
|
41919
|
+
...service.container,
|
|
41920
|
+
run_as: normalizeServiceRunAs(service.container.run_as)
|
|
41921
|
+
};
|
|
41860
41922
|
return pruneUndefinedValues({
|
|
41861
41923
|
...service,
|
|
41924
|
+
container,
|
|
41862
41925
|
agents
|
|
41863
41926
|
});
|
|
41864
41927
|
}
|
|
@@ -41867,62 +41930,27 @@ ${newlined}
|
|
|
41867
41930
|
delete payload.id;
|
|
41868
41931
|
return payload;
|
|
41869
41932
|
}
|
|
41870
|
-
|
|
41871
|
-
|
|
41872
|
-
|
|
41873
|
-
}
|
|
41874
|
-
static fromJson(json) {
|
|
41875
|
-
return new _ManagedAgentGrant({ admin: json["admin"] === true });
|
|
41933
|
+
function toFetchBody(body) {
|
|
41934
|
+
if (body == null) {
|
|
41935
|
+
return void 0;
|
|
41876
41936
|
}
|
|
41877
|
-
|
|
41878
|
-
return
|
|
41879
|
-
}
|
|
41880
|
-
};
|
|
41881
|
-
exports.ManagedAgentGrant = ManagedAgentGrant;
|
|
41882
|
-
var globalScope = globalThis;
|
|
41883
|
-
function bytesToBase64(bytes) {
|
|
41884
|
-
if (globalScope.Buffer) {
|
|
41885
|
-
return globalScope.Buffer.from(bytes).toString("base64");
|
|
41886
|
-
}
|
|
41887
|
-
if (!globalScope.btoa) {
|
|
41888
|
-
throw new Error("base64 encoding is not available in this runtime");
|
|
41889
|
-
}
|
|
41890
|
-
let binary = "";
|
|
41891
|
-
for (const byte of bytes) {
|
|
41892
|
-
binary += String.fromCharCode(byte);
|
|
41893
|
-
}
|
|
41894
|
-
return globalScope.btoa(binary);
|
|
41895
|
-
}
|
|
41896
|
-
function base64ToBytes(base64) {
|
|
41897
|
-
if (globalScope.Buffer) {
|
|
41898
|
-
return Uint8Array.from(globalScope.Buffer.from(base64, "base64"));
|
|
41899
|
-
}
|
|
41900
|
-
if (!globalScope.atob) {
|
|
41901
|
-
throw new Error("base64 decoding is not available in this runtime");
|
|
41902
|
-
}
|
|
41903
|
-
const binary = globalScope.atob(base64);
|
|
41904
|
-
const bytes = new Uint8Array(binary.length);
|
|
41905
|
-
for (let index = 0; index < binary.length; index += 1) {
|
|
41906
|
-
bytes[index] = binary.charCodeAt(index);
|
|
41907
|
-
}
|
|
41908
|
-
return bytes;
|
|
41909
|
-
}
|
|
41910
|
-
function toFetchBody(body) {
|
|
41911
|
-
if (body == null) {
|
|
41912
|
-
return void 0;
|
|
41913
|
-
}
|
|
41914
|
-
if (typeof body === "string" || body instanceof ArrayBuffer) {
|
|
41915
|
-
return body;
|
|
41937
|
+
if (typeof body === "string" || body instanceof ArrayBuffer) {
|
|
41938
|
+
return body;
|
|
41916
41939
|
}
|
|
41917
41940
|
const copy = new Uint8Array(body.byteLength);
|
|
41918
41941
|
copy.set(body);
|
|
41919
41942
|
return copy.buffer;
|
|
41920
41943
|
}
|
|
41921
|
-
function
|
|
41922
|
-
|
|
41923
|
-
|
|
41944
|
+
function bytesToBase64(value) {
|
|
41945
|
+
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
41946
|
+
if (typeof Buffer !== "undefined") {
|
|
41947
|
+
return Buffer.from(bytes).toString("base64");
|
|
41948
|
+
}
|
|
41949
|
+
let binary = "";
|
|
41950
|
+
for (const byte of bytes) {
|
|
41951
|
+
binary += String.fromCharCode(byte);
|
|
41924
41952
|
}
|
|
41925
|
-
return
|
|
41953
|
+
return btoa(binary);
|
|
41926
41954
|
}
|
|
41927
41955
|
var Meshagent2 = class {
|
|
41928
41956
|
constructor({ baseUrl, token } = {}) {
|
|
@@ -41978,11 +42006,10 @@ ${newlined}
|
|
|
41978
42006
|
} catch {
|
|
41979
42007
|
message2 = "<unable to read body>";
|
|
41980
42008
|
}
|
|
41981
|
-
const errorMessage = `Failed to ${action}. Status code: ${response.status}, body: ${message2}`;
|
|
41982
42009
|
if (response.status === 403) {
|
|
41983
|
-
throw new requirement_js_1.ForbiddenException(
|
|
42010
|
+
throw new requirement_js_1.ForbiddenException(`Failed to ${action}. Status code: ${response.status}, body: ${message2}`);
|
|
41984
42011
|
}
|
|
41985
|
-
throw new requirement_js_1.RoomException(
|
|
42012
|
+
throw new requirement_js_1.RoomException(`Failed to ${action}. Status code: ${response.status}, body: ${message2}`);
|
|
41986
42013
|
}
|
|
41987
42014
|
switch (responseType) {
|
|
41988
42015
|
case "json":
|
|
@@ -41999,22 +42026,46 @@ ${newlined}
|
|
|
41999
42026
|
return void 0;
|
|
42000
42027
|
}
|
|
42001
42028
|
}
|
|
42002
|
-
|
|
42003
|
-
|
|
42004
|
-
|
|
42005
|
-
|
|
42006
|
-
|
|
42007
|
-
|
|
42008
|
-
|
|
42009
|
-
|
|
42010
|
-
|
|
42011
|
-
|
|
42012
|
-
|
|
42013
|
-
|
|
42029
|
+
secretPayload(input) {
|
|
42030
|
+
const payload = {};
|
|
42031
|
+
if (input.projectId !== void 0)
|
|
42032
|
+
payload.project_id = input.projectId;
|
|
42033
|
+
if (input.name !== void 0)
|
|
42034
|
+
payload.name = input.name;
|
|
42035
|
+
if (input.type !== void 0)
|
|
42036
|
+
payload.type = input.type;
|
|
42037
|
+
if (input.httpOnly !== void 0)
|
|
42038
|
+
payload.http_only = input.httpOnly;
|
|
42039
|
+
if (input.metadata !== void 0)
|
|
42040
|
+
payload.metadata = input.metadata;
|
|
42041
|
+
if (input.annotations !== void 0)
|
|
42042
|
+
payload.annotations = input.annotations;
|
|
42043
|
+
return payload;
|
|
42044
|
+
}
|
|
42045
|
+
secretSearchPayload(input) {
|
|
42046
|
+
const payload = {
|
|
42047
|
+
page_size: input.pageSize ?? 100
|
|
42048
|
+
};
|
|
42049
|
+
if (input.filter !== void 0)
|
|
42050
|
+
payload.filter = input.filter;
|
|
42051
|
+
if (input.name !== void 0)
|
|
42052
|
+
payload.name = input.name;
|
|
42053
|
+
if (input.type !== void 0)
|
|
42054
|
+
payload.type = input.type;
|
|
42055
|
+
if (input.httpOnly !== void 0)
|
|
42056
|
+
payload.http_only = input.httpOnly;
|
|
42057
|
+
if (input.metadata !== void 0)
|
|
42058
|
+
payload.metadata = input.metadata;
|
|
42059
|
+
if (input.annotations !== void 0)
|
|
42060
|
+
payload.annotations = input.annotations;
|
|
42061
|
+
if (input.continuationToken !== void 0)
|
|
42062
|
+
payload.continuation_token = input.continuationToken;
|
|
42063
|
+
return payload;
|
|
42064
|
+
}
|
|
42065
|
+
secretVersionPayload(input) {
|
|
42014
42066
|
return {
|
|
42015
|
-
|
|
42016
|
-
|
|
42017
|
-
settings: settings && typeof settings === "object" ? settings : {}
|
|
42067
|
+
value_base64: bytesToBase64(input.value),
|
|
42068
|
+
set_current: input.setCurrent ?? true
|
|
42018
42069
|
};
|
|
42019
42070
|
}
|
|
42020
42071
|
parseRoomSession(data) {
|
|
@@ -42044,32 +42095,33 @@ ${newlined}
|
|
|
42044
42095
|
createdAt: new Date(created),
|
|
42045
42096
|
isActive: isActiveValue,
|
|
42046
42097
|
participants: participants && typeof participants === "object" ? participants : void 0,
|
|
42047
|
-
kind: typeof kind === "string" ? kind :
|
|
42098
|
+
kind: typeof kind === "string" ? kind : void 0,
|
|
42048
42099
|
agentId: typeof agentId === "string" ? agentId : typeof agentIdRaw === "string" ? agentIdRaw : void 0,
|
|
42049
42100
|
agentName: typeof agentName === "string" ? agentName : typeof agentNameRaw === "string" ? agentNameRaw : void 0
|
|
42050
42101
|
});
|
|
42051
42102
|
}
|
|
42052
|
-
|
|
42103
|
+
parseRoom(data) {
|
|
42053
42104
|
if (!data || typeof data !== "object") {
|
|
42054
|
-
throw new requirement_js_1.RoomException("Invalid
|
|
42105
|
+
throw new requirement_js_1.RoomException("Invalid room payload");
|
|
42055
42106
|
}
|
|
42056
|
-
const { id, name,
|
|
42107
|
+
const { id, name, metadata, annotations } = data;
|
|
42057
42108
|
if (typeof id !== "string" || typeof name !== "string") {
|
|
42058
|
-
throw new requirement_js_1.RoomException("Invalid
|
|
42109
|
+
throw new requirement_js_1.RoomException("Invalid room payload: missing id or name");
|
|
42059
42110
|
}
|
|
42060
42111
|
return {
|
|
42061
42112
|
id,
|
|
42062
42113
|
name,
|
|
42063
|
-
|
|
42114
|
+
metadata: metadata && typeof metadata === "object" ? metadata : {},
|
|
42115
|
+
annotations: annotations && typeof annotations === "object" ? annotations : {}
|
|
42064
42116
|
};
|
|
42065
42117
|
}
|
|
42066
|
-
|
|
42118
|
+
parseGroup(data) {
|
|
42067
42119
|
if (!data || typeof data !== "object") {
|
|
42068
|
-
throw new requirement_js_1.RoomException("Invalid
|
|
42120
|
+
throw new requirement_js_1.RoomException("Invalid group payload");
|
|
42069
42121
|
}
|
|
42070
42122
|
const { id, name, metadata, annotations } = data;
|
|
42071
42123
|
if (typeof id !== "string" || typeof name !== "string") {
|
|
42072
|
-
throw new requirement_js_1.RoomException("Invalid
|
|
42124
|
+
throw new requirement_js_1.RoomException("Invalid group payload: missing id or name");
|
|
42073
42125
|
}
|
|
42074
42126
|
return {
|
|
42075
42127
|
id,
|
|
@@ -42190,53 +42242,99 @@ ${newlined}
|
|
|
42190
42242
|
createdAt: new Date(createdAtValue)
|
|
42191
42243
|
};
|
|
42192
42244
|
}
|
|
42193
|
-
|
|
42194
|
-
if (!
|
|
42195
|
-
throw new requirement_js_1.RoomException("Invalid
|
|
42245
|
+
parseAccessResource(resource) {
|
|
42246
|
+
if (!resource || typeof resource !== "object" || typeof resource.type !== "string" || typeof resource.id !== "string") {
|
|
42247
|
+
throw new requirement_js_1.RoomException("Invalid access resource payload");
|
|
42196
42248
|
}
|
|
42197
|
-
|
|
42198
|
-
|
|
42199
|
-
|
|
42200
|
-
|
|
42201
|
-
|
|
42202
|
-
|
|
42203
|
-
|
|
42204
|
-
const permissions = permissionsRaw && typeof permissionsRaw === "object" ? participant_token_js_1.ApiScope.fromJSON(permissionsRaw) : new participant_token_js_1.ApiScope();
|
|
42205
|
-
return { room, userId, permissions };
|
|
42249
|
+
return {
|
|
42250
|
+
type: resource.type,
|
|
42251
|
+
id: resource.id,
|
|
42252
|
+
name: typeof resource.name === "string" ? resource.name : null,
|
|
42253
|
+
metadata: resource.metadata && typeof resource.metadata === "object" ? resource.metadata : {},
|
|
42254
|
+
annotations: resource.annotations && typeof resource.annotations === "object" ? resource.annotations : {}
|
|
42255
|
+
};
|
|
42206
42256
|
}
|
|
42207
|
-
|
|
42208
|
-
|
|
42209
|
-
|
|
42210
|
-
throw new requirement_js_1.RoomException("Invalid room grant count payload: missing room");
|
|
42211
|
-
}
|
|
42212
|
-
const room = this.parseRoom(roomData);
|
|
42213
|
-
const count = data.count;
|
|
42214
|
-
if (typeof count !== "number") {
|
|
42215
|
-
throw new requirement_js_1.RoomException("Invalid room grant count payload: missing count");
|
|
42257
|
+
parseAccessSubject(subject) {
|
|
42258
|
+
if (!subject || typeof subject !== "object" || typeof subject.type !== "string" || typeof subject.id !== "string") {
|
|
42259
|
+
throw new requirement_js_1.RoomException("Invalid access subject payload");
|
|
42216
42260
|
}
|
|
42217
|
-
return {
|
|
42261
|
+
return {
|
|
42262
|
+
type: subject.type,
|
|
42263
|
+
id: subject.id,
|
|
42264
|
+
name: typeof subject.name === "string" ? subject.name : null,
|
|
42265
|
+
firstName: typeof subject.first_name === "string" ? subject.first_name : null,
|
|
42266
|
+
lastName: typeof subject.last_name === "string" ? subject.last_name : null,
|
|
42267
|
+
email: typeof subject.email === "string" ? subject.email : null,
|
|
42268
|
+
objectType: typeof subject.object_type === "string" ? subject.object_type : null,
|
|
42269
|
+
relation: typeof subject.relation === "string" ? subject.relation : null
|
|
42270
|
+
};
|
|
42271
|
+
}
|
|
42272
|
+
serializeAccessSubject(subject) {
|
|
42273
|
+
return {
|
|
42274
|
+
type: subject.type,
|
|
42275
|
+
id: subject.id,
|
|
42276
|
+
...subject.name !== void 0 ? { name: subject.name } : {},
|
|
42277
|
+
...subject.firstName !== void 0 ? { first_name: subject.firstName } : {},
|
|
42278
|
+
...subject.lastName !== void 0 ? { last_name: subject.lastName } : {},
|
|
42279
|
+
...subject.email !== void 0 ? { email: subject.email } : {},
|
|
42280
|
+
...subject.objectType !== void 0 ? { object_type: subject.objectType } : {},
|
|
42281
|
+
...subject.relation !== void 0 ? { relation: subject.relation } : {}
|
|
42282
|
+
};
|
|
42283
|
+
}
|
|
42284
|
+
serializeAccessResource(resource) {
|
|
42285
|
+
return {
|
|
42286
|
+
type: resource.type,
|
|
42287
|
+
id: resource.id,
|
|
42288
|
+
...resource.name !== void 0 ? { name: resource.name } : {},
|
|
42289
|
+
...resource.metadata !== void 0 ? { metadata: resource.metadata } : {},
|
|
42290
|
+
...resource.annotations !== void 0 ? { annotations: resource.annotations } : {}
|
|
42291
|
+
};
|
|
42218
42292
|
}
|
|
42219
|
-
|
|
42293
|
+
parseProjectMember(data) {
|
|
42220
42294
|
if (!data || typeof data !== "object") {
|
|
42221
|
-
throw new requirement_js_1.RoomException("Invalid
|
|
42295
|
+
throw new requirement_js_1.RoomException("Invalid project member payload");
|
|
42222
42296
|
}
|
|
42223
|
-
const
|
|
42224
|
-
const
|
|
42225
|
-
|
|
42226
|
-
|
|
42227
|
-
|
|
42228
|
-
|
|
42229
|
-
|
|
42297
|
+
const user = data.user && typeof data.user === "object" ? data.user : data;
|
|
42298
|
+
const directRoles = Array.isArray(data.direct_roles) ? data.direct_roles.filter((item) => item === "member" || item === "admin" || item === "developer" || item === "room_creator" || item === "agent_creator" || item === "mailbox_creator" || item === "route_creator" || item === "scheduled_task_creator" || item === "llm_proxy_user" || item === "usage_reporter" || item === "billing_manager" || item === "group_manager") : [];
|
|
42299
|
+
const id = typeof user.id === "string" ? user.id : "";
|
|
42300
|
+
const email = typeof user.email === "string" ? user.email : "";
|
|
42301
|
+
return {
|
|
42302
|
+
id,
|
|
42303
|
+
email,
|
|
42304
|
+
firstName: typeof user.first_name === "string" ? user.first_name : null,
|
|
42305
|
+
lastName: typeof user.last_name === "string" ? user.last_name : null,
|
|
42306
|
+
directRoles
|
|
42307
|
+
};
|
|
42308
|
+
}
|
|
42309
|
+
parseGroupMember(data) {
|
|
42310
|
+
if (!data || typeof data !== "object") {
|
|
42311
|
+
throw new requirement_js_1.RoomException("Invalid group member payload");
|
|
42230
42312
|
}
|
|
42231
|
-
|
|
42232
|
-
|
|
42313
|
+
const directRoles = Array.isArray(data.direct_roles) ? data.direct_roles.filter((item) => item === "member" || item === "manager") : [];
|
|
42314
|
+
return {
|
|
42315
|
+
subject: this.parseAccessSubject(data.subject),
|
|
42316
|
+
directRoles
|
|
42317
|
+
};
|
|
42318
|
+
}
|
|
42319
|
+
parseProjectRoomGrant(data) {
|
|
42320
|
+
if (!data || typeof data !== "object") {
|
|
42321
|
+
throw new requirement_js_1.RoomException("Invalid room grant payload");
|
|
42233
42322
|
}
|
|
42323
|
+
const parsedResource = this.parseAccessResource(data.resource);
|
|
42324
|
+
const parsedSubject = this.parseAccessSubject(data.subject);
|
|
42325
|
+
const parsedDirectRoles = Array.isArray(data.direct_roles) ? data.direct_roles.filter((item) => item === "member" || item === "viewer" || item === "operator" || item === "developer" || item === "admin" || item === "room_creator" || item === "room_inventory" || item === "room_manager" || item === "session_inventory" || item === "agent_creator" || item === "agent_inventory" || item === "agent_manager" || item === "repository_creator" || item === "repository_inventory" || item === "repository_manager" || item === "feed_creator" || item === "feed_inventory" || item === "feed_manager" || item === "oauth_client_creator" || item === "oauth_client_inventory" || item === "oauth_client_manager" || item === "api_key_creator" || item === "api_key_inventory" || item === "api_key_manager" || item === "service_creator" || item === "service_inventory" || item === "service_manager" || item === "service_account_creator" || item === "service_account_inventory" || item === "service_account_manager" || item === "participant_token_creator" || item === "mailbox_creator" || item === "mailbox_inventory" || item === "mailbox_manager" || item === "route_creator" || item === "route_inventory" || item === "route_manager" || item === "scheduled_task_creator" || item === "scheduled_task_inventory" || item === "scheduled_task_manager" || item === "feed_subscription_creator" || item === "feed_subscription_inventory" || item === "feed_subscription_manager" || item === "llm_logger_creator" || item === "llm_logger_inventory" || item === "llm_logger_manager" || item === "llm_proxy_user" || item === "usage_reporter" || item === "billing_manager" || item === "group_manager" || item === "reader" || item === "subscriber" || item === "publisher" || item === "manager" || item === "list") : [];
|
|
42326
|
+
const room = {
|
|
42327
|
+
id: parsedResource.id,
|
|
42328
|
+
name: parsedResource.name ?? parsedResource.id,
|
|
42329
|
+
metadata: parsedResource.metadata ?? {},
|
|
42330
|
+
annotations: parsedResource.annotations ?? {}
|
|
42331
|
+
};
|
|
42234
42332
|
return {
|
|
42235
|
-
|
|
42236
|
-
|
|
42237
|
-
|
|
42238
|
-
|
|
42239
|
-
|
|
42333
|
+
resource: parsedResource,
|
|
42334
|
+
subject: parsedSubject,
|
|
42335
|
+
directRoles: parsedDirectRoles,
|
|
42336
|
+
room,
|
|
42337
|
+
userId: parsedSubject.id
|
|
42240
42338
|
};
|
|
42241
42339
|
}
|
|
42242
42340
|
parseBalance(data) {
|
|
@@ -42285,179 +42383,13 @@ ${newlined}
|
|
|
42285
42383
|
createdAt: new Date(createdValue)
|
|
42286
42384
|
};
|
|
42287
42385
|
}
|
|
42288
|
-
parseSecret(data) {
|
|
42289
|
-
if (!data || typeof data !== "object") {
|
|
42290
|
-
throw new requirement_js_1.RoomException("Invalid secret payload");
|
|
42291
|
-
}
|
|
42292
|
-
const type = data.type;
|
|
42293
|
-
if (type === "docker") {
|
|
42294
|
-
const server = data.server;
|
|
42295
|
-
const username = data.username;
|
|
42296
|
-
const password = data.password;
|
|
42297
|
-
if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
|
|
42298
|
-
throw new requirement_js_1.RoomException("Invalid docker secret payload");
|
|
42299
|
-
}
|
|
42300
|
-
return {
|
|
42301
|
-
id: typeof data.id === "string" ? data.id : void 0,
|
|
42302
|
-
name: data.name,
|
|
42303
|
-
type: "docker",
|
|
42304
|
-
server,
|
|
42305
|
-
username,
|
|
42306
|
-
password,
|
|
42307
|
-
email: typeof data.email === "string" ? data.email : void 0
|
|
42308
|
-
};
|
|
42309
|
-
}
|
|
42310
|
-
if (type === "keys") {
|
|
42311
|
-
const record = data.data;
|
|
42312
|
-
if (!record || typeof record !== "object") {
|
|
42313
|
-
throw new requirement_js_1.RoomException("Invalid keys secret payload");
|
|
42314
|
-
}
|
|
42315
|
-
return {
|
|
42316
|
-
id: typeof data.id === "string" ? data.id : void 0,
|
|
42317
|
-
name: data.name,
|
|
42318
|
-
type: "keys",
|
|
42319
|
-
data: record
|
|
42320
|
-
};
|
|
42321
|
-
}
|
|
42322
|
-
throw new requirement_js_1.RoomException(`Unknown secret type: ${type}`);
|
|
42323
|
-
}
|
|
42324
|
-
parseManagedSecretInfo(data) {
|
|
42325
|
-
if (!data || typeof data !== "object") {
|
|
42326
|
-
throw new requirement_js_1.RoomException("Invalid managed secret payload");
|
|
42327
|
-
}
|
|
42328
|
-
const { id, type, name, delegated_to: delegatedToRaw, delegatedTo } = data;
|
|
42329
|
-
if (typeof id !== "string" || typeof type !== "string" || typeof name !== "string") {
|
|
42330
|
-
throw new requirement_js_1.RoomException("Invalid managed secret payload: missing id, type, or name");
|
|
42331
|
-
}
|
|
42332
|
-
const delegatedToValue = typeof delegatedTo === "string" ? delegatedTo : typeof delegatedToRaw === "string" ? delegatedToRaw : null;
|
|
42333
|
-
return {
|
|
42334
|
-
id,
|
|
42335
|
-
type,
|
|
42336
|
-
name,
|
|
42337
|
-
delegatedTo: delegatedToValue
|
|
42338
|
-
};
|
|
42339
|
-
}
|
|
42340
|
-
parseManagedSecret(data) {
|
|
42341
|
-
const secret = this.parseManagedSecretInfo(data);
|
|
42342
|
-
const dataBase64 = data.data_base64 ?? data.dataBase64;
|
|
42343
|
-
if (typeof dataBase64 !== "string") {
|
|
42344
|
-
throw new requirement_js_1.RoomException("Invalid managed secret payload: missing data_base64");
|
|
42345
|
-
}
|
|
42346
|
-
return {
|
|
42347
|
-
...secret,
|
|
42348
|
-
dataBase64,
|
|
42349
|
-
data: base64ToBytes(dataBase64)
|
|
42350
|
-
};
|
|
42351
|
-
}
|
|
42352
|
-
parseSecretPayload(secret, rawData) {
|
|
42353
|
-
let payload;
|
|
42354
|
-
try {
|
|
42355
|
-
payload = JSON.parse(utils_js_1.decoder.decode(rawData));
|
|
42356
|
-
} catch {
|
|
42357
|
-
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
42358
|
-
}
|
|
42359
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
42360
|
-
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
42361
|
-
}
|
|
42362
|
-
if (secret.type === "docker") {
|
|
42363
|
-
const { server, username, password, email } = payload;
|
|
42364
|
-
if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
|
|
42365
|
-
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
42366
|
-
}
|
|
42367
|
-
return {
|
|
42368
|
-
id: secret.id,
|
|
42369
|
-
name: secret.name,
|
|
42370
|
-
type: "docker",
|
|
42371
|
-
server,
|
|
42372
|
-
username,
|
|
42373
|
-
password,
|
|
42374
|
-
email: typeof email === "string" ? email : "none@example.com"
|
|
42375
|
-
};
|
|
42376
|
-
}
|
|
42377
|
-
const entries = Object.entries(payload);
|
|
42378
|
-
if (entries.some(([, value]) => typeof value !== "string")) {
|
|
42379
|
-
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
42380
|
-
}
|
|
42381
|
-
return {
|
|
42382
|
-
id: secret.id,
|
|
42383
|
-
name: secret.name,
|
|
42384
|
-
type: "keys",
|
|
42385
|
-
data: Object.fromEntries(entries)
|
|
42386
|
-
};
|
|
42387
|
-
}
|
|
42388
|
-
toSecretPayload(secret) {
|
|
42389
|
-
if (secret.type === "docker") {
|
|
42390
|
-
return {
|
|
42391
|
-
name: secret.name,
|
|
42392
|
-
type: secret.type,
|
|
42393
|
-
data: {
|
|
42394
|
-
server: secret.server,
|
|
42395
|
-
username: secret.username,
|
|
42396
|
-
password: secret.password,
|
|
42397
|
-
email: secret.email ?? "none@example.com"
|
|
42398
|
-
}
|
|
42399
|
-
};
|
|
42400
|
-
}
|
|
42401
|
-
return {
|
|
42402
|
-
name: secret.name,
|
|
42403
|
-
type: secret.type,
|
|
42404
|
-
data: { ...secret.data }
|
|
42405
|
-
};
|
|
42406
|
-
}
|
|
42407
|
-
parseConnectorRef(data) {
|
|
42408
|
-
if (data == null) {
|
|
42409
|
-
return null;
|
|
42410
|
-
}
|
|
42411
|
-
if (typeof data !== "object") {
|
|
42412
|
-
throw new requirement_js_1.RoomException("Invalid connector payload");
|
|
42413
|
-
}
|
|
42414
|
-
const { openai_connector_id: openaiConnectorIdRaw, openaiConnectorId, server_url: serverUrlRaw, serverUrl, client_secret_id: clientSecretIdRaw, clientSecretId } = data;
|
|
42415
|
-
return {
|
|
42416
|
-
openaiConnectorId: typeof openaiConnectorId === "string" ? openaiConnectorId : typeof openaiConnectorIdRaw === "string" ? openaiConnectorIdRaw : null,
|
|
42417
|
-
serverUrl: typeof serverUrl === "string" ? serverUrl : typeof serverUrlRaw === "string" ? serverUrlRaw : null,
|
|
42418
|
-
clientSecretId: typeof clientSecretId === "string" ? clientSecretId : typeof clientSecretIdRaw === "string" ? clientSecretIdRaw : null
|
|
42419
|
-
};
|
|
42420
|
-
}
|
|
42421
|
-
serializeConnectorRef(connector) {
|
|
42422
|
-
if (connector == null) {
|
|
42423
|
-
return null;
|
|
42424
|
-
}
|
|
42425
|
-
const payload = {};
|
|
42426
|
-
if (connector.openaiConnectorId) {
|
|
42427
|
-
payload.openai_connector_id = connector.openaiConnectorId;
|
|
42428
|
-
}
|
|
42429
|
-
if (connector.serverUrl) {
|
|
42430
|
-
payload.server_url = connector.serverUrl;
|
|
42431
|
-
}
|
|
42432
|
-
if (connector.clientSecretId) {
|
|
42433
|
-
payload.client_secret_id = connector.clientSecretId;
|
|
42434
|
-
}
|
|
42435
|
-
return payload;
|
|
42436
|
-
}
|
|
42437
|
-
parseExternalOAuthClientRegistration(data) {
|
|
42438
|
-
if (!data || typeof data !== "object") {
|
|
42439
|
-
throw new requirement_js_1.RoomException("Invalid external oauth registration payload");
|
|
42440
|
-
}
|
|
42441
|
-
const { id, delegated_to: delegatedToRaw, delegatedTo, connector, oauth, client_id: clientIdRaw, clientId, client_secret: clientSecretRaw, clientSecret } = data;
|
|
42442
|
-
const delegatedToValue = typeof delegatedTo === "string" ? delegatedTo : delegatedToRaw;
|
|
42443
|
-
const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
|
|
42444
|
-
const clientSecretValue = typeof clientSecret === "string" ? clientSecret : clientSecretRaw;
|
|
42445
|
-
if (typeof id !== "string" || typeof delegatedToValue !== "string" || typeof clientIdValue !== "string") {
|
|
42446
|
-
throw new requirement_js_1.RoomException("Invalid external oauth registration payload: missing fields");
|
|
42447
|
-
}
|
|
42448
|
-
return {
|
|
42449
|
-
id,
|
|
42450
|
-
delegatedTo: delegatedToValue,
|
|
42451
|
-
connector: this.parseConnectorRef(connector),
|
|
42452
|
-
oauth: oauth && typeof oauth === "object" ? oauth : null,
|
|
42453
|
-
clientId: clientIdValue,
|
|
42454
|
-
clientSecret: typeof clientSecretValue === "string" ? clientSecretValue : null
|
|
42455
|
-
};
|
|
42456
|
-
}
|
|
42457
42386
|
parseOAuthClient(data) {
|
|
42458
42387
|
if (!data || typeof data !== "object") {
|
|
42459
42388
|
throw new requirement_js_1.RoomException("Invalid OAuth client payload");
|
|
42460
42389
|
}
|
|
42390
|
+
if ("client" in data && data.client && typeof data.client === "object") {
|
|
42391
|
+
data = data.client;
|
|
42392
|
+
}
|
|
42461
42393
|
const { client_id: clientIdRaw, clientId, client_secret: clientSecretRaw, clientSecret, grant_types: grantTypesRaw, grantTypes, response_types: responseTypesRaw, responseTypes, redirect_uris: redirectUrisRaw, redirectUris, scope, project_id: projectIdRaw, projectId, metadata } = data;
|
|
42462
42394
|
const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
|
|
42463
42395
|
const clientSecretValue = typeof clientSecret === "string" ? clientSecret : clientSecretRaw;
|
|
@@ -42476,7 +42408,8 @@ ${newlined}
|
|
|
42476
42408
|
redirectUris: redirectUrisValue.map(String),
|
|
42477
42409
|
scope,
|
|
42478
42410
|
projectId: projectIdValue,
|
|
42479
|
-
metadata: metadata && typeof metadata === "object" ? metadata : {}
|
|
42411
|
+
metadata: metadata && typeof metadata === "object" ? metadata : {},
|
|
42412
|
+
official: Boolean(data.official)
|
|
42480
42413
|
};
|
|
42481
42414
|
}
|
|
42482
42415
|
parseRoomConnectionInfo(data) {
|
|
@@ -42517,45 +42450,6 @@ ${newlined}
|
|
|
42517
42450
|
responseType: "arrayBuffer"
|
|
42518
42451
|
});
|
|
42519
42452
|
}
|
|
42520
|
-
async getProjectRole(projectId) {
|
|
42521
|
-
const payload = await this.request(`/accounts/projects/${projectId}/role`, {
|
|
42522
|
-
action: "fetch project role"
|
|
42523
|
-
});
|
|
42524
|
-
const role = payload?.role;
|
|
42525
|
-
if (role !== "member" && role !== "admin" && role !== "developer") {
|
|
42526
|
-
throw new requirement_js_1.RoomException("Invalid role payload");
|
|
42527
|
-
}
|
|
42528
|
-
return role;
|
|
42529
|
-
}
|
|
42530
|
-
async createShare(projectId, settings) {
|
|
42531
|
-
return await this.request(`/accounts/projects/${projectId}/shares`, {
|
|
42532
|
-
method: "POST",
|
|
42533
|
-
json: { settings: settings ?? {} },
|
|
42534
|
-
action: "create share"
|
|
42535
|
-
});
|
|
42536
|
-
}
|
|
42537
|
-
async deleteShare(projectId, shareId) {
|
|
42538
|
-
await this.request(`/accounts/projects/${projectId}/shares/${shareId}`, {
|
|
42539
|
-
method: "DELETE",
|
|
42540
|
-
action: "delete share",
|
|
42541
|
-
responseType: "void"
|
|
42542
|
-
});
|
|
42543
|
-
}
|
|
42544
|
-
async updateShare(projectId, shareId, settings) {
|
|
42545
|
-
await this.request(`/accounts/projects/${projectId}/shares/${shareId}`, {
|
|
42546
|
-
method: "PUT",
|
|
42547
|
-
json: { settings: settings ?? {} },
|
|
42548
|
-
action: "update share",
|
|
42549
|
-
responseType: "void"
|
|
42550
|
-
});
|
|
42551
|
-
}
|
|
42552
|
-
async listShares(projectId) {
|
|
42553
|
-
const data = await this.request(`/accounts/projects/${projectId}/shares`, {
|
|
42554
|
-
action: "list shares"
|
|
42555
|
-
});
|
|
42556
|
-
const shares = Array.isArray(data?.shares) ? data.shares : [];
|
|
42557
|
-
return shares.map((item) => this.parseRoomShare(item));
|
|
42558
|
-
}
|
|
42559
42453
|
async createProject(name, settings) {
|
|
42560
42454
|
return await this.request(`/accounts/projects`, {
|
|
42561
42455
|
method: "POST",
|
|
@@ -42564,30 +42458,14 @@ ${newlined}
|
|
|
42564
42458
|
});
|
|
42565
42459
|
}
|
|
42566
42460
|
async addUserToProject(projectId, userId, options = {}) {
|
|
42567
|
-
const {
|
|
42461
|
+
const { roles = ["member"], email, inviteRedirectUrl } = options;
|
|
42568
42462
|
return await this.request(`/accounts/projects/${projectId}/users`, {
|
|
42569
42463
|
method: "POST",
|
|
42570
42464
|
json: {
|
|
42571
42465
|
project_id: projectId,
|
|
42572
42466
|
user_id: userId,
|
|
42573
|
-
|
|
42574
|
-
...
|
|
42575
|
-
...canCreateRooms !== void 0 ? { can_create_rooms: canCreateRooms } : {},
|
|
42576
|
-
...inviteRedirectUrl !== void 0 ? { invite_redirect_url: inviteRedirectUrl } : {}
|
|
42577
|
-
},
|
|
42578
|
-
action: "add user to project"
|
|
42579
|
-
});
|
|
42580
|
-
}
|
|
42581
|
-
async addUserToProjectByEmail(projectId, email, options = {}) {
|
|
42582
|
-
const { isAdmin, isDeveloper, canCreateRooms, inviteRedirectUrl } = options;
|
|
42583
|
-
return await this.request(`/accounts/projects/${projectId}/users`, {
|
|
42584
|
-
method: "POST",
|
|
42585
|
-
json: {
|
|
42586
|
-
project_id: projectId,
|
|
42587
|
-
email,
|
|
42588
|
-
...isAdmin !== void 0 ? { is_admin: isAdmin } : {},
|
|
42589
|
-
...isDeveloper !== void 0 ? { is_developer: isDeveloper } : {},
|
|
42590
|
-
...canCreateRooms !== void 0 ? { can_create_rooms: canCreateRooms } : {},
|
|
42467
|
+
roles,
|
|
42468
|
+
...email !== void 0 ? { email } : {},
|
|
42591
42469
|
...inviteRedirectUrl !== void 0 ? { invite_redirect_url: inviteRedirectUrl } : {}
|
|
42592
42470
|
},
|
|
42593
42471
|
action: "add user to project"
|
|
@@ -42606,18 +42484,25 @@ ${newlined}
|
|
|
42606
42484
|
action: "update project settings"
|
|
42607
42485
|
});
|
|
42608
42486
|
}
|
|
42487
|
+
async updateUserInProject(projectId, userId, roles) {
|
|
42488
|
+
return await this.request(`/accounts/projects/${projectId}/users/${userId}`, {
|
|
42489
|
+
method: "PUT",
|
|
42490
|
+
json: { roles },
|
|
42491
|
+
action: "update project user"
|
|
42492
|
+
});
|
|
42493
|
+
}
|
|
42609
42494
|
async getUsersInProjectPage(projectId, options = {}) {
|
|
42610
|
-
const {
|
|
42495
|
+
const { pageSize = 100, continuationToken, filter, email } = options;
|
|
42611
42496
|
const data = await this.request(`/accounts/projects/${projectId}/users`, {
|
|
42612
|
-
query: {
|
|
42497
|
+
query: { page_size: pageSize, continuation_token: continuationToken, filter, email },
|
|
42613
42498
|
action: "fetch project users"
|
|
42614
42499
|
});
|
|
42615
42500
|
const users = Array.isArray(data?.users) ? data.users : [];
|
|
42616
|
-
return { users
|
|
42501
|
+
return { users: users.map((user) => this.parseProjectMember(user)), continuationToken: data?.continuation_token ?? null };
|
|
42617
42502
|
}
|
|
42618
42503
|
async getUsersInProject(projectId) {
|
|
42619
42504
|
const page = await this.getUsersInProjectPage(projectId);
|
|
42620
|
-
return
|
|
42505
|
+
return page.users;
|
|
42621
42506
|
}
|
|
42622
42507
|
async getUserProfile(userId) {
|
|
42623
42508
|
return await this.request(`/accounts/profiles/${userId}`, {
|
|
@@ -42646,96 +42531,291 @@ ${newlined}
|
|
|
42646
42531
|
action: "get project by key"
|
|
42647
42532
|
});
|
|
42648
42533
|
}
|
|
42649
|
-
async
|
|
42650
|
-
const
|
|
42651
|
-
|
|
42652
|
-
|
|
42534
|
+
async listServiceAccounts(projectId, options = {}) {
|
|
42535
|
+
const params = new URLSearchParams();
|
|
42536
|
+
if (options.pageSize !== void 0)
|
|
42537
|
+
params.set("page_size", String(options.pageSize));
|
|
42538
|
+
if (options.continuationToken !== void 0)
|
|
42539
|
+
params.set("continuation_token", options.continuationToken);
|
|
42540
|
+
if (options.filter !== void 0)
|
|
42541
|
+
params.set("filter", options.filter);
|
|
42542
|
+
if (options.view !== void 0)
|
|
42543
|
+
params.set("view", options.view);
|
|
42544
|
+
const query = params.toString();
|
|
42545
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts${query ? `?${query}` : ""}`, {
|
|
42546
|
+
action: "list service accounts"
|
|
42547
|
+
});
|
|
42548
|
+
}
|
|
42549
|
+
async createServiceAccount(projectId, name, options = {}) {
|
|
42550
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts`, {
|
|
42653
42551
|
method: "POST",
|
|
42654
|
-
json: {
|
|
42655
|
-
|
|
42656
|
-
|
|
42657
|
-
|
|
42658
|
-
|
|
42659
|
-
|
|
42552
|
+
json: { name, ...options },
|
|
42553
|
+
action: "create service account"
|
|
42554
|
+
});
|
|
42555
|
+
}
|
|
42556
|
+
async mintParticipantToken(projectId, options) {
|
|
42557
|
+
const json = options.grants !== void 0 ? { name: options.name, grants: options.grants } : {
|
|
42558
|
+
name: options.name,
|
|
42559
|
+
room_name: options.roomName,
|
|
42560
|
+
role: options.role,
|
|
42561
|
+
api: options.api
|
|
42562
|
+
};
|
|
42563
|
+
const data = await this.request(`/accounts/projects/${projectId}/participant-tokens`, {
|
|
42564
|
+
method: "POST",
|
|
42565
|
+
json,
|
|
42566
|
+
action: "mint participant token"
|
|
42660
42567
|
});
|
|
42661
|
-
|
|
42568
|
+
if (typeof data?.token !== "string" || data.token.trim() === "") {
|
|
42569
|
+
throw new Error("Invalid participant token mint response");
|
|
42570
|
+
}
|
|
42571
|
+
return data.token;
|
|
42662
42572
|
}
|
|
42663
|
-
async createApiKey(projectId, name, description) {
|
|
42664
|
-
return await this.request(`/accounts/projects/${projectId}/api-keys`, {
|
|
42573
|
+
async createApiKey(projectId, serviceAccountId, name, description) {
|
|
42574
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/api-keys`, {
|
|
42665
42575
|
method: "POST",
|
|
42666
42576
|
json: { name, description },
|
|
42667
42577
|
action: "create api key"
|
|
42668
42578
|
});
|
|
42669
42579
|
}
|
|
42670
|
-
async deleteApiKey(projectId, id) {
|
|
42671
|
-
await this.request(`/accounts/projects/${projectId}/api-keys/${id}`, {
|
|
42580
|
+
async deleteApiKey(projectId, serviceAccountId, id) {
|
|
42581
|
+
await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/api-keys/${id}`, {
|
|
42672
42582
|
method: "DELETE",
|
|
42673
42583
|
action: "delete api key",
|
|
42674
42584
|
responseType: "void"
|
|
42675
42585
|
});
|
|
42676
42586
|
}
|
|
42677
|
-
async
|
|
42678
|
-
return await this.request(`/accounts/projects/${projectId}/api-keys`, {
|
|
42587
|
+
async revokeApiKeysByMsid(projectId, serviceAccountId, msid) {
|
|
42588
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/api-keys:revoke`, {
|
|
42589
|
+
method: "POST",
|
|
42590
|
+
json: { msid },
|
|
42591
|
+
action: "revoke api keys"
|
|
42592
|
+
});
|
|
42593
|
+
}
|
|
42594
|
+
async listApiKeys(projectId, serviceAccountId) {
|
|
42595
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/api-keys`, {
|
|
42679
42596
|
action: "list api keys"
|
|
42680
42597
|
});
|
|
42681
42598
|
}
|
|
42682
|
-
async
|
|
42683
|
-
return await this.request(`/
|
|
42684
|
-
|
|
42599
|
+
async createUserSecret(input) {
|
|
42600
|
+
return await this.request(`/accounts/users/me/secrets`, {
|
|
42601
|
+
method: "POST",
|
|
42602
|
+
json: this.secretPayload(input),
|
|
42603
|
+
action: "create user secret"
|
|
42685
42604
|
});
|
|
42686
42605
|
}
|
|
42687
|
-
async
|
|
42688
|
-
|
|
42689
|
-
|
|
42606
|
+
async listUserSecrets(options = {}) {
|
|
42607
|
+
return await this.request(`/accounts/users/me/secrets`, {
|
|
42608
|
+
query: {
|
|
42609
|
+
page_size: options.pageSize ?? 100,
|
|
42610
|
+
continuation_token: options.continuationToken,
|
|
42611
|
+
filter: options.filter
|
|
42612
|
+
},
|
|
42613
|
+
action: "list user secrets"
|
|
42690
42614
|
});
|
|
42691
|
-
const enabled = data?.["enabled"];
|
|
42692
|
-
if (typeof enabled !== "boolean") {
|
|
42693
|
-
throw new requirement_js_1.RoomException("Invalid status payload: expected boolean 'enabled'");
|
|
42694
|
-
}
|
|
42695
|
-
return enabled;
|
|
42696
42615
|
}
|
|
42697
|
-
async
|
|
42698
|
-
|
|
42699
|
-
|
|
42616
|
+
async searchUserSecrets(input = {}) {
|
|
42617
|
+
return await this.request(`/accounts/users/me/secrets:search`, {
|
|
42618
|
+
method: "POST",
|
|
42619
|
+
json: this.secretSearchPayload(input),
|
|
42620
|
+
action: "search user secrets"
|
|
42700
42621
|
});
|
|
42701
|
-
return this.parseBalance(data);
|
|
42702
42622
|
}
|
|
42703
|
-
async
|
|
42704
|
-
|
|
42705
|
-
|
|
42623
|
+
async getUserSecret(secretId, options = {}) {
|
|
42624
|
+
return await this.request(`/accounts/users/me/secrets/${secretId}`, {
|
|
42625
|
+
query: {
|
|
42626
|
+
include_value: options.includeValue ? "true" : void 0
|
|
42627
|
+
},
|
|
42628
|
+
action: "get user secret"
|
|
42706
42629
|
});
|
|
42707
|
-
const list = Array.isArray(data?.transactions) ? data.transactions : [];
|
|
42708
|
-
return list.map((item) => this.parseTransaction(item));
|
|
42709
42630
|
}
|
|
42710
|
-
async
|
|
42711
|
-
await this.request(`/accounts/
|
|
42712
|
-
method: "
|
|
42713
|
-
json:
|
|
42714
|
-
action: "update
|
|
42631
|
+
async updateUserSecret(secretId, input) {
|
|
42632
|
+
return await this.request(`/accounts/users/me/secrets/${secretId}`, {
|
|
42633
|
+
method: "PATCH",
|
|
42634
|
+
json: this.secretPayload(input),
|
|
42635
|
+
action: "update user secret"
|
|
42636
|
+
});
|
|
42637
|
+
}
|
|
42638
|
+
async deleteUserSecret(secretId) {
|
|
42639
|
+
await this.request(`/accounts/users/me/secrets/${secretId}`, {
|
|
42640
|
+
method: "DELETE",
|
|
42641
|
+
action: "delete user secret",
|
|
42715
42642
|
responseType: "void"
|
|
42716
42643
|
});
|
|
42717
42644
|
}
|
|
42718
|
-
async
|
|
42719
|
-
const
|
|
42720
|
-
|
|
42721
|
-
json: { success_url: successUrl, cancel_url: cancelUrl },
|
|
42722
|
-
action: "create subscription checkout"
|
|
42645
|
+
async listUserSecretVersions(secretId) {
|
|
42646
|
+
const page = await this.request(`/accounts/users/me/secrets/${secretId}/versions`, {
|
|
42647
|
+
action: "list user secret versions"
|
|
42723
42648
|
});
|
|
42724
|
-
|
|
42725
|
-
if (typeof url !== "string") {
|
|
42726
|
-
throw new requirement_js_1.RoomException("Invalid subscription payload: expected 'checkout_url' string");
|
|
42727
|
-
}
|
|
42728
|
-
return url;
|
|
42649
|
+
return page.versions;
|
|
42729
42650
|
}
|
|
42730
|
-
async
|
|
42731
|
-
|
|
42651
|
+
async createUserSecretVersion(secretId, input) {
|
|
42652
|
+
return await this.request(`/accounts/users/me/secrets/${secretId}/versions`, {
|
|
42732
42653
|
method: "POST",
|
|
42733
|
-
json:
|
|
42734
|
-
action: "create
|
|
42654
|
+
json: this.secretVersionPayload(input),
|
|
42655
|
+
action: "create user secret version"
|
|
42735
42656
|
});
|
|
42736
|
-
|
|
42737
|
-
|
|
42738
|
-
|
|
42657
|
+
}
|
|
42658
|
+
async listUserSecretProxyAccess(secretId, options = {}) {
|
|
42659
|
+
return await this.request(`/accounts/users/me/secrets/${secretId}/access`, {
|
|
42660
|
+
query: {
|
|
42661
|
+
page_size: options.pageSize ?? 100,
|
|
42662
|
+
continuation_token: options.continuationToken
|
|
42663
|
+
},
|
|
42664
|
+
action: "list user secret proxy access"
|
|
42665
|
+
});
|
|
42666
|
+
}
|
|
42667
|
+
async grantUserSecretProxyAccess(secretId, serviceAccountId) {
|
|
42668
|
+
await this.request(`/accounts/users/me/secrets/${secretId}/access:grant-proxy`, {
|
|
42669
|
+
method: "POST",
|
|
42670
|
+
json: { subject: { type: "service_account", id: serviceAccountId } },
|
|
42671
|
+
action: "grant user secret proxy access",
|
|
42672
|
+
responseType: "void"
|
|
42673
|
+
});
|
|
42674
|
+
}
|
|
42675
|
+
async revokeUserSecretProxyAccess(secretId, serviceAccountId) {
|
|
42676
|
+
await this.request(`/accounts/users/me/secrets/${secretId}/access:revoke-proxy`, {
|
|
42677
|
+
method: "POST",
|
|
42678
|
+
json: { subject: { type: "service_account", id: serviceAccountId } },
|
|
42679
|
+
action: "revoke user secret proxy access",
|
|
42680
|
+
responseType: "void"
|
|
42681
|
+
});
|
|
42682
|
+
}
|
|
42683
|
+
async createServiceAccountSecret(projectId, serviceAccountId, input) {
|
|
42684
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/secrets`, {
|
|
42685
|
+
method: "POST",
|
|
42686
|
+
json: this.secretPayload(input),
|
|
42687
|
+
action: "create service account secret"
|
|
42688
|
+
});
|
|
42689
|
+
}
|
|
42690
|
+
async listServiceAccountSecrets(projectId, serviceAccountId, options = {}) {
|
|
42691
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/secrets`, {
|
|
42692
|
+
query: {
|
|
42693
|
+
page_size: options.pageSize ?? 100,
|
|
42694
|
+
continuation_token: options.continuationToken,
|
|
42695
|
+
filter: options.filter
|
|
42696
|
+
},
|
|
42697
|
+
action: "list service account secrets"
|
|
42698
|
+
});
|
|
42699
|
+
}
|
|
42700
|
+
async searchServiceAccountSecrets(projectId, serviceAccountId, input = {}) {
|
|
42701
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/secrets:search`, {
|
|
42702
|
+
method: "POST",
|
|
42703
|
+
json: this.secretSearchPayload(input),
|
|
42704
|
+
action: "search service account secrets"
|
|
42705
|
+
});
|
|
42706
|
+
}
|
|
42707
|
+
async getServiceAccountSecret(projectId, serviceAccountId, secretId, options = {}) {
|
|
42708
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/secrets/${secretId}`, {
|
|
42709
|
+
query: {
|
|
42710
|
+
include_value: options.includeValue ? "true" : void 0
|
|
42711
|
+
},
|
|
42712
|
+
action: "get service account secret"
|
|
42713
|
+
});
|
|
42714
|
+
}
|
|
42715
|
+
async updateServiceAccountSecret(projectId, serviceAccountId, secretId, input) {
|
|
42716
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/secrets/${secretId}`, {
|
|
42717
|
+
method: "PATCH",
|
|
42718
|
+
json: this.secretPayload(input),
|
|
42719
|
+
action: "update service account secret"
|
|
42720
|
+
});
|
|
42721
|
+
}
|
|
42722
|
+
async deleteServiceAccountSecret(projectId, serviceAccountId, secretId) {
|
|
42723
|
+
await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/secrets/${secretId}`, {
|
|
42724
|
+
method: "DELETE",
|
|
42725
|
+
action: "delete service account secret",
|
|
42726
|
+
responseType: "void"
|
|
42727
|
+
});
|
|
42728
|
+
}
|
|
42729
|
+
async listServiceAccountSecretVersions(projectId, serviceAccountId, secretId) {
|
|
42730
|
+
const page = await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/secrets/${secretId}/versions`, {
|
|
42731
|
+
action: "list service account secret versions"
|
|
42732
|
+
});
|
|
42733
|
+
return page.versions;
|
|
42734
|
+
}
|
|
42735
|
+
async createServiceAccountSecretVersion(projectId, serviceAccountId, secretId, input) {
|
|
42736
|
+
return await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/secrets/${secretId}/versions`, {
|
|
42737
|
+
method: "POST",
|
|
42738
|
+
json: this.secretVersionPayload(input),
|
|
42739
|
+
action: "create service account secret version"
|
|
42740
|
+
});
|
|
42741
|
+
}
|
|
42742
|
+
async listServiceAccountPullSecrets(projectId, serviceAccountId) {
|
|
42743
|
+
const page = await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/pull-secrets`, {
|
|
42744
|
+
action: "list service account pull secrets"
|
|
42745
|
+
});
|
|
42746
|
+
return page.secrets;
|
|
42747
|
+
}
|
|
42748
|
+
async addServiceAccountPullSecret(projectId, serviceAccountId, secretId) {
|
|
42749
|
+
await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/pull-secrets/${secretId}`, {
|
|
42750
|
+
method: "PUT",
|
|
42751
|
+
action: "add service account pull secret",
|
|
42752
|
+
responseType: "void"
|
|
42753
|
+
});
|
|
42754
|
+
}
|
|
42755
|
+
async removeServiceAccountPullSecret(projectId, serviceAccountId, secretId) {
|
|
42756
|
+
await this.request(`/accounts/projects/${projectId}/service-accounts/${serviceAccountId}/pull-secrets/${secretId}`, {
|
|
42757
|
+
method: "DELETE",
|
|
42758
|
+
action: "remove service account pull secret",
|
|
42759
|
+
responseType: "void"
|
|
42760
|
+
});
|
|
42761
|
+
}
|
|
42762
|
+
async getPricing() {
|
|
42763
|
+
return await this.request(`/pricing`, {
|
|
42764
|
+
action: "fetch pricing data"
|
|
42765
|
+
});
|
|
42766
|
+
}
|
|
42767
|
+
async getStatus(projectId) {
|
|
42768
|
+
const data = await this.request(`/accounts/projects/${projectId}/status`, {
|
|
42769
|
+
action: "fetch project status"
|
|
42770
|
+
});
|
|
42771
|
+
const enabled = data?.["enabled"];
|
|
42772
|
+
if (typeof enabled !== "boolean") {
|
|
42773
|
+
throw new requirement_js_1.RoomException("Invalid status payload: expected boolean 'enabled'");
|
|
42774
|
+
}
|
|
42775
|
+
return enabled;
|
|
42776
|
+
}
|
|
42777
|
+
async getBalance(projectId) {
|
|
42778
|
+
const data = await this.request(`/accounts/projects/${projectId}/balance`, {
|
|
42779
|
+
action: "fetch balance"
|
|
42780
|
+
});
|
|
42781
|
+
return this.parseBalance(data);
|
|
42782
|
+
}
|
|
42783
|
+
async getRecentTransactions(projectId) {
|
|
42784
|
+
const data = await this.request(`/accounts/projects/${projectId}/transactions`, {
|
|
42785
|
+
action: "fetch transactions"
|
|
42786
|
+
});
|
|
42787
|
+
const list = Array.isArray(data?.transactions) ? data.transactions : [];
|
|
42788
|
+
return list.map((item) => this.parseTransaction(item));
|
|
42789
|
+
}
|
|
42790
|
+
async setAutoRecharge({ projectId, enabled, amount, threshold, monthlyBudget = null }) {
|
|
42791
|
+
await this.request(`/accounts/projects/${projectId}/recharge`, {
|
|
42792
|
+
method: "POST",
|
|
42793
|
+
json: { enabled, amount, threshold, monthly_budget: monthlyBudget },
|
|
42794
|
+
action: "update auto recharge settings",
|
|
42795
|
+
responseType: "void"
|
|
42796
|
+
});
|
|
42797
|
+
}
|
|
42798
|
+
async getCheckoutUrl(projectId, { successUrl, cancelUrl }) {
|
|
42799
|
+
const data = await this.request(`/accounts/projects/${projectId}/subscription`, {
|
|
42800
|
+
method: "POST",
|
|
42801
|
+
json: { success_url: successUrl, cancel_url: cancelUrl },
|
|
42802
|
+
action: "create subscription checkout"
|
|
42803
|
+
});
|
|
42804
|
+
const url = data?.["checkout_url"];
|
|
42805
|
+
if (typeof url !== "string") {
|
|
42806
|
+
throw new requirement_js_1.RoomException("Invalid subscription payload: expected 'checkout_url' string");
|
|
42807
|
+
}
|
|
42808
|
+
return url;
|
|
42809
|
+
}
|
|
42810
|
+
async getCreditsCheckoutUrl(projectId, { successUrl, cancelUrl, quantity }) {
|
|
42811
|
+
const data = await this.request(`/accounts/projects/${projectId}/credits`, {
|
|
42812
|
+
method: "POST",
|
|
42813
|
+
json: { success_url: successUrl, cancel_url: cancelUrl, quantity },
|
|
42814
|
+
action: "create credits checkout"
|
|
42815
|
+
});
|
|
42816
|
+
const url = data?.["checkout_url"];
|
|
42817
|
+
if (typeof url !== "string") {
|
|
42818
|
+
throw new requirement_js_1.RoomException("Invalid credits payload: expected 'checkout_url' string");
|
|
42739
42819
|
}
|
|
42740
42820
|
return url;
|
|
42741
42821
|
}
|
|
@@ -42787,6 +42867,40 @@ ${newlined}
|
|
|
42787
42867
|
const sessions = Array.isArray(data?.sessions) ? data.sessions : [];
|
|
42788
42868
|
return sessions.map((item) => this.parseRoomSession(item));
|
|
42789
42869
|
}
|
|
42870
|
+
async listRecentRoomSessions(projectId, roomName, options = {}) {
|
|
42871
|
+
const params = new URLSearchParams();
|
|
42872
|
+
if (options.limit !== void 0) {
|
|
42873
|
+
params.set("limit", String(options.limit));
|
|
42874
|
+
}
|
|
42875
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
42876
|
+
const data = await this.request(`/accounts/projects/${projectId}/rooms/${encodeURIComponent(roomName)}/sessions${query}`, { action: "list recent room sessions" });
|
|
42877
|
+
const sessions = Array.isArray(data?.sessions) ? data.sessions : [];
|
|
42878
|
+
return sessions.map((item) => this.parseRoomSession(item));
|
|
42879
|
+
}
|
|
42880
|
+
async listRecentSingleAgentSessions(projectId, agentName, options = {}) {
|
|
42881
|
+
const params = new URLSearchParams();
|
|
42882
|
+
if (options.limit !== void 0) {
|
|
42883
|
+
params.set("limit", String(options.limit));
|
|
42884
|
+
}
|
|
42885
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
42886
|
+
const data = await this.request(`/accounts/projects/${projectId}/agents/${encodeURIComponent(agentName)}/sessions${query}`, { action: "list recent agent sessions" });
|
|
42887
|
+
const sessions = Array.isArray(data?.sessions) ? data.sessions : [];
|
|
42888
|
+
return sessions.map((item) => this.parseRoomSession(item));
|
|
42889
|
+
}
|
|
42890
|
+
async createAgent(params) {
|
|
42891
|
+
const body = {
|
|
42892
|
+
configuration: params.configuration,
|
|
42893
|
+
if_not_exists: params.ifNotExists ?? false
|
|
42894
|
+
};
|
|
42895
|
+
if (params.permissions != null) {
|
|
42896
|
+
body.permissions = params.permissions;
|
|
42897
|
+
}
|
|
42898
|
+
return await this.request(`/accounts/projects/${params.projectId}/agents`, {
|
|
42899
|
+
method: "POST",
|
|
42900
|
+
json: body,
|
|
42901
|
+
action: "create agent"
|
|
42902
|
+
});
|
|
42903
|
+
}
|
|
42790
42904
|
async listSessionEvents(projectId, sessionId) {
|
|
42791
42905
|
const data = await this.request(`/accounts/projects/${projectId}/sessions/${sessionId}/events`, {
|
|
42792
42906
|
action: "list session events"
|
|
@@ -42815,34 +42929,6 @@ ${newlined}
|
|
|
42815
42929
|
const metrics = data?.["metrics"];
|
|
42816
42930
|
return Array.isArray(metrics) ? metrics : [];
|
|
42817
42931
|
}
|
|
42818
|
-
async createWebhook(projectId, params) {
|
|
42819
|
-
const { name, url, events, description = "", action: webhookAction = "", payload = null } = params;
|
|
42820
|
-
return await this.request(`/accounts/projects/${projectId}/webhooks`, {
|
|
42821
|
-
method: "POST",
|
|
42822
|
-
json: { name, description, url, events, action: webhookAction, payload },
|
|
42823
|
-
action: "create webhook"
|
|
42824
|
-
});
|
|
42825
|
-
}
|
|
42826
|
-
async updateWebhook(projectId, webhookId, params) {
|
|
42827
|
-
const { name, url, events, description = "", action: webhookAction = null, payload = null } = params;
|
|
42828
|
-
return await this.request(`/accounts/projects/${projectId}/webhooks/${webhookId}`, {
|
|
42829
|
-
method: "PUT",
|
|
42830
|
-
json: { name, description, url, events, action: webhookAction, payload },
|
|
42831
|
-
action: "update webhook"
|
|
42832
|
-
});
|
|
42833
|
-
}
|
|
42834
|
-
async listWebhooks(projectId) {
|
|
42835
|
-
return await this.request(`/accounts/projects/${projectId}/webhooks`, {
|
|
42836
|
-
action: "list webhooks"
|
|
42837
|
-
});
|
|
42838
|
-
}
|
|
42839
|
-
async deleteWebhook(projectId, webhookId) {
|
|
42840
|
-
await this.request(`/accounts/projects/${projectId}/webhooks/${webhookId}`, {
|
|
42841
|
-
method: "DELETE",
|
|
42842
|
-
action: "delete webhook",
|
|
42843
|
-
responseType: "void"
|
|
42844
|
-
});
|
|
42845
|
-
}
|
|
42846
42932
|
async createMailbox(params) {
|
|
42847
42933
|
const { projectId, address, room, queue, isPublic } = params;
|
|
42848
42934
|
await this.request(`/accounts/projects/${projectId}/mailboxes`, {
|
|
@@ -42875,18 +42961,24 @@ ${newlined}
|
|
|
42875
42961
|
return { address, room, roomId: room_id, queue };
|
|
42876
42962
|
}
|
|
42877
42963
|
async listMailboxesPage(projectId, options = {}) {
|
|
42878
|
-
const {
|
|
42964
|
+
const { pageSize = 100, continuationToken, filter } = options;
|
|
42879
42965
|
const data = await this.request(`/accounts/projects/${projectId}/mailboxes`, {
|
|
42880
|
-
query: {
|
|
42966
|
+
query: { page_size: pageSize, continuation_token: continuationToken, filter },
|
|
42881
42967
|
action: "list mailboxes"
|
|
42882
42968
|
});
|
|
42883
42969
|
const mailboxes = Array.isArray(data?.mailboxes) ? data.mailboxes : [];
|
|
42884
42970
|
const parsed = mailboxes.map((item) => this.parseMailbox(item));
|
|
42885
|
-
return { mailboxes: parsed, total: typeof data?.total === "number" ? data.total : parsed.length };
|
|
42971
|
+
return { mailboxes: parsed, total: typeof data?.total === "number" ? data.total : parsed.length, continuationToken: data.continuation_token ?? null };
|
|
42886
42972
|
}
|
|
42887
42973
|
async listMailboxes(projectId, options = {}) {
|
|
42888
|
-
const
|
|
42889
|
-
|
|
42974
|
+
const mailboxes = [];
|
|
42975
|
+
let continuationToken;
|
|
42976
|
+
do {
|
|
42977
|
+
const page = await this.listMailboxesPage(projectId, { ...options, continuationToken });
|
|
42978
|
+
mailboxes.push(...page.mailboxes);
|
|
42979
|
+
continuationToken = page.continuationToken ?? void 0;
|
|
42980
|
+
} while (continuationToken);
|
|
42981
|
+
return mailboxes;
|
|
42890
42982
|
}
|
|
42891
42983
|
async deleteMailbox(projectId, address) {
|
|
42892
42984
|
await this.request(`/accounts/projects/${projectId}/mailboxes/${address}`, {
|
|
@@ -42933,18 +43025,24 @@ ${newlined}
|
|
|
42933
43025
|
return this.parseFeed(data.feed);
|
|
42934
43026
|
}
|
|
42935
43027
|
async listFeedsPage(projectId, options = {}) {
|
|
42936
|
-
const {
|
|
43028
|
+
const { pageSize = 100, continuationToken, filter, view } = options;
|
|
42937
43029
|
const data = await this.request(`/accounts/projects/${projectId}/feeds`, {
|
|
42938
|
-
query: {
|
|
43030
|
+
query: { page_size: pageSize, continuation_token: continuationToken, filter, view },
|
|
42939
43031
|
action: "list feeds"
|
|
42940
43032
|
});
|
|
42941
43033
|
const feeds = Array.isArray(data?.feeds) ? data.feeds : [];
|
|
42942
43034
|
const parsed = feeds.map((item) => this.parseFeed(item));
|
|
42943
|
-
return { feeds: parsed, total: typeof data?.total === "number" ? data.total : parsed.length };
|
|
43035
|
+
return { feeds: parsed, total: typeof data?.total === "number" ? data.total : parsed.length, continuationToken: data.continuation_token ?? null };
|
|
42944
43036
|
}
|
|
42945
43037
|
async listFeeds(projectId, options = {}) {
|
|
42946
|
-
const
|
|
42947
|
-
|
|
43038
|
+
const feeds = [];
|
|
43039
|
+
let continuationToken;
|
|
43040
|
+
do {
|
|
43041
|
+
const page = await this.listFeedsPage(projectId, { ...options, continuationToken });
|
|
43042
|
+
feeds.push(...page.feeds);
|
|
43043
|
+
continuationToken = page.continuationToken ?? void 0;
|
|
43044
|
+
} while (continuationToken);
|
|
43045
|
+
return feeds;
|
|
42948
43046
|
}
|
|
42949
43047
|
async listRoomFeedsPage(projectId, roomName, options = {}) {
|
|
42950
43048
|
const { count = 100, offset = 0, filter } = options;
|
|
@@ -43103,12 +43201,28 @@ ${newlined}
|
|
|
43103
43201
|
});
|
|
43104
43202
|
return this.parseProjectRepository(data);
|
|
43105
43203
|
}
|
|
43106
|
-
async
|
|
43204
|
+
async listRepositoriesPage(projectId, options = {}) {
|
|
43205
|
+
const { pageSize = 100, view, continuationToken } = options;
|
|
43107
43206
|
const data = await this.request(`/accounts/projects/${projectId}/repositories`, {
|
|
43207
|
+
query: { page_size: pageSize, view, continuation_token: continuationToken },
|
|
43108
43208
|
action: "list repositories"
|
|
43109
43209
|
});
|
|
43110
43210
|
const repositories = Array.isArray(data?.repositories) ? data.repositories : [];
|
|
43111
|
-
return
|
|
43211
|
+
return {
|
|
43212
|
+
repositories: repositories.map((item) => this.parseProjectRepository(item)),
|
|
43213
|
+
total: Number(data.total ?? repositories.length),
|
|
43214
|
+
continuationToken: data.continuation_token ?? null
|
|
43215
|
+
};
|
|
43216
|
+
}
|
|
43217
|
+
async listRepositories(projectId, options = {}) {
|
|
43218
|
+
const repositories = [];
|
|
43219
|
+
let continuationToken;
|
|
43220
|
+
do {
|
|
43221
|
+
const page = await this.listRepositoriesPage(projectId, { view: options.view, continuationToken });
|
|
43222
|
+
repositories.push(...page.repositories);
|
|
43223
|
+
continuationToken = page.continuationToken ?? void 0;
|
|
43224
|
+
} while (continuationToken);
|
|
43225
|
+
return repositories;
|
|
43112
43226
|
}
|
|
43113
43227
|
async deleteRepository(projectId, repositoryId) {
|
|
43114
43228
|
await this.request(`/accounts/projects/${projectId}/repositories/${repositoryId}`, {
|
|
@@ -43198,279 +43312,14 @@ ${newlined}
|
|
|
43198
43312
|
responseType: "void"
|
|
43199
43313
|
});
|
|
43200
43314
|
}
|
|
43201
|
-
async createProjectSecret(params) {
|
|
43202
|
-
const { projectId, name, type, data } = params;
|
|
43203
|
-
const payload = await this.request(`/accounts/projects/${projectId}/secrets`, {
|
|
43204
|
-
method: "POST",
|
|
43205
|
-
json: {
|
|
43206
|
-
name,
|
|
43207
|
-
type,
|
|
43208
|
-
data_base64: bytesToBase64(normalizeBinary(data))
|
|
43209
|
-
},
|
|
43210
|
-
action: "create project secret"
|
|
43211
|
-
});
|
|
43212
|
-
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
43213
|
-
throw new requirement_js_1.RoomException("Invalid create project secret response payload");
|
|
43214
|
-
}
|
|
43215
|
-
return payload.id;
|
|
43216
|
-
}
|
|
43217
|
-
async updateProjectSecret(params) {
|
|
43218
|
-
const { projectId, secretId, name, type, data } = params;
|
|
43219
|
-
await this.request(`/accounts/projects/${projectId}/secrets/${secretId}`, {
|
|
43220
|
-
method: "PUT",
|
|
43221
|
-
json: {
|
|
43222
|
-
name,
|
|
43223
|
-
type,
|
|
43224
|
-
data_base64: bytesToBase64(normalizeBinary(data))
|
|
43225
|
-
},
|
|
43226
|
-
action: "update project secret",
|
|
43227
|
-
responseType: "void"
|
|
43228
|
-
});
|
|
43229
|
-
}
|
|
43230
|
-
async getProjectSecret(projectId, secretId) {
|
|
43231
|
-
const data = await this.request(`/accounts/projects/${projectId}/secrets/${secretId}`, {
|
|
43232
|
-
action: "fetch project secret"
|
|
43233
|
-
});
|
|
43234
|
-
return this.parseManagedSecret(data);
|
|
43235
|
-
}
|
|
43236
|
-
async listProjectSecrets(projectId) {
|
|
43237
|
-
const data = await this.request(`/accounts/projects/${projectId}/secrets`, {
|
|
43238
|
-
action: "list project secrets"
|
|
43239
|
-
});
|
|
43240
|
-
const secrets = Array.isArray(data?.secrets) ? data.secrets : [];
|
|
43241
|
-
return secrets.map((item) => this.parseManagedSecretInfo(item));
|
|
43242
|
-
}
|
|
43243
|
-
async deleteProjectSecret(projectId, secretId) {
|
|
43244
|
-
await this.request(`/accounts/projects/${projectId}/secrets/${secretId}`, {
|
|
43245
|
-
method: "DELETE",
|
|
43246
|
-
action: "delete project secret",
|
|
43247
|
-
responseType: "void"
|
|
43248
|
-
});
|
|
43249
|
-
}
|
|
43250
|
-
async createRoomSecret(params) {
|
|
43251
|
-
const { projectId, roomName, data, secretId, name, type, delegatedTo, forIdentity } = params;
|
|
43252
|
-
const payload = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/secrets`, {
|
|
43253
|
-
method: "POST",
|
|
43254
|
-
json: {
|
|
43255
|
-
data_base64: bytesToBase64(normalizeBinary(data)),
|
|
43256
|
-
secret_id: secretId,
|
|
43257
|
-
name,
|
|
43258
|
-
type,
|
|
43259
|
-
delegated_to: delegatedTo,
|
|
43260
|
-
for_identity: forIdentity
|
|
43261
|
-
},
|
|
43262
|
-
action: "create room secret"
|
|
43263
|
-
});
|
|
43264
|
-
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
43265
|
-
throw new requirement_js_1.RoomException("Invalid create room secret response payload");
|
|
43266
|
-
}
|
|
43267
|
-
return payload.id;
|
|
43268
|
-
}
|
|
43269
|
-
async updateRoomSecret(params) {
|
|
43270
|
-
const { projectId, roomName, secretId, data, name, type, delegatedTo, forIdentity } = params;
|
|
43271
|
-
await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/secrets/${secretId}`, {
|
|
43272
|
-
method: "PUT",
|
|
43273
|
-
json: {
|
|
43274
|
-
data_base64: bytesToBase64(normalizeBinary(data)),
|
|
43275
|
-
name,
|
|
43276
|
-
type,
|
|
43277
|
-
delegated_to: delegatedTo,
|
|
43278
|
-
for_identity: forIdentity
|
|
43279
|
-
},
|
|
43280
|
-
action: "update room secret",
|
|
43281
|
-
responseType: "void"
|
|
43282
|
-
});
|
|
43283
|
-
}
|
|
43284
|
-
async getRoomSecret(params) {
|
|
43285
|
-
const { projectId, roomName, secretId, delegatedTo, forIdentity } = params;
|
|
43286
|
-
const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/secrets/${secretId}`, {
|
|
43287
|
-
query: {
|
|
43288
|
-
delegated_to: delegatedTo,
|
|
43289
|
-
for_identity: forIdentity
|
|
43290
|
-
},
|
|
43291
|
-
action: "fetch room secret"
|
|
43292
|
-
});
|
|
43293
|
-
return this.parseManagedSecret(data);
|
|
43294
|
-
}
|
|
43295
|
-
async listRoomSecrets(params) {
|
|
43296
|
-
const { projectId, roomName, forIdentity } = params;
|
|
43297
|
-
const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/secrets`, {
|
|
43298
|
-
query: {
|
|
43299
|
-
for_identity: forIdentity
|
|
43300
|
-
},
|
|
43301
|
-
action: "list room secrets"
|
|
43302
|
-
});
|
|
43303
|
-
const secrets = Array.isArray(data?.secrets) ? data.secrets : [];
|
|
43304
|
-
return secrets.map((item) => this.parseManagedSecretInfo(item));
|
|
43305
|
-
}
|
|
43306
|
-
async deleteRoomSecret(params) {
|
|
43307
|
-
const { projectId, roomName, secretId, delegatedTo, forIdentity } = params;
|
|
43308
|
-
await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/secrets/${secretId}`, {
|
|
43309
|
-
method: "DELETE",
|
|
43310
|
-
query: {
|
|
43311
|
-
delegated_to: delegatedTo,
|
|
43312
|
-
for_identity: forIdentity
|
|
43313
|
-
},
|
|
43314
|
-
action: "delete room secret",
|
|
43315
|
-
responseType: "void"
|
|
43316
|
-
});
|
|
43317
|
-
}
|
|
43318
|
-
async createSecret(projectId, secret) {
|
|
43319
|
-
await this.createProjectSecret({
|
|
43320
|
-
projectId,
|
|
43321
|
-
name: secret.name,
|
|
43322
|
-
type: secret.type,
|
|
43323
|
-
data: utils_js_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data))
|
|
43324
|
-
});
|
|
43325
|
-
}
|
|
43326
|
-
async updateSecret(projectId, secret) {
|
|
43327
|
-
if (!secret.id) {
|
|
43328
|
-
throw new requirement_js_1.RoomException("Secret id is required to update a secret");
|
|
43329
|
-
}
|
|
43330
|
-
await this.updateProjectSecret({
|
|
43331
|
-
projectId,
|
|
43332
|
-
secretId: secret.id,
|
|
43333
|
-
name: secret.name,
|
|
43334
|
-
type: secret.type,
|
|
43335
|
-
data: utils_js_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data))
|
|
43336
|
-
});
|
|
43337
|
-
}
|
|
43338
|
-
async deleteSecret(projectId, secretId) {
|
|
43339
|
-
await this.deleteProjectSecret(projectId, secretId);
|
|
43340
|
-
}
|
|
43341
|
-
async listSecrets(projectId) {
|
|
43342
|
-
const secretInfos = await this.listProjectSecrets(projectId);
|
|
43343
|
-
const secrets = await Promise.all(secretInfos.map(async (secretInfo) => {
|
|
43344
|
-
const secret = await this.getProjectSecret(projectId, secretInfo.id);
|
|
43345
|
-
return this.parseSecretPayload(secret, secret.data);
|
|
43346
|
-
}));
|
|
43347
|
-
return secrets;
|
|
43348
|
-
}
|
|
43349
|
-
async createProjectExternalOAuthRegistration(params) {
|
|
43350
|
-
const { projectId, oauth, clientId, clientSecret, delegatedTo, connector } = params;
|
|
43351
|
-
const payload = await this.request(`/accounts/projects/${projectId}/external-oauth`, {
|
|
43352
|
-
method: "POST",
|
|
43353
|
-
json: {
|
|
43354
|
-
oauth,
|
|
43355
|
-
client_id: clientId,
|
|
43356
|
-
client_secret: clientSecret,
|
|
43357
|
-
delegated_to: delegatedTo,
|
|
43358
|
-
connector: this.serializeConnectorRef(connector)
|
|
43359
|
-
},
|
|
43360
|
-
action: "create project external oauth registration"
|
|
43361
|
-
});
|
|
43362
|
-
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
43363
|
-
throw new requirement_js_1.RoomException("Invalid create project external oauth registration response payload");
|
|
43364
|
-
}
|
|
43365
|
-
return payload.id;
|
|
43366
|
-
}
|
|
43367
|
-
async updateProjectExternalOAuthRegistration(params) {
|
|
43368
|
-
const { projectId, registrationId, oauth, clientId, clientSecret, delegatedTo, connector } = params;
|
|
43369
|
-
await this.request(`/accounts/projects/${projectId}/external-oauth/${registrationId}`, {
|
|
43370
|
-
method: "PUT",
|
|
43371
|
-
json: {
|
|
43372
|
-
oauth,
|
|
43373
|
-
client_id: clientId,
|
|
43374
|
-
client_secret: clientSecret,
|
|
43375
|
-
delegated_to: delegatedTo,
|
|
43376
|
-
connector: this.serializeConnectorRef(connector)
|
|
43377
|
-
},
|
|
43378
|
-
action: "update project external oauth registration",
|
|
43379
|
-
responseType: "void"
|
|
43380
|
-
});
|
|
43381
|
-
}
|
|
43382
|
-
async listProjectExternalOAuthRegistrations(params) {
|
|
43383
|
-
const { projectId, delegatedTo } = params;
|
|
43384
|
-
const data = await this.request(`/accounts/projects/${projectId}/external-oauth`, {
|
|
43385
|
-
query: {
|
|
43386
|
-
delegated_to: delegatedTo
|
|
43387
|
-
},
|
|
43388
|
-
action: "list project external oauth registrations"
|
|
43389
|
-
});
|
|
43390
|
-
const registrations = Array.isArray(data?.registrations) ? data.registrations : [];
|
|
43391
|
-
return registrations.map((item) => this.parseExternalOAuthClientRegistration(item));
|
|
43392
|
-
}
|
|
43393
|
-
async deleteProjectExternalOAuthRegistration(params) {
|
|
43394
|
-
const { projectId, registrationId, delegatedTo } = params;
|
|
43395
|
-
await this.request(`/accounts/projects/${projectId}/external-oauth/${registrationId}`, {
|
|
43396
|
-
method: "DELETE",
|
|
43397
|
-
query: {
|
|
43398
|
-
delegated_to: delegatedTo
|
|
43399
|
-
},
|
|
43400
|
-
action: "delete project external oauth registration",
|
|
43401
|
-
responseType: "void"
|
|
43402
|
-
});
|
|
43403
|
-
}
|
|
43404
|
-
async createRoomExternalOAuthRegistration(params) {
|
|
43405
|
-
const { projectId, roomName, oauth, clientId, clientSecret, delegatedTo, connector } = params;
|
|
43406
|
-
const payload = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/external-oauth`, {
|
|
43407
|
-
method: "POST",
|
|
43408
|
-
json: {
|
|
43409
|
-
oauth,
|
|
43410
|
-
client_id: clientId,
|
|
43411
|
-
client_secret: clientSecret,
|
|
43412
|
-
delegated_to: delegatedTo,
|
|
43413
|
-
connector: this.serializeConnectorRef(connector)
|
|
43414
|
-
},
|
|
43415
|
-
action: "create room external oauth registration"
|
|
43416
|
-
});
|
|
43417
|
-
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
43418
|
-
throw new requirement_js_1.RoomException("Invalid create room external oauth registration response payload");
|
|
43419
|
-
}
|
|
43420
|
-
return payload.id;
|
|
43421
|
-
}
|
|
43422
|
-
async updateRoomExternalOAuthRegistration(params) {
|
|
43423
|
-
const { projectId, roomName, registrationId, oauth, clientId, clientSecret, delegatedTo, connector } = params;
|
|
43424
|
-
await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/external-oauth/${registrationId}`, {
|
|
43425
|
-
method: "PUT",
|
|
43426
|
-
json: {
|
|
43427
|
-
oauth,
|
|
43428
|
-
client_id: clientId,
|
|
43429
|
-
client_secret: clientSecret,
|
|
43430
|
-
delegated_to: delegatedTo,
|
|
43431
|
-
connector: this.serializeConnectorRef(connector)
|
|
43432
|
-
},
|
|
43433
|
-
action: "update room external oauth registration",
|
|
43434
|
-
responseType: "void"
|
|
43435
|
-
});
|
|
43436
|
-
}
|
|
43437
|
-
async listRoomExternalOAuthRegistrations(params) {
|
|
43438
|
-
const { projectId, roomName, delegatedTo } = params;
|
|
43439
|
-
const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/external-oauth`, {
|
|
43440
|
-
query: {
|
|
43441
|
-
delegated_to: delegatedTo
|
|
43442
|
-
},
|
|
43443
|
-
action: "list room external oauth registrations"
|
|
43444
|
-
});
|
|
43445
|
-
const registrations = Array.isArray(data?.registrations) ? data.registrations : [];
|
|
43446
|
-
return registrations.map((item) => this.parseExternalOAuthClientRegistration(item));
|
|
43447
|
-
}
|
|
43448
|
-
async deleteRoomExternalOAuthRegistration(params) {
|
|
43449
|
-
const { projectId, roomName, registrationId, delegatedTo } = params;
|
|
43450
|
-
await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/external-oauth/${registrationId}`, {
|
|
43451
|
-
method: "DELETE",
|
|
43452
|
-
query: {
|
|
43453
|
-
delegated_to: delegatedTo
|
|
43454
|
-
},
|
|
43455
|
-
action: "delete room external oauth registration",
|
|
43456
|
-
responseType: "void"
|
|
43457
|
-
});
|
|
43458
|
-
}
|
|
43459
43315
|
async createRoom(params) {
|
|
43460
|
-
const { projectId, name, ifNotExists = false, metadata, annotations
|
|
43316
|
+
const { projectId, name, ifNotExists = false, metadata, annotations } = params;
|
|
43461
43317
|
const payload = {
|
|
43462
43318
|
name,
|
|
43463
43319
|
if_not_exists: Boolean(ifNotExists),
|
|
43464
43320
|
metadata,
|
|
43465
43321
|
annotations
|
|
43466
43322
|
};
|
|
43467
|
-
if (permissions) {
|
|
43468
|
-
const serialized = {};
|
|
43469
|
-
for (const [key, value] of Object.entries(permissions)) {
|
|
43470
|
-
serialized[key] = value instanceof participant_token_js_1.ApiScope ? value.toJSON() : value;
|
|
43471
|
-
}
|
|
43472
|
-
payload["permissions"] = serialized;
|
|
43473
|
-
}
|
|
43474
43323
|
const data = await this.request(`/accounts/projects/${projectId}/rooms`, {
|
|
43475
43324
|
method: "POST",
|
|
43476
43325
|
json: payload,
|
|
@@ -43506,76 +43355,103 @@ ${newlined}
|
|
|
43506
43355
|
responseType: "void"
|
|
43507
43356
|
});
|
|
43508
43357
|
}
|
|
43509
|
-
async
|
|
43510
|
-
const
|
|
43358
|
+
async createGroup(params) {
|
|
43359
|
+
const { projectId, name, metadata, annotations } = params;
|
|
43360
|
+
const data = await this.request(`/accounts/projects/${projectId}/groups`, {
|
|
43511
43361
|
method: "POST",
|
|
43512
|
-
json: {},
|
|
43513
|
-
action: "
|
|
43362
|
+
json: { name, metadata, annotations },
|
|
43363
|
+
action: "create group"
|
|
43514
43364
|
});
|
|
43515
|
-
return this.
|
|
43365
|
+
return this.parseGroup(data);
|
|
43516
43366
|
}
|
|
43517
|
-
async
|
|
43518
|
-
const
|
|
43519
|
-
|
|
43520
|
-
|
|
43521
|
-
|
|
43522
|
-
|
|
43523
|
-
|
|
43524
|
-
|
|
43525
|
-
|
|
43526
|
-
|
|
43367
|
+
async getGroup(projectId, groupId) {
|
|
43368
|
+
const data = await this.request(`/accounts/projects/${projectId}/groups/${groupId}`, {
|
|
43369
|
+
action: "fetch group"
|
|
43370
|
+
});
|
|
43371
|
+
return this.parseGroup(data);
|
|
43372
|
+
}
|
|
43373
|
+
async updateGroup(projectId, groupId, name, options = {}) {
|
|
43374
|
+
const payload = { name };
|
|
43375
|
+
if (options.metadata !== void 0) {
|
|
43376
|
+
payload["metadata"] = options.metadata;
|
|
43377
|
+
}
|
|
43378
|
+
if (options.annotations !== void 0) {
|
|
43379
|
+
payload["annotations"] = options.annotations;
|
|
43380
|
+
}
|
|
43381
|
+
await this.request(`/accounts/projects/${projectId}/groups/${groupId}`, {
|
|
43382
|
+
method: "PUT",
|
|
43383
|
+
json: payload,
|
|
43384
|
+
action: "update group",
|
|
43527
43385
|
responseType: "void"
|
|
43528
43386
|
});
|
|
43529
43387
|
}
|
|
43530
|
-
async
|
|
43531
|
-
|
|
43532
|
-
|
|
43533
|
-
|
|
43534
|
-
json: {
|
|
43535
|
-
room_id: roomId,
|
|
43536
|
-
email,
|
|
43537
|
-
permissions: permissions.toJSON(),
|
|
43538
|
-
...inviteRedirectUrl !== void 0 ? { invite_redirect_url: inviteRedirectUrl } : {}
|
|
43539
|
-
},
|
|
43540
|
-
action: "create room grant",
|
|
43388
|
+
async deleteGroup(projectId, groupId) {
|
|
43389
|
+
await this.request(`/accounts/projects/${projectId}/groups/${groupId}`, {
|
|
43390
|
+
method: "DELETE",
|
|
43391
|
+
action: "delete group",
|
|
43541
43392
|
responseType: "void"
|
|
43542
43393
|
});
|
|
43543
43394
|
}
|
|
43544
|
-
async
|
|
43545
|
-
const
|
|
43546
|
-
|
|
43547
|
-
|
|
43548
|
-
|
|
43549
|
-
|
|
43550
|
-
room_id: roomId,
|
|
43551
|
-
user_id: userId,
|
|
43552
|
-
permissions: permissions.toJSON()
|
|
43395
|
+
async listGroupsPage(projectId, options = {}) {
|
|
43396
|
+
const data = await this.request(`/accounts/projects/${projectId}/groups`, {
|
|
43397
|
+
query: {
|
|
43398
|
+
page_size: options.pageSize ?? 50,
|
|
43399
|
+
continuation_token: options.continuationToken,
|
|
43400
|
+
filter: options.filter
|
|
43553
43401
|
},
|
|
43554
|
-
action: "
|
|
43402
|
+
action: "list groups"
|
|
43403
|
+
});
|
|
43404
|
+
const groups = Array.isArray(data?.groups) ? data.groups : [];
|
|
43405
|
+
return {
|
|
43406
|
+
groups: groups.map((item) => this.parseGroup(item)),
|
|
43407
|
+
continuationToken: data?.continuation_token ?? null
|
|
43408
|
+
};
|
|
43409
|
+
}
|
|
43410
|
+
async listGroups(projectId, options = {}) {
|
|
43411
|
+
const page = await this.listGroupsPage(projectId, options);
|
|
43412
|
+
return page.groups;
|
|
43413
|
+
}
|
|
43414
|
+
async setGroupMember(params) {
|
|
43415
|
+
const { projectId, groupId, subject, role = "member" } = params;
|
|
43416
|
+
await this.request(`/accounts/projects/${projectId}/groups/${groupId}/members`, {
|
|
43417
|
+
method: "POST",
|
|
43418
|
+
json: { subject, role },
|
|
43419
|
+
action: "set group member",
|
|
43555
43420
|
responseType: "void"
|
|
43556
43421
|
});
|
|
43557
43422
|
}
|
|
43558
|
-
async
|
|
43559
|
-
const
|
|
43560
|
-
|
|
43561
|
-
|
|
43423
|
+
async listGroupMembersPage(projectId, groupId, options = {}) {
|
|
43424
|
+
const data = await this.request(`/accounts/projects/${projectId}/groups/${groupId}/members`, {
|
|
43425
|
+
query: { page_size: options.pageSize ?? 50, continuation_token: options.continuationToken },
|
|
43426
|
+
action: "list group members"
|
|
43427
|
+
});
|
|
43428
|
+
const members = Array.isArray(data?.members) ? data.members : [];
|
|
43429
|
+
return { members: members.map((item) => this.parseGroupMember(item)), continuationToken: data?.continuation_token ?? null };
|
|
43430
|
+
}
|
|
43431
|
+
async listGroupMembers(projectId, groupId, options = {}) {
|
|
43432
|
+
const page = await this.listGroupMembersPage(projectId, groupId, options);
|
|
43433
|
+
return page.members;
|
|
43434
|
+
}
|
|
43435
|
+
async deleteGroupMember(params) {
|
|
43436
|
+
const { projectId, groupId, subjectType, subjectId } = params;
|
|
43437
|
+
await this.request(`/accounts/projects/${projectId}/groups/${groupId}/members/${subjectType}/${subjectId}`, {
|
|
43562
43438
|
method: "DELETE",
|
|
43563
|
-
action: "delete
|
|
43439
|
+
action: "delete group member",
|
|
43564
43440
|
responseType: "void"
|
|
43565
43441
|
});
|
|
43566
43442
|
}
|
|
43567
|
-
async
|
|
43568
|
-
const
|
|
43569
|
-
|
|
43570
|
-
|
|
43571
|
-
action: "
|
|
43443
|
+
async connectRoom(projectId, room) {
|
|
43444
|
+
const data = await this.request(`/accounts/projects/${projectId}/rooms/${room}/connect`, {
|
|
43445
|
+
method: "POST",
|
|
43446
|
+
json: {},
|
|
43447
|
+
action: "connect room"
|
|
43572
43448
|
});
|
|
43573
|
-
return this.
|
|
43449
|
+
return this.parseRoomConnectionInfo(data);
|
|
43574
43450
|
}
|
|
43575
43451
|
async listRooms(projectId, options = {}) {
|
|
43576
|
-
const {
|
|
43452
|
+
const { pageSize = 50, continuationToken, filter, view } = options;
|
|
43577
43453
|
const data = await this.request(`/accounts/projects/${projectId}/rooms`, {
|
|
43578
|
-
query: {
|
|
43454
|
+
query: { page_size: pageSize, continuation_token: continuationToken, filter, view },
|
|
43579
43455
|
action: "list rooms"
|
|
43580
43456
|
});
|
|
43581
43457
|
const rooms = Array.isArray(data?.rooms) ? data.rooms : [];
|
|
@@ -43606,16 +43482,23 @@ ${newlined}
|
|
|
43606
43482
|
return this.parseRoute(data.route);
|
|
43607
43483
|
}
|
|
43608
43484
|
async listRoutesPage(projectId, options = {}) {
|
|
43609
|
-
const {
|
|
43485
|
+
const { pageSize = 100, continuationToken, filter } = options;
|
|
43610
43486
|
const data = await this.request(`/accounts/projects/${projectId}/routes`, {
|
|
43611
|
-
query: {
|
|
43487
|
+
query: { page_size: pageSize, continuation_token: continuationToken, filter },
|
|
43612
43488
|
action: "list routes"
|
|
43613
43489
|
});
|
|
43614
43490
|
const routes = Array.isArray(data.routes) ? data.routes.map((item) => this.parseRoute(item)) : [];
|
|
43615
|
-
return { routes, total: Number(data.total ?? routes.length) };
|
|
43491
|
+
return { routes, total: Number(data.total ?? routes.length), continuationToken: data.continuation_token ?? null };
|
|
43616
43492
|
}
|
|
43617
43493
|
async listRoutes(projectId, options = {}) {
|
|
43618
|
-
|
|
43494
|
+
const routes = [];
|
|
43495
|
+
let continuationToken;
|
|
43496
|
+
do {
|
|
43497
|
+
const page = await this.listRoutesPage(projectId, { ...options, continuationToken });
|
|
43498
|
+
routes.push(...page.routes);
|
|
43499
|
+
continuationToken = page.continuationToken ?? void 0;
|
|
43500
|
+
} while (continuationToken);
|
|
43501
|
+
return routes;
|
|
43619
43502
|
}
|
|
43620
43503
|
async listRoomRoutesPage(params) {
|
|
43621
43504
|
const { projectId, roomName, count = 100, offset = 0, filter } = params;
|
|
@@ -43651,63 +43534,111 @@ ${newlined}
|
|
|
43651
43534
|
responseType: "void"
|
|
43652
43535
|
});
|
|
43653
43536
|
}
|
|
43654
|
-
async
|
|
43655
|
-
const
|
|
43656
|
-
|
|
43657
|
-
|
|
43658
|
-
|
|
43537
|
+
async testAccess(projectId, params) {
|
|
43538
|
+
const data = await this.request(`/accounts/projects/${projectId}/access:test`, {
|
|
43539
|
+
method: "POST",
|
|
43540
|
+
json: {
|
|
43541
|
+
subject: this.serializeAccessSubject(params.subject),
|
|
43542
|
+
resource: this.serializeAccessResource(params.resource),
|
|
43543
|
+
relation: params.relation
|
|
43544
|
+
},
|
|
43545
|
+
action: "test access"
|
|
43659
43546
|
});
|
|
43660
|
-
|
|
43661
|
-
|
|
43547
|
+
return {
|
|
43548
|
+
allowed: data?.allowed === true,
|
|
43549
|
+
resource: data?.resource && typeof data.resource === "object" ? this.parseAccessResource(data.resource) : void 0,
|
|
43550
|
+
subject: data?.subject && typeof data.subject === "object" ? this.parseAccessSubject(data.subject) : void 0,
|
|
43551
|
+
relation: typeof data?.relation === "string" ? data.relation : void 0
|
|
43552
|
+
};
|
|
43662
43553
|
}
|
|
43663
|
-
async
|
|
43664
|
-
const
|
|
43665
|
-
|
|
43666
|
-
|
|
43667
|
-
|
|
43668
|
-
|
|
43554
|
+
async getEffectiveAccess(projectId, params) {
|
|
43555
|
+
const data = await this.request(`/accounts/projects/${projectId}/access:effective`, {
|
|
43556
|
+
method: "POST",
|
|
43557
|
+
json: {
|
|
43558
|
+
subject: this.serializeAccessSubject(params.subject),
|
|
43559
|
+
resource: this.serializeAccessResource(params.resource),
|
|
43560
|
+
...params.relations ? { relations: params.relations } : {}
|
|
43561
|
+
},
|
|
43562
|
+
action: "get effective access"
|
|
43669
43563
|
});
|
|
43670
|
-
|
|
43671
|
-
|
|
43564
|
+
return {
|
|
43565
|
+
resource: this.parseAccessResource(data?.resource),
|
|
43566
|
+
subject: this.parseAccessSubject(data?.subject),
|
|
43567
|
+
effectiveRoles: Array.isArray(data?.effective_roles) ? data.effective_roles.filter((item) => typeof item === "string") : [],
|
|
43568
|
+
capabilities: data?.capabilities && typeof data.capabilities === "object" ? data.capabilities : {}
|
|
43569
|
+
};
|
|
43570
|
+
}
|
|
43571
|
+
async listAccessBindings(projectId, params) {
|
|
43572
|
+
const page = await this.listAccessBindingsPage(projectId, params);
|
|
43573
|
+
return page.accessGrants;
|
|
43672
43574
|
}
|
|
43673
|
-
async
|
|
43674
|
-
const
|
|
43675
|
-
|
|
43676
|
-
|
|
43677
|
-
|
|
43678
|
-
|
|
43575
|
+
async listAccessBindingsPage(projectId, params) {
|
|
43576
|
+
const data = await this.request(`/accounts/projects/${projectId}/access:bindings`, {
|
|
43577
|
+
method: "POST",
|
|
43578
|
+
json: {
|
|
43579
|
+
subject: this.serializeAccessSubject(params.subject)
|
|
43580
|
+
},
|
|
43581
|
+
action: "list access bindings"
|
|
43679
43582
|
});
|
|
43680
|
-
|
|
43681
|
-
|
|
43583
|
+
return {
|
|
43584
|
+
accessGrants: Array.isArray(data?.access_grants) ? data.access_grants.map((item) => this.parseProjectRoomGrant(item)) : []
|
|
43585
|
+
};
|
|
43682
43586
|
}
|
|
43683
|
-
async
|
|
43684
|
-
|
|
43685
|
-
const data = await this.request(`/accounts/projects/${projectId}/
|
|
43686
|
-
|
|
43687
|
-
|
|
43587
|
+
async getResourcePolicyPage(projectId, params) {
|
|
43588
|
+
this.validateResourcePolicyType(params.resourceType);
|
|
43589
|
+
const data = await this.request(`/accounts/projects/${projectId}/iam/${params.resourceType}/${params.resourceId}/policy`, {
|
|
43590
|
+
method: "GET",
|
|
43591
|
+
query: { page_size: params.pageSize ?? 50, continuation_token: params.continuationToken },
|
|
43592
|
+
action: "get resource policy"
|
|
43688
43593
|
});
|
|
43689
|
-
|
|
43690
|
-
|
|
43594
|
+
return {
|
|
43595
|
+
resource: this.parseAccessResource(data?.resource),
|
|
43596
|
+
accessGrants: Array.isArray(data?.access_grants) ? data.access_grants.map((item) => this.parseProjectRoomGrant(item)) : [],
|
|
43597
|
+
continuationToken: typeof data?.continuation_token === "string" ? data.continuation_token : null
|
|
43598
|
+
};
|
|
43691
43599
|
}
|
|
43692
|
-
async
|
|
43693
|
-
const
|
|
43694
|
-
|
|
43695
|
-
|
|
43696
|
-
|
|
43600
|
+
async getResourcePolicy(projectId, params) {
|
|
43601
|
+
const grants = [];
|
|
43602
|
+
let continuationToken = params.continuationToken;
|
|
43603
|
+
do {
|
|
43604
|
+
const page = await this.getResourcePolicyPage(projectId, { ...params, continuationToken });
|
|
43605
|
+
grants.push(...page.accessGrants);
|
|
43606
|
+
continuationToken = page.continuationToken ?? void 0;
|
|
43607
|
+
} while (continuationToken);
|
|
43608
|
+
return grants;
|
|
43609
|
+
}
|
|
43610
|
+
async grantResourcePolicy(projectId, params) {
|
|
43611
|
+
this.validateResourcePolicyType(params.resourceType);
|
|
43612
|
+
await this.request(`/accounts/projects/${projectId}/iam/${params.resourceType}/${params.resourceId}/policy:grant`, {
|
|
43613
|
+
method: "POST",
|
|
43614
|
+
json: {
|
|
43615
|
+
subject: this.serializeAccessSubject(params.subject),
|
|
43616
|
+
roles: params.roles,
|
|
43617
|
+
...params.inviteRedirectUrl ? { invite_redirect_url: params.inviteRedirectUrl } : {}
|
|
43618
|
+
},
|
|
43619
|
+
action: "grant resource policy"
|
|
43697
43620
|
});
|
|
43698
|
-
const users = Array.isArray(data?.users) ? data.users : [];
|
|
43699
|
-
const parsed = users.map((item) => this.parseProjectUserGrantCount(item));
|
|
43700
|
-
return { users: parsed, total: typeof data?.total === "number" ? data.total : parsed.length };
|
|
43701
43621
|
}
|
|
43702
|
-
async
|
|
43703
|
-
|
|
43704
|
-
|
|
43622
|
+
async revokeResourcePolicy(projectId, params) {
|
|
43623
|
+
this.validateResourcePolicyType(params.resourceType);
|
|
43624
|
+
await this.request(`/accounts/projects/${projectId}/iam/${params.resourceType}/${params.resourceId}/policy:revoke`, {
|
|
43625
|
+
method: "POST",
|
|
43626
|
+
json: {
|
|
43627
|
+
subject: this.serializeAccessSubject(params.subject)
|
|
43628
|
+
},
|
|
43629
|
+
action: "revoke resource policy"
|
|
43630
|
+
});
|
|
43631
|
+
}
|
|
43632
|
+
validateResourcePolicyType(resourceType) {
|
|
43633
|
+
if (resourceType === "agent") {
|
|
43634
|
+
throw new Error("managed agent resource policies are not supported; use agent run_as instead");
|
|
43635
|
+
}
|
|
43705
43636
|
}
|
|
43706
43637
|
async createOAuthClient(projectId, params) {
|
|
43707
|
-
const { grantTypes, responseTypes, redirectUris, scope, metadata = {} } = params;
|
|
43638
|
+
const { grantTypes, responseTypes, redirectUris, scope, metadata = {}, official = false } = params;
|
|
43708
43639
|
const data = await this.request(`/accounts/projects/${projectId}/oauth/clients`, {
|
|
43709
43640
|
method: "POST",
|
|
43710
|
-
json: { grant_types: grantTypes, response_types: responseTypes, redirect_uris: redirectUris, scope, metadata },
|
|
43641
|
+
json: { grant_types: grantTypes, response_types: responseTypes, redirect_uris: redirectUris, scope, metadata, official },
|
|
43711
43642
|
action: "create oauth client"
|
|
43712
43643
|
});
|
|
43713
43644
|
return this.parseOAuthClient(data);
|
|
@@ -44730,23 +44661,73 @@ ${newlined}
|
|
|
44730
44661
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44731
44662
|
exports.fullOAuthScope = exports.fullOAuthScopes = void 0;
|
|
44732
44663
|
exports.fullOAuthScopes = [
|
|
44733
|
-
"profile",
|
|
44664
|
+
"profile:read",
|
|
44665
|
+
"profile:write",
|
|
44734
44666
|
"project/*",
|
|
44735
44667
|
"room/*",
|
|
44736
|
-
"
|
|
44737
|
-
"
|
|
44738
|
-
"
|
|
44739
|
-
"
|
|
44740
|
-
"
|
|
44741
|
-
"
|
|
44742
|
-
"
|
|
44743
|
-
"
|
|
44744
|
-
"
|
|
44745
|
-
"
|
|
44746
|
-
"
|
|
44747
|
-
"
|
|
44668
|
+
"users:create",
|
|
44669
|
+
"users:read",
|
|
44670
|
+
"users:update",
|
|
44671
|
+
"users:delete",
|
|
44672
|
+
"projects:read",
|
|
44673
|
+
"projects:update",
|
|
44674
|
+
"projects:iam.read",
|
|
44675
|
+
"projects:iam.write",
|
|
44676
|
+
"projects:billing.read",
|
|
44677
|
+
"projects:billing.write",
|
|
44678
|
+
"rooms:create",
|
|
44679
|
+
"rooms:read",
|
|
44680
|
+
"rooms:connect",
|
|
44681
|
+
"rooms:update",
|
|
44682
|
+
"rooms:delete",
|
|
44683
|
+
"agents:create",
|
|
44684
|
+
"agents:read",
|
|
44685
|
+
"agents:update",
|
|
44686
|
+
"agents:delete",
|
|
44687
|
+
"agents:run",
|
|
44688
|
+
"agents:sessions.read",
|
|
44689
|
+
"mailboxes:create",
|
|
44690
|
+
"mailboxes:read",
|
|
44691
|
+
"mailboxes:update",
|
|
44692
|
+
"mailboxes:delete",
|
|
44693
|
+
"routes:create",
|
|
44694
|
+
"routes:read",
|
|
44695
|
+
"routes:update",
|
|
44696
|
+
"routes:delete",
|
|
44697
|
+
"scheduledTasks:create",
|
|
44698
|
+
"scheduledTasks:read",
|
|
44699
|
+
"scheduledTasks:update",
|
|
44700
|
+
"scheduledTasks:delete",
|
|
44701
|
+
"services:create",
|
|
44702
|
+
"services:read",
|
|
44703
|
+
"services:update",
|
|
44704
|
+
"services:delete",
|
|
44705
|
+
"repositories:create",
|
|
44706
|
+
"repositories:read",
|
|
44707
|
+
"repositories:update",
|
|
44708
|
+
"repositories:delete",
|
|
44709
|
+
"apiKeys:create",
|
|
44710
|
+
"apiKeys:read",
|
|
44711
|
+
"apiKeys:delete",
|
|
44712
|
+
"serviceAccounts:create",
|
|
44713
|
+
"serviceAccounts:read",
|
|
44714
|
+
"serviceAccounts:update",
|
|
44715
|
+
"serviceAccounts:delete",
|
|
44716
|
+
"oauthClients:create",
|
|
44717
|
+
"oauthClients:read",
|
|
44718
|
+
"oauthClients:update",
|
|
44719
|
+
"oauthClients:delete",
|
|
44720
|
+
"llm:invoke",
|
|
44721
|
+
"llm:usage.read",
|
|
44722
|
+
"llm:logs.read",
|
|
44723
|
+
"llm:logs.write",
|
|
44724
|
+
"secrets:read",
|
|
44725
|
+
"secrets:write",
|
|
44726
|
+
"secrets:delete",
|
|
44727
|
+
"secrets:grant",
|
|
44728
|
+
"secrets:proxy"
|
|
44748
44729
|
];
|
|
44749
|
-
exports.fullOAuthScope = "
|
|
44730
|
+
exports.fullOAuthScope = exports.fullOAuthScopes.join(" ");
|
|
44750
44731
|
}
|
|
44751
44732
|
});
|
|
44752
44733
|
|
|
@@ -44784,355 +44765,677 @@ ${newlined}
|
|
|
44784
44765
|
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44785
44766
|
throw this._unexpectedResponseError("list");
|
|
44786
44767
|
}
|
|
44787
|
-
const queues = response.json["queues"];
|
|
44788
|
-
return queues.map((q) => new Queue({ name: q["name"], size: q["size"] }));
|
|
44768
|
+
const queues = response.json["queues"];
|
|
44769
|
+
return queues.map((q) => new Queue({ name: q["name"], size: q["size"] }));
|
|
44770
|
+
}
|
|
44771
|
+
async open(name) {
|
|
44772
|
+
const response = await this._invoke("open", { name });
|
|
44773
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44774
|
+
throw this._unexpectedResponseError("open");
|
|
44775
|
+
}
|
|
44776
|
+
}
|
|
44777
|
+
async drain(name) {
|
|
44778
|
+
const response = await this._invoke("drain", { name });
|
|
44779
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44780
|
+
throw this._unexpectedResponseError("drain");
|
|
44781
|
+
}
|
|
44782
|
+
}
|
|
44783
|
+
async close(name) {
|
|
44784
|
+
const response = await this._invoke("close", { name });
|
|
44785
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44786
|
+
throw this._unexpectedResponseError("close");
|
|
44787
|
+
}
|
|
44788
|
+
}
|
|
44789
|
+
async send(name, message2, { create = true }) {
|
|
44790
|
+
const response = await this._invoke("send", { name, create, message: message2 });
|
|
44791
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44792
|
+
throw this._unexpectedResponseError("send");
|
|
44793
|
+
}
|
|
44794
|
+
}
|
|
44795
|
+
async receive(name, { create = true, wait = true }) {
|
|
44796
|
+
const response = await this._invoke("receive", {
|
|
44797
|
+
name,
|
|
44798
|
+
create,
|
|
44799
|
+
wait
|
|
44800
|
+
});
|
|
44801
|
+
if (response instanceof response_js_1.EmptyContent) {
|
|
44802
|
+
return null;
|
|
44803
|
+
}
|
|
44804
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
44805
|
+
return response.json;
|
|
44806
|
+
}
|
|
44807
|
+
throw this._unexpectedResponseError("receive");
|
|
44808
|
+
}
|
|
44809
|
+
};
|
|
44810
|
+
exports.QueuesClient = QueuesClient;
|
|
44811
|
+
}
|
|
44812
|
+
});
|
|
44813
|
+
|
|
44814
|
+
// ../meshagent-ts/dist/browser/sqlite-client.js
|
|
44815
|
+
var require_sqlite_client = __commonJS({
|
|
44816
|
+
"../meshagent-ts/dist/browser/sqlite-client.js"(exports) {
|
|
44817
|
+
"use strict";
|
|
44818
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44819
|
+
exports.SqliteClient = exports.SqliteDatabaseClient = void 0;
|
|
44820
|
+
var apache_arrow_1 = require_Arrow_dom();
|
|
44821
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
44822
|
+
var response_js_1 = require_response();
|
|
44823
|
+
var datasets_client_js_1 = require_datasets_client();
|
|
44824
|
+
var ARROW_IPC_STREAM_MIME_TYPE = "application/vnd.apache.arrow.stream";
|
|
44825
|
+
var globalScope = globalThis;
|
|
44826
|
+
async function* toAsyncArrowIterable(chunks) {
|
|
44827
|
+
if (Symbol.asyncIterator in chunks) {
|
|
44828
|
+
for await (const chunk of chunks) {
|
|
44829
|
+
yield chunk;
|
|
44830
|
+
}
|
|
44831
|
+
return;
|
|
44832
|
+
}
|
|
44833
|
+
for (const chunk of chunks) {
|
|
44834
|
+
yield chunk;
|
|
44835
|
+
}
|
|
44836
|
+
}
|
|
44837
|
+
function isRecord(value) {
|
|
44838
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44839
|
+
}
|
|
44840
|
+
function bytesToBase64(bytes) {
|
|
44841
|
+
if (globalScope.Buffer) {
|
|
44842
|
+
return globalScope.Buffer.from(bytes).toString("base64");
|
|
44843
|
+
}
|
|
44844
|
+
if (!globalScope.btoa) {
|
|
44845
|
+
throw new Error("base64 encoding is not available in this runtime");
|
|
44846
|
+
}
|
|
44847
|
+
let binary = "";
|
|
44848
|
+
for (const byte of bytes) {
|
|
44849
|
+
binary += String.fromCharCode(byte);
|
|
44850
|
+
}
|
|
44851
|
+
return globalScope.btoa(binary);
|
|
44852
|
+
}
|
|
44853
|
+
function encodeRecordValue(value) {
|
|
44854
|
+
if (value instanceof datasets_client_js_1.DatasetValueEncoder) {
|
|
44855
|
+
return value.encodeDatasetValue();
|
|
44856
|
+
}
|
|
44857
|
+
if (value instanceof Uint8Array) {
|
|
44858
|
+
return {
|
|
44859
|
+
binary: bytesToBase64(value)
|
|
44860
|
+
};
|
|
44861
|
+
}
|
|
44862
|
+
if (value instanceof Date) {
|
|
44863
|
+
return {
|
|
44864
|
+
timestamp: value.toISOString().replace("+00:00", "Z")
|
|
44865
|
+
};
|
|
44866
|
+
}
|
|
44867
|
+
if (Array.isArray(value)) {
|
|
44868
|
+
return {
|
|
44869
|
+
list: value.map((item) => encodeRecordValue(item))
|
|
44870
|
+
};
|
|
44871
|
+
}
|
|
44872
|
+
if (isRecord(value)) {
|
|
44873
|
+
throw new room_server_client_js_1.RoomServerException("sqlite object values must use DatasetStruct or DatasetJson");
|
|
44874
|
+
}
|
|
44875
|
+
return value;
|
|
44876
|
+
}
|
|
44877
|
+
function buildWhereClause(where) {
|
|
44878
|
+
if (where != null && typeof where === "object" && !Array.isArray(where)) {
|
|
44879
|
+
return Object.fromEntries(Object.entries(where).map(([key, value]) => [key, encodeRecordValue(value)]));
|
|
44880
|
+
}
|
|
44881
|
+
if (typeof where === "string") {
|
|
44882
|
+
return where;
|
|
44883
|
+
}
|
|
44884
|
+
return null;
|
|
44885
|
+
}
|
|
44886
|
+
function schemaToIPC(schema) {
|
|
44887
|
+
return (0, apache_arrow_1.tableToIPC)(new apache_arrow_1.Table(schema, []), "stream");
|
|
44888
|
+
}
|
|
44889
|
+
function tableFromIPCBytes(data) {
|
|
44890
|
+
const table = (0, apache_arrow_1.tableFromIPC)(data);
|
|
44891
|
+
if (table instanceof Promise) {
|
|
44892
|
+
throw new room_server_client_js_1.RoomServerException("unexpected async Arrow IPC result");
|
|
44893
|
+
}
|
|
44894
|
+
return table;
|
|
44895
|
+
}
|
|
44896
|
+
function tableFromChunks(chunks) {
|
|
44897
|
+
if (chunks.length === 0) {
|
|
44898
|
+
return new apache_arrow_1.Table(new apache_arrow_1.Schema([]), []);
|
|
44899
|
+
}
|
|
44900
|
+
const [first, ...rest] = chunks;
|
|
44901
|
+
return first.concat(...rest);
|
|
44902
|
+
}
|
|
44903
|
+
function schemaFromIPCBytes(data) {
|
|
44904
|
+
return tableFromIPCBytes(data).schema;
|
|
44905
|
+
}
|
|
44906
|
+
var SqliteArrowWriteInputStream = class {
|
|
44907
|
+
constructor(start, chunks, schema) {
|
|
44908
|
+
this.start = start;
|
|
44909
|
+
this.schema = schema;
|
|
44910
|
+
this.pulls = [];
|
|
44911
|
+
this.closed = false;
|
|
44912
|
+
this.source = toAsyncArrowIterable(chunks)[Symbol.asyncIterator]();
|
|
44913
|
+
}
|
|
44914
|
+
requestNext() {
|
|
44915
|
+
if (this.closed) {
|
|
44916
|
+
return;
|
|
44917
|
+
}
|
|
44918
|
+
const waiter = this.pulls.shift();
|
|
44919
|
+
if (waiter) {
|
|
44920
|
+
waiter();
|
|
44921
|
+
return;
|
|
44922
|
+
}
|
|
44923
|
+
this.pulls.push(() => void 0);
|
|
44924
|
+
}
|
|
44925
|
+
close() {
|
|
44926
|
+
if (this.closed) {
|
|
44927
|
+
return;
|
|
44928
|
+
}
|
|
44929
|
+
this.closed = true;
|
|
44930
|
+
while (this.pulls.length > 0) {
|
|
44931
|
+
const waiter = this.pulls.shift();
|
|
44932
|
+
waiter?.();
|
|
44933
|
+
}
|
|
44934
|
+
void this.source.return?.();
|
|
44935
|
+
}
|
|
44936
|
+
async waitForPull() {
|
|
44937
|
+
if (this.closed) {
|
|
44938
|
+
return;
|
|
44939
|
+
}
|
|
44940
|
+
const waiter = this.pulls.shift();
|
|
44941
|
+
if (waiter) {
|
|
44942
|
+
waiter();
|
|
44943
|
+
return;
|
|
44944
|
+
}
|
|
44945
|
+
await new Promise((resolve) => {
|
|
44946
|
+
this.pulls.push(resolve);
|
|
44947
|
+
});
|
|
44948
|
+
}
|
|
44949
|
+
async *stream() {
|
|
44950
|
+
yield new response_js_1.BinaryContent({
|
|
44951
|
+
data: this.schema == null ? new Uint8Array() : schemaToIPC(this.schema),
|
|
44952
|
+
headers: this.start
|
|
44953
|
+
});
|
|
44954
|
+
while (!this.closed) {
|
|
44955
|
+
await this.waitForPull();
|
|
44956
|
+
if (this.closed) {
|
|
44957
|
+
return;
|
|
44958
|
+
}
|
|
44959
|
+
const nextChunk = await this.source.next();
|
|
44960
|
+
if (nextChunk.done) {
|
|
44961
|
+
return;
|
|
44962
|
+
}
|
|
44963
|
+
if (nextChunk.value.numRows === 0) {
|
|
44964
|
+
continue;
|
|
44965
|
+
}
|
|
44966
|
+
yield new response_js_1.BinaryContent({
|
|
44967
|
+
data: (0, apache_arrow_1.tableToIPC)(nextChunk.value, "stream"),
|
|
44968
|
+
headers: { kind: "data", content_type: ARROW_IPC_STREAM_MIME_TYPE }
|
|
44969
|
+
});
|
|
44970
|
+
}
|
|
44971
|
+
}
|
|
44972
|
+
};
|
|
44973
|
+
var SqliteArrowReadInputStream = class {
|
|
44974
|
+
constructor(start) {
|
|
44975
|
+
this.start = start;
|
|
44976
|
+
this.pulls = [];
|
|
44977
|
+
this.closed = false;
|
|
44978
|
+
}
|
|
44979
|
+
requestNext() {
|
|
44980
|
+
if (this.closed) {
|
|
44981
|
+
return;
|
|
44982
|
+
}
|
|
44983
|
+
const waiter = this.pulls.shift();
|
|
44984
|
+
if (waiter) {
|
|
44985
|
+
waiter();
|
|
44986
|
+
return;
|
|
44987
|
+
}
|
|
44988
|
+
this.pulls.push(() => void 0);
|
|
44989
|
+
}
|
|
44990
|
+
close() {
|
|
44991
|
+
if (this.closed) {
|
|
44992
|
+
return;
|
|
44993
|
+
}
|
|
44994
|
+
this.closed = true;
|
|
44995
|
+
while (this.pulls.length > 0) {
|
|
44996
|
+
const waiter = this.pulls.shift();
|
|
44997
|
+
waiter?.();
|
|
44998
|
+
}
|
|
44999
|
+
}
|
|
45000
|
+
async waitForPull() {
|
|
45001
|
+
if (this.closed) {
|
|
45002
|
+
return;
|
|
45003
|
+
}
|
|
45004
|
+
const waiter = this.pulls.shift();
|
|
45005
|
+
if (waiter) {
|
|
45006
|
+
waiter();
|
|
45007
|
+
return;
|
|
45008
|
+
}
|
|
45009
|
+
await new Promise((resolve) => {
|
|
45010
|
+
this.pulls.push(resolve);
|
|
45011
|
+
});
|
|
45012
|
+
}
|
|
45013
|
+
async *stream() {
|
|
45014
|
+
yield new response_js_1.BinaryContent({ data: new Uint8Array(), headers: this.start });
|
|
45015
|
+
while (!this.closed) {
|
|
45016
|
+
await this.waitForPull();
|
|
45017
|
+
if (this.closed) {
|
|
45018
|
+
return;
|
|
45019
|
+
}
|
|
45020
|
+
yield new response_js_1.BinaryContent({ data: new Uint8Array(), headers: { kind: "pull" } });
|
|
45021
|
+
}
|
|
45022
|
+
}
|
|
45023
|
+
};
|
|
45024
|
+
var SqliteDatabaseClient = class {
|
|
45025
|
+
constructor(client, database, namespace) {
|
|
45026
|
+
this.client = client;
|
|
45027
|
+
this.database = database;
|
|
45028
|
+
this.namespace = namespace;
|
|
45029
|
+
}
|
|
45030
|
+
async createDatabase({ mode = "create" } = {}) {
|
|
45031
|
+
return this.client.createDatabase({ name: this.database, namespace: this.namespace, mode });
|
|
45032
|
+
}
|
|
45033
|
+
async dropDatabase({ ignoreMissing = false } = {}) {
|
|
45034
|
+
return this.client.dropDatabase({ name: this.database, namespace: this.namespace, ignoreMissing });
|
|
45035
|
+
}
|
|
45036
|
+
async inspectDatabase() {
|
|
45037
|
+
return this.client.inspectDatabase({ name: this.database, namespace: this.namespace });
|
|
45038
|
+
}
|
|
45039
|
+
async listTables() {
|
|
45040
|
+
return this.client.listTables({ database: this.database, namespace: this.namespace });
|
|
45041
|
+
}
|
|
45042
|
+
async createTableWithSchema(params) {
|
|
45043
|
+
return this.client.createTableWithSchema({ ...params, database: this.database, namespace: this.namespace });
|
|
45044
|
+
}
|
|
45045
|
+
async createTableFromData(params) {
|
|
45046
|
+
return this.client.createTableFromData({ ...params, database: this.database, namespace: this.namespace });
|
|
45047
|
+
}
|
|
45048
|
+
async dropTable(params) {
|
|
45049
|
+
return this.client.dropTable({ ...params, database: this.database, namespace: this.namespace });
|
|
45050
|
+
}
|
|
45051
|
+
async renameTable(params) {
|
|
45052
|
+
return this.client.renameTable({ ...params, database: this.database, namespace: this.namespace });
|
|
45053
|
+
}
|
|
45054
|
+
async inspect(params) {
|
|
45055
|
+
return this.client.inspect({ ...params, database: this.database, namespace: this.namespace });
|
|
45056
|
+
}
|
|
45057
|
+
async addColumns(params) {
|
|
45058
|
+
return this.client.addColumns({ ...params, database: this.database, namespace: this.namespace });
|
|
45059
|
+
}
|
|
45060
|
+
async dropColumns(params) {
|
|
45061
|
+
return this.client.dropColumns({ ...params, database: this.database, namespace: this.namespace });
|
|
45062
|
+
}
|
|
45063
|
+
async insert(params) {
|
|
45064
|
+
return this.client.insert({ ...params, database: this.database, namespace: this.namespace });
|
|
45065
|
+
}
|
|
45066
|
+
async update(params) {
|
|
45067
|
+
return this.client.update({ ...params, database: this.database, namespace: this.namespace });
|
|
45068
|
+
}
|
|
45069
|
+
async delete(params) {
|
|
45070
|
+
return this.client.delete({ ...params, database: this.database, namespace: this.namespace });
|
|
45071
|
+
}
|
|
45072
|
+
async search(params) {
|
|
45073
|
+
return this.client.search({ ...params, database: this.database, namespace: this.namespace });
|
|
45074
|
+
}
|
|
45075
|
+
async searchTable(params) {
|
|
45076
|
+
return this.client.searchTable({ ...params, database: this.database, namespace: this.namespace });
|
|
45077
|
+
}
|
|
45078
|
+
async searchStream(params) {
|
|
45079
|
+
return this.client.searchStream({ ...params, database: this.database, namespace: this.namespace });
|
|
45080
|
+
}
|
|
45081
|
+
async count(params) {
|
|
45082
|
+
return this.client.count({ ...params, database: this.database, namespace: this.namespace });
|
|
45083
|
+
}
|
|
45084
|
+
async sql(params) {
|
|
45085
|
+
return this.client.sql({ ...params, database: this.database, namespace: this.namespace });
|
|
45086
|
+
}
|
|
45087
|
+
async sqlTable(params) {
|
|
45088
|
+
return this.client.sqlTable({ ...params, database: this.database, namespace: this.namespace });
|
|
45089
|
+
}
|
|
45090
|
+
async *sqlStream(params) {
|
|
45091
|
+
yield* this.client.sqlStream({ ...params, database: this.database, namespace: this.namespace });
|
|
45092
|
+
}
|
|
45093
|
+
async executeSql(params) {
|
|
45094
|
+
return this.client.executeSql({ ...params, database: this.database, namespace: this.namespace });
|
|
45095
|
+
}
|
|
45096
|
+
async executeSqlStatement(params) {
|
|
45097
|
+
return this.client.executeSqlStatement({ ...params, database: this.database, namespace: this.namespace });
|
|
45098
|
+
}
|
|
45099
|
+
};
|
|
45100
|
+
exports.SqliteDatabaseClient = SqliteDatabaseClient;
|
|
45101
|
+
var SqliteClient = class {
|
|
45102
|
+
constructor({ room }) {
|
|
45103
|
+
this.room = room;
|
|
45104
|
+
}
|
|
45105
|
+
unexpectedResponseError(operation) {
|
|
45106
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from sqlite.${operation}`);
|
|
45107
|
+
}
|
|
45108
|
+
database(name, { namespace } = {}) {
|
|
45109
|
+
return new SqliteDatabaseClient(this, name, namespace);
|
|
45110
|
+
}
|
|
45111
|
+
async invoke(operation, input) {
|
|
45112
|
+
return await this.room.invokeContent({ toolkit: "sqlite", tool: operation, input });
|
|
45113
|
+
}
|
|
45114
|
+
async invokeContent(operation, input) {
|
|
45115
|
+
return await this.room.invokeContent({ toolkit: "sqlite", tool: operation, input });
|
|
45116
|
+
}
|
|
45117
|
+
async invokeStream(operation, input) {
|
|
45118
|
+
return await this.room.invokeStream({ toolkit: "sqlite", tool: operation, input });
|
|
45119
|
+
}
|
|
45120
|
+
async drainWriteStream(operation, input) {
|
|
45121
|
+
const response = await this.invokeStream(operation, input.stream());
|
|
45122
|
+
try {
|
|
45123
|
+
for await (const chunk of response) {
|
|
45124
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
45125
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
45126
|
+
}
|
|
45127
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
45128
|
+
if (chunk.method === "close") {
|
|
45129
|
+
return;
|
|
45130
|
+
}
|
|
45131
|
+
throw this.unexpectedResponseError(operation);
|
|
45132
|
+
}
|
|
45133
|
+
if (!(chunk instanceof response_js_1.BinaryContent) || chunk.headers.kind !== "pull") {
|
|
45134
|
+
throw this.unexpectedResponseError(operation);
|
|
45135
|
+
}
|
|
45136
|
+
input.requestNext();
|
|
45137
|
+
}
|
|
45138
|
+
} finally {
|
|
45139
|
+
input.close();
|
|
45140
|
+
}
|
|
45141
|
+
}
|
|
45142
|
+
async *streamArrow(operation, start) {
|
|
45143
|
+
const input = new SqliteArrowReadInputStream(start);
|
|
45144
|
+
const response = await this.invokeStream(operation, input.stream());
|
|
45145
|
+
input.requestNext();
|
|
45146
|
+
try {
|
|
45147
|
+
for await (const chunk of response) {
|
|
45148
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
45149
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
45150
|
+
}
|
|
45151
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
45152
|
+
if (chunk.method === "close") {
|
|
45153
|
+
return;
|
|
45154
|
+
}
|
|
45155
|
+
throw this.unexpectedResponseError(operation);
|
|
45156
|
+
}
|
|
45157
|
+
if (!(chunk instanceof response_js_1.BinaryContent) || chunk.headers.kind !== "data") {
|
|
45158
|
+
throw this.unexpectedResponseError(operation);
|
|
45159
|
+
}
|
|
45160
|
+
yield tableFromIPCBytes(chunk.data);
|
|
45161
|
+
input.requestNext();
|
|
45162
|
+
}
|
|
45163
|
+
} finally {
|
|
45164
|
+
input.close();
|
|
45165
|
+
}
|
|
44789
45166
|
}
|
|
44790
|
-
async
|
|
44791
|
-
const response = await this.
|
|
44792
|
-
if (!(response instanceof response_js_1.
|
|
44793
|
-
throw this.
|
|
45167
|
+
async listDatabases({ namespace } = {}) {
|
|
45168
|
+
const response = await this.invoke("list_databases", { namespace: namespace ?? null });
|
|
45169
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.databases)) {
|
|
45170
|
+
throw this.unexpectedResponseError("list_databases");
|
|
44794
45171
|
}
|
|
45172
|
+
return response.json.databases;
|
|
44795
45173
|
}
|
|
44796
|
-
async
|
|
44797
|
-
const response = await this.
|
|
45174
|
+
async createDatabase({ name, namespace, mode = "create" }) {
|
|
45175
|
+
const response = await this.invoke("create_database", { name, namespace: namespace ?? null, mode });
|
|
44798
45176
|
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44799
|
-
throw this.
|
|
45177
|
+
throw this.unexpectedResponseError("create_database");
|
|
44800
45178
|
}
|
|
44801
45179
|
}
|
|
44802
|
-
async
|
|
44803
|
-
const response = await this.
|
|
45180
|
+
async dropDatabase({ name, namespace, ignoreMissing = false }) {
|
|
45181
|
+
const response = await this.invoke("drop_database", { name, namespace: namespace ?? null, ignore_missing: ignoreMissing });
|
|
44804
45182
|
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44805
|
-
throw this.
|
|
45183
|
+
throw this.unexpectedResponseError("drop_database");
|
|
44806
45184
|
}
|
|
44807
45185
|
}
|
|
44808
|
-
async
|
|
44809
|
-
const response = await this.
|
|
44810
|
-
if (!(response instanceof response_js_1.
|
|
44811
|
-
throw this.
|
|
45186
|
+
async inspectDatabase({ name, namespace }) {
|
|
45187
|
+
const response = await this.invoke("inspect_database", { name, namespace: namespace ?? null });
|
|
45188
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json.name !== "string" || typeof response.json.tables !== "number") {
|
|
45189
|
+
throw this.unexpectedResponseError("inspect_database");
|
|
44812
45190
|
}
|
|
45191
|
+
return {
|
|
45192
|
+
name: response.json.name,
|
|
45193
|
+
namespace: Array.isArray(response.json.namespace) ? response.json.namespace : null,
|
|
45194
|
+
tables: response.json.tables,
|
|
45195
|
+
sizeBytes: typeof response.json.size_bytes === "number" ? response.json.size_bytes : 0
|
|
45196
|
+
};
|
|
44813
45197
|
}
|
|
44814
|
-
async
|
|
44815
|
-
const response = await this.
|
|
44816
|
-
|
|
44817
|
-
|
|
44818
|
-
wait
|
|
44819
|
-
});
|
|
44820
|
-
if (response instanceof response_js_1.EmptyContent) {
|
|
44821
|
-
return null;
|
|
44822
|
-
}
|
|
44823
|
-
if (response instanceof response_js_1.JsonContent) {
|
|
44824
|
-
return response.json;
|
|
45198
|
+
async listTables({ database, namespace }) {
|
|
45199
|
+
const response = await this.invoke("list_tables", { database, namespace: namespace ?? null });
|
|
45200
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.tables)) {
|
|
45201
|
+
throw this.unexpectedResponseError("list_tables");
|
|
44825
45202
|
}
|
|
44826
|
-
|
|
45203
|
+
return response.json.tables;
|
|
44827
45204
|
}
|
|
44828
|
-
|
|
44829
|
-
|
|
44830
|
-
|
|
44831
|
-
|
|
44832
|
-
|
|
44833
|
-
|
|
44834
|
-
|
|
44835
|
-
|
|
44836
|
-
|
|
44837
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44838
|
-
exports.SecretsClient = void 0;
|
|
44839
|
-
var response_js_1 = require_response();
|
|
44840
|
-
var room_server_client_js_1 = require_room_server_client();
|
|
44841
|
-
var utils_js_1 = require_utils();
|
|
44842
|
-
function isRecord(value) {
|
|
44843
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44844
|
-
}
|
|
44845
|
-
var SecretsClient = class {
|
|
44846
|
-
constructor({ room, oauthTokenRequestHandler, secretRequestHandler }) {
|
|
44847
|
-
this._oauthRequestHandler = this._handleClientOAuthTokenRequest.bind(this);
|
|
44848
|
-
this._secretRequestHandler = this._handleClientSecretRequest.bind(this);
|
|
44849
|
-
this.client = room;
|
|
44850
|
-
this.oauthTokenRequestHandler = oauthTokenRequestHandler;
|
|
44851
|
-
this.secretRequestHandler = secretRequestHandler;
|
|
44852
|
-
this.client.protocol.addHandler("secrets.request_oauth_token", this._oauthRequestHandler);
|
|
44853
|
-
this.client.protocol.addHandler("secrets.request_secret", this._secretRequestHandler);
|
|
45205
|
+
async createTable({ database, name, data, schema, mode = "create", namespace }) {
|
|
45206
|
+
const input = new SqliteArrowWriteInputStream({
|
|
45207
|
+
kind: "start",
|
|
45208
|
+
database,
|
|
45209
|
+
name,
|
|
45210
|
+
mode,
|
|
45211
|
+
namespace: namespace ?? null
|
|
45212
|
+
}, data ?? [], schema);
|
|
45213
|
+
await this.drainWriteStream("create_table", input);
|
|
44854
45214
|
}
|
|
44855
|
-
|
|
44856
|
-
return
|
|
45215
|
+
async createTableWithSchema({ database, name, schema, data, mode = "create", namespace }) {
|
|
45216
|
+
return this.createTable({
|
|
45217
|
+
database,
|
|
45218
|
+
name,
|
|
45219
|
+
schema,
|
|
45220
|
+
data: data == null ? void 0 : data instanceof apache_arrow_1.Table ? [data] : data,
|
|
45221
|
+
mode,
|
|
45222
|
+
namespace
|
|
45223
|
+
});
|
|
44857
45224
|
}
|
|
44858
|
-
async
|
|
44859
|
-
return
|
|
44860
|
-
|
|
44861
|
-
|
|
44862
|
-
|
|
45225
|
+
async createTableFromData({ database, name, data, mode = "create", namespace }) {
|
|
45226
|
+
return this.createTable({
|
|
45227
|
+
database,
|
|
45228
|
+
name,
|
|
45229
|
+
data: data == null ? void 0 : data instanceof apache_arrow_1.Table ? [data] : data,
|
|
45230
|
+
mode,
|
|
45231
|
+
namespace
|
|
44863
45232
|
});
|
|
44864
45233
|
}
|
|
44865
|
-
|
|
44866
|
-
|
|
44867
|
-
|
|
45234
|
+
async dropTable({ database, name, ignoreMissing = false, namespace }) {
|
|
45235
|
+
const response = await this.invoke("drop_table", { database, name, ignore_missing: ignoreMissing, namespace: namespace ?? null });
|
|
45236
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
45237
|
+
throw this.unexpectedResponseError("drop_table");
|
|
44868
45238
|
}
|
|
44869
|
-
return {
|
|
44870
|
-
openai_connector_id: connector.openaiConnectorId ?? null,
|
|
44871
|
-
server_url: connector.serverUrl ?? null,
|
|
44872
|
-
client_secret_id: connector.clientSecretId ?? null
|
|
44873
|
-
};
|
|
44874
45239
|
}
|
|
44875
|
-
|
|
44876
|
-
|
|
44877
|
-
|
|
45240
|
+
async renameTable({ database, name, newName, namespace }) {
|
|
45241
|
+
const response = await this.invoke("rename_table", { database, name, new_name: newName, namespace: namespace ?? null });
|
|
45242
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
45243
|
+
throw this.unexpectedResponseError("rename_table");
|
|
44878
45244
|
}
|
|
44879
|
-
return {
|
|
44880
|
-
client_id: oauth.client_id,
|
|
44881
|
-
client_secret: oauth.client_secret ?? null,
|
|
44882
|
-
authorization_endpoint: oauth.authorization_endpoint,
|
|
44883
|
-
token_endpoint: oauth.token_endpoint,
|
|
44884
|
-
no_pkce: oauth.no_pkce ?? null,
|
|
44885
|
-
scopes: oauth.scopes ?? null
|
|
44886
|
-
};
|
|
44887
45245
|
}
|
|
44888
|
-
|
|
44889
|
-
|
|
44890
|
-
|
|
44891
|
-
|
|
44892
|
-
const token = response.json["access_token"];
|
|
44893
|
-
if (typeof token !== "string" || token.length === 0) {
|
|
44894
|
-
return null;
|
|
45246
|
+
async inspect({ database, table, namespace }) {
|
|
45247
|
+
const response = await this.invoke("inspect", { database, table, namespace: namespace ?? null });
|
|
45248
|
+
if (!(response instanceof response_js_1.BinaryContent)) {
|
|
45249
|
+
throw this.unexpectedResponseError("inspect");
|
|
44895
45250
|
}
|
|
44896
|
-
return
|
|
45251
|
+
return schemaFromIPCBytes(response.data);
|
|
44897
45252
|
}
|
|
44898
|
-
|
|
44899
|
-
|
|
44900
|
-
|
|
44901
|
-
|
|
44902
|
-
|
|
44903
|
-
|
|
44904
|
-
|
|
45253
|
+
async addColumns({ database, table, newColumns, namespace }) {
|
|
45254
|
+
const response = await this.invokeContent("add_columns", new response_js_1.BinaryContent({
|
|
45255
|
+
data: schemaToIPC(newColumns),
|
|
45256
|
+
headers: {
|
|
45257
|
+
database,
|
|
45258
|
+
table,
|
|
45259
|
+
namespace: namespace ?? null,
|
|
45260
|
+
content_type: ARROW_IPC_STREAM_MIME_TYPE
|
|
45261
|
+
}
|
|
45262
|
+
}));
|
|
45263
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
45264
|
+
throw this.unexpectedResponseError("add_columns");
|
|
44905
45265
|
}
|
|
44906
|
-
return {
|
|
44907
|
-
id: value["id"],
|
|
44908
|
-
name: value["name"],
|
|
44909
|
-
type: value["type"],
|
|
44910
|
-
delegatedTo
|
|
44911
|
-
};
|
|
44912
45266
|
}
|
|
44913
|
-
async
|
|
44914
|
-
|
|
44915
|
-
|
|
44916
|
-
|
|
44917
|
-
void messageId;
|
|
44918
|
-
void type;
|
|
44919
|
-
if (bytes == null) {
|
|
44920
|
-
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44921
|
-
}
|
|
44922
|
-
if (this.oauthTokenRequestHandler == null) {
|
|
44923
|
-
throw new room_server_client_js_1.RoomServerException("No oauth token handler registered");
|
|
44924
|
-
}
|
|
44925
|
-
const [request] = (0, utils_js_1.unpackMessage)(bytes);
|
|
44926
|
-
const requestId = request["request_id"];
|
|
44927
|
-
const challenge = request["challenge"];
|
|
44928
|
-
const requestPayload = request["request"];
|
|
44929
|
-
if (typeof requestId !== "string" || !isRecord(requestPayload)) {
|
|
44930
|
-
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44931
|
-
}
|
|
44932
|
-
const oauth = requestPayload["oauth"];
|
|
44933
|
-
if (!isRecord(oauth) || typeof oauth["authorization_endpoint"] !== "string" || typeof oauth["token_endpoint"] !== "string") {
|
|
44934
|
-
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44935
|
-
}
|
|
44936
|
-
const scopes = oauth["scopes"];
|
|
44937
|
-
if (scopes !== void 0 && scopes !== null && (!Array.isArray(scopes) || scopes.some((scope) => typeof scope !== "string"))) {
|
|
44938
|
-
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
45267
|
+
async dropColumns({ database, table, columns, namespace }) {
|
|
45268
|
+
const response = await this.invoke("drop_columns", { database, table, columns, namespace: namespace ?? null });
|
|
45269
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
45270
|
+
throw this.unexpectedResponseError("drop_columns");
|
|
44939
45271
|
}
|
|
44940
|
-
Promise.resolve(this.oauthTokenRequestHandler({
|
|
44941
|
-
requestId,
|
|
44942
|
-
authorizationEndpoint: oauth["authorization_endpoint"],
|
|
44943
|
-
tokenEndpoint: oauth["token_endpoint"],
|
|
44944
|
-
challenge: typeof challenge === "string" ? challenge : null,
|
|
44945
|
-
scopes: scopes ?? null,
|
|
44946
|
-
clientId: typeof oauth["client_id"] === "string" ? oauth["client_id"] : null
|
|
44947
|
-
})).catch((error) => {
|
|
44948
|
-
console.warn("OAuth token request handler threw", error);
|
|
44949
|
-
});
|
|
44950
45272
|
}
|
|
44951
|
-
async
|
|
44952
|
-
|
|
44953
|
-
return;
|
|
44954
|
-
}
|
|
44955
|
-
void messageId;
|
|
44956
|
-
void type;
|
|
44957
|
-
if (bytes == null) {
|
|
44958
|
-
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_secret payload");
|
|
44959
|
-
}
|
|
44960
|
-
if (this.secretRequestHandler == null) {
|
|
44961
|
-
throw new room_server_client_js_1.RoomServerException("No secret handler registered");
|
|
44962
|
-
}
|
|
44963
|
-
const [request] = (0, utils_js_1.unpackMessage)(bytes);
|
|
44964
|
-
const requestId = request["request_id"];
|
|
44965
|
-
const requestPayload = request["request"];
|
|
44966
|
-
if (typeof requestId !== "string" || !isRecord(requestPayload) || typeof requestPayload["url"] !== "string" || typeof requestPayload["type"] !== "string") {
|
|
44967
|
-
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_secret payload");
|
|
44968
|
-
}
|
|
44969
|
-
Promise.resolve(this.secretRequestHandler({
|
|
44970
|
-
requestId,
|
|
44971
|
-
url: requestPayload["url"],
|
|
44972
|
-
type: requestPayload["type"],
|
|
44973
|
-
delegateTo: typeof requestPayload["delegate_to"] === "string" ? requestPayload["delegate_to"] : null
|
|
44974
|
-
})).catch((error) => {
|
|
44975
|
-
console.warn("Secret request handler threw", error);
|
|
44976
|
-
});
|
|
45273
|
+
async insert({ database, table, records, namespace }) {
|
|
45274
|
+
await this.insertStream({ database, table, chunks: [records], namespace });
|
|
44977
45275
|
}
|
|
44978
|
-
async
|
|
44979
|
-
const
|
|
44980
|
-
|
|
44981
|
-
|
|
44982
|
-
|
|
44983
|
-
|
|
44984
|
-
|
|
44985
|
-
|
|
44986
|
-
}
|
|
44987
|
-
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
45276
|
+
async insertStream({ database, table, chunks, namespace }) {
|
|
45277
|
+
const input = new SqliteArrowWriteInputStream({
|
|
45278
|
+
kind: "start",
|
|
45279
|
+
database,
|
|
45280
|
+
table,
|
|
45281
|
+
namespace: namespace ?? null
|
|
45282
|
+
}, chunks);
|
|
45283
|
+
await this.drainWriteStream("insert", input);
|
|
44988
45284
|
}
|
|
44989
|
-
async
|
|
44990
|
-
const response = await this.invoke("
|
|
44991
|
-
|
|
44992
|
-
|
|
44993
|
-
|
|
45285
|
+
async update({ database, table, where, values, params, namespace }) {
|
|
45286
|
+
const response = await this.invoke("update", {
|
|
45287
|
+
database,
|
|
45288
|
+
table,
|
|
45289
|
+
where,
|
|
45290
|
+
values: Object.entries(values).map(([column, value]) => ({ column, value_json: JSON.stringify(encodeRecordValue(value)) })),
|
|
45291
|
+
params: params ?? null,
|
|
45292
|
+
namespace: namespace ?? null
|
|
44994
45293
|
});
|
|
44995
|
-
if (response instanceof response_js_1.
|
|
44996
|
-
|
|
45294
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json.rows_affected !== "number") {
|
|
45295
|
+
throw this.unexpectedResponseError("update");
|
|
44997
45296
|
}
|
|
44998
|
-
|
|
45297
|
+
return response.json.rows_affected;
|
|
44999
45298
|
}
|
|
45000
|
-
async
|
|
45001
|
-
const response = await this.invoke("
|
|
45002
|
-
|
|
45003
|
-
|
|
45004
|
-
request_id: requestId,
|
|
45005
|
-
error: null
|
|
45006
|
-
}
|
|
45007
|
-
}));
|
|
45008
|
-
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
45009
|
-
return;
|
|
45299
|
+
async delete({ database, table, where, params, namespace }) {
|
|
45300
|
+
const response = await this.invoke("delete", { database, table, where, params: params ?? null, namespace: namespace ?? null });
|
|
45301
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json.rows_affected !== "number") {
|
|
45302
|
+
throw this.unexpectedResponseError("delete");
|
|
45010
45303
|
}
|
|
45011
|
-
|
|
45304
|
+
return response.json.rows_affected;
|
|
45012
45305
|
}
|
|
45013
|
-
async
|
|
45014
|
-
const
|
|
45015
|
-
|
|
45016
|
-
|
|
45017
|
-
request_id: requestId,
|
|
45018
|
-
error
|
|
45019
|
-
}
|
|
45020
|
-
}));
|
|
45021
|
-
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
45022
|
-
return;
|
|
45306
|
+
async search({ database, table, where, params, offset, limit, select, namespace }) {
|
|
45307
|
+
const results = [];
|
|
45308
|
+
for await (const chunk of this.searchStream({ database, table, where, params, offset, limit, select, namespace })) {
|
|
45309
|
+
results.push(chunk);
|
|
45023
45310
|
}
|
|
45024
|
-
|
|
45311
|
+
return results;
|
|
45025
45312
|
}
|
|
45026
|
-
async
|
|
45027
|
-
|
|
45028
|
-
connector: this.serializeConnectorRef(connector),
|
|
45029
|
-
oauth: this.serializeOAuthConfig(oauth),
|
|
45030
|
-
delegated_to: delegatedTo ?? null,
|
|
45031
|
-
delegated_by: delegatedBy ?? null
|
|
45032
|
-
});
|
|
45033
|
-
return this.parseAccessToken("get_offline_oauth_token", response);
|
|
45313
|
+
async searchTable({ database, table, where, params, offset, limit, select, namespace }) {
|
|
45314
|
+
return tableFromChunks(await this.search({ database, table, where, params, offset, limit, select, namespace }));
|
|
45034
45315
|
}
|
|
45035
|
-
async
|
|
45036
|
-
|
|
45037
|
-
|
|
45038
|
-
|
|
45039
|
-
|
|
45040
|
-
|
|
45041
|
-
|
|
45042
|
-
|
|
45316
|
+
async *searchStream({ database, table, where, params, offset, limit, select, namespace }) {
|
|
45317
|
+
yield* this.streamArrow("search", {
|
|
45318
|
+
kind: "start",
|
|
45319
|
+
database,
|
|
45320
|
+
table,
|
|
45321
|
+
where: buildWhereClause(where),
|
|
45322
|
+
params: params ?? null,
|
|
45323
|
+
offset: offset ?? null,
|
|
45324
|
+
limit: limit ?? null,
|
|
45325
|
+
select: select ?? null,
|
|
45326
|
+
namespace: namespace ?? null
|
|
45043
45327
|
});
|
|
45044
|
-
return this.parseAccessToken("request_oauth_token", response);
|
|
45045
45328
|
}
|
|
45046
|
-
async
|
|
45047
|
-
const response = await this.invoke("
|
|
45048
|
-
|
|
45049
|
-
|
|
45050
|
-
|
|
45051
|
-
|
|
45052
|
-
|
|
45053
|
-
|
|
45329
|
+
async count({ database, table, where, params, namespace }) {
|
|
45330
|
+
const response = await this.invoke("count", {
|
|
45331
|
+
database,
|
|
45332
|
+
table,
|
|
45333
|
+
where: buildWhereClause(where),
|
|
45334
|
+
params: params ?? null,
|
|
45335
|
+
namespace: namespace ?? null
|
|
45336
|
+
});
|
|
45337
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json.count !== "number" || !Number.isInteger(response.json.count)) {
|
|
45338
|
+
throw this.unexpectedResponseError("count");
|
|
45054
45339
|
}
|
|
45055
|
-
return
|
|
45340
|
+
return response.json.count;
|
|
45056
45341
|
}
|
|
45057
|
-
async
|
|
45058
|
-
const
|
|
45059
|
-
|
|
45060
|
-
|
|
45061
|
-
for_identity: forIdentity ?? null
|
|
45062
|
-
});
|
|
45063
|
-
if (!(response instanceof response_js_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
45064
|
-
throw this.unexpectedResponse("exists");
|
|
45342
|
+
async sql({ database, query, params, namespace }) {
|
|
45343
|
+
const results = [];
|
|
45344
|
+
for await (const chunk of this.sqlStream({ database, query, params, namespace })) {
|
|
45345
|
+
results.push(chunk);
|
|
45065
45346
|
}
|
|
45066
|
-
return
|
|
45347
|
+
return results;
|
|
45067
45348
|
}
|
|
45068
|
-
async
|
|
45069
|
-
|
|
45070
|
-
|
|
45071
|
-
|
|
45072
|
-
|
|
45073
|
-
|
|
45074
|
-
|
|
45349
|
+
async sqlTable({ database, query, params, namespace }) {
|
|
45350
|
+
return tableFromChunks(await this.sql({ database, query, params, namespace }));
|
|
45351
|
+
}
|
|
45352
|
+
async openSqlQuery({ database, query, params, namespace }) {
|
|
45353
|
+
const response = await this.invokeContent("open_sql_query", new response_js_1.BinaryContent({
|
|
45354
|
+
data: new Uint8Array(),
|
|
45355
|
+
headers: { database, query, params: params ?? null, namespace: namespace ?? null }
|
|
45356
|
+
}));
|
|
45357
|
+
if (!(response instanceof response_js_1.BinaryContent)) {
|
|
45358
|
+
throw this.unexpectedResponseError("open_sql_query");
|
|
45359
|
+
}
|
|
45360
|
+
const queryId = response.headers.query_id;
|
|
45361
|
+
if (typeof queryId !== "string" || queryId === "") {
|
|
45362
|
+
throw this.unexpectedResponseError("open_sql_query");
|
|
45075
45363
|
}
|
|
45076
|
-
|
|
45364
|
+
return {
|
|
45365
|
+
schema: schemaFromIPCBytes(response.data),
|
|
45366
|
+
kind: "query",
|
|
45367
|
+
queryId
|
|
45368
|
+
};
|
|
45077
45369
|
}
|
|
45078
|
-
async
|
|
45079
|
-
const response = await this.
|
|
45080
|
-
|
|
45081
|
-
|
|
45082
|
-
|
|
45083
|
-
|
|
45084
|
-
|
|
45085
|
-
|
|
45370
|
+
async executeSql({ database, query, params, namespace }) {
|
|
45371
|
+
const response = await this.invokeContent("execute_sql", new response_js_1.BinaryContent({
|
|
45372
|
+
data: new Uint8Array(),
|
|
45373
|
+
headers: { database, query, params: params ?? null, namespace: namespace ?? null }
|
|
45374
|
+
}));
|
|
45375
|
+
if (response instanceof response_js_1.BinaryContent) {
|
|
45376
|
+
if (response.headers.kind !== "query") {
|
|
45377
|
+
throw this.unexpectedResponseError("execute_sql");
|
|
45378
|
+
}
|
|
45379
|
+
const queryId = response.headers.query_id;
|
|
45380
|
+
if (typeof queryId !== "string" || queryId === "") {
|
|
45381
|
+
throw this.unexpectedResponseError("execute_sql");
|
|
45382
|
+
}
|
|
45383
|
+
return {
|
|
45384
|
+
kind: "query",
|
|
45385
|
+
schema: schemaFromIPCBytes(response.data),
|
|
45386
|
+
queryId
|
|
45387
|
+
};
|
|
45388
|
+
}
|
|
45389
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
45390
|
+
if (response.json.kind !== "statement" || typeof response.json.rows_affected !== "number" || !Number.isInteger(response.json.rows_affected)) {
|
|
45391
|
+
throw this.unexpectedResponseError("execute_sql");
|
|
45392
|
+
}
|
|
45393
|
+
return {
|
|
45394
|
+
kind: "statement",
|
|
45395
|
+
rowsAffected: response.json.rows_affected
|
|
45396
|
+
};
|
|
45086
45397
|
}
|
|
45087
|
-
throw this.
|
|
45398
|
+
throw this.unexpectedResponseError("execute_sql");
|
|
45088
45399
|
}
|
|
45089
|
-
async
|
|
45090
|
-
const
|
|
45091
|
-
|
|
45092
|
-
|
|
45093
|
-
|
|
45094
|
-
|
|
45095
|
-
|
|
45096
|
-
}
|
|
45097
|
-
|
|
45098
|
-
return response.data;
|
|
45400
|
+
async *sqlStream({ database, query, params, namespace }) {
|
|
45401
|
+
const result = await this.executeSql({ database, query, params, namespace });
|
|
45402
|
+
if (result.kind === "statement") {
|
|
45403
|
+
throw new room_server_client_js_1.RoomServerException(`SQL statement did not return rows; rows_affected=${result.rowsAffected}`);
|
|
45404
|
+
}
|
|
45405
|
+
try {
|
|
45406
|
+
yield* this.readSqlQuery({ queryId: result.queryId });
|
|
45407
|
+
} finally {
|
|
45408
|
+
await this.closeSqlQuery({ queryId: result.queryId });
|
|
45099
45409
|
}
|
|
45100
|
-
throw this.unexpectedResponse("request_secret");
|
|
45101
45410
|
}
|
|
45102
|
-
async
|
|
45103
|
-
|
|
45104
|
-
|
|
45105
|
-
|
|
45106
|
-
|
|
45107
|
-
|
|
45108
|
-
|
|
45109
|
-
delegated_to: delegatedTo ?? null,
|
|
45110
|
-
for_identity: forIdentity ?? null,
|
|
45111
|
-
has_data: true
|
|
45112
|
-
}
|
|
45113
|
-
}));
|
|
45114
|
-
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
45115
|
-
return;
|
|
45411
|
+
async *readSqlQuery({ queryId }) {
|
|
45412
|
+
yield* this.streamArrow("read_sql_query", { kind: "start", query_id: queryId });
|
|
45413
|
+
}
|
|
45414
|
+
async closeSqlQuery({ queryId }) {
|
|
45415
|
+
const response = await this.invoke("close_sql_query", { query_id: queryId });
|
|
45416
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
45417
|
+
throw this.unexpectedResponseError("close_sql_query");
|
|
45116
45418
|
}
|
|
45117
|
-
throw this.unexpectedResponse("set_secret");
|
|
45118
45419
|
}
|
|
45119
|
-
async
|
|
45120
|
-
const response = await this.invoke("
|
|
45121
|
-
|
|
45122
|
-
|
|
45123
|
-
name: name ?? null,
|
|
45124
|
-
delegated_to: delegatedTo ?? null
|
|
45125
|
-
});
|
|
45126
|
-
if (response instanceof response_js_1.EmptyContent) {
|
|
45127
|
-
return null;
|
|
45420
|
+
async cancelSqlQuery({ queryId }) {
|
|
45421
|
+
const response = await this.invoke("cancel_sql_query", { query_id: queryId });
|
|
45422
|
+
if (!(response instanceof response_js_1.JsonContent) || !["cancelled", "cancelling", "not_cancellable"].includes(response.json.status)) {
|
|
45423
|
+
throw this.unexpectedResponseError("cancel_sql_query");
|
|
45128
45424
|
}
|
|
45129
|
-
|
|
45130
|
-
|
|
45425
|
+
return { status: response.json.status };
|
|
45426
|
+
}
|
|
45427
|
+
async executeSqlStatement({ database, query, params, namespace }) {
|
|
45428
|
+
const response = await this.invokeContent("execute_sql_statement", new response_js_1.BinaryContent({
|
|
45429
|
+
data: new Uint8Array(),
|
|
45430
|
+
headers: { database, query, params: params ?? null, namespace: namespace ?? null }
|
|
45431
|
+
}));
|
|
45432
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json.rows_affected !== "number" || !Number.isInteger(response.json.rows_affected)) {
|
|
45433
|
+
throw this.unexpectedResponseError("execute_sql_statement");
|
|
45131
45434
|
}
|
|
45132
|
-
|
|
45435
|
+
return response.json.rows_affected;
|
|
45133
45436
|
}
|
|
45134
45437
|
};
|
|
45135
|
-
exports.
|
|
45438
|
+
exports.SqliteClient = SqliteClient;
|
|
45136
45439
|
}
|
|
45137
45440
|
});
|
|
45138
45441
|
|
|
@@ -45159,6 +45462,7 @@ ${newlined}
|
|
|
45159
45462
|
}
|
|
45160
45463
|
const state = value["state"];
|
|
45161
45464
|
const containerId = value["container_id"];
|
|
45465
|
+
const eventsRaw = value["events"];
|
|
45162
45466
|
return {
|
|
45163
45467
|
serviceId: value["service_id"],
|
|
45164
45468
|
state: typeof state === "string" ? state : "unknown",
|
|
@@ -45167,7 +45471,23 @@ ${newlined}
|
|
|
45167
45471
|
startedAt: toOptionalNumber(value["started_at"]),
|
|
45168
45472
|
restartCount: toOptionalInteger(value["restart_count"]) ?? 0,
|
|
45169
45473
|
lastExitCode: toOptionalInteger(value["last_exit_code"]),
|
|
45170
|
-
lastExitAt: toOptionalNumber(value["last_exit_at"])
|
|
45474
|
+
lastExitAt: toOptionalNumber(value["last_exit_at"]),
|
|
45475
|
+
lastStartError: typeof value["last_start_error"] === "string" ? value["last_start_error"] : void 0,
|
|
45476
|
+
lastStartErrorAt: toOptionalNumber(value["last_start_error_at"]),
|
|
45477
|
+
events: Array.isArray(eventsRaw) ? eventsRaw.map((event) => parseServiceRuntimeEvent(event)) : []
|
|
45478
|
+
};
|
|
45479
|
+
}
|
|
45480
|
+
function parseServiceRuntimeEvent(value) {
|
|
45481
|
+
if (!isRecord(value)) {
|
|
45482
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from services.list");
|
|
45483
|
+
}
|
|
45484
|
+
return {
|
|
45485
|
+
type: typeof value["type"] === "string" ? value["type"] : "Normal",
|
|
45486
|
+
reason: typeof value["reason"] === "string" ? value["reason"] : "Unknown",
|
|
45487
|
+
message: typeof value["message"] === "string" ? value["message"] : "",
|
|
45488
|
+
count: toOptionalInteger(value["count"]) ?? 1,
|
|
45489
|
+
firstTimestamp: toOptionalNumber(value["first_timestamp"]) ?? 0,
|
|
45490
|
+
lastTimestamp: toOptionalNumber(value["last_timestamp"]) ?? 0
|
|
45171
45491
|
};
|
|
45172
45492
|
}
|
|
45173
45493
|
function parseServiceSpecJson(value) {
|
|
@@ -46209,6 +46529,7 @@ ${newlined}
|
|
|
46209
46529
|
exports.RoomClient = exports.RoomProtocolProxy = void 0;
|
|
46210
46530
|
var completer_js_1 = require_completer();
|
|
46211
46531
|
var datasets_client_js_1 = require_datasets_client();
|
|
46532
|
+
var sqlite_client_js_1 = require_sqlite_client();
|
|
46212
46533
|
var developer_client_js_1 = require_developer_client();
|
|
46213
46534
|
var event_emitter_js_1 = require_event_emitter();
|
|
46214
46535
|
var messaging_client_js_1 = require_messaging_client();
|
|
@@ -46219,7 +46540,6 @@ ${newlined}
|
|
|
46219
46540
|
var response_js_1 = require_response();
|
|
46220
46541
|
var room_event_js_1 = require_room_event();
|
|
46221
46542
|
var room_server_client_js_1 = require_room_server_client();
|
|
46222
|
-
var secrets_client_js_1 = require_secrets_client();
|
|
46223
46543
|
var services_client_js_1 = require_services_client();
|
|
46224
46544
|
var storage_client_js_1 = require_storage_client();
|
|
46225
46545
|
var stream_controller_js_1 = require_stream_controller();
|
|
@@ -46409,7 +46729,7 @@ ${newlined}
|
|
|
46409
46729
|
};
|
|
46410
46730
|
exports.RoomProtocolProxy = RoomProtocolProxy;
|
|
46411
46731
|
var RoomClient = class _RoomClient {
|
|
46412
|
-
constructor({ protocolFactory = null, reconnectTimeout = null
|
|
46732
|
+
constructor({ protocolFactory = null, reconnectTimeout = null } = {}) {
|
|
46413
46733
|
this._entered = false;
|
|
46414
46734
|
this._allowDisconnectedRequests = false;
|
|
46415
46735
|
this._eventsController = new stream_controller_js_1.StreamController();
|
|
@@ -46456,22 +46776,16 @@ ${newlined}
|
|
|
46456
46776
|
this.messaging = new messaging_client_js_1.MessagingClient({ room: this });
|
|
46457
46777
|
this.queues = new queues_client_js_1.QueuesClient({ room: this });
|
|
46458
46778
|
this.datasets = new datasets_client_js_1.DatasetsClient({ room: this });
|
|
46779
|
+
this.sqlite = new sqlite_client_js_1.SqliteClient({ room: this });
|
|
46459
46780
|
this.agents = new agent_client_js_1.AgentsClient({ room: this });
|
|
46460
|
-
this.secrets = new secrets_client_js_1.SecretsClient({
|
|
46461
|
-
room: this,
|
|
46462
|
-
oauthTokenRequestHandler,
|
|
46463
|
-
secretRequestHandler
|
|
46464
|
-
});
|
|
46465
46781
|
this.containers = new containers_client_js_1.ContainersClient({ room: this });
|
|
46466
46782
|
this.memory = new memory_client_js_1.MemoryClient({ room: this });
|
|
46467
46783
|
this.services = new services_client_js_1.ServicesClient({ room: this });
|
|
46468
46784
|
}
|
|
46469
|
-
static withIAP({ url = "./.well-known/meshagent/room/connect", reconnectTimeout = null
|
|
46785
|
+
static withIAP({ url = "./.well-known/meshagent/room/connect", reconnectTimeout = null } = {}) {
|
|
46470
46786
|
return new _RoomClient({
|
|
46471
46787
|
protocolFactory: () => protocol_js_1.WebSocketClientProtocol.withIAP({ url }),
|
|
46472
|
-
reconnectTimeout
|
|
46473
|
-
oauthTokenRequestHandler,
|
|
46474
|
-
secretRequestHandler
|
|
46788
|
+
reconnectTimeout
|
|
46475
46789
|
});
|
|
46476
46790
|
}
|
|
46477
46791
|
get localParticipant() {
|
|
@@ -47905,30 +48219,19 @@ ${newlined}
|
|
|
47905
48219
|
if (connector == null && this.oauth == null) {
|
|
47906
48220
|
return true;
|
|
47907
48221
|
}
|
|
47908
|
-
|
|
47909
|
-
|
|
47910
|
-
|
|
47911
|
-
delegatedTo: agentName
|
|
47912
|
-
});
|
|
47913
|
-
return token != null;
|
|
48222
|
+
void room;
|
|
48223
|
+
void agentName;
|
|
48224
|
+
throw new Error("OAuth MCP connections require proxy-backed user secrets");
|
|
47914
48225
|
}
|
|
47915
48226
|
async authenticate(client, agent, redirectUri) {
|
|
47916
48227
|
const connector = this.buildConnectorRef();
|
|
47917
48228
|
if (connector == null && this.oauth == null) {
|
|
47918
48229
|
return null;
|
|
47919
48230
|
}
|
|
47920
|
-
|
|
47921
|
-
|
|
47922
|
-
|
|
47923
|
-
|
|
47924
|
-
const agentName = agent.getAttribute("name");
|
|
47925
|
-
return await client.secrets.requestOAuthToken({
|
|
47926
|
-
fromParticipantId: localParticipant.id,
|
|
47927
|
-
connector,
|
|
47928
|
-
oauth: this.oauth,
|
|
47929
|
-
redirectUri,
|
|
47930
|
-
delegateTo: agentName == null ? null : String(agentName)
|
|
47931
|
-
});
|
|
48231
|
+
void client;
|
|
48232
|
+
void agent;
|
|
48233
|
+
void redirectUri;
|
|
48234
|
+
throw new Error("OAuth MCP connections require proxy-backed user secrets");
|
|
47932
48235
|
}
|
|
47933
48236
|
};
|
|
47934
48237
|
exports.Connector = Connector;
|
|
@@ -47977,7 +48280,25 @@ ${newlined}
|
|
|
47977
48280
|
const fragment = baseUrl.hash;
|
|
47978
48281
|
return `${baseUrl.protocol}//${userInfo}${bracketIpv6Host(baseUrl.hostname)}:${portValue}${joinedPath}${query}${fragment}`;
|
|
47979
48282
|
}
|
|
47980
|
-
function
|
|
48283
|
+
function proxyMcpServerUrl({ serverUrl, useProxySecret, proxyConfig }) {
|
|
48284
|
+
const secretId = useProxySecret?.trim();
|
|
48285
|
+
if (serverUrl == null || secretId == null || secretId.length === 0 || proxyConfig == null) {
|
|
48286
|
+
return serverUrl;
|
|
48287
|
+
}
|
|
48288
|
+
const apiUrl = proxyConfig.apiUrl.trim().replace(/\/+$/, "");
|
|
48289
|
+
if (apiUrl.length === 0 || proxyConfig.apiKey.trim().length === 0) {
|
|
48290
|
+
throw new Error("meshagent_proxy_config requires apiUrl and apiKey");
|
|
48291
|
+
}
|
|
48292
|
+
const url = new URL(`${apiUrl}/proxy-request`);
|
|
48293
|
+
url.searchParams.set("url", serverUrl);
|
|
48294
|
+
url.searchParams.set("secret-id", secretId);
|
|
48295
|
+
const user = proxyConfig.user?.trim();
|
|
48296
|
+
if (user != null && user.length > 0) {
|
|
48297
|
+
url.searchParams.set("user", user);
|
|
48298
|
+
}
|
|
48299
|
+
return url.toString();
|
|
48300
|
+
}
|
|
48301
|
+
function mcpConnectorsFromRoomServices({ services, agentName, meshagentProxyConfig }) {
|
|
47981
48302
|
const connectors = [];
|
|
47982
48303
|
for (const service of services) {
|
|
47983
48304
|
const filter = service.metadata.annotations?.["meshagent.agent.filter"];
|
|
@@ -47994,12 +48315,22 @@ ${newlined}
|
|
|
47994
48315
|
name: mcp.label,
|
|
47995
48316
|
server: new MCPServer({
|
|
47996
48317
|
serverLabel: mcp.label,
|
|
47997
|
-
serverUrl:
|
|
47998
|
-
|
|
48318
|
+
serverUrl: proxyMcpServerUrl({
|
|
48319
|
+
serverUrl: roomServiceMcpServerUrl({ service, port, endpoint }),
|
|
48320
|
+
useProxySecret: mcp.use_proxy_secret,
|
|
48321
|
+
proxyConfig: meshagentProxyConfig
|
|
48322
|
+
}),
|
|
48323
|
+
headers: mcp.use_proxy_secret != null && meshagentProxyConfig != null ? [
|
|
48324
|
+
...headersFromEndpointSpec(mcp.headers) ?? [],
|
|
48325
|
+
new MCPHeader({
|
|
48326
|
+
name: "Authorization",
|
|
48327
|
+
value: `Bearer ${meshagentProxyConfig.apiKey}`
|
|
48328
|
+
})
|
|
48329
|
+
] : headersFromEndpointSpec(mcp.headers),
|
|
47999
48330
|
requireApproval: mcp.require_approval,
|
|
48000
48331
|
openaiConnectorId: mcp.openai_connector_id
|
|
48001
48332
|
}),
|
|
48002
|
-
oauth: mcp.oauth
|
|
48333
|
+
oauth: mcp.use_proxy_secret != null ? void 0 : mcp.oauth
|
|
48003
48334
|
}));
|
|
48004
48335
|
}
|
|
48005
48336
|
}
|
|
@@ -48181,7 +48512,7 @@ ${newlined}
|
|
|
48181
48512
|
__exportStar(require_schema3(), exports);
|
|
48182
48513
|
__exportStar(require_storage_client(), exports);
|
|
48183
48514
|
__exportStar(require_services_client(), exports);
|
|
48184
|
-
__exportStar(
|
|
48515
|
+
__exportStar(require_sqlite_client(), exports);
|
|
48185
48516
|
__exportStar(require_stream_controller(), exports);
|
|
48186
48517
|
__exportStar(require_sync_client(), exports);
|
|
48187
48518
|
__exportStar(require_api_keys(), exports);
|