@djvlc/runtime-web 1.1.0 → 1.1.2
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/adapters/openapi-user-adapter.d.ts +17 -0
- package/dist/adapters/openapi-user-adapter.d.ts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/mount.d.ts.map +1 -1
- package/dist/runtime.esm.js +2507 -260
- package/dist/runtime.iife.js +1 -1
- package/package.json +4 -2
package/dist/runtime.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const RUNTIME_VERSION = "1.
|
|
1
|
+
const RUNTIME_VERSION = "1.1.1";
|
|
2
2
|
var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
3
3
|
ErrorCode2["SYSTEM_INTERNAL_ERROR"] = "SYSTEM_INTERNAL_ERROR";
|
|
4
4
|
ErrorCode2["SYSTEM_SERVICE_UNAVAILABLE"] = "SYSTEM_SERVICE_UNAVAILABLE";
|
|
@@ -1039,7 +1039,7 @@ var i = class extends Error {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
const i2 = performance.now();
|
|
1041
1041
|
try {
|
|
1042
|
-
const n2 = await this.
|
|
1042
|
+
const n2 = await this.callResolveViaAdapter(t3, e), r2 = await this.loadFromCdn(n2, t3);
|
|
1043
1043
|
((_b = this.options.cache) == null ? void 0 : _b.enabled) && this.cache.set(s, { data: r2, timestamp: Date.now() });
|
|
1044
1044
|
const o2 = performance.now() - i2;
|
|
1045
1045
|
return this.log("info", `Page ${t3} resolved in ${o2.toFixed(2)}ms`), r2;
|
|
@@ -1048,16 +1048,10 @@ var i = class extends Error {
|
|
|
1048
1048
|
throw new n(`Failed to resolve page: ${e2 instanceof Error ? e2.message : "Unknown error"}`, { pageId: t3 });
|
|
1049
1049
|
}
|
|
1050
1050
|
}
|
|
1051
|
-
async
|
|
1052
|
-
const s =
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
this.options.authToken && (i2.Authorization = `Bearer ${this.options.authToken}`), this.log("debug", "Calling resolve API:" + s.toString());
|
|
1056
|
-
const r2 = await fetch(s.toString(), { method: "GET", headers: i2 });
|
|
1057
|
-
if (!r2.ok) throw new n(`Failed to resolve page: ${r2.status} ${r2.statusText}`, { pageId: t3, status: r2.status });
|
|
1058
|
-
const o2 = await r2.json();
|
|
1059
|
-
if (!this.isValidPageResolveResponse(o2)) throw new n("Invalid page resolve response", { pageId: t3 });
|
|
1060
|
-
return o2;
|
|
1051
|
+
async callResolveViaAdapter(t3, e) {
|
|
1052
|
+
const s = await this.options.userApiAdapter.resolvePage({ pageId: t3, uid: e == null ? void 0 : e.uid, deviceId: e == null ? void 0 : e.deviceId, env: this.options.env, channel: this.options.channel, previewToken: this.options.previewToken });
|
|
1053
|
+
if (!this.isValidPageResolveResponse(s)) throw new n("Invalid page resolve response", { pageId: t3 });
|
|
1054
|
+
return s;
|
|
1061
1055
|
}
|
|
1062
1056
|
async loadFromCdn(t3, e) {
|
|
1063
1057
|
try {
|
|
@@ -1100,8 +1094,7 @@ var i = class extends Error {
|
|
|
1100
1094
|
else this.cache.clear();
|
|
1101
1095
|
}
|
|
1102
1096
|
buildHeaders() {
|
|
1103
|
-
|
|
1104
|
-
return this.options.authToken && (t3.Authorization = `Bearer ${this.options.authToken}`), t3;
|
|
1097
|
+
return { "Content-Type": "application/json", ...this.options.headers };
|
|
1105
1098
|
}
|
|
1106
1099
|
getCacheKey(t3, e) {
|
|
1107
1100
|
const s = [t3, this.options.env, this.options.channel];
|
|
@@ -1115,7 +1108,7 @@ var i = class extends Error {
|
|
|
1115
1108
|
log(t3, e) {
|
|
1116
1109
|
this.options.logger && this.options.logger[t3](e);
|
|
1117
1110
|
}
|
|
1118
|
-
}, p = class {
|
|
1111
|
+
}, p = { sha256: "SHA-256", sha384: "SHA-384", sha512: "SHA-512" }, f = class {
|
|
1119
1112
|
constructor(t3) {
|
|
1120
1113
|
this.loadedComponents = /* @__PURE__ */ new Map(), this.loadingPromises = /* @__PURE__ */ new Map(), this.options = { enableSRI: true, concurrency: 4, timeout: 3e4, blockedComponents: [], ...t3 }, this.blockedSet = new Set(this.options.blockedComponents);
|
|
1121
1114
|
}
|
|
@@ -1186,9 +1179,9 @@ var i = class extends Error {
|
|
|
1186
1179
|
}
|
|
1187
1180
|
}
|
|
1188
1181
|
async fetchWithTimeout(t3) {
|
|
1189
|
-
const e = new AbortController(), s = setTimeout(() => e.abort(), this.options.timeout);
|
|
1182
|
+
const e = new AbortController(), s = setTimeout(() => e.abort(), this.options.timeout), i2 = { signal: e.signal, credentials: "omit", headers: this.options.headers ? { ...this.options.headers } : void 0 }, n2 = this.options.fetchComponentScript ?? fetch;
|
|
1190
1183
|
try {
|
|
1191
|
-
return await
|
|
1184
|
+
return await n2(t3, i2);
|
|
1192
1185
|
} finally {
|
|
1193
1186
|
clearTimeout(s);
|
|
1194
1187
|
}
|
|
@@ -1197,19 +1190,24 @@ var i = class extends Error {
|
|
|
1197
1190
|
if (!t3.integrity) return;
|
|
1198
1191
|
const [s, i2] = t3.integrity.split("-");
|
|
1199
1192
|
if (!s || !i2) throw new o(t3.name, t3.version, t3.integrity, "Invalid format");
|
|
1200
|
-
const n2 =
|
|
1201
|
-
if (
|
|
1193
|
+
const n2 = p[s.toLowerCase()];
|
|
1194
|
+
if (!n2) throw new o(t3.name, t3.version, t3.integrity, `Unsupported SRI algorithm: ${s}, expected sha256/sha384/sha512`);
|
|
1195
|
+
const r2 = await crypto.subtle.digest(n2, new TextEncoder().encode(e)), a2 = Array.from(new Uint8Array(r2)), c2 = btoa(String.fromCharCode(...a2));
|
|
1196
|
+
if (c2 !== i2) throw new o(t3.name, t3.version, i2, c2);
|
|
1202
1197
|
}
|
|
1203
1198
|
async executeScript(t3, e) {
|
|
1204
1199
|
const s = new Blob([t3], { type: "application/javascript" }), i2 = URL.createObjectURL(s);
|
|
1205
1200
|
try {
|
|
1206
|
-
const t4 = await import(i2), s2 = t4.default
|
|
1207
|
-
if (!s2) throw new r(e.name, e.version, "Component module does not export a valid component");
|
|
1201
|
+
const t4 = await import(i2), s2 = t4.default ?? t4[e.name] ?? t4[this.kebabToPascal(e.name)] ?? t4.Component;
|
|
1202
|
+
if (!s2) throw new r(e.name, e.version, "Component module does not export a valid component (expected default or Component)");
|
|
1208
1203
|
return s2;
|
|
1209
1204
|
} finally {
|
|
1210
1205
|
URL.revokeObjectURL(i2);
|
|
1211
1206
|
}
|
|
1212
1207
|
}
|
|
1208
|
+
kebabToPascal(t3) {
|
|
1209
|
+
return t3.split("-").map((t4) => t4.charAt(0).toUpperCase() + t4.slice(1).toLowerCase()).join("");
|
|
1210
|
+
}
|
|
1213
1211
|
resolveUrl(t3) {
|
|
1214
1212
|
return t3.startsWith("http://") || t3.startsWith("https://") ? t3 : `${this.options.cdnBaseUrl}/${t3.replace(/^\//, "")}`;
|
|
1215
1213
|
}
|
|
@@ -1219,7 +1217,7 @@ var i = class extends Error {
|
|
|
1219
1217
|
log(t3, e) {
|
|
1220
1218
|
this.options.logger && this.options.logger[t3](e);
|
|
1221
1219
|
}
|
|
1222
|
-
},
|
|
1220
|
+
}, m = class {
|
|
1223
1221
|
constructor(t3) {
|
|
1224
1222
|
this.preconnectedHosts = /* @__PURE__ */ new Set(), this.preloadedAssets = /* @__PURE__ */ new Set(), this.options = t3;
|
|
1225
1223
|
}
|
|
@@ -1238,21 +1236,21 @@ var i = class extends Error {
|
|
|
1238
1236
|
preloadScript(t3, e) {
|
|
1239
1237
|
if (this.preloadedAssets.has(t3)) return;
|
|
1240
1238
|
const s = document.createElement("link");
|
|
1241
|
-
s.rel = "preload", s.as
|
|
1239
|
+
s.rel = "preload", s.setAttribute("as", "script"), s.href = t3, e && (s.setAttribute("integrity", e), s.setAttribute("crossorigin", "anonymous")), document.head.appendChild(s), this.preloadedAssets.add(t3);
|
|
1242
1240
|
}
|
|
1243
1241
|
preloadStyle(t3, e) {
|
|
1244
1242
|
if (this.preloadedAssets.has(t3)) return;
|
|
1245
1243
|
const s = document.createElement("link");
|
|
1246
|
-
s.rel = "preload", s.as
|
|
1244
|
+
s.rel = "preload", s.setAttribute("as", "style"), s.href = t3, e && (s.setAttribute("integrity", e), s.setAttribute("crossorigin", "anonymous")), document.head.appendChild(s), this.preloadedAssets.add(t3);
|
|
1247
1245
|
}
|
|
1248
1246
|
preloadImage(t3) {
|
|
1249
1247
|
if (this.preloadedAssets.has(t3)) return;
|
|
1250
1248
|
const e = document.createElement("link");
|
|
1251
|
-
e.rel = "preload", e.as
|
|
1249
|
+
e.rel = "preload", e.setAttribute("as", "image"), e.href = t3, document.head.appendChild(e), this.preloadedAssets.add(t3);
|
|
1252
1250
|
}
|
|
1253
1251
|
prefetch(t3, e) {
|
|
1254
1252
|
const s = document.createElement("link");
|
|
1255
|
-
s.rel = "prefetch", s.href = t3, e &&
|
|
1253
|
+
s.rel = "prefetch", s.href = t3, e && s.setAttribute("as", e), document.head.appendChild(s);
|
|
1256
1254
|
}
|
|
1257
1255
|
loadStylesheet(t3, e) {
|
|
1258
1256
|
return new Promise((s, i2) => {
|
|
@@ -1266,7 +1264,7 @@ var i = class extends Error {
|
|
|
1266
1264
|
n2.src = t3, n2.async = true, e && (n2.integrity = e, n2.crossOrigin = "anonymous"), n2.onload = () => s(), n2.onerror = () => i2(new Error(`Failed to load script: ${t3}`)), document.body.appendChild(n2);
|
|
1267
1265
|
});
|
|
1268
1266
|
}
|
|
1269
|
-
},
|
|
1267
|
+
}, g = class {
|
|
1270
1268
|
constructor() {
|
|
1271
1269
|
this.listeners = /* @__PURE__ */ new Set(), this.changeCallbacks = /* @__PURE__ */ new Set(), this.state = this.createInitialState();
|
|
1272
1270
|
}
|
|
@@ -1398,7 +1396,7 @@ var i = class extends Error {
|
|
|
1398
1396
|
createInitialState() {
|
|
1399
1397
|
return { phase: "idle", page: null, variables: {}, queries: {}, components: /* @__PURE__ */ new Map(), error: null, destroyed: false };
|
|
1400
1398
|
}
|
|
1401
|
-
},
|
|
1399
|
+
}, y = class {
|
|
1402
1400
|
constructor(t3) {
|
|
1403
1401
|
this.bindings = /* @__PURE__ */ new Map(), this.dependencyGraph = /* @__PURE__ */ new Map(), this.bindingDependencies = /* @__PURE__ */ new Map(), this.options = t3;
|
|
1404
1402
|
}
|
|
@@ -1580,7 +1578,7 @@ var i = class extends Error {
|
|
|
1580
1578
|
log(t3, e, ...s) {
|
|
1581
1579
|
this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
|
|
1582
1580
|
}
|
|
1583
|
-
},
|
|
1581
|
+
}, b = class {
|
|
1584
1582
|
constructor(t3 = {}) {
|
|
1585
1583
|
this.handlers = /* @__PURE__ */ new Map(), this.options = { debug: false, maxListeners: 100, ...t3 };
|
|
1586
1584
|
}
|
|
@@ -1624,7 +1622,7 @@ var i = class extends Error {
|
|
|
1624
1622
|
log(t3, e, ...s) {
|
|
1625
1623
|
this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
|
|
1626
1624
|
}
|
|
1627
|
-
},
|
|
1625
|
+
}, w = class t {
|
|
1628
1626
|
constructor(t3) {
|
|
1629
1627
|
this.debounceTimers = /* @__PURE__ */ new Map(), this.throttleTimers = /* @__PURE__ */ new Map(), this.options = t3;
|
|
1630
1628
|
}
|
|
@@ -1783,8 +1781,8 @@ var i = class extends Error {
|
|
|
1783
1781
|
this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
|
|
1784
1782
|
}
|
|
1785
1783
|
};
|
|
1786
|
-
|
|
1787
|
-
var
|
|
1784
|
+
w.EXPRESSION_TYPES = ["state", "binding", "local", "template", "computed"];
|
|
1785
|
+
var v = w, $ = class {
|
|
1788
1786
|
constructor(t3) {
|
|
1789
1787
|
this.pos = 0, this.tokens = [], this.input = t3;
|
|
1790
1788
|
}
|
|
@@ -1890,7 +1888,7 @@ var w = b, v = class {
|
|
|
1890
1888
|
peek(t3 = 1) {
|
|
1891
1889
|
return this.input[this.pos + t3] || "";
|
|
1892
1890
|
}
|
|
1893
|
-
},
|
|
1891
|
+
}, S = { len: (t3) => "string" == typeof t3 || Array.isArray(t3) ? t3.length : 0, trim: (t3) => String(t3 ?? "").trim(), upper: (t3) => String(t3 ?? "").toUpperCase(), lower: (t3) => String(t3 ?? "").toLowerCase(), substr: (t3, e, s) => {
|
|
1894
1892
|
const i2 = String(t3 ?? ""), n2 = Number(e) || 0, r2 = void 0 !== s ? Number(s) : void 0;
|
|
1895
1893
|
return i2.substring(n2, void 0 !== r2 ? n2 + r2 : void 0);
|
|
1896
1894
|
}, concat: (...t3) => t3.map((t4) => String(t4 ?? "")).join(""), replace: (t3, e, s) => String(t3 ?? "").split(String(e)).join(String(s)), split: (t3, e) => String(t3 ?? "").split(String(e)), join: (t3, e) => Array.isArray(t3) ? t3.join(void 0 !== e ? String(e) : ",") : "", startsWith: (t3, e) => String(t3 ?? "").startsWith(String(e)), endsWith: (t3, e) => String(t3 ?? "").endsWith(String(e)), contains: (t3, e) => String(t3 ?? "").includes(String(e)), toNumber: (t3) => {
|
|
@@ -2047,7 +2045,7 @@ var w = b, v = class {
|
|
|
2047
2045
|
}, repeat: (t3, e) => {
|
|
2048
2046
|
const s = String(t3 ?? ""), i2 = Math.max(0, Math.floor(Number(e) || 0));
|
|
2049
2047
|
return s.repeat(i2);
|
|
2050
|
-
} },
|
|
2048
|
+
} }, x = { "||": 1, "??": 1, "&&": 2, "==": 3, "!=": 3, "<": 4, ">": 4, "<=": 4, ">=": 4, "+": 5, "-": 5, "*": 6, "/": 6, "%": 6 }, k = class {
|
|
2051
2049
|
constructor(t3) {
|
|
2052
2050
|
this.pos = 0, this.tokens = t3;
|
|
2053
2051
|
}
|
|
@@ -2073,7 +2071,7 @@ var w = b, v = class {
|
|
|
2073
2071
|
for (; ; ) {
|
|
2074
2072
|
const s = this.current();
|
|
2075
2073
|
if ("OPERATOR" !== s.type) break;
|
|
2076
|
-
const i2 =
|
|
2074
|
+
const i2 = x[s.value];
|
|
2077
2075
|
if (void 0 === i2 || i2 < t3) break;
|
|
2078
2076
|
this.advance();
|
|
2079
2077
|
const n2 = this.parseBinary(i2 + 1);
|
|
@@ -2103,7 +2101,7 @@ var w = b, v = class {
|
|
|
2103
2101
|
if ("LPAREN" !== e.type || "identifier" !== t3.type) break;
|
|
2104
2102
|
{
|
|
2105
2103
|
const s = t3.name;
|
|
2106
|
-
if (!(s in
|
|
2104
|
+
if (!(s in S)) throw new Error(`Unknown function '${s}' at position ${e.start}`);
|
|
2107
2105
|
this.advance();
|
|
2108
2106
|
const i2 = this.parseArguments();
|
|
2109
2107
|
this.expect("RPAREN"), t3 = { type: "call", callee: s, arguments: i2, raw: void 0 };
|
|
@@ -2148,7 +2146,7 @@ var w = b, v = class {
|
|
|
2148
2146
|
if (e.type !== t3) throw new Error(`Expected '${t3}' but got '${e.type}' at position ${e.start}`);
|
|
2149
2147
|
return this.advance();
|
|
2150
2148
|
}
|
|
2151
|
-
},
|
|
2149
|
+
}, E = class {
|
|
2152
2150
|
constructor(t3 = {}) {
|
|
2153
2151
|
this.depth = 0, this.startTime = 0, this.options = { maxDepth: 100, timeout: 1e3, debug: false, ...t3 };
|
|
2154
2152
|
}
|
|
@@ -2216,7 +2214,7 @@ var w = b, v = class {
|
|
|
2216
2214
|
return i2 = t3.computed ? this.evaluateNode(t3.property, e) : t3.property, "object" == typeof s && null !== s ? s[i2] : void 0;
|
|
2217
2215
|
}
|
|
2218
2216
|
evaluateCall(t3, e) {
|
|
2219
|
-
const s =
|
|
2217
|
+
const s = S[t3.callee];
|
|
2220
2218
|
if (!s) throw new c("", `Unknown function '${t3.callee}'`);
|
|
2221
2219
|
return s(...t3.arguments.map((t4) => this.evaluateNode(t4, e)));
|
|
2222
2220
|
}
|
|
@@ -2282,9 +2280,9 @@ var w = b, v = class {
|
|
|
2282
2280
|
if (this.depth++, this.depth > (this.options.maxDepth ?? 100)) throw new c("", "Maximum recursion depth exceeded");
|
|
2283
2281
|
if (Date.now() - this.startTime > (this.options.timeout ?? 1e3)) throw new c("", "Expression evaluation timeout");
|
|
2284
2282
|
}
|
|
2285
|
-
},
|
|
2283
|
+
}, I = class {
|
|
2286
2284
|
constructor(t3 = {}) {
|
|
2287
|
-
this.astCache = /* @__PURE__ */ new Map(), this.options = { cacheAST: true, maxCacheSize: 1e3, ...t3 }, this.evaluator = new
|
|
2285
|
+
this.astCache = /* @__PURE__ */ new Map(), this.options = { cacheAST: true, maxCacheSize: 1e3, ...t3 }, this.evaluator = new E(t3);
|
|
2288
2286
|
}
|
|
2289
2287
|
evaluate(t3, e) {
|
|
2290
2288
|
try {
|
|
@@ -2310,7 +2308,7 @@ var w = b, v = class {
|
|
|
2310
2308
|
if (e) return e;
|
|
2311
2309
|
}
|
|
2312
2310
|
try {
|
|
2313
|
-
const e = new
|
|
2311
|
+
const e = new $(t3).tokenize(), s = new k(e).parse();
|
|
2314
2312
|
return this.options.cacheAST && (this.astCache.size >= (this.options.maxCacheSize ?? 1e3) && Array.from(this.astCache.keys()).slice(0, Math.floor(this.astCache.size / 2)).forEach((t4) => this.astCache.delete(t4)), this.astCache.set(t3, s)), s;
|
|
2315
2313
|
} catch (e) {
|
|
2316
2314
|
throw new c(t3, e instanceof Error ? e.message : "Parse error");
|
|
@@ -2365,7 +2363,7 @@ var w = b, v = class {
|
|
|
2365
2363
|
log(t3, e, ...s) {
|
|
2366
2364
|
this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
|
|
2367
2365
|
}
|
|
2368
|
-
},
|
|
2366
|
+
}, A = class {
|
|
2369
2367
|
constructor(t3) {
|
|
2370
2368
|
this.loadingCount = 0, this.loadingElement = null, this.clipboard = { write: async (t4) => {
|
|
2371
2369
|
try {
|
|
@@ -2427,22 +2425,15 @@ var w = b, v = class {
|
|
|
2427
2425
|
track(t3) {
|
|
2428
2426
|
this.log("debug", "Track event:", t3);
|
|
2429
2427
|
const e = this.options.context;
|
|
2430
|
-
|
|
2431
|
-
this.log("warn", "Track failed:", t4);
|
|
2432
|
-
});
|
|
2428
|
+
this.options.userApiAdapter.track({ eventName: t3.eventName, params: t3.params, type: t3.type || "custom", timestamp: Date.now(), context: { pageVersionId: e.pageVersionId, runtimeVersion: e.runtimeVersion, userId: e.userId, deviceId: e.deviceId, channel: e.channel, appId: e.appId, env: e.env } });
|
|
2433
2429
|
}
|
|
2434
2430
|
async requestData(t3, e) {
|
|
2435
2431
|
this.log("debug", `Requesting data: ${t3}`, e);
|
|
2436
2432
|
const s = performance.now(), i2 = this.options.context;
|
|
2437
2433
|
try {
|
|
2438
|
-
const n2 = await
|
|
2439
|
-
if (!n2.
|
|
2440
|
-
|
|
2441
|
-
throw new Error(`HTTP ${n2.status}: ${t4 || n2.statusText}`);
|
|
2442
|
-
}
|
|
2443
|
-
const r2 = await n2.json(), o2 = performance.now() - s;
|
|
2444
|
-
if (this.log("debug", `Data query completed in ${o2.toFixed(2)}ms`), !r2.success) throw new Error(r2.message || r2.errorMessage || "Query failed");
|
|
2445
|
-
return this.options.stateManager.setQuery(t3, r2.data), r2.data;
|
|
2434
|
+
const n2 = await this.options.userApiAdapter.executeQuery({ queryVersionId: t3, params: e ?? {}, context: { pageVersionId: i2.pageVersionId, uid: i2.userId, deviceId: i2.deviceId } }), r2 = performance.now() - s;
|
|
2435
|
+
if (this.log("debug", `Data query completed in ${r2.toFixed(2)}ms`), !n2.success) throw new Error(n2.message || n2.errorMessage || "Query failed");
|
|
2436
|
+
return this.options.stateManager.setQuery(t3, n2.data), n2.data;
|
|
2446
2437
|
} catch (e2) {
|
|
2447
2438
|
const i3 = performance.now() - s;
|
|
2448
2439
|
throw this.log("error", `Data query failed: ${t3} (${i3.toFixed(2)}ms)`, e2), e2;
|
|
@@ -2453,13 +2444,8 @@ var w = b, v = class {
|
|
|
2453
2444
|
const s = performance.now(), i2 = this.options.context, n2 = this.generateIdempotencyKey(t3, e);
|
|
2454
2445
|
this.track({ eventName: "djvlc_action_start", params: { actionType: t3, idempotencyKey: n2 }, type: "custom" });
|
|
2455
2446
|
try {
|
|
2456
|
-
const r2 = await
|
|
2457
|
-
|
|
2458
|
-
const e2 = await r2.text(), i3 = performance.now() - s;
|
|
2459
|
-
return this.log("error", `Action HTTP error: ${t3} (${i3.toFixed(2)}ms)`, e2), { success: false, errorCode: `HTTP_${r2.status}`, errorMessage: e2 || r2.statusText };
|
|
2460
|
-
}
|
|
2461
|
-
const o2 = await r2.json(), a2 = performance.now() - s;
|
|
2462
|
-
return this.log("debug", `Action completed in ${a2.toFixed(2)}ms`, { success: o2.success }), this.track({ eventName: o2.success ? "djvlc_action_success" : "djvlc_action_fail", params: { actionType: t3, idempotencyKey: n2, duration: Math.round(a2), errorCode: o2.errorCode }, type: "custom" }), { success: o2.success, data: o2.data, errorCode: o2.errorCode, errorMessage: o2.errorMessage };
|
|
2447
|
+
const r2 = await this.options.userApiAdapter.executeAction({ actionType: t3, params: e || {}, context: { pageVersionId: i2.pageVersionId, uid: i2.userId, deviceId: i2.deviceId, channel: i2.channel, appId: i2.appId }, idempotencyKey: n2 }), o2 = performance.now() - s;
|
|
2448
|
+
return this.log("debug", `Action completed in ${o2.toFixed(2)}ms`, { success: r2.success }), this.track({ eventName: r2.success ? "djvlc_action_success" : "djvlc_action_fail", params: { actionType: t3, idempotencyKey: n2, duration: Math.round(o2), errorCode: r2.errorCode }, type: "custom" }), r2;
|
|
2463
2449
|
} catch (e2) {
|
|
2464
2450
|
const i3 = performance.now() - s;
|
|
2465
2451
|
return this.log("error", `Action failed: ${t3} (${i3.toFixed(2)}ms)`, e2), this.track({ eventName: "djvlc_action_error", params: { actionType: t3, idempotencyKey: n2, duration: Math.round(i3), errorMessage: e2 instanceof Error ? e2.message : "Unknown error" }, type: "custom" }), { success: false, errorCode: "NETWORK_ERROR", errorMessage: e2 instanceof Error ? e2.message : "Action failed" };
|
|
@@ -2551,10 +2537,6 @@ var w = b, v = class {
|
|
|
2551
2537
|
const t3 = this.options.context;
|
|
2552
2538
|
return { pageVersionId: t3.pageVersionId, componentVersionId: "", instanceId: "", userId: t3.userId, deviceId: t3.deviceId, channel: t3.channel, appId: t3.appId, env: t3.env };
|
|
2553
2539
|
}
|
|
2554
|
-
buildHeaders() {
|
|
2555
|
-
const t3 = { "Content-Type": "application/json", ...this.options.headers };
|
|
2556
|
-
return this.options.authToken && (t3.Authorization = `Bearer ${this.options.authToken}`), t3;
|
|
2557
|
-
}
|
|
2558
2540
|
generateIdempotencyKey(t3, e) {
|
|
2559
2541
|
const s = Date.now(), i2 = JSON.stringify(e || {});
|
|
2560
2542
|
return `${t3}:${s}:${this.simpleHash(i2)}`;
|
|
@@ -2578,7 +2560,7 @@ var w = b, v = class {
|
|
|
2578
2560
|
log(t3, e, ...s) {
|
|
2579
2561
|
this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
|
|
2580
2562
|
}
|
|
2581
|
-
},
|
|
2563
|
+
}, N = class {
|
|
2582
2564
|
constructor(t3 = {}) {
|
|
2583
2565
|
var _a;
|
|
2584
2566
|
this.blockedComponentsMap = /* @__PURE__ */ new Map(), this.blockedActionsSet = /* @__PURE__ */ new Set(), this.allowedCapabilitiesSet = null, this.options = { enableSRI: true, cdnDomains: [], apiDomains: [], blockedComponents: [], blockedActions: [], applyCSPOnInit: false, ...t3 }, this.updateBlockedList(((_a = t3.blockedComponents) == null ? void 0 : _a.map((t4) => `${t4.name}@${t4.version}`)) || [], t3.blockedActions || []), t3.allowedCapabilities && (this.allowedCapabilitiesSet = new Set(t3.allowedCapabilities)), t3.applyCSPOnInit && this.applyCSP();
|
|
@@ -2680,7 +2662,7 @@ var w = b, v = class {
|
|
|
2680
2662
|
log(t3, e, ...s) {
|
|
2681
2663
|
this.options.logger && this.options.logger[t3](e, ...s);
|
|
2682
2664
|
}
|
|
2683
|
-
},
|
|
2665
|
+
}, C = class {
|
|
2684
2666
|
constructor(t3) {
|
|
2685
2667
|
this.spans = /* @__PURE__ */ new Map(), this.metrics = [], this.errors = [], this.options = { enabled: true, sampleRate: 1, batchSize: 50, flushInterval: 3e4, ...t3 }, this.traceId = this.generateTraceId(), this.shouldSample = Math.random() < (this.options.sampleRate ?? 1), this.options.enabled && this.options.endpoint && this.startAutoFlush(), "undefined" != typeof window && (window.addEventListener("beforeunload", () => this.flush()), window.addEventListener("visibilitychange", () => {
|
|
2686
2668
|
"hidden" === document.visibilityState && this.flush();
|
|
@@ -2783,7 +2765,7 @@ var w = b, v = class {
|
|
|
2783
2765
|
log(t3, e, ...s) {
|
|
2784
2766
|
this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
|
|
2785
2767
|
}
|
|
2786
|
-
},
|
|
2768
|
+
}, j = class t2 {
|
|
2787
2769
|
constructor(t3) {
|
|
2788
2770
|
this.container = null, this.renderedElements = /* @__PURE__ */ new Map(), this.componentEventListeners = /* @__PURE__ */ new Map(), this.expressionContext = { state: {}, binding: {}, local: {} }, this.loopContextStack = [], this.styleElement = null, this.options = t3;
|
|
2789
2771
|
}
|
|
@@ -3138,9 +3120,9 @@ var w = b, v = class {
|
|
|
3138
3120
|
this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
|
|
3139
3121
|
}
|
|
3140
3122
|
};
|
|
3141
|
-
|
|
3142
|
-
var
|
|
3143
|
-
function
|
|
3123
|
+
j.EXPRESSION_TYPES = ["state", "binding", "local", "template", "computed"];
|
|
3124
|
+
var D = j;
|
|
3125
|
+
function T() {
|
|
3144
3126
|
customElements.get("djvlc-fallback") || customElements.define("djvlc-fallback", class extends HTMLElement {
|
|
3145
3127
|
constructor() {
|
|
3146
3128
|
super(), this.attachShadow({ mode: "open" }).innerHTML = '\n <style>\n :host {\n display: block;\n padding: 16px;\n background: #fff2f0;\n border: 1px solid #ffccc7;\n border-radius: 4px;\n color: #ff4d4f;\n font-size: 14px;\n }\n .title {\n font-weight: 600;\n margin-bottom: 8px;\n }\n .message {\n color: #666;\n }\n </style>\n <div class="title">组件加载失败</div>\n <div class="message"><slot>请刷新页面重试</slot></div>\n ';
|
|
@@ -3168,11 +3150,11 @@ function j() {
|
|
|
3168
3150
|
}
|
|
3169
3151
|
});
|
|
3170
3152
|
}
|
|
3171
|
-
function
|
|
3153
|
+
function R(t3, e, s) {
|
|
3172
3154
|
const i2 = `djvlc-${"error-boundary"}`, n2 = document.createElement(i2);
|
|
3173
3155
|
return e && n2.setAttribute("message", e), n2;
|
|
3174
3156
|
}
|
|
3175
|
-
var
|
|
3157
|
+
var M = class {
|
|
3176
3158
|
constructor(t3) {
|
|
3177
3159
|
this.lifecycle = null, this.mounted = false, this.destroyed = false, this.cleanupFns = [], this.options = t3;
|
|
3178
3160
|
}
|
|
@@ -3234,20 +3216,21 @@ var R = class {
|
|
|
3234
3216
|
log(t3, e, ...s) {
|
|
3235
3217
|
this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
|
|
3236
3218
|
}
|
|
3237
|
-
},
|
|
3238
|
-
function
|
|
3239
|
-
return new
|
|
3219
|
+
}, L = CURRENT_SCHEMA_VERSION, O = "1.0.0";
|
|
3220
|
+
function P(t3) {
|
|
3221
|
+
return new V(t3);
|
|
3240
3222
|
}
|
|
3241
|
-
var
|
|
3223
|
+
var V = class {
|
|
3242
3224
|
constructor(t3) {
|
|
3243
3225
|
if (this.container = null, !t3.pageId) throw new Error("pageId is required");
|
|
3244
|
-
this.options = { channel: "prod", debug: false, enableSRI: true, env: "production", ...t3 }, this.logger = this.createLogger(), this.stateManager = new
|
|
3226
|
+
if (this.options = { channel: "prod", debug: false, enableSRI: true, env: "production", ...t3 }, this.logger = this.createLogger(), this.stateManager = new g(), this.eventBus = new b({ debug: t3.debug, logger: this.logger }), this.expressionEngine = new I({ debug: t3.debug, logger: this.logger }), !t3.userApiAdapter) throw new Error("userApiAdapter is required. Inject a UserApiAdapter implementation (e.g. from @djvlc/runtime-web or your host).");
|
|
3227
|
+
this.userApiAdapter = t3.userApiAdapter, this.pageLoader = new d({ apiBaseUrl: t3.apiBaseUrl, userApiAdapter: this.userApiAdapter, channel: t3.channel, previewToken: t3.previewToken, headers: t3.headers, logger: this.logger }), this.componentLoader = new f({ cdnBaseUrl: t3.cdnBaseUrl, enableSRI: t3.enableSRI, headers: t3.headers, logger: this.logger }), this.assetLoader = new m({ cdnHosts: [new URL(t3.cdnBaseUrl).host], apiHosts: [new URL(t3.apiBaseUrl).host] }), this.securityManager = new N({ enableSRI: t3.enableSRI, cdnDomains: [new URL(t3.cdnBaseUrl).host], apiDomains: [new URL(t3.apiBaseUrl).host], logger: this.logger }), this.log("info", "Runtime created", { version: O });
|
|
3245
3228
|
}
|
|
3246
3229
|
async init() {
|
|
3247
3230
|
this.log("info", "Initializing runtime");
|
|
3248
3231
|
const t3 = performance.now();
|
|
3249
3232
|
try {
|
|
3250
|
-
this.container = this.resolveContainer(), this.assetLoader.preconnectAll(), this.pageLoader.preconnect(),
|
|
3233
|
+
this.container = this.resolveContainer(), this.assetLoader.preconnectAll(), this.pageLoader.preconnect(), T(), this.stateManager.setPhase("resolving");
|
|
3251
3234
|
const e = performance.now() - t3;
|
|
3252
3235
|
this.log("info", `Runtime initialized in ${e.toFixed(2)}ms`);
|
|
3253
3236
|
} catch (t4) {
|
|
@@ -3261,7 +3244,7 @@ var P = class {
|
|
|
3261
3244
|
try {
|
|
3262
3245
|
this.stateManager.setPhase("resolving");
|
|
3263
3246
|
const e = await this.pageLoader.resolve(this.options.pageId, { uid: this.options.userId, deviceId: this.options.deviceId });
|
|
3264
|
-
if (this.validateSchemaVersion(e.pageJson), this.stateManager.setPage(e), this.telemetryManager = new
|
|
3247
|
+
if (this.validateSchemaVersion(e.pageJson), this.stateManager.setPage(e), this.telemetryManager = new C({ pageVersionId: e.pageVersionId, appId: this.options.appId, debug: this.options.debug, logger: this.logger, onMetric: this.options.onMetric }), e.runtimeConfig) {
|
|
3265
3248
|
const t4 = ((_a = e.runtimeConfig.blockedComponents) == null ? void 0 : _a.map((t5) => `${t5.name}@${t5.version}`)) || [];
|
|
3266
3249
|
this.securityManager.updateBlockedList(t4, []), this.componentLoader.updateBlockedList(t4);
|
|
3267
3250
|
}
|
|
@@ -3319,7 +3302,7 @@ var P = class {
|
|
|
3319
3302
|
this.log("info", "Destroying runtime"), await ((_a = this.lifecycleManager) == null ? void 0 : _a.destroy()), (_b = this.telemetryManager) == null ? void 0 : _b.flush(), (_c = this.dataBindingManager) == null ? void 0 : _c.destroy(), (_d = this.actionBridge) == null ? void 0 : _d.destroy(), (_e = this.renderer) == null ? void 0 : _e.destroy(), this.eventBus.clear(), this.stateManager.setDestroyed(), this.container && (this.container.innerHTML = ""), this.emitEvent("page:destroyed", {}), this.log("info", "Runtime destroyed");
|
|
3320
3303
|
}
|
|
3321
3304
|
validateSchemaVersion(t3) {
|
|
3322
|
-
if (t3.schemaVersion !==
|
|
3305
|
+
if (t3.schemaVersion !== L) throw new n(`Unsupported schema version: ${t3.schemaVersion}. Only ${L} is supported.`, { schemaVersion: t3.schemaVersion, supportedVersion: L });
|
|
3323
3306
|
}
|
|
3324
3307
|
resolveContainer() {
|
|
3325
3308
|
const { container: t3 } = this.options;
|
|
@@ -3331,10 +3314,10 @@ var P = class {
|
|
|
3331
3314
|
return t3;
|
|
3332
3315
|
}
|
|
3333
3316
|
initHostApi(t3) {
|
|
3334
|
-
this.hostApi = new
|
|
3317
|
+
this.hostApi = new A({ userApiAdapter: this.userApiAdapter, stateManager: this.stateManager, eventBus: this.eventBus, expressionEngine: this.expressionEngine, context: { pageId: t3.pageId, pageVersionId: t3.pageVersionId, runtimeVersion: O, userId: this.options.userId, deviceId: this.options.deviceId, channel: this.options.channel, appId: this.options.appId || "", env: this.options.env || "production", isEditMode: false, isPreviewMode: t3.isPreview || false }, debug: this.options.debug, logger: this.logger });
|
|
3335
3318
|
}
|
|
3336
3319
|
initActionBridge() {
|
|
3337
|
-
this.actionBridge = new
|
|
3320
|
+
this.actionBridge = new v({ executor: { executeAction: (t3, e) => this.hostApi.executeAction(t3, e), requestData: (t3, e) => this.hostApi.requestData(t3, e), navigate: (t3) => this.hostApi.navigate(t3), openDialog: (t3) => this.hostApi.openDialog(t3), closeDialog: () => this.hostApi.closeDialog(), showToast: (t3) => this.hostApi.showToast(t3), showLoading: (t3) => this.hostApi.showLoading(t3), hideLoading: () => this.hostApi.hideLoading(), track: (t3) => this.hostApi.track(t3), setState: (t3, e) => this.stateManager.setVariable(t3, e), getState: (t3) => this.stateManager.getVariable(t3), refreshData: (t3) => this.refreshData(t3) }, expressionEngine: this.expressionEngine, debug: this.options.debug, logger: this.logger, onActionStart: (t3, e) => {
|
|
3338
3321
|
this.emitEvent("action:executing", { action: t3, params: e });
|
|
3339
3322
|
}, onActionComplete: (t3, e) => {
|
|
3340
3323
|
var _a;
|
|
@@ -3342,7 +3325,7 @@ var P = class {
|
|
|
3342
3325
|
} });
|
|
3343
3326
|
}
|
|
3344
3327
|
initDataBindingManager(t3) {
|
|
3345
|
-
this.dataBindingManager = new
|
|
3328
|
+
this.dataBindingManager = new y({ requester: { requestData: (t4, e) => this.hostApi.requestData(t4, e) }, stateSetter: { setVariable: (t4, e) => this.stateManager.setVariable(t4, e), getVariable: (t4) => this.stateManager.getVariable(t4) }, expressionEngine: this.expressionEngine, debug: this.options.debug, logger: this.logger, onDataLoaded: (t4, e) => {
|
|
3346
3329
|
var _a;
|
|
3347
3330
|
this.emitEvent("query:fetched", { bindingId: t4, data: e }), (_a = this.renderer) == null ? void 0 : _a.updateContext(this.stateManager.getExpressionContext());
|
|
3348
3331
|
}, onDataError: (t4, e) => {
|
|
@@ -3352,7 +3335,7 @@ var P = class {
|
|
|
3352
3335
|
});
|
|
3353
3336
|
}
|
|
3354
3337
|
initLifecycleManager(t3) {
|
|
3355
|
-
this.lifecycleManager = new
|
|
3338
|
+
this.lifecycleManager = new M({ actionBridge: this.actionBridge, getContext: () => this.stateManager.getExpressionContext(), debug: this.options.debug, logger: this.logger, onLifecycleEvent: (t4, e) => {
|
|
3356
3339
|
this.emitEvent(`page:lifecycle:${t4}`, e ?? {});
|
|
3357
3340
|
} }), this.lifecycleManager.register(t3.lifecycle);
|
|
3358
3341
|
}
|
|
@@ -3363,11 +3346,11 @@ var P = class {
|
|
|
3363
3346
|
const [i2, n2] = s.split("@");
|
|
3364
3347
|
t3.set(i2, { name: i2, version: n2, Component: e.component, loadTime: e.loadTime || 0 });
|
|
3365
3348
|
}
|
|
3366
|
-
}), this.renderer = new
|
|
3349
|
+
}), this.renderer = new D({ expressionEngine: this.expressionEngine, components: t3, injectHostApi: (t4, e) => {
|
|
3367
3350
|
t4.hostApi = this.hostApi, t4.componentId = e;
|
|
3368
3351
|
}, onComponentEvent: (t4, e, s, i2) => {
|
|
3369
3352
|
this.handleComponentEvent(t4, e, s, i2);
|
|
3370
|
-
}, debug: this.options.debug, logger: this.logger, onRenderError: (t4, e) => (this.log("error", `Render error in ${t4}:`, e), this.emitEvent("component:error", { componentId: t4, error: e.message }),
|
|
3353
|
+
}, debug: this.options.debug, logger: this.logger, onRenderError: (t4, e) => (this.log("error", `Render error in ${t4}:`, e), this.emitEvent("component:error", { componentId: t4, error: e.message }), R("error", e.message)) }), this.renderer.init();
|
|
3371
3354
|
}
|
|
3372
3355
|
handleComponentEvent(t3, e, s, i2) {
|
|
3373
3356
|
this.log("debug", `Component event: ${t3}.${e}`, i2);
|
|
@@ -3380,7 +3363,7 @@ var P = class {
|
|
|
3380
3363
|
}
|
|
3381
3364
|
emitEvent(t3, e) {
|
|
3382
3365
|
var _a;
|
|
3383
|
-
const s =
|
|
3366
|
+
const s = b.createEvent(t3, e, (_a = this.telemetryManager) == null ? void 0 : _a.getTraceId());
|
|
3384
3367
|
this.eventBus.emit(s), this.options.onEvent && this.options.onEvent(s);
|
|
3385
3368
|
}
|
|
3386
3369
|
createLogger() {
|
|
@@ -3395,202 +3378,2459 @@ var P = class {
|
|
|
3395
3378
|
this.logger[t3](e, ...s);
|
|
3396
3379
|
}
|
|
3397
3380
|
};
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3381
|
+
var BaseClientError = class extends Error {
|
|
3382
|
+
constructor(message) {
|
|
3383
|
+
super(message);
|
|
3384
|
+
this.name = this.constructor.name;
|
|
3385
|
+
this.timestamp = /* @__PURE__ */ new Date();
|
|
3386
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
3387
|
+
if (Error.captureStackTrace) {
|
|
3388
|
+
Error.captureStackTrace(this, this.constructor);
|
|
3405
3389
|
}
|
|
3406
|
-
const lcpObserver = new PerformanceObserver((list) => {
|
|
3407
|
-
const entries = list.getEntries();
|
|
3408
|
-
const lastEntry = entries[entries.length - 1];
|
|
3409
|
-
if (lastEntry) {
|
|
3410
|
-
metrics.lcp = lastEntry.startTime;
|
|
3411
|
-
}
|
|
3412
|
-
});
|
|
3413
|
-
lcpObserver.observe({ type: "largest-contentful-paint", buffered: true });
|
|
3414
|
-
const fidObserver = new PerformanceObserver((list) => {
|
|
3415
|
-
const entries = list.getEntries();
|
|
3416
|
-
if (entries.length > 0) {
|
|
3417
|
-
const firstEntry = entries[0];
|
|
3418
|
-
metrics.fid = firstEntry.processingStart - firstEntry.startTime;
|
|
3419
|
-
}
|
|
3420
|
-
});
|
|
3421
|
-
fidObserver.observe({ type: "first-input", buffered: true });
|
|
3422
|
-
let clsValue = 0;
|
|
3423
|
-
const clsObserver = new PerformanceObserver((list) => {
|
|
3424
|
-
for (const entry of list.getEntries()) {
|
|
3425
|
-
const layoutShift = entry;
|
|
3426
|
-
if (!layoutShift.hadRecentInput && layoutShift.value) {
|
|
3427
|
-
clsValue += layoutShift.value;
|
|
3428
|
-
metrics.cls = clsValue;
|
|
3429
|
-
}
|
|
3430
|
-
}
|
|
3431
|
-
});
|
|
3432
|
-
clsObserver.observe({ type: "layout-shift", buffered: true });
|
|
3433
|
-
} catch {
|
|
3434
|
-
}
|
|
3435
|
-
}
|
|
3436
|
-
class PerformanceMonitor {
|
|
3437
|
-
constructor(enabled = true) {
|
|
3438
|
-
this.marks = /* @__PURE__ */ new Map();
|
|
3439
|
-
this.measures = /* @__PURE__ */ new Map();
|
|
3440
|
-
this.enabled = enabled;
|
|
3441
3390
|
}
|
|
3442
3391
|
/**
|
|
3443
|
-
*
|
|
3392
|
+
* 转换为 JSON 对象(用于日志和序列化)
|
|
3444
3393
|
*/
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3394
|
+
toJSON() {
|
|
3395
|
+
return {
|
|
3396
|
+
name: this.name,
|
|
3397
|
+
type: this.type,
|
|
3398
|
+
message: this.message,
|
|
3399
|
+
retryable: this.retryable,
|
|
3400
|
+
timestamp: this.timestamp.toISOString(),
|
|
3401
|
+
stack: this.stack
|
|
3402
|
+
};
|
|
3451
3403
|
}
|
|
3452
3404
|
/**
|
|
3453
|
-
*
|
|
3405
|
+
* 转换为字符串
|
|
3454
3406
|
*/
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3407
|
+
toString() {
|
|
3408
|
+
return `${this.name}: ${this.message}`;
|
|
3409
|
+
}
|
|
3410
|
+
};
|
|
3411
|
+
var NetworkError = class _NetworkError extends BaseClientError {
|
|
3412
|
+
constructor(message, cause) {
|
|
3413
|
+
super(message);
|
|
3414
|
+
this.type = "NETWORK_ERROR";
|
|
3415
|
+
this.retryable = true;
|
|
3416
|
+
this.cause = cause;
|
|
3417
|
+
}
|
|
3418
|
+
toJSON() {
|
|
3419
|
+
return {
|
|
3420
|
+
...super.toJSON(),
|
|
3421
|
+
cause: this.cause ? {
|
|
3422
|
+
name: this.cause.name,
|
|
3423
|
+
message: this.cause.message
|
|
3424
|
+
} : void 0
|
|
3425
|
+
};
|
|
3473
3426
|
}
|
|
3474
3427
|
/**
|
|
3475
|
-
*
|
|
3428
|
+
* 类型守卫:判断是否为 NetworkError
|
|
3476
3429
|
*/
|
|
3477
|
-
|
|
3478
|
-
return
|
|
3430
|
+
static is(error) {
|
|
3431
|
+
return error instanceof _NetworkError;
|
|
3479
3432
|
}
|
|
3480
3433
|
/**
|
|
3481
|
-
*
|
|
3434
|
+
* 从原生 fetch 错误创建 NetworkError
|
|
3482
3435
|
*/
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3436
|
+
static fromFetchError(error) {
|
|
3437
|
+
const message = error.message.toLowerCase();
|
|
3438
|
+
if (message.includes("network") || message.includes("failed to fetch")) {
|
|
3439
|
+
return new _NetworkError("Network request failed", error);
|
|
3440
|
+
}
|
|
3441
|
+
if (message.includes("dns") || message.includes("getaddrinfo")) {
|
|
3442
|
+
return new _NetworkError("DNS resolution failed", error);
|
|
3443
|
+
}
|
|
3444
|
+
if (message.includes("connection refused") || message.includes("econnrefused")) {
|
|
3445
|
+
return new _NetworkError("Connection refused", error);
|
|
3446
|
+
}
|
|
3447
|
+
if (message.includes("connection reset") || message.includes("econnreset")) {
|
|
3448
|
+
return new _NetworkError("Connection reset", error);
|
|
3449
|
+
}
|
|
3450
|
+
if (message.includes("ssl") || message.includes("certificate")) {
|
|
3451
|
+
return new _NetworkError("SSL/TLS error", error);
|
|
3452
|
+
}
|
|
3453
|
+
return new _NetworkError(error.message || "Unknown network error", error);
|
|
3486
3454
|
}
|
|
3487
|
-
}
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
}
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
)
|
|
3496
|
-
if (navigation) {
|
|
3455
|
+
};
|
|
3456
|
+
var TimeoutError = class _TimeoutError extends BaseClientError {
|
|
3457
|
+
constructor(timeoutMs) {
|
|
3458
|
+
super(`Request timeout after ${timeoutMs}ms`);
|
|
3459
|
+
this.type = "TIMEOUT_ERROR";
|
|
3460
|
+
this.retryable = true;
|
|
3461
|
+
this.timeoutMs = timeoutMs;
|
|
3462
|
+
}
|
|
3463
|
+
toJSON() {
|
|
3497
3464
|
return {
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
ssl: navigation.secureConnectionStart > 0 ? navigation.connectEnd - navigation.secureConnectionStart : 0,
|
|
3501
|
-
ttfb: navigation.responseStart - navigation.requestStart,
|
|
3502
|
-
download: navigation.responseEnd - navigation.responseStart,
|
|
3503
|
-
domParse: navigation.domInteractive - navigation.responseEnd,
|
|
3504
|
-
domContentLoaded: navigation.domContentLoadedEventEnd - navigation.domContentLoadedEventStart,
|
|
3505
|
-
load: navigation.loadEventEnd - navigation.loadEventStart,
|
|
3506
|
-
total: navigation.loadEventEnd - navigation.startTime
|
|
3465
|
+
...super.toJSON(),
|
|
3466
|
+
timeoutMs: this.timeoutMs
|
|
3507
3467
|
};
|
|
3508
3468
|
}
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3469
|
+
/**
|
|
3470
|
+
* 类型守卫:判断是否为 TimeoutError
|
|
3471
|
+
*/
|
|
3472
|
+
static is(error) {
|
|
3473
|
+
return error instanceof _TimeoutError;
|
|
3474
|
+
}
|
|
3475
|
+
};
|
|
3476
|
+
var BearerAuthenticator = class {
|
|
3477
|
+
constructor(config) {
|
|
3478
|
+
this.type = "bearer";
|
|
3479
|
+
this.getToken = config.getToken;
|
|
3480
|
+
this.headerName = config.headerName ?? "Authorization";
|
|
3481
|
+
this.prefix = config.prefix ?? "Bearer";
|
|
3482
|
+
}
|
|
3483
|
+
async authenticate(headers) {
|
|
3484
|
+
const token = await this.getToken();
|
|
3485
|
+
if (token !== null && token !== "") {
|
|
3486
|
+
headers[this.headerName] = `${this.prefix} ${token}`;
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
};
|
|
3490
|
+
var ApiKeyAuthenticator = class {
|
|
3491
|
+
constructor(config) {
|
|
3492
|
+
this.type = "api-key";
|
|
3493
|
+
this.apiKey = config.apiKey;
|
|
3494
|
+
this.headerName = config.headerName ?? "X-API-Key";
|
|
3495
|
+
}
|
|
3496
|
+
authenticate(headers) {
|
|
3497
|
+
headers[this.headerName] = this.apiKey;
|
|
3498
|
+
}
|
|
3499
|
+
};
|
|
3500
|
+
function encodeBase64(str) {
|
|
3501
|
+
const utf8Bytes = new TextEncoder().encode(str);
|
|
3502
|
+
const binaryString = Array.from(utf8Bytes, (byte) => String.fromCharCode(byte)).join("");
|
|
3503
|
+
return typeof btoa !== "undefined" ? btoa(binaryString) : (() => {
|
|
3504
|
+
throw new Error("Base64 encoding is not supported in this environment");
|
|
3505
|
+
})();
|
|
3519
3506
|
}
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
}
|
|
3507
|
+
var BasicAuthenticator = class {
|
|
3508
|
+
constructor(config) {
|
|
3509
|
+
this.type = "basic";
|
|
3510
|
+
this.encodedCredentials = encodeBase64(`${config.username}:${config.password}`);
|
|
3511
|
+
}
|
|
3512
|
+
authenticate(headers) {
|
|
3513
|
+
headers["Authorization"] = `Basic ${this.encodedCredentials}`;
|
|
3514
|
+
}
|
|
3515
|
+
};
|
|
3516
|
+
var CustomAuthenticator = class {
|
|
3517
|
+
constructor(config) {
|
|
3518
|
+
this.type = "custom";
|
|
3519
|
+
this.authenticateFn = config.authenticate;
|
|
3520
|
+
}
|
|
3521
|
+
async authenticate(headers) {
|
|
3522
|
+
await this.authenticateFn(headers);
|
|
3523
|
+
}
|
|
3524
|
+
};
|
|
3525
|
+
var NoAuthenticator = class {
|
|
3526
|
+
constructor() {
|
|
3527
|
+
this.type = "none";
|
|
3528
|
+
}
|
|
3529
|
+
authenticate(_headers) {
|
|
3530
|
+
}
|
|
3531
|
+
};
|
|
3532
|
+
var noAuthenticator = new NoAuthenticator();
|
|
3533
|
+
function createAuthenticatorFromConfig(config) {
|
|
3534
|
+
switch (config.type) {
|
|
3535
|
+
case "bearer":
|
|
3536
|
+
return new BearerAuthenticator({ getToken: config.getToken, headerName: config.headerName, prefix: config.prefix });
|
|
3537
|
+
case "api-key":
|
|
3538
|
+
return new ApiKeyAuthenticator({ apiKey: config.apiKey, headerName: config.headerName });
|
|
3539
|
+
case "basic":
|
|
3540
|
+
return new BasicAuthenticator({ username: config.username, password: config.password });
|
|
3541
|
+
case "custom":
|
|
3542
|
+
return new CustomAuthenticator({ authenticate: config.authenticate });
|
|
3543
|
+
case "none":
|
|
3544
|
+
return noAuthenticator;
|
|
3545
|
+
default: {
|
|
3546
|
+
const _exhaustiveCheck = config;
|
|
3547
|
+
throw new Error(`Unknown auth type: ${_exhaustiveCheck.type}`);
|
|
3548
|
+
}
|
|
3549
|
+
}
|
|
3528
3550
|
}
|
|
3529
|
-
function
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
}
|
|
3551
|
+
function generateRequestId() {
|
|
3552
|
+
const timestamp = Date.now().toString(36);
|
|
3553
|
+
const random = Math.random().toString(36).slice(2, 9);
|
|
3554
|
+
return `req_${timestamp}_${random}`;
|
|
3533
3555
|
}
|
|
3534
|
-
function
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
link.crossOrigin = "anonymous";
|
|
3540
|
-
document.head.appendChild(link);
|
|
3541
|
-
});
|
|
3556
|
+
function generateTraceId$1() {
|
|
3557
|
+
const timestamp = Date.now().toString(36);
|
|
3558
|
+
const random1 = Math.random().toString(36).slice(2, 9);
|
|
3559
|
+
const random2 = Math.random().toString(36).slice(2, 9);
|
|
3560
|
+
return `trace_${timestamp}_${random1}_${random2}`;
|
|
3542
3561
|
}
|
|
3543
|
-
function
|
|
3544
|
-
|
|
3545
|
-
`${cdnBaseUrl}/runtime/${version}/runtime.esm.js`,
|
|
3546
|
-
`${cdnBaseUrl}/runtime/${version}/runtime.css`
|
|
3547
|
-
];
|
|
3548
|
-
assets.forEach((href) => {
|
|
3549
|
-
const link = document.createElement("link");
|
|
3550
|
-
link.rel = "preload";
|
|
3551
|
-
link.href = href;
|
|
3552
|
-
link.as = href.endsWith(".js") ? "script" : "style";
|
|
3553
|
-
if (href.endsWith(".js")) {
|
|
3554
|
-
link.crossOrigin = "anonymous";
|
|
3555
|
-
}
|
|
3556
|
-
document.head.appendChild(link);
|
|
3557
|
-
});
|
|
3562
|
+
function sleep(ms) {
|
|
3563
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3558
3564
|
}
|
|
3559
|
-
function
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3565
|
+
function generateUniqueRequestKey() {
|
|
3566
|
+
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
3567
|
+
}
|
|
3568
|
+
var REQUEST_KEY_HEADER = "X-Internal-Request-Key";
|
|
3569
|
+
var retryStateMap = /* @__PURE__ */ new Map();
|
|
3570
|
+
function getRequestKey(init) {
|
|
3571
|
+
const headers = init.headers;
|
|
3572
|
+
return (headers == null ? void 0 : headers[REQUEST_KEY_HEADER]) ?? "";
|
|
3573
|
+
}
|
|
3574
|
+
function createMiddlewares(config = {}) {
|
|
3575
|
+
var _a, _b, _c;
|
|
3576
|
+
const middlewares = [];
|
|
3577
|
+
middlewares.push(createRequestMiddleware(config));
|
|
3578
|
+
if (config.logger) {
|
|
3579
|
+
middlewares.push(createLoggingMiddleware(config.logger, config.debug ?? false));
|
|
3580
|
+
}
|
|
3581
|
+
if (config.enableRetry !== false && config.retry) {
|
|
3582
|
+
middlewares.push(createRetryMiddleware(config));
|
|
3583
|
+
}
|
|
3584
|
+
if ((_a = config.preMiddlewares) == null ? void 0 : _a.length) {
|
|
3585
|
+
for (const preFn of config.preMiddlewares) {
|
|
3586
|
+
middlewares.push({ pre: preFn });
|
|
3567
3587
|
}
|
|
3568
3588
|
}
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3589
|
+
if ((_b = config.postMiddlewares) == null ? void 0 : _b.length) {
|
|
3590
|
+
for (const postFn of config.postMiddlewares) {
|
|
3591
|
+
middlewares.push({ post: postFn });
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
if ((_c = config.errorMiddlewares) == null ? void 0 : _c.length) {
|
|
3595
|
+
for (const errorFn of config.errorMiddlewares) {
|
|
3596
|
+
middlewares.push({ onError: errorFn });
|
|
3597
|
+
}
|
|
3598
|
+
}
|
|
3599
|
+
return middlewares;
|
|
3574
3600
|
}
|
|
3575
|
-
function
|
|
3576
|
-
const
|
|
3577
|
-
return
|
|
3601
|
+
function createRequestMiddleware(config) {
|
|
3602
|
+
const authenticator = config.auth ? createAuthenticatorFromConfig(config.auth) : noAuthenticator;
|
|
3603
|
+
return {
|
|
3604
|
+
async pre(context) {
|
|
3605
|
+
const requestId = generateRequestId();
|
|
3606
|
+
const traceId = generateTraceId$1();
|
|
3607
|
+
const requestKey = generateUniqueRequestKey();
|
|
3608
|
+
retryStateMap.set(requestKey, {
|
|
3609
|
+
attempt: 0,
|
|
3610
|
+
startTime: Date.now(),
|
|
3611
|
+
requestId,
|
|
3612
|
+
traceId
|
|
3613
|
+
});
|
|
3614
|
+
const existingHeaders = context.init.headers ?? {};
|
|
3615
|
+
const headers = {};
|
|
3616
|
+
if (existingHeaders instanceof Headers) {
|
|
3617
|
+
existingHeaders.forEach((value, key) => {
|
|
3618
|
+
headers[key] = value;
|
|
3619
|
+
});
|
|
3620
|
+
} else if (Array.isArray(existingHeaders)) {
|
|
3621
|
+
for (const [key, value] of existingHeaders) {
|
|
3622
|
+
headers[key] = value;
|
|
3623
|
+
}
|
|
3624
|
+
} else {
|
|
3625
|
+
Object.assign(headers, existingHeaders);
|
|
3626
|
+
}
|
|
3627
|
+
headers[REQUEST_KEY_HEADER] = requestKey;
|
|
3628
|
+
headers["X-Request-ID"] = requestId;
|
|
3629
|
+
headers["X-Trace-ID"] = traceId;
|
|
3630
|
+
if (config.headers) {
|
|
3631
|
+
Object.assign(headers, config.headers);
|
|
3632
|
+
}
|
|
3633
|
+
await authenticator.authenticate(headers);
|
|
3634
|
+
return {
|
|
3635
|
+
url: context.url,
|
|
3636
|
+
init: {
|
|
3637
|
+
...context.init,
|
|
3638
|
+
headers
|
|
3639
|
+
}
|
|
3640
|
+
};
|
|
3641
|
+
}
|
|
3642
|
+
};
|
|
3578
3643
|
}
|
|
3579
|
-
function
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3644
|
+
function createLoggingMiddleware(logger, debugMode) {
|
|
3645
|
+
return {
|
|
3646
|
+
async pre(context) {
|
|
3647
|
+
var _a;
|
|
3648
|
+
if (!debugMode) return void 0;
|
|
3649
|
+
const method = context.init.method ?? "GET";
|
|
3650
|
+
const requestId = ((_a = context.init.headers) == null ? void 0 : _a["X-Request-ID"]) ?? "";
|
|
3651
|
+
logger.debug(`[Request] ${method} ${context.url}`, { requestId });
|
|
3652
|
+
return void 0;
|
|
3653
|
+
},
|
|
3654
|
+
async post(context) {
|
|
3655
|
+
var _a;
|
|
3656
|
+
const requestKey = getRequestKey(context.init);
|
|
3657
|
+
const state = retryStateMap.get(requestKey);
|
|
3658
|
+
const duration = state ? Date.now() - state.startTime : 0;
|
|
3659
|
+
if (requestKey) {
|
|
3660
|
+
retryStateMap.delete(requestKey);
|
|
3661
|
+
}
|
|
3662
|
+
if (!debugMode) return void 0;
|
|
3663
|
+
const method = context.init.method ?? "GET";
|
|
3664
|
+
const requestId = ((_a = context.init.headers) == null ? void 0 : _a["X-Request-ID"]) ?? "";
|
|
3665
|
+
logger.debug(`[Response] ${method} ${context.url} - ${context.response.status} (${duration}ms)`, {
|
|
3666
|
+
requestId,
|
|
3667
|
+
status: context.response.status,
|
|
3668
|
+
duration
|
|
3669
|
+
});
|
|
3670
|
+
return void 0;
|
|
3671
|
+
},
|
|
3672
|
+
async onError(context) {
|
|
3673
|
+
var _a;
|
|
3674
|
+
const method = context.init.method ?? "GET";
|
|
3675
|
+
const requestId = ((_a = context.init.headers) == null ? void 0 : _a["X-Request-ID"]) ?? "";
|
|
3676
|
+
const requestKey = getRequestKey(context.init);
|
|
3677
|
+
const state = retryStateMap.get(requestKey);
|
|
3678
|
+
const duration = state ? Date.now() - state.startTime : 0;
|
|
3679
|
+
const errorMessage = context.error instanceof Error ? context.error.message : String(context.error);
|
|
3680
|
+
logger.error(`[Error] ${method} ${context.url} - ${errorMessage} (${duration}ms)`, {
|
|
3681
|
+
requestId,
|
|
3682
|
+
error: errorMessage,
|
|
3683
|
+
duration
|
|
3684
|
+
});
|
|
3685
|
+
return void 0;
|
|
3686
|
+
}
|
|
3687
|
+
};
|
|
3583
3688
|
}
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3689
|
+
function createRetryMiddleware(config) {
|
|
3690
|
+
const retryConfig = config.retry;
|
|
3691
|
+
const maxRetries = retryConfig.maxRetries;
|
|
3692
|
+
const logger = config.logger;
|
|
3693
|
+
const debug = config.debug ?? false;
|
|
3694
|
+
return {
|
|
3695
|
+
async onError(context) {
|
|
3696
|
+
const requestKey = getRequestKey(context.init);
|
|
3697
|
+
const state = retryStateMap.get(requestKey);
|
|
3698
|
+
if (!state) {
|
|
3699
|
+
return void 0;
|
|
3700
|
+
}
|
|
3701
|
+
if (!shouldRetry(context.error, state.attempt, maxRetries, retryConfig)) {
|
|
3702
|
+
retryStateMap.delete(requestKey);
|
|
3703
|
+
return void 0;
|
|
3704
|
+
}
|
|
3705
|
+
state.attempt++;
|
|
3706
|
+
const delay = calculateRetryDelay2(state.attempt, retryConfig);
|
|
3707
|
+
if (retryConfig.onRetry) {
|
|
3708
|
+
const method = context.init.method ?? "GET";
|
|
3709
|
+
retryConfig.onRetry({
|
|
3710
|
+
attempt: state.attempt,
|
|
3711
|
+
maxRetries,
|
|
3712
|
+
delayMs: delay,
|
|
3713
|
+
error: context.error instanceof Error ? context.error : new Error(String(context.error)),
|
|
3714
|
+
url: context.url,
|
|
3715
|
+
method
|
|
3716
|
+
});
|
|
3717
|
+
}
|
|
3718
|
+
if (debug && logger) {
|
|
3719
|
+
const method = context.init.method ?? "GET";
|
|
3720
|
+
logger.debug(`[Retry] ${method} ${context.url} - attempt ${state.attempt}/${maxRetries}, delay ${delay}ms`);
|
|
3721
|
+
}
|
|
3722
|
+
await sleep(delay);
|
|
3723
|
+
try {
|
|
3724
|
+
const response = await context.fetch(context.url, context.init);
|
|
3725
|
+
if (!response.ok && shouldRetryStatus(response.status, state.attempt, maxRetries, retryConfig)) {
|
|
3726
|
+
state.attempt++;
|
|
3727
|
+
const nextDelay = calculateRetryDelay2(state.attempt, retryConfig);
|
|
3728
|
+
if (debug && logger) {
|
|
3729
|
+
const method = context.init.method ?? "GET";
|
|
3730
|
+
logger.debug(`[Retry] ${method} ${context.url} - status ${response.status}, attempt ${state.attempt}/${maxRetries}, delay ${nextDelay}ms`);
|
|
3731
|
+
}
|
|
3732
|
+
await sleep(nextDelay);
|
|
3733
|
+
return context.fetch(context.url, context.init);
|
|
3734
|
+
}
|
|
3735
|
+
retryStateMap.delete(requestKey);
|
|
3736
|
+
return response;
|
|
3737
|
+
} catch (retryError) {
|
|
3738
|
+
if (state.attempt < maxRetries) {
|
|
3739
|
+
throw retryError;
|
|
3740
|
+
}
|
|
3741
|
+
retryStateMap.delete(requestKey);
|
|
3742
|
+
throw retryError;
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
};
|
|
3746
|
+
}
|
|
3747
|
+
function shouldRetry(error, attempt, maxRetries, retryConfig) {
|
|
3748
|
+
if (attempt >= maxRetries) return false;
|
|
3749
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
3750
|
+
return false;
|
|
3751
|
+
}
|
|
3752
|
+
if (error instanceof TypeError || error instanceof NetworkError) {
|
|
3753
|
+
return retryConfig.retryOnNetworkError !== false;
|
|
3754
|
+
}
|
|
3755
|
+
if (error instanceof TimeoutError) {
|
|
3756
|
+
return retryConfig.retryOnTimeout !== false;
|
|
3757
|
+
}
|
|
3758
|
+
return true;
|
|
3759
|
+
}
|
|
3760
|
+
function shouldRetryStatus(status, attempt, maxRetries, retryConfig) {
|
|
3761
|
+
if (attempt >= maxRetries) return false;
|
|
3762
|
+
const retryableCodes = retryConfig.retryableStatusCodes ?? [429, 500, 502, 503, 504];
|
|
3763
|
+
return retryableCodes.includes(status);
|
|
3764
|
+
}
|
|
3765
|
+
function calculateRetryDelay2(attempt, retryConfig) {
|
|
3766
|
+
const {
|
|
3767
|
+
initialDelayMs = 1e3,
|
|
3768
|
+
maxDelayMs = 3e4,
|
|
3769
|
+
backoffStrategy = "exponential",
|
|
3770
|
+
jitterFactor = 0.1
|
|
3771
|
+
} = retryConfig;
|
|
3772
|
+
let delay;
|
|
3773
|
+
switch (backoffStrategy) {
|
|
3774
|
+
case "fixed":
|
|
3775
|
+
delay = initialDelayMs;
|
|
3776
|
+
break;
|
|
3777
|
+
case "linear":
|
|
3778
|
+
delay = initialDelayMs * attempt;
|
|
3779
|
+
break;
|
|
3780
|
+
case "exponential":
|
|
3781
|
+
default:
|
|
3782
|
+
delay = initialDelayMs * Math.pow(2, attempt - 1);
|
|
3783
|
+
break;
|
|
3784
|
+
}
|
|
3785
|
+
delay = Math.min(delay, maxDelayMs);
|
|
3786
|
+
if (jitterFactor > 0) {
|
|
3787
|
+
const jitter = delay * jitterFactor * (Math.random() * 2 - 1);
|
|
3788
|
+
delay = Math.max(0, delay + jitter);
|
|
3789
|
+
}
|
|
3790
|
+
return Math.round(delay);
|
|
3791
|
+
}
|
|
3792
|
+
var BASE_PATH = "/api/user".replace(/\/+$/, "");
|
|
3793
|
+
var Configuration = class {
|
|
3794
|
+
constructor(configuration = {}) {
|
|
3795
|
+
this.configuration = configuration;
|
|
3796
|
+
}
|
|
3797
|
+
set config(configuration) {
|
|
3798
|
+
this.configuration = configuration;
|
|
3799
|
+
}
|
|
3800
|
+
get basePath() {
|
|
3801
|
+
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
|
|
3802
|
+
}
|
|
3803
|
+
get fetchApi() {
|
|
3804
|
+
return this.configuration.fetchApi;
|
|
3805
|
+
}
|
|
3806
|
+
get middleware() {
|
|
3807
|
+
return this.configuration.middleware || [];
|
|
3808
|
+
}
|
|
3809
|
+
get queryParamsStringify() {
|
|
3810
|
+
return this.configuration.queryParamsStringify || querystring;
|
|
3811
|
+
}
|
|
3812
|
+
get username() {
|
|
3813
|
+
return this.configuration.username;
|
|
3814
|
+
}
|
|
3815
|
+
get password() {
|
|
3816
|
+
return this.configuration.password;
|
|
3817
|
+
}
|
|
3818
|
+
get apiKey() {
|
|
3819
|
+
const apiKey = this.configuration.apiKey;
|
|
3820
|
+
if (apiKey) {
|
|
3821
|
+
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
3822
|
+
}
|
|
3823
|
+
return void 0;
|
|
3824
|
+
}
|
|
3825
|
+
get accessToken() {
|
|
3826
|
+
const accessToken = this.configuration.accessToken;
|
|
3827
|
+
if (accessToken) {
|
|
3828
|
+
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
3829
|
+
}
|
|
3830
|
+
return void 0;
|
|
3831
|
+
}
|
|
3832
|
+
get headers() {
|
|
3833
|
+
return this.configuration.headers;
|
|
3834
|
+
}
|
|
3835
|
+
get credentials() {
|
|
3836
|
+
return this.configuration.credentials;
|
|
3837
|
+
}
|
|
3838
|
+
};
|
|
3839
|
+
var DefaultConfig = new Configuration();
|
|
3840
|
+
var _BaseAPI = class _BaseAPI2 {
|
|
3841
|
+
constructor(configuration = DefaultConfig) {
|
|
3842
|
+
this.configuration = configuration;
|
|
3843
|
+
this.fetchApi = async (url, init) => {
|
|
3844
|
+
let fetchParams = { url, init };
|
|
3845
|
+
for (const middleware of this.middleware) {
|
|
3846
|
+
if (middleware.pre) {
|
|
3847
|
+
fetchParams = await middleware.pre({
|
|
3848
|
+
fetch: this.fetchApi,
|
|
3849
|
+
...fetchParams
|
|
3850
|
+
}) || fetchParams;
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
let response = void 0;
|
|
3854
|
+
try {
|
|
3855
|
+
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
3856
|
+
} catch (e) {
|
|
3857
|
+
for (const middleware of this.middleware) {
|
|
3858
|
+
if (middleware.onError) {
|
|
3859
|
+
response = await middleware.onError({
|
|
3860
|
+
fetch: this.fetchApi,
|
|
3861
|
+
url: fetchParams.url,
|
|
3862
|
+
init: fetchParams.init,
|
|
3863
|
+
error: e,
|
|
3864
|
+
response: response ? response.clone() : void 0
|
|
3865
|
+
}) || response;
|
|
3866
|
+
}
|
|
3867
|
+
}
|
|
3868
|
+
if (response === void 0) {
|
|
3869
|
+
if (e instanceof Error) {
|
|
3870
|
+
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
|
|
3871
|
+
} else {
|
|
3872
|
+
throw e;
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
for (const middleware of this.middleware) {
|
|
3877
|
+
if (middleware.post) {
|
|
3878
|
+
response = await middleware.post({
|
|
3879
|
+
fetch: this.fetchApi,
|
|
3880
|
+
url: fetchParams.url,
|
|
3881
|
+
init: fetchParams.init,
|
|
3882
|
+
response: response.clone()
|
|
3883
|
+
}) || response;
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
return response;
|
|
3887
|
+
};
|
|
3888
|
+
this.middleware = configuration.middleware;
|
|
3889
|
+
}
|
|
3890
|
+
withMiddleware(...middlewares) {
|
|
3891
|
+
const next = this.clone();
|
|
3892
|
+
next.middleware = next.middleware.concat(...middlewares);
|
|
3893
|
+
return next;
|
|
3894
|
+
}
|
|
3895
|
+
withPreMiddleware(...preMiddlewares) {
|
|
3896
|
+
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
3897
|
+
return this.withMiddleware(...middlewares);
|
|
3898
|
+
}
|
|
3899
|
+
withPostMiddleware(...postMiddlewares) {
|
|
3900
|
+
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
3901
|
+
return this.withMiddleware(...middlewares);
|
|
3902
|
+
}
|
|
3903
|
+
/**
|
|
3904
|
+
* Check if the given MIME is a JSON MIME.
|
|
3905
|
+
* JSON MIME examples:
|
|
3906
|
+
* application/json
|
|
3907
|
+
* application/json; charset=UTF8
|
|
3908
|
+
* APPLICATION/JSON
|
|
3909
|
+
* application/vnd.company+json
|
|
3910
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
3911
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
3912
|
+
*/
|
|
3913
|
+
isJsonMime(mime) {
|
|
3914
|
+
if (!mime) {
|
|
3915
|
+
return false;
|
|
3916
|
+
}
|
|
3917
|
+
return _BaseAPI2.jsonRegex.test(mime);
|
|
3918
|
+
}
|
|
3919
|
+
async request(context, initOverrides) {
|
|
3920
|
+
const { url, init } = await this.createFetchParams(context, initOverrides);
|
|
3921
|
+
const response = await this.fetchApi(url, init);
|
|
3922
|
+
if (response && (response.status >= 200 && response.status < 300)) {
|
|
3923
|
+
return response;
|
|
3924
|
+
}
|
|
3925
|
+
throw new ResponseError(response, "Response returned an error code");
|
|
3926
|
+
}
|
|
3927
|
+
async createFetchParams(context, initOverrides) {
|
|
3928
|
+
let url = this.configuration.basePath + context.path;
|
|
3929
|
+
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
|
|
3930
|
+
url += "?" + this.configuration.queryParamsStringify(context.query);
|
|
3931
|
+
}
|
|
3932
|
+
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
3933
|
+
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
|
|
3934
|
+
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
|
|
3935
|
+
const initParams = {
|
|
3936
|
+
method: context.method,
|
|
3937
|
+
headers,
|
|
3938
|
+
body: context.body,
|
|
3939
|
+
credentials: this.configuration.credentials
|
|
3940
|
+
};
|
|
3941
|
+
const overriddenInit = {
|
|
3942
|
+
...initParams,
|
|
3943
|
+
...await initOverrideFn({
|
|
3944
|
+
init: initParams,
|
|
3945
|
+
context
|
|
3946
|
+
})
|
|
3947
|
+
};
|
|
3948
|
+
let body;
|
|
3949
|
+
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
|
|
3950
|
+
body = overriddenInit.body;
|
|
3951
|
+
} else if (this.isJsonMime(headers["Content-Type"])) {
|
|
3952
|
+
body = JSON.stringify(overriddenInit.body);
|
|
3953
|
+
} else {
|
|
3954
|
+
body = overriddenInit.body;
|
|
3955
|
+
}
|
|
3956
|
+
const init = {
|
|
3957
|
+
...overriddenInit,
|
|
3958
|
+
body
|
|
3959
|
+
};
|
|
3960
|
+
return { url, init };
|
|
3961
|
+
}
|
|
3962
|
+
/**
|
|
3963
|
+
* Create a shallow clone of `this` by constructing a new instance
|
|
3964
|
+
* and then shallow cloning data members.
|
|
3965
|
+
*/
|
|
3966
|
+
clone() {
|
|
3967
|
+
const constructor = this.constructor;
|
|
3968
|
+
const next = new constructor(this.configuration);
|
|
3969
|
+
next.middleware = this.middleware.slice();
|
|
3970
|
+
return next;
|
|
3971
|
+
}
|
|
3972
|
+
};
|
|
3973
|
+
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
|
|
3974
|
+
var BaseAPI = _BaseAPI;
|
|
3975
|
+
function isBlob(value) {
|
|
3976
|
+
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
3977
|
+
}
|
|
3978
|
+
function isFormData(value) {
|
|
3979
|
+
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
3980
|
+
}
|
|
3981
|
+
var ResponseError = class extends Error {
|
|
3982
|
+
constructor(response, msg) {
|
|
3983
|
+
super(msg);
|
|
3984
|
+
this.response = response;
|
|
3985
|
+
this.name = "ResponseError";
|
|
3986
|
+
}
|
|
3987
|
+
};
|
|
3988
|
+
var FetchError = class extends Error {
|
|
3989
|
+
constructor(cause, msg) {
|
|
3990
|
+
super(msg);
|
|
3991
|
+
this.cause = cause;
|
|
3992
|
+
this.name = "FetchError";
|
|
3993
|
+
}
|
|
3994
|
+
};
|
|
3995
|
+
var RequiredError = class extends Error {
|
|
3996
|
+
constructor(field, msg) {
|
|
3997
|
+
super(msg);
|
|
3998
|
+
this.field = field;
|
|
3999
|
+
this.name = "RequiredError";
|
|
4000
|
+
}
|
|
4001
|
+
};
|
|
4002
|
+
function exists(json, key) {
|
|
4003
|
+
const value = json[key];
|
|
4004
|
+
return value !== null && value !== void 0;
|
|
4005
|
+
}
|
|
4006
|
+
function querystring(params, prefix = "") {
|
|
4007
|
+
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
|
|
4008
|
+
}
|
|
4009
|
+
function querystringSingleKey(key, value, keyPrefix = "") {
|
|
4010
|
+
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
|
|
4011
|
+
if (value instanceof Array) {
|
|
4012
|
+
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
|
|
4013
|
+
return `${encodeURIComponent(fullKey)}=${multiValue}`;
|
|
4014
|
+
}
|
|
4015
|
+
if (value instanceof Set) {
|
|
4016
|
+
const valueAsArray = Array.from(value);
|
|
4017
|
+
return querystringSingleKey(key, valueAsArray, keyPrefix);
|
|
4018
|
+
}
|
|
4019
|
+
if (value instanceof Date) {
|
|
4020
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
|
|
4021
|
+
}
|
|
4022
|
+
if (value instanceof Object) {
|
|
4023
|
+
return querystring(value, fullKey);
|
|
4024
|
+
}
|
|
4025
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
|
4026
|
+
}
|
|
4027
|
+
function mapValues(data, fn) {
|
|
4028
|
+
return Object.keys(data).reduce(
|
|
4029
|
+
(acc, key) => ({ ...acc, [key]: fn(data[key]) }),
|
|
4030
|
+
{}
|
|
4031
|
+
);
|
|
4032
|
+
}
|
|
4033
|
+
var JSONApiResponse = class {
|
|
4034
|
+
constructor(raw, transformer = (jsonValue) => jsonValue) {
|
|
4035
|
+
this.raw = raw;
|
|
4036
|
+
this.transformer = transformer;
|
|
4037
|
+
}
|
|
4038
|
+
async value() {
|
|
4039
|
+
return this.transformer(await this.raw.json());
|
|
4040
|
+
}
|
|
4041
|
+
};
|
|
4042
|
+
function ActionContextToJSON(value) {
|
|
4043
|
+
if (value === void 0) {
|
|
4044
|
+
return void 0;
|
|
4045
|
+
}
|
|
4046
|
+
if (value === null) {
|
|
4047
|
+
return null;
|
|
4048
|
+
}
|
|
4049
|
+
return {
|
|
4050
|
+
"pageVersionId": value.pageVersionId,
|
|
4051
|
+
"componentVersionId": value.componentVersionId,
|
|
4052
|
+
"componentInstanceId": value.componentInstanceId,
|
|
4053
|
+
"triggerEvent": value.triggerEvent,
|
|
4054
|
+
"deviceId": value.deviceId,
|
|
4055
|
+
"channel": value.channel,
|
|
4056
|
+
"clientTimestamp": value.clientTimestamp === void 0 ? void 0 : value.clientTimestamp.toISOString(),
|
|
4057
|
+
"extra": value.extra
|
|
4058
|
+
};
|
|
4059
|
+
}
|
|
4060
|
+
function ActionDefinitionResponseDataFromJSON(json) {
|
|
4061
|
+
return ActionDefinitionResponseDataFromJSONTyped(json);
|
|
4062
|
+
}
|
|
4063
|
+
function ActionDefinitionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
4064
|
+
if (json === void 0 || json === null) {
|
|
4065
|
+
return json;
|
|
4066
|
+
}
|
|
4067
|
+
return {
|
|
4068
|
+
"actionDefinitionVersionId": !exists(json, "actionDefinitionVersionId") ? void 0 : json["actionDefinitionVersionId"],
|
|
4069
|
+
"actionType": !exists(json, "actionType") ? void 0 : json["actionType"],
|
|
4070
|
+
"name": !exists(json, "name") ? void 0 : json["name"],
|
|
4071
|
+
"paramsSchema": !exists(json, "paramsSchema") ? void 0 : json["paramsSchema"],
|
|
4072
|
+
"resultSchema": !exists(json, "resultSchema") ? void 0 : json["resultSchema"]
|
|
4073
|
+
};
|
|
4074
|
+
}
|
|
4075
|
+
function ActionDefinitionResponseFromJSON(json) {
|
|
4076
|
+
return ActionDefinitionResponseFromJSONTyped(json);
|
|
4077
|
+
}
|
|
4078
|
+
function ActionDefinitionResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4079
|
+
if (json === void 0 || json === null) {
|
|
4080
|
+
return json;
|
|
4081
|
+
}
|
|
4082
|
+
return {
|
|
4083
|
+
"data": ActionDefinitionResponseDataFromJSON(json["data"])
|
|
4084
|
+
};
|
|
4085
|
+
}
|
|
4086
|
+
function ActionEffectFromJSON(json) {
|
|
4087
|
+
return ActionEffectFromJSONTyped(json);
|
|
4088
|
+
}
|
|
4089
|
+
function ActionEffectFromJSONTyped(json, ignoreDiscriminator) {
|
|
4090
|
+
if (json === void 0 || json === null) {
|
|
4091
|
+
return json;
|
|
4092
|
+
}
|
|
4093
|
+
return {
|
|
4094
|
+
"type": json["type"],
|
|
4095
|
+
"payload": !exists(json, "payload") ? void 0 : json["payload"]
|
|
4096
|
+
};
|
|
4097
|
+
}
|
|
4098
|
+
function BatchQueryRequestQueriesInnerToJSON(value) {
|
|
4099
|
+
if (value === void 0) {
|
|
4100
|
+
return void 0;
|
|
4101
|
+
}
|
|
4102
|
+
if (value === null) {
|
|
4103
|
+
return null;
|
|
4104
|
+
}
|
|
4105
|
+
return {
|
|
4106
|
+
"queryVersionId": value.queryVersionId,
|
|
4107
|
+
"params": value.params,
|
|
4108
|
+
"alias": value.alias
|
|
4109
|
+
};
|
|
4110
|
+
}
|
|
4111
|
+
function QueryContextToJSON(value) {
|
|
4112
|
+
if (value === void 0) {
|
|
4113
|
+
return void 0;
|
|
4114
|
+
}
|
|
4115
|
+
if (value === null) {
|
|
4116
|
+
return null;
|
|
4117
|
+
}
|
|
4118
|
+
return {
|
|
4119
|
+
"pageVersionId": value.pageVersionId,
|
|
4120
|
+
"componentVersionId": value.componentVersionId
|
|
4121
|
+
};
|
|
4122
|
+
}
|
|
4123
|
+
function BatchQueryRequestToJSON(value) {
|
|
4124
|
+
if (value === void 0) {
|
|
4125
|
+
return void 0;
|
|
4126
|
+
}
|
|
4127
|
+
if (value === null) {
|
|
4128
|
+
return null;
|
|
4129
|
+
}
|
|
4130
|
+
return {
|
|
4131
|
+
"queries": value.queries.map(BatchQueryRequestQueriesInnerToJSON),
|
|
4132
|
+
"context": QueryContextToJSON(value.context)
|
|
4133
|
+
};
|
|
4134
|
+
}
|
|
4135
|
+
function BatchQueryResponseDataValueErrorFromJSON(json) {
|
|
4136
|
+
return BatchQueryResponseDataValueErrorFromJSONTyped(json);
|
|
4137
|
+
}
|
|
4138
|
+
function BatchQueryResponseDataValueErrorFromJSONTyped(json, ignoreDiscriminator) {
|
|
4139
|
+
if (json === void 0 || json === null) {
|
|
4140
|
+
return json;
|
|
4141
|
+
}
|
|
4142
|
+
return {
|
|
4143
|
+
"code": !exists(json, "code") ? void 0 : json["code"],
|
|
4144
|
+
"message": !exists(json, "message") ? void 0 : json["message"]
|
|
4145
|
+
};
|
|
4146
|
+
}
|
|
4147
|
+
function BatchQueryResponseDataValueFromJSON(json) {
|
|
4148
|
+
return BatchQueryResponseDataValueFromJSONTyped(json);
|
|
4149
|
+
}
|
|
4150
|
+
function BatchQueryResponseDataValueFromJSONTyped(json, ignoreDiscriminator) {
|
|
4151
|
+
if (json === void 0 || json === null) {
|
|
4152
|
+
return json;
|
|
4153
|
+
}
|
|
4154
|
+
return {
|
|
4155
|
+
"success": !exists(json, "success") ? void 0 : json["success"],
|
|
4156
|
+
"data": !exists(json, "data") ? void 0 : json["data"],
|
|
4157
|
+
"error": !exists(json, "error") ? void 0 : BatchQueryResponseDataValueErrorFromJSON(json["error"])
|
|
4158
|
+
};
|
|
4159
|
+
}
|
|
4160
|
+
function BatchQueryResponseFromJSON(json) {
|
|
4161
|
+
return BatchQueryResponseFromJSONTyped(json);
|
|
4162
|
+
}
|
|
4163
|
+
function BatchQueryResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4164
|
+
if (json === void 0 || json === null) {
|
|
4165
|
+
return json;
|
|
4166
|
+
}
|
|
4167
|
+
return {
|
|
4168
|
+
"success": json["success"],
|
|
4169
|
+
"data": mapValues(json["data"], BatchQueryResponseDataValueFromJSON)
|
|
4170
|
+
};
|
|
4171
|
+
}
|
|
4172
|
+
function ClaimRecordInfoFromJSON(json) {
|
|
4173
|
+
return ClaimRecordInfoFromJSONTyped(json);
|
|
4174
|
+
}
|
|
4175
|
+
function ClaimRecordInfoFromJSONTyped(json, ignoreDiscriminator) {
|
|
4176
|
+
if (json === void 0 || json === null) {
|
|
4177
|
+
return json;
|
|
4178
|
+
}
|
|
4179
|
+
return {
|
|
4180
|
+
"id": json["id"],
|
|
4181
|
+
"activityId": !exists(json, "activityId") ? void 0 : json["activityId"],
|
|
4182
|
+
"rewardType": json["rewardType"],
|
|
4183
|
+
"rewardName": !exists(json, "rewardName") ? void 0 : json["rewardName"],
|
|
4184
|
+
"rewardValue": !exists(json, "rewardValue") ? void 0 : json["rewardValue"],
|
|
4185
|
+
"status": json["status"],
|
|
4186
|
+
"createdAt": new Date(json["createdAt"]),
|
|
4187
|
+
"claimedAt": !exists(json, "claimedAt") ? void 0 : new Date(json["claimedAt"]),
|
|
4188
|
+
"expiresAt": !exists(json, "expiresAt") ? void 0 : new Date(json["expiresAt"])
|
|
4189
|
+
};
|
|
4190
|
+
}
|
|
4191
|
+
function ExecuteActionRequestToJSON(value) {
|
|
4192
|
+
if (value === void 0) {
|
|
4193
|
+
return void 0;
|
|
4194
|
+
}
|
|
4195
|
+
if (value === null) {
|
|
4196
|
+
return null;
|
|
4197
|
+
}
|
|
4198
|
+
return {
|
|
4199
|
+
"actionType": value.actionType,
|
|
4200
|
+
"actionDefinitionVersionId": value.actionDefinitionVersionId,
|
|
4201
|
+
"params": value.params,
|
|
4202
|
+
"context": ActionContextToJSON(value.context),
|
|
4203
|
+
"idempotencyKey": value.idempotencyKey
|
|
4204
|
+
};
|
|
4205
|
+
}
|
|
4206
|
+
function ExecuteActionResponseAllOfDataFromJSON(json) {
|
|
4207
|
+
return ExecuteActionResponseAllOfDataFromJSONTyped(json);
|
|
4208
|
+
}
|
|
4209
|
+
function ExecuteActionResponseAllOfDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
4210
|
+
if (json === void 0 || json === null) {
|
|
4211
|
+
return json;
|
|
4212
|
+
}
|
|
4213
|
+
return {
|
|
4214
|
+
"actionId": !exists(json, "actionId") ? void 0 : json["actionId"],
|
|
4215
|
+
"result": !exists(json, "result") ? void 0 : json["result"],
|
|
4216
|
+
"effects": !exists(json, "effects") ? void 0 : json["effects"].map(ActionEffectFromJSON),
|
|
4217
|
+
"errorCode": !exists(json, "errorCode") ? void 0 : json["errorCode"],
|
|
4218
|
+
"errorMessage": !exists(json, "errorMessage") ? void 0 : json["errorMessage"],
|
|
4219
|
+
"errorDetails": !exists(json, "errorDetails") ? void 0 : json["errorDetails"],
|
|
4220
|
+
"requestId": !exists(json, "requestId") ? void 0 : json["requestId"],
|
|
4221
|
+
"traceId": !exists(json, "traceId") ? void 0 : json["traceId"],
|
|
4222
|
+
"duration": !exists(json, "duration") ? void 0 : json["duration"],
|
|
4223
|
+
"retryable": !exists(json, "retryable") ? void 0 : json["retryable"],
|
|
4224
|
+
"retryAfter": !exists(json, "retryAfter") ? void 0 : json["retryAfter"]
|
|
4225
|
+
};
|
|
4226
|
+
}
|
|
4227
|
+
function ExecuteActionResponseFromJSON(json) {
|
|
4228
|
+
return ExecuteActionResponseFromJSONTyped(json);
|
|
4229
|
+
}
|
|
4230
|
+
function ExecuteActionResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4231
|
+
if (json === void 0 || json === null) {
|
|
4232
|
+
return json;
|
|
4233
|
+
}
|
|
4234
|
+
return {
|
|
4235
|
+
"success": json["success"],
|
|
4236
|
+
"code": json["code"],
|
|
4237
|
+
"message": json["message"],
|
|
4238
|
+
"data": ExecuteActionResponseAllOfDataFromJSON(json["data"]),
|
|
4239
|
+
"timestamp": json["timestamp"],
|
|
4240
|
+
"path": json["path"],
|
|
4241
|
+
"requestId": !exists(json, "requestId") ? void 0 : json["requestId"]
|
|
4242
|
+
};
|
|
4243
|
+
}
|
|
4244
|
+
function PublicActivityInfoRewardsInnerFromJSON(json) {
|
|
4245
|
+
return PublicActivityInfoRewardsInnerFromJSONTyped(json);
|
|
4246
|
+
}
|
|
4247
|
+
function PublicActivityInfoRewardsInnerFromJSONTyped(json, ignoreDiscriminator) {
|
|
4248
|
+
if (json === void 0 || json === null) {
|
|
4249
|
+
return json;
|
|
4250
|
+
}
|
|
4251
|
+
return {
|
|
4252
|
+
"name": !exists(json, "name") ? void 0 : json["name"],
|
|
4253
|
+
"description": !exists(json, "description") ? void 0 : json["description"],
|
|
4254
|
+
"icon": !exists(json, "icon") ? void 0 : json["icon"]
|
|
4255
|
+
};
|
|
4256
|
+
}
|
|
4257
|
+
function PublicActivityInfoFromJSON(json) {
|
|
4258
|
+
return PublicActivityInfoFromJSONTyped(json);
|
|
4259
|
+
}
|
|
4260
|
+
function PublicActivityInfoFromJSONTyped(json, ignoreDiscriminator) {
|
|
4261
|
+
if (json === void 0 || json === null) {
|
|
4262
|
+
return json;
|
|
4263
|
+
}
|
|
4264
|
+
return {
|
|
4265
|
+
"id": json["id"],
|
|
4266
|
+
"name": json["name"],
|
|
4267
|
+
"type": json["type"],
|
|
4268
|
+
"status": json["status"],
|
|
4269
|
+
"description": !exists(json, "description") ? void 0 : json["description"],
|
|
4270
|
+
"startTime": !exists(json, "startTime") ? void 0 : new Date(json["startTime"]),
|
|
4271
|
+
"endTime": !exists(json, "endTime") ? void 0 : new Date(json["endTime"]),
|
|
4272
|
+
"rules": !exists(json, "rules") ? void 0 : json["rules"],
|
|
4273
|
+
"rewards": !exists(json, "rewards") ? void 0 : json["rewards"].map(PublicActivityInfoRewardsInnerFromJSON)
|
|
4274
|
+
};
|
|
4275
|
+
}
|
|
4276
|
+
function GetActivityInfo200ResponseFromJSON(json) {
|
|
4277
|
+
return GetActivityInfo200ResponseFromJSONTyped(json);
|
|
4278
|
+
}
|
|
4279
|
+
function GetActivityInfo200ResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4280
|
+
if (json === void 0 || json === null) {
|
|
4281
|
+
return json;
|
|
4282
|
+
}
|
|
4283
|
+
return {
|
|
4284
|
+
"success": !exists(json, "success") ? void 0 : json["success"],
|
|
4285
|
+
"data": !exists(json, "data") ? void 0 : PublicActivityInfoFromJSON(json["data"])
|
|
4286
|
+
};
|
|
4287
|
+
}
|
|
4288
|
+
function UserActivityStateTypeStateOneOfAvailablePrizesInnerFromJSON(json) {
|
|
4289
|
+
return UserActivityStateTypeStateOneOfAvailablePrizesInnerFromJSONTyped(json);
|
|
4290
|
+
}
|
|
4291
|
+
function UserActivityStateTypeStateOneOfAvailablePrizesInnerFromJSONTyped(json, ignoreDiscriminator) {
|
|
4292
|
+
if (json === void 0 || json === null) {
|
|
4293
|
+
return json;
|
|
4294
|
+
}
|
|
4295
|
+
return {
|
|
4296
|
+
"prizeId": !exists(json, "prizeId") ? void 0 : json["prizeId"],
|
|
4297
|
+
"name": !exists(json, "name") ? void 0 : json["name"],
|
|
4298
|
+
"stock": !exists(json, "stock") ? void 0 : json["stock"]
|
|
4299
|
+
};
|
|
4300
|
+
}
|
|
4301
|
+
function UserActivityStateTypeStateOneOfFromJSONTyped(json, ignoreDiscriminator) {
|
|
4302
|
+
if (json === void 0 || json === null) {
|
|
4303
|
+
return json;
|
|
4304
|
+
}
|
|
4305
|
+
return {
|
|
4306
|
+
"type": json["type"],
|
|
4307
|
+
"claimed": json["claimed"],
|
|
4308
|
+
"claimedAt": !exists(json, "claimedAt") ? void 0 : new Date(json["claimedAt"]),
|
|
4309
|
+
"claimedPrizeId": !exists(json, "claimedPrizeId") ? void 0 : json["claimedPrizeId"],
|
|
4310
|
+
"availablePrizes": !exists(json, "availablePrizes") ? void 0 : json["availablePrizes"].map(UserActivityStateTypeStateOneOfAvailablePrizesInnerFromJSON)
|
|
4311
|
+
};
|
|
4312
|
+
}
|
|
4313
|
+
function UserActivityStateTypeStateOneOf1CycleRecordsInnerFromJSON(json) {
|
|
4314
|
+
return UserActivityStateTypeStateOneOf1CycleRecordsInnerFromJSONTyped(json);
|
|
4315
|
+
}
|
|
4316
|
+
function UserActivityStateTypeStateOneOf1CycleRecordsInnerFromJSONTyped(json, ignoreDiscriminator) {
|
|
4317
|
+
if (json === void 0 || json === null) {
|
|
4318
|
+
return json;
|
|
4319
|
+
}
|
|
4320
|
+
return {
|
|
4321
|
+
"dayKey": !exists(json, "dayKey") ? void 0 : json["dayKey"],
|
|
4322
|
+
"signed": !exists(json, "signed") ? void 0 : json["signed"],
|
|
4323
|
+
"isMakeup": !exists(json, "isMakeup") ? void 0 : json["isMakeup"]
|
|
4324
|
+
};
|
|
4325
|
+
}
|
|
4326
|
+
function UserActivityStateTypeStateOneOf1NextRewardFromJSON(json) {
|
|
4327
|
+
return UserActivityStateTypeStateOneOf1NextRewardFromJSONTyped(json);
|
|
4328
|
+
}
|
|
4329
|
+
function UserActivityStateTypeStateOneOf1NextRewardFromJSONTyped(json, ignoreDiscriminator) {
|
|
4330
|
+
if (json === void 0 || json === null) {
|
|
4331
|
+
return json;
|
|
4332
|
+
}
|
|
4333
|
+
return {
|
|
4334
|
+
"type": !exists(json, "type") ? void 0 : json["type"],
|
|
4335
|
+
"daysNeeded": !exists(json, "daysNeeded") ? void 0 : json["daysNeeded"],
|
|
4336
|
+
"reward": !exists(json, "reward") ? void 0 : json["reward"]
|
|
4337
|
+
};
|
|
4338
|
+
}
|
|
4339
|
+
function UserActivityStateTypeStateOneOf1FromJSONTyped(json, ignoreDiscriminator) {
|
|
4340
|
+
if (json === void 0 || json === null) {
|
|
4341
|
+
return json;
|
|
4342
|
+
}
|
|
4343
|
+
return {
|
|
4344
|
+
"type": json["type"],
|
|
4345
|
+
"signedToday": json["signedToday"],
|
|
4346
|
+
"todaySignedAt": !exists(json, "todaySignedAt") ? void 0 : new Date(json["todaySignedAt"]),
|
|
4347
|
+
"consecutiveDays": json["consecutiveDays"],
|
|
4348
|
+
"totalDays": json["totalDays"],
|
|
4349
|
+
"cycleRecords": json["cycleRecords"].map(UserActivityStateTypeStateOneOf1CycleRecordsInnerFromJSON),
|
|
4350
|
+
"makeupAvailable": json["makeupAvailable"],
|
|
4351
|
+
"nextReward": !exists(json, "nextReward") ? void 0 : UserActivityStateTypeStateOneOf1NextRewardFromJSON(json["nextReward"])
|
|
4352
|
+
};
|
|
4353
|
+
}
|
|
4354
|
+
function UserActivityStateTypeStateOneOf2PityProgressFromJSON(json) {
|
|
4355
|
+
return UserActivityStateTypeStateOneOf2PityProgressFromJSONTyped(json);
|
|
4356
|
+
}
|
|
4357
|
+
function UserActivityStateTypeStateOneOf2PityProgressFromJSONTyped(json, ignoreDiscriminator) {
|
|
4358
|
+
if (json === void 0 || json === null) {
|
|
4359
|
+
return json;
|
|
4360
|
+
}
|
|
4361
|
+
return {
|
|
4362
|
+
"current": !exists(json, "current") ? void 0 : json["current"],
|
|
4363
|
+
"target": !exists(json, "target") ? void 0 : json["target"]
|
|
4364
|
+
};
|
|
4365
|
+
}
|
|
4366
|
+
function UserActivityStateTypeStateOneOf2ResourcesInnerFromJSON(json) {
|
|
4367
|
+
return UserActivityStateTypeStateOneOf2ResourcesInnerFromJSONTyped(json);
|
|
4368
|
+
}
|
|
4369
|
+
function UserActivityStateTypeStateOneOf2ResourcesInnerFromJSONTyped(json, ignoreDiscriminator) {
|
|
4370
|
+
if (json === void 0 || json === null) {
|
|
4371
|
+
return json;
|
|
4372
|
+
}
|
|
4373
|
+
return {
|
|
4374
|
+
"type": !exists(json, "type") ? void 0 : json["type"],
|
|
4375
|
+
"amount": !exists(json, "amount") ? void 0 : json["amount"]
|
|
4376
|
+
};
|
|
4377
|
+
}
|
|
4378
|
+
function UserActivityStateTypeStateOneOf2FromJSONTyped(json, ignoreDiscriminator) {
|
|
4379
|
+
if (json === void 0 || json === null) {
|
|
4380
|
+
return json;
|
|
4381
|
+
}
|
|
4382
|
+
return {
|
|
4383
|
+
"type": json["type"],
|
|
4384
|
+
"freeDrawsRemaining": json["freeDrawsRemaining"],
|
|
4385
|
+
"todayDrawCount": json["todayDrawCount"],
|
|
4386
|
+
"totalDrawCount": json["totalDrawCount"],
|
|
4387
|
+
"pityProgress": !exists(json, "pityProgress") ? void 0 : UserActivityStateTypeStateOneOf2PityProgressFromJSON(json["pityProgress"]),
|
|
4388
|
+
"resources": !exists(json, "resources") ? void 0 : json["resources"].map(UserActivityStateTypeStateOneOf2ResourcesInnerFromJSON)
|
|
4389
|
+
};
|
|
4390
|
+
}
|
|
4391
|
+
function UserActivityStateTypeStateFromJSON(json) {
|
|
4392
|
+
return UserActivityStateTypeStateFromJSONTyped(json);
|
|
4393
|
+
}
|
|
4394
|
+
function UserActivityStateTypeStateFromJSONTyped(json, ignoreDiscriminator) {
|
|
4395
|
+
if (json === void 0 || json === null) {
|
|
4396
|
+
return json;
|
|
4397
|
+
}
|
|
4398
|
+
return { ...UserActivityStateTypeStateOneOfFromJSONTyped(json), ...UserActivityStateTypeStateOneOf1FromJSONTyped(json), ...UserActivityStateTypeStateOneOf2FromJSONTyped(json) };
|
|
4399
|
+
}
|
|
4400
|
+
function UserActivityStateFromJSON(json) {
|
|
4401
|
+
return UserActivityStateFromJSONTyped(json);
|
|
4402
|
+
}
|
|
4403
|
+
function UserActivityStateFromJSONTyped(json, ignoreDiscriminator) {
|
|
4404
|
+
if (json === void 0 || json === null) {
|
|
4405
|
+
return json;
|
|
4406
|
+
}
|
|
4407
|
+
return {
|
|
4408
|
+
"activityId": json["activityId"],
|
|
4409
|
+
"userId": json["userId"],
|
|
4410
|
+
"activityType": json["activityType"],
|
|
4411
|
+
"canParticipate": json["canParticipate"],
|
|
4412
|
+
"notParticipateReason": !exists(json, "notParticipateReason") ? void 0 : json["notParticipateReason"],
|
|
4413
|
+
"remainingCount": !exists(json, "remainingCount") ? void 0 : json["remainingCount"],
|
|
4414
|
+
"typeState": UserActivityStateTypeStateFromJSON(json["typeState"])
|
|
4415
|
+
};
|
|
4416
|
+
}
|
|
4417
|
+
function GetActivityState200ResponseFromJSON(json) {
|
|
4418
|
+
return GetActivityState200ResponseFromJSONTyped(json);
|
|
4419
|
+
}
|
|
4420
|
+
function GetActivityState200ResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4421
|
+
if (json === void 0 || json === null) {
|
|
4422
|
+
return json;
|
|
4423
|
+
}
|
|
4424
|
+
return {
|
|
4425
|
+
"success": !exists(json, "success") ? void 0 : json["success"],
|
|
4426
|
+
"data": !exists(json, "data") ? void 0 : UserActivityStateFromJSON(json["data"])
|
|
4427
|
+
};
|
|
4428
|
+
}
|
|
4429
|
+
function PaginationMetaFromJSON(json) {
|
|
4430
|
+
return PaginationMetaFromJSONTyped(json);
|
|
4431
|
+
}
|
|
4432
|
+
function PaginationMetaFromJSONTyped(json, ignoreDiscriminator) {
|
|
4433
|
+
if (json === void 0 || json === null) {
|
|
4434
|
+
return json;
|
|
4435
|
+
}
|
|
4436
|
+
return {
|
|
4437
|
+
"page": json["page"],
|
|
4438
|
+
"limit": json["limit"],
|
|
4439
|
+
"total": json["total"],
|
|
4440
|
+
"totalPages": json["totalPages"]
|
|
4441
|
+
};
|
|
4442
|
+
}
|
|
4443
|
+
function GetClaimRecords200ResponseFromJSON(json) {
|
|
4444
|
+
return GetClaimRecords200ResponseFromJSONTyped(json);
|
|
4445
|
+
}
|
|
4446
|
+
function GetClaimRecords200ResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4447
|
+
if (json === void 0 || json === null) {
|
|
4448
|
+
return json;
|
|
4449
|
+
}
|
|
4450
|
+
return {
|
|
4451
|
+
"success": !exists(json, "success") ? void 0 : json["success"],
|
|
4452
|
+
"data": !exists(json, "data") ? void 0 : json["data"].map(ClaimRecordInfoFromJSON),
|
|
4453
|
+
"meta": !exists(json, "meta") ? void 0 : PaginationMetaFromJSON(json["meta"])
|
|
4454
|
+
};
|
|
4455
|
+
}
|
|
4456
|
+
function LotteryRecordInfoFromJSON(json) {
|
|
4457
|
+
return LotteryRecordInfoFromJSONTyped(json);
|
|
4458
|
+
}
|
|
4459
|
+
function LotteryRecordInfoFromJSONTyped(json, ignoreDiscriminator) {
|
|
4460
|
+
if (json === void 0 || json === null) {
|
|
4461
|
+
return json;
|
|
4462
|
+
}
|
|
4463
|
+
return {
|
|
4464
|
+
"id": json["id"],
|
|
4465
|
+
"activityId": !exists(json, "activityId") ? void 0 : json["activityId"],
|
|
4466
|
+
"prizeId": json["prizeId"],
|
|
4467
|
+
"prizeName": !exists(json, "prizeName") ? void 0 : json["prizeName"],
|
|
4468
|
+
"prizeType": !exists(json, "prizeType") ? void 0 : json["prizeType"],
|
|
4469
|
+
"status": json["status"],
|
|
4470
|
+
"createdAt": new Date(json["createdAt"]),
|
|
4471
|
+
"claimedAt": !exists(json, "claimedAt") ? void 0 : new Date(json["claimedAt"])
|
|
4472
|
+
};
|
|
4473
|
+
}
|
|
4474
|
+
function GetLotteryRecords200ResponseFromJSON(json) {
|
|
4475
|
+
return GetLotteryRecords200ResponseFromJSONTyped(json);
|
|
4476
|
+
}
|
|
4477
|
+
function GetLotteryRecords200ResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4478
|
+
if (json === void 0 || json === null) {
|
|
4479
|
+
return json;
|
|
4480
|
+
}
|
|
4481
|
+
return {
|
|
4482
|
+
"success": !exists(json, "success") ? void 0 : json["success"],
|
|
4483
|
+
"data": !exists(json, "data") ? void 0 : json["data"].map(LotteryRecordInfoFromJSON),
|
|
4484
|
+
"meta": !exists(json, "meta") ? void 0 : PaginationMetaFromJSON(json["meta"])
|
|
4485
|
+
};
|
|
4486
|
+
}
|
|
4487
|
+
function SigninCalendarRecordsInnerRewardFromJSON(json) {
|
|
4488
|
+
return SigninCalendarRecordsInnerRewardFromJSONTyped(json);
|
|
4489
|
+
}
|
|
4490
|
+
function SigninCalendarRecordsInnerRewardFromJSONTyped(json, ignoreDiscriminator) {
|
|
4491
|
+
if (json === void 0 || json === null) {
|
|
4492
|
+
return json;
|
|
4493
|
+
}
|
|
4494
|
+
return {
|
|
4495
|
+
"name": !exists(json, "name") ? void 0 : json["name"],
|
|
4496
|
+
"amount": !exists(json, "amount") ? void 0 : json["amount"]
|
|
4497
|
+
};
|
|
4498
|
+
}
|
|
4499
|
+
function SigninCalendarRecordsInnerFromJSON(json) {
|
|
4500
|
+
return SigninCalendarRecordsInnerFromJSONTyped(json);
|
|
4501
|
+
}
|
|
4502
|
+
function SigninCalendarRecordsInnerFromJSONTyped(json, ignoreDiscriminator) {
|
|
4503
|
+
if (json === void 0 || json === null) {
|
|
4504
|
+
return json;
|
|
4505
|
+
}
|
|
4506
|
+
return {
|
|
4507
|
+
"day": !exists(json, "day") ? void 0 : json["day"],
|
|
4508
|
+
"signedIn": !exists(json, "signedIn") ? void 0 : json["signedIn"],
|
|
4509
|
+
"reward": !exists(json, "reward") ? void 0 : SigninCalendarRecordsInnerRewardFromJSON(json["reward"])
|
|
4510
|
+
};
|
|
4511
|
+
}
|
|
4512
|
+
function SigninCalendarFromJSON(json) {
|
|
4513
|
+
return SigninCalendarFromJSONTyped(json);
|
|
4514
|
+
}
|
|
4515
|
+
function SigninCalendarFromJSONTyped(json, ignoreDiscriminator) {
|
|
4516
|
+
if (json === void 0 || json === null) {
|
|
4517
|
+
return json;
|
|
4518
|
+
}
|
|
4519
|
+
return {
|
|
4520
|
+
"year": json["year"],
|
|
4521
|
+
"month": json["month"],
|
|
4522
|
+
"records": json["records"].map(SigninCalendarRecordsInnerFromJSON),
|
|
4523
|
+
"consecutiveDays": !exists(json, "consecutiveDays") ? void 0 : json["consecutiveDays"],
|
|
4524
|
+
"totalDays": !exists(json, "totalDays") ? void 0 : json["totalDays"]
|
|
4525
|
+
};
|
|
4526
|
+
}
|
|
4527
|
+
function GetSigninCalendar200ResponseFromJSON(json) {
|
|
4528
|
+
return GetSigninCalendar200ResponseFromJSONTyped(json);
|
|
4529
|
+
}
|
|
4530
|
+
function GetSigninCalendar200ResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4531
|
+
if (json === void 0 || json === null) {
|
|
4532
|
+
return json;
|
|
4533
|
+
}
|
|
4534
|
+
return {
|
|
4535
|
+
"success": !exists(json, "success") ? void 0 : json["success"],
|
|
4536
|
+
"data": !exists(json, "data") ? void 0 : SigninCalendarFromJSON(json["data"])
|
|
4537
|
+
};
|
|
4538
|
+
}
|
|
4539
|
+
function OpsConfigBlockedComponentsInnerFromJSON(json) {
|
|
4540
|
+
return OpsConfigBlockedComponentsInnerFromJSONTyped(json);
|
|
4541
|
+
}
|
|
4542
|
+
function OpsConfigBlockedComponentsInnerFromJSONTyped(json, ignoreDiscriminator) {
|
|
4543
|
+
if (json === void 0 || json === null) {
|
|
4544
|
+
return json;
|
|
4545
|
+
}
|
|
4546
|
+
return {
|
|
4547
|
+
"componentName": !exists(json, "componentName") ? void 0 : json["componentName"],
|
|
4548
|
+
"componentVersion": !exists(json, "componentVersion") ? void 0 : json["componentVersion"],
|
|
4549
|
+
"reason": !exists(json, "reason") ? void 0 : json["reason"]
|
|
4550
|
+
};
|
|
4551
|
+
}
|
|
4552
|
+
function OpsConfigFromJSON(json) {
|
|
4553
|
+
return OpsConfigFromJSONTyped(json);
|
|
4554
|
+
}
|
|
4555
|
+
function OpsConfigFromJSONTyped(json, ignoreDiscriminator) {
|
|
4556
|
+
if (json === void 0 || json === null) {
|
|
4557
|
+
return json;
|
|
4558
|
+
}
|
|
4559
|
+
return {
|
|
4560
|
+
"killSwitch": json["killSwitch"],
|
|
4561
|
+
"blockedComponents": json["blockedComponents"].map(OpsConfigBlockedComponentsInnerFromJSON),
|
|
4562
|
+
"flags": json["flags"]
|
|
4563
|
+
};
|
|
4564
|
+
}
|
|
4565
|
+
function QueryDataRequestCacheControlToJSON(value) {
|
|
4566
|
+
if (value === void 0) {
|
|
4567
|
+
return void 0;
|
|
4568
|
+
}
|
|
4569
|
+
if (value === null) {
|
|
4570
|
+
return null;
|
|
4571
|
+
}
|
|
4572
|
+
return {
|
|
4573
|
+
"noCache": value.noCache,
|
|
4574
|
+
"forceRefresh": value.forceRefresh
|
|
4575
|
+
};
|
|
4576
|
+
}
|
|
4577
|
+
function QueryDataRequestToJSON(value) {
|
|
4578
|
+
if (value === void 0) {
|
|
4579
|
+
return void 0;
|
|
4580
|
+
}
|
|
4581
|
+
if (value === null) {
|
|
4582
|
+
return null;
|
|
4583
|
+
}
|
|
4584
|
+
return {
|
|
4585
|
+
"queryVersionId": value.queryVersionId,
|
|
4586
|
+
"params": value.params,
|
|
4587
|
+
"cacheControl": QueryDataRequestCacheControlToJSON(value.cacheControl),
|
|
4588
|
+
"context": QueryContextToJSON(value.context)
|
|
4589
|
+
};
|
|
4590
|
+
}
|
|
4591
|
+
function QueryDataResponseFromJSON(json) {
|
|
4592
|
+
return QueryDataResponseFromJSONTyped(json);
|
|
4593
|
+
}
|
|
4594
|
+
function QueryDataResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4595
|
+
if (json === void 0 || json === null) {
|
|
4596
|
+
return json;
|
|
4597
|
+
}
|
|
4598
|
+
return {
|
|
4599
|
+
"success": json["success"],
|
|
4600
|
+
"code": json["code"],
|
|
4601
|
+
"message": json["message"],
|
|
4602
|
+
"data": json["data"],
|
|
4603
|
+
"timestamp": json["timestamp"],
|
|
4604
|
+
"path": json["path"],
|
|
4605
|
+
"requestId": !exists(json, "requestId") ? void 0 : json["requestId"],
|
|
4606
|
+
"errorCode": !exists(json, "errorCode") ? void 0 : json["errorCode"],
|
|
4607
|
+
"errorMessage": !exists(json, "errorMessage") ? void 0 : json["errorMessage"],
|
|
4608
|
+
"fromCache": !exists(json, "fromCache") ? void 0 : json["fromCache"],
|
|
4609
|
+
"cachedAt": !exists(json, "cachedAt") ? void 0 : new Date(json["cachedAt"]),
|
|
4610
|
+
"age": !exists(json, "age") ? void 0 : json["age"],
|
|
4611
|
+
"traceId": !exists(json, "traceId") ? void 0 : json["traceId"],
|
|
4612
|
+
"duration": !exists(json, "duration") ? void 0 : json["duration"],
|
|
4613
|
+
"degraded": !exists(json, "degraded") ? void 0 : json["degraded"],
|
|
4614
|
+
"degradedReason": !exists(json, "degradedReason") ? void 0 : json["degradedReason"]
|
|
4615
|
+
};
|
|
4616
|
+
}
|
|
4617
|
+
function QueryDefinitionResponseDataFromJSON(json) {
|
|
4618
|
+
return QueryDefinitionResponseDataFromJSONTyped(json);
|
|
4619
|
+
}
|
|
4620
|
+
function QueryDefinitionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
4621
|
+
if (json === void 0 || json === null) {
|
|
4622
|
+
return json;
|
|
4623
|
+
}
|
|
4624
|
+
return {
|
|
4625
|
+
"queryVersionId": !exists(json, "queryVersionId") ? void 0 : json["queryVersionId"],
|
|
4626
|
+
"name": !exists(json, "name") ? void 0 : json["name"],
|
|
4627
|
+
"paramsSchema": !exists(json, "paramsSchema") ? void 0 : json["paramsSchema"],
|
|
4628
|
+
"resultSchema": !exists(json, "resultSchema") ? void 0 : json["resultSchema"],
|
|
4629
|
+
"cacheTtl": !exists(json, "cacheTtl") ? void 0 : json["cacheTtl"]
|
|
4630
|
+
};
|
|
4631
|
+
}
|
|
4632
|
+
function QueryDefinitionResponseFromJSON(json) {
|
|
4633
|
+
return QueryDefinitionResponseFromJSONTyped(json);
|
|
4634
|
+
}
|
|
4635
|
+
function QueryDefinitionResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4636
|
+
if (json === void 0 || json === null) {
|
|
4637
|
+
return json;
|
|
4638
|
+
}
|
|
4639
|
+
return {
|
|
4640
|
+
"data": QueryDefinitionResponseDataFromJSON(json["data"])
|
|
4641
|
+
};
|
|
4642
|
+
}
|
|
4643
|
+
function ResolvePageResponseAllOfDataRolloutMatchFromJSON(json) {
|
|
4644
|
+
return ResolvePageResponseAllOfDataRolloutMatchFromJSONTyped(json);
|
|
4645
|
+
}
|
|
4646
|
+
function ResolvePageResponseAllOfDataRolloutMatchFromJSONTyped(json, ignoreDiscriminator) {
|
|
4647
|
+
if (json === void 0 || json === null) {
|
|
4648
|
+
return json;
|
|
4649
|
+
}
|
|
4650
|
+
return {
|
|
4651
|
+
"strategyId": !exists(json, "strategyId") ? void 0 : json["strategyId"],
|
|
4652
|
+
"strategyName": !exists(json, "strategyName") ? void 0 : json["strategyName"],
|
|
4653
|
+
"isDefault": !exists(json, "isDefault") ? void 0 : json["isDefault"]
|
|
4654
|
+
};
|
|
4655
|
+
}
|
|
4656
|
+
function ResolvePageResponseAllOfDataSnapshotDefinitionsDigestActionsFromJSON(json) {
|
|
4657
|
+
return ResolvePageResponseAllOfDataSnapshotDefinitionsDigestActionsFromJSONTyped(json);
|
|
4658
|
+
}
|
|
4659
|
+
function ResolvePageResponseAllOfDataSnapshotDefinitionsDigestActionsFromJSONTyped(json, ignoreDiscriminator) {
|
|
4660
|
+
if (json === void 0 || json === null) {
|
|
4661
|
+
return json;
|
|
4662
|
+
}
|
|
4663
|
+
return {
|
|
4664
|
+
"id": !exists(json, "id") ? void 0 : json["id"],
|
|
4665
|
+
"name": !exists(json, "name") ? void 0 : json["name"],
|
|
4666
|
+
"versionId": !exists(json, "versionId") ? void 0 : json["versionId"],
|
|
4667
|
+
"hash": !exists(json, "hash") ? void 0 : json["hash"]
|
|
4668
|
+
};
|
|
4669
|
+
}
|
|
4670
|
+
function ResolvePageResponseAllOfDataSnapshotDefinitionsDigestFromJSON(json) {
|
|
4671
|
+
return ResolvePageResponseAllOfDataSnapshotDefinitionsDigestFromJSONTyped(json);
|
|
4672
|
+
}
|
|
4673
|
+
function ResolvePageResponseAllOfDataSnapshotDefinitionsDigestFromJSONTyped(json, ignoreDiscriminator) {
|
|
4674
|
+
if (json === void 0 || json === null) {
|
|
4675
|
+
return json;
|
|
4676
|
+
}
|
|
4677
|
+
return {
|
|
4678
|
+
"actions": !exists(json, "actions") ? void 0 : json["actions"].map(ResolvePageResponseAllOfDataSnapshotDefinitionsDigestActionsFromJSON),
|
|
4679
|
+
"queries": !exists(json, "queries") ? void 0 : json["queries"].map(ResolvePageResponseAllOfDataSnapshotDefinitionsDigestActionsFromJSON)
|
|
4680
|
+
};
|
|
4681
|
+
}
|
|
4682
|
+
function ResolvePageResponseAllOfDataSnapshotManifestEntrypointsFromJSON(json) {
|
|
4683
|
+
return ResolvePageResponseAllOfDataSnapshotManifestEntrypointsFromJSONTyped(json);
|
|
4684
|
+
}
|
|
4685
|
+
function ResolvePageResponseAllOfDataSnapshotManifestEntrypointsFromJSONTyped(json, ignoreDiscriminator) {
|
|
4686
|
+
if (json === void 0 || json === null) {
|
|
4687
|
+
return json;
|
|
4688
|
+
}
|
|
4689
|
+
return {
|
|
4690
|
+
"js": !exists(json, "js") ? void 0 : json["js"],
|
|
4691
|
+
"css": !exists(json, "css") ? void 0 : json["css"],
|
|
4692
|
+
"chunks": !exists(json, "chunks") ? void 0 : json["chunks"]
|
|
4693
|
+
};
|
|
4694
|
+
}
|
|
4695
|
+
function ResolvePageResponseAllOfDataSnapshotManifestComponentsFromJSON(json) {
|
|
4696
|
+
return ResolvePageResponseAllOfDataSnapshotManifestComponentsFromJSONTyped(json);
|
|
4697
|
+
}
|
|
4698
|
+
function ResolvePageResponseAllOfDataSnapshotManifestComponentsFromJSONTyped(json, ignoreDiscriminator) {
|
|
4699
|
+
if (json === void 0 || json === null) {
|
|
4700
|
+
return json;
|
|
4701
|
+
}
|
|
4702
|
+
return {
|
|
4703
|
+
"name": !exists(json, "name") ? void 0 : json["name"],
|
|
4704
|
+
"version": !exists(json, "version") ? void 0 : json["version"],
|
|
4705
|
+
"integrity": !exists(json, "integrity") ? void 0 : json["integrity"],
|
|
4706
|
+
"assetsUrl": !exists(json, "assetsUrl") ? void 0 : json["assetsUrl"],
|
|
4707
|
+
"entrypoints": !exists(json, "entrypoints") ? void 0 : ResolvePageResponseAllOfDataSnapshotManifestEntrypointsFromJSON(json["entrypoints"])
|
|
4708
|
+
};
|
|
4709
|
+
}
|
|
4710
|
+
function ResolvePageResponseAllOfDataSnapshotManifestRuntimeFromJSON(json) {
|
|
4711
|
+
return ResolvePageResponseAllOfDataSnapshotManifestRuntimeFromJSONTyped(json);
|
|
4712
|
+
}
|
|
4713
|
+
function ResolvePageResponseAllOfDataSnapshotManifestRuntimeFromJSONTyped(json, ignoreDiscriminator) {
|
|
4714
|
+
if (json === void 0 || json === null) {
|
|
4715
|
+
return json;
|
|
4716
|
+
}
|
|
4717
|
+
return {
|
|
4718
|
+
"version": !exists(json, "version") ? void 0 : json["version"],
|
|
4719
|
+
"minVersion": !exists(json, "minVersion") ? void 0 : json["minVersion"]
|
|
4720
|
+
};
|
|
4721
|
+
}
|
|
4722
|
+
function ResolvePageResponseAllOfDataSnapshotManifestFromJSON(json) {
|
|
4723
|
+
return ResolvePageResponseAllOfDataSnapshotManifestFromJSONTyped(json);
|
|
4724
|
+
}
|
|
4725
|
+
function ResolvePageResponseAllOfDataSnapshotManifestFromJSONTyped(json, ignoreDiscriminator) {
|
|
4726
|
+
if (json === void 0 || json === null) {
|
|
4727
|
+
return json;
|
|
4728
|
+
}
|
|
4729
|
+
return {
|
|
4730
|
+
"components": !exists(json, "components") ? void 0 : json["components"].map(ResolvePageResponseAllOfDataSnapshotManifestComponentsFromJSON),
|
|
4731
|
+
"runtime": !exists(json, "runtime") ? void 0 : ResolvePageResponseAllOfDataSnapshotManifestRuntimeFromJSON(json["runtime"])
|
|
4732
|
+
};
|
|
4733
|
+
}
|
|
4734
|
+
function ResolvePageResponseAllOfDataSnapshotMetaBindingsFromJSON(json) {
|
|
4735
|
+
return ResolvePageResponseAllOfDataSnapshotMetaBindingsFromJSONTyped(json);
|
|
4736
|
+
}
|
|
4737
|
+
function ResolvePageResponseAllOfDataSnapshotMetaBindingsFromJSONTyped(json, ignoreDiscriminator) {
|
|
4738
|
+
if (json === void 0 || json === null) {
|
|
4739
|
+
return json;
|
|
4740
|
+
}
|
|
4741
|
+
return {
|
|
4742
|
+
"componentVersions": !exists(json, "componentVersions") ? void 0 : json["componentVersions"],
|
|
4743
|
+
"definitionVersions": !exists(json, "definitionVersions") ? void 0 : json["definitionVersions"]
|
|
4744
|
+
};
|
|
4745
|
+
}
|
|
4746
|
+
function ResolvePageResponseAllOfDataSnapshotMetaFromJSON(json) {
|
|
4747
|
+
return ResolvePageResponseAllOfDataSnapshotMetaFromJSONTyped(json);
|
|
4748
|
+
}
|
|
4749
|
+
function ResolvePageResponseAllOfDataSnapshotMetaFromJSONTyped(json, ignoreDiscriminator) {
|
|
4750
|
+
if (json === void 0 || json === null) {
|
|
4751
|
+
return json;
|
|
4752
|
+
}
|
|
4753
|
+
return {
|
|
4754
|
+
"pageId": !exists(json, "pageId") ? void 0 : json["pageId"],
|
|
4755
|
+
"pageVersionId": !exists(json, "pageVersionId") ? void 0 : json["pageVersionId"],
|
|
4756
|
+
"publishId": !exists(json, "publishId") ? void 0 : json["publishId"],
|
|
4757
|
+
"schemaVersion": !exists(json, "schemaVersion") ? void 0 : json["schemaVersion"],
|
|
4758
|
+
"createdAt": !exists(json, "createdAt") ? void 0 : new Date(json["createdAt"]),
|
|
4759
|
+
"createdBy": !exists(json, "createdBy") ? void 0 : json["createdBy"],
|
|
4760
|
+
"contentHash": !exists(json, "contentHash") ? void 0 : json["contentHash"],
|
|
4761
|
+
"bindings": !exists(json, "bindings") ? void 0 : ResolvePageResponseAllOfDataSnapshotMetaBindingsFromJSON(json["bindings"]),
|
|
4762
|
+
"runtimeVersion": !exists(json, "runtimeVersion") ? void 0 : json["runtimeVersion"],
|
|
4763
|
+
"env": !exists(json, "env") ? void 0 : json["env"]
|
|
4764
|
+
};
|
|
4765
|
+
}
|
|
4766
|
+
function ResolvePageResponseAllOfDataSnapshotPageFromJSON(json) {
|
|
4767
|
+
return ResolvePageResponseAllOfDataSnapshotPageFromJSONTyped(json);
|
|
4768
|
+
}
|
|
4769
|
+
function ResolvePageResponseAllOfDataSnapshotPageFromJSONTyped(json, ignoreDiscriminator) {
|
|
4770
|
+
if (json === void 0 || json === null) {
|
|
4771
|
+
return json;
|
|
4772
|
+
}
|
|
4773
|
+
return {
|
|
4774
|
+
"schemaVersion": !exists(json, "schemaVersion") ? void 0 : json["schemaVersion"],
|
|
4775
|
+
"pageId": !exists(json, "pageId") ? void 0 : json["pageId"],
|
|
4776
|
+
"pageVersion": !exists(json, "pageVersion") ? void 0 : json["pageVersion"],
|
|
4777
|
+
"title": !exists(json, "title") ? void 0 : json["title"],
|
|
4778
|
+
"initialState": !exists(json, "initialState") ? void 0 : json["initialState"],
|
|
4779
|
+
"bindings": !exists(json, "bindings") ? void 0 : json["bindings"],
|
|
4780
|
+
"root": !exists(json, "root") ? void 0 : json["root"],
|
|
4781
|
+
"config": !exists(json, "config") ? void 0 : json["config"]
|
|
4782
|
+
};
|
|
4783
|
+
}
|
|
4784
|
+
function ResolvePageResponseAllOfDataSnapshotFromJSON(json) {
|
|
4785
|
+
return ResolvePageResponseAllOfDataSnapshotFromJSONTyped(json);
|
|
4786
|
+
}
|
|
4787
|
+
function ResolvePageResponseAllOfDataSnapshotFromJSONTyped(json, ignoreDiscriminator) {
|
|
4788
|
+
if (json === void 0 || json === null) {
|
|
4789
|
+
return json;
|
|
4790
|
+
}
|
|
4791
|
+
return {
|
|
4792
|
+
"page": !exists(json, "page") ? void 0 : ResolvePageResponseAllOfDataSnapshotPageFromJSON(json["page"]),
|
|
4793
|
+
"manifest": !exists(json, "manifest") ? void 0 : ResolvePageResponseAllOfDataSnapshotManifestFromJSON(json["manifest"]),
|
|
4794
|
+
"definitionsDigest": !exists(json, "definitionsDigest") ? void 0 : ResolvePageResponseAllOfDataSnapshotDefinitionsDigestFromJSON(json["definitionsDigest"]),
|
|
4795
|
+
"meta": !exists(json, "meta") ? void 0 : ResolvePageResponseAllOfDataSnapshotMetaFromJSON(json["meta"])
|
|
4796
|
+
};
|
|
4797
|
+
}
|
|
4798
|
+
function ResolvePageResponseAllOfDataFromJSON(json) {
|
|
4799
|
+
return ResolvePageResponseAllOfDataFromJSONTyped(json);
|
|
4800
|
+
}
|
|
4801
|
+
function ResolvePageResponseAllOfDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
4802
|
+
if (json === void 0 || json === null) {
|
|
4803
|
+
return json;
|
|
4804
|
+
}
|
|
4805
|
+
return {
|
|
4806
|
+
"pageId": json["pageId"],
|
|
4807
|
+
"resolvedVersionId": json["resolvedVersionId"],
|
|
4808
|
+
"cdnBase": json["cdnBase"],
|
|
4809
|
+
"snapshotUrl": json["snapshotUrl"],
|
|
4810
|
+
"manifestUrl": json["manifestUrl"],
|
|
4811
|
+
"ops": OpsConfigFromJSON(json["ops"]),
|
|
4812
|
+
"etag": json["etag"],
|
|
4813
|
+
"cacheTtlSeconds": json["cacheTtlSeconds"],
|
|
4814
|
+
"rolloutMatch": !exists(json, "rolloutMatch") ? void 0 : ResolvePageResponseAllOfDataRolloutMatchFromJSON(json["rolloutMatch"]),
|
|
4815
|
+
"snapshot": !exists(json, "snapshot") ? void 0 : ResolvePageResponseAllOfDataSnapshotFromJSON(json["snapshot"])
|
|
4816
|
+
};
|
|
4817
|
+
}
|
|
4818
|
+
function ResolvePageResponseFromJSON(json) {
|
|
4819
|
+
return ResolvePageResponseFromJSONTyped(json);
|
|
4820
|
+
}
|
|
4821
|
+
function ResolvePageResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4822
|
+
if (json === void 0 || json === null) {
|
|
4823
|
+
return json;
|
|
4824
|
+
}
|
|
4825
|
+
return {
|
|
4826
|
+
"success": json["success"],
|
|
4827
|
+
"code": json["code"],
|
|
4828
|
+
"message": json["message"],
|
|
4829
|
+
"data": ResolvePageResponseAllOfDataFromJSON(json["data"]),
|
|
4830
|
+
"timestamp": json["timestamp"],
|
|
4831
|
+
"path": json["path"],
|
|
4832
|
+
"requestId": !exists(json, "requestId") ? void 0 : json["requestId"]
|
|
4833
|
+
};
|
|
4834
|
+
}
|
|
4835
|
+
function Track202ResponseDataFromJSON(json) {
|
|
4836
|
+
return Track202ResponseDataFromJSONTyped(json);
|
|
4837
|
+
}
|
|
4838
|
+
function Track202ResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
4839
|
+
if (json === void 0 || json === null) {
|
|
4840
|
+
return json;
|
|
4841
|
+
}
|
|
4842
|
+
return {
|
|
4843
|
+
"eventId": !exists(json, "eventId") ? void 0 : json["eventId"]
|
|
4844
|
+
};
|
|
4845
|
+
}
|
|
4846
|
+
function Track202ResponseFromJSON(json) {
|
|
4847
|
+
return Track202ResponseFromJSONTyped(json);
|
|
4848
|
+
}
|
|
4849
|
+
function Track202ResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4850
|
+
if (json === void 0 || json === null) {
|
|
4851
|
+
return json;
|
|
4852
|
+
}
|
|
4853
|
+
return {
|
|
4854
|
+
"success": !exists(json, "success") ? void 0 : json["success"],
|
|
4855
|
+
"data": !exists(json, "data") ? void 0 : Track202ResponseDataFromJSON(json["data"])
|
|
4856
|
+
};
|
|
4857
|
+
}
|
|
4858
|
+
function TrackBatch202ResponseDataErrorsInnerFromJSON(json) {
|
|
4859
|
+
return TrackBatch202ResponseDataErrorsInnerFromJSONTyped(json);
|
|
4860
|
+
}
|
|
4861
|
+
function TrackBatch202ResponseDataErrorsInnerFromJSONTyped(json, ignoreDiscriminator) {
|
|
4862
|
+
if (json === void 0 || json === null) {
|
|
4863
|
+
return json;
|
|
4864
|
+
}
|
|
4865
|
+
return {
|
|
4866
|
+
"index": !exists(json, "index") ? void 0 : json["index"],
|
|
4867
|
+
"reason": !exists(json, "reason") ? void 0 : json["reason"]
|
|
4868
|
+
};
|
|
4869
|
+
}
|
|
4870
|
+
function TrackBatch202ResponseDataFromJSON(json) {
|
|
4871
|
+
return TrackBatch202ResponseDataFromJSONTyped(json);
|
|
4872
|
+
}
|
|
4873
|
+
function TrackBatch202ResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
4874
|
+
if (json === void 0 || json === null) {
|
|
4875
|
+
return json;
|
|
4876
|
+
}
|
|
4877
|
+
return {
|
|
4878
|
+
"accepted": !exists(json, "accepted") ? void 0 : json["accepted"],
|
|
4879
|
+
"rejected": !exists(json, "rejected") ? void 0 : json["rejected"],
|
|
4880
|
+
"errors": !exists(json, "errors") ? void 0 : json["errors"].map(TrackBatch202ResponseDataErrorsInnerFromJSON)
|
|
4881
|
+
};
|
|
4882
|
+
}
|
|
4883
|
+
function TrackBatch202ResponseFromJSON(json) {
|
|
4884
|
+
return TrackBatch202ResponseFromJSONTyped(json);
|
|
4885
|
+
}
|
|
4886
|
+
function TrackBatch202ResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4887
|
+
if (json === void 0 || json === null) {
|
|
4888
|
+
return json;
|
|
4889
|
+
}
|
|
4890
|
+
return {
|
|
4891
|
+
"success": !exists(json, "success") ? void 0 : json["success"],
|
|
4892
|
+
"data": !exists(json, "data") ? void 0 : TrackBatch202ResponseDataFromJSON(json["data"])
|
|
4893
|
+
};
|
|
4894
|
+
}
|
|
4895
|
+
function TrackRequestContextToJSON(value) {
|
|
4896
|
+
if (value === void 0) {
|
|
4897
|
+
return void 0;
|
|
4898
|
+
}
|
|
4899
|
+
if (value === null) {
|
|
4900
|
+
return null;
|
|
4901
|
+
}
|
|
4902
|
+
return {
|
|
4903
|
+
"pageVersionId": value.pageVersionId,
|
|
4904
|
+
"componentVersionId": value.componentVersionId,
|
|
4905
|
+
"sessionId": value.sessionId,
|
|
4906
|
+
"deviceType": value.deviceType,
|
|
4907
|
+
"traceId": value.traceId
|
|
4908
|
+
};
|
|
4909
|
+
}
|
|
4910
|
+
function TrackRequestToJSON(value) {
|
|
4911
|
+
if (value === void 0) {
|
|
4912
|
+
return void 0;
|
|
4913
|
+
}
|
|
4914
|
+
if (value === null) {
|
|
4915
|
+
return null;
|
|
4916
|
+
}
|
|
4917
|
+
return {
|
|
4918
|
+
"eventName": value.eventName,
|
|
4919
|
+
"eventType": value.eventType,
|
|
4920
|
+
"properties": value.properties,
|
|
4921
|
+
"timestamp": value.timestamp === void 0 ? void 0 : value.timestamp.toISOString(),
|
|
4922
|
+
"context": TrackRequestContextToJSON(value.context)
|
|
4923
|
+
};
|
|
4924
|
+
}
|
|
4925
|
+
function TrackBatchRequestToJSON(value) {
|
|
4926
|
+
if (value === void 0) {
|
|
4927
|
+
return void 0;
|
|
4928
|
+
}
|
|
4929
|
+
if (value === null) {
|
|
4930
|
+
return null;
|
|
4931
|
+
}
|
|
4932
|
+
return {
|
|
4933
|
+
"events": value.events.map(TrackRequestToJSON)
|
|
4934
|
+
};
|
|
4935
|
+
}
|
|
4936
|
+
function ValidateActionRequestToJSON(value) {
|
|
4937
|
+
if (value === void 0) {
|
|
4938
|
+
return void 0;
|
|
4939
|
+
}
|
|
4940
|
+
if (value === null) {
|
|
4941
|
+
return null;
|
|
4942
|
+
}
|
|
4943
|
+
return {
|
|
4944
|
+
"actionType": value.actionType,
|
|
4945
|
+
"actionDefinitionVersionId": value.actionDefinitionVersionId,
|
|
4946
|
+
"params": value.params
|
|
4947
|
+
};
|
|
4948
|
+
}
|
|
4949
|
+
function ValidateActionResponseDataErrorsInnerFromJSON(json) {
|
|
4950
|
+
return ValidateActionResponseDataErrorsInnerFromJSONTyped(json);
|
|
4951
|
+
}
|
|
4952
|
+
function ValidateActionResponseDataErrorsInnerFromJSONTyped(json, ignoreDiscriminator) {
|
|
4953
|
+
if (json === void 0 || json === null) {
|
|
4954
|
+
return json;
|
|
4955
|
+
}
|
|
4956
|
+
return {
|
|
4957
|
+
"path": !exists(json, "path") ? void 0 : json["path"],
|
|
4958
|
+
"message": !exists(json, "message") ? void 0 : json["message"],
|
|
4959
|
+
"code": !exists(json, "code") ? void 0 : json["code"]
|
|
4960
|
+
};
|
|
4961
|
+
}
|
|
4962
|
+
function ValidateActionResponseDataFromJSON(json) {
|
|
4963
|
+
return ValidateActionResponseDataFromJSONTyped(json);
|
|
4964
|
+
}
|
|
4965
|
+
function ValidateActionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
4966
|
+
if (json === void 0 || json === null) {
|
|
4967
|
+
return json;
|
|
4968
|
+
}
|
|
4969
|
+
return {
|
|
4970
|
+
"valid": json["valid"],
|
|
4971
|
+
"errors": !exists(json, "errors") ? void 0 : json["errors"].map(ValidateActionResponseDataErrorsInnerFromJSON)
|
|
4972
|
+
};
|
|
4973
|
+
}
|
|
4974
|
+
function ValidateActionResponseFromJSON(json) {
|
|
4975
|
+
return ValidateActionResponseFromJSONTyped(json);
|
|
4976
|
+
}
|
|
4977
|
+
function ValidateActionResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
4978
|
+
if (json === void 0 || json === null) {
|
|
4979
|
+
return json;
|
|
4980
|
+
}
|
|
4981
|
+
return {
|
|
4982
|
+
"data": ValidateActionResponseDataFromJSON(json["data"])
|
|
4983
|
+
};
|
|
4984
|
+
}
|
|
4985
|
+
var ActionsApi = class extends BaseAPI {
|
|
4986
|
+
/**
|
|
4987
|
+
* Action Gateway 唯一入口,所有业务动作都通过此接口执行。 执行流程(Pipeline): 1. Auth(登录态/票据/签名) 2. Risk(限流、黑名单、设备指纹、验证码开关) 3. Idempotency(幂等键检查) 4. Execute(执行器:Claim/Signin/Lottery...) 5. Audit(审计落库 + outbox) 6. Normalize(统一错误码/返回) 支持的动作类型: - claim: 领取 - signin: 签到 - lottery: 抽奖 - reserve: 预约 - bind: 绑定 - task_complete: 任务完成 - vote: 投票 - share: 分享 - form_submit: 表单提交 - navigate: 页面跳转(内置) - setState: 状态更新(内置) - showToast: 提示消息(内置) - custom: 自定义动作
|
|
4988
|
+
* 执行动作(统一入口)
|
|
4989
|
+
*/
|
|
4990
|
+
async executeActionRaw(requestParameters, initOverrides) {
|
|
4991
|
+
if (requestParameters.executeActionRequest === null || requestParameters.executeActionRequest === void 0) {
|
|
4992
|
+
throw new RequiredError("executeActionRequest", "Required parameter requestParameters.executeActionRequest was null or undefined when calling executeAction.");
|
|
4993
|
+
}
|
|
4994
|
+
const queryParameters = {};
|
|
4995
|
+
const headerParameters = {};
|
|
4996
|
+
headerParameters["Content-Type"] = "application/json";
|
|
4997
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
4998
|
+
headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
|
|
4999
|
+
}
|
|
5000
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5001
|
+
const token = this.configuration.accessToken;
|
|
5002
|
+
const tokenString = await token("BearerAuth", []);
|
|
5003
|
+
if (tokenString) {
|
|
5004
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5005
|
+
}
|
|
5006
|
+
}
|
|
5007
|
+
const response = await this.request({
|
|
5008
|
+
path: `/actions/execute`,
|
|
5009
|
+
method: "POST",
|
|
5010
|
+
headers: headerParameters,
|
|
5011
|
+
query: queryParameters,
|
|
5012
|
+
body: ExecuteActionRequestToJSON(requestParameters.executeActionRequest)
|
|
5013
|
+
}, initOverrides);
|
|
5014
|
+
return new JSONApiResponse(response, (jsonValue) => ExecuteActionResponseFromJSON(jsonValue));
|
|
5015
|
+
}
|
|
5016
|
+
/**
|
|
5017
|
+
* Action Gateway 唯一入口,所有业务动作都通过此接口执行。 执行流程(Pipeline): 1. Auth(登录态/票据/签名) 2. Risk(限流、黑名单、设备指纹、验证码开关) 3. Idempotency(幂等键检查) 4. Execute(执行器:Claim/Signin/Lottery...) 5. Audit(审计落库 + outbox) 6. Normalize(统一错误码/返回) 支持的动作类型: - claim: 领取 - signin: 签到 - lottery: 抽奖 - reserve: 预约 - bind: 绑定 - task_complete: 任务完成 - vote: 投票 - share: 分享 - form_submit: 表单提交 - navigate: 页面跳转(内置) - setState: 状态更新(内置) - showToast: 提示消息(内置) - custom: 自定义动作
|
|
5018
|
+
* 执行动作(统一入口)
|
|
5019
|
+
*/
|
|
5020
|
+
async executeAction(requestParameters, initOverrides) {
|
|
5021
|
+
const response = await this.executeActionRaw(requestParameters, initOverrides);
|
|
5022
|
+
return await response.value();
|
|
5023
|
+
}
|
|
5024
|
+
/**
|
|
5025
|
+
* 获取指定动作定义版本的详细信息(用于 Runtime 渲染动作配置)
|
|
5026
|
+
* 获取动作定义
|
|
5027
|
+
*/
|
|
5028
|
+
async getActionDefinitionRaw(requestParameters, initOverrides) {
|
|
5029
|
+
if (requestParameters.actionDefinitionVersionId === null || requestParameters.actionDefinitionVersionId === void 0) {
|
|
5030
|
+
throw new RequiredError("actionDefinitionVersionId", "Required parameter requestParameters.actionDefinitionVersionId was null or undefined when calling getActionDefinition.");
|
|
5031
|
+
}
|
|
5032
|
+
const queryParameters = {};
|
|
5033
|
+
if (requestParameters.actionDefinitionVersionId !== void 0) {
|
|
5034
|
+
queryParameters["actionDefinitionVersionId"] = requestParameters.actionDefinitionVersionId;
|
|
5035
|
+
}
|
|
5036
|
+
const headerParameters = {};
|
|
5037
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
5038
|
+
headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
|
|
5039
|
+
}
|
|
5040
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5041
|
+
const token = this.configuration.accessToken;
|
|
5042
|
+
const tokenString = await token("BearerAuth", []);
|
|
5043
|
+
if (tokenString) {
|
|
5044
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
const response = await this.request({
|
|
5048
|
+
path: `/actions/definitions`,
|
|
5049
|
+
method: "GET",
|
|
5050
|
+
headers: headerParameters,
|
|
5051
|
+
query: queryParameters
|
|
5052
|
+
}, initOverrides);
|
|
5053
|
+
return new JSONApiResponse(response, (jsonValue) => ActionDefinitionResponseFromJSON(jsonValue));
|
|
5054
|
+
}
|
|
5055
|
+
/**
|
|
5056
|
+
* 获取指定动作定义版本的详细信息(用于 Runtime 渲染动作配置)
|
|
5057
|
+
* 获取动作定义
|
|
5058
|
+
*/
|
|
5059
|
+
async getActionDefinition(requestParameters, initOverrides) {
|
|
5060
|
+
const response = await this.getActionDefinitionRaw(requestParameters, initOverrides);
|
|
5061
|
+
return await response.value();
|
|
5062
|
+
}
|
|
5063
|
+
/**
|
|
5064
|
+
* 验证动作参数是否符合 Schema 定义(不执行动作)。 用于前端表单提交前的预校验。
|
|
5065
|
+
* 验证动作参数
|
|
5066
|
+
*/
|
|
5067
|
+
async validateActionParamsRaw(requestParameters, initOverrides) {
|
|
5068
|
+
if (requestParameters.validateActionRequest === null || requestParameters.validateActionRequest === void 0) {
|
|
5069
|
+
throw new RequiredError("validateActionRequest", "Required parameter requestParameters.validateActionRequest was null or undefined when calling validateActionParams.");
|
|
5070
|
+
}
|
|
5071
|
+
const queryParameters = {};
|
|
5072
|
+
const headerParameters = {};
|
|
5073
|
+
headerParameters["Content-Type"] = "application/json";
|
|
5074
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
5075
|
+
headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
|
|
5076
|
+
}
|
|
5077
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5078
|
+
const token = this.configuration.accessToken;
|
|
5079
|
+
const tokenString = await token("BearerAuth", []);
|
|
5080
|
+
if (tokenString) {
|
|
5081
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
5084
|
+
const response = await this.request({
|
|
5085
|
+
path: `/actions/validate`,
|
|
5086
|
+
method: "POST",
|
|
5087
|
+
headers: headerParameters,
|
|
5088
|
+
query: queryParameters,
|
|
5089
|
+
body: ValidateActionRequestToJSON(requestParameters.validateActionRequest)
|
|
5090
|
+
}, initOverrides);
|
|
5091
|
+
return new JSONApiResponse(response, (jsonValue) => ValidateActionResponseFromJSON(jsonValue));
|
|
5092
|
+
}
|
|
5093
|
+
/**
|
|
5094
|
+
* 验证动作参数是否符合 Schema 定义(不执行动作)。 用于前端表单提交前的预校验。
|
|
5095
|
+
* 验证动作参数
|
|
5096
|
+
*/
|
|
5097
|
+
async validateActionParams(requestParameters, initOverrides) {
|
|
5098
|
+
const response = await this.validateActionParamsRaw(requestParameters, initOverrides);
|
|
5099
|
+
return await response.value();
|
|
5100
|
+
}
|
|
5101
|
+
};
|
|
5102
|
+
var ActivitiesApi = class extends BaseAPI {
|
|
5103
|
+
/**
|
|
5104
|
+
* 获取活动的公开信息,不需要登录。 返回内容包括: - 活动基本信息 - 时间范围 - 奖品列表(脱敏)
|
|
5105
|
+
* 获取活动信息(公开)
|
|
5106
|
+
*/
|
|
5107
|
+
async getActivityInfoRaw(requestParameters, initOverrides) {
|
|
5108
|
+
if (requestParameters.activityId === null || requestParameters.activityId === void 0) {
|
|
5109
|
+
throw new RequiredError("activityId", "Required parameter requestParameters.activityId was null or undefined when calling getActivityInfo.");
|
|
5110
|
+
}
|
|
5111
|
+
const queryParameters = {};
|
|
5112
|
+
const headerParameters = {};
|
|
5113
|
+
const response = await this.request({
|
|
5114
|
+
path: `/activities/{activityId}`.replace(`{${"activityId"}}`, encodeURIComponent(String(requestParameters.activityId))),
|
|
5115
|
+
method: "GET",
|
|
5116
|
+
headers: headerParameters,
|
|
5117
|
+
query: queryParameters
|
|
5118
|
+
}, initOverrides);
|
|
5119
|
+
return new JSONApiResponse(response, (jsonValue) => GetActivityInfo200ResponseFromJSON(jsonValue));
|
|
5120
|
+
}
|
|
5121
|
+
/**
|
|
5122
|
+
* 获取活动的公开信息,不需要登录。 返回内容包括: - 活动基本信息 - 时间范围 - 奖品列表(脱敏)
|
|
5123
|
+
* 获取活动信息(公开)
|
|
5124
|
+
*/
|
|
5125
|
+
async getActivityInfo(requestParameters, initOverrides) {
|
|
5126
|
+
const response = await this.getActivityInfoRaw(requestParameters, initOverrides);
|
|
5127
|
+
return await response.value();
|
|
5128
|
+
}
|
|
5129
|
+
/**
|
|
5130
|
+
* 查询用户在指定活动中的参与状态。 返回内容包括: - 是否可参与 - 剩余次数 - 类型特定状态(领取/签到/抽奖等)
|
|
5131
|
+
* 获取用户活动状态
|
|
5132
|
+
*/
|
|
5133
|
+
async getActivityStateRaw(requestParameters, initOverrides) {
|
|
5134
|
+
if (requestParameters.activityId === null || requestParameters.activityId === void 0) {
|
|
5135
|
+
throw new RequiredError("activityId", "Required parameter requestParameters.activityId was null or undefined when calling getActivityState.");
|
|
5136
|
+
}
|
|
5137
|
+
const queryParameters = {};
|
|
5138
|
+
const headerParameters = {};
|
|
5139
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5140
|
+
const token = this.configuration.accessToken;
|
|
5141
|
+
const tokenString = await token("BearerAuth", []);
|
|
5142
|
+
if (tokenString) {
|
|
5143
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5144
|
+
}
|
|
5145
|
+
}
|
|
5146
|
+
const response = await this.request({
|
|
5147
|
+
path: `/activities/{activityId}/state`.replace(`{${"activityId"}}`, encodeURIComponent(String(requestParameters.activityId))),
|
|
5148
|
+
method: "GET",
|
|
5149
|
+
headers: headerParameters,
|
|
5150
|
+
query: queryParameters
|
|
5151
|
+
}, initOverrides);
|
|
5152
|
+
return new JSONApiResponse(response, (jsonValue) => GetActivityState200ResponseFromJSON(jsonValue));
|
|
5153
|
+
}
|
|
5154
|
+
/**
|
|
5155
|
+
* 查询用户在指定活动中的参与状态。 返回内容包括: - 是否可参与 - 剩余次数 - 类型特定状态(领取/签到/抽奖等)
|
|
5156
|
+
* 获取用户活动状态
|
|
5157
|
+
*/
|
|
5158
|
+
async getActivityState(requestParameters, initOverrides) {
|
|
5159
|
+
const response = await this.getActivityStateRaw(requestParameters, initOverrides);
|
|
5160
|
+
return await response.value();
|
|
5161
|
+
}
|
|
5162
|
+
/**
|
|
5163
|
+
* 获取用户在指定活动中的领取记录
|
|
5164
|
+
* 获取领取记录
|
|
5165
|
+
*/
|
|
5166
|
+
async getClaimRecordsRaw(requestParameters, initOverrides) {
|
|
5167
|
+
if (requestParameters.activityId === null || requestParameters.activityId === void 0) {
|
|
5168
|
+
throw new RequiredError("activityId", "Required parameter requestParameters.activityId was null or undefined when calling getClaimRecords.");
|
|
5169
|
+
}
|
|
5170
|
+
const queryParameters = {};
|
|
5171
|
+
if (requestParameters.pageSize !== void 0) {
|
|
5172
|
+
queryParameters["pageSize"] = requestParameters.pageSize;
|
|
5173
|
+
}
|
|
5174
|
+
if (requestParameters.pageToken !== void 0) {
|
|
5175
|
+
queryParameters["pageToken"] = requestParameters.pageToken;
|
|
5176
|
+
}
|
|
5177
|
+
const headerParameters = {};
|
|
5178
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5179
|
+
const token = this.configuration.accessToken;
|
|
5180
|
+
const tokenString = await token("BearerAuth", []);
|
|
5181
|
+
if (tokenString) {
|
|
5182
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5183
|
+
}
|
|
5184
|
+
}
|
|
5185
|
+
const response = await this.request({
|
|
5186
|
+
path: `/activities/{activityId}/claims`.replace(`{${"activityId"}}`, encodeURIComponent(String(requestParameters.activityId))),
|
|
5187
|
+
method: "GET",
|
|
5188
|
+
headers: headerParameters,
|
|
5189
|
+
query: queryParameters
|
|
5190
|
+
}, initOverrides);
|
|
5191
|
+
return new JSONApiResponse(response, (jsonValue) => GetClaimRecords200ResponseFromJSON(jsonValue));
|
|
5192
|
+
}
|
|
5193
|
+
/**
|
|
5194
|
+
* 获取用户在指定活动中的领取记录
|
|
5195
|
+
* 获取领取记录
|
|
5196
|
+
*/
|
|
5197
|
+
async getClaimRecords(requestParameters, initOverrides) {
|
|
5198
|
+
const response = await this.getClaimRecordsRaw(requestParameters, initOverrides);
|
|
5199
|
+
return await response.value();
|
|
5200
|
+
}
|
|
5201
|
+
/**
|
|
5202
|
+
* 获取用户在指定活动中的抽奖记录
|
|
5203
|
+
* 获取抽奖记录
|
|
5204
|
+
*/
|
|
5205
|
+
async getLotteryRecordsRaw(requestParameters, initOverrides) {
|
|
5206
|
+
if (requestParameters.activityId === null || requestParameters.activityId === void 0) {
|
|
5207
|
+
throw new RequiredError("activityId", "Required parameter requestParameters.activityId was null or undefined when calling getLotteryRecords.");
|
|
5208
|
+
}
|
|
5209
|
+
const queryParameters = {};
|
|
5210
|
+
if (requestParameters.pageSize !== void 0) {
|
|
5211
|
+
queryParameters["pageSize"] = requestParameters.pageSize;
|
|
5212
|
+
}
|
|
5213
|
+
if (requestParameters.pageToken !== void 0) {
|
|
5214
|
+
queryParameters["pageToken"] = requestParameters.pageToken;
|
|
5215
|
+
}
|
|
5216
|
+
const headerParameters = {};
|
|
5217
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5218
|
+
const token = this.configuration.accessToken;
|
|
5219
|
+
const tokenString = await token("BearerAuth", []);
|
|
5220
|
+
if (tokenString) {
|
|
5221
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
5224
|
+
const response = await this.request({
|
|
5225
|
+
path: `/activities/{activityId}/lottery`.replace(`{${"activityId"}}`, encodeURIComponent(String(requestParameters.activityId))),
|
|
5226
|
+
method: "GET",
|
|
5227
|
+
headers: headerParameters,
|
|
5228
|
+
query: queryParameters
|
|
5229
|
+
}, initOverrides);
|
|
5230
|
+
return new JSONApiResponse(response, (jsonValue) => GetLotteryRecords200ResponseFromJSON(jsonValue));
|
|
5231
|
+
}
|
|
5232
|
+
/**
|
|
5233
|
+
* 获取用户在指定活动中的抽奖记录
|
|
5234
|
+
* 获取抽奖记录
|
|
5235
|
+
*/
|
|
5236
|
+
async getLotteryRecords(requestParameters, initOverrides) {
|
|
5237
|
+
const response = await this.getLotteryRecordsRaw(requestParameters, initOverrides);
|
|
5238
|
+
return await response.value();
|
|
5239
|
+
}
|
|
5240
|
+
/**
|
|
5241
|
+
* 获取用户的签到日历数据。 返回内容包括: - 当前周期的签到记录 - 连续签到天数 - 累计签到天数 - 奖励进度
|
|
5242
|
+
* 获取签到日历
|
|
5243
|
+
*/
|
|
5244
|
+
async getSigninCalendarRaw(requestParameters, initOverrides) {
|
|
5245
|
+
if (requestParameters.activityId === null || requestParameters.activityId === void 0) {
|
|
5246
|
+
throw new RequiredError("activityId", "Required parameter requestParameters.activityId was null or undefined when calling getSigninCalendar.");
|
|
5247
|
+
}
|
|
5248
|
+
const queryParameters = {};
|
|
5249
|
+
if (requestParameters.month !== void 0) {
|
|
5250
|
+
queryParameters["month"] = requestParameters.month;
|
|
5251
|
+
}
|
|
5252
|
+
const headerParameters = {};
|
|
5253
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5254
|
+
const token = this.configuration.accessToken;
|
|
5255
|
+
const tokenString = await token("BearerAuth", []);
|
|
5256
|
+
if (tokenString) {
|
|
5257
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5258
|
+
}
|
|
5259
|
+
}
|
|
5260
|
+
const response = await this.request({
|
|
5261
|
+
path: `/activities/{activityId}/signin/calendar`.replace(`{${"activityId"}}`, encodeURIComponent(String(requestParameters.activityId))),
|
|
5262
|
+
method: "GET",
|
|
5263
|
+
headers: headerParameters,
|
|
5264
|
+
query: queryParameters
|
|
5265
|
+
}, initOverrides);
|
|
5266
|
+
return new JSONApiResponse(response, (jsonValue) => GetSigninCalendar200ResponseFromJSON(jsonValue));
|
|
5267
|
+
}
|
|
5268
|
+
/**
|
|
5269
|
+
* 获取用户的签到日历数据。 返回内容包括: - 当前周期的签到记录 - 连续签到天数 - 累计签到天数 - 奖励进度
|
|
5270
|
+
* 获取签到日历
|
|
5271
|
+
*/
|
|
5272
|
+
async getSigninCalendar(requestParameters, initOverrides) {
|
|
5273
|
+
const response = await this.getSigninCalendarRaw(requestParameters, initOverrides);
|
|
5274
|
+
return await response.value();
|
|
5275
|
+
}
|
|
5276
|
+
};
|
|
5277
|
+
var PagesApi = class extends BaseAPI {
|
|
5278
|
+
/**
|
|
5279
|
+
* Runtime 的核心接口,返回渲染所需的完整数据。 支持两种模式: 1. 稳定入口(推荐):支持灰度/回滚/ops,返回 resolvedVersionId 和 CDN 地址 2. 保底模式:当 includeSnapshot=1 时,返回完整 snapshot(CDN 失败时使用) 响应包含: - resolvedVersionId: 解析后的页面版本 ID(考虑灰度/回滚) - cdnBase: CDN 基础地址 - snapshotUrl: snapshot.json 的完整 URL - manifestUrl: manifest.json 的完整 URL - ops: 运维配置(killSwitch、blockedComponents、flags) - etag: 内容哈希(用于缓存) - cacheTtlSeconds: 缓存 TTL(建议 10~30 秒) - snapshot: 完整快照(仅当 includeSnapshot=1 时返回)
|
|
5280
|
+
* 解析页面(Runtime 核心接口)
|
|
5281
|
+
*/
|
|
5282
|
+
async resolvePageRaw(requestParameters, initOverrides) {
|
|
5283
|
+
if (requestParameters.pageId === null || requestParameters.pageId === void 0) {
|
|
5284
|
+
throw new RequiredError("pageId", "Required parameter requestParameters.pageId was null or undefined when calling resolvePage.");
|
|
5285
|
+
}
|
|
5286
|
+
const queryParameters = {};
|
|
5287
|
+
if (requestParameters.pageId !== void 0) {
|
|
5288
|
+
queryParameters["pageId"] = requestParameters.pageId;
|
|
5289
|
+
}
|
|
5290
|
+
if (requestParameters.env !== void 0) {
|
|
5291
|
+
queryParameters["env"] = requestParameters.env;
|
|
5292
|
+
}
|
|
5293
|
+
if (requestParameters.uid !== void 0) {
|
|
5294
|
+
queryParameters["uid"] = requestParameters.uid;
|
|
5295
|
+
}
|
|
5296
|
+
if (requestParameters.deviceId !== void 0) {
|
|
5297
|
+
queryParameters["deviceId"] = requestParameters.deviceId;
|
|
5298
|
+
}
|
|
5299
|
+
if (requestParameters.channel !== void 0) {
|
|
5300
|
+
queryParameters["channel"] = requestParameters.channel;
|
|
5301
|
+
}
|
|
5302
|
+
if (requestParameters.includeSnapshot !== void 0) {
|
|
5303
|
+
queryParameters["includeSnapshot"] = requestParameters.includeSnapshot;
|
|
5304
|
+
}
|
|
5305
|
+
const headerParameters = {};
|
|
5306
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
5307
|
+
headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
|
|
5308
|
+
}
|
|
5309
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5310
|
+
const token = this.configuration.accessToken;
|
|
5311
|
+
const tokenString = await token("BearerAuth", []);
|
|
5312
|
+
if (tokenString) {
|
|
5313
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5314
|
+
}
|
|
5315
|
+
}
|
|
5316
|
+
const response = await this.request({
|
|
5317
|
+
path: `/page/resolve`,
|
|
5318
|
+
method: "GET",
|
|
5319
|
+
headers: headerParameters,
|
|
5320
|
+
query: queryParameters
|
|
5321
|
+
}, initOverrides);
|
|
5322
|
+
return new JSONApiResponse(response, (jsonValue) => ResolvePageResponseFromJSON(jsonValue));
|
|
5323
|
+
}
|
|
5324
|
+
/**
|
|
5325
|
+
* Runtime 的核心接口,返回渲染所需的完整数据。 支持两种模式: 1. 稳定入口(推荐):支持灰度/回滚/ops,返回 resolvedVersionId 和 CDN 地址 2. 保底模式:当 includeSnapshot=1 时,返回完整 snapshot(CDN 失败时使用) 响应包含: - resolvedVersionId: 解析后的页面版本 ID(考虑灰度/回滚) - cdnBase: CDN 基础地址 - snapshotUrl: snapshot.json 的完整 URL - manifestUrl: manifest.json 的完整 URL - ops: 运维配置(killSwitch、blockedComponents、flags) - etag: 内容哈希(用于缓存) - cacheTtlSeconds: 缓存 TTL(建议 10~30 秒) - snapshot: 完整快照(仅当 includeSnapshot=1 时返回)
|
|
5326
|
+
* 解析页面(Runtime 核心接口)
|
|
5327
|
+
*/
|
|
5328
|
+
async resolvePage(requestParameters, initOverrides) {
|
|
5329
|
+
const response = await this.resolvePageRaw(requestParameters, initOverrides);
|
|
5330
|
+
return await response.value();
|
|
5331
|
+
}
|
|
5332
|
+
};
|
|
5333
|
+
var QueriesApi = class extends BaseAPI {
|
|
5334
|
+
/**
|
|
5335
|
+
* 批量执行多个数据查询,用于页面初始化时预取多个数据源。 所有查询并行执行,部分失败不影响其他查询返回。
|
|
5336
|
+
* 批量执行数据查询
|
|
5337
|
+
*/
|
|
5338
|
+
async batchQueryDataRaw(requestParameters, initOverrides) {
|
|
5339
|
+
if (requestParameters.batchQueryRequest === null || requestParameters.batchQueryRequest === void 0) {
|
|
5340
|
+
throw new RequiredError("batchQueryRequest", "Required parameter requestParameters.batchQueryRequest was null or undefined when calling batchQueryData.");
|
|
5341
|
+
}
|
|
5342
|
+
const queryParameters = {};
|
|
5343
|
+
const headerParameters = {};
|
|
5344
|
+
headerParameters["Content-Type"] = "application/json";
|
|
5345
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
5346
|
+
headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
|
|
5347
|
+
}
|
|
5348
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5349
|
+
const token = this.configuration.accessToken;
|
|
5350
|
+
const tokenString = await token("BearerAuth", []);
|
|
5351
|
+
if (tokenString) {
|
|
5352
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5353
|
+
}
|
|
5354
|
+
}
|
|
5355
|
+
const response = await this.request({
|
|
5356
|
+
path: `/data/query/batch`,
|
|
5357
|
+
method: "POST",
|
|
5358
|
+
headers: headerParameters,
|
|
5359
|
+
query: queryParameters,
|
|
5360
|
+
body: BatchQueryRequestToJSON(requestParameters.batchQueryRequest)
|
|
5361
|
+
}, initOverrides);
|
|
5362
|
+
return new JSONApiResponse(response, (jsonValue) => BatchQueryResponseFromJSON(jsonValue));
|
|
5363
|
+
}
|
|
5364
|
+
/**
|
|
5365
|
+
* 批量执行多个数据查询,用于页面初始化时预取多个数据源。 所有查询并行执行,部分失败不影响其他查询返回。
|
|
5366
|
+
* 批量执行数据查询
|
|
5367
|
+
*/
|
|
5368
|
+
async batchQueryData(requestParameters, initOverrides) {
|
|
5369
|
+
const response = await this.batchQueryDataRaw(requestParameters, initOverrides);
|
|
5370
|
+
return await response.value();
|
|
5371
|
+
}
|
|
5372
|
+
/**
|
|
5373
|
+
* 获取指定数据查询定义版本的详细信息
|
|
5374
|
+
* 获取查询定义
|
|
5375
|
+
*/
|
|
5376
|
+
async getQueryDefinitionRaw(requestParameters, initOverrides) {
|
|
5377
|
+
if (requestParameters.queryVersionId === null || requestParameters.queryVersionId === void 0) {
|
|
5378
|
+
throw new RequiredError("queryVersionId", "Required parameter requestParameters.queryVersionId was null or undefined when calling getQueryDefinition.");
|
|
5379
|
+
}
|
|
5380
|
+
const queryParameters = {};
|
|
5381
|
+
if (requestParameters.queryVersionId !== void 0) {
|
|
5382
|
+
queryParameters["queryVersionId"] = requestParameters.queryVersionId;
|
|
5383
|
+
}
|
|
5384
|
+
const headerParameters = {};
|
|
5385
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
5386
|
+
headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
|
|
5387
|
+
}
|
|
5388
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5389
|
+
const token = this.configuration.accessToken;
|
|
5390
|
+
const tokenString = await token("BearerAuth", []);
|
|
5391
|
+
if (tokenString) {
|
|
5392
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5393
|
+
}
|
|
5394
|
+
}
|
|
5395
|
+
const response = await this.request({
|
|
5396
|
+
path: `/data/definitions`,
|
|
5397
|
+
method: "GET",
|
|
5398
|
+
headers: headerParameters,
|
|
5399
|
+
query: queryParameters
|
|
5400
|
+
}, initOverrides);
|
|
5401
|
+
return new JSONApiResponse(response, (jsonValue) => QueryDefinitionResponseFromJSON(jsonValue));
|
|
5402
|
+
}
|
|
5403
|
+
/**
|
|
5404
|
+
* 获取指定数据查询定义版本的详细信息
|
|
5405
|
+
* 获取查询定义
|
|
5406
|
+
*/
|
|
5407
|
+
async getQueryDefinition(requestParameters, initOverrides) {
|
|
5408
|
+
const response = await this.getQueryDefinitionRaw(requestParameters, initOverrides);
|
|
5409
|
+
return await response.value();
|
|
5410
|
+
}
|
|
5411
|
+
/**
|
|
5412
|
+
* Data Proxy 统一入口,所有数据查询都通过此接口执行。 功能: - 白名单校验(queryVersionId 属于该 app/workspace) - 字段裁剪、脱敏 - 缓存(短 TTL) - 失败降级(兜底结构) - 审计(可选,或采样) 支持的数据源类型: - http: HTTP 接口 - graphql: GraphQL 查询 - database: 数据库查询(受限) - internal: 内部服务 - aggregation: 聚合查询
|
|
5413
|
+
* 执行数据查询(Data Proxy 统一入口)
|
|
5414
|
+
*/
|
|
5415
|
+
async queryDataRaw(requestParameters, initOverrides) {
|
|
5416
|
+
if (requestParameters.queryDataRequest === null || requestParameters.queryDataRequest === void 0) {
|
|
5417
|
+
throw new RequiredError("queryDataRequest", "Required parameter requestParameters.queryDataRequest was null or undefined when calling queryData.");
|
|
5418
|
+
}
|
|
5419
|
+
const queryParameters = {};
|
|
5420
|
+
const headerParameters = {};
|
|
5421
|
+
headerParameters["Content-Type"] = "application/json";
|
|
5422
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
5423
|
+
headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
|
|
5424
|
+
}
|
|
5425
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5426
|
+
const token = this.configuration.accessToken;
|
|
5427
|
+
const tokenString = await token("BearerAuth", []);
|
|
5428
|
+
if (tokenString) {
|
|
5429
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5430
|
+
}
|
|
5431
|
+
}
|
|
5432
|
+
const response = await this.request({
|
|
5433
|
+
path: `/data/query`,
|
|
5434
|
+
method: "POST",
|
|
5435
|
+
headers: headerParameters,
|
|
5436
|
+
query: queryParameters,
|
|
5437
|
+
body: QueryDataRequestToJSON(requestParameters.queryDataRequest)
|
|
5438
|
+
}, initOverrides);
|
|
5439
|
+
return new JSONApiResponse(response, (jsonValue) => QueryDataResponseFromJSON(jsonValue));
|
|
5440
|
+
}
|
|
5441
|
+
/**
|
|
5442
|
+
* Data Proxy 统一入口,所有数据查询都通过此接口执行。 功能: - 白名单校验(queryVersionId 属于该 app/workspace) - 字段裁剪、脱敏 - 缓存(短 TTL) - 失败降级(兜底结构) - 审计(可选,或采样) 支持的数据源类型: - http: HTTP 接口 - graphql: GraphQL 查询 - database: 数据库查询(受限) - internal: 内部服务 - aggregation: 聚合查询
|
|
5443
|
+
* 执行数据查询(Data Proxy 统一入口)
|
|
5444
|
+
*/
|
|
5445
|
+
async queryData(requestParameters, initOverrides) {
|
|
5446
|
+
const response = await this.queryDataRaw(requestParameters, initOverrides);
|
|
5447
|
+
return await response.value();
|
|
5448
|
+
}
|
|
5449
|
+
};
|
|
5450
|
+
var TrackApi = class extends BaseAPI {
|
|
5451
|
+
/**
|
|
5452
|
+
* 接收客户端埋点数据,异步写入 Outbox。 特点: - 高性能:不阻塞主链路 - 可靠:通过 Outbox 异步持久化 - 可追溯:自动关联 pageVersionId/componentVersionId/traceId
|
|
5453
|
+
* 埋点上报
|
|
5454
|
+
*/
|
|
5455
|
+
async trackRaw(requestParameters, initOverrides) {
|
|
5456
|
+
if (requestParameters.trackRequest === null || requestParameters.trackRequest === void 0) {
|
|
5457
|
+
throw new RequiredError("trackRequest", "Required parameter requestParameters.trackRequest was null or undefined when calling track.");
|
|
5458
|
+
}
|
|
5459
|
+
const queryParameters = {};
|
|
5460
|
+
const headerParameters = {};
|
|
5461
|
+
headerParameters["Content-Type"] = "application/json";
|
|
5462
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
5463
|
+
headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
|
|
5464
|
+
}
|
|
5465
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5466
|
+
const token = this.configuration.accessToken;
|
|
5467
|
+
const tokenString = await token("BearerAuth", []);
|
|
5468
|
+
if (tokenString) {
|
|
5469
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5470
|
+
}
|
|
5471
|
+
}
|
|
5472
|
+
const response = await this.request({
|
|
5473
|
+
path: `/track`,
|
|
5474
|
+
method: "POST",
|
|
5475
|
+
headers: headerParameters,
|
|
5476
|
+
query: queryParameters,
|
|
5477
|
+
body: TrackRequestToJSON(requestParameters.trackRequest)
|
|
5478
|
+
}, initOverrides);
|
|
5479
|
+
return new JSONApiResponse(response, (jsonValue) => Track202ResponseFromJSON(jsonValue));
|
|
5480
|
+
}
|
|
5481
|
+
/**
|
|
5482
|
+
* 接收客户端埋点数据,异步写入 Outbox。 特点: - 高性能:不阻塞主链路 - 可靠:通过 Outbox 异步持久化 - 可追溯:自动关联 pageVersionId/componentVersionId/traceId
|
|
5483
|
+
* 埋点上报
|
|
5484
|
+
*/
|
|
5485
|
+
async track(requestParameters, initOverrides) {
|
|
5486
|
+
const response = await this.trackRaw(requestParameters, initOverrides);
|
|
5487
|
+
return await response.value();
|
|
5488
|
+
}
|
|
5489
|
+
/**
|
|
5490
|
+
* 批量接收客户端埋点数据,提高上报效率。 限制: - 单次最多 100 条 - 单条事件不超过 10KB
|
|
5491
|
+
* 批量埋点上报
|
|
5492
|
+
*/
|
|
5493
|
+
async trackBatchRaw(requestParameters, initOverrides) {
|
|
5494
|
+
if (requestParameters.trackBatchRequest === null || requestParameters.trackBatchRequest === void 0) {
|
|
5495
|
+
throw new RequiredError("trackBatchRequest", "Required parameter requestParameters.trackBatchRequest was null or undefined when calling trackBatch.");
|
|
5496
|
+
}
|
|
5497
|
+
const queryParameters = {};
|
|
5498
|
+
const headerParameters = {};
|
|
5499
|
+
headerParameters["Content-Type"] = "application/json";
|
|
5500
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
5501
|
+
headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
|
|
5502
|
+
}
|
|
5503
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
5504
|
+
const token = this.configuration.accessToken;
|
|
5505
|
+
const tokenString = await token("BearerAuth", []);
|
|
5506
|
+
if (tokenString) {
|
|
5507
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
5508
|
+
}
|
|
5509
|
+
}
|
|
5510
|
+
const response = await this.request({
|
|
5511
|
+
path: `/track/batch`,
|
|
5512
|
+
method: "POST",
|
|
5513
|
+
headers: headerParameters,
|
|
5514
|
+
query: queryParameters,
|
|
5515
|
+
body: TrackBatchRequestToJSON(requestParameters.trackBatchRequest)
|
|
5516
|
+
}, initOverrides);
|
|
5517
|
+
return new JSONApiResponse(response, (jsonValue) => TrackBatch202ResponseFromJSON(jsonValue));
|
|
5518
|
+
}
|
|
5519
|
+
/**
|
|
5520
|
+
* 批量接收客户端埋点数据,提高上报效率。 限制: - 单次最多 100 条 - 单条事件不超过 10KB
|
|
5521
|
+
* 批量埋点上报
|
|
5522
|
+
*/
|
|
5523
|
+
async trackBatch(requestParameters, initOverrides) {
|
|
5524
|
+
const response = await this.trackBatchRaw(requestParameters, initOverrides);
|
|
5525
|
+
return await response.value();
|
|
5526
|
+
}
|
|
5527
|
+
};
|
|
5528
|
+
var DEFAULT_BASE_URL = "/api";
|
|
5529
|
+
var UserClient = class {
|
|
5530
|
+
constructor(config = {}) {
|
|
5531
|
+
const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
5532
|
+
const coreMiddlewares = createMiddlewares({
|
|
5533
|
+
auth: config.auth,
|
|
5534
|
+
retry: config.retry,
|
|
5535
|
+
enableRetry: config.enableRetry,
|
|
5536
|
+
logger: config.logger,
|
|
5537
|
+
debug: config.debug,
|
|
5538
|
+
timeout: config.timeout,
|
|
5539
|
+
headers: config.headers,
|
|
5540
|
+
preMiddlewares: config.preMiddlewares,
|
|
5541
|
+
postMiddlewares: config.postMiddlewares,
|
|
5542
|
+
errorMiddlewares: config.errorMiddlewares
|
|
5543
|
+
});
|
|
5544
|
+
const allMiddlewares = [...coreMiddlewares, ...config.middlewares ?? []];
|
|
5545
|
+
this.configuration = new Configuration({
|
|
5546
|
+
basePath: baseUrl,
|
|
5547
|
+
middleware: allMiddlewares,
|
|
5548
|
+
headers: config.headers
|
|
5549
|
+
});
|
|
5550
|
+
this.pages = new PagesApi(this.configuration);
|
|
5551
|
+
this.actions = new ActionsApi(this.configuration);
|
|
5552
|
+
this.activities = new ActivitiesApi(this.configuration);
|
|
5553
|
+
this.queries = new QueriesApi(this.configuration);
|
|
5554
|
+
this.track = new TrackApi(this.configuration);
|
|
5555
|
+
}
|
|
5556
|
+
};
|
|
5557
|
+
function createUserClient(config) {
|
|
5558
|
+
return new UserClient(config);
|
|
5559
|
+
}
|
|
5560
|
+
class OpenApiUserAdapter {
|
|
5561
|
+
constructor(options = {}) {
|
|
5562
|
+
this.client = createUserClient({
|
|
5563
|
+
baseUrl: options.baseUrl ?? "/api",
|
|
5564
|
+
timeout: options.timeout ?? 3e4,
|
|
5565
|
+
auth: options.auth,
|
|
5566
|
+
headers: options.headers,
|
|
5567
|
+
retry: options.retry,
|
|
5568
|
+
enableRetry: options.enableRetry,
|
|
5569
|
+
logger: options.logger,
|
|
5570
|
+
debug: options.debug
|
|
5571
|
+
});
|
|
5572
|
+
}
|
|
5573
|
+
async resolvePage(params) {
|
|
5574
|
+
const res = await this.client.pages.resolvePage({
|
|
5575
|
+
pageId: params.pageId,
|
|
5576
|
+
env: params.env,
|
|
5577
|
+
uid: params.uid,
|
|
5578
|
+
deviceId: params.deviceId,
|
|
5579
|
+
channel: params.channel
|
|
5580
|
+
});
|
|
5581
|
+
return res.data;
|
|
5582
|
+
}
|
|
5583
|
+
async executeAction(params) {
|
|
5584
|
+
const res = await this.client.actions.executeAction({
|
|
5585
|
+
executeActionRequest: {
|
|
5586
|
+
actionType: params.actionType,
|
|
5587
|
+
params: params.params,
|
|
5588
|
+
context: {
|
|
5589
|
+
pageVersionId: params.context.pageVersionId,
|
|
5590
|
+
deviceId: params.context.deviceId,
|
|
5591
|
+
channel: params.context.channel,
|
|
5592
|
+
extra: { uid: params.context.uid, appId: params.context.appId }
|
|
5593
|
+
},
|
|
5594
|
+
idempotencyKey: params.idempotencyKey
|
|
5595
|
+
}
|
|
5596
|
+
});
|
|
5597
|
+
const data = res.data;
|
|
5598
|
+
return {
|
|
5599
|
+
success: res.success,
|
|
5600
|
+
data: data == null ? void 0 : data.result,
|
|
5601
|
+
errorCode: data == null ? void 0 : data.errorCode,
|
|
5602
|
+
errorMessage: data == null ? void 0 : data.errorMessage
|
|
5603
|
+
};
|
|
5604
|
+
}
|
|
5605
|
+
async executeQuery(params) {
|
|
5606
|
+
const res = await this.client.queries.queryData({
|
|
5607
|
+
queryDataRequest: {
|
|
5608
|
+
queryVersionId: params.queryVersionId,
|
|
5609
|
+
params: params.params ?? {},
|
|
5610
|
+
context: {
|
|
5611
|
+
pageVersionId: params.context.pageVersionId
|
|
5612
|
+
}
|
|
5613
|
+
}
|
|
5614
|
+
});
|
|
5615
|
+
return {
|
|
5616
|
+
success: res.success,
|
|
5617
|
+
data: res.data ?? void 0,
|
|
5618
|
+
message: res.message,
|
|
5619
|
+
errorMessage: res.errorMessage
|
|
5620
|
+
};
|
|
5621
|
+
}
|
|
5622
|
+
track(payload) {
|
|
5623
|
+
this.client.track.track({
|
|
5624
|
+
trackRequest: {
|
|
5625
|
+
eventName: payload.eventName,
|
|
5626
|
+
eventType: payload.type ?? "custom",
|
|
5627
|
+
properties: payload.params,
|
|
5628
|
+
timestamp: payload.timestamp != null ? new Date(payload.timestamp) : void 0,
|
|
5629
|
+
context: {
|
|
5630
|
+
pageVersionId: payload.context.pageVersionId,
|
|
5631
|
+
sessionId: payload.context.userId
|
|
5632
|
+
}
|
|
5633
|
+
}
|
|
5634
|
+
}).catch(() => {
|
|
5635
|
+
});
|
|
5636
|
+
}
|
|
5637
|
+
}
|
|
5638
|
+
function collectWebVitalsMetrics(metrics) {
|
|
5639
|
+
if (typeof PerformanceObserver === "undefined") return;
|
|
5640
|
+
try {
|
|
5641
|
+
const paintEntries = performance.getEntriesByType("paint");
|
|
5642
|
+
const fcpEntry = paintEntries.find((entry) => entry.name === "first-contentful-paint");
|
|
5643
|
+
if (fcpEntry) {
|
|
5644
|
+
metrics.fcp = fcpEntry.startTime;
|
|
5645
|
+
}
|
|
5646
|
+
const lcpObserver = new PerformanceObserver((list) => {
|
|
5647
|
+
const entries = list.getEntries();
|
|
5648
|
+
const lastEntry = entries[entries.length - 1];
|
|
5649
|
+
if (lastEntry) {
|
|
5650
|
+
metrics.lcp = lastEntry.startTime;
|
|
5651
|
+
}
|
|
5652
|
+
});
|
|
5653
|
+
lcpObserver.observe({ type: "largest-contentful-paint", buffered: true });
|
|
5654
|
+
const fidObserver = new PerformanceObserver((list) => {
|
|
5655
|
+
const entries = list.getEntries();
|
|
5656
|
+
if (entries.length > 0) {
|
|
5657
|
+
const firstEntry = entries[0];
|
|
5658
|
+
metrics.fid = firstEntry.processingStart - firstEntry.startTime;
|
|
5659
|
+
}
|
|
5660
|
+
});
|
|
5661
|
+
fidObserver.observe({ type: "first-input", buffered: true });
|
|
5662
|
+
let clsValue = 0;
|
|
5663
|
+
const clsObserver = new PerformanceObserver((list) => {
|
|
5664
|
+
for (const entry of list.getEntries()) {
|
|
5665
|
+
const layoutShift = entry;
|
|
5666
|
+
if (!layoutShift.hadRecentInput && layoutShift.value) {
|
|
5667
|
+
clsValue += layoutShift.value;
|
|
5668
|
+
metrics.cls = clsValue;
|
|
5669
|
+
}
|
|
5670
|
+
}
|
|
5671
|
+
});
|
|
5672
|
+
clsObserver.observe({ type: "layout-shift", buffered: true });
|
|
5673
|
+
} catch {
|
|
5674
|
+
}
|
|
5675
|
+
}
|
|
5676
|
+
class PerformanceMonitor {
|
|
5677
|
+
constructor(enabled = true) {
|
|
5678
|
+
this.marks = /* @__PURE__ */ new Map();
|
|
5679
|
+
this.measures = /* @__PURE__ */ new Map();
|
|
5680
|
+
this.enabled = enabled;
|
|
5681
|
+
}
|
|
5682
|
+
/**
|
|
5683
|
+
* 标记开始时间
|
|
5684
|
+
*/
|
|
5685
|
+
mark(name) {
|
|
5686
|
+
if (!this.enabled) return;
|
|
5687
|
+
this.marks.set(name, performance.now());
|
|
5688
|
+
if (typeof performance.mark === "function") {
|
|
5689
|
+
performance.mark(`djvlc:${name}`);
|
|
5690
|
+
}
|
|
5691
|
+
}
|
|
5692
|
+
/**
|
|
5693
|
+
* 测量耗时
|
|
5694
|
+
*/
|
|
5695
|
+
measure(name, startMark, endMark) {
|
|
5696
|
+
if (!this.enabled) return 0;
|
|
5697
|
+
const start = this.marks.get(startMark);
|
|
5698
|
+
const end = endMark ? this.marks.get(endMark) : performance.now();
|
|
5699
|
+
if (start === void 0) return 0;
|
|
5700
|
+
const duration = (end ?? performance.now()) - start;
|
|
5701
|
+
this.measures.set(name, duration);
|
|
5702
|
+
if (typeof performance.measure === "function") {
|
|
5703
|
+
try {
|
|
5704
|
+
performance.measure(
|
|
5705
|
+
`djvlc:${name}`,
|
|
5706
|
+
`djvlc:${startMark}`,
|
|
5707
|
+
endMark ? `djvlc:${endMark}` : void 0
|
|
5708
|
+
);
|
|
5709
|
+
} catch {
|
|
5710
|
+
}
|
|
5711
|
+
}
|
|
5712
|
+
return duration;
|
|
5713
|
+
}
|
|
5714
|
+
/**
|
|
5715
|
+
* 获取所有测量结果
|
|
5716
|
+
*/
|
|
5717
|
+
getMeasures() {
|
|
5718
|
+
return Object.fromEntries(this.measures);
|
|
5719
|
+
}
|
|
5720
|
+
/**
|
|
5721
|
+
* 清空
|
|
5722
|
+
*/
|
|
5723
|
+
clear() {
|
|
5724
|
+
this.marks.clear();
|
|
5725
|
+
this.measures.clear();
|
|
5726
|
+
}
|
|
5727
|
+
}
|
|
5728
|
+
function createPerformanceMonitor(enabled = true) {
|
|
5729
|
+
return new PerformanceMonitor(enabled);
|
|
5730
|
+
}
|
|
5731
|
+
function getPagePerformance() {
|
|
5732
|
+
const timing = performance.timing || {};
|
|
5733
|
+
const navigation = performance.getEntriesByType(
|
|
5734
|
+
"navigation"
|
|
5735
|
+
)[0];
|
|
5736
|
+
if (navigation) {
|
|
5737
|
+
return {
|
|
5738
|
+
dns: navigation.domainLookupEnd - navigation.domainLookupStart,
|
|
5739
|
+
tcp: navigation.connectEnd - navigation.connectStart,
|
|
5740
|
+
ssl: navigation.secureConnectionStart > 0 ? navigation.connectEnd - navigation.secureConnectionStart : 0,
|
|
5741
|
+
ttfb: navigation.responseStart - navigation.requestStart,
|
|
5742
|
+
download: navigation.responseEnd - navigation.responseStart,
|
|
5743
|
+
domParse: navigation.domInteractive - navigation.responseEnd,
|
|
5744
|
+
domContentLoaded: navigation.domContentLoadedEventEnd - navigation.domContentLoadedEventStart,
|
|
5745
|
+
load: navigation.loadEventEnd - navigation.loadEventStart,
|
|
5746
|
+
total: navigation.loadEventEnd - navigation.startTime
|
|
5747
|
+
};
|
|
5748
|
+
}
|
|
5749
|
+
return {
|
|
5750
|
+
dns: timing.domainLookupEnd - timing.domainLookupStart,
|
|
5751
|
+
tcp: timing.connectEnd - timing.connectStart,
|
|
5752
|
+
ttfb: timing.responseStart - timing.requestStart,
|
|
5753
|
+
download: timing.responseEnd - timing.responseStart,
|
|
5754
|
+
domParse: timing.domInteractive - timing.responseEnd,
|
|
5755
|
+
domContentLoaded: timing.domContentLoadedEventEnd - timing.domContentLoadedEventStart,
|
|
5756
|
+
load: timing.loadEventEnd - timing.loadEventStart,
|
|
5757
|
+
total: timing.loadEventEnd - timing.navigationStart
|
|
5758
|
+
};
|
|
5759
|
+
}
|
|
5760
|
+
function getResourcePerformance(filter) {
|
|
5761
|
+
const entries = performance.getEntriesByType("resource");
|
|
5762
|
+
return entries.filter(filter || (() => true)).map((entry) => ({
|
|
5763
|
+
name: entry.name,
|
|
5764
|
+
type: entry.initiatorType,
|
|
5765
|
+
duration: entry.duration,
|
|
5766
|
+
size: entry.transferSize || 0
|
|
5767
|
+
}));
|
|
5768
|
+
}
|
|
5769
|
+
function getRuntimeResourcePerformance() {
|
|
5770
|
+
return getResourcePerformance((entry) => {
|
|
5771
|
+
return entry.name.includes("/components/") || entry.name.includes("/runtime/");
|
|
5772
|
+
});
|
|
5773
|
+
}
|
|
5774
|
+
function preconnect(hosts) {
|
|
5775
|
+
hosts.forEach((host) => {
|
|
5776
|
+
const link = document.createElement("link");
|
|
5777
|
+
link.rel = "preconnect";
|
|
5778
|
+
link.href = host.startsWith("http") ? host : `https://${host}`;
|
|
5779
|
+
link.crossOrigin = "anonymous";
|
|
5780
|
+
document.head.appendChild(link);
|
|
5781
|
+
});
|
|
5782
|
+
}
|
|
5783
|
+
function preloadAssets(cdnBaseUrl, version = RUNTIME_VERSION) {
|
|
5784
|
+
const assets = [
|
|
5785
|
+
`${cdnBaseUrl}/runtime/${version}/runtime.esm.js`,
|
|
5786
|
+
`${cdnBaseUrl}/runtime/${version}/runtime.css`
|
|
5787
|
+
];
|
|
5788
|
+
assets.forEach((href) => {
|
|
5789
|
+
const link = document.createElement("link");
|
|
5790
|
+
link.rel = "preload";
|
|
5791
|
+
link.href = href;
|
|
5792
|
+
link.as = href.endsWith(".js") ? "script" : "style";
|
|
5793
|
+
if (href.endsWith(".js")) {
|
|
5794
|
+
link.crossOrigin = "anonymous";
|
|
5795
|
+
}
|
|
5796
|
+
document.head.appendChild(link);
|
|
5797
|
+
});
|
|
5798
|
+
}
|
|
5799
|
+
function getDeviceId() {
|
|
5800
|
+
const key = "djv_device_id";
|
|
5801
|
+
let deviceId = localStorage.getItem(key);
|
|
5802
|
+
if (!deviceId) {
|
|
5803
|
+
deviceId = `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
5804
|
+
try {
|
|
5805
|
+
localStorage.setItem(key, deviceId);
|
|
5806
|
+
} catch {
|
|
5807
|
+
}
|
|
5808
|
+
}
|
|
5809
|
+
return deviceId;
|
|
5810
|
+
}
|
|
5811
|
+
function generateTraceId() {
|
|
5812
|
+
const randomHex = (len) => Array.from({ length: len }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
5813
|
+
return randomHex(32);
|
|
5814
|
+
}
|
|
5815
|
+
function generateSpanId() {
|
|
5816
|
+
const randomHex = (len) => Array.from({ length: len }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
5817
|
+
return randomHex(16);
|
|
5818
|
+
}
|
|
5819
|
+
function generateTraceparent() {
|
|
5820
|
+
const traceId = generateTraceId();
|
|
5821
|
+
const spanId = generateSpanId();
|
|
5822
|
+
return `00-${traceId}-${spanId}-01`;
|
|
5823
|
+
}
|
|
5824
|
+
const urlUtils = {
|
|
5825
|
+
/**
|
|
5826
|
+
* 获取 URL 参数
|
|
5827
|
+
*/
|
|
5828
|
+
getParam(name, url = window.location.href) {
|
|
5829
|
+
const searchParams = new URL(url).searchParams;
|
|
5830
|
+
return searchParams.get(name);
|
|
5831
|
+
},
|
|
5832
|
+
/**
|
|
5833
|
+
* 设置 URL 参数
|
|
3594
5834
|
*/
|
|
3595
5835
|
setParam(name, value) {
|
|
3596
5836
|
const url = new URL(window.location.href);
|
|
@@ -3708,9 +5948,15 @@ async function mount(container, options) {
|
|
|
3708
5948
|
if (m2.error) metrics.dataRequestErrors++;
|
|
3709
5949
|
}
|
|
3710
5950
|
}
|
|
3711
|
-
}
|
|
5951
|
+
},
|
|
5952
|
+
userApiAdapter: new OpenApiUserAdapter({
|
|
5953
|
+
baseUrl: options.apiBaseUrl,
|
|
5954
|
+
headers: options.headers,
|
|
5955
|
+
timeout: 3e4,
|
|
5956
|
+
...options.authToken != null && options.authToken !== "" ? { auth: { type: "bearer", getToken: () => Promise.resolve(options.authToken) } } : {}
|
|
5957
|
+
})
|
|
3712
5958
|
};
|
|
3713
|
-
const runtime =
|
|
5959
|
+
const runtime = P(runtimeOptions);
|
|
3714
5960
|
const withTimeout = (promise, ms) => {
|
|
3715
5961
|
return Promise.race([
|
|
3716
5962
|
promise,
|
|
@@ -4199,10 +6445,11 @@ const index = {
|
|
|
4199
6445
|
isWeChat,
|
|
4200
6446
|
supportsWebP,
|
|
4201
6447
|
// 核心
|
|
4202
|
-
createRuntime:
|
|
6448
|
+
createRuntime: P
|
|
4203
6449
|
};
|
|
4204
6450
|
export {
|
|
4205
6451
|
ErrorReporter,
|
|
6452
|
+
OpenApiUserAdapter,
|
|
4206
6453
|
PerformanceMonitor,
|
|
4207
6454
|
RUNTIME_VERSION,
|
|
4208
6455
|
StorageHelper,
|
|
@@ -4211,7 +6458,7 @@ export {
|
|
|
4211
6458
|
collectWebVitalsMetrics,
|
|
4212
6459
|
createErrorReporter,
|
|
4213
6460
|
createPerformanceMonitor,
|
|
4214
|
-
|
|
6461
|
+
P as createRuntime,
|
|
4215
6462
|
createStorageHelper,
|
|
4216
6463
|
createTrackingManager,
|
|
4217
6464
|
index as default,
|