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.cjs
CHANGED
|
@@ -37729,6 +37729,31 @@ SearchSpecCard.displayName = "SearchSpecCard";
|
|
|
37729
37729
|
var import_react66 = __toESM(require("react"), 1);
|
|
37730
37730
|
|
|
37731
37731
|
// src/molecules/creator-discovery/MCQCard/defaultFetchers.ts
|
|
37732
|
+
function getBackendOrigin() {
|
|
37733
|
+
if (typeof window === "undefined") return null;
|
|
37734
|
+
return window.__NEXT_DATA__?.runtimeConfig?.NEXT_PUBLIC_AGENT_BACKEND ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_AGENT_BACKEND : void 0) ?? null;
|
|
37735
|
+
}
|
|
37736
|
+
function getBaseUrl() {
|
|
37737
|
+
const backend = getBackendOrigin();
|
|
37738
|
+
if (backend) return `${backend}/api/custom-agents`;
|
|
37739
|
+
return "/api/agents-proxy/custom-agents";
|
|
37740
|
+
}
|
|
37741
|
+
function getAuthToken() {
|
|
37742
|
+
if (typeof document === "undefined") return null;
|
|
37743
|
+
for (const name of ["adminTokenBuilder", "adminToken", "token"]) {
|
|
37744
|
+
const match2 = document.cookie.match(new RegExp(`(?:^|;\\s*)${name}=([^;]*)`));
|
|
37745
|
+
if (match2?.[1]) return match2[1];
|
|
37746
|
+
}
|
|
37747
|
+
return null;
|
|
37748
|
+
}
|
|
37749
|
+
function buildHeaders() {
|
|
37750
|
+
const headers = { "Content-Type": "application/json" };
|
|
37751
|
+
if (getBackendOrigin()) {
|
|
37752
|
+
const token = getAuthToken();
|
|
37753
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
37754
|
+
}
|
|
37755
|
+
return headers;
|
|
37756
|
+
}
|
|
37732
37757
|
var STORAGE_KEY = (sessionId) => `mcq_selections_${sessionId}`;
|
|
37733
37758
|
function getLocalSelections(sessionId) {
|
|
37734
37759
|
try {
|
|
@@ -37751,10 +37776,10 @@ async function defaultFetchSelections(sessionId) {
|
|
|
37751
37776
|
if (Object.keys(local).length > 0) return local;
|
|
37752
37777
|
try {
|
|
37753
37778
|
const res = await fetch(
|
|
37754
|
-
|
|
37779
|
+
`${getBaseUrl()}/sessions/${sessionId}/mcq-selections/get`,
|
|
37755
37780
|
{
|
|
37756
37781
|
method: "POST",
|
|
37757
|
-
headers:
|
|
37782
|
+
headers: buildHeaders(),
|
|
37758
37783
|
body: "{}"
|
|
37759
37784
|
}
|
|
37760
37785
|
);
|
|
@@ -37776,10 +37801,10 @@ async function defaultPersistSelection(sessionId, questionKey, value) {
|
|
|
37776
37801
|
setLocalSelection(sessionId, questionKey, value);
|
|
37777
37802
|
try {
|
|
37778
37803
|
await fetch(
|
|
37779
|
-
|
|
37804
|
+
`${getBaseUrl()}/sessions/${sessionId}/mcq-selections`,
|
|
37780
37805
|
{
|
|
37781
37806
|
method: "PATCH",
|
|
37782
|
-
headers:
|
|
37807
|
+
headers: buildHeaders(),
|
|
37783
37808
|
body: JSON.stringify({ question_key: questionKey, value })
|
|
37784
37809
|
}
|
|
37785
37810
|
);
|