tensorlake 0.5.89 → 0.5.92
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.cjs +124 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +124 -29
- package/dist/index.js.map +1 -1
- package/dist/native/darwin-arm64/tensorlake-node.node +0 -0
- package/dist/native/linux-arm64/tensorlake-node.node +0 -0
- package/dist/native/linux-arm64-musl/tensorlake-node.node +0 -0
- package/dist/native/linux-x64/tensorlake-node.node +0 -0
- package/dist/native/linux-x64-musl/tensorlake-node.node +0 -0
- package/dist/native/win32-x64/tensorlake-node.node +0 -0
- package/dist/sandbox-image.cjs +47 -4
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.js +47 -4
- package/dist/sandbox-image.js.map +1 -1
- package/package.json +2 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/sandbox-image.cjs
CHANGED
|
@@ -35,7 +35,7 @@ var SDK_VERSION, API_URL, API_KEY, NAMESPACE, SANDBOX_PROXY_URL, DEFAULT_HTTP_TI
|
|
|
35
35
|
var init_defaults = __esm({
|
|
36
36
|
"src/defaults.ts"() {
|
|
37
37
|
"use strict";
|
|
38
|
-
SDK_VERSION = "0.5.
|
|
38
|
+
SDK_VERSION = "0.5.92";
|
|
39
39
|
API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
40
40
|
API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
41
41
|
NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -506,7 +506,8 @@ function parseTimestamp(v) {
|
|
|
506
506
|
return new Date(ts * 1e3);
|
|
507
507
|
}
|
|
508
508
|
function fromSnakeKeys(obj, idField) {
|
|
509
|
-
if (Array.isArray(obj))
|
|
509
|
+
if (Array.isArray(obj))
|
|
510
|
+
return obj.map((item) => fromSnakeKeys(item, idField));
|
|
510
511
|
if (obj !== null && typeof obj === "object" && !(obj instanceof Date)) {
|
|
511
512
|
const result = {};
|
|
512
513
|
for (const [k, v] of Object.entries(obj)) {
|
|
@@ -595,6 +596,21 @@ var init_sse = __esm({
|
|
|
595
596
|
});
|
|
596
597
|
|
|
597
598
|
// src/cloud-client.ts
|
|
599
|
+
function applicationAllowsUnauthenticatedRequests(manifest) {
|
|
600
|
+
return Array.isArray(manifest.allow) && manifest.allow.includes(UNAUTHENTICATED_REQUESTS);
|
|
601
|
+
}
|
|
602
|
+
function publicEndpointIdFromManifest(manifest) {
|
|
603
|
+
for (const key of ["public_endpoint_id", "publicEndpointId"]) {
|
|
604
|
+
const value = manifest[key];
|
|
605
|
+
if (typeof value === "string" && value.length > 0) {
|
|
606
|
+
return value;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
return void 0;
|
|
610
|
+
}
|
|
611
|
+
function generatePublicEndpointId() {
|
|
612
|
+
return `endpoint_${(0, import_nanoid.nanoid)()}`;
|
|
613
|
+
}
|
|
598
614
|
function createApplicationBuildForm(request, imageContexts) {
|
|
599
615
|
const contextsByPartName = /* @__PURE__ */ new Map();
|
|
600
616
|
for (const context of imageContexts) {
|
|
@@ -664,10 +680,11 @@ async function parseJsonResponse(response) {
|
|
|
664
680
|
}
|
|
665
681
|
return JSON.parse(text);
|
|
666
682
|
}
|
|
667
|
-
var CloudClient;
|
|
683
|
+
var import_nanoid, CloudClient, UNAUTHENTICATED_REQUESTS;
|
|
668
684
|
var init_cloud_client = __esm({
|
|
669
685
|
"src/cloud-client.ts"() {
|
|
670
686
|
"use strict";
|
|
687
|
+
import_nanoid = require("nanoid");
|
|
671
688
|
init_defaults();
|
|
672
689
|
init_http();
|
|
673
690
|
init_models();
|
|
@@ -697,6 +714,19 @@ var init_cloud_client = __esm({
|
|
|
697
714
|
this.http.close();
|
|
698
715
|
}
|
|
699
716
|
async upsertApplication(manifest, codeZip, upgradeRunningRequests = false) {
|
|
717
|
+
const applicationManifest = { ...manifest };
|
|
718
|
+
let publicEndpointId = publicEndpointIdFromManifest(applicationManifest);
|
|
719
|
+
if (applicationAllowsUnauthenticatedRequests(applicationManifest) && publicEndpointId === void 0) {
|
|
720
|
+
const applicationName = applicationManifest.name;
|
|
721
|
+
if (typeof applicationName === "string" && applicationName.length > 0) {
|
|
722
|
+
publicEndpointId = await this.existingApplicationPublicEndpointId(applicationName);
|
|
723
|
+
}
|
|
724
|
+
publicEndpointId ??= generatePublicEndpointId();
|
|
725
|
+
}
|
|
726
|
+
if (publicEndpointId !== void 0) {
|
|
727
|
+
applicationManifest.public_endpoint_id = publicEndpointId;
|
|
728
|
+
delete applicationManifest.publicEndpointId;
|
|
729
|
+
}
|
|
700
730
|
const form = new FormData();
|
|
701
731
|
form.append(
|
|
702
732
|
"code",
|
|
@@ -704,7 +734,7 @@ var init_cloud_client = __esm({
|
|
|
704
734
|
"code.zip"
|
|
705
735
|
);
|
|
706
736
|
form.append("code_content_type", "application/zip");
|
|
707
|
-
form.append("application", JSON.stringify(
|
|
737
|
+
form.append("application", JSON.stringify(applicationManifest));
|
|
708
738
|
form.append(
|
|
709
739
|
"upgrade_requests_to_latest_code",
|
|
710
740
|
String(upgradeRunningRequests)
|
|
@@ -1017,6 +1047,18 @@ var init_cloud_client = __esm({
|
|
|
1017
1047
|
namespacePath(subpath) {
|
|
1018
1048
|
return `/v1/namespaces/${encodeURIComponent(this.namespace)}/${subpath.replace(/^\/+/, "")}`;
|
|
1019
1049
|
}
|
|
1050
|
+
async existingApplicationPublicEndpointId(applicationName) {
|
|
1051
|
+
const response = await this.http.requestResponse(
|
|
1052
|
+
"GET",
|
|
1053
|
+
this.namespacePath(`applications/${encodeURIComponent(applicationName)}`),
|
|
1054
|
+
{ allowedErrorStatusCodes: /* @__PURE__ */ new Set([404]) }
|
|
1055
|
+
);
|
|
1056
|
+
if (response.status === 404) {
|
|
1057
|
+
return void 0;
|
|
1058
|
+
}
|
|
1059
|
+
const application = await parseJsonResponse(response);
|
|
1060
|
+
return publicEndpointIdFromManifest(application);
|
|
1061
|
+
}
|
|
1020
1062
|
resolveScope(organizationId, projectId) {
|
|
1021
1063
|
const resolvedOrganizationId = organizationId ?? this.organizationId;
|
|
1022
1064
|
const resolvedProjectId = projectId ?? this.projectId;
|
|
@@ -1031,6 +1073,7 @@ var init_cloud_client = __esm({
|
|
|
1031
1073
|
};
|
|
1032
1074
|
}
|
|
1033
1075
|
};
|
|
1076
|
+
UNAUTHENTICATED_REQUESTS = "unauthenticated_requests";
|
|
1034
1077
|
}
|
|
1035
1078
|
});
|
|
1036
1079
|
|