@hsuite/smart-engines-sdk 3.10.0 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +91 -47
- package/dist/index.js +190 -94
- package/dist/index.js.map +1 -1
- package/dist/nestjs/index.d.ts +90 -46
- package/dist/nestjs/index.js +190 -94
- package/dist/nestjs/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6609,7 +6609,7 @@ var SdkHttpError = class extends Error {
|
|
|
6609
6609
|
};
|
|
6610
6610
|
function createHttpClient(config) {
|
|
6611
6611
|
const timeout = config.timeout ?? 3e4;
|
|
6612
|
-
function getHeaders(contentType) {
|
|
6612
|
+
function getHeaders(contentType, opts) {
|
|
6613
6613
|
const headers = {};
|
|
6614
6614
|
if (contentType) {
|
|
6615
6615
|
headers["Content-Type"] = contentType;
|
|
@@ -6620,6 +6620,12 @@ function createHttpClient(config) {
|
|
|
6620
6620
|
if (config.apiKey) {
|
|
6621
6621
|
headers["X-API-Key"] = config.apiKey;
|
|
6622
6622
|
}
|
|
6623
|
+
if (opts?.customerToken) {
|
|
6624
|
+
headers["X-Customer-Session-Token"] = opts.customerToken;
|
|
6625
|
+
}
|
|
6626
|
+
if (opts?.headers) {
|
|
6627
|
+
Object.assign(headers, opts.headers);
|
|
6628
|
+
}
|
|
6623
6629
|
return headers;
|
|
6624
6630
|
}
|
|
6625
6631
|
function setAuthToken(token) {
|
|
@@ -6628,14 +6634,14 @@ function createHttpClient(config) {
|
|
|
6628
6634
|
function getAuthToken() {
|
|
6629
6635
|
return config.authToken;
|
|
6630
6636
|
}
|
|
6631
|
-
async function request(method, path, body) {
|
|
6637
|
+
async function request(method, path, body, opts) {
|
|
6632
6638
|
const url = `${config.baseUrl}${path}`;
|
|
6633
6639
|
const controller = new AbortController();
|
|
6634
6640
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
6635
6641
|
try {
|
|
6636
6642
|
const init = {
|
|
6637
6643
|
method,
|
|
6638
|
-
headers: getHeaders("application/json"),
|
|
6644
|
+
headers: getHeaders("application/json", opts),
|
|
6639
6645
|
signal: controller.signal
|
|
6640
6646
|
};
|
|
6641
6647
|
if (body !== void 0) {
|
|
@@ -6664,14 +6670,14 @@ function createHttpClient(config) {
|
|
|
6664
6670
|
throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
|
|
6665
6671
|
}
|
|
6666
6672
|
}
|
|
6667
|
-
async function getText(path) {
|
|
6673
|
+
async function getText(path, opts) {
|
|
6668
6674
|
const url = `${config.baseUrl}${path}`;
|
|
6669
6675
|
const controller = new AbortController();
|
|
6670
6676
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
6671
6677
|
try {
|
|
6672
6678
|
const response = await fetch(url, {
|
|
6673
6679
|
method: "GET",
|
|
6674
|
-
headers: getHeaders(),
|
|
6680
|
+
headers: getHeaders(void 0, opts),
|
|
6675
6681
|
signal: controller.signal
|
|
6676
6682
|
});
|
|
6677
6683
|
clearTimeout(timeoutId);
|
|
@@ -6694,7 +6700,37 @@ function createHttpClient(config) {
|
|
|
6694
6700
|
throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
|
|
6695
6701
|
}
|
|
6696
6702
|
}
|
|
6697
|
-
async function
|
|
6703
|
+
async function getBinary(path, opts) {
|
|
6704
|
+
const url = `${config.baseUrl}${path}`;
|
|
6705
|
+
const controller = new AbortController();
|
|
6706
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
6707
|
+
try {
|
|
6708
|
+
const response = await fetch(url, {
|
|
6709
|
+
method: "GET",
|
|
6710
|
+
headers: getHeaders(void 0, opts),
|
|
6711
|
+
signal: controller.signal
|
|
6712
|
+
});
|
|
6713
|
+
clearTimeout(timeoutId);
|
|
6714
|
+
if (!response.ok) {
|
|
6715
|
+
const errBody = await response.json().catch(() => ({}));
|
|
6716
|
+
throw new SdkHttpError(
|
|
6717
|
+
errBody.message || `API error: ${response.status} ${response.statusText}`,
|
|
6718
|
+
response.status,
|
|
6719
|
+
errBody
|
|
6720
|
+
);
|
|
6721
|
+
}
|
|
6722
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
6723
|
+
} catch (error) {
|
|
6724
|
+
clearTimeout(timeoutId);
|
|
6725
|
+
if (error instanceof SdkHttpError) throw error;
|
|
6726
|
+
const err = error;
|
|
6727
|
+
if (err.name === "AbortError") {
|
|
6728
|
+
throw new SdkHttpError("Request timeout", 408);
|
|
6729
|
+
}
|
|
6730
|
+
throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
|
|
6731
|
+
}
|
|
6732
|
+
}
|
|
6733
|
+
async function upload(path, file, filename, metadata, fieldName = "file", opts) {
|
|
6698
6734
|
const url = `${config.baseUrl}${path}`;
|
|
6699
6735
|
const controller = new AbortController();
|
|
6700
6736
|
const timeoutId = setTimeout(() => controller.abort(), timeout * 2);
|
|
@@ -6714,6 +6750,12 @@ function createHttpClient(config) {
|
|
|
6714
6750
|
if (config.apiKey) {
|
|
6715
6751
|
headers["X-API-Key"] = config.apiKey;
|
|
6716
6752
|
}
|
|
6753
|
+
if (opts?.customerToken) {
|
|
6754
|
+
headers["X-Customer-Session-Token"] = opts.customerToken;
|
|
6755
|
+
}
|
|
6756
|
+
if (opts?.headers) {
|
|
6757
|
+
Object.assign(headers, opts.headers);
|
|
6758
|
+
}
|
|
6717
6759
|
const response = await fetch(url, {
|
|
6718
6760
|
method: "POST",
|
|
6719
6761
|
headers,
|
|
@@ -6761,13 +6803,14 @@ function createHttpClient(config) {
|
|
|
6761
6803
|
}
|
|
6762
6804
|
}
|
|
6763
6805
|
const client = {
|
|
6764
|
-
post: (path, body) => withAuthRetry(path, () => request("POST", path, body)),
|
|
6765
|
-
get: (path) => withAuthRetry(path, () => request("GET", path)),
|
|
6766
|
-
put: (path, body) => withAuthRetry(path, () => request("PUT", path, body)),
|
|
6767
|
-
patch: (path, body) => withAuthRetry(path, () => request("PATCH", path, body)),
|
|
6768
|
-
delete: (path) => withAuthRetry(path, () => request("DELETE", path)),
|
|
6769
|
-
getText: (path) => withAuthRetry(path, () => getText(path)),
|
|
6770
|
-
|
|
6806
|
+
post: (path, body, opts) => withAuthRetry(path, () => request("POST", path, body, opts)),
|
|
6807
|
+
get: (path, opts) => withAuthRetry(path, () => request("GET", path, void 0, opts)),
|
|
6808
|
+
put: (path, body, opts) => withAuthRetry(path, () => request("PUT", path, body, opts)),
|
|
6809
|
+
patch: (path, body, opts) => withAuthRetry(path, () => request("PATCH", path, body, opts)),
|
|
6810
|
+
delete: (path, opts) => withAuthRetry(path, () => request("DELETE", path, void 0, opts)),
|
|
6811
|
+
getText: (path, opts) => withAuthRetry(path, () => getText(path, opts)),
|
|
6812
|
+
getBinary: (path, opts) => withAuthRetry(path, () => getBinary(path, opts)),
|
|
6813
|
+
upload: ((path, file, filename, metadata, fieldName, opts) => withAuthRetry(path, () => upload(path, file, filename, metadata, fieldName, opts))),
|
|
6771
6814
|
setAuthToken,
|
|
6772
6815
|
getAuthToken
|
|
6773
6816
|
};
|
|
@@ -8530,50 +8573,58 @@ var AgentsClient = class {
|
|
|
8530
8573
|
}
|
|
8531
8574
|
http;
|
|
8532
8575
|
/** Register a new agent */
|
|
8533
|
-
async register(request) {
|
|
8534
|
-
return this.http.post("/api/v3/baas/agents/register", request);
|
|
8576
|
+
async register(request, opts) {
|
|
8577
|
+
return this.http.post("/api/v3/baas/agents/register", request, opts);
|
|
8535
8578
|
}
|
|
8536
8579
|
/** Get agent details */
|
|
8537
|
-
async get(agentId) {
|
|
8538
|
-
return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}
|
|
8580
|
+
async get(agentId, opts) {
|
|
8581
|
+
return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}`, opts);
|
|
8539
8582
|
}
|
|
8540
8583
|
/** List all agents */
|
|
8541
|
-
async list() {
|
|
8542
|
-
return this.http.get("/api/v3/baas/agents");
|
|
8584
|
+
async list(opts) {
|
|
8585
|
+
return this.http.get("/api/v3/baas/agents", opts);
|
|
8543
8586
|
}
|
|
8544
8587
|
/**
|
|
8545
8588
|
* Fund agent treasury (owner-only). Returns a
|
|
8546
8589
|
* `PreparedTransactionResponse` wrapped in a `success: true` envelope —
|
|
8547
8590
|
* the caller is expected to sign and submit the prepared bytes.
|
|
8548
8591
|
*/
|
|
8549
|
-
async fund(agentId, request) {
|
|
8550
|
-
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/fund`, request);
|
|
8592
|
+
async fund(agentId, request, opts) {
|
|
8593
|
+
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/fund`, request, opts);
|
|
8551
8594
|
}
|
|
8552
8595
|
/**
|
|
8553
8596
|
* Execute a trade (agent-wallet OR owner). Returns a
|
|
8554
8597
|
* `PreparedTransactionResponse` wrapped in a `success: true` envelope.
|
|
8555
8598
|
*/
|
|
8556
|
-
async trade(agentId, request) {
|
|
8557
|
-
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/trade`, request);
|
|
8599
|
+
async trade(agentId, request, opts) {
|
|
8600
|
+
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/trade`, request, opts);
|
|
8558
8601
|
}
|
|
8559
8602
|
/**
|
|
8560
8603
|
* Withdraw from agent treasury (owner-only). Returns a
|
|
8561
8604
|
* `PreparedTransactionResponse` wrapped in a `success: true` envelope.
|
|
8562
8605
|
*/
|
|
8563
|
-
async withdraw(agentId, request) {
|
|
8564
|
-
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/withdraw`, request);
|
|
8606
|
+
async withdraw(agentId, request, opts) {
|
|
8607
|
+
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/withdraw`, request, opts);
|
|
8608
|
+
}
|
|
8609
|
+
/**
|
|
8610
|
+
* Execute a generic, declared capability (agent-wallet OR owner). The
|
|
8611
|
+
* chain-agnostic general form of an agent action: the capability may settle
|
|
8612
|
+
* on-chain, act off-chain, or both. Returns the ordered step results.
|
|
8613
|
+
*/
|
|
8614
|
+
async execute(agentId, request, opts) {
|
|
8615
|
+
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/execute`, request, opts);
|
|
8565
8616
|
}
|
|
8566
8617
|
/** Pause an agent */
|
|
8567
|
-
async pause(agentId) {
|
|
8568
|
-
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/pause`, {});
|
|
8618
|
+
async pause(agentId, opts) {
|
|
8619
|
+
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/pause`, {}, opts);
|
|
8569
8620
|
}
|
|
8570
8621
|
/** Resume a paused agent */
|
|
8571
|
-
async resume(agentId) {
|
|
8572
|
-
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/resume`, {});
|
|
8622
|
+
async resume(agentId, opts) {
|
|
8623
|
+
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/resume`, {}, opts);
|
|
8573
8624
|
}
|
|
8574
8625
|
/** Revoke an agent (permanent) */
|
|
8575
|
-
async revoke(agentId) {
|
|
8576
|
-
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/revoke`, {});
|
|
8626
|
+
async revoke(agentId, opts) {
|
|
8627
|
+
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/revoke`, {}, opts);
|
|
8577
8628
|
}
|
|
8578
8629
|
/**
|
|
8579
8630
|
* Update agent rules.
|
|
@@ -8583,24 +8634,24 @@ var AgentsClient = class {
|
|
|
8583
8634
|
* Nest matched the dynamic `:agentId` GET/POST handlers and rejected
|
|
8584
8635
|
* the verb mismatch.
|
|
8585
8636
|
*/
|
|
8586
|
-
async updateRules(agentId, rules) {
|
|
8587
|
-
return this.http.patch(`/api/v3/baas/agents/${encodePathParam(agentId)}/rules`, rules);
|
|
8637
|
+
async updateRules(agentId, rules, opts) {
|
|
8638
|
+
return this.http.patch(`/api/v3/baas/agents/${encodePathParam(agentId)}/rules`, rules, opts);
|
|
8588
8639
|
}
|
|
8589
8640
|
/** Get agent events */
|
|
8590
|
-
async getEvents(agentId) {
|
|
8591
|
-
return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/events
|
|
8641
|
+
async getEvents(agentId, opts) {
|
|
8642
|
+
return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/events`, opts);
|
|
8592
8643
|
}
|
|
8593
8644
|
/** Get agent balances across chains */
|
|
8594
|
-
async getBalances(agentId) {
|
|
8595
|
-
return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/balances
|
|
8645
|
+
async getBalances(agentId, opts) {
|
|
8646
|
+
return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/balances`, opts);
|
|
8596
8647
|
}
|
|
8597
8648
|
/** Approve a pending agent operation */
|
|
8598
|
-
async approve(agentId, operationId) {
|
|
8599
|
-
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/approve/${encodePathParam(operationId)}`, {});
|
|
8649
|
+
async approve(agentId, operationId, opts) {
|
|
8650
|
+
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/approve/${encodePathParam(operationId)}`, {}, opts);
|
|
8600
8651
|
}
|
|
8601
8652
|
/** Reject a pending agent operation */
|
|
8602
|
-
async reject(agentId, operationId) {
|
|
8603
|
-
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/reject/${encodePathParam(operationId)}`, {});
|
|
8653
|
+
async reject(agentId, operationId, opts) {
|
|
8654
|
+
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/reject/${encodePathParam(operationId)}`, {}, opts);
|
|
8604
8655
|
}
|
|
8605
8656
|
};
|
|
8606
8657
|
|
|
@@ -10478,30 +10529,31 @@ var StorageClient = class {
|
|
|
10478
10529
|
/**
|
|
10479
10530
|
* Upload a file to storage
|
|
10480
10531
|
*/
|
|
10481
|
-
async upload(file, filename, metadata) {
|
|
10532
|
+
async upload(file, filename, metadata, opts) {
|
|
10482
10533
|
const appId = this.getAppId();
|
|
10483
|
-
return this.http.upload(`/api/v3/baas/storage/${encodePathParam(appId)}/upload`, file, filename, metadata);
|
|
10534
|
+
return this.http.upload(`/api/v3/baas/storage/${encodePathParam(appId)}/upload`, file, filename, metadata, void 0, opts);
|
|
10484
10535
|
}
|
|
10485
10536
|
/**
|
|
10486
|
-
* Download a file by CID
|
|
10537
|
+
* Download a file by CID. Returns the raw file bytes as a `Uint8Array`
|
|
10538
|
+
* (binary-safe — never JSON-parsed or text-decoded).
|
|
10487
10539
|
*/
|
|
10488
|
-
async download(cid) {
|
|
10540
|
+
async download(cid, opts) {
|
|
10489
10541
|
const appId = this.getAppId();
|
|
10490
|
-
return this.http.
|
|
10542
|
+
return this.http.getBinary(`/api/v3/baas/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`, opts);
|
|
10491
10543
|
}
|
|
10492
10544
|
/**
|
|
10493
10545
|
* Get file metadata
|
|
10494
10546
|
*/
|
|
10495
|
-
async getMetadata(cid) {
|
|
10547
|
+
async getMetadata(cid, opts) {
|
|
10496
10548
|
const appId = this.getAppId();
|
|
10497
|
-
return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}
|
|
10549
|
+
return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/metadata/${encodePathParam(cid)}`, opts);
|
|
10498
10550
|
}
|
|
10499
10551
|
/**
|
|
10500
10552
|
* Delete a file
|
|
10501
10553
|
*/
|
|
10502
|
-
async delete(cid) {
|
|
10554
|
+
async delete(cid, opts) {
|
|
10503
10555
|
const appId = this.getAppId();
|
|
10504
|
-
return this.http.delete(`/api/v3/baas/storage/${encodePathParam(appId)}/${encodePathParam(cid)}
|
|
10556
|
+
return this.http.delete(`/api/v3/baas/storage/${encodePathParam(appId)}/${encodePathParam(cid)}`, opts);
|
|
10505
10557
|
}
|
|
10506
10558
|
/**
|
|
10507
10559
|
* List all files for the app.
|
|
@@ -10510,27 +10562,27 @@ var StorageClient = class {
|
|
|
10510
10562
|
* `offset` for pagination).
|
|
10511
10563
|
* @returns The file list and total count.
|
|
10512
10564
|
*/
|
|
10513
|
-
async listFiles(pagination) {
|
|
10565
|
+
async listFiles(pagination, opts) {
|
|
10514
10566
|
const appId = this.getAppId();
|
|
10515
10567
|
const params = new URLSearchParams();
|
|
10516
10568
|
if (pagination?.limit !== void 0) params.set("limit", String(pagination.limit));
|
|
10517
10569
|
if (pagination?.offset !== void 0) params.set("offset", String(pagination.offset));
|
|
10518
10570
|
const qs = params.toString();
|
|
10519
|
-
return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}
|
|
10571
|
+
return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/files${qs ? `?${qs}` : ""}`, opts);
|
|
10520
10572
|
}
|
|
10521
10573
|
/**
|
|
10522
10574
|
* Get storage usage for the current app
|
|
10523
10575
|
*/
|
|
10524
|
-
async getUsage() {
|
|
10576
|
+
async getUsage(opts) {
|
|
10525
10577
|
const appId = this.getAppId();
|
|
10526
|
-
return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/usage
|
|
10578
|
+
return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/usage`, opts);
|
|
10527
10579
|
}
|
|
10528
10580
|
/**
|
|
10529
10581
|
* Check if a file exists
|
|
10530
10582
|
*/
|
|
10531
|
-
async exists(cid) {
|
|
10583
|
+
async exists(cid, opts) {
|
|
10532
10584
|
const appId = this.getAppId();
|
|
10533
|
-
return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}
|
|
10585
|
+
return this.http.get(`/api/v3/baas/storage/${encodePathParam(appId)}/exists/${encodePathParam(cid)}`, opts);
|
|
10534
10586
|
}
|
|
10535
10587
|
};
|
|
10536
10588
|
|
|
@@ -10543,61 +10595,99 @@ var FunctionsClient = class {
|
|
|
10543
10595
|
http;
|
|
10544
10596
|
getAppId;
|
|
10545
10597
|
/**
|
|
10546
|
-
*
|
|
10547
|
-
|
|
10548
|
-
|
|
10598
|
+
* Build the Ed25519 signed-code envelope the host mandates for every deploy
|
|
10599
|
+
* and eval. A fresh ephemeral keypair is generated per call, so no long-lived
|
|
10600
|
+
* signing key is held anywhere — each artifact carries its own signature.
|
|
10601
|
+
*
|
|
10602
|
+
* Scheme (must match the host verifier): `hash = sha256(code)` (hex),
|
|
10603
|
+
* `message = "<hash>:<timestamp>"`, signed Ed25519; `publicKey` is SPKI-DER
|
|
10604
|
+
* (base64). `crypto` is imported lazily so this never pulls Node built-ins
|
|
10605
|
+
* into a browser bundle that doesn't sign code.
|
|
10606
|
+
*/
|
|
10607
|
+
async signCode(code) {
|
|
10608
|
+
const { generateKeyPairSync, createHash, sign: sign2 } = await import('crypto');
|
|
10609
|
+
const { publicKey, privateKey } = generateKeyPairSync("ed25519");
|
|
10610
|
+
const hash = createHash("sha256").update(code, "utf8").digest("hex");
|
|
10611
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
10612
|
+
const signature = sign2(null, Buffer.from(`${hash}:${timestamp}`, "utf8"), privateKey).toString("base64");
|
|
10613
|
+
const publicKeyDer = publicKey.export({ format: "der", type: "spki" }).toString("base64");
|
|
10614
|
+
return { code, hash, timestamp, signature, publicKey: publicKeyDer };
|
|
10615
|
+
}
|
|
10616
|
+
/**
|
|
10617
|
+
* Deploy a new function. If `signedCode` is omitted it is auto-built from
|
|
10618
|
+
* `request.code` via {@link signCode} — the host requires it, so the default
|
|
10619
|
+
* is to sign rather than 400. Pass your own envelope to override.
|
|
10620
|
+
*/
|
|
10621
|
+
async deploy(request, opts) {
|
|
10549
10622
|
const appId = this.getAppId();
|
|
10550
|
-
|
|
10623
|
+
const signedCode = request.signedCode ?? await this.signCode(request.code);
|
|
10624
|
+
return this.http.post(`/api/v3/baas/functions/${encodePathParam(appId)}`, { ...request, signedCode }, opts);
|
|
10551
10625
|
}
|
|
10552
10626
|
/**
|
|
10553
10627
|
* Invoke a function
|
|
10554
10628
|
*/
|
|
10555
|
-
async invoke(functionId, payload) {
|
|
10629
|
+
async invoke(functionId, payload, opts) {
|
|
10556
10630
|
const appId = this.getAppId();
|
|
10557
10631
|
return this.http.post(
|
|
10558
10632
|
`/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/invoke`,
|
|
10559
|
-
payload ?? {}
|
|
10633
|
+
payload ?? {},
|
|
10634
|
+
opts
|
|
10560
10635
|
);
|
|
10561
10636
|
}
|
|
10637
|
+
/**
|
|
10638
|
+
* Evaluate signed code once (ephemeral) — no persistent deploy.
|
|
10639
|
+
*
|
|
10640
|
+
* For throwaway / AI-generated snippets. The host runs it in the same hardened
|
|
10641
|
+
* isolate and discards it; metered + quota'd like a normal invocation. As with
|
|
10642
|
+
* {@link deploy}, `signedCode` is auto-built from `request.code` when omitted.
|
|
10643
|
+
*/
|
|
10644
|
+
async eval(request, opts) {
|
|
10645
|
+
const appId = this.getAppId();
|
|
10646
|
+
const signedCode = request.signedCode ?? await this.signCode(request.code);
|
|
10647
|
+
return this.http.post(`/api/v3/baas/functions/${encodePathParam(appId)}/eval`, { ...request, signedCode }, opts);
|
|
10648
|
+
}
|
|
10562
10649
|
/**
|
|
10563
10650
|
* List all functions for the current app
|
|
10564
10651
|
*/
|
|
10565
|
-
async list() {
|
|
10652
|
+
async list(opts) {
|
|
10566
10653
|
const appId = this.getAppId();
|
|
10567
|
-
return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}
|
|
10654
|
+
return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}`, opts);
|
|
10568
10655
|
}
|
|
10569
10656
|
/**
|
|
10570
10657
|
* Get function details
|
|
10571
10658
|
*/
|
|
10572
|
-
async get(functionId) {
|
|
10659
|
+
async get(functionId, opts) {
|
|
10573
10660
|
const appId = this.getAppId();
|
|
10574
10661
|
return this.http.get(
|
|
10575
|
-
`/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}
|
|
10662
|
+
`/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
|
|
10663
|
+
opts
|
|
10576
10664
|
);
|
|
10577
10665
|
}
|
|
10578
10666
|
/**
|
|
10579
10667
|
* Update a function
|
|
10580
10668
|
*/
|
|
10581
|
-
async update(functionId, updates) {
|
|
10669
|
+
async update(functionId, updates, opts) {
|
|
10582
10670
|
const appId = this.getAppId();
|
|
10583
10671
|
return this.http.put(
|
|
10584
10672
|
`/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
|
|
10585
|
-
updates
|
|
10673
|
+
updates,
|
|
10674
|
+
opts
|
|
10586
10675
|
);
|
|
10587
10676
|
}
|
|
10588
10677
|
/**
|
|
10589
10678
|
* Delete a function
|
|
10590
10679
|
*/
|
|
10591
|
-
async delete(functionId) {
|
|
10680
|
+
async delete(functionId, opts) {
|
|
10592
10681
|
const appId = this.getAppId();
|
|
10593
10682
|
return this.http.delete(
|
|
10594
|
-
`/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}
|
|
10683
|
+
`/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}`,
|
|
10684
|
+
opts
|
|
10595
10685
|
);
|
|
10596
10686
|
}
|
|
10597
10687
|
/**
|
|
10598
10688
|
* Get function execution logs
|
|
10599
10689
|
*/
|
|
10600
|
-
async getLogs(functionId, options) {
|
|
10690
|
+
async getLogs(functionId, options, opts) {
|
|
10601
10691
|
const appId = this.getAppId();
|
|
10602
10692
|
const params = new URLSearchParams();
|
|
10603
10693
|
if (options?.limit !== void 0) params.set("limit", String(options.limit));
|
|
@@ -10605,15 +10695,16 @@ var FunctionsClient = class {
|
|
|
10605
10695
|
if (options?.level) params.set("level", options.level);
|
|
10606
10696
|
const qs = params.toString();
|
|
10607
10697
|
return this.http.get(
|
|
10608
|
-
`/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}
|
|
10698
|
+
`/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/logs${qs ? `?${qs}` : ""}`,
|
|
10699
|
+
opts
|
|
10609
10700
|
);
|
|
10610
10701
|
}
|
|
10611
10702
|
/**
|
|
10612
10703
|
* Get function statistics for an app
|
|
10613
10704
|
*/
|
|
10614
|
-
async getStats() {
|
|
10705
|
+
async getStats(opts) {
|
|
10615
10706
|
const appId = this.getAppId();
|
|
10616
|
-
return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}/stats
|
|
10707
|
+
return this.http.get(`/api/v3/baas/functions/${encodePathParam(appId)}/stats`, opts);
|
|
10617
10708
|
}
|
|
10618
10709
|
};
|
|
10619
10710
|
|
|
@@ -10628,45 +10719,46 @@ var MessagingClient = class {
|
|
|
10628
10719
|
/**
|
|
10629
10720
|
* Create a new channel
|
|
10630
10721
|
*/
|
|
10631
|
-
async createChannel(config) {
|
|
10722
|
+
async createChannel(config, opts) {
|
|
10632
10723
|
const appId = this.getAppId();
|
|
10633
|
-
return this.http.post(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, config);
|
|
10724
|
+
return this.http.post(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, config, opts);
|
|
10634
10725
|
}
|
|
10635
10726
|
/**
|
|
10636
10727
|
* Delete a channel
|
|
10637
10728
|
*/
|
|
10638
|
-
async deleteChannel(channelId) {
|
|
10729
|
+
async deleteChannel(channelId, opts) {
|
|
10639
10730
|
const appId = this.getAppId();
|
|
10640
|
-
return this.http.delete(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}
|
|
10731
|
+
return this.http.delete(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`, opts);
|
|
10641
10732
|
}
|
|
10642
10733
|
/**
|
|
10643
10734
|
* Get a channel by ID
|
|
10644
10735
|
*/
|
|
10645
|
-
async getChannel(channelId) {
|
|
10736
|
+
async getChannel(channelId, opts) {
|
|
10646
10737
|
const appId = this.getAppId();
|
|
10647
|
-
return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}
|
|
10738
|
+
return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channelId)}`, opts);
|
|
10648
10739
|
}
|
|
10649
10740
|
/**
|
|
10650
10741
|
* List all channels for the app
|
|
10651
10742
|
*/
|
|
10652
|
-
async listChannels() {
|
|
10743
|
+
async listChannels(opts) {
|
|
10653
10744
|
const appId = this.getAppId();
|
|
10654
|
-
return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels
|
|
10745
|
+
return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/channels`, opts);
|
|
10655
10746
|
}
|
|
10656
10747
|
/**
|
|
10657
10748
|
* Publish a message to a channel
|
|
10658
10749
|
*/
|
|
10659
|
-
async publish(channel, message, metadata) {
|
|
10750
|
+
async publish(channel, message, metadata, opts) {
|
|
10660
10751
|
const appId = this.getAppId();
|
|
10661
10752
|
return this.http.post(
|
|
10662
10753
|
`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/publish`,
|
|
10663
|
-
{ data: message, metadata }
|
|
10754
|
+
{ data: message, metadata },
|
|
10755
|
+
opts
|
|
10664
10756
|
);
|
|
10665
10757
|
}
|
|
10666
10758
|
/**
|
|
10667
10759
|
* Get message history for a channel
|
|
10668
10760
|
*/
|
|
10669
|
-
async getHistory(channel, options) {
|
|
10761
|
+
async getHistory(channel, options, opts) {
|
|
10670
10762
|
const appId = this.getAppId();
|
|
10671
10763
|
const params = new URLSearchParams();
|
|
10672
10764
|
if (options?.limit !== void 0) params.set("limit", String(options.limit));
|
|
@@ -10674,7 +10766,8 @@ var MessagingClient = class {
|
|
|
10674
10766
|
if (options?.after) params.set("after", options.after);
|
|
10675
10767
|
const qs = params.toString();
|
|
10676
10768
|
return this.http.get(
|
|
10677
|
-
`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}
|
|
10769
|
+
`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/history${qs ? `?${qs}` : ""}`,
|
|
10770
|
+
opts
|
|
10678
10771
|
);
|
|
10679
10772
|
}
|
|
10680
10773
|
/**
|
|
@@ -10685,11 +10778,12 @@ var MessagingClient = class {
|
|
|
10685
10778
|
* `setPresence(member)` hit a non-existent appId-scoped route and 404'd
|
|
10686
10779
|
* in production. The channel is now the first argument.
|
|
10687
10780
|
*/
|
|
10688
|
-
async setPresence(channel, member) {
|
|
10781
|
+
async setPresence(channel, member, opts) {
|
|
10689
10782
|
const appId = this.getAppId();
|
|
10690
10783
|
return this.http.post(
|
|
10691
10784
|
`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
|
|
10692
|
-
member
|
|
10785
|
+
member,
|
|
10786
|
+
opts
|
|
10693
10787
|
);
|
|
10694
10788
|
}
|
|
10695
10789
|
/**
|
|
@@ -10701,27 +10795,29 @@ var MessagingClient = class {
|
|
|
10701
10795
|
* `clientId` (not `memberId`) the second — they're the same identifier
|
|
10702
10796
|
* but renamed to match the server param.
|
|
10703
10797
|
*/
|
|
10704
|
-
async removePresence(channel, clientId) {
|
|
10798
|
+
async removePresence(channel, clientId, opts) {
|
|
10705
10799
|
const appId = this.getAppId();
|
|
10706
10800
|
return this.http.delete(
|
|
10707
|
-
`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}
|
|
10801
|
+
`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence/${encodePathParam(clientId)}`,
|
|
10802
|
+
opts
|
|
10708
10803
|
);
|
|
10709
10804
|
}
|
|
10710
10805
|
/**
|
|
10711
10806
|
* Get presence info for a channel
|
|
10712
10807
|
*/
|
|
10713
|
-
async getPresence(channel) {
|
|
10808
|
+
async getPresence(channel, opts) {
|
|
10714
10809
|
const appId = this.getAppId();
|
|
10715
10810
|
return this.http.get(
|
|
10716
|
-
`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence
|
|
10811
|
+
`/api/v3/baas/messaging/${encodePathParam(appId)}/channels/${encodePathParam(channel)}/presence`,
|
|
10812
|
+
opts
|
|
10717
10813
|
);
|
|
10718
10814
|
}
|
|
10719
10815
|
/**
|
|
10720
10816
|
* Get messaging statistics
|
|
10721
10817
|
*/
|
|
10722
|
-
async getStats() {
|
|
10818
|
+
async getStats(opts) {
|
|
10723
10819
|
const appId = this.getAppId();
|
|
10724
|
-
return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/stats
|
|
10820
|
+
return this.http.get(`/api/v3/baas/messaging/${encodePathParam(appId)}/stats`, opts);
|
|
10725
10821
|
}
|
|
10726
10822
|
};
|
|
10727
10823
|
|