pxengine 0.1.61 → 0.1.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +29 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +29 -4
- package/dist/index.mjs.map +1 -1
- package/dist/registry.json +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -37438,6 +37438,31 @@ SearchSpecCard.displayName = "SearchSpecCard";
|
|
|
37438
37438
|
import React96 from "react";
|
|
37439
37439
|
|
|
37440
37440
|
// src/molecules/creator-discovery/MCQCard/defaultFetchers.ts
|
|
37441
|
+
function getBackendOrigin() {
|
|
37442
|
+
if (typeof window === "undefined") return null;
|
|
37443
|
+
return window.__NEXT_DATA__?.runtimeConfig?.NEXT_PUBLIC_AGENT_BACKEND ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_AGENT_BACKEND : void 0) ?? null;
|
|
37444
|
+
}
|
|
37445
|
+
function getBaseUrl() {
|
|
37446
|
+
const backend = getBackendOrigin();
|
|
37447
|
+
if (backend) return `${backend}/api/custom-agents`;
|
|
37448
|
+
return "/api/agents-proxy/custom-agents";
|
|
37449
|
+
}
|
|
37450
|
+
function getAuthToken() {
|
|
37451
|
+
if (typeof document === "undefined") return null;
|
|
37452
|
+
for (const name of ["adminTokenBuilder", "adminToken", "token"]) {
|
|
37453
|
+
const match2 = document.cookie.match(new RegExp(`(?:^|;\\s*)${name}=([^;]*)`));
|
|
37454
|
+
if (match2?.[1]) return match2[1];
|
|
37455
|
+
}
|
|
37456
|
+
return null;
|
|
37457
|
+
}
|
|
37458
|
+
function buildHeaders() {
|
|
37459
|
+
const headers = { "Content-Type": "application/json" };
|
|
37460
|
+
if (getBackendOrigin()) {
|
|
37461
|
+
const token = getAuthToken();
|
|
37462
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
37463
|
+
}
|
|
37464
|
+
return headers;
|
|
37465
|
+
}
|
|
37441
37466
|
var STORAGE_KEY = (sessionId) => `mcq_selections_${sessionId}`;
|
|
37442
37467
|
function getLocalSelections(sessionId) {
|
|
37443
37468
|
try {
|
|
@@ -37460,10 +37485,10 @@ async function defaultFetchSelections(sessionId) {
|
|
|
37460
37485
|
if (Object.keys(local).length > 0) return local;
|
|
37461
37486
|
try {
|
|
37462
37487
|
const res = await fetch(
|
|
37463
|
-
|
|
37488
|
+
`${getBaseUrl()}/sessions/${sessionId}/mcq-selections/get`,
|
|
37464
37489
|
{
|
|
37465
37490
|
method: "POST",
|
|
37466
|
-
headers:
|
|
37491
|
+
headers: buildHeaders(),
|
|
37467
37492
|
body: "{}"
|
|
37468
37493
|
}
|
|
37469
37494
|
);
|
|
@@ -37485,10 +37510,10 @@ async function defaultPersistSelection(sessionId, questionKey, value) {
|
|
|
37485
37510
|
setLocalSelection(sessionId, questionKey, value);
|
|
37486
37511
|
try {
|
|
37487
37512
|
await fetch(
|
|
37488
|
-
|
|
37513
|
+
`${getBaseUrl()}/sessions/${sessionId}/mcq-selections`,
|
|
37489
37514
|
{
|
|
37490
37515
|
method: "PATCH",
|
|
37491
|
-
headers:
|
|
37516
|
+
headers: buildHeaders(),
|
|
37492
37517
|
body: JSON.stringify({ question_key: questionKey, value })
|
|
37493
37518
|
}
|
|
37494
37519
|
);
|