@sylphx/sdk 0.26.0 → 0.27.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/README.md +10 -6
- package/dist/index.d.ts +372 -99
- package/dist/index.mjs +609 -162
- package/dist/index.mjs.map +1 -1
- package/package.json +126 -126
package/dist/index.mjs
CHANGED
|
@@ -511,6 +511,109 @@ var init_errors = __esm({
|
|
|
511
511
|
}
|
|
512
512
|
});
|
|
513
513
|
|
|
514
|
+
// src/compute.ts
|
|
515
|
+
import {
|
|
516
|
+
DEFAULT_MACHINE_SIZE,
|
|
517
|
+
isMachineSize,
|
|
518
|
+
MACHINE_CONFIGS,
|
|
519
|
+
MACHINE_MAX_INSTANCES,
|
|
520
|
+
MACHINE_RESOURCE_REQUIREMENTS,
|
|
521
|
+
MACHINE_SIZES,
|
|
522
|
+
parseMachineSize,
|
|
523
|
+
resolveMachineConfig,
|
|
524
|
+
resolveMachineMaxInstances,
|
|
525
|
+
resolveMachineResources,
|
|
526
|
+
resolveMachineTierResources,
|
|
527
|
+
toPublicMachineSize
|
|
528
|
+
} from "@sylphx/contract/compute";
|
|
529
|
+
|
|
530
|
+
// src/config/database-pricing.ts
|
|
531
|
+
var COMPUTE_PRICE_PER_HOUR_MICRODOLLARS = 8e4;
|
|
532
|
+
var FREE_COMPUTE_HOURS = 3;
|
|
533
|
+
var STORAGE_PRICE_PER_GB_MONTH_MICRODOLLARS = 25e4;
|
|
534
|
+
var FREE_STORAGE_GB = 0.25;
|
|
535
|
+
var TRANSFER_PRICE_PER_GB_MICRODOLLARS = 9e4;
|
|
536
|
+
var KV_FREE_STORAGE_GB = 0.25;
|
|
537
|
+
var HOURS_PER_MONTH = 730;
|
|
538
|
+
|
|
539
|
+
// src/config/referrals.ts
|
|
540
|
+
var DEFAULT_POINTS_REWARD = 100;
|
|
541
|
+
var DISCOUNT_DURATION_MONTHS = 3;
|
|
542
|
+
var DISCOUNT_PERCENT = 20;
|
|
543
|
+
var PREMIUM_TRIAL_DAYS = 7;
|
|
544
|
+
var REFERRAL_CODE_LENGTH = 8;
|
|
545
|
+
var REFERRAL_CODE_CHARS = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
546
|
+
function generateReferralCode() {
|
|
547
|
+
const bytes = new Uint8Array(REFERRAL_CODE_LENGTH);
|
|
548
|
+
crypto.getRandomValues(bytes);
|
|
549
|
+
let code = "";
|
|
550
|
+
for (let i = 0; i < REFERRAL_CODE_LENGTH; i++) {
|
|
551
|
+
code += REFERRAL_CODE_CHARS[bytes[i] % REFERRAL_CODE_CHARS.length];
|
|
552
|
+
}
|
|
553
|
+
return code;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// src/error-extract.ts
|
|
557
|
+
function getErrorMessage(error, fallback = "Unknown error") {
|
|
558
|
+
if (error instanceof Error) {
|
|
559
|
+
return error.message;
|
|
560
|
+
}
|
|
561
|
+
if (typeof error === "string") {
|
|
562
|
+
return error;
|
|
563
|
+
}
|
|
564
|
+
if (error && typeof error === "object" && "message" in error) {
|
|
565
|
+
const message = error.message;
|
|
566
|
+
if (typeof message === "string") {
|
|
567
|
+
return message;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
if (error && typeof error === "object" && "response" in error) {
|
|
571
|
+
const response = error.response;
|
|
572
|
+
if (response?.data?.message) return response.data.message;
|
|
573
|
+
if (response?.data?.error) return response.data.error;
|
|
574
|
+
}
|
|
575
|
+
return fallback;
|
|
576
|
+
}
|
|
577
|
+
function getErrorCode(error) {
|
|
578
|
+
if (!error || typeof error !== "object") {
|
|
579
|
+
return void 0;
|
|
580
|
+
}
|
|
581
|
+
if ("code" in error && typeof error.code === "string") {
|
|
582
|
+
return error.code;
|
|
583
|
+
}
|
|
584
|
+
if ("status" in error && typeof error.status === "number") {
|
|
585
|
+
return String(error.status);
|
|
586
|
+
}
|
|
587
|
+
if ("statusCode" in error && typeof error.statusCode === "number") {
|
|
588
|
+
return String(error.statusCode);
|
|
589
|
+
}
|
|
590
|
+
return void 0;
|
|
591
|
+
}
|
|
592
|
+
function getErrorDetails(error, fallbackMessage = "Unknown error") {
|
|
593
|
+
const details = {
|
|
594
|
+
message: getErrorMessage(error, fallbackMessage)
|
|
595
|
+
};
|
|
596
|
+
if (error instanceof Error) {
|
|
597
|
+
details.name = error.name;
|
|
598
|
+
details.stack = error.stack;
|
|
599
|
+
if (error.cause) {
|
|
600
|
+
details.cause = error.cause;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
const code = getErrorCode(error);
|
|
604
|
+
if (code) {
|
|
605
|
+
details.code = code;
|
|
606
|
+
}
|
|
607
|
+
if (error && typeof error === "object") {
|
|
608
|
+
if ("status" in error && typeof error.status === "number") {
|
|
609
|
+
details.status = error.status;
|
|
610
|
+
} else if ("statusCode" in error && typeof error.statusCode === "number") {
|
|
611
|
+
details.status = error.statusCode;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return details;
|
|
615
|
+
}
|
|
616
|
+
|
|
514
617
|
// src/product/errors.ts
|
|
515
618
|
var SdkError = class _SdkError extends Error {
|
|
516
619
|
status;
|
|
@@ -685,15 +788,9 @@ var Transport = class {
|
|
|
685
788
|
);
|
|
686
789
|
} catch (e) {
|
|
687
790
|
if (isAbortError(e) || e instanceof Error && /timed out/i.test(e.message)) {
|
|
688
|
-
throw SdkError.transport(
|
|
689
|
-
`request timed out after ${this.timeoutMs}ms`,
|
|
690
|
-
e
|
|
691
|
-
);
|
|
791
|
+
throw SdkError.transport(`request timed out after ${this.timeoutMs}ms`, e);
|
|
692
792
|
}
|
|
693
|
-
throw SdkError.transport(
|
|
694
|
-
e instanceof Error ? e.message : String(e),
|
|
695
|
-
e
|
|
696
|
-
);
|
|
793
|
+
throw SdkError.transport(e instanceof Error ? e.message : String(e), e);
|
|
697
794
|
}
|
|
698
795
|
const text = await res.text();
|
|
699
796
|
if (res.ok) {
|
|
@@ -703,10 +800,7 @@ var Transport = class {
|
|
|
703
800
|
try {
|
|
704
801
|
return JSON.parse(text);
|
|
705
802
|
} catch (e) {
|
|
706
|
-
throw SdkError.decode(
|
|
707
|
-
`invalid JSON: ${e instanceof Error ? e.message : String(e)}`,
|
|
708
|
-
text
|
|
709
|
-
);
|
|
803
|
+
throw SdkError.decode(`invalid JSON: ${e instanceof Error ? e.message : String(e)}`, text);
|
|
710
804
|
}
|
|
711
805
|
}
|
|
712
806
|
if (attempt < this.retry.maxAttempts && isRetryable(res.status)) {
|
|
@@ -739,10 +833,7 @@ var Transport = class {
|
|
|
739
833
|
);
|
|
740
834
|
} catch (e) {
|
|
741
835
|
if (isAbortError(e) || e instanceof Error && /timed out/i.test(e.message)) {
|
|
742
|
-
throw SdkError.transport(
|
|
743
|
-
`request timed out after ${this.timeoutMs}ms`,
|
|
744
|
-
e
|
|
745
|
-
);
|
|
836
|
+
throw SdkError.transport(`request timed out after ${this.timeoutMs}ms`, e);
|
|
746
837
|
}
|
|
747
838
|
throw SdkError.transport(e instanceof Error ? e.message : String(e), e);
|
|
748
839
|
}
|
|
@@ -756,10 +847,7 @@ var Transport = class {
|
|
|
756
847
|
}
|
|
757
848
|
}
|
|
758
849
|
if (!res.ok) {
|
|
759
|
-
throw SdkError.fromHttp(
|
|
760
|
-
res.status,
|
|
761
|
-
typeof parsed === "string" ? parsed : text
|
|
762
|
-
);
|
|
850
|
+
throw SdkError.fromHttp(res.status, typeof parsed === "string" ? parsed : text);
|
|
763
851
|
}
|
|
764
852
|
return { status: res.status, body: parsed };
|
|
765
853
|
}
|
|
@@ -809,10 +897,7 @@ var Client = class _Client {
|
|
|
809
897
|
/** KV get as wire response. */
|
|
810
898
|
async kvGetWire(key) {
|
|
811
899
|
const path = `/kv/${encodePathSegment(key)}`;
|
|
812
|
-
const body = await this.transport.requestJson(
|
|
813
|
-
"GET",
|
|
814
|
-
path
|
|
815
|
-
);
|
|
900
|
+
const body = await this.transport.requestJson("GET", path);
|
|
816
901
|
return kvGetFromRest(body);
|
|
817
902
|
}
|
|
818
903
|
/** KV get decoded JSON value. */
|
|
@@ -821,10 +906,7 @@ var Client = class _Client {
|
|
|
821
906
|
try {
|
|
822
907
|
return JSON.parse(wire.valueJson);
|
|
823
908
|
} catch (e) {
|
|
824
|
-
throw SdkError.decode(
|
|
825
|
-
e instanceof Error ? e.message : String(e),
|
|
826
|
-
wire.valueJson
|
|
827
|
-
);
|
|
909
|
+
throw SdkError.decode(e instanceof Error ? e.message : String(e), wire.valueJson);
|
|
828
910
|
}
|
|
829
911
|
}
|
|
830
912
|
/** KV get with TTL. */
|
|
@@ -847,11 +929,7 @@ var Client = class _Client {
|
|
|
847
929
|
async kvIncr(key, by) {
|
|
848
930
|
const amount = by === void 0 || by === 0 ? 1 : by;
|
|
849
931
|
const body = { key, by: amount };
|
|
850
|
-
const raw = await this.transport.requestJson(
|
|
851
|
-
"POST",
|
|
852
|
-
"/kv/incr",
|
|
853
|
-
body
|
|
854
|
-
);
|
|
932
|
+
const raw = await this.transport.requestJson("POST", "/kv/incr", body);
|
|
855
933
|
const value = Number(raw.value);
|
|
856
934
|
if (Number.isNaN(value)) {
|
|
857
935
|
throw SdkError.decode("KvIncrResponse.value is not a number", raw);
|
|
@@ -861,19 +939,15 @@ var Client = class _Client {
|
|
|
861
939
|
/** Existence check — wire `KvExists` via `GET /kv/{key}/exists`. */
|
|
862
940
|
async kvExists(key) {
|
|
863
941
|
const path = `/kv/${encodePathSegment(key)}/exists`;
|
|
864
|
-
const raw = await this.transport.requestJson(
|
|
865
|
-
"GET",
|
|
866
|
-
path
|
|
867
|
-
);
|
|
942
|
+
const raw = await this.transport.requestJson("GET", path);
|
|
868
943
|
return { exists: Boolean(raw.exists) };
|
|
869
944
|
}
|
|
870
945
|
/** Set TTL without rewrite — wire `KvExpire` via `POST /kv/expire`. */
|
|
871
946
|
async kvExpire(key, ex) {
|
|
872
|
-
const raw = await this.transport.requestJson(
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
);
|
|
947
|
+
const raw = await this.transport.requestJson("POST", "/kv/expire", {
|
|
948
|
+
key,
|
|
949
|
+
ex
|
|
950
|
+
});
|
|
877
951
|
return { success: Boolean(raw.success) };
|
|
878
952
|
}
|
|
879
953
|
};
|
|
@@ -944,10 +1018,7 @@ var ManagementClient = class _ManagementClient {
|
|
|
944
1018
|
return _ManagementClient.builder(token).build();
|
|
945
1019
|
}
|
|
946
1020
|
async health() {
|
|
947
|
-
const raw = await this.transport.requestJson(
|
|
948
|
-
"GET",
|
|
949
|
-
"/health"
|
|
950
|
-
);
|
|
1021
|
+
const raw = await this.transport.requestJson("GET", "/health");
|
|
951
1022
|
return {
|
|
952
1023
|
status: String(raw.status ?? ""),
|
|
953
1024
|
version: raw.version !== void 0 ? String(raw.version) : void 0,
|
|
@@ -955,10 +1026,7 @@ var ManagementClient = class _ManagementClient {
|
|
|
955
1026
|
};
|
|
956
1027
|
}
|
|
957
1028
|
async whoami() {
|
|
958
|
-
const raw = await this.transport.requestJson(
|
|
959
|
-
"GET",
|
|
960
|
-
"/whoami"
|
|
961
|
-
);
|
|
1029
|
+
const raw = await this.transport.requestJson("GET", "/whoami");
|
|
962
1030
|
return normalizeWhoAmI(raw);
|
|
963
1031
|
}
|
|
964
1032
|
async listOrgs() {
|
|
@@ -1049,6 +1117,464 @@ var ManagementClient = class _ManagementClient {
|
|
|
1049
1117
|
async listDeploymentItems(projectId, page2, orgId) {
|
|
1050
1118
|
return (await this.listDeployments(projectId, page2, orgId)).data;
|
|
1051
1119
|
}
|
|
1120
|
+
async createProject(name, opts) {
|
|
1121
|
+
const body = { name };
|
|
1122
|
+
if (opts?.slug) body.slug = opts.slug;
|
|
1123
|
+
if (opts?.description) body.description = opts.description;
|
|
1124
|
+
if (opts?.ref) body.ref = opts.ref;
|
|
1125
|
+
const raw = await this.transport.requestJson(
|
|
1126
|
+
"POST",
|
|
1127
|
+
"/projects",
|
|
1128
|
+
body,
|
|
1129
|
+
orgHeaders(opts?.orgId)
|
|
1130
|
+
);
|
|
1131
|
+
return normalizeProject(raw);
|
|
1132
|
+
}
|
|
1133
|
+
async createDeploy(projectId, opts) {
|
|
1134
|
+
const body = {};
|
|
1135
|
+
if (opts?.envType) body.envType = opts.envType;
|
|
1136
|
+
if (opts?.envId) body.envId = opts.envId;
|
|
1137
|
+
if (opts?.ref) body.ref = opts.ref;
|
|
1138
|
+
if (opts?.serviceId) body.serviceId = opts.serviceId;
|
|
1139
|
+
const path = `/projects/${encodePathSegment(projectId)}/deploy`;
|
|
1140
|
+
const raw = await this.transport.requestJson(
|
|
1141
|
+
"POST",
|
|
1142
|
+
path,
|
|
1143
|
+
body,
|
|
1144
|
+
orgHeaders(opts?.orgId)
|
|
1145
|
+
);
|
|
1146
|
+
return {
|
|
1147
|
+
id: String(raw.id ?? ""),
|
|
1148
|
+
status: String(raw.status ?? ""),
|
|
1149
|
+
projectId: raw.projectId !== void 0 ? String(raw.projectId) : void 0,
|
|
1150
|
+
environmentId: raw.environmentId !== void 0 ? String(raw.environmentId) : void 0,
|
|
1151
|
+
message: raw.message !== void 0 ? String(raw.message) : void 0
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
async rollback(projectId, opts) {
|
|
1155
|
+
const body = {};
|
|
1156
|
+
if (opts?.envId) body.envId = opts.envId;
|
|
1157
|
+
if (opts?.deploymentRecordId) body.deploymentRecordId = opts.deploymentRecordId;
|
|
1158
|
+
if (opts?.serviceId) body.serviceId = opts.serviceId;
|
|
1159
|
+
const path = `/projects/${encodePathSegment(projectId)}/rollback`;
|
|
1160
|
+
const raw = await this.transport.requestJson(
|
|
1161
|
+
"POST",
|
|
1162
|
+
path,
|
|
1163
|
+
body,
|
|
1164
|
+
orgHeaders(opts?.orgId)
|
|
1165
|
+
);
|
|
1166
|
+
return {
|
|
1167
|
+
id: String(raw.id ?? ""),
|
|
1168
|
+
status: String(raw.status ?? ""),
|
|
1169
|
+
projectId: raw.projectId !== void 0 ? String(raw.projectId) : void 0,
|
|
1170
|
+
message: raw.message !== void 0 ? String(raw.message) : void 0
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
async getProjectStatus(projectId, orgId) {
|
|
1174
|
+
const path = `/projects/${encodePathSegment(projectId)}/status`;
|
|
1175
|
+
const raw = await this.transport.requestJson(
|
|
1176
|
+
"GET",
|
|
1177
|
+
path,
|
|
1178
|
+
void 0,
|
|
1179
|
+
orgHeaders(orgId)
|
|
1180
|
+
);
|
|
1181
|
+
return {
|
|
1182
|
+
projectId: String(raw.projectId ?? projectId),
|
|
1183
|
+
status: String(raw.status ?? ""),
|
|
1184
|
+
environmentId: raw.environmentId !== void 0 ? String(raw.environmentId) : void 0,
|
|
1185
|
+
deploymentId: raw.deploymentId !== void 0 ? String(raw.deploymentId) : void 0,
|
|
1186
|
+
message: raw.message !== void 0 ? String(raw.message) : void 0
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
async listEnvVars(projectId, opts) {
|
|
1190
|
+
const q = new URLSearchParams();
|
|
1191
|
+
if (opts?.envType) q.set("envType", opts.envType);
|
|
1192
|
+
if (opts?.envId) q.set("envId", opts.envId);
|
|
1193
|
+
const base = `/projects/${encodePathSegment(projectId)}/env-vars`;
|
|
1194
|
+
const path = q.toString() ? `${base}?${q}` : base;
|
|
1195
|
+
const raw = await this.transport.requestJson(
|
|
1196
|
+
"GET",
|
|
1197
|
+
path,
|
|
1198
|
+
void 0,
|
|
1199
|
+
orgHeaders(opts?.orgId)
|
|
1200
|
+
);
|
|
1201
|
+
const dataRaw = Array.isArray(raw.data) ? raw.data : [];
|
|
1202
|
+
return {
|
|
1203
|
+
object: String(raw.object ?? "list"),
|
|
1204
|
+
data: dataRaw.map((row) => {
|
|
1205
|
+
const r = row;
|
|
1206
|
+
return {
|
|
1207
|
+
key: String(r.key ?? ""),
|
|
1208
|
+
value: r.value !== void 0 && r.value !== null ? String(r.value) : void 0,
|
|
1209
|
+
secret: Boolean(r.secret),
|
|
1210
|
+
envType: r.envType !== void 0 ? String(r.envType) : void 0,
|
|
1211
|
+
envId: r.envId !== void 0 ? String(r.envId) : void 0
|
|
1212
|
+
};
|
|
1213
|
+
})
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
async setEnvVar(projectId, key, value, opts) {
|
|
1217
|
+
const body = { key, value, secret: opts?.secret ?? false };
|
|
1218
|
+
if (opts?.envType) body.envType = opts.envType;
|
|
1219
|
+
if (opts?.envId) body.envId = opts.envId;
|
|
1220
|
+
const path = `/projects/${encodePathSegment(projectId)}/env-vars`;
|
|
1221
|
+
const raw = await this.transport.requestJson(
|
|
1222
|
+
"POST",
|
|
1223
|
+
path,
|
|
1224
|
+
body,
|
|
1225
|
+
orgHeaders(opts?.orgId)
|
|
1226
|
+
);
|
|
1227
|
+
const ev = raw.envVar ?? {};
|
|
1228
|
+
return {
|
|
1229
|
+
created: Boolean(raw.created),
|
|
1230
|
+
envVar: {
|
|
1231
|
+
key: String(ev.key ?? key),
|
|
1232
|
+
value: ev.value !== void 0 && ev.value !== null ? String(ev.value) : void 0,
|
|
1233
|
+
secret: Boolean(ev.secret)
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
async deleteEnvVar(projectId, key, opts) {
|
|
1238
|
+
const q = new URLSearchParams();
|
|
1239
|
+
if (opts?.envType) q.set("envType", opts.envType);
|
|
1240
|
+
if (opts?.envId) q.set("envId", opts.envId);
|
|
1241
|
+
const base = `/projects/${encodePathSegment(projectId)}/env-vars/${encodePathSegment(key)}`;
|
|
1242
|
+
const path = q.toString() ? `${base}?${q}` : base;
|
|
1243
|
+
const raw = await this.transport.requestJson(
|
|
1244
|
+
"DELETE",
|
|
1245
|
+
path,
|
|
1246
|
+
void 0,
|
|
1247
|
+
orgHeaders(opts?.orgId)
|
|
1248
|
+
);
|
|
1249
|
+
return { deleted: Boolean(raw.deleted), key: String(raw.key ?? key) };
|
|
1250
|
+
}
|
|
1251
|
+
async listLogs(opts) {
|
|
1252
|
+
const q = new URLSearchParams();
|
|
1253
|
+
if (opts.logType) q.set("type", opts.logType);
|
|
1254
|
+
if (opts.envType) q.set("envType", opts.envType);
|
|
1255
|
+
if (opts.limit !== void 0) q.set("limit", String(opts.limit));
|
|
1256
|
+
if (opts.level) q.set("level", opts.level);
|
|
1257
|
+
if (opts.service) q.set("service", opts.service);
|
|
1258
|
+
if (opts.grep) q.set("grep", opts.grep);
|
|
1259
|
+
let base;
|
|
1260
|
+
if (opts.environmentId) {
|
|
1261
|
+
base = `/environments/${encodePathSegment(opts.environmentId)}/logs`;
|
|
1262
|
+
} else if (opts.projectId) {
|
|
1263
|
+
base = `/projects/${encodePathSegment(opts.projectId)}/logs`;
|
|
1264
|
+
} else {
|
|
1265
|
+
throw SdkError.invalidCredential("listLogs requires projectId or environmentId");
|
|
1266
|
+
}
|
|
1267
|
+
const path = q.toString() ? `${base}?${q}` : base;
|
|
1268
|
+
const raw = await this.transport.requestJson(
|
|
1269
|
+
"GET",
|
|
1270
|
+
path,
|
|
1271
|
+
void 0,
|
|
1272
|
+
orgHeaders(opts.orgId)
|
|
1273
|
+
);
|
|
1274
|
+
const dataRaw = Array.isArray(raw.data) ? raw.data : [];
|
|
1275
|
+
return {
|
|
1276
|
+
object: String(raw.object ?? "list"),
|
|
1277
|
+
data: dataRaw.map((row) => {
|
|
1278
|
+
const r = row;
|
|
1279
|
+
return {
|
|
1280
|
+
timestamp: String(r.timestamp ?? ""),
|
|
1281
|
+
message: String(r.message ?? ""),
|
|
1282
|
+
level: r.level !== void 0 ? String(r.level) : void 0,
|
|
1283
|
+
service: r.service !== void 0 ? String(r.service) : void 0,
|
|
1284
|
+
source: r.source !== void 0 ? String(r.source) : void 0
|
|
1285
|
+
};
|
|
1286
|
+
})
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
async listResources(opts) {
|
|
1290
|
+
const q = new URLSearchParams();
|
|
1291
|
+
if (opts?.kind) q.set("kind", opts.kind);
|
|
1292
|
+
if (opts?.projectId) q.set("projectId", opts.projectId);
|
|
1293
|
+
const path = q.toString() ? `/resources?${q}` : "/resources";
|
|
1294
|
+
const raw = await this.transport.requestJson(
|
|
1295
|
+
"GET",
|
|
1296
|
+
path,
|
|
1297
|
+
void 0,
|
|
1298
|
+
orgHeaders(opts?.orgId)
|
|
1299
|
+
);
|
|
1300
|
+
const dataRaw = Array.isArray(raw.data) ? raw.data : [];
|
|
1301
|
+
return {
|
|
1302
|
+
object: String(raw.object ?? "list"),
|
|
1303
|
+
data: dataRaw.map((row) => normalizeResource(row))
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
async getResource(id, orgId) {
|
|
1307
|
+
const path = `/resources/${encodePathSegment(id)}`;
|
|
1308
|
+
const raw = await this.transport.requestJson(
|
|
1309
|
+
"GET",
|
|
1310
|
+
path,
|
|
1311
|
+
void 0,
|
|
1312
|
+
orgHeaders(orgId)
|
|
1313
|
+
);
|
|
1314
|
+
return normalizeResource(raw);
|
|
1315
|
+
}
|
|
1316
|
+
async createResource(kind, name, opts) {
|
|
1317
|
+
const body = { kind, name };
|
|
1318
|
+
if (opts?.projectId) body.projectId = opts.projectId;
|
|
1319
|
+
if (opts?.tier) body.tier = opts.tier;
|
|
1320
|
+
if (opts?.storageGb !== void 0) body.storageGb = opts.storageGb;
|
|
1321
|
+
const raw = await this.transport.requestJson(
|
|
1322
|
+
"POST",
|
|
1323
|
+
"/resources",
|
|
1324
|
+
body,
|
|
1325
|
+
orgHeaders(opts?.orgId)
|
|
1326
|
+
);
|
|
1327
|
+
const res = raw.resource;
|
|
1328
|
+
return {
|
|
1329
|
+
resource: res ? normalizeResource(res) : void 0,
|
|
1330
|
+
message: raw.message !== void 0 ? String(raw.message) : void 0
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
async deleteResource(id, orgId) {
|
|
1334
|
+
const path = `/resources/${encodePathSegment(id)}`;
|
|
1335
|
+
const raw = await this.transport.requestJson(
|
|
1336
|
+
"DELETE",
|
|
1337
|
+
path,
|
|
1338
|
+
void 0,
|
|
1339
|
+
orgHeaders(orgId)
|
|
1340
|
+
);
|
|
1341
|
+
return { deleted: Boolean(raw.deleted), id: String(raw.id ?? id) };
|
|
1342
|
+
}
|
|
1343
|
+
async bindResource(resourceId, environmentId, opts) {
|
|
1344
|
+
const body = { environmentId };
|
|
1345
|
+
if (opts?.projectId) body.projectId = opts.projectId;
|
|
1346
|
+
const path = `/resources/${encodePathSegment(resourceId)}/bindings`;
|
|
1347
|
+
const raw = await this.transport.requestJson(
|
|
1348
|
+
"POST",
|
|
1349
|
+
path,
|
|
1350
|
+
body,
|
|
1351
|
+
orgHeaders(opts?.orgId)
|
|
1352
|
+
);
|
|
1353
|
+
return {
|
|
1354
|
+
bound: Boolean(raw.bound),
|
|
1355
|
+
resourceId: String(raw.resourceId ?? resourceId),
|
|
1356
|
+
environmentId: String(raw.environmentId ?? environmentId)
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
async branchResource(resourceId, name, opts) {
|
|
1360
|
+
const body = { name };
|
|
1361
|
+
if (opts?.envId) body.envId = opts.envId;
|
|
1362
|
+
const path = `/resources/${encodePathSegment(resourceId)}/branch`;
|
|
1363
|
+
const raw = await this.transport.requestJson(
|
|
1364
|
+
"POST",
|
|
1365
|
+
path,
|
|
1366
|
+
body,
|
|
1367
|
+
orgHeaders(opts?.orgId)
|
|
1368
|
+
);
|
|
1369
|
+
const res = raw.resource;
|
|
1370
|
+
return { resource: res ? normalizeResource(res) : void 0 };
|
|
1371
|
+
}
|
|
1372
|
+
async createProjectStorage(projectId, name, opts) {
|
|
1373
|
+
const body = { name };
|
|
1374
|
+
if (opts?.envType) body.envType = opts.envType;
|
|
1375
|
+
const path = `/projects/${encodePathSegment(projectId)}/storage`;
|
|
1376
|
+
const raw = await this.transport.requestJson(
|
|
1377
|
+
"POST",
|
|
1378
|
+
path,
|
|
1379
|
+
body,
|
|
1380
|
+
orgHeaders(opts?.orgId)
|
|
1381
|
+
);
|
|
1382
|
+
const s = raw.storage ?? {};
|
|
1383
|
+
return {
|
|
1384
|
+
storage: {
|
|
1385
|
+
id: String(s.id ?? ""),
|
|
1386
|
+
name: String(s.name ?? name),
|
|
1387
|
+
projectId: String(s.projectId ?? projectId),
|
|
1388
|
+
publicUrl: s.publicUrl !== void 0 ? String(s.publicUrl) : void 0,
|
|
1389
|
+
status: s.status !== void 0 ? String(s.status) : void 0
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
async listProjectStorage(projectId, orgId) {
|
|
1394
|
+
const path = `/projects/${encodePathSegment(projectId)}/storage`;
|
|
1395
|
+
const raw = await this.transport.requestJson(
|
|
1396
|
+
"GET",
|
|
1397
|
+
path,
|
|
1398
|
+
void 0,
|
|
1399
|
+
orgHeaders(orgId)
|
|
1400
|
+
);
|
|
1401
|
+
const dataRaw = Array.isArray(raw.data) ? raw.data : [];
|
|
1402
|
+
return {
|
|
1403
|
+
object: String(raw.object ?? "list"),
|
|
1404
|
+
data: dataRaw.map((row) => {
|
|
1405
|
+
const s = row;
|
|
1406
|
+
return {
|
|
1407
|
+
id: String(s.id ?? ""),
|
|
1408
|
+
name: String(s.name ?? ""),
|
|
1409
|
+
projectId: String(s.projectId ?? projectId),
|
|
1410
|
+
publicUrl: s.publicUrl !== void 0 ? String(s.publicUrl) : void 0,
|
|
1411
|
+
status: s.status !== void 0 ? String(s.status) : void 0
|
|
1412
|
+
};
|
|
1413
|
+
})
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
async listTasks(opts) {
|
|
1417
|
+
const q = new URLSearchParams();
|
|
1418
|
+
if (opts?.projectId) q.set("projectId", opts.projectId);
|
|
1419
|
+
const path = q.toString() ? `/tasks?${q}` : "/tasks";
|
|
1420
|
+
const raw = await this.transport.requestJson(
|
|
1421
|
+
"GET",
|
|
1422
|
+
path,
|
|
1423
|
+
void 0,
|
|
1424
|
+
orgHeaders(opts?.orgId)
|
|
1425
|
+
);
|
|
1426
|
+
const dataRaw = Array.isArray(raw.data) ? raw.data : [];
|
|
1427
|
+
return {
|
|
1428
|
+
object: String(raw.object ?? "list"),
|
|
1429
|
+
data: dataRaw.map((row) => normalizeTask(row))
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
async createTask(name, opts) {
|
|
1433
|
+
const body = { name };
|
|
1434
|
+
if (opts?.projectId) body.projectId = opts.projectId;
|
|
1435
|
+
if (opts?.mode) body.mode = opts.mode;
|
|
1436
|
+
if (opts?.handler) body.handler = opts.handler;
|
|
1437
|
+
if (opts?.cron) body.cron = opts.cron;
|
|
1438
|
+
if (opts?.callbackUrl) body.callbackUrl = opts.callbackUrl;
|
|
1439
|
+
const raw = await this.transport.requestJson(
|
|
1440
|
+
"POST",
|
|
1441
|
+
"/tasks",
|
|
1442
|
+
body,
|
|
1443
|
+
orgHeaders(opts?.orgId)
|
|
1444
|
+
);
|
|
1445
|
+
const t = raw.task;
|
|
1446
|
+
return { task: t ? normalizeTask(t) : void 0 };
|
|
1447
|
+
}
|
|
1448
|
+
async getTask(id, orgId) {
|
|
1449
|
+
const path = `/tasks/${encodePathSegment(id)}`;
|
|
1450
|
+
const raw = await this.transport.requestJson(
|
|
1451
|
+
"GET",
|
|
1452
|
+
path,
|
|
1453
|
+
void 0,
|
|
1454
|
+
orgHeaders(orgId)
|
|
1455
|
+
);
|
|
1456
|
+
return normalizeTask(raw);
|
|
1457
|
+
}
|
|
1458
|
+
async listBackups(opts) {
|
|
1459
|
+
const path = opts?.resourceId ? `/resources/${encodePathSegment(opts.resourceId)}/backups` : "/backups";
|
|
1460
|
+
const raw = await this.transport.requestJson(
|
|
1461
|
+
"GET",
|
|
1462
|
+
path,
|
|
1463
|
+
void 0,
|
|
1464
|
+
orgHeaders(opts?.orgId)
|
|
1465
|
+
);
|
|
1466
|
+
const dataRaw = Array.isArray(raw.data) ? raw.data : [];
|
|
1467
|
+
return {
|
|
1468
|
+
object: String(raw.object ?? "list"),
|
|
1469
|
+
data: dataRaw.map((row) => {
|
|
1470
|
+
const b = row;
|
|
1471
|
+
return {
|
|
1472
|
+
id: String(b.id ?? ""),
|
|
1473
|
+
status: String(b.status ?? ""),
|
|
1474
|
+
resourceId: b.resourceId !== void 0 ? String(b.resourceId) : void 0,
|
|
1475
|
+
tag: b.tag !== void 0 ? String(b.tag) : void 0,
|
|
1476
|
+
createdAt: b.createdAt !== void 0 ? String(b.createdAt) : void 0
|
|
1477
|
+
};
|
|
1478
|
+
})
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
async createBackup(opts) {
|
|
1482
|
+
const body = {};
|
|
1483
|
+
if (opts?.resourceId) body.resourceId = opts.resourceId;
|
|
1484
|
+
if (opts?.tag) body.tag = opts.tag;
|
|
1485
|
+
const raw = await this.transport.requestJson(
|
|
1486
|
+
"POST",
|
|
1487
|
+
"/backups/trigger",
|
|
1488
|
+
body,
|
|
1489
|
+
orgHeaders(opts?.orgId)
|
|
1490
|
+
);
|
|
1491
|
+
const b = raw.backup ?? {};
|
|
1492
|
+
return {
|
|
1493
|
+
backup: {
|
|
1494
|
+
id: String(b.id ?? ""),
|
|
1495
|
+
status: String(b.status ?? ""),
|
|
1496
|
+
resourceId: b.resourceId !== void 0 ? String(b.resourceId) : void 0,
|
|
1497
|
+
tag: b.tag !== void 0 ? String(b.tag) : void 0,
|
|
1498
|
+
createdAt: b.createdAt !== void 0 ? String(b.createdAt) : void 0
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
async restoreBackup(backupId, opts) {
|
|
1503
|
+
const body = {};
|
|
1504
|
+
if (opts?.resourceId) body.resourceId = opts.resourceId;
|
|
1505
|
+
const path = `/backups/${encodePathSegment(backupId)}/restore`;
|
|
1506
|
+
const raw = await this.transport.requestJson(
|
|
1507
|
+
"POST",
|
|
1508
|
+
path,
|
|
1509
|
+
body,
|
|
1510
|
+
orgHeaders(opts?.orgId)
|
|
1511
|
+
);
|
|
1512
|
+
return {
|
|
1513
|
+
id: String(raw.id ?? backupId),
|
|
1514
|
+
status: String(raw.status ?? ""),
|
|
1515
|
+
message: raw.message !== void 0 ? String(raw.message) : void 0
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
async listFlags(opts) {
|
|
1519
|
+
const q = new URLSearchParams();
|
|
1520
|
+
if (opts?.projectId) q.set("projectId", opts.projectId);
|
|
1521
|
+
const path = q.toString() ? `/flags?${q}` : "/flags";
|
|
1522
|
+
const raw = await this.transport.requestJson(
|
|
1523
|
+
"GET",
|
|
1524
|
+
path,
|
|
1525
|
+
void 0,
|
|
1526
|
+
orgHeaders(opts?.orgId)
|
|
1527
|
+
);
|
|
1528
|
+
const dataRaw = Array.isArray(raw.data) ? raw.data : [];
|
|
1529
|
+
return {
|
|
1530
|
+
object: String(raw.object ?? "list"),
|
|
1531
|
+
data: dataRaw.map((row) => normalizeFlag(row))
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
async createFlag(key, opts) {
|
|
1535
|
+
const body = { key };
|
|
1536
|
+
if (opts?.description) body.description = opts.description;
|
|
1537
|
+
if (opts?.projectId) body.projectId = opts.projectId;
|
|
1538
|
+
if (opts?.enabled !== void 0) body.enabled = opts.enabled;
|
|
1539
|
+
const raw = await this.transport.requestJson(
|
|
1540
|
+
"POST",
|
|
1541
|
+
"/flags",
|
|
1542
|
+
body,
|
|
1543
|
+
orgHeaders(opts?.orgId)
|
|
1544
|
+
);
|
|
1545
|
+
const f = raw.flag;
|
|
1546
|
+
return { flag: f ? normalizeFlag(f) : void 0 };
|
|
1547
|
+
}
|
|
1548
|
+
async toggleFlag(key, opts) {
|
|
1549
|
+
const body = {};
|
|
1550
|
+
if (opts?.enabled !== void 0) body.enabled = opts.enabled;
|
|
1551
|
+
if (opts?.projectId) body.projectId = opts.projectId;
|
|
1552
|
+
const path = `/flags/${encodePathSegment(key)}/toggle`;
|
|
1553
|
+
const raw = await this.transport.requestJson(
|
|
1554
|
+
"POST",
|
|
1555
|
+
path,
|
|
1556
|
+
body,
|
|
1557
|
+
orgHeaders(opts?.orgId)
|
|
1558
|
+
);
|
|
1559
|
+
const f = raw.flag;
|
|
1560
|
+
return { flag: f ? normalizeFlag(f) : void 0 };
|
|
1561
|
+
}
|
|
1562
|
+
async getPreviewCost(projectId, prNumber, orgId) {
|
|
1563
|
+
const path = `/projects/${encodePathSegment(projectId)}/previews/${encodePathSegment(prNumber)}/cost`;
|
|
1564
|
+
const raw = await this.transport.requestJson(
|
|
1565
|
+
"GET",
|
|
1566
|
+
path,
|
|
1567
|
+
void 0,
|
|
1568
|
+
orgHeaders(orgId)
|
|
1569
|
+
);
|
|
1570
|
+
return {
|
|
1571
|
+
projectId: String(raw.projectId ?? projectId),
|
|
1572
|
+
prNumber: String(raw.prNumber ?? prNumber),
|
|
1573
|
+
total: Number(raw.total ?? 0),
|
|
1574
|
+
currency: String(raw.currency ?? "USD"),
|
|
1575
|
+
breakdownJson: raw.breakdownJson !== void 0 ? String(raw.breakdownJson) : void 0
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1052
1578
|
/** Escape hatch: authenticated raw Management REST. */
|
|
1053
1579
|
async api(method, path, body, orgId) {
|
|
1054
1580
|
return this.transport.rawRequest(method, path, body, orgHeaders(orgId));
|
|
@@ -1118,9 +1644,7 @@ function normalizeListProjects(raw) {
|
|
|
1118
1644
|
const pageRaw = raw.page ?? {};
|
|
1119
1645
|
return {
|
|
1120
1646
|
object: String(raw.object ?? "list"),
|
|
1121
|
-
data: dataRaw.map(
|
|
1122
|
-
(row) => normalizeProject(row)
|
|
1123
|
-
),
|
|
1647
|
+
data: dataRaw.map((row) => normalizeProject(row)),
|
|
1124
1648
|
page: {
|
|
1125
1649
|
nextPageToken: pageRaw.next_page_token !== void 0 ? String(pageRaw.next_page_token) : pageRaw.nextPageToken !== void 0 ? String(pageRaw.nextPageToken) : void 0,
|
|
1126
1650
|
hasMore: pageRaw.has_more !== void 0 ? Boolean(pageRaw.has_more) : pageRaw.hasMore !== void 0 ? Boolean(pageRaw.hasMore) : void 0
|
|
@@ -1161,9 +1685,7 @@ function normalizeListEnvironments(raw) {
|
|
|
1161
1685
|
const pageRaw = raw.page ?? {};
|
|
1162
1686
|
return {
|
|
1163
1687
|
object: String(raw.object ?? "list"),
|
|
1164
|
-
data: dataRaw.map(
|
|
1165
|
-
(row) => normalizeEnvironment(row)
|
|
1166
|
-
),
|
|
1688
|
+
data: dataRaw.map((row) => normalizeEnvironment(row)),
|
|
1167
1689
|
page: {
|
|
1168
1690
|
nextPageToken: pageRaw.next_page_token !== void 0 ? String(pageRaw.next_page_token) : pageRaw.nextPageToken !== void 0 ? String(pageRaw.nextPageToken) : void 0,
|
|
1169
1691
|
hasMore: pageRaw.has_more !== void 0 ? Boolean(pageRaw.has_more) : pageRaw.hasMore !== void 0 ? Boolean(pageRaw.hasMore) : void 0
|
|
@@ -1185,123 +1707,48 @@ function normalizeListDeployments(raw) {
|
|
|
1185
1707
|
const pageRaw = raw.page ?? {};
|
|
1186
1708
|
return {
|
|
1187
1709
|
object: String(raw.object ?? "list"),
|
|
1188
|
-
data: dataRaw.map(
|
|
1189
|
-
(row) => normalizeDeployment(row)
|
|
1190
|
-
),
|
|
1710
|
+
data: dataRaw.map((row) => normalizeDeployment(row)),
|
|
1191
1711
|
page: {
|
|
1192
1712
|
nextPageToken: pageRaw.next_page_token !== void 0 ? String(pageRaw.next_page_token) : pageRaw.nextPageToken !== void 0 ? String(pageRaw.nextPageToken) : void 0,
|
|
1193
1713
|
hasMore: pageRaw.has_more !== void 0 ? Boolean(pageRaw.has_more) : pageRaw.hasMore !== void 0 ? Boolean(pageRaw.hasMore) : void 0
|
|
1194
1714
|
}
|
|
1195
1715
|
};
|
|
1196
1716
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
MACHINE_RESOURCE_REQUIREMENTS,
|
|
1209
|
-
MACHINE_SIZES,
|
|
1210
|
-
parseMachineSize,
|
|
1211
|
-
resolveMachineConfig,
|
|
1212
|
-
resolveMachineMaxInstances,
|
|
1213
|
-
resolveMachineResources,
|
|
1214
|
-
resolveMachineTierResources,
|
|
1215
|
-
toPublicMachineSize
|
|
1216
|
-
} from "@sylphx/contract/compute";
|
|
1217
|
-
|
|
1218
|
-
// src/config/database-pricing.ts
|
|
1219
|
-
var COMPUTE_PRICE_PER_HOUR_MICRODOLLARS = 8e4;
|
|
1220
|
-
var FREE_COMPUTE_HOURS = 3;
|
|
1221
|
-
var STORAGE_PRICE_PER_GB_MONTH_MICRODOLLARS = 25e4;
|
|
1222
|
-
var FREE_STORAGE_GB = 0.25;
|
|
1223
|
-
var TRANSFER_PRICE_PER_GB_MICRODOLLARS = 9e4;
|
|
1224
|
-
var KV_FREE_STORAGE_GB = 0.25;
|
|
1225
|
-
var HOURS_PER_MONTH = 730;
|
|
1226
|
-
|
|
1227
|
-
// src/config/referrals.ts
|
|
1228
|
-
var DEFAULT_POINTS_REWARD = 100;
|
|
1229
|
-
var DISCOUNT_DURATION_MONTHS = 3;
|
|
1230
|
-
var DISCOUNT_PERCENT = 20;
|
|
1231
|
-
var PREMIUM_TRIAL_DAYS = 7;
|
|
1232
|
-
var REFERRAL_CODE_LENGTH = 8;
|
|
1233
|
-
var REFERRAL_CODE_CHARS = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
1234
|
-
function generateReferralCode() {
|
|
1235
|
-
const bytes = new Uint8Array(REFERRAL_CODE_LENGTH);
|
|
1236
|
-
crypto.getRandomValues(bytes);
|
|
1237
|
-
let code = "";
|
|
1238
|
-
for (let i = 0; i < REFERRAL_CODE_LENGTH; i++) {
|
|
1239
|
-
code += REFERRAL_CODE_CHARS[bytes[i] % REFERRAL_CODE_CHARS.length];
|
|
1240
|
-
}
|
|
1241
|
-
return code;
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
// src/error-extract.ts
|
|
1245
|
-
function getErrorMessage(error, fallback = "Unknown error") {
|
|
1246
|
-
if (error instanceof Error) {
|
|
1247
|
-
return error.message;
|
|
1248
|
-
}
|
|
1249
|
-
if (typeof error === "string") {
|
|
1250
|
-
return error;
|
|
1251
|
-
}
|
|
1252
|
-
if (error && typeof error === "object" && "message" in error) {
|
|
1253
|
-
const message = error.message;
|
|
1254
|
-
if (typeof message === "string") {
|
|
1255
|
-
return message;
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
if (error && typeof error === "object" && "response" in error) {
|
|
1259
|
-
const response = error.response;
|
|
1260
|
-
if (response?.data?.message) return response.data.message;
|
|
1261
|
-
if (response?.data?.error) return response.data.error;
|
|
1262
|
-
}
|
|
1263
|
-
return fallback;
|
|
1717
|
+
function normalizeResource(raw) {
|
|
1718
|
+
return {
|
|
1719
|
+
id: String(raw.id ?? ""),
|
|
1720
|
+
kind: String(raw.kind ?? ""),
|
|
1721
|
+
name: String(raw.name ?? ""),
|
|
1722
|
+
status: String(raw.status ?? ""),
|
|
1723
|
+
projectId: raw.projectId !== void 0 ? String(raw.projectId) : void 0,
|
|
1724
|
+
storageGb: raw.storageGb !== void 0 ? Number(raw.storageGb) : void 0,
|
|
1725
|
+
tier: raw.tier !== void 0 ? String(raw.tier) : void 0,
|
|
1726
|
+
message: raw.message !== void 0 ? String(raw.message) : void 0
|
|
1727
|
+
};
|
|
1264
1728
|
}
|
|
1265
|
-
function
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
}
|
|
1275
|
-
if ("statusCode" in error && typeof error.statusCode === "number") {
|
|
1276
|
-
return String(error.statusCode);
|
|
1277
|
-
}
|
|
1278
|
-
return void 0;
|
|
1729
|
+
function normalizeTask(raw) {
|
|
1730
|
+
return {
|
|
1731
|
+
id: String(raw.id ?? ""),
|
|
1732
|
+
name: String(raw.name ?? ""),
|
|
1733
|
+
status: String(raw.status ?? ""),
|
|
1734
|
+
mode: raw.mode !== void 0 ? String(raw.mode) : void 0,
|
|
1735
|
+
projectId: raw.projectId !== void 0 ? String(raw.projectId) : void 0,
|
|
1736
|
+
handler: raw.handler !== void 0 ? String(raw.handler) : void 0
|
|
1737
|
+
};
|
|
1279
1738
|
}
|
|
1280
|
-
function
|
|
1281
|
-
|
|
1282
|
-
|
|
1739
|
+
function normalizeFlag(raw) {
|
|
1740
|
+
return {
|
|
1741
|
+
key: String(raw.key ?? ""),
|
|
1742
|
+
enabled: Boolean(raw.enabled),
|
|
1743
|
+
description: raw.description !== void 0 ? String(raw.description) : void 0,
|
|
1744
|
+
projectId: raw.projectId !== void 0 ? String(raw.projectId) : void 0
|
|
1283
1745
|
};
|
|
1284
|
-
if (error instanceof Error) {
|
|
1285
|
-
details.name = error.name;
|
|
1286
|
-
details.stack = error.stack;
|
|
1287
|
-
if (error.cause) {
|
|
1288
|
-
details.cause = error.cause;
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
const code = getErrorCode(error);
|
|
1292
|
-
if (code) {
|
|
1293
|
-
details.code = code;
|
|
1294
|
-
}
|
|
1295
|
-
if (error && typeof error === "object") {
|
|
1296
|
-
if ("status" in error && typeof error.status === "number") {
|
|
1297
|
-
details.status = error.status;
|
|
1298
|
-
} else if ("statusCode" in error && typeof error.statusCode === "number") {
|
|
1299
|
-
details.status = error.statusCode;
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
return details;
|
|
1303
1746
|
}
|
|
1304
1747
|
|
|
1748
|
+
// src/product/wire.ts
|
|
1749
|
+
var WIRE_CONTRACT_PACKAGE = "sylphx.platform.v1";
|
|
1750
|
+
var WIRE_CONTRACT_REVISION = "0.4.0";
|
|
1751
|
+
|
|
1305
1752
|
// src/connection-url.ts
|
|
1306
1753
|
var SYLPHX_PROTOCOL = "sylphx:";
|
|
1307
1754
|
var DEFAULT_DOMAIN = "api.sylphx.com";
|