@realtek/core-theme-live 0.0.383 → 0.0.384

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.
@@ -26,7 +26,10 @@ async function c(e = {}) {
26
26
  Authorization: `Bearer ${e}`
27
27
  }
28
28
  });
29
- if (!r.ok) throw Error(`API ${r.status}: ${r.statusText}`);
29
+ if (!r.ok) {
30
+ let e = /* @__PURE__ */ Error(`API ${r.status}: ${r.statusText}`);
31
+ throw e.status = r.status, e;
32
+ }
30
33
  return r.json();
31
34
  });
32
35
  }
@@ -50,4 +53,4 @@ async function u(e, i) {
50
53
  //#endregion
51
54
  export { u as n, l as r, a as t };
52
55
 
53
- //# sourceMappingURL=addFormApi-C73cTTIu.js.map
56
+ //# sourceMappingURL=addFormApi-Bly_wUfr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addFormApi-Bly_wUfr.js","names":[],"sources":["../src/services/addFormApi.js"],"sourcesContent":["import { ensureToken, fetchJsonWithAuth } from './authApi';\nimport { AUTH_URL, JOBS_URL } from './apiConfig';\nimport { fetchFormGroupsCached, invalidateFormGroupsCache } from './formGroupsCache';\n\n// ── Form Groups ───────────────────────────────────────────────────────────────\n\nfunction extractFormGroups(json) {\n const payload = json?.data ?? json;\n if (Array.isArray(payload)) return payload;\n if (Array.isArray(payload?.groups)) return payload.groups;\n if (Array.isArray(json?.groups)) return json.groups;\n return [];\n}\n\n/**\n * formGroupsUrl — the canonical URL for one form-groups query. Built in a fixed\n * parameter order so two callers asking the same question produce the same\n * string, which is what makes them shareable (see formGroupsCache).\n */\nfunction formGroupsUrl({ module, id, action, clientId, region, group, view } = {}) {\n const params = new URLSearchParams({ module });\n if (id) params.set('id', id);\n if (action) params.set('action', action);\n if (clientId) params.set('clientId', clientId);\n if (region) params.set('region', region);\n if (group) params.set('group', group);\n if (view) params.set('view', view);\n return `${AUTH_URL}/admin/form-groups?${params.toString()}`;\n}\n\n/**\n * fetchFormGroupsPayload — the RAW payload for one query, shared between every\n * caller that asks for it (see formGroupsCache for why). Returns the whole\n * envelope, so a caller that needs `recordMeta` and one that needs only the\n * groups array still cost ONE request between them.\n */\nexport async function fetchFormGroupsPayload(options = {}) {\n if (!options.module) throw new Error('module is required to fetch form groups');\n const url = formGroupsUrl(options);\n return fetchFormGroupsCached(url, async () => {\n const token = await ensureToken();\n const res = await fetch(url, {\n method: 'GET',\n headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },\n });\n if (!res.ok) {\n // `.status` is what isRecordUnavailableError (detail/recordAccess.js)\n // reads, via EditFormV1's getFormGroups call, to decide whether a\n // fetch failure means \"you cannot see this record\" and should render\n // the centered unavailable-record page instead of a raw error. A bare\n // `new Error(...)` here left `.status` undefined, so EditFormV1's\n // \"record not available\" page was never actually reachable despite\n // being wired up — the same bug DetailViewV1 had via dropdownApi.js.\n const error = new Error(`API ${res.status}: ${res.statusText}`);\n error.status = res.status;\n throw error;\n }\n return res.json();\n });\n}\n\nexport async function getFormGroups(options = {}) {\n return extractFormGroups(await fetchFormGroupsPayload(options));\n}\n\nexport async function getCandidateFormGroups(options = {}) {\n return getFormGroups({ module: 'candidates', ...options });\n}\n\nexport async function getMentionUsers(search = '') {\n const { apiGetWithAuth } = await import('./authApi');\n const params = search ? `?search=${encodeURIComponent(search)}` : '';\n return apiGetWithAuth(JOBS_URL, `/users/any${params}`);\n}\n\n// ── Create Records ────────────────────────────────────────────────────────────\n// Routes through the Auth gateway which injects tenant context from JWT\n// and proxies to the correct downstream service based on module name.\n\nexport async function createModuleRecord(moduleName, formData) {\n // ensureToken (not getStoredToken) so a missing/expired session throws a\n // clear \"Authentication required\" error instead of silently sending the\n // request with no Authorization header (which the gateway rejects as 401).\n // NOTE: do NOT set Content-Type here — the browser must add the multipart\n // boundary itself. Only the Authorization header is set manually.\n const token = await ensureToken();\n\n const res = await fetch(\n `${AUTH_URL}/module/create?module=${encodeURIComponent(moduleName)}`,\n { method: 'POST', headers: { Authorization: `Bearer ${token}` }, body: formData },\n );\n\n const { logout } = await import('./authApi');\n if (res.status === 401) logout();\n\n // A save is exactly the moment a cached form-groups payload stops describing\n // the record — invalidate before the caller can navigate and read one back.\n invalidateFormGroupsCache();\n\n const contentType = res.headers.get('content-type') || '';\n const data = contentType.includes('application/json') ? await res.json() : await res.text();\n\n if (!res.ok) {\n const error = new Error(data?.error || data?.message || `API ${res.status}: ${res.statusText}`);\n error.status = res.status;\n error.data = data;\n throw error;\n }\n\n return data;\n}\n"],"mappings":";;;;;;;;;AAMA,SAAS,EAAkB,GAAM;CAC/B,IAAM,IAAU,GAAM,QAAQ;CAI9B,OAHI,MAAM,QAAQ,CAAO,IAAU,IAC/B,MAAM,QAAQ,GAAS,MAAM,IAAU,EAAQ,SAC/C,MAAM,QAAQ,GAAM,MAAM,IAAU,EAAK,SACtC,CAAC;AACV;AAOA,SAAS,EAAc,EAAE,WAAQ,OAAI,WAAQ,aAAU,WAAQ,UAAO,YAAS,CAAC,GAAG;CACjF,IAAM,IAAS,IAAI,gBAAgB,EAAE,UAAO,CAAC;CAO7C,OANI,KAAI,EAAO,IAAI,MAAM,CAAE,GACvB,KAAQ,EAAO,IAAI,UAAU,CAAM,GACnC,KAAU,EAAO,IAAI,YAAY,CAAQ,GACzC,KAAQ,EAAO,IAAI,UAAU,CAAM,GACnC,KAAO,EAAO,IAAI,SAAS,CAAK,GAChC,KAAM,EAAO,IAAI,QAAQ,CAAI,GAC1B,GAAG,EAAS,qBAAqB,EAAO,SAAS;AAC1D;AAQA,eAAsB,EAAuB,IAAU,CAAC,GAAG;CACzD,IAAI,CAAC,EAAQ,QAAQ,MAAU,MAAM,yCAAyC;CAC9E,IAAM,IAAM,EAAc,CAAO;CACjC,OAAO,EAAsB,GAAK,YAAY;EAC5C,IAAM,IAAQ,MAAM,EAAY,GAC1B,IAAM,MAAM,MAAM,GAAK;GAC3B,QAAQ;GACR,SAAS;IAAE,gBAAgB;IAAoB,eAAe,UAAU;GAAQ;EAClF,CAAC;EACD,IAAI,CAAC,EAAI,IAAI;GAQX,IAAM,IAAQ,gBAAI,MAAM,OAAO,EAAI,OAAO,IAAI,EAAI,YAAY;GAE9D,MADA,EAAM,SAAS,EAAI,QACb;EACR;EACA,OAAO,EAAI,KAAK;CAClB,CAAC;AACH;AAEA,eAAsB,EAAc,IAAU,CAAC,GAAG;CAChD,OAAO,EAAkB,MAAM,EAAuB,CAAO,CAAC;AAChE;AAgBA,eAAsB,EAAmB,GAAY,GAAU;CAM7D,IAAM,IAAQ,MAAM,EAAY,GAE1B,IAAM,MAAM,MAChB,GAAG,EAAS,wBAAwB,mBAAmB,CAAU,KACjE;EAAE,QAAQ;EAAQ,SAAS,EAAE,eAAe,UAAU,IAAQ;EAAG,MAAM;CAAS,CAClF,GAEM,EAAE,cAAW,MAAM,OAAO,wBAAA,CAAA,MAAA,MAAA,EAAA,CAAA;CAKhC,AAJI,EAAI,WAAW,OAAK,EAAO,GAI/B,EAA0B;CAG1B,IAAM,KADc,EAAI,QAAQ,IAAI,cAAc,KAAK,GAAA,CAC9B,SAAS,kBAAkB,IAAI,MAAM,EAAI,KAAK,IAAI,MAAM,EAAI,KAAK;CAE1F,IAAI,CAAC,EAAI,IAAI;EACX,IAAM,IAAY,MAAM,GAAM,SAAS,GAAM,WAAW,OAAO,EAAI,OAAO,IAAI,EAAI,YAAY;EAG9F,MAFA,EAAM,SAAS,EAAI,QACnB,EAAM,OAAO,GACP;CACR;CAEA,OAAO;AACT"}
@@ -0,0 +1,2 @@
1
+ const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./authApi-B9mjMdVC.cjs"),n=require("./formGroupsCache-Bbz-28ws.cjs");var r=e.t({createModuleRecord:()=>c,fetchFormGroupsPayload:()=>o,getFormGroups:()=>s});function i(e){let t=e?.data??e;return Array.isArray(t)?t:Array.isArray(t?.groups)?t.groups:Array.isArray(e?.groups)?e.groups:[]}function a({module:e,id:n,action:r,clientId:i,region:a,group:o,view:s}={}){let c=new URLSearchParams({module:e});return n&&c.set(`id`,n),r&&c.set(`action`,r),i&&c.set(`clientId`,i),a&&c.set(`region`,a),o&&c.set(`group`,o),s&&c.set(`view`,s),`${t.x}/admin/form-groups?${c.toString()}`}async function o(e={}){if(!e.module)throw Error(`module is required to fetch form groups`);let r=a(e);return n.t(r,async()=>{let e=await t.a(),n=await fetch(r,{method:`GET`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e}`}});if(!n.ok){let e=Error(`API ${n.status}: ${n.statusText}`);throw e.status=n.status,e}return n.json()})}async function s(e={}){return i(await o(e))}async function c(e,r){let i=await t.a(),a=await fetch(`${t.x}/module/create?module=${encodeURIComponent(e)}`,{method:`POST`,headers:{Authorization:`Bearer ${i}`},body:r}),{logout:o}=await Promise.resolve().then(()=>require("./authApi-B9mjMdVC.cjs")).then(e=>e.n);a.status===401&&o(),n.r();let s=(a.headers.get(`content-type`)||``).includes(`application/json`)?await a.json():await a.text();if(!a.ok){let e=Error(s?.error||s?.message||`API ${a.status}: ${a.statusText}`);throw e.status=a.status,e.data=s,e}return s}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
2
+ //# sourceMappingURL=addFormApi-CKdtiVhh.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addFormApi-CKdtiVhh.cjs","names":[],"sources":["../src/services/addFormApi.js"],"sourcesContent":["import { ensureToken, fetchJsonWithAuth } from './authApi';\nimport { AUTH_URL, JOBS_URL } from './apiConfig';\nimport { fetchFormGroupsCached, invalidateFormGroupsCache } from './formGroupsCache';\n\n// ── Form Groups ───────────────────────────────────────────────────────────────\n\nfunction extractFormGroups(json) {\n const payload = json?.data ?? json;\n if (Array.isArray(payload)) return payload;\n if (Array.isArray(payload?.groups)) return payload.groups;\n if (Array.isArray(json?.groups)) return json.groups;\n return [];\n}\n\n/**\n * formGroupsUrl — the canonical URL for one form-groups query. Built in a fixed\n * parameter order so two callers asking the same question produce the same\n * string, which is what makes them shareable (see formGroupsCache).\n */\nfunction formGroupsUrl({ module, id, action, clientId, region, group, view } = {}) {\n const params = new URLSearchParams({ module });\n if (id) params.set('id', id);\n if (action) params.set('action', action);\n if (clientId) params.set('clientId', clientId);\n if (region) params.set('region', region);\n if (group) params.set('group', group);\n if (view) params.set('view', view);\n return `${AUTH_URL}/admin/form-groups?${params.toString()}`;\n}\n\n/**\n * fetchFormGroupsPayload — the RAW payload for one query, shared between every\n * caller that asks for it (see formGroupsCache for why). Returns the whole\n * envelope, so a caller that needs `recordMeta` and one that needs only the\n * groups array still cost ONE request between them.\n */\nexport async function fetchFormGroupsPayload(options = {}) {\n if (!options.module) throw new Error('module is required to fetch form groups');\n const url = formGroupsUrl(options);\n return fetchFormGroupsCached(url, async () => {\n const token = await ensureToken();\n const res = await fetch(url, {\n method: 'GET',\n headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },\n });\n if (!res.ok) {\n // `.status` is what isRecordUnavailableError (detail/recordAccess.js)\n // reads, via EditFormV1's getFormGroups call, to decide whether a\n // fetch failure means \"you cannot see this record\" and should render\n // the centered unavailable-record page instead of a raw error. A bare\n // `new Error(...)` here left `.status` undefined, so EditFormV1's\n // \"record not available\" page was never actually reachable despite\n // being wired up — the same bug DetailViewV1 had via dropdownApi.js.\n const error = new Error(`API ${res.status}: ${res.statusText}`);\n error.status = res.status;\n throw error;\n }\n return res.json();\n });\n}\n\nexport async function getFormGroups(options = {}) {\n return extractFormGroups(await fetchFormGroupsPayload(options));\n}\n\nexport async function getCandidateFormGroups(options = {}) {\n return getFormGroups({ module: 'candidates', ...options });\n}\n\nexport async function getMentionUsers(search = '') {\n const { apiGetWithAuth } = await import('./authApi');\n const params = search ? `?search=${encodeURIComponent(search)}` : '';\n return apiGetWithAuth(JOBS_URL, `/users/any${params}`);\n}\n\n// ── Create Records ────────────────────────────────────────────────────────────\n// Routes through the Auth gateway which injects tenant context from JWT\n// and proxies to the correct downstream service based on module name.\n\nexport async function createModuleRecord(moduleName, formData) {\n // ensureToken (not getStoredToken) so a missing/expired session throws a\n // clear \"Authentication required\" error instead of silently sending the\n // request with no Authorization header (which the gateway rejects as 401).\n // NOTE: do NOT set Content-Type here — the browser must add the multipart\n // boundary itself. Only the Authorization header is set manually.\n const token = await ensureToken();\n\n const res = await fetch(\n `${AUTH_URL}/module/create?module=${encodeURIComponent(moduleName)}`,\n { method: 'POST', headers: { Authorization: `Bearer ${token}` }, body: formData },\n );\n\n const { logout } = await import('./authApi');\n if (res.status === 401) logout();\n\n // A save is exactly the moment a cached form-groups payload stops describing\n // the record — invalidate before the caller can navigate and read one back.\n invalidateFormGroupsCache();\n\n const contentType = res.headers.get('content-type') || '';\n const data = contentType.includes('application/json') ? await res.json() : await res.text();\n\n if (!res.ok) {\n const error = new Error(data?.error || data?.message || `API ${res.status}: ${res.statusText}`);\n error.status = res.status;\n error.data = data;\n throw error;\n }\n\n return data;\n}\n"],"mappings":"0NAMA,SAAS,EAAkB,EAAM,CAC/B,IAAM,EAAU,GAAM,MAAQ,EAI9B,OAHI,MAAM,QAAQ,CAAO,EAAU,EAC/B,MAAM,QAAQ,GAAS,MAAM,EAAU,EAAQ,OAC/C,MAAM,QAAQ,GAAM,MAAM,EAAU,EAAK,OACtC,CAAC,CACV,CAOA,SAAS,EAAc,CAAE,SAAQ,KAAI,SAAQ,WAAU,SAAQ,QAAO,QAAS,CAAC,EAAG,CACjF,IAAM,EAAS,IAAI,gBAAgB,CAAE,QAAO,CAAC,EAO7C,OANI,GAAI,EAAO,IAAI,KAAM,CAAE,EACvB,GAAQ,EAAO,IAAI,SAAU,CAAM,EACnC,GAAU,EAAO,IAAI,WAAY,CAAQ,EACzC,GAAQ,EAAO,IAAI,SAAU,CAAM,EACnC,GAAO,EAAO,IAAI,QAAS,CAAK,EAChC,GAAM,EAAO,IAAI,OAAQ,CAAI,EAC1B,GAAG,EAAA,EAAS,qBAAqB,EAAO,SAAS,GAC1D,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