@forjacms/client 1.2.7 → 1.2.8

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.
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../client-eFMh_n88.cjs`);let t=require(`@angular/core`);const n=new t.InjectionToken(`ForjaClient`);function r(r){return(0,t.makeEnvironmentProviders)([{provide:n,useFactory:()=>new e.t(r)}])}function i(){return(0,t.inject)(n)}function a(e){let n=(0,t.signal)(void 0),r=(0,t.signal)(!0),i=(0,t.signal)(null),a=()=>{r.set(!0),i.set(null),e().then(e=>n.set(e)).catch(e=>i.set(e instanceof Error?e:Error(String(e)))).finally(()=>r.set(!1))};return a(),{value:n.asReadonly(),isLoading:r.asReadonly(),error:i.asReadonly(),reload:a}}exports.FORJA_CLIENT=n,exports.forjaResource=a,exports.injectForja=i,exports.provideForja=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../client-_Ak79dHS.cjs`);let t=require(`@angular/core`);const n=new t.InjectionToken(`ForjaClient`);function r(r){return(0,t.makeEnvironmentProviders)([{provide:n,useFactory:()=>new e.t(r)}])}function i(){return(0,t.inject)(n)}function a(e){let n=(0,t.signal)(void 0),r=(0,t.signal)(!0),i=(0,t.signal)(null),a=()=>{r.set(!0),i.set(null),e().then(e=>n.set(e)).catch(e=>i.set(e instanceof Error?e:Error(String(e)))).finally(()=>r.set(!1))};return a(),{value:n.asReadonly(),isLoading:r.asReadonly(),error:i.asReadonly(),reload:a}}exports.FORJA_CLIENT=n,exports.forjaResource=a,exports.injectForja=i,exports.provideForja=r;
@@ -1,4 +1,4 @@
1
- import { b as ForjaClientConfig, t as ForjaClient } from "../client-BBAKLM2r.cjs";
1
+ import { t as ForjaClient, x as ForjaClientConfig } from "../client-B6llPNEv.cjs";
2
2
  import { EnvironmentProviders, InjectionToken, Signal } from "@angular/core";
3
3
 
4
4
  //#region src/angular/provider.d.ts
@@ -1,4 +1,4 @@
1
- import { b as ForjaClientConfig, t as ForjaClient } from "../client-d-QwwKUW.mjs";
1
+ import { t as ForjaClient, x as ForjaClientConfig } from "../client-CyzDT4Ir.mjs";
2
2
  import { EnvironmentProviders, InjectionToken, Signal } from "@angular/core";
3
3
 
4
4
  //#region src/angular/provider.d.ts
@@ -1 +1 @@
1
- import{t as e}from"../client-DTfhjUoX.mjs";import{InjectionToken as t,inject as n,makeEnvironmentProviders as r,signal as i}from"@angular/core";const a=new t(`ForjaClient`);function o(t){return r([{provide:a,useFactory:()=>new e(t)}])}function s(){return n(a)}function c(e){let t=i(void 0),n=i(!0),r=i(null),a=()=>{n.set(!0),r.set(null),e().then(e=>t.set(e)).catch(e=>r.set(e instanceof Error?e:Error(String(e)))).finally(()=>n.set(!1))};return a(),{value:t.asReadonly(),isLoading:n.asReadonly(),error:r.asReadonly(),reload:a}}export{a as FORJA_CLIENT,c as forjaResource,s as injectForja,o as provideForja};
1
+ import{t as e}from"../client-C6mKwSKr.mjs";import{InjectionToken as t,inject as n,makeEnvironmentProviders as r,signal as i}from"@angular/core";const a=new t(`ForjaClient`);function o(t){return r([{provide:a,useFactory:()=>new e(t)}])}function s(){return n(a)}function c(e){let t=i(void 0),n=i(!0),r=i(null),a=()=>{n.set(!0),r.set(null),e().then(e=>t.set(e)).catch(e=>r.set(e instanceof Error?e:Error(String(e)))).finally(()=>n.set(!1))};return a(),{value:t.asReadonly(),isLoading:n.asReadonly(),error:r.asReadonly(),reload:a}}export{a as FORJA_CLIENT,c as forjaResource,s as injectForja,o as provideForja};
@@ -346,6 +346,13 @@ interface LegalDocumentWithGroups {
346
346
  document_type: LegalDocType;
347
347
  groups: LegalGroupWithItems[];
348
348
  }
349
+ /** Custom HTML/JS snippets configured for injection into page templates. */
350
+ interface CodeInjection {
351
+ /** HTML/JS to inject into <head> */
352
+ code_injection_head: string;
353
+ /** HTML/JS to inject before </body> */
354
+ code_injection_footer: string;
355
+ }
349
356
  interface SiteResponse {
350
357
  id: string;
351
358
  name: string;
@@ -1436,6 +1443,29 @@ declare class SiteResource {
1436
1443
  * ```
1437
1444
  */
1438
1445
  listLocales(): Promise<SiteLocaleResponse[]>;
1446
+ /**
1447
+ * Get code injection scripts configured for this site.
1448
+ *
1449
+ * **Endpoint:** `GET /sites/{siteId}/settings`
1450
+ *
1451
+ * Returns the custom HTML/JS snippets configured for injection into
1452
+ * the site's `<head>` and footer. Use these to embed analytics tags,
1453
+ * chat widgets, or any custom scripts into your template.
1454
+ *
1455
+ * Fields that are not configured on the server default to empty strings.
1456
+ *
1457
+ * Requires an API key with `Read` permission.
1458
+ *
1459
+ * @returns The code injection head and footer snippets.
1460
+ *
1461
+ * @example
1462
+ * ```ts
1463
+ * const injection = await forja.site.getCodeInjection();
1464
+ * // injection.code_injection_head → "<script>...</script>"
1465
+ * // injection.code_injection_footer → "<script>...</script>"
1466
+ * ```
1467
+ */
1468
+ getCodeInjection(): Promise<CodeInjection>;
1439
1469
  }
1440
1470
  //#endregion
1441
1471
  //#region src/resources/social.d.ts
@@ -1670,4 +1700,4 @@ declare class ForjaClient {
1670
1700
  constructor(config: ForjaClientConfig);
1671
1701
  }
1672
1702
  //#endregion
1673
- export { ProjectLocalizationResponse as $, LegalVersionResponse as A, NavigationTree as B, LegalDocumentDetailResponse as C, LegalGroupResponse as D, LegalDocumentWithGroups as E, MediaResponse as F, PageType as G, PageListItem as H, MediaVariantResponse as I, PaginationParams as J, Paginated as K, NavigationItemLocalizationResponse as L, LocalizationResponse as M, MediaListItem as N, LegalGroupWithItems as O, MediaListParams as P, ProjectListParams as Q, NavigationItemResponse as R, LegalDocType as S, LegalDocumentResponse as T, PageResponse as U, PageDetailResponse as V, PageSectionResponse as W, ProjectLinkResponse as X, ProjectDetailResponse as Y, ProjectLinkType as Z, CvEntryResponse as _, TranslationStatus as _t, AnalyticsPageParams as a, SearchablePaginationParams as at, ForjaClientConfig as b, BlogDetailResponse as c, SiteLocaleResponse as ct, BlogResponse as d, SkillResponse as dt, ProjectMediaResponse as et, CategoryResponse as f, SocialLinkResponse as ft, CvEntryParams as g, TrackPageviewResponse as gt, ContentStatus as h, TrackPageviewRequest as ht, AnalyticsPageDetailResponse as i, ReferrerItem as it, LocaleFilterParams as j, LegalItemResponse as k, BlogDocumentResponse as l, SiteResponse as lt, CategoryWithCountResponse as m, TopContentItem as mt, HttpClient as n, RedirectLookupResponse as nt, AnalyticsReportParams as o, SectionLocalizationResponse as ot, CategoryTree as p, TagResponse as pt, PaginationMeta as q, PaginatedResult as r, RedirectResponse as rt, AnalyticsReportResponse as s, SectionType as st, ForjaClient as t, ProjectResponse as tt, BlogListItem as u, SkillCategory as ut, CvEntryType as v, TrendDataPoint as vt, LegalDocumentFullDetailResponse as w, LegalDocLocalizationResponse as x, DocumentLocalizationResponse as y, NavigationMenuResponse as z };
1703
+ export { ProjectListParams as $, LegalItemResponse as A, NavigationMenuResponse as B, LegalDocType as C, LegalDocumentWithGroups as D, LegalDocumentResponse as E, MediaListParams as F, PageSectionResponse as G, PageDetailResponse as H, MediaResponse as I, PaginationMeta as J, PageType as K, MediaVariantResponse as L, LocaleFilterParams as M, LocalizationResponse as N, LegalGroupResponse as O, MediaListItem as P, ProjectLinkType as Q, NavigationItemLocalizationResponse as R, LegalDocLocalizationResponse as S, LegalDocumentFullDetailResponse as T, PageListItem as U, NavigationTree as V, PageResponse as W, ProjectDetailResponse as X, PaginationParams as Y, ProjectLinkResponse as Z, CvEntryParams as _, TrackPageviewResponse as _t, AnalyticsPageParams as a, ReferrerItem as at, DocumentLocalizationResponse as b, BlogDetailResponse as c, SectionType as ct, BlogResponse as d, SkillCategory as dt, ProjectLocalizationResponse as et, CategoryResponse as f, SkillResponse as ft, ContentStatus as g, TrackPageviewRequest as gt, CodeInjection as h, TopContentItem as ht, AnalyticsPageDetailResponse as i, RedirectResponse as it, LegalVersionResponse as j, LegalGroupWithItems as k, BlogDocumentResponse as l, SiteLocaleResponse as lt, CategoryWithCountResponse as m, TagResponse as mt, HttpClient as n, ProjectResponse as nt, AnalyticsReportParams as o, SearchablePaginationParams as ot, CategoryTree as p, SocialLinkResponse as pt, Paginated as q, PaginatedResult as r, RedirectLookupResponse as rt, AnalyticsReportResponse as s, SectionLocalizationResponse as st, ForjaClient as t, ProjectMediaResponse as tt, BlogListItem as u, SiteResponse as ut, CvEntryResponse as v, TranslationStatus as vt, LegalDocumentDetailResponse as w, ForjaClientConfig as x, CvEntryType as y, TrendDataPoint as yt, NavigationItemResponse as z };
@@ -1 +1 @@
1
- var e=class extends Error{constructor(e,t){super(e),this.code=t,this.name=`ForjaError`}},t=class extends e{constructor(e=`Invalid or missing API key`){super(e,`AUTH_ERROR`),this.name=`ForjaAuthError`}},n=class extends e{constructor(e=`Insufficient permissions`){super(e,`PERMISSION_ERROR`),this.name=`ForjaPermissionError`}},r=class extends e{constructor(e=`Resource not found`){super(e,`NOT_FOUND`),this.name=`ForjaNotFoundError`}},i=class extends e{constructor(e=`Rate limit exceeded`,t){super(e,`RATE_LIMIT`),this.retryAfter=t,this.name=`ForjaRateLimitError`}},a=class extends e{constructor(e=`Validation error`,t){super(e,`VALIDATION_ERROR`),this.details=t,this.name=`ForjaValidationError`}},o=class extends e{constructor(e=`Internal server error`,t=500){super(e,`SERVER_ERROR`),this.status=t,this.name=`ForjaServerError`}},s=class extends e{constructor(e=`Network error`,t){super(e,`NETWORK_ERROR`),this.cause=t,this.name=`ForjaNetworkError`}};function c(e,t,n){let r=e.replace(/\/+$/,``),i=t.startsWith(`/`)?t:`/${t}`,a=new URL(`${r}${i}`);if(n)for(let[e,t]of Object.entries(n))t!==void 0&&a.searchParams.set(e,t);return a.toString()}function l(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[u(n)]=String(r));return t}function u(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function d(e){let s;try{let t=await e.json();s=t.detail||t.message||t.title||e.statusText}catch{s=e.statusText}switch(e.status){case 401:throw new t(s);case 403:throw new n(s);case 404:throw new r(s);case 422:throw new a(s);case 429:{let t=e.headers.get(`retry-after`);throw new i(s,t?parseInt(t,10):void 0)}default:throw e.status,new o(s,e.status)}}function f(e){let t=e.fetch??globalThis.fetch,n=e.baseUrl.replace(/\/+$/,``),r={"X-API-Key":e.apiKey,"Content-Type":`application/json`};async function i(e,i,a,o){let l=c(n,i,a),u;try{u=await t(l,{method:e,headers:r,body:o===void 0?void 0:JSON.stringify(o)})}catch(e){throw new s(`Failed to connect to the Forja API`,e instanceof Error?e:void 0)}return u.ok?u:d(u)}return{get:(e,t)=>i(`GET`,e,t).then(e=>e.json()),getText:(e,t)=>i(`GET`,e,t).then(e=>e.text()),post:(e,t)=>i(`POST`,e,void 0,t).then(e=>e.json())}}function p(e,t,n){return{data:e,meta:t,async fetchNext(){if(t.page>=t.total_pages)return null;let e=await n(t.page+1);return p(e.data,e.meta,n)},async fetchAll(){let r=[...e],i=t.page;for(;i<t.total_pages;){i++;let e=await n(i);r.push(...e.data)}return r},async*[Symbol.asyncIterator](){yield{data:e,meta:t};let r=t.page;for(;r<t.total_pages;)r++,yield await n(r)}}}var m=class{constructor(e,t){this.http=e,this.siteId=t}async trackPageview(e){return this.http.post(`/sites/${this.siteId}/analytics/pageview`,e)}async getReport(e){let t=e?l({days:e.days,top_n:e.topN,start_date:e.startDate,end_date:e.endDate}):void 0;return this.http.get(`/sites/${this.siteId}/analytics/report`,t)}async getPageAnalytics(e){let t=l({path:e.path,days:e.days,start_date:e.startDate,end_date:e.endDate});return this.http.get(`/sites/${this.siteId}/analytics/report/page`,t)}},h=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=e?.localeId?{locale_id:e.localeId}:{},r=async e=>this.http.get(`/sites/${this.siteId}/blogs/published`,{...t,...n,page:String(e)}),i=await r(e?.page??1);return p(i.data,i.meta,r)}async listByCategory(e,t){let n=t?l(t):void 0,r=t?.localeId?{locale_id:t.localeId}:{},i=async t=>this.http.get(`/sites/${this.siteId}/blogs/published/category/${encodeURIComponent(e)}`,{...n,...r,page:String(t)}),a=await i(t?.page??1);return p(a.data,a.meta,i)}async listFeatured(e){return this.http.get(`/sites/${this.siteId}/blogs/featured`,e?.limit===void 0?void 0:{limit:String(e.limit)})}async listSimilar(e,t){return this.http.get(`/sites/${this.siteId}/blogs/${encodeURIComponent(e)}/similar`,t?.limit===void 0?void 0:{limit:String(t.limit)})}async getBySlug(e){try{let t=await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return await this.http.get(`/blogs/${t.id}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async get(e){try{return await this.http.get(`/blogs/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},g=class{constructor(e,t){this.http=e,this.siteId=t}async listSkills(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/skills`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getSkill(e){try{return await this.http.get(`/skills/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e){try{return await this.http.get(`/skills/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async listEntries(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/cv`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}},_=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/legal`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCookieConsent(){try{return await this.http.get(`/sites/${this.siteId}/legal/cookie-consent`)}catch(e){if(e instanceof r)return null;throw e}}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async getDetail(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},v=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/media`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/media/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},y=class{constructor(e,t){this.http=e,this.siteId=t}async listMenus(){return this.http.get(`/sites/${this.siteId}/menus`)}async getMenu(e){try{return await this.http.get(`/menus/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getMenuBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/menus/slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTree(e,t){return this.http.get(`/menus/${encodeURIComponent(e)}/tree`,t?.locale?{locale:t.locale}:void 0)}async listItems(e){return this.http.get(`/menus/${encodeURIComponent(e)}/items`)}async getItem(e){try{return await this.http.get(`/navigation/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},b=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/pages`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getByRoute(e){let t=e.startsWith(`/`)?e.slice(1):e;try{return await this.http.get(`/sites/${this.siteId}/pages/by-route/${encodeURIComponent(t)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSections(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections`)}async getSectionLocalizations(e){return this.http.get(`/pages/sections/${encodeURIComponent(e)}/localizations`)}async getPageSectionLocalizations(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections/localizations`)}},x=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/projects/public`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/projects/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},S=class{constructor(e,t){this.http=e,this.siteId=t}async lookup(e){try{return await this.http.get(`/sites/${this.siteId}/redirects/lookup`,{path:e})}catch(e){if(e instanceof r)return null;throw e}}},C=class{constructor(e,t){this.http=e,this.siteId=t}async get(){return this.http.get(`/sites/${this.siteId}`)}async listLocales(){return this.http.get(`/sites/${this.siteId}/locales`)}},w=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},T=class{constructor(e,t){this.http=e,this.siteId=t}async listTags(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/tags`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async listCategories(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/categories`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getCategoriesWithBlogCounts(){return this.http.get(`/sites/${this.siteId}/categories/blog-counts`)}async getContentTags(e){return this.http.get(`/content/${encodeURIComponent(e)}/tags`)}async getContentCategories(e){return this.http.get(`/content/${encodeURIComponent(e)}/categories`)}async getTag(e){try{return await this.http.get(`/tags/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTagBySlug(e){try{return await this.http.get(`/tags/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategory(e){try{return await this.http.get(`/categories/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategoryChildren(e){return this.http.get(`/categories/${encodeURIComponent(e)}/children`)}},E=class{constructor(e){let t=f(e);this.blogs=new h(t,e.siteId),this.pages=new b(t,e.siteId),this.navigation=new y(t,e.siteId),this.taxonomy=new T(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new g(t,e.siteId),this.legal=new _(t,e.siteId),this.projects=new x(t,e.siteId),this.redirects=new S(t,e.siteId),this.site=new C(t,e.siteId),this.media=new v(t,e.siteId),this.social=new w(t,e.siteId)}};export{r as a,o as c,s as i,a as l,t as n,n as o,e as r,i as s,E as t};
1
+ var e=class extends Error{constructor(e,t){super(e),this.code=t,this.name=`ForjaError`}},t=class extends e{constructor(e=`Invalid or missing API key`){super(e,`AUTH_ERROR`),this.name=`ForjaAuthError`}},n=class extends e{constructor(e=`Insufficient permissions`){super(e,`PERMISSION_ERROR`),this.name=`ForjaPermissionError`}},r=class extends e{constructor(e=`Resource not found`){super(e,`NOT_FOUND`),this.name=`ForjaNotFoundError`}},i=class extends e{constructor(e=`Rate limit exceeded`,t){super(e,`RATE_LIMIT`),this.retryAfter=t,this.name=`ForjaRateLimitError`}},a=class extends e{constructor(e=`Validation error`,t){super(e,`VALIDATION_ERROR`),this.details=t,this.name=`ForjaValidationError`}},o=class extends e{constructor(e=`Internal server error`,t=500){super(e,`SERVER_ERROR`),this.status=t,this.name=`ForjaServerError`}},s=class extends e{constructor(e=`Network error`,t){super(e,`NETWORK_ERROR`),this.cause=t,this.name=`ForjaNetworkError`}};function c(e,t,n){let r=e.replace(/\/+$/,``),i=t.startsWith(`/`)?t:`/${t}`,a=new URL(`${r}${i}`);if(n)for(let[e,t]of Object.entries(n))t!==void 0&&a.searchParams.set(e,t);return a.toString()}function l(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[u(n)]=String(r));return t}function u(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function d(e){let s;try{let t=await e.json();s=t.detail||t.message||t.title||e.statusText}catch{s=e.statusText}switch(e.status){case 401:throw new t(s);case 403:throw new n(s);case 404:throw new r(s);case 422:throw new a(s);case 429:{let t=e.headers.get(`retry-after`);throw new i(s,t?parseInt(t,10):void 0)}default:throw e.status,new o(s,e.status)}}function f(e){let t=e.fetch??globalThis.fetch,n=e.baseUrl.replace(/\/+$/,``),r={"X-API-Key":e.apiKey,"Content-Type":`application/json`};async function i(e,i,a,o){let l=c(n,i,a),u;try{u=await t(l,{method:e,headers:r,body:o===void 0?void 0:JSON.stringify(o)})}catch(e){throw new s(`Failed to connect to the Forja API`,e instanceof Error?e:void 0)}return u.ok?u:d(u)}return{get:(e,t)=>i(`GET`,e,t).then(e=>e.json()),getText:(e,t)=>i(`GET`,e,t).then(e=>e.text()),post:(e,t)=>i(`POST`,e,void 0,t).then(e=>e.json())}}function p(e,t,n){return{data:e,meta:t,async fetchNext(){if(t.page>=t.total_pages)return null;let e=await n(t.page+1);return p(e.data,e.meta,n)},async fetchAll(){let r=[...e],i=t.page;for(;i<t.total_pages;){i++;let e=await n(i);r.push(...e.data)}return r},async*[Symbol.asyncIterator](){yield{data:e,meta:t};let r=t.page;for(;r<t.total_pages;)r++,yield await n(r)}}}var m=class{constructor(e,t){this.http=e,this.siteId=t}async trackPageview(e){return this.http.post(`/sites/${this.siteId}/analytics/pageview`,e)}async getReport(e){let t=e?l({days:e.days,top_n:e.topN,start_date:e.startDate,end_date:e.endDate}):void 0;return this.http.get(`/sites/${this.siteId}/analytics/report`,t)}async getPageAnalytics(e){let t=l({path:e.path,days:e.days,start_date:e.startDate,end_date:e.endDate});return this.http.get(`/sites/${this.siteId}/analytics/report/page`,t)}},h=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=e?.localeId?{locale_id:e.localeId}:{},r=async e=>this.http.get(`/sites/${this.siteId}/blogs/published`,{...t,...n,page:String(e)}),i=await r(e?.page??1);return p(i.data,i.meta,r)}async listByCategory(e,t){let n=t?l(t):void 0,r=t?.localeId?{locale_id:t.localeId}:{},i=async t=>this.http.get(`/sites/${this.siteId}/blogs/published/category/${encodeURIComponent(e)}`,{...n,...r,page:String(t)}),a=await i(t?.page??1);return p(a.data,a.meta,i)}async listFeatured(e){return this.http.get(`/sites/${this.siteId}/blogs/featured`,e?.limit===void 0?void 0:{limit:String(e.limit)})}async listSimilar(e,t){return this.http.get(`/sites/${this.siteId}/blogs/${encodeURIComponent(e)}/similar`,t?.limit===void 0?void 0:{limit:String(t.limit)})}async getBySlug(e){try{let t=await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return await this.http.get(`/blogs/${t.id}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async get(e){try{return await this.http.get(`/blogs/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},g=class{constructor(e,t){this.http=e,this.siteId=t}async listSkills(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/skills`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getSkill(e){try{return await this.http.get(`/skills/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e){try{return await this.http.get(`/skills/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async listEntries(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/cv`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}},_=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/legal`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCookieConsent(){try{return await this.http.get(`/sites/${this.siteId}/legal/cookie-consent`)}catch(e){if(e instanceof r)return null;throw e}}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async getDetail(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},v=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/media`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/media/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},y=class{constructor(e,t){this.http=e,this.siteId=t}async listMenus(){return this.http.get(`/sites/${this.siteId}/menus`)}async getMenu(e){try{return await this.http.get(`/menus/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getMenuBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/menus/slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTree(e,t){return this.http.get(`/menus/${encodeURIComponent(e)}/tree`,t?.locale?{locale:t.locale}:void 0)}async listItems(e){return this.http.get(`/menus/${encodeURIComponent(e)}/items`)}async getItem(e){try{return await this.http.get(`/navigation/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},b=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/pages`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getByRoute(e){let t=e.startsWith(`/`)?e.slice(1):e;try{return await this.http.get(`/sites/${this.siteId}/pages/by-route/${encodeURIComponent(t)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSections(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections`)}async getSectionLocalizations(e){return this.http.get(`/pages/sections/${encodeURIComponent(e)}/localizations`)}async getPageSectionLocalizations(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections/localizations`)}},x=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/projects/public`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/projects/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},S=class{constructor(e,t){this.http=e,this.siteId=t}async lookup(e){try{return await this.http.get(`/sites/${this.siteId}/redirects/lookup`,{path:e})}catch(e){if(e instanceof r)return null;throw e}}},C=class{constructor(e,t){this.http=e,this.siteId=t}async get(){return this.http.get(`/sites/${this.siteId}`)}async listLocales(){return this.http.get(`/sites/${this.siteId}/locales`)}async getCodeInjection(){let e=await this.http.get(`/sites/${this.siteId}/settings`);return{code_injection_head:e.code_injection_head??``,code_injection_footer:e.code_injection_footer??``}}},w=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},T=class{constructor(e,t){this.http=e,this.siteId=t}async listTags(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/tags`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async listCategories(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/categories`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getCategoriesWithBlogCounts(){return this.http.get(`/sites/${this.siteId}/categories/blog-counts`)}async getContentTags(e){return this.http.get(`/content/${encodeURIComponent(e)}/tags`)}async getContentCategories(e){return this.http.get(`/content/${encodeURIComponent(e)}/categories`)}async getTag(e){try{return await this.http.get(`/tags/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTagBySlug(e){try{return await this.http.get(`/tags/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategory(e){try{return await this.http.get(`/categories/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategoryChildren(e){return this.http.get(`/categories/${encodeURIComponent(e)}/children`)}},E=class{constructor(e){let t=f(e);this.blogs=new h(t,e.siteId),this.pages=new b(t,e.siteId),this.navigation=new y(t,e.siteId),this.taxonomy=new T(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new g(t,e.siteId),this.legal=new _(t,e.siteId),this.projects=new x(t,e.siteId),this.redirects=new S(t,e.siteId),this.site=new C(t,e.siteId),this.media=new v(t,e.siteId),this.social=new w(t,e.siteId)}};export{r as a,o as c,s as i,a as l,t as n,n as o,e as r,i as s,E as t};
@@ -346,6 +346,13 @@ interface LegalDocumentWithGroups {
346
346
  document_type: LegalDocType;
347
347
  groups: LegalGroupWithItems[];
348
348
  }
349
+ /** Custom HTML/JS snippets configured for injection into page templates. */
350
+ interface CodeInjection {
351
+ /** HTML/JS to inject into <head> */
352
+ code_injection_head: string;
353
+ /** HTML/JS to inject before </body> */
354
+ code_injection_footer: string;
355
+ }
349
356
  interface SiteResponse {
350
357
  id: string;
351
358
  name: string;
@@ -1436,6 +1443,29 @@ declare class SiteResource {
1436
1443
  * ```
1437
1444
  */
1438
1445
  listLocales(): Promise<SiteLocaleResponse[]>;
1446
+ /**
1447
+ * Get code injection scripts configured for this site.
1448
+ *
1449
+ * **Endpoint:** `GET /sites/{siteId}/settings`
1450
+ *
1451
+ * Returns the custom HTML/JS snippets configured for injection into
1452
+ * the site's `<head>` and footer. Use these to embed analytics tags,
1453
+ * chat widgets, or any custom scripts into your template.
1454
+ *
1455
+ * Fields that are not configured on the server default to empty strings.
1456
+ *
1457
+ * Requires an API key with `Read` permission.
1458
+ *
1459
+ * @returns The code injection head and footer snippets.
1460
+ *
1461
+ * @example
1462
+ * ```ts
1463
+ * const injection = await forja.site.getCodeInjection();
1464
+ * // injection.code_injection_head → "<script>...</script>"
1465
+ * // injection.code_injection_footer → "<script>...</script>"
1466
+ * ```
1467
+ */
1468
+ getCodeInjection(): Promise<CodeInjection>;
1439
1469
  }
1440
1470
  //#endregion
1441
1471
  //#region src/resources/social.d.ts
@@ -1670,4 +1700,4 @@ declare class ForjaClient {
1670
1700
  constructor(config: ForjaClientConfig);
1671
1701
  }
1672
1702
  //#endregion
1673
- export { ProjectLocalizationResponse as $, LegalVersionResponse as A, NavigationTree as B, LegalDocumentDetailResponse as C, LegalGroupResponse as D, LegalDocumentWithGroups as E, MediaResponse as F, PageType as G, PageListItem as H, MediaVariantResponse as I, PaginationParams as J, Paginated as K, NavigationItemLocalizationResponse as L, LocalizationResponse as M, MediaListItem as N, LegalGroupWithItems as O, MediaListParams as P, ProjectListParams as Q, NavigationItemResponse as R, LegalDocType as S, LegalDocumentResponse as T, PageResponse as U, PageDetailResponse as V, PageSectionResponse as W, ProjectLinkResponse as X, ProjectDetailResponse as Y, ProjectLinkType as Z, CvEntryResponse as _, TranslationStatus as _t, AnalyticsPageParams as a, SearchablePaginationParams as at, ForjaClientConfig as b, BlogDetailResponse as c, SiteLocaleResponse as ct, BlogResponse as d, SkillResponse as dt, ProjectMediaResponse as et, CategoryResponse as f, SocialLinkResponse as ft, CvEntryParams as g, TrackPageviewResponse as gt, ContentStatus as h, TrackPageviewRequest as ht, AnalyticsPageDetailResponse as i, ReferrerItem as it, LocaleFilterParams as j, LegalItemResponse as k, BlogDocumentResponse as l, SiteResponse as lt, CategoryWithCountResponse as m, TopContentItem as mt, HttpClient as n, RedirectLookupResponse as nt, AnalyticsReportParams as o, SectionLocalizationResponse as ot, CategoryTree as p, TagResponse as pt, PaginationMeta as q, PaginatedResult as r, RedirectResponse as rt, AnalyticsReportResponse as s, SectionType as st, ForjaClient as t, ProjectResponse as tt, BlogListItem as u, SkillCategory as ut, CvEntryType as v, TrendDataPoint as vt, LegalDocumentFullDetailResponse as w, LegalDocLocalizationResponse as x, DocumentLocalizationResponse as y, NavigationMenuResponse as z };
1703
+ export { ProjectListParams as $, LegalItemResponse as A, NavigationMenuResponse as B, LegalDocType as C, LegalDocumentWithGroups as D, LegalDocumentResponse as E, MediaListParams as F, PageSectionResponse as G, PageDetailResponse as H, MediaResponse as I, PaginationMeta as J, PageType as K, MediaVariantResponse as L, LocaleFilterParams as M, LocalizationResponse as N, LegalGroupResponse as O, MediaListItem as P, ProjectLinkType as Q, NavigationItemLocalizationResponse as R, LegalDocLocalizationResponse as S, LegalDocumentFullDetailResponse as T, PageListItem as U, NavigationTree as V, PageResponse as W, ProjectDetailResponse as X, PaginationParams as Y, ProjectLinkResponse as Z, CvEntryParams as _, TrackPageviewResponse as _t, AnalyticsPageParams as a, ReferrerItem as at, DocumentLocalizationResponse as b, BlogDetailResponse as c, SectionType as ct, BlogResponse as d, SkillCategory as dt, ProjectLocalizationResponse as et, CategoryResponse as f, SkillResponse as ft, ContentStatus as g, TrackPageviewRequest as gt, CodeInjection as h, TopContentItem as ht, AnalyticsPageDetailResponse as i, RedirectResponse as it, LegalVersionResponse as j, LegalGroupWithItems as k, BlogDocumentResponse as l, SiteLocaleResponse as lt, CategoryWithCountResponse as m, TagResponse as mt, HttpClient as n, ProjectResponse as nt, AnalyticsReportParams as o, SearchablePaginationParams as ot, CategoryTree as p, SocialLinkResponse as pt, Paginated as q, PaginatedResult as r, RedirectLookupResponse as rt, AnalyticsReportResponse as s, SectionLocalizationResponse as st, ForjaClient as t, ProjectMediaResponse as tt, BlogListItem as u, SiteResponse as ut, CvEntryResponse as v, TranslationStatus as vt, LegalDocumentDetailResponse as w, ForjaClientConfig as x, CvEntryType as y, TrendDataPoint as yt, NavigationItemResponse as z };
@@ -1 +1 @@
1
- var e=class extends Error{constructor(e,t){super(e),this.code=t,this.name=`ForjaError`}},t=class extends e{constructor(e=`Invalid or missing API key`){super(e,`AUTH_ERROR`),this.name=`ForjaAuthError`}},n=class extends e{constructor(e=`Insufficient permissions`){super(e,`PERMISSION_ERROR`),this.name=`ForjaPermissionError`}},r=class extends e{constructor(e=`Resource not found`){super(e,`NOT_FOUND`),this.name=`ForjaNotFoundError`}},i=class extends e{constructor(e=`Rate limit exceeded`,t){super(e,`RATE_LIMIT`),this.retryAfter=t,this.name=`ForjaRateLimitError`}},a=class extends e{constructor(e=`Validation error`,t){super(e,`VALIDATION_ERROR`),this.details=t,this.name=`ForjaValidationError`}},o=class extends e{constructor(e=`Internal server error`,t=500){super(e,`SERVER_ERROR`),this.status=t,this.name=`ForjaServerError`}},s=class extends e{constructor(e=`Network error`,t){super(e,`NETWORK_ERROR`),this.cause=t,this.name=`ForjaNetworkError`}};function c(e,t,n){let r=e.replace(/\/+$/,``),i=t.startsWith(`/`)?t:`/${t}`,a=new URL(`${r}${i}`);if(n)for(let[e,t]of Object.entries(n))t!==void 0&&a.searchParams.set(e,t);return a.toString()}function l(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[u(n)]=String(r));return t}function u(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function d(e){let s;try{let t=await e.json();s=t.detail||t.message||t.title||e.statusText}catch{s=e.statusText}switch(e.status){case 401:throw new t(s);case 403:throw new n(s);case 404:throw new r(s);case 422:throw new a(s);case 429:{let t=e.headers.get(`retry-after`);throw new i(s,t?parseInt(t,10):void 0)}default:throw e.status,new o(s,e.status)}}function f(e){let t=e.fetch??globalThis.fetch,n=e.baseUrl.replace(/\/+$/,``),r={"X-API-Key":e.apiKey,"Content-Type":`application/json`};async function i(e,i,a,o){let l=c(n,i,a),u;try{u=await t(l,{method:e,headers:r,body:o===void 0?void 0:JSON.stringify(o)})}catch(e){throw new s(`Failed to connect to the Forja API`,e instanceof Error?e:void 0)}return u.ok?u:d(u)}return{get:(e,t)=>i(`GET`,e,t).then(e=>e.json()),getText:(e,t)=>i(`GET`,e,t).then(e=>e.text()),post:(e,t)=>i(`POST`,e,void 0,t).then(e=>e.json())}}function p(e,t,n){return{data:e,meta:t,async fetchNext(){if(t.page>=t.total_pages)return null;let e=await n(t.page+1);return p(e.data,e.meta,n)},async fetchAll(){let r=[...e],i=t.page;for(;i<t.total_pages;){i++;let e=await n(i);r.push(...e.data)}return r},async*[Symbol.asyncIterator](){yield{data:e,meta:t};let r=t.page;for(;r<t.total_pages;)r++,yield await n(r)}}}var m=class{constructor(e,t){this.http=e,this.siteId=t}async trackPageview(e){return this.http.post(`/sites/${this.siteId}/analytics/pageview`,e)}async getReport(e){let t=e?l({days:e.days,top_n:e.topN,start_date:e.startDate,end_date:e.endDate}):void 0;return this.http.get(`/sites/${this.siteId}/analytics/report`,t)}async getPageAnalytics(e){let t=l({path:e.path,days:e.days,start_date:e.startDate,end_date:e.endDate});return this.http.get(`/sites/${this.siteId}/analytics/report/page`,t)}},h=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=e?.localeId?{locale_id:e.localeId}:{},r=async e=>this.http.get(`/sites/${this.siteId}/blogs/published`,{...t,...n,page:String(e)}),i=await r(e?.page??1);return p(i.data,i.meta,r)}async listByCategory(e,t){let n=t?l(t):void 0,r=t?.localeId?{locale_id:t.localeId}:{},i=async t=>this.http.get(`/sites/${this.siteId}/blogs/published/category/${encodeURIComponent(e)}`,{...n,...r,page:String(t)}),a=await i(t?.page??1);return p(a.data,a.meta,i)}async listFeatured(e){return this.http.get(`/sites/${this.siteId}/blogs/featured`,e?.limit===void 0?void 0:{limit:String(e.limit)})}async listSimilar(e,t){return this.http.get(`/sites/${this.siteId}/blogs/${encodeURIComponent(e)}/similar`,t?.limit===void 0?void 0:{limit:String(t.limit)})}async getBySlug(e){try{let t=await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return await this.http.get(`/blogs/${t.id}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async get(e){try{return await this.http.get(`/blogs/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},g=class{constructor(e,t){this.http=e,this.siteId=t}async listSkills(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/skills`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getSkill(e){try{return await this.http.get(`/skills/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e){try{return await this.http.get(`/skills/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async listEntries(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/cv`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}},_=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/legal`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCookieConsent(){try{return await this.http.get(`/sites/${this.siteId}/legal/cookie-consent`)}catch(e){if(e instanceof r)return null;throw e}}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async getDetail(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},v=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/media`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/media/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},y=class{constructor(e,t){this.http=e,this.siteId=t}async listMenus(){return this.http.get(`/sites/${this.siteId}/menus`)}async getMenu(e){try{return await this.http.get(`/menus/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getMenuBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/menus/slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTree(e,t){return this.http.get(`/menus/${encodeURIComponent(e)}/tree`,t?.locale?{locale:t.locale}:void 0)}async listItems(e){return this.http.get(`/menus/${encodeURIComponent(e)}/items`)}async getItem(e){try{return await this.http.get(`/navigation/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},b=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/pages`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getByRoute(e){let t=e.startsWith(`/`)?e.slice(1):e;try{return await this.http.get(`/sites/${this.siteId}/pages/by-route/${encodeURIComponent(t)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSections(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections`)}async getSectionLocalizations(e){return this.http.get(`/pages/sections/${encodeURIComponent(e)}/localizations`)}async getPageSectionLocalizations(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections/localizations`)}},x=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/projects/public`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/projects/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},S=class{constructor(e,t){this.http=e,this.siteId=t}async lookup(e){try{return await this.http.get(`/sites/${this.siteId}/redirects/lookup`,{path:e})}catch(e){if(e instanceof r)return null;throw e}}},C=class{constructor(e,t){this.http=e,this.siteId=t}async get(){return this.http.get(`/sites/${this.siteId}`)}async listLocales(){return this.http.get(`/sites/${this.siteId}/locales`)}},w=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},T=class{constructor(e,t){this.http=e,this.siteId=t}async listTags(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/tags`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async listCategories(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/categories`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getCategoriesWithBlogCounts(){return this.http.get(`/sites/${this.siteId}/categories/blog-counts`)}async getContentTags(e){return this.http.get(`/content/${encodeURIComponent(e)}/tags`)}async getContentCategories(e){return this.http.get(`/content/${encodeURIComponent(e)}/categories`)}async getTag(e){try{return await this.http.get(`/tags/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTagBySlug(e){try{return await this.http.get(`/tags/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategory(e){try{return await this.http.get(`/categories/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategoryChildren(e){return this.http.get(`/categories/${encodeURIComponent(e)}/children`)}},E=class{constructor(e){let t=f(e);this.blogs=new h(t,e.siteId),this.pages=new b(t,e.siteId),this.navigation=new y(t,e.siteId),this.taxonomy=new T(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new g(t,e.siteId),this.legal=new _(t,e.siteId),this.projects=new x(t,e.siteId),this.redirects=new S(t,e.siteId),this.site=new C(t,e.siteId),this.media=new v(t,e.siteId),this.social=new w(t,e.siteId)}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return E}});
1
+ var e=class extends Error{constructor(e,t){super(e),this.code=t,this.name=`ForjaError`}},t=class extends e{constructor(e=`Invalid or missing API key`){super(e,`AUTH_ERROR`),this.name=`ForjaAuthError`}},n=class extends e{constructor(e=`Insufficient permissions`){super(e,`PERMISSION_ERROR`),this.name=`ForjaPermissionError`}},r=class extends e{constructor(e=`Resource not found`){super(e,`NOT_FOUND`),this.name=`ForjaNotFoundError`}},i=class extends e{constructor(e=`Rate limit exceeded`,t){super(e,`RATE_LIMIT`),this.retryAfter=t,this.name=`ForjaRateLimitError`}},a=class extends e{constructor(e=`Validation error`,t){super(e,`VALIDATION_ERROR`),this.details=t,this.name=`ForjaValidationError`}},o=class extends e{constructor(e=`Internal server error`,t=500){super(e,`SERVER_ERROR`),this.status=t,this.name=`ForjaServerError`}},s=class extends e{constructor(e=`Network error`,t){super(e,`NETWORK_ERROR`),this.cause=t,this.name=`ForjaNetworkError`}};function c(e,t,n){let r=e.replace(/\/+$/,``),i=t.startsWith(`/`)?t:`/${t}`,a=new URL(`${r}${i}`);if(n)for(let[e,t]of Object.entries(n))t!==void 0&&a.searchParams.set(e,t);return a.toString()}function l(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[u(n)]=String(r));return t}function u(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function d(e){let s;try{let t=await e.json();s=t.detail||t.message||t.title||e.statusText}catch{s=e.statusText}switch(e.status){case 401:throw new t(s);case 403:throw new n(s);case 404:throw new r(s);case 422:throw new a(s);case 429:{let t=e.headers.get(`retry-after`);throw new i(s,t?parseInt(t,10):void 0)}default:throw e.status,new o(s,e.status)}}function f(e){let t=e.fetch??globalThis.fetch,n=e.baseUrl.replace(/\/+$/,``),r={"X-API-Key":e.apiKey,"Content-Type":`application/json`};async function i(e,i,a,o){let l=c(n,i,a),u;try{u=await t(l,{method:e,headers:r,body:o===void 0?void 0:JSON.stringify(o)})}catch(e){throw new s(`Failed to connect to the Forja API`,e instanceof Error?e:void 0)}return u.ok?u:d(u)}return{get:(e,t)=>i(`GET`,e,t).then(e=>e.json()),getText:(e,t)=>i(`GET`,e,t).then(e=>e.text()),post:(e,t)=>i(`POST`,e,void 0,t).then(e=>e.json())}}function p(e,t,n){return{data:e,meta:t,async fetchNext(){if(t.page>=t.total_pages)return null;let e=await n(t.page+1);return p(e.data,e.meta,n)},async fetchAll(){let r=[...e],i=t.page;for(;i<t.total_pages;){i++;let e=await n(i);r.push(...e.data)}return r},async*[Symbol.asyncIterator](){yield{data:e,meta:t};let r=t.page;for(;r<t.total_pages;)r++,yield await n(r)}}}var m=class{constructor(e,t){this.http=e,this.siteId=t}async trackPageview(e){return this.http.post(`/sites/${this.siteId}/analytics/pageview`,e)}async getReport(e){let t=e?l({days:e.days,top_n:e.topN,start_date:e.startDate,end_date:e.endDate}):void 0;return this.http.get(`/sites/${this.siteId}/analytics/report`,t)}async getPageAnalytics(e){let t=l({path:e.path,days:e.days,start_date:e.startDate,end_date:e.endDate});return this.http.get(`/sites/${this.siteId}/analytics/report/page`,t)}},h=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=e?.localeId?{locale_id:e.localeId}:{},r=async e=>this.http.get(`/sites/${this.siteId}/blogs/published`,{...t,...n,page:String(e)}),i=await r(e?.page??1);return p(i.data,i.meta,r)}async listByCategory(e,t){let n=t?l(t):void 0,r=t?.localeId?{locale_id:t.localeId}:{},i=async t=>this.http.get(`/sites/${this.siteId}/blogs/published/category/${encodeURIComponent(e)}`,{...n,...r,page:String(t)}),a=await i(t?.page??1);return p(a.data,a.meta,i)}async listFeatured(e){return this.http.get(`/sites/${this.siteId}/blogs/featured`,e?.limit===void 0?void 0:{limit:String(e.limit)})}async listSimilar(e,t){return this.http.get(`/sites/${this.siteId}/blogs/${encodeURIComponent(e)}/similar`,t?.limit===void 0?void 0:{limit:String(t.limit)})}async getBySlug(e){try{let t=await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return await this.http.get(`/blogs/${t.id}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async get(e){try{return await this.http.get(`/blogs/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},g=class{constructor(e,t){this.http=e,this.siteId=t}async listSkills(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/skills`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getSkill(e){try{return await this.http.get(`/skills/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e){try{return await this.http.get(`/skills/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async listEntries(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/cv`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}},_=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/legal`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCookieConsent(){try{return await this.http.get(`/sites/${this.siteId}/legal/cookie-consent`)}catch(e){if(e instanceof r)return null;throw e}}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async getDetail(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},v=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/media`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/media/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},y=class{constructor(e,t){this.http=e,this.siteId=t}async listMenus(){return this.http.get(`/sites/${this.siteId}/menus`)}async getMenu(e){try{return await this.http.get(`/menus/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getMenuBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/menus/slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTree(e,t){return this.http.get(`/menus/${encodeURIComponent(e)}/tree`,t?.locale?{locale:t.locale}:void 0)}async listItems(e){return this.http.get(`/menus/${encodeURIComponent(e)}/items`)}async getItem(e){try{return await this.http.get(`/navigation/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},b=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/pages`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getByRoute(e){let t=e.startsWith(`/`)?e.slice(1):e;try{return await this.http.get(`/sites/${this.siteId}/pages/by-route/${encodeURIComponent(t)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSections(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections`)}async getSectionLocalizations(e){return this.http.get(`/pages/sections/${encodeURIComponent(e)}/localizations`)}async getPageSectionLocalizations(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections/localizations`)}},x=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/projects/public`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/projects/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},S=class{constructor(e,t){this.http=e,this.siteId=t}async lookup(e){try{return await this.http.get(`/sites/${this.siteId}/redirects/lookup`,{path:e})}catch(e){if(e instanceof r)return null;throw e}}},C=class{constructor(e,t){this.http=e,this.siteId=t}async get(){return this.http.get(`/sites/${this.siteId}`)}async listLocales(){return this.http.get(`/sites/${this.siteId}/locales`)}async getCodeInjection(){let e=await this.http.get(`/sites/${this.siteId}/settings`);return{code_injection_head:e.code_injection_head??``,code_injection_footer:e.code_injection_footer??``}}},w=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},T=class{constructor(e,t){this.http=e,this.siteId=t}async listTags(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/tags`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async listCategories(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/categories`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getCategoriesWithBlogCounts(){return this.http.get(`/sites/${this.siteId}/categories/blog-counts`)}async getContentTags(e){return this.http.get(`/content/${encodeURIComponent(e)}/tags`)}async getContentCategories(e){return this.http.get(`/content/${encodeURIComponent(e)}/categories`)}async getTag(e){try{return await this.http.get(`/tags/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTagBySlug(e){try{return await this.http.get(`/tags/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategory(e){try{return await this.http.get(`/categories/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategoryChildren(e){return this.http.get(`/categories/${encodeURIComponent(e)}/children`)}},E=class{constructor(e){let t=f(e);this.blogs=new h(t,e.siteId),this.pages=new b(t,e.siteId),this.navigation=new y(t,e.siteId),this.taxonomy=new T(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new g(t,e.siteId),this.legal=new _(t,e.siteId),this.projects=new x(t,e.siteId),this.redirects=new S(t,e.siteId),this.site=new C(t,e.siteId),this.media=new v(t,e.siteId),this.social=new w(t,e.siteId)}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return E}});
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./client-eFMh_n88.cjs`);exports.ForjaAuthError=e.n,exports.ForjaClient=e.t,exports.ForjaError=e.r,exports.ForjaNetworkError=e.i,exports.ForjaNotFoundError=e.a,exports.ForjaPermissionError=e.o,exports.ForjaRateLimitError=e.s,exports.ForjaServerError=e.c,exports.ForjaValidationError=e.l;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./client-_Ak79dHS.cjs`);function t(e){return{head:e.code_injection_head,footer:e.code_injection_footer}}exports.ForjaAuthError=e.n,exports.ForjaClient=e.t,exports.ForjaError=e.r,exports.ForjaNetworkError=e.i,exports.ForjaNotFoundError=e.a,exports.ForjaPermissionError=e.o,exports.ForjaRateLimitError=e.s,exports.ForjaServerError=e.c,exports.ForjaValidationError=e.l,exports.renderCodeInjection=t;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,38 @@
1
- import { $ as ProjectLocalizationResponse, A as LegalVersionResponse, B as NavigationTree, C as LegalDocumentDetailResponse, D as LegalGroupResponse, E as LegalDocumentWithGroups, F as MediaResponse, G as PageType, H as PageListItem, I as MediaVariantResponse, J as PaginationParams, K as Paginated, L as NavigationItemLocalizationResponse, M as LocalizationResponse, N as MediaListItem, O as LegalGroupWithItems, P as MediaListParams, Q as ProjectListParams, R as NavigationItemResponse, S as LegalDocType, T as LegalDocumentResponse, U as PageResponse, V as PageDetailResponse, W as PageSectionResponse, X as ProjectLinkResponse, Y as ProjectDetailResponse, Z as ProjectLinkType, _ as CvEntryResponse, _t as TranslationStatus, a as AnalyticsPageParams, at as SearchablePaginationParams, b as ForjaClientConfig, c as BlogDetailResponse, ct as SiteLocaleResponse, d as BlogResponse, dt as SkillResponse, et as ProjectMediaResponse, f as CategoryResponse, ft as SocialLinkResponse, g as CvEntryParams, gt as TrackPageviewResponse, h as ContentStatus, ht as TrackPageviewRequest, i as AnalyticsPageDetailResponse, it as ReferrerItem, j as LocaleFilterParams, k as LegalItemResponse, l as BlogDocumentResponse, lt as SiteResponse, m as CategoryWithCountResponse, mt as TopContentItem, n as HttpClient, nt as RedirectLookupResponse, o as AnalyticsReportParams, ot as SectionLocalizationResponse, p as CategoryTree, pt as TagResponse, q as PaginationMeta, r as PaginatedResult, rt as RedirectResponse, s as AnalyticsReportResponse, st as SectionType, t as ForjaClient, tt as ProjectResponse, u as BlogListItem, ut as SkillCategory, v as CvEntryType, vt as TrendDataPoint, w as LegalDocumentFullDetailResponse, x as LegalDocLocalizationResponse, y as DocumentLocalizationResponse, z as NavigationMenuResponse } from "./client-BBAKLM2r.cjs";
1
+ import { $ as ProjectListParams, A as LegalItemResponse, B as NavigationMenuResponse, C as LegalDocType, D as LegalDocumentWithGroups, E as LegalDocumentResponse, F as MediaListParams, G as PageSectionResponse, H as PageDetailResponse, I as MediaResponse, J as PaginationMeta, K as PageType, L as MediaVariantResponse, M as LocaleFilterParams, N as LocalizationResponse, O as LegalGroupResponse, P as MediaListItem, Q as ProjectLinkType, R as NavigationItemLocalizationResponse, S as LegalDocLocalizationResponse, T as LegalDocumentFullDetailResponse, U as PageListItem, V as NavigationTree, W as PageResponse, X as ProjectDetailResponse, Y as PaginationParams, Z as ProjectLinkResponse, _ as CvEntryParams, _t as TrackPageviewResponse, a as AnalyticsPageParams, at as ReferrerItem, b as DocumentLocalizationResponse, c as BlogDetailResponse, ct as SectionType, d as BlogResponse, dt as SkillCategory, et as ProjectLocalizationResponse, f as CategoryResponse, ft as SkillResponse, g as ContentStatus, gt as TrackPageviewRequest, h as CodeInjection, ht as TopContentItem, i as AnalyticsPageDetailResponse, it as RedirectResponse, j as LegalVersionResponse, k as LegalGroupWithItems, l as BlogDocumentResponse, lt as SiteLocaleResponse, m as CategoryWithCountResponse, mt as TagResponse, n as HttpClient, nt as ProjectResponse, o as AnalyticsReportParams, ot as SearchablePaginationParams, p as CategoryTree, pt as SocialLinkResponse, q as Paginated, r as PaginatedResult, rt as RedirectLookupResponse, s as AnalyticsReportResponse, st as SectionLocalizationResponse, t as ForjaClient, tt as ProjectMediaResponse, u as BlogListItem, ut as SiteResponse, v as CvEntryResponse, vt as TranslationStatus, w as LegalDocumentDetailResponse, x as ForjaClientConfig, y as CvEntryType, yt as TrendDataPoint, z as NavigationItemResponse } from "./client-B6llPNEv.cjs";
2
2
 
3
+ //#region src/code-injection.d.ts
4
+ /**
5
+ * Render code injection as HTML strings ready for embedding.
6
+ *
7
+ * Returns `{ head, footer }` where each is safe to insert via
8
+ * `set:html` in Astro or innerHTML in a trusted template context.
9
+ *
10
+ * **Important:** Code injection values come from the site's admin
11
+ * settings and are considered trusted (admin-authored) content.
12
+ *
13
+ * This is deliberately a thin pass-through to provide a clear API
14
+ * surface and a single place to add sanitization later.
15
+ *
16
+ * @example
17
+ * ```astro
18
+ * ---
19
+ * const injection = await forja.site.getCodeInjection();
20
+ * const { head, footer } = renderCodeInjection(injection);
21
+ * ---
22
+ * <head>
23
+ * <Fragment set:html={head} />
24
+ * </head>
25
+ * <body>
26
+ * <!-- page content -->
27
+ * <Fragment set:html={footer} />
28
+ * </body>
29
+ * ```
30
+ */
31
+ declare function renderCodeInjection(injection: CodeInjection): {
32
+ head: string;
33
+ footer: string;
34
+ };
35
+ //#endregion
3
36
  //#region src/errors.d.ts
4
37
  /**
5
38
  * Base error class for all Forja SDK errors.
@@ -11,6 +44,7 @@ declare class ForjaError extends Error {
11
44
  /** Machine-readable error code (e.g. `AUTH_ERROR`, `NOT_FOUND`). */
12
45
  readonly code: string;
13
46
  constructor(message: string, /** Machine-readable error code (e.g. `AUTH_ERROR`, `NOT_FOUND`). */
47
+
14
48
  code: string);
15
49
  }
16
50
  /**
@@ -101,4 +135,4 @@ declare class ForjaNetworkError extends ForjaError {
101
135
  constructor(message?: string, /** The underlying network error (e.g. `TypeError: Failed to fetch`). */cause?: Error | undefined);
102
136
  }
103
137
  //#endregion
104
- export { type AnalyticsPageDetailResponse, type AnalyticsPageParams, type AnalyticsReportParams, type AnalyticsReportResponse, type BlogDetailResponse, type BlogDocumentResponse, type BlogListItem, type BlogResponse, type CategoryResponse, type CategoryTree, type CategoryWithCountResponse, type ContentStatus, type CvEntryParams, type CvEntryResponse, type CvEntryType, type DocumentLocalizationResponse, ForjaAuthError, ForjaClient, type ForjaClientConfig, ForjaError, ForjaNetworkError, ForjaNotFoundError, ForjaPermissionError, ForjaRateLimitError, ForjaServerError, ForjaValidationError, type HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint };
138
+ export { type AnalyticsPageDetailResponse, type AnalyticsPageParams, type AnalyticsReportParams, type AnalyticsReportResponse, type BlogDetailResponse, type BlogDocumentResponse, type BlogListItem, type BlogResponse, type CategoryResponse, type CategoryTree, type CategoryWithCountResponse, type CodeInjection, type ContentStatus, type CvEntryParams, type CvEntryResponse, type CvEntryType, type DocumentLocalizationResponse, ForjaAuthError, ForjaClient, type ForjaClientConfig, ForjaError, ForjaNetworkError, ForjaNotFoundError, ForjaPermissionError, ForjaRateLimitError, ForjaServerError, ForjaValidationError, type HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint, renderCodeInjection };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,38 @@
1
- import { $ as ProjectLocalizationResponse, A as LegalVersionResponse, B as NavigationTree, C as LegalDocumentDetailResponse, D as LegalGroupResponse, E as LegalDocumentWithGroups, F as MediaResponse, G as PageType, H as PageListItem, I as MediaVariantResponse, J as PaginationParams, K as Paginated, L as NavigationItemLocalizationResponse, M as LocalizationResponse, N as MediaListItem, O as LegalGroupWithItems, P as MediaListParams, Q as ProjectListParams, R as NavigationItemResponse, S as LegalDocType, T as LegalDocumentResponse, U as PageResponse, V as PageDetailResponse, W as PageSectionResponse, X as ProjectLinkResponse, Y as ProjectDetailResponse, Z as ProjectLinkType, _ as CvEntryResponse, _t as TranslationStatus, a as AnalyticsPageParams, at as SearchablePaginationParams, b as ForjaClientConfig, c as BlogDetailResponse, ct as SiteLocaleResponse, d as BlogResponse, dt as SkillResponse, et as ProjectMediaResponse, f as CategoryResponse, ft as SocialLinkResponse, g as CvEntryParams, gt as TrackPageviewResponse, h as ContentStatus, ht as TrackPageviewRequest, i as AnalyticsPageDetailResponse, it as ReferrerItem, j as LocaleFilterParams, k as LegalItemResponse, l as BlogDocumentResponse, lt as SiteResponse, m as CategoryWithCountResponse, mt as TopContentItem, n as HttpClient, nt as RedirectLookupResponse, o as AnalyticsReportParams, ot as SectionLocalizationResponse, p as CategoryTree, pt as TagResponse, q as PaginationMeta, r as PaginatedResult, rt as RedirectResponse, s as AnalyticsReportResponse, st as SectionType, t as ForjaClient, tt as ProjectResponse, u as BlogListItem, ut as SkillCategory, v as CvEntryType, vt as TrendDataPoint, w as LegalDocumentFullDetailResponse, x as LegalDocLocalizationResponse, y as DocumentLocalizationResponse, z as NavigationMenuResponse } from "./client-d-QwwKUW.mjs";
1
+ import { $ as ProjectListParams, A as LegalItemResponse, B as NavigationMenuResponse, C as LegalDocType, D as LegalDocumentWithGroups, E as LegalDocumentResponse, F as MediaListParams, G as PageSectionResponse, H as PageDetailResponse, I as MediaResponse, J as PaginationMeta, K as PageType, L as MediaVariantResponse, M as LocaleFilterParams, N as LocalizationResponse, O as LegalGroupResponse, P as MediaListItem, Q as ProjectLinkType, R as NavigationItemLocalizationResponse, S as LegalDocLocalizationResponse, T as LegalDocumentFullDetailResponse, U as PageListItem, V as NavigationTree, W as PageResponse, X as ProjectDetailResponse, Y as PaginationParams, Z as ProjectLinkResponse, _ as CvEntryParams, _t as TrackPageviewResponse, a as AnalyticsPageParams, at as ReferrerItem, b as DocumentLocalizationResponse, c as BlogDetailResponse, ct as SectionType, d as BlogResponse, dt as SkillCategory, et as ProjectLocalizationResponse, f as CategoryResponse, ft as SkillResponse, g as ContentStatus, gt as TrackPageviewRequest, h as CodeInjection, ht as TopContentItem, i as AnalyticsPageDetailResponse, it as RedirectResponse, j as LegalVersionResponse, k as LegalGroupWithItems, l as BlogDocumentResponse, lt as SiteLocaleResponse, m as CategoryWithCountResponse, mt as TagResponse, n as HttpClient, nt as ProjectResponse, o as AnalyticsReportParams, ot as SearchablePaginationParams, p as CategoryTree, pt as SocialLinkResponse, q as Paginated, r as PaginatedResult, rt as RedirectLookupResponse, s as AnalyticsReportResponse, st as SectionLocalizationResponse, t as ForjaClient, tt as ProjectMediaResponse, u as BlogListItem, ut as SiteResponse, v as CvEntryResponse, vt as TranslationStatus, w as LegalDocumentDetailResponse, x as ForjaClientConfig, y as CvEntryType, yt as TrendDataPoint, z as NavigationItemResponse } from "./client-CyzDT4Ir.mjs";
2
2
 
3
+ //#region src/code-injection.d.ts
4
+ /**
5
+ * Render code injection as HTML strings ready for embedding.
6
+ *
7
+ * Returns `{ head, footer }` where each is safe to insert via
8
+ * `set:html` in Astro or innerHTML in a trusted template context.
9
+ *
10
+ * **Important:** Code injection values come from the site's admin
11
+ * settings and are considered trusted (admin-authored) content.
12
+ *
13
+ * This is deliberately a thin pass-through to provide a clear API
14
+ * surface and a single place to add sanitization later.
15
+ *
16
+ * @example
17
+ * ```astro
18
+ * ---
19
+ * const injection = await forja.site.getCodeInjection();
20
+ * const { head, footer } = renderCodeInjection(injection);
21
+ * ---
22
+ * <head>
23
+ * <Fragment set:html={head} />
24
+ * </head>
25
+ * <body>
26
+ * <!-- page content -->
27
+ * <Fragment set:html={footer} />
28
+ * </body>
29
+ * ```
30
+ */
31
+ declare function renderCodeInjection(injection: CodeInjection): {
32
+ head: string;
33
+ footer: string;
34
+ };
35
+ //#endregion
3
36
  //#region src/errors.d.ts
4
37
  /**
5
38
  * Base error class for all Forja SDK errors.
@@ -11,6 +44,7 @@ declare class ForjaError extends Error {
11
44
  /** Machine-readable error code (e.g. `AUTH_ERROR`, `NOT_FOUND`). */
12
45
  readonly code: string;
13
46
  constructor(message: string, /** Machine-readable error code (e.g. `AUTH_ERROR`, `NOT_FOUND`). */
47
+
14
48
  code: string);
15
49
  }
16
50
  /**
@@ -101,4 +135,4 @@ declare class ForjaNetworkError extends ForjaError {
101
135
  constructor(message?: string, /** The underlying network error (e.g. `TypeError: Failed to fetch`). */cause?: Error | undefined);
102
136
  }
103
137
  //#endregion
104
- export { type AnalyticsPageDetailResponse, type AnalyticsPageParams, type AnalyticsReportParams, type AnalyticsReportResponse, type BlogDetailResponse, type BlogDocumentResponse, type BlogListItem, type BlogResponse, type CategoryResponse, type CategoryTree, type CategoryWithCountResponse, type ContentStatus, type CvEntryParams, type CvEntryResponse, type CvEntryType, type DocumentLocalizationResponse, ForjaAuthError, ForjaClient, type ForjaClientConfig, ForjaError, ForjaNetworkError, ForjaNotFoundError, ForjaPermissionError, ForjaRateLimitError, ForjaServerError, ForjaValidationError, type HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint };
138
+ export { type AnalyticsPageDetailResponse, type AnalyticsPageParams, type AnalyticsReportParams, type AnalyticsReportResponse, type BlogDetailResponse, type BlogDocumentResponse, type BlogListItem, type BlogResponse, type CategoryResponse, type CategoryTree, type CategoryWithCountResponse, type CodeInjection, type ContentStatus, type CvEntryParams, type CvEntryResponse, type CvEntryType, type DocumentLocalizationResponse, ForjaAuthError, ForjaClient, type ForjaClientConfig, ForjaError, ForjaNetworkError, ForjaNotFoundError, ForjaPermissionError, ForjaRateLimitError, ForjaServerError, ForjaValidationError, type HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint, renderCodeInjection };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./client-DTfhjUoX.mjs";export{i as ForjaAuthError,c as ForjaClient,o as ForjaError,n as ForjaNetworkError,e as ForjaNotFoundError,a as ForjaPermissionError,s as ForjaRateLimitError,t as ForjaServerError,r as ForjaValidationError};
1
+ import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./client-C6mKwSKr.mjs";function l(e){return{head:e.code_injection_head,footer:e.code_injection_footer}}export{i as ForjaAuthError,c as ForjaClient,o as ForjaError,n as ForjaNetworkError,e as ForjaNotFoundError,a as ForjaPermissionError,s as ForjaRateLimitError,t as ForjaServerError,r as ForjaValidationError,l as renderCodeInjection};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forjacms/client",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Typed TypeScript SDK for the Forja CMS content API",
5
5
  "author": "Dominik Dorfstetter <dominik@dorfstetter.at>",
6
6
  "main": "dist/index.cjs",