@mitralab.io/functions-sdk 0.2.7 → 0.2.8
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 +15 -0
- package/dist/index.cjs +1 -30
- package/dist/index.js +1 -32
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.2.8
|
|
6
|
+
|
|
7
|
+
Stable release of the 0.2.8-beta.0 line, already on the `beta` tag and running in the dev Functions
|
|
8
|
+
template. No change on top of the beta.
|
|
9
|
+
|
|
10
|
+
- `init()` resolves without any network call instead of fetching the app info route, which is rate
|
|
11
|
+
limited per IP. `await client.init()`, `dataSourceId` and `MITRA_DATA_SOURCE_ID` still work.
|
|
12
|
+
|
|
13
|
+
## 0.2.8-beta.0
|
|
14
|
+
|
|
15
|
+
- `init()` resolves without any network call. It used to fetch `GET /code-studio/api/v1/apps/<id>/info`
|
|
16
|
+
only to keep a data source id that no operation reads, and that public route is rate limited per
|
|
17
|
+
IP, so Functions sharing an e2b host failed at startup with 429. `await client.init()` still works,
|
|
18
|
+
and `dataSourceId` and `MITRA_DATA_SOURCE_ID` are still accepted.
|
|
19
|
+
|
|
5
20
|
## 0.2.7
|
|
6
21
|
|
|
7
22
|
Stable release of the 0.2.7-beta.0 line, already on the `beta` tag. This release only moves the
|
package/dist/index.cjs
CHANGED
|
@@ -785,13 +785,9 @@ var DefaultMitraClient = class {
|
|
|
785
785
|
schema;
|
|
786
786
|
sql;
|
|
787
787
|
workflows;
|
|
788
|
-
#dataSourceId;
|
|
789
|
-
#initPromise;
|
|
790
788
|
#appId;
|
|
791
|
-
#codeStudioHttpClient;
|
|
792
789
|
constructor(config) {
|
|
793
790
|
this.#appId = config.appId;
|
|
794
|
-
this.#dataSourceId = config.dataSourceId;
|
|
795
791
|
const httpClient = (service) => new HttpClient({
|
|
796
792
|
baseUrl: `${config.apiUrl}/${service}`,
|
|
797
793
|
authentication: "bearer",
|
|
@@ -868,34 +864,9 @@ var DefaultMitraClient = class {
|
|
|
868
864
|
this.schema = core.schema;
|
|
869
865
|
this.sql = core.sql;
|
|
870
866
|
this.workflows = core.workflows;
|
|
871
|
-
this.#codeStudioHttpClient = httpClient("code-studio");
|
|
872
867
|
}
|
|
873
868
|
init() {
|
|
874
|
-
|
|
875
|
-
if (!this.#initPromise) {
|
|
876
|
-
this.#initPromise = this.resolveDataSourceId().catch((error) => {
|
|
877
|
-
this.#initPromise = void 0;
|
|
878
|
-
throw error;
|
|
879
|
-
});
|
|
880
|
-
}
|
|
881
|
-
return this.#initPromise;
|
|
882
|
-
}
|
|
883
|
-
async resolveDataSourceId() {
|
|
884
|
-
const appInfo = (0, import_sdk_core3.expectObject)(
|
|
885
|
-
await this.#codeStudioHttpClient.get(
|
|
886
|
-
`/api/v1/apps/${(0, import_sdk_core3.encodePathSegment)(this.#appId, "appId", coreErrors)}/info`
|
|
887
|
-
),
|
|
888
|
-
"App info response",
|
|
889
|
-
coreErrors
|
|
890
|
-
);
|
|
891
|
-
if (appInfo.dataSourceId === null) return;
|
|
892
|
-
if (typeof appInfo.dataSourceId !== "string" || !appInfo.dataSourceId.trim()) {
|
|
893
|
-
throw new MitraApiError("The app info response does not include a dataSourceId", 200, {
|
|
894
|
-
code: "INVALID_RESPONSE",
|
|
895
|
-
retryable: false
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
this.#dataSourceId = appInfo.dataSourceId;
|
|
869
|
+
return Promise.resolve();
|
|
899
870
|
}
|
|
900
871
|
};
|
|
901
872
|
function createConfiguredClient(config) {
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createAgentTaskSessionManager,
|
|
4
4
|
createSdkCore,
|
|
5
|
-
encodePathSegment as encodePathSegment2,
|
|
6
|
-
expectObject,
|
|
7
5
|
withAgentTaskSessions
|
|
8
6
|
} from "@mitralab.io/sdk-core";
|
|
9
7
|
|
|
@@ -691,13 +689,9 @@ var DefaultMitraClient = class {
|
|
|
691
689
|
schema;
|
|
692
690
|
sql;
|
|
693
691
|
workflows;
|
|
694
|
-
#dataSourceId;
|
|
695
|
-
#initPromise;
|
|
696
692
|
#appId;
|
|
697
|
-
#codeStudioHttpClient;
|
|
698
693
|
constructor(config) {
|
|
699
694
|
this.#appId = config.appId;
|
|
700
|
-
this.#dataSourceId = config.dataSourceId;
|
|
701
695
|
const httpClient = (service) => new HttpClient({
|
|
702
696
|
baseUrl: `${config.apiUrl}/${service}`,
|
|
703
697
|
authentication: "bearer",
|
|
@@ -774,34 +768,9 @@ var DefaultMitraClient = class {
|
|
|
774
768
|
this.schema = core.schema;
|
|
775
769
|
this.sql = core.sql;
|
|
776
770
|
this.workflows = core.workflows;
|
|
777
|
-
this.#codeStudioHttpClient = httpClient("code-studio");
|
|
778
771
|
}
|
|
779
772
|
init() {
|
|
780
|
-
|
|
781
|
-
if (!this.#initPromise) {
|
|
782
|
-
this.#initPromise = this.resolveDataSourceId().catch((error) => {
|
|
783
|
-
this.#initPromise = void 0;
|
|
784
|
-
throw error;
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
return this.#initPromise;
|
|
788
|
-
}
|
|
789
|
-
async resolveDataSourceId() {
|
|
790
|
-
const appInfo = expectObject(
|
|
791
|
-
await this.#codeStudioHttpClient.get(
|
|
792
|
-
`/api/v1/apps/${encodePathSegment2(this.#appId, "appId", coreErrors)}/info`
|
|
793
|
-
),
|
|
794
|
-
"App info response",
|
|
795
|
-
coreErrors
|
|
796
|
-
);
|
|
797
|
-
if (appInfo.dataSourceId === null) return;
|
|
798
|
-
if (typeof appInfo.dataSourceId !== "string" || !appInfo.dataSourceId.trim()) {
|
|
799
|
-
throw new MitraApiError("The app info response does not include a dataSourceId", 200, {
|
|
800
|
-
code: "INVALID_RESPONSE",
|
|
801
|
-
retryable: false
|
|
802
|
-
});
|
|
803
|
-
}
|
|
804
|
-
this.#dataSourceId = appInfo.dataSourceId;
|
|
773
|
+
return Promise.resolve();
|
|
805
774
|
}
|
|
806
775
|
};
|
|
807
776
|
function createConfiguredClient(config) {
|