@forjacms/client 1.8.2 → 2.0.0

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-DnYre1oI.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-BSWR_os4.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 { R as ForjaClientConfig, t as ForjaClient } from "../client-C-LeSLIx.cjs";
1
+ import { R as ForjaClientConfig, t as ForjaClient } from "../client-BoEyJL6_.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 { R as ForjaClientConfig, t as ForjaClient } from "../client-CWPMXGU3.mjs";
1
+ import { R as ForjaClientConfig, t as ForjaClient } from "../client-BoEyJL6_.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-BS9LwrFb.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-D9WF4wKY.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};
@@ -0,0 +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(/\/+$/,``),i={"X-API-Key":e.apiKey,"Content-Type":`application/json`};e.siteDomain&&(i[`X-Site-Domain`]=e.siteDomain);async function a(e,r,a,o){let l=c(n,r,a),u;try{u=await t(l,{method:e,headers:i,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)}function o(e,t){return a(`GET`,e,t).then(e=>e.json())}async function l(e,t){try{return await o(e,t)}catch(e){if(e instanceof r)return null;throw e}}return{get:o,getOrNull:l,getText:(e,t)=>a(`GET`,e,t).then(e=>e.text()),post:(e,t)=>a(`POST`,e,void 0,t).then(e=>e.json()),delete:e=>a(`DELETE`,e).then(()=>void 0)}}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,n){this.http=e,this.siteId=t,this.config=n}async paginate(e,t,n){let r=t?l(t):void 0,i=t=>this.http.get(e,{...r,...n,page:String(t)}),a=await i(t?.page??1);return p(a.data,a.meta,i)}async list(e){return this.paginate(this.config.listPath,e)}async getDetail(e,t){return this.http.getOrNull(`/${this.config.detailBase}/${encodeURIComponent(e)}/detail`,{locale:t?.locale})}},g=class extends h{constructor(e,t){super(e,t,{listPath:`/sites/${t}/blogs/published`,detailBase:`blogs`})}async listPublished(e){return this.paginate(`/sites/${this.siteId}/blogs/published`,e,e?.localeId?{locale_id:e.localeId}:void 0)}async listByCategory(e,t){return this.paginate(`/sites/${this.siteId}/blogs/published/category/${encodeURIComponent(e)}`,t,t?.localeId?{locale_id:t.localeId}:void 0)}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,t){let n=await this.http.getOrNull(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return n?this.http.getOrNull(`/blogs/${n.id}/detail`,{locale:t?.locale}):null}async get(e,t){return super.getDetail(e,t)}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},_=class{constructor(e,t,n){this.http=e,this.siteId=t,this.typeKey=n}base(){return`/sites/${this.siteId}/collections/${encodeURIComponent(this.typeKey)}`}async published(e){let t=async t=>this.http.get(`${this.base()}/published`,{...e?.locale?{locale:e.locale}:{},...e?.pageSize?{page_size:String(e.pageSize)}:{},page:String(t)}),n=await t(e?.page??1);return p(n.data,n.meta,t)}async bySlug(e,t){return this.http.getOrNull(`${this.base()}/by-slug/${encodeURIComponent(e)}`,{locale:t?.locale})}async schema(){return this.http.getOrNull(`${this.base()}/schema`)}},v=class extends h{constructor(e,t){super(e,t,{listPath:`/sites/${t}/cv`,detailBase:`cv`})}async listSkills(e){return this.paginate(`/sites/${this.siteId}/skills`,e)}async getSkill(e,t){return this.http.getOrNull(`/skills/${encodeURIComponent(e)}`,{locale:t?.locale})}async getSkillBySlug(e,t){return this.http.getOrNull(`/skills/by-slug/${encodeURIComponent(e)}`,{locale:t?.locale})}async listEntries(e){return this.paginate(`/sites/${this.siteId}/cv`,e)}async getEntry(e,t){return this.http.getOrNull(`/cv/${encodeURIComponent(e)}`,{locale:t?.locale})}async getEntryDetail(e,t){return super.getDetail(e,t)}},y=class{constructor(e){this.http=e}async getForm(e,t){let n=t?.locale?{locale:t.locale}:void 0;return this.http.get(`/public/forms/${encodeURIComponent(e)}`,n)}async getAltchaChallenge(e){return this.http.get(`/public/forms/${encodeURIComponent(e)}/altcha-challenge`)}async submitForm(e,t,n={}){return this.http.post(`/public/forms/${encodeURIComponent(e)}/submit`,{data:t,consent_given:n.consentGiven??!1,bot_protection_token:n.botProtectionToken})}async lookupSubmission(e){return this.http.post(`/public/submissions/lookup`,{reference_code:e})}async getSubmission(e){return this.http.get(`/public/submissions/${encodeURIComponent(e)}`)}async deleteSubmission(e){return this.http.delete(`/public/submissions/${encodeURIComponent(e)}`)}};const b=/^[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}$/;function x(e,t){let n={};for(let r of e.fields){let e=t[r.label],i=S(r,e);i&&(n[r.label]=i)}return n}function S(e,t){let n=t,r=n==null||typeof n==`string`&&n===``||Array.isArray(n)&&n.length===0;if((e.is_required||e.validation.required)&&r)return`${e.label} is required`;if(r)return null;switch(e.field_type){case`text`:case`textarea`:case`custom`:if(typeof n!=`string`)return`Must be a string`;if(e.validation.min_length!==void 0&&n.length<e.validation.min_length)return`Must be at least ${e.validation.min_length} characters`;if(e.validation.max_length!==void 0&&n.length>e.validation.max_length)return`Must be at most ${e.validation.max_length} characters`;if(e.validation.pattern)try{if(!new RegExp(e.validation.pattern).test(n))return`Value does not match the required pattern`}catch{return`Field has an invalid validation pattern`}return null;case`email`:return typeof n==`string`?b.test(n)?null:`Invalid email format`:`Must be a string`;case`number`:{let t=typeof n==`number`?n:Number(n);return Number.isNaN(t)?`Must be a number`:e.validation.min!==void 0&&t<e.validation.min?`Must be at least ${e.validation.min}`:e.validation.max!==void 0&&t>e.validation.max?`Must be at most ${e.validation.max}`:null}case`date`:return typeof n!=`string`||Number.isNaN(Date.parse(n))&&!/^\d{4}-\d{2}-\d{2}$/.test(n)?`Invalid date format`:null;case`select`:case`radio`:case`checkbox`:return null}}var C=class extends h{constructor(e,t){super(e,t,{listPath:`/sites/${t}/legal`,detailBase:`legal`})}async list(e){return this.paginate(`/sites/${this.siteId}/legal`,e)}async get(e){return this.http.getOrNull(`/legal/${encodeURIComponent(e)}`)}async getBySlug(e,t){return this.http.getOrNull(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`,{locale:t?.locale})}async getCookieConsent(){return this.http.getOrNull(`/sites/${this.siteId}/legal/cookie-consent`)}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},w=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){return this.http.getOrNull(`/media/${encodeURIComponent(e)}`)}},T=class{constructor(e,t){this.http=e,this.siteId=t}async listMenus(){return this.http.get(`/sites/${this.siteId}/menus`)}async getMenu(e){return this.http.getOrNull(`/menus/${encodeURIComponent(e)}`)}async getMenuBySlug(e){return this.http.getOrNull(`/sites/${this.siteId}/menus/slug/${encodeURIComponent(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){return this.http.getOrNull(`/navigation/${encodeURIComponent(e)}`)}},E=class extends h{constructor(e,t){super(e,t,{listPath:`/sites/${t}/pages`,detailBase:`pages`})}async list(e){return this.paginate(`/sites/${this.siteId}/pages`,e)}async getByRoute(e){let t=e.startsWith(`/`)?e.slice(1):e;return this.http.getOrNull(`/sites/${this.siteId}/pages/by-route/${encodeURIComponent(t)}`)}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`)}},D=class extends h{constructor(e,t){super(e,t,{listPath:`/sites/${t}/projects/public`,detailBase:`projects`})}async listPublished(e){return this.paginate(`/sites/${this.siteId}/projects/public`,e)}async get(e,t){return this.http.getOrNull(`/projects/${encodeURIComponent(e)}`,{locale:t?.locale})}async getBySlug(e,t){return this.http.getOrNull(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`,{locale:t?.locale})}},O=class{constructor(e,t){this.http=e,this.siteId=t}async lookup(e){return this.http.getOrNull(`/sites/${this.siteId}/redirects/lookup`,{path:e})}},k=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??``}}},A=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},j=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){return this.http.getOrNull(`/tags/${encodeURIComponent(e)}`)}async getTagBySlug(e){return this.http.getOrNull(`/tags/by-slug/${encodeURIComponent(e)}`)}async getCategory(e){return this.http.getOrNull(`/categories/${encodeURIComponent(e)}`)}async getCategoryChildren(e){return this.http.get(`/categories/${encodeURIComponent(e)}/children`)}},M=class{constructor(e){let t=f(e);this.http=t,this.siteId=e.siteId,this.blogs=new g(t,e.siteId),this.pages=new E(t,e.siteId),this.navigation=new T(t,e.siteId),this.taxonomy=new j(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new v(t,e.siteId),this.legal=new C(t,e.siteId),this.projects=new D(t,e.siteId),this.redirects=new O(t,e.siteId),this.site=new k(t,e.siteId),this.media=new w(t,e.siteId),this.social=new A(t,e.siteId),this.forms=new y(t)}collections(e){return new _(this.http,this.siteId,e)}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return o}});
@@ -684,6 +684,15 @@ interface LegalVersionResponse {
684
684
  interface HttpClient {
685
685
  /** Send a GET request. Query params with `undefined` values are omitted. */
686
686
  get<T>(path: string, params?: Record<string, string | undefined>): Promise<T>;
687
+ /**
688
+ * Send a GET request, resolving to `null` when the resource is not found
689
+ * (HTTP 404 / {@link ForjaNotFoundError}) instead of throwing. Every other
690
+ * error (auth, validation, server, network) still propagates.
691
+ *
692
+ * Centralizes the `404 -> null` discrimination that single-resource lookups
693
+ * need, so resource methods don't each hand-roll a try/catch.
694
+ */
695
+ getOrNull<T>(path: string, params?: Record<string, string | undefined>): Promise<T | null>;
687
696
  /** Send a GET request and return the response as plain text (for XML, HTML, etc.). */
688
697
  getText(path: string, params?: Record<string, string | undefined>): Promise<string>;
689
698
  /** Send a POST request with a JSON body. */
@@ -805,6 +814,58 @@ declare class AnalyticsResource {
805
814
  getPageAnalytics(params: AnalyticsPageParams): Promise<AnalyticsPageDetailResponse>;
806
815
  }
807
816
  //#endregion
817
+ //#region src/resources/content-resource.d.ts
818
+ /** Minimal shape every content list-params object satisfies. */
819
+ interface PaginationLike {
820
+ /** 1-indexed starting page. */
821
+ page?: number;
822
+ }
823
+ /** Optional locale resolver for detail lookups (ADR 0002). */
824
+ interface DetailParams {
825
+ locale?: string;
826
+ }
827
+ /**
828
+ * Per-entity endpoint configuration for {@link ContentResource}.
829
+ */
830
+ interface ContentResourceConfig {
831
+ /** Full path of the primary list endpoint, e.g. `/sites/{siteId}/blogs/published`. */
832
+ listPath: string;
833
+ /** Base segment for detail-by-id: `/{detailBase}/{id}/detail` (e.g. `blogs`). */
834
+ detailBase: string;
835
+ }
836
+ /**
837
+ * Generic base for the public client SDK's content resources.
838
+ *
839
+ * Owns the CRUD-read + pagination scaffold shared verbatim across the entity
840
+ * resources (`list` / `get` / `getDetail` / `getBySlug`), so each entity class
841
+ * extends this and adds only its extras (`listFeatured`, `listSimilar`,
842
+ * `getSections`, …) while keeping its current public method names. Slug lookups
843
+ * stay per-entity: their paths, step count (blog resolves slug→id→detail), and
844
+ * return shape (list vs detail) genuinely differ, so they aren't on the base.
845
+ *
846
+ * @typeParam TList - The list-item shape returned by the list endpoint.
847
+ * @typeParam TDetail - The detail shape returned by `/{detailBase}/{id}/detail`.
848
+ */
849
+ declare class ContentResource<TList, TDetail> {
850
+ protected readonly http: HttpClient;
851
+ protected readonly siteId: string;
852
+ protected readonly config: ContentResourceConfig;
853
+ constructor(http: HttpClient, siteId: string, config: ContentResourceConfig);
854
+ /**
855
+ * The shared pagination scaffold: build a `fetchPage` closure over `path`
856
+ * and wrap the first page in a {@link PaginatedResult}. Subclasses reuse this
857
+ * for their bespoke list endpoints (category/featured/etc.).
858
+ */
859
+ protected paginate<T, P extends PaginationLike = PaginationLike>(path: string, params?: P, extraQuery?: Record<string, string | undefined>): Promise<PaginatedResult<T>>;
860
+ /** Fetch the primary paginated list (the configured `listPath`). */
861
+ list<P extends PaginationLike = PaginationLike>(params?: P): Promise<PaginatedResult<TList>>;
862
+ /**
863
+ * Fetch an entity's full detail by UUID (`/{detailBase}/{id}/detail`).
864
+ * Returns `null` on 404; every other transport error propagates.
865
+ */
866
+ getDetail(id: string, params?: DetailParams): Promise<TDetail | null>;
867
+ }
868
+ //#endregion
808
869
  //#region src/resources/blogs.d.ts
809
870
  /**
810
871
  * Blog post operations.
@@ -814,9 +875,7 @@ declare class AnalyticsResource {
814
875
  *
815
876
  * All read operations require an API key with `Read` permission.
816
877
  */
817
- declare class BlogsResource {
818
- private readonly http;
819
- private readonly siteId;
878
+ declare class BlogsResource extends ContentResource<BlogListItem, BlogDetailResponse> {
820
879
  constructor(http: HttpClient, siteId: string);
821
880
  /**
822
881
  * Fetch a paginated list of published blog posts.
@@ -1011,9 +1070,7 @@ declare class CollectionsResource {
1011
1070
  *
1012
1071
  * All operations require an API key with `Read` permission.
1013
1072
  */
1014
- declare class CvResource {
1015
- private readonly http;
1016
- private readonly siteId;
1073
+ declare class CvResource extends ContentResource<CvEntryResponse, CvEntryResponse> {
1017
1074
  constructor(http: HttpClient, siteId: string);
1018
1075
  /**
1019
1076
  * Fetch a paginated list of skills.
@@ -1089,6 +1146,21 @@ declare class CvResource {
1089
1146
  * ```
1090
1147
  */
1091
1148
  getEntry(id: string, params?: CvEntryDetailParams): Promise<CvEntryResponse | null>;
1149
+ /**
1150
+ * Fetch a CV entry's full detail by its UUID.
1151
+ *
1152
+ * **Endpoint:** `GET /cv/{id}/detail`
1153
+ *
1154
+ * For CV entries the detail shape is identical to the lightweight
1155
+ * {@link getEntry} shape — the relational graph is bounded, so the
1156
+ * `/detail` route exists purely for uniformity across content types
1157
+ * (ADR 0003).
1158
+ *
1159
+ * @param id - The CV entry's UUID.
1160
+ * @param params - Optional locale resolver per ADR 0002.
1161
+ * @returns The CV entry detail, or `null` if not found.
1162
+ */
1163
+ getEntryDetail(id: string, params?: CvEntryDetailParams): Promise<CvEntryResponse | null>;
1092
1164
  }
1093
1165
  //#endregion
1094
1166
  //#region src/resources/forms.d.ts
@@ -1234,9 +1306,7 @@ declare function validateSubmission(form: PublicFormDefinition, data: FormSubmit
1234
1306
  *
1235
1307
  * All operations require an API key with `Read` permission.
1236
1308
  */
1237
- declare class LegalResource {
1238
- private readonly http;
1239
- private readonly siteId;
1309
+ declare class LegalResource extends ContentResource<LegalDocumentResponse, LegalDocumentFullDetailResponse> {
1240
1310
  constructor(http: HttpClient, siteId: string);
1241
1311
  /**
1242
1312
  * Fetch a paginated list of legal documents for the site.
@@ -1318,30 +1388,6 @@ declare class LegalResource {
1318
1388
  * @returns Array of consent items (cookie name, required flag, display order).
1319
1389
  */
1320
1390
  getGroupItems(groupId: string): Promise<LegalItemResponse[]>;
1321
- /**
1322
- * Fetch the full detail of a legal document, including content localizations.
1323
- *
1324
- * **Endpoint:** `GET /legal/{id}/detail`
1325
- *
1326
- * Unlike {@link get}, this returns the full content body localizations
1327
- * (rendered text), document status, slug, version, and publish window.
1328
- * Use for rendering the full legal document page.
1329
- *
1330
- * @param id - The legal document's UUID.
1331
- * @returns The full document detail with content and doc localizations, or `null` if not found.
1332
- *
1333
- * @example
1334
- * ```ts
1335
- * const detail = await forja.legal.getDetail('doc-uuid');
1336
- * if (detail) {
1337
- * console.log(detail.version); // 3
1338
- * console.log(detail.document_type); // "PrivacyPolicy"
1339
- * console.log(detail.localizations); // content body per locale
1340
- * console.log(detail.doc_localizations); // title + intro per locale
1341
- * }
1342
- * ```
1343
- */
1344
- getDetail(id: string, params?: LegalDetailParams): Promise<LegalDocumentFullDetailResponse | null>;
1345
1391
  /**
1346
1392
  * Fetch the version history of a legal document.
1347
1393
  *
@@ -1539,19 +1585,6 @@ interface PageListParams extends SearchablePaginationParams {
1539
1585
  /** Exclude pages with this status. */
1540
1586
  excludeStatus?: string;
1541
1587
  }
1542
- /**
1543
- * Options for page-detail lookups (`getDetail`). The list shape
1544
- * (`PageResponse`) does not carry `localizations[]` today — adding it is
1545
- * tracked as a separate canonicalization gap; until then the resolver
1546
- * applies only to the detail endpoint.
1547
- */
1548
- interface PageDetailParams {
1549
- /**
1550
- * Optional locale code (e.g. `"en"`). When set, `localizations[]`
1551
- * collapses to one resolved entry. See ADR 0002.
1552
- */
1553
- locale?: string;
1554
- }
1555
1588
  /**
1556
1589
  * CMS page operations.
1557
1590
  *
@@ -1560,9 +1593,7 @@ interface PageDetailParams {
1560
1593
  *
1561
1594
  * All operations require an API key with `Read` permission.
1562
1595
  */
1563
- declare class PagesResource {
1564
- private readonly http;
1565
- private readonly siteId;
1596
+ declare class PagesResource extends ContentResource<PageListItem, PageDetailResponse> {
1566
1597
  constructor(http: HttpClient, siteId: string);
1567
1598
  /**
1568
1599
  * Fetch a paginated list of CMS pages.
@@ -1598,25 +1629,6 @@ declare class PagesResource {
1598
1629
  * ```
1599
1630
  */
1600
1631
  getByRoute(route: string): Promise<PageDetailResponse | null>;
1601
- /**
1602
- * Fetch a page's full detail (content localizations + computed OG image).
1603
- *
1604
- * **Endpoint:** `GET /pages/{id}/detail`
1605
- *
1606
- * @param id - The page's UUID.
1607
- * @param params - Optional locale resolver (ADR 0002).
1608
- * @returns The page detail, or `null` if not found.
1609
- *
1610
- * @example
1611
- * ```ts
1612
- * // Every localization (admin/editor use case)
1613
- * const detail = await forja.pages.getDetail('page-uuid');
1614
- *
1615
- * // Server-side rendering — single locale
1616
- * const en = await forja.pages.getDetail('page-uuid', { locale: 'en' });
1617
- * ```
1618
- */
1619
- getDetail(id: string, params?: PageDetailParams): Promise<PageDetailResponse | null>;
1620
1632
  /**
1621
1633
  * Fetch all sections for a page.
1622
1634
  *
@@ -1661,9 +1673,7 @@ declare class PagesResource {
1661
1673
  *
1662
1674
  * All read operations require an API key with `Read` permission.
1663
1675
  */
1664
- declare class ProjectsResource {
1665
- private readonly http;
1666
- private readonly siteId;
1676
+ declare class ProjectsResource extends ContentResource<ProjectResponse, ProjectDetailResponse> {
1667
1677
  constructor(http: HttpClient, siteId: string);
1668
1678
  /**
1669
1679
  * Fetch a paginated list of published projects.
@@ -1697,16 +1707,18 @@ declare class ProjectsResource {
1697
1707
  */
1698
1708
  listPublished(params?: ProjectListParams): Promise<PaginatedResult<ProjectResponse>>;
1699
1709
  /**
1700
- * Fetch a project's full detail by its UUID.
1710
+ * Fetch a project (lightweight list shape) by its UUID.
1701
1711
  *
1702
1712
  * **Endpoint:** `GET /projects/{id}`
1703
1713
  *
1704
- * Returns the complete project with localizations (title, description per locale),
1705
- * external links (repository, demo, docs), media attachments (cover image,
1706
- * screenshots), and associations to skills and CV entries.
1714
+ * Returns the list-shape project: scalar fields, `skill_ids`, and
1715
+ * `localizations` (title, description per locale). The relational graph
1716
+ * held off the list `links`, `media`, `cv_entry_ids` — is available
1717
+ * via {@link getDetail} (ADR 0001 / ADR 0003).
1707
1718
  *
1708
1719
  * @param id - The project's UUID.
1709
- * @returns The full project detail, or `null` if not found.
1720
+ * @param params - Optional locale resolver per ADR 0002.
1721
+ * @returns The project (lightweight), or `null` if not found.
1710
1722
  *
1711
1723
  * @example
1712
1724
  * ```ts
@@ -1714,11 +1726,10 @@ declare class ProjectsResource {
1714
1726
  * if (project) {
1715
1727
  * const loc = project.localizations.find(l => l.locale_id === localeId);
1716
1728
  * console.log(loc?.title, loc?.short_description);
1717
- * console.log(project.links); // [{ label, url, link_type }]
1718
1729
  * }
1719
1730
  * ```
1720
1731
  */
1721
- get(id: string, params?: ProjectDetailParams): Promise<ProjectDetailResponse | null>;
1732
+ get(id: string, params?: ProjectDetailParams): Promise<ProjectResponse | null>;
1722
1733
  /**
1723
1734
  * Fetch a project by its URL slug.
1724
1735
  *
@@ -684,6 +684,15 @@ interface LegalVersionResponse {
684
684
  interface HttpClient {
685
685
  /** Send a GET request. Query params with `undefined` values are omitted. */
686
686
  get<T>(path: string, params?: Record<string, string | undefined>): Promise<T>;
687
+ /**
688
+ * Send a GET request, resolving to `null` when the resource is not found
689
+ * (HTTP 404 / {@link ForjaNotFoundError}) instead of throwing. Every other
690
+ * error (auth, validation, server, network) still propagates.
691
+ *
692
+ * Centralizes the `404 -> null` discrimination that single-resource lookups
693
+ * need, so resource methods don't each hand-roll a try/catch.
694
+ */
695
+ getOrNull<T>(path: string, params?: Record<string, string | undefined>): Promise<T | null>;
687
696
  /** Send a GET request and return the response as plain text (for XML, HTML, etc.). */
688
697
  getText(path: string, params?: Record<string, string | undefined>): Promise<string>;
689
698
  /** Send a POST request with a JSON body. */
@@ -805,6 +814,58 @@ declare class AnalyticsResource {
805
814
  getPageAnalytics(params: AnalyticsPageParams): Promise<AnalyticsPageDetailResponse>;
806
815
  }
807
816
  //#endregion
817
+ //#region src/resources/content-resource.d.ts
818
+ /** Minimal shape every content list-params object satisfies. */
819
+ interface PaginationLike {
820
+ /** 1-indexed starting page. */
821
+ page?: number;
822
+ }
823
+ /** Optional locale resolver for detail lookups (ADR 0002). */
824
+ interface DetailParams {
825
+ locale?: string;
826
+ }
827
+ /**
828
+ * Per-entity endpoint configuration for {@link ContentResource}.
829
+ */
830
+ interface ContentResourceConfig {
831
+ /** Full path of the primary list endpoint, e.g. `/sites/{siteId}/blogs/published`. */
832
+ listPath: string;
833
+ /** Base segment for detail-by-id: `/{detailBase}/{id}/detail` (e.g. `blogs`). */
834
+ detailBase: string;
835
+ }
836
+ /**
837
+ * Generic base for the public client SDK's content resources.
838
+ *
839
+ * Owns the CRUD-read + pagination scaffold shared verbatim across the entity
840
+ * resources (`list` / `get` / `getDetail` / `getBySlug`), so each entity class
841
+ * extends this and adds only its extras (`listFeatured`, `listSimilar`,
842
+ * `getSections`, …) while keeping its current public method names. Slug lookups
843
+ * stay per-entity: their paths, step count (blog resolves slug→id→detail), and
844
+ * return shape (list vs detail) genuinely differ, so they aren't on the base.
845
+ *
846
+ * @typeParam TList - The list-item shape returned by the list endpoint.
847
+ * @typeParam TDetail - The detail shape returned by `/{detailBase}/{id}/detail`.
848
+ */
849
+ declare class ContentResource<TList, TDetail> {
850
+ protected readonly http: HttpClient;
851
+ protected readonly siteId: string;
852
+ protected readonly config: ContentResourceConfig;
853
+ constructor(http: HttpClient, siteId: string, config: ContentResourceConfig);
854
+ /**
855
+ * The shared pagination scaffold: build a `fetchPage` closure over `path`
856
+ * and wrap the first page in a {@link PaginatedResult}. Subclasses reuse this
857
+ * for their bespoke list endpoints (category/featured/etc.).
858
+ */
859
+ protected paginate<T, P extends PaginationLike = PaginationLike>(path: string, params?: P, extraQuery?: Record<string, string | undefined>): Promise<PaginatedResult<T>>;
860
+ /** Fetch the primary paginated list (the configured `listPath`). */
861
+ list<P extends PaginationLike = PaginationLike>(params?: P): Promise<PaginatedResult<TList>>;
862
+ /**
863
+ * Fetch an entity's full detail by UUID (`/{detailBase}/{id}/detail`).
864
+ * Returns `null` on 404; every other transport error propagates.
865
+ */
866
+ getDetail(id: string, params?: DetailParams): Promise<TDetail | null>;
867
+ }
868
+ //#endregion
808
869
  //#region src/resources/blogs.d.ts
809
870
  /**
810
871
  * Blog post operations.
@@ -814,9 +875,7 @@ declare class AnalyticsResource {
814
875
  *
815
876
  * All read operations require an API key with `Read` permission.
816
877
  */
817
- declare class BlogsResource {
818
- private readonly http;
819
- private readonly siteId;
878
+ declare class BlogsResource extends ContentResource<BlogListItem, BlogDetailResponse> {
820
879
  constructor(http: HttpClient, siteId: string);
821
880
  /**
822
881
  * Fetch a paginated list of published blog posts.
@@ -1011,9 +1070,7 @@ declare class CollectionsResource {
1011
1070
  *
1012
1071
  * All operations require an API key with `Read` permission.
1013
1072
  */
1014
- declare class CvResource {
1015
- private readonly http;
1016
- private readonly siteId;
1073
+ declare class CvResource extends ContentResource<CvEntryResponse, CvEntryResponse> {
1017
1074
  constructor(http: HttpClient, siteId: string);
1018
1075
  /**
1019
1076
  * Fetch a paginated list of skills.
@@ -1089,6 +1146,21 @@ declare class CvResource {
1089
1146
  * ```
1090
1147
  */
1091
1148
  getEntry(id: string, params?: CvEntryDetailParams): Promise<CvEntryResponse | null>;
1149
+ /**
1150
+ * Fetch a CV entry's full detail by its UUID.
1151
+ *
1152
+ * **Endpoint:** `GET /cv/{id}/detail`
1153
+ *
1154
+ * For CV entries the detail shape is identical to the lightweight
1155
+ * {@link getEntry} shape — the relational graph is bounded, so the
1156
+ * `/detail` route exists purely for uniformity across content types
1157
+ * (ADR 0003).
1158
+ *
1159
+ * @param id - The CV entry's UUID.
1160
+ * @param params - Optional locale resolver per ADR 0002.
1161
+ * @returns The CV entry detail, or `null` if not found.
1162
+ */
1163
+ getEntryDetail(id: string, params?: CvEntryDetailParams): Promise<CvEntryResponse | null>;
1092
1164
  }
1093
1165
  //#endregion
1094
1166
  //#region src/resources/forms.d.ts
@@ -1234,9 +1306,7 @@ declare function validateSubmission(form: PublicFormDefinition, data: FormSubmit
1234
1306
  *
1235
1307
  * All operations require an API key with `Read` permission.
1236
1308
  */
1237
- declare class LegalResource {
1238
- private readonly http;
1239
- private readonly siteId;
1309
+ declare class LegalResource extends ContentResource<LegalDocumentResponse, LegalDocumentFullDetailResponse> {
1240
1310
  constructor(http: HttpClient, siteId: string);
1241
1311
  /**
1242
1312
  * Fetch a paginated list of legal documents for the site.
@@ -1318,30 +1388,6 @@ declare class LegalResource {
1318
1388
  * @returns Array of consent items (cookie name, required flag, display order).
1319
1389
  */
1320
1390
  getGroupItems(groupId: string): Promise<LegalItemResponse[]>;
1321
- /**
1322
- * Fetch the full detail of a legal document, including content localizations.
1323
- *
1324
- * **Endpoint:** `GET /legal/{id}/detail`
1325
- *
1326
- * Unlike {@link get}, this returns the full content body localizations
1327
- * (rendered text), document status, slug, version, and publish window.
1328
- * Use for rendering the full legal document page.
1329
- *
1330
- * @param id - The legal document's UUID.
1331
- * @returns The full document detail with content and doc localizations, or `null` if not found.
1332
- *
1333
- * @example
1334
- * ```ts
1335
- * const detail = await forja.legal.getDetail('doc-uuid');
1336
- * if (detail) {
1337
- * console.log(detail.version); // 3
1338
- * console.log(detail.document_type); // "PrivacyPolicy"
1339
- * console.log(detail.localizations); // content body per locale
1340
- * console.log(detail.doc_localizations); // title + intro per locale
1341
- * }
1342
- * ```
1343
- */
1344
- getDetail(id: string, params?: LegalDetailParams): Promise<LegalDocumentFullDetailResponse | null>;
1345
1391
  /**
1346
1392
  * Fetch the version history of a legal document.
1347
1393
  *
@@ -1539,19 +1585,6 @@ interface PageListParams extends SearchablePaginationParams {
1539
1585
  /** Exclude pages with this status. */
1540
1586
  excludeStatus?: string;
1541
1587
  }
1542
- /**
1543
- * Options for page-detail lookups (`getDetail`). The list shape
1544
- * (`PageResponse`) does not carry `localizations[]` today — adding it is
1545
- * tracked as a separate canonicalization gap; until then the resolver
1546
- * applies only to the detail endpoint.
1547
- */
1548
- interface PageDetailParams {
1549
- /**
1550
- * Optional locale code (e.g. `"en"`). When set, `localizations[]`
1551
- * collapses to one resolved entry. See ADR 0002.
1552
- */
1553
- locale?: string;
1554
- }
1555
1588
  /**
1556
1589
  * CMS page operations.
1557
1590
  *
@@ -1560,9 +1593,7 @@ interface PageDetailParams {
1560
1593
  *
1561
1594
  * All operations require an API key with `Read` permission.
1562
1595
  */
1563
- declare class PagesResource {
1564
- private readonly http;
1565
- private readonly siteId;
1596
+ declare class PagesResource extends ContentResource<PageListItem, PageDetailResponse> {
1566
1597
  constructor(http: HttpClient, siteId: string);
1567
1598
  /**
1568
1599
  * Fetch a paginated list of CMS pages.
@@ -1598,25 +1629,6 @@ declare class PagesResource {
1598
1629
  * ```
1599
1630
  */
1600
1631
  getByRoute(route: string): Promise<PageDetailResponse | null>;
1601
- /**
1602
- * Fetch a page's full detail (content localizations + computed OG image).
1603
- *
1604
- * **Endpoint:** `GET /pages/{id}/detail`
1605
- *
1606
- * @param id - The page's UUID.
1607
- * @param params - Optional locale resolver (ADR 0002).
1608
- * @returns The page detail, or `null` if not found.
1609
- *
1610
- * @example
1611
- * ```ts
1612
- * // Every localization (admin/editor use case)
1613
- * const detail = await forja.pages.getDetail('page-uuid');
1614
- *
1615
- * // Server-side rendering — single locale
1616
- * const en = await forja.pages.getDetail('page-uuid', { locale: 'en' });
1617
- * ```
1618
- */
1619
- getDetail(id: string, params?: PageDetailParams): Promise<PageDetailResponse | null>;
1620
1632
  /**
1621
1633
  * Fetch all sections for a page.
1622
1634
  *
@@ -1661,9 +1673,7 @@ declare class PagesResource {
1661
1673
  *
1662
1674
  * All read operations require an API key with `Read` permission.
1663
1675
  */
1664
- declare class ProjectsResource {
1665
- private readonly http;
1666
- private readonly siteId;
1676
+ declare class ProjectsResource extends ContentResource<ProjectResponse, ProjectDetailResponse> {
1667
1677
  constructor(http: HttpClient, siteId: string);
1668
1678
  /**
1669
1679
  * Fetch a paginated list of published projects.
@@ -1697,16 +1707,18 @@ declare class ProjectsResource {
1697
1707
  */
1698
1708
  listPublished(params?: ProjectListParams): Promise<PaginatedResult<ProjectResponse>>;
1699
1709
  /**
1700
- * Fetch a project's full detail by its UUID.
1710
+ * Fetch a project (lightweight list shape) by its UUID.
1701
1711
  *
1702
1712
  * **Endpoint:** `GET /projects/{id}`
1703
1713
  *
1704
- * Returns the complete project with localizations (title, description per locale),
1705
- * external links (repository, demo, docs), media attachments (cover image,
1706
- * screenshots), and associations to skills and CV entries.
1714
+ * Returns the list-shape project: scalar fields, `skill_ids`, and
1715
+ * `localizations` (title, description per locale). The relational graph
1716
+ * held off the list `links`, `media`, `cv_entry_ids` — is available
1717
+ * via {@link getDetail} (ADR 0001 / ADR 0003).
1707
1718
  *
1708
1719
  * @param id - The project's UUID.
1709
- * @returns The full project detail, or `null` if not found.
1720
+ * @param params - Optional locale resolver per ADR 0002.
1721
+ * @returns The project (lightweight), or `null` if not found.
1710
1722
  *
1711
1723
  * @example
1712
1724
  * ```ts
@@ -1714,11 +1726,10 @@ declare class ProjectsResource {
1714
1726
  * if (project) {
1715
1727
  * const loc = project.localizations.find(l => l.locale_id === localeId);
1716
1728
  * console.log(loc?.title, loc?.short_description);
1717
- * console.log(project.links); // [{ label, url, link_type }]
1718
1729
  * }
1719
1730
  * ```
1720
1731
  */
1721
- get(id: string, params?: ProjectDetailParams): Promise<ProjectDetailResponse | null>;
1732
+ get(id: string, params?: ProjectDetailParams): Promise<ProjectResponse | null>;
1722
1733
  /**
1723
1734
  * Fetch a project by its URL slug.
1724
1735
  *
@@ -0,0 +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(/\/+$/,``),i={"X-API-Key":e.apiKey,"Content-Type":`application/json`};e.siteDomain&&(i[`X-Site-Domain`]=e.siteDomain);async function a(e,r,a,o){let l=c(n,r,a),u;try{u=await t(l,{method:e,headers:i,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)}function o(e,t){return a(`GET`,e,t).then(e=>e.json())}async function l(e,t){try{return await o(e,t)}catch(e){if(e instanceof r)return null;throw e}}return{get:o,getOrNull:l,getText:(e,t)=>a(`GET`,e,t).then(e=>e.text()),post:(e,t)=>a(`POST`,e,void 0,t).then(e=>e.json()),delete:e=>a(`DELETE`,e).then(()=>void 0)}}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,n){this.http=e,this.siteId=t,this.config=n}async paginate(e,t,n){let r=t?l(t):void 0,i=t=>this.http.get(e,{...r,...n,page:String(t)}),a=await i(t?.page??1);return p(a.data,a.meta,i)}async list(e){return this.paginate(this.config.listPath,e)}async getDetail(e,t){return this.http.getOrNull(`/${this.config.detailBase}/${encodeURIComponent(e)}/detail`,{locale:t?.locale})}},g=class extends h{constructor(e,t){super(e,t,{listPath:`/sites/${t}/blogs/published`,detailBase:`blogs`})}async listPublished(e){return this.paginate(`/sites/${this.siteId}/blogs/published`,e,e?.localeId?{locale_id:e.localeId}:void 0)}async listByCategory(e,t){return this.paginate(`/sites/${this.siteId}/blogs/published/category/${encodeURIComponent(e)}`,t,t?.localeId?{locale_id:t.localeId}:void 0)}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,t){let n=await this.http.getOrNull(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return n?this.http.getOrNull(`/blogs/${n.id}/detail`,{locale:t?.locale}):null}async get(e,t){return super.getDetail(e,t)}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},_=class{constructor(e,t,n){this.http=e,this.siteId=t,this.typeKey=n}base(){return`/sites/${this.siteId}/collections/${encodeURIComponent(this.typeKey)}`}async published(e){let t=async t=>this.http.get(`${this.base()}/published`,{...e?.locale?{locale:e.locale}:{},...e?.pageSize?{page_size:String(e.pageSize)}:{},page:String(t)}),n=await t(e?.page??1);return p(n.data,n.meta,t)}async bySlug(e,t){return this.http.getOrNull(`${this.base()}/by-slug/${encodeURIComponent(e)}`,{locale:t?.locale})}async schema(){return this.http.getOrNull(`${this.base()}/schema`)}},v=class extends h{constructor(e,t){super(e,t,{listPath:`/sites/${t}/cv`,detailBase:`cv`})}async listSkills(e){return this.paginate(`/sites/${this.siteId}/skills`,e)}async getSkill(e,t){return this.http.getOrNull(`/skills/${encodeURIComponent(e)}`,{locale:t?.locale})}async getSkillBySlug(e,t){return this.http.getOrNull(`/skills/by-slug/${encodeURIComponent(e)}`,{locale:t?.locale})}async listEntries(e){return this.paginate(`/sites/${this.siteId}/cv`,e)}async getEntry(e,t){return this.http.getOrNull(`/cv/${encodeURIComponent(e)}`,{locale:t?.locale})}async getEntryDetail(e,t){return super.getDetail(e,t)}},y=class{constructor(e){this.http=e}async getForm(e,t){let n=t?.locale?{locale:t.locale}:void 0;return this.http.get(`/public/forms/${encodeURIComponent(e)}`,n)}async getAltchaChallenge(e){return this.http.get(`/public/forms/${encodeURIComponent(e)}/altcha-challenge`)}async submitForm(e,t,n={}){return this.http.post(`/public/forms/${encodeURIComponent(e)}/submit`,{data:t,consent_given:n.consentGiven??!1,bot_protection_token:n.botProtectionToken})}async lookupSubmission(e){return this.http.post(`/public/submissions/lookup`,{reference_code:e})}async getSubmission(e){return this.http.get(`/public/submissions/${encodeURIComponent(e)}`)}async deleteSubmission(e){return this.http.delete(`/public/submissions/${encodeURIComponent(e)}`)}};const b=/^[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}$/;function x(e,t){let n={};for(let r of e.fields){let e=t[r.label],i=S(r,e);i&&(n[r.label]=i)}return n}function S(e,t){let n=t,r=n==null||typeof n==`string`&&n===``||Array.isArray(n)&&n.length===0;if((e.is_required||e.validation.required)&&r)return`${e.label} is required`;if(r)return null;switch(e.field_type){case`text`:case`textarea`:case`custom`:if(typeof n!=`string`)return`Must be a string`;if(e.validation.min_length!==void 0&&n.length<e.validation.min_length)return`Must be at least ${e.validation.min_length} characters`;if(e.validation.max_length!==void 0&&n.length>e.validation.max_length)return`Must be at most ${e.validation.max_length} characters`;if(e.validation.pattern)try{if(!new RegExp(e.validation.pattern).test(n))return`Value does not match the required pattern`}catch{return`Field has an invalid validation pattern`}return null;case`email`:return typeof n==`string`?b.test(n)?null:`Invalid email format`:`Must be a string`;case`number`:{let t=typeof n==`number`?n:Number(n);return Number.isNaN(t)?`Must be a number`:e.validation.min!==void 0&&t<e.validation.min?`Must be at least ${e.validation.min}`:e.validation.max!==void 0&&t>e.validation.max?`Must be at most ${e.validation.max}`:null}case`date`:return typeof n!=`string`||Number.isNaN(Date.parse(n))&&!/^\d{4}-\d{2}-\d{2}$/.test(n)?`Invalid date format`:null;case`select`:case`radio`:case`checkbox`:return null}}var C=class extends h{constructor(e,t){super(e,t,{listPath:`/sites/${t}/legal`,detailBase:`legal`})}async list(e){return this.paginate(`/sites/${this.siteId}/legal`,e)}async get(e){return this.http.getOrNull(`/legal/${encodeURIComponent(e)}`)}async getBySlug(e,t){return this.http.getOrNull(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`,{locale:t?.locale})}async getCookieConsent(){return this.http.getOrNull(`/sites/${this.siteId}/legal/cookie-consent`)}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},w=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){return this.http.getOrNull(`/media/${encodeURIComponent(e)}`)}},T=class{constructor(e,t){this.http=e,this.siteId=t}async listMenus(){return this.http.get(`/sites/${this.siteId}/menus`)}async getMenu(e){return this.http.getOrNull(`/menus/${encodeURIComponent(e)}`)}async getMenuBySlug(e){return this.http.getOrNull(`/sites/${this.siteId}/menus/slug/${encodeURIComponent(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){return this.http.getOrNull(`/navigation/${encodeURIComponent(e)}`)}},E=class extends h{constructor(e,t){super(e,t,{listPath:`/sites/${t}/pages`,detailBase:`pages`})}async list(e){return this.paginate(`/sites/${this.siteId}/pages`,e)}async getByRoute(e){let t=e.startsWith(`/`)?e.slice(1):e;return this.http.getOrNull(`/sites/${this.siteId}/pages/by-route/${encodeURIComponent(t)}`)}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`)}},D=class extends h{constructor(e,t){super(e,t,{listPath:`/sites/${t}/projects/public`,detailBase:`projects`})}async listPublished(e){return this.paginate(`/sites/${this.siteId}/projects/public`,e)}async get(e,t){return this.http.getOrNull(`/projects/${encodeURIComponent(e)}`,{locale:t?.locale})}async getBySlug(e,t){return this.http.getOrNull(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`,{locale:t?.locale})}},O=class{constructor(e,t){this.http=e,this.siteId=t}async lookup(e){return this.http.getOrNull(`/sites/${this.siteId}/redirects/lookup`,{path:e})}},k=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??``}}},A=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},j=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){return this.http.getOrNull(`/tags/${encodeURIComponent(e)}`)}async getTagBySlug(e){return this.http.getOrNull(`/tags/by-slug/${encodeURIComponent(e)}`)}async getCategory(e){return this.http.getOrNull(`/categories/${encodeURIComponent(e)}`)}async getCategoryChildren(e){return this.http.get(`/categories/${encodeURIComponent(e)}/children`)}},M=class{constructor(e){let t=f(e);this.http=t,this.siteId=e.siteId,this.blogs=new g(t,e.siteId),this.pages=new E(t,e.siteId),this.navigation=new T(t,e.siteId),this.taxonomy=new j(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new v(t,e.siteId),this.legal=new C(t,e.siteId),this.projects=new D(t,e.siteId),this.redirects=new O(t,e.siteId),this.site=new k(t,e.siteId),this.media=new w(t,e.siteId),this.social=new A(t,e.siteId),this.forms=new y(t)}collections(e){return new _(this.http,this.siteId,e)}};export{e as a,n as c,a as d,t as i,i as l,x as n,s as o,_ as r,r as s,M as t,o as u};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./client-DnYre1oI.cjs`);function t(e){return{head:e.code_injection_head,footer:e.code_injection_footer}}exports.CollectionsResource=e.r,exports.ForjaAuthError=e.i,exports.ForjaClient=e.t,exports.ForjaError=e.a,exports.ForjaNetworkError=e.o,exports.ForjaNotFoundError=e.s,exports.ForjaPermissionError=e.c,exports.ForjaRateLimitError=e.l,exports.ForjaServerError=e.u,exports.ForjaValidationError=e.d,exports.renderCodeInjection=t,exports.validateSubmission=e.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./client-BSWR_os4.cjs");function t(e){return{head:e.code_injection_head,footer:e.code_injection_footer}}exports.CollectionsResource=e.r,exports.ForjaAuthError=e.i,exports.ForjaClient=e.t,exports.ForjaError=e.a,exports.ForjaNetworkError=e.o,exports.ForjaNotFoundError=e.s,exports.ForjaPermissionError=e.c,exports.ForjaRateLimitError=e.l,exports.ForjaServerError=e.u,exports.ForjaValidationError=e.d,exports.renderCodeInjection=t,exports.validateSubmission=e.n;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as MediaResponse, A as CategoryTree, At as SocialLinkResponse, B as LegalDocType, C as AnalyticsReportParams, Ct as SearchablePaginationParams, D as BlogListItem, Dt as SiteResponse, E as BlogDocumentResponse, Et as SiteLocaleResponse, F as CvEntryResponse, Ft as TranslationStatus, G as LegalGroupResponse, H as LegalDocumentFullDetailResponse, I as CvEntryType, It as TrendDataPoint, J as LegalVersionResponse, K as LegalGroupWithItems, L as DocumentLocalizationResponse, M as CodeInjection, Mt as TopContentItem, N as ContentStatus, Nt as TrackPageviewRequest, O as BlogResponse, Ot as SkillCategory, P as CvEntryParams, Pt as TrackPageviewResponse, Q as MediaListParams, R as ForjaClientConfig, S as AnalyticsPageParams, St as ReferrerItem, T as BlogDetailResponse, Tt as SectionType, U as LegalDocumentResponse, V as LegalDocumentDetailResponse, W as LegalDocumentWithGroups, X as LocalizationResponse, Y as LocaleFilterParams, Z as MediaListItem, _ as PublicCollectionListParams, _t as ProjectLocalizationResponse, a as FormFieldValidation, at as PageDetailResponse, b as PaginatedResult, bt as RedirectLookupResponse, c as PublicFormDefinition, ct as PageSectionResponse, d as SubmitFormOptions, dt as PaginationMeta, et as MediaVariantResponse, f as ValidationErrorMap, ft as PaginationParams, g as PublicCollectionField, gt as ProjectListParams, h as PublicCollectionEntry, ht as ProjectLinkType, i as FormFieldType, it as NavigationTree, j as CategoryWithCountResponse, jt as TagResponse, k as CategoryResponse, kt as SkillResponse, l as SelfServiceLookup, lt as PageType, m as CollectionsResource, mt as ProjectLinkResponse, n as FormBotProtection, nt as NavigationItemResponse, o as FormSubmitData, ot as PageListItem, p as validateSubmission, pt as ProjectDetailResponse, q as LegalItemResponse, r as FormFieldDefinition, rt as NavigationMenuResponse, s as FormSubmitResponse, st as PageResponse, t as ForjaClient, tt as NavigationItemLocalizationResponse, u as SelfServiceSubmission, ut as Paginated, v as PublicCollectionSchema, vt as ProjectMediaResponse, w as AnalyticsReportResponse, wt as SectionLocalizationResponse, x as AnalyticsPageDetailResponse, xt as RedirectResponse, y as HttpClient, yt as ProjectResponse, z as LegalDocLocalizationResponse } from "./client-C-LeSLIx.cjs";
1
+ import { $ as MediaResponse, A as CategoryTree, At as SocialLinkResponse, B as LegalDocType, C as AnalyticsReportParams, Ct as SearchablePaginationParams, D as BlogListItem, Dt as SiteResponse, E as BlogDocumentResponse, Et as SiteLocaleResponse, F as CvEntryResponse, Ft as TranslationStatus, G as LegalGroupResponse, H as LegalDocumentFullDetailResponse, I as CvEntryType, It as TrendDataPoint, J as LegalVersionResponse, K as LegalGroupWithItems, L as DocumentLocalizationResponse, M as CodeInjection, Mt as TopContentItem, N as ContentStatus, Nt as TrackPageviewRequest, O as BlogResponse, Ot as SkillCategory, P as CvEntryParams, Pt as TrackPageviewResponse, Q as MediaListParams, R as ForjaClientConfig, S as AnalyticsPageParams, St as ReferrerItem, T as BlogDetailResponse, Tt as SectionType, U as LegalDocumentResponse, V as LegalDocumentDetailResponse, W as LegalDocumentWithGroups, X as LocalizationResponse, Y as LocaleFilterParams, Z as MediaListItem, _ as PublicCollectionListParams, _t as ProjectLocalizationResponse, a as FormFieldValidation, at as PageDetailResponse, b as PaginatedResult, bt as RedirectLookupResponse, c as PublicFormDefinition, ct as PageSectionResponse, d as SubmitFormOptions, dt as PaginationMeta, et as MediaVariantResponse, f as ValidationErrorMap, ft as PaginationParams, g as PublicCollectionField, gt as ProjectListParams, h as PublicCollectionEntry, ht as ProjectLinkType, i as FormFieldType, it as NavigationTree, j as CategoryWithCountResponse, jt as TagResponse, k as CategoryResponse, kt as SkillResponse, l as SelfServiceLookup, lt as PageType, m as CollectionsResource, mt as ProjectLinkResponse, n as FormBotProtection, nt as NavigationItemResponse, o as FormSubmitData, ot as PageListItem, p as validateSubmission, pt as ProjectDetailResponse, q as LegalItemResponse, r as FormFieldDefinition, rt as NavigationMenuResponse, s as FormSubmitResponse, st as PageResponse, t as ForjaClient, tt as NavigationItemLocalizationResponse, u as SelfServiceSubmission, ut as Paginated, v as PublicCollectionSchema, vt as ProjectMediaResponse, w as AnalyticsReportResponse, wt as SectionLocalizationResponse, x as AnalyticsPageDetailResponse, xt as RedirectResponse, y as HttpClient, yt as ProjectResponse, z as LegalDocLocalizationResponse } from "./client-BoEyJL6_.cjs";
2
2
 
3
3
  //#region src/code-injection.d.ts
4
4
  /**
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as MediaResponse, A as CategoryTree, At as SocialLinkResponse, B as LegalDocType, C as AnalyticsReportParams, Ct as SearchablePaginationParams, D as BlogListItem, Dt as SiteResponse, E as BlogDocumentResponse, Et as SiteLocaleResponse, F as CvEntryResponse, Ft as TranslationStatus, G as LegalGroupResponse, H as LegalDocumentFullDetailResponse, I as CvEntryType, It as TrendDataPoint, J as LegalVersionResponse, K as LegalGroupWithItems, L as DocumentLocalizationResponse, M as CodeInjection, Mt as TopContentItem, N as ContentStatus, Nt as TrackPageviewRequest, O as BlogResponse, Ot as SkillCategory, P as CvEntryParams, Pt as TrackPageviewResponse, Q as MediaListParams, R as ForjaClientConfig, S as AnalyticsPageParams, St as ReferrerItem, T as BlogDetailResponse, Tt as SectionType, U as LegalDocumentResponse, V as LegalDocumentDetailResponse, W as LegalDocumentWithGroups, X as LocalizationResponse, Y as LocaleFilterParams, Z as MediaListItem, _ as PublicCollectionListParams, _t as ProjectLocalizationResponse, a as FormFieldValidation, at as PageDetailResponse, b as PaginatedResult, bt as RedirectLookupResponse, c as PublicFormDefinition, ct as PageSectionResponse, d as SubmitFormOptions, dt as PaginationMeta, et as MediaVariantResponse, f as ValidationErrorMap, ft as PaginationParams, g as PublicCollectionField, gt as ProjectListParams, h as PublicCollectionEntry, ht as ProjectLinkType, i as FormFieldType, it as NavigationTree, j as CategoryWithCountResponse, jt as TagResponse, k as CategoryResponse, kt as SkillResponse, l as SelfServiceLookup, lt as PageType, m as CollectionsResource, mt as ProjectLinkResponse, n as FormBotProtection, nt as NavigationItemResponse, o as FormSubmitData, ot as PageListItem, p as validateSubmission, pt as ProjectDetailResponse, q as LegalItemResponse, r as FormFieldDefinition, rt as NavigationMenuResponse, s as FormSubmitResponse, st as PageResponse, t as ForjaClient, tt as NavigationItemLocalizationResponse, u as SelfServiceSubmission, ut as Paginated, v as PublicCollectionSchema, vt as ProjectMediaResponse, w as AnalyticsReportResponse, wt as SectionLocalizationResponse, x as AnalyticsPageDetailResponse, xt as RedirectResponse, y as HttpClient, yt as ProjectResponse, z as LegalDocLocalizationResponse } from "./client-CWPMXGU3.mjs";
1
+ import { $ as MediaResponse, A as CategoryTree, At as SocialLinkResponse, B as LegalDocType, C as AnalyticsReportParams, Ct as SearchablePaginationParams, D as BlogListItem, Dt as SiteResponse, E as BlogDocumentResponse, Et as SiteLocaleResponse, F as CvEntryResponse, Ft as TranslationStatus, G as LegalGroupResponse, H as LegalDocumentFullDetailResponse, I as CvEntryType, It as TrendDataPoint, J as LegalVersionResponse, K as LegalGroupWithItems, L as DocumentLocalizationResponse, M as CodeInjection, Mt as TopContentItem, N as ContentStatus, Nt as TrackPageviewRequest, O as BlogResponse, Ot as SkillCategory, P as CvEntryParams, Pt as TrackPageviewResponse, Q as MediaListParams, R as ForjaClientConfig, S as AnalyticsPageParams, St as ReferrerItem, T as BlogDetailResponse, Tt as SectionType, U as LegalDocumentResponse, V as LegalDocumentDetailResponse, W as LegalDocumentWithGroups, X as LocalizationResponse, Y as LocaleFilterParams, Z as MediaListItem, _ as PublicCollectionListParams, _t as ProjectLocalizationResponse, a as FormFieldValidation, at as PageDetailResponse, b as PaginatedResult, bt as RedirectLookupResponse, c as PublicFormDefinition, ct as PageSectionResponse, d as SubmitFormOptions, dt as PaginationMeta, et as MediaVariantResponse, f as ValidationErrorMap, ft as PaginationParams, g as PublicCollectionField, gt as ProjectListParams, h as PublicCollectionEntry, ht as ProjectLinkType, i as FormFieldType, it as NavigationTree, j as CategoryWithCountResponse, jt as TagResponse, k as CategoryResponse, kt as SkillResponse, l as SelfServiceLookup, lt as PageType, m as CollectionsResource, mt as ProjectLinkResponse, n as FormBotProtection, nt as NavigationItemResponse, o as FormSubmitData, ot as PageListItem, p as validateSubmission, pt as ProjectDetailResponse, q as LegalItemResponse, r as FormFieldDefinition, rt as NavigationMenuResponse, s as FormSubmitResponse, st as PageResponse, t as ForjaClient, tt as NavigationItemLocalizationResponse, u as SelfServiceSubmission, ut as Paginated, v as PublicCollectionSchema, vt as ProjectMediaResponse, w as AnalyticsReportResponse, wt as SectionLocalizationResponse, x as AnalyticsPageDetailResponse, xt as RedirectResponse, y as HttpClient, yt as ProjectResponse, z as LegalDocLocalizationResponse } from "./client-BoEyJL6_.mjs";
2
2
 
3
3
  //#region src/code-injection.d.ts
4
4
  /**
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,i as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./client-BS9LwrFb.mjs";function d(e){return{head:e.code_injection_head,footer:e.code_injection_footer}}export{s as CollectionsResource,r as ForjaAuthError,l as ForjaClient,e as ForjaError,o as ForjaNetworkError,c as ForjaNotFoundError,t as ForjaPermissionError,i as ForjaRateLimitError,u as ForjaServerError,n as ForjaValidationError,d as renderCodeInjection,a as validateSubmission};
1
+ import{a as e,c as t,d as n,i as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./client-D9WF4wKY.mjs";function d(e){return{head:e.code_injection_head,footer:e.code_injection_footer}}export{s as CollectionsResource,r as ForjaAuthError,l as ForjaClient,e as ForjaError,o as ForjaNetworkError,c as ForjaNotFoundError,t as ForjaPermissionError,i as ForjaRateLimitError,u as ForjaServerError,n as ForjaValidationError,d as renderCodeInjection,a as validateSubmission};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forjacms/client",
3
- "version": "1.8.2",
3
+ "version": "2.0.0",
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",
@@ -63,15 +63,15 @@
63
63
  }
64
64
  },
65
65
  "devDependencies": {
66
- "@angular/core": "^21.2.9",
66
+ "@angular/core": "^22.0.0",
67
67
  "@vitest/coverage-v8": "^4.0.18",
68
68
  "rxjs": "^7.8.2",
69
- "tsdown": "^0.22.0",
70
- "typescript": "^6.0.2",
69
+ "tsdown": "^0.22.2",
70
+ "typescript": "^6.0.3",
71
71
  "vitest": "^4.0.18",
72
- "zone.js": "^0.16.1"
72
+ "zone.js": "^0.16.2"
73
73
  },
74
74
  "overrides": {
75
- "typescript": "^6.0.2"
75
+ "typescript": "^6.0.3"
76
76
  }
77
77
  }
@@ -1 +0,0 @@
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`};e.siteDomain&&(r[`X-Site-Domain`]=e.siteDomain);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()),delete:e=>i(`DELETE`,e).then(()=>void 0)}}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,t){try{let n=`/blogs/${(await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`)).id}/detail`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}async get(e,t){try{let n=`/blogs/${encodeURIComponent(e)}/detail`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}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,n){this.http=e,this.siteId=t,this.typeKey=n}base(){return`/sites/${this.siteId}/collections/${encodeURIComponent(this.typeKey)}`}async published(e){let t=async t=>this.http.get(`${this.base()}/published`,{...e?.locale?{locale:e.locale}:{},...e?.pageSize?{page_size:String(e.pageSize)}:{},page:String(t)}),n=await t(e?.page??1);return p(n.data,n.meta,t)}async bySlug(e,t){try{return await this.http.get(`${this.base()}/by-slug/${encodeURIComponent(e)}`,t?.locale?{locale:t.locale}:void 0)}catch(e){if(e instanceof r)return null;throw e}}async schema(){try{return await this.http.get(`${this.base()}/schema`)}catch(e){if(e instanceof r)return null;throw e}}},_=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,t){try{let n=`/skills/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e,t){try{let n=`/skills/by-slug/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}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)}async getEntry(e,t){try{let n=`/cv/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}},v=class{constructor(e){this.http=e}async getForm(e,t){let n=t?.locale?{locale:t.locale}:void 0;return this.http.get(`/public/forms/${encodeURIComponent(e)}`,n)}async getAltchaChallenge(e){return this.http.get(`/public/forms/${encodeURIComponent(e)}/altcha-challenge`)}async submitForm(e,t,n={}){return this.http.post(`/public/forms/${encodeURIComponent(e)}/submit`,{data:t,consent_given:n.consentGiven??!1,bot_protection_token:n.botProtectionToken})}async lookupSubmission(e){return this.http.post(`/public/submissions/lookup`,{reference_code:e})}async getSubmission(e){return this.http.get(`/public/submissions/${encodeURIComponent(e)}`)}async deleteSubmission(e){return this.http.delete(`/public/submissions/${encodeURIComponent(e)}`)}};const y=/^[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}$/;function b(e,t){let n={};for(let r of e.fields){let e=t[r.label],i=x(r,e);i&&(n[r.label]=i)}return n}function x(e,t){let n=t,r=n==null||typeof n==`string`&&n===``||Array.isArray(n)&&n.length===0;if((e.is_required||e.validation.required)&&r)return`${e.label} is required`;if(r)return null;switch(e.field_type){case`text`:case`textarea`:case`custom`:if(typeof n!=`string`)return`Must be a string`;if(e.validation.min_length!==void 0&&n.length<e.validation.min_length)return`Must be at least ${e.validation.min_length} characters`;if(e.validation.max_length!==void 0&&n.length>e.validation.max_length)return`Must be at most ${e.validation.max_length} characters`;if(e.validation.pattern)try{if(!new RegExp(e.validation.pattern).test(n))return`Value does not match the required pattern`}catch{return`Field has an invalid validation pattern`}return null;case`email`:return typeof n==`string`?y.test(n)?null:`Invalid email format`:`Must be a string`;case`number`:{let t=typeof n==`number`?n:Number(n);return Number.isNaN(t)?`Must be a number`:e.validation.min!==void 0&&t<e.validation.min?`Must be at least ${e.validation.min}`:e.validation.max!==void 0&&t>e.validation.max?`Must be at most ${e.validation.max}`:null}case`date`:return typeof n!=`string`||Number.isNaN(Date.parse(n))&&!/^\d{4}-\d{2}-\d{2}$/.test(n)?`Invalid date format`:null;case`select`:case`radio`:case`checkbox`:return null}}var S=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,t){try{let n=`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}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,t){try{let n=`/legal/${encodeURIComponent(e)}/detail`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},C=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}}},w=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}}},T=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 getDetail(e,t){try{let n=`/pages/${encodeURIComponent(e)}/detail`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}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`)}},E=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,t){try{let n=`/projects/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e,t){try{let n=`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}},D=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}}},O=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??``}}},k=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},A=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`)}},j=class{constructor(e){let t=f(e);this.http=t,this.siteId=e.siteId,this.blogs=new h(t,e.siteId),this.pages=new T(t,e.siteId),this.navigation=new w(t,e.siteId),this.taxonomy=new A(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new _(t,e.siteId),this.legal=new S(t,e.siteId),this.projects=new E(t,e.siteId),this.redirects=new D(t,e.siteId),this.site=new O(t,e.siteId),this.media=new C(t,e.siteId),this.social=new k(t,e.siteId),this.forms=new v(t)}collections(e){return new g(this.http,this.siteId,e)}};export{e as a,n as c,a as d,t as i,i as l,b as n,s as o,g as r,r as s,j as t,o as u};
@@ -1 +0,0 @@
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`};e.siteDomain&&(r[`X-Site-Domain`]=e.siteDomain);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()),delete:e=>i(`DELETE`,e).then(()=>void 0)}}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,t){try{let n=`/blogs/${(await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`)).id}/detail`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}async get(e,t){try{let n=`/blogs/${encodeURIComponent(e)}/detail`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}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,n){this.http=e,this.siteId=t,this.typeKey=n}base(){return`/sites/${this.siteId}/collections/${encodeURIComponent(this.typeKey)}`}async published(e){let t=async t=>this.http.get(`${this.base()}/published`,{...e?.locale?{locale:e.locale}:{},...e?.pageSize?{page_size:String(e.pageSize)}:{},page:String(t)}),n=await t(e?.page??1);return p(n.data,n.meta,t)}async bySlug(e,t){try{return await this.http.get(`${this.base()}/by-slug/${encodeURIComponent(e)}`,t?.locale?{locale:t.locale}:void 0)}catch(e){if(e instanceof r)return null;throw e}}async schema(){try{return await this.http.get(`${this.base()}/schema`)}catch(e){if(e instanceof r)return null;throw e}}},_=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,t){try{let n=`/skills/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e,t){try{let n=`/skills/by-slug/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}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)}async getEntry(e,t){try{let n=`/cv/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}},v=class{constructor(e){this.http=e}async getForm(e,t){let n=t?.locale?{locale:t.locale}:void 0;return this.http.get(`/public/forms/${encodeURIComponent(e)}`,n)}async getAltchaChallenge(e){return this.http.get(`/public/forms/${encodeURIComponent(e)}/altcha-challenge`)}async submitForm(e,t,n={}){return this.http.post(`/public/forms/${encodeURIComponent(e)}/submit`,{data:t,consent_given:n.consentGiven??!1,bot_protection_token:n.botProtectionToken})}async lookupSubmission(e){return this.http.post(`/public/submissions/lookup`,{reference_code:e})}async getSubmission(e){return this.http.get(`/public/submissions/${encodeURIComponent(e)}`)}async deleteSubmission(e){return this.http.delete(`/public/submissions/${encodeURIComponent(e)}`)}};const y=/^[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}$/;function b(e,t){let n={};for(let r of e.fields){let e=t[r.label],i=x(r,e);i&&(n[r.label]=i)}return n}function x(e,t){let n=t,r=n==null||typeof n==`string`&&n===``||Array.isArray(n)&&n.length===0;if((e.is_required||e.validation.required)&&r)return`${e.label} is required`;if(r)return null;switch(e.field_type){case`text`:case`textarea`:case`custom`:if(typeof n!=`string`)return`Must be a string`;if(e.validation.min_length!==void 0&&n.length<e.validation.min_length)return`Must be at least ${e.validation.min_length} characters`;if(e.validation.max_length!==void 0&&n.length>e.validation.max_length)return`Must be at most ${e.validation.max_length} characters`;if(e.validation.pattern)try{if(!new RegExp(e.validation.pattern).test(n))return`Value does not match the required pattern`}catch{return`Field has an invalid validation pattern`}return null;case`email`:return typeof n==`string`?y.test(n)?null:`Invalid email format`:`Must be a string`;case`number`:{let t=typeof n==`number`?n:Number(n);return Number.isNaN(t)?`Must be a number`:e.validation.min!==void 0&&t<e.validation.min?`Must be at least ${e.validation.min}`:e.validation.max!==void 0&&t>e.validation.max?`Must be at most ${e.validation.max}`:null}case`date`:return typeof n!=`string`||Number.isNaN(Date.parse(n))&&!/^\d{4}-\d{2}-\d{2}$/.test(n)?`Invalid date format`:null;case`select`:case`radio`:case`checkbox`:return null}}var S=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,t){try{let n=`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}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,t){try{let n=`/legal/${encodeURIComponent(e)}/detail`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},C=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}}},w=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}}},T=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 getDetail(e,t){try{let n=`/pages/${encodeURIComponent(e)}/detail`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}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`)}},E=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,t){try{let n=`/projects/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e,t){try{let n=`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`;return t?.locale?await this.http.get(n,{locale:t.locale}):await this.http.get(n)}catch(e){if(e instanceof r)return null;throw e}}},D=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}}},O=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??``}}},k=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},A=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`)}},j=class{constructor(e){let t=f(e);this.http=t,this.siteId=e.siteId,this.blogs=new h(t,e.siteId),this.pages=new T(t,e.siteId),this.navigation=new w(t,e.siteId),this.taxonomy=new A(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new _(t,e.siteId),this.legal=new S(t,e.siteId),this.projects=new E(t,e.siteId),this.redirects=new D(t,e.siteId),this.site=new O(t,e.siteId),this.media=new C(t,e.siteId),this.social=new k(t,e.siteId),this.forms=new v(t)}collections(e){return new g(this.http,this.siteId,e)}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return o}});