@forjacms/client 1.7.9 → 1.8.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.
- package/dist/angular/index.cjs +1 -1
- package/dist/angular/index.d.cts +1 -1
- package/dist/angular/index.d.mts +1 -1
- package/dist/angular/index.mjs +1 -1
- package/dist/client-BS9LwrFb.mjs +1 -0
- package/dist/{client-DnlMLCQX.d.cts → client-C-LeSLIx.d.cts} +88 -1
- package/dist/{client-suk46QJJ.d.mts → client-CWPMXGU3.d.mts} +88 -1
- package/dist/client-DnYre1oI.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/client-BsrJVReZ.cjs +0 -1
- package/dist/client-CMLPs3ca.mjs +0 -1
package/dist/angular/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../client-
|
|
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;
|
package/dist/angular/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as ForjaClientConfig, t as ForjaClient } from "../client-C-LeSLIx.cjs";
|
|
2
2
|
import { EnvironmentProviders, InjectionToken, Signal } from "@angular/core";
|
|
3
3
|
|
|
4
4
|
//#region src/angular/provider.d.ts
|
package/dist/angular/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as ForjaClientConfig, t as ForjaClient } from "../client-CWPMXGU3.mjs";
|
|
2
2
|
import { EnvironmentProviders, InjectionToken, Signal } from "@angular/core";
|
|
3
3
|
|
|
4
4
|
//#region src/angular/provider.d.ts
|
package/dist/angular/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../client-
|
|
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};
|
|
@@ -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(/\/+$/,``),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};
|
|
@@ -931,6 +931,77 @@ declare class BlogsResource {
|
|
|
931
931
|
rss(): Promise<string>;
|
|
932
932
|
}
|
|
933
933
|
//#endregion
|
|
934
|
+
//#region src/resources/collections.d.ts
|
|
935
|
+
/**
|
|
936
|
+
* A published custom-type ("Collection") entry as served on the public
|
|
937
|
+
* Consumer API. PII fields are stripped server-side; `data` merges the shared
|
|
938
|
+
* and localized values with the title under the designated title field key.
|
|
939
|
+
*/
|
|
940
|
+
interface PublicCollectionEntry {
|
|
941
|
+
slug: string | null;
|
|
942
|
+
status: string;
|
|
943
|
+
published_at: string | null;
|
|
944
|
+
locale: string | null;
|
|
945
|
+
data: Record<string, unknown>;
|
|
946
|
+
}
|
|
947
|
+
/** A single field in a public collection schema (no PII / compliance metadata). */
|
|
948
|
+
interface PublicCollectionField {
|
|
949
|
+
key: string;
|
|
950
|
+
label: string;
|
|
951
|
+
field_type: string;
|
|
952
|
+
localized: boolean;
|
|
953
|
+
/** The designated title field — renderers use it as the heading. */
|
|
954
|
+
is_title: boolean;
|
|
955
|
+
enum_options?: unknown;
|
|
956
|
+
}
|
|
957
|
+
/** A collection's public field schema, for generic renderers. */
|
|
958
|
+
interface PublicCollectionSchema {
|
|
959
|
+
key: string;
|
|
960
|
+
name: string;
|
|
961
|
+
content_kind: string;
|
|
962
|
+
fields: PublicCollectionField[];
|
|
963
|
+
}
|
|
964
|
+
interface PublicCollectionListParams {
|
|
965
|
+
locale?: string;
|
|
966
|
+
page?: number;
|
|
967
|
+
pageSize?: number;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Read operations for one custom type ("Collection"), parameterised by its
|
|
971
|
+
* key. Obtain via {@link ForjaClient.collections | `forja.collections(key)`}.
|
|
972
|
+
* One generic resource serves every type — no per-type codegen.
|
|
973
|
+
*
|
|
974
|
+
* Only types flagged publicly-readable are served; everything else surfaces
|
|
975
|
+
* as `null` (by-slug / schema) or a 404 (`bySlug`/`schema` return `null`).
|
|
976
|
+
*/
|
|
977
|
+
declare class CollectionsResource {
|
|
978
|
+
private readonly http;
|
|
979
|
+
private readonly siteId;
|
|
980
|
+
private readonly typeKey;
|
|
981
|
+
constructor(http: HttpClient, siteId: string, typeKey: string);
|
|
982
|
+
private base;
|
|
983
|
+
/**
|
|
984
|
+
* Paginated list of published entries.
|
|
985
|
+
*
|
|
986
|
+
* **Endpoint:** `GET /sites/{siteId}/collections/{typeKey}/published`
|
|
987
|
+
*/
|
|
988
|
+
published(params?: PublicCollectionListParams): Promise<PaginatedResult<PublicCollectionEntry>>;
|
|
989
|
+
/**
|
|
990
|
+
* A single published entry by slug, or `null` if not found / not public.
|
|
991
|
+
*
|
|
992
|
+
* **Endpoint:** `GET /sites/{siteId}/collections/{typeKey}/by-slug/{slug}`
|
|
993
|
+
*/
|
|
994
|
+
bySlug(slug: string, params?: {
|
|
995
|
+
locale?: string;
|
|
996
|
+
}): Promise<PublicCollectionEntry | null>;
|
|
997
|
+
/**
|
|
998
|
+
* The collection's public field schema, or `null` if not public.
|
|
999
|
+
*
|
|
1000
|
+
* **Endpoint:** `GET /sites/{siteId}/collections/{typeKey}/schema`
|
|
1001
|
+
*/
|
|
1002
|
+
schema(): Promise<PublicCollectionSchema | null>;
|
|
1003
|
+
}
|
|
1004
|
+
//#endregion
|
|
934
1005
|
//#region src/resources/cv.d.ts
|
|
935
1006
|
/**
|
|
936
1007
|
* CV / resume operations.
|
|
@@ -2023,6 +2094,10 @@ declare class ForjaClient {
|
|
|
2023
2094
|
readonly social: SocialResource;
|
|
2024
2095
|
/** Forms module — public form rendering, submission, and self-service. */
|
|
2025
2096
|
readonly forms: FormsResource;
|
|
2097
|
+
/** Shared HTTP client + site id, retained so {@link collections} can build
|
|
2098
|
+
* a per-type resource on demand. */
|
|
2099
|
+
private readonly http;
|
|
2100
|
+
private readonly siteId;
|
|
2026
2101
|
/**
|
|
2027
2102
|
* @param config - API connection settings.
|
|
2028
2103
|
* @param config.baseUrl - Full URL to the Forja API (e.g. `https://cms.example.com/api/v1`).
|
|
@@ -2031,6 +2106,18 @@ declare class ForjaClient {
|
|
|
2031
2106
|
* @param config.fetch - Optional custom `fetch` implementation for edge runtimes or testing.
|
|
2032
2107
|
*/
|
|
2033
2108
|
constructor(config: ForjaClientConfig);
|
|
2109
|
+
/**
|
|
2110
|
+
* Read operations for a custom type ("Collection"), by its key. One generic
|
|
2111
|
+
* resource serves every type — no per-type codegen.
|
|
2112
|
+
*
|
|
2113
|
+
* @example
|
|
2114
|
+
* ```ts
|
|
2115
|
+
* const recipes = await forja.collections('recipe').published({ page: 1 });
|
|
2116
|
+
* const one = await forja.collections('recipe').bySlug('spaghetti');
|
|
2117
|
+
* const schema = await forja.collections('recipe').schema();
|
|
2118
|
+
* ```
|
|
2119
|
+
*/
|
|
2120
|
+
collections(typeKey: string): CollectionsResource;
|
|
2034
2121
|
}
|
|
2035
2122
|
//#endregion
|
|
2036
|
-
export {
|
|
2123
|
+
export { MediaResponse as $, CategoryTree as A, SocialLinkResponse as At, LegalDocType as B, AnalyticsReportParams as C, SearchablePaginationParams as Ct, BlogListItem as D, SiteResponse as Dt, BlogDocumentResponse as E, SiteLocaleResponse as Et, CvEntryResponse as F, TranslationStatus as Ft, LegalGroupResponse as G, LegalDocumentFullDetailResponse as H, CvEntryType as I, TrendDataPoint as It, LegalVersionResponse as J, LegalGroupWithItems as K, DocumentLocalizationResponse as L, CodeInjection as M, TopContentItem as Mt, ContentStatus as N, TrackPageviewRequest as Nt, BlogResponse as O, SkillCategory as Ot, CvEntryParams as P, TrackPageviewResponse as Pt, MediaListParams as Q, ForjaClientConfig as R, AnalyticsPageParams as S, ReferrerItem as St, BlogDetailResponse as T, SectionType as Tt, LegalDocumentResponse as U, LegalDocumentDetailResponse as V, LegalDocumentWithGroups as W, LocalizationResponse as X, LocaleFilterParams as Y, MediaListItem as Z, PublicCollectionListParams as _, ProjectLocalizationResponse as _t, FormFieldValidation as a, PageDetailResponse as at, PaginatedResult as b, RedirectLookupResponse as bt, PublicFormDefinition as c, PageSectionResponse as ct, SubmitFormOptions as d, PaginationMeta as dt, MediaVariantResponse as et, ValidationErrorMap as f, PaginationParams as ft, PublicCollectionField as g, ProjectListParams as gt, PublicCollectionEntry as h, ProjectLinkType as ht, FormFieldType as i, NavigationTree as it, CategoryWithCountResponse as j, TagResponse as jt, CategoryResponse as k, SkillResponse as kt, SelfServiceLookup as l, PageType as lt, CollectionsResource as m, ProjectLinkResponse as mt, FormBotProtection as n, NavigationItemResponse as nt, FormSubmitData as o, PageListItem as ot, validateSubmission as p, ProjectDetailResponse as pt, LegalItemResponse as q, FormFieldDefinition as r, NavigationMenuResponse as rt, FormSubmitResponse as s, PageResponse as st, ForjaClient as t, NavigationItemLocalizationResponse as tt, SelfServiceSubmission as u, Paginated as ut, PublicCollectionSchema as v, ProjectMediaResponse as vt, AnalyticsReportResponse as w, SectionLocalizationResponse as wt, AnalyticsPageDetailResponse as x, RedirectResponse as xt, HttpClient as y, ProjectResponse as yt, LegalDocLocalizationResponse as z };
|
|
@@ -931,6 +931,77 @@ declare class BlogsResource {
|
|
|
931
931
|
rss(): Promise<string>;
|
|
932
932
|
}
|
|
933
933
|
//#endregion
|
|
934
|
+
//#region src/resources/collections.d.ts
|
|
935
|
+
/**
|
|
936
|
+
* A published custom-type ("Collection") entry as served on the public
|
|
937
|
+
* Consumer API. PII fields are stripped server-side; `data` merges the shared
|
|
938
|
+
* and localized values with the title under the designated title field key.
|
|
939
|
+
*/
|
|
940
|
+
interface PublicCollectionEntry {
|
|
941
|
+
slug: string | null;
|
|
942
|
+
status: string;
|
|
943
|
+
published_at: string | null;
|
|
944
|
+
locale: string | null;
|
|
945
|
+
data: Record<string, unknown>;
|
|
946
|
+
}
|
|
947
|
+
/** A single field in a public collection schema (no PII / compliance metadata). */
|
|
948
|
+
interface PublicCollectionField {
|
|
949
|
+
key: string;
|
|
950
|
+
label: string;
|
|
951
|
+
field_type: string;
|
|
952
|
+
localized: boolean;
|
|
953
|
+
/** The designated title field — renderers use it as the heading. */
|
|
954
|
+
is_title: boolean;
|
|
955
|
+
enum_options?: unknown;
|
|
956
|
+
}
|
|
957
|
+
/** A collection's public field schema, for generic renderers. */
|
|
958
|
+
interface PublicCollectionSchema {
|
|
959
|
+
key: string;
|
|
960
|
+
name: string;
|
|
961
|
+
content_kind: string;
|
|
962
|
+
fields: PublicCollectionField[];
|
|
963
|
+
}
|
|
964
|
+
interface PublicCollectionListParams {
|
|
965
|
+
locale?: string;
|
|
966
|
+
page?: number;
|
|
967
|
+
pageSize?: number;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Read operations for one custom type ("Collection"), parameterised by its
|
|
971
|
+
* key. Obtain via {@link ForjaClient.collections | `forja.collections(key)`}.
|
|
972
|
+
* One generic resource serves every type — no per-type codegen.
|
|
973
|
+
*
|
|
974
|
+
* Only types flagged publicly-readable are served; everything else surfaces
|
|
975
|
+
* as `null` (by-slug / schema) or a 404 (`bySlug`/`schema` return `null`).
|
|
976
|
+
*/
|
|
977
|
+
declare class CollectionsResource {
|
|
978
|
+
private readonly http;
|
|
979
|
+
private readonly siteId;
|
|
980
|
+
private readonly typeKey;
|
|
981
|
+
constructor(http: HttpClient, siteId: string, typeKey: string);
|
|
982
|
+
private base;
|
|
983
|
+
/**
|
|
984
|
+
* Paginated list of published entries.
|
|
985
|
+
*
|
|
986
|
+
* **Endpoint:** `GET /sites/{siteId}/collections/{typeKey}/published`
|
|
987
|
+
*/
|
|
988
|
+
published(params?: PublicCollectionListParams): Promise<PaginatedResult<PublicCollectionEntry>>;
|
|
989
|
+
/**
|
|
990
|
+
* A single published entry by slug, or `null` if not found / not public.
|
|
991
|
+
*
|
|
992
|
+
* **Endpoint:** `GET /sites/{siteId}/collections/{typeKey}/by-slug/{slug}`
|
|
993
|
+
*/
|
|
994
|
+
bySlug(slug: string, params?: {
|
|
995
|
+
locale?: string;
|
|
996
|
+
}): Promise<PublicCollectionEntry | null>;
|
|
997
|
+
/**
|
|
998
|
+
* The collection's public field schema, or `null` if not public.
|
|
999
|
+
*
|
|
1000
|
+
* **Endpoint:** `GET /sites/{siteId}/collections/{typeKey}/schema`
|
|
1001
|
+
*/
|
|
1002
|
+
schema(): Promise<PublicCollectionSchema | null>;
|
|
1003
|
+
}
|
|
1004
|
+
//#endregion
|
|
934
1005
|
//#region src/resources/cv.d.ts
|
|
935
1006
|
/**
|
|
936
1007
|
* CV / resume operations.
|
|
@@ -2023,6 +2094,10 @@ declare class ForjaClient {
|
|
|
2023
2094
|
readonly social: SocialResource;
|
|
2024
2095
|
/** Forms module — public form rendering, submission, and self-service. */
|
|
2025
2096
|
readonly forms: FormsResource;
|
|
2097
|
+
/** Shared HTTP client + site id, retained so {@link collections} can build
|
|
2098
|
+
* a per-type resource on demand. */
|
|
2099
|
+
private readonly http;
|
|
2100
|
+
private readonly siteId;
|
|
2026
2101
|
/**
|
|
2027
2102
|
* @param config - API connection settings.
|
|
2028
2103
|
* @param config.baseUrl - Full URL to the Forja API (e.g. `https://cms.example.com/api/v1`).
|
|
@@ -2031,6 +2106,18 @@ declare class ForjaClient {
|
|
|
2031
2106
|
* @param config.fetch - Optional custom `fetch` implementation for edge runtimes or testing.
|
|
2032
2107
|
*/
|
|
2033
2108
|
constructor(config: ForjaClientConfig);
|
|
2109
|
+
/**
|
|
2110
|
+
* Read operations for a custom type ("Collection"), by its key. One generic
|
|
2111
|
+
* resource serves every type — no per-type codegen.
|
|
2112
|
+
*
|
|
2113
|
+
* @example
|
|
2114
|
+
* ```ts
|
|
2115
|
+
* const recipes = await forja.collections('recipe').published({ page: 1 });
|
|
2116
|
+
* const one = await forja.collections('recipe').bySlug('spaghetti');
|
|
2117
|
+
* const schema = await forja.collections('recipe').schema();
|
|
2118
|
+
* ```
|
|
2119
|
+
*/
|
|
2120
|
+
collections(typeKey: string): CollectionsResource;
|
|
2034
2121
|
}
|
|
2035
2122
|
//#endregion
|
|
2036
|
-
export {
|
|
2123
|
+
export { MediaResponse as $, CategoryTree as A, SocialLinkResponse as At, LegalDocType as B, AnalyticsReportParams as C, SearchablePaginationParams as Ct, BlogListItem as D, SiteResponse as Dt, BlogDocumentResponse as E, SiteLocaleResponse as Et, CvEntryResponse as F, TranslationStatus as Ft, LegalGroupResponse as G, LegalDocumentFullDetailResponse as H, CvEntryType as I, TrendDataPoint as It, LegalVersionResponse as J, LegalGroupWithItems as K, DocumentLocalizationResponse as L, CodeInjection as M, TopContentItem as Mt, ContentStatus as N, TrackPageviewRequest as Nt, BlogResponse as O, SkillCategory as Ot, CvEntryParams as P, TrackPageviewResponse as Pt, MediaListParams as Q, ForjaClientConfig as R, AnalyticsPageParams as S, ReferrerItem as St, BlogDetailResponse as T, SectionType as Tt, LegalDocumentResponse as U, LegalDocumentDetailResponse as V, LegalDocumentWithGroups as W, LocalizationResponse as X, LocaleFilterParams as Y, MediaListItem as Z, PublicCollectionListParams as _, ProjectLocalizationResponse as _t, FormFieldValidation as a, PageDetailResponse as at, PaginatedResult as b, RedirectLookupResponse as bt, PublicFormDefinition as c, PageSectionResponse as ct, SubmitFormOptions as d, PaginationMeta as dt, MediaVariantResponse as et, ValidationErrorMap as f, PaginationParams as ft, PublicCollectionField as g, ProjectListParams as gt, PublicCollectionEntry as h, ProjectLinkType as ht, FormFieldType as i, NavigationTree as it, CategoryWithCountResponse as j, TagResponse as jt, CategoryResponse as k, SkillResponse as kt, SelfServiceLookup as l, PageType as lt, CollectionsResource as m, ProjectLinkResponse as mt, FormBotProtection as n, NavigationItemResponse as nt, FormSubmitData as o, PageListItem as ot, validateSubmission as p, ProjectDetailResponse as pt, LegalItemResponse as q, FormFieldDefinition as r, NavigationMenuResponse as rt, FormSubmitResponse as s, PageResponse as st, ForjaClient as t, NavigationItemLocalizationResponse as tt, SelfServiceSubmission as u, Paginated as ut, PublicCollectionSchema as v, ProjectMediaResponse as vt, AnalyticsReportResponse as w, SectionLocalizationResponse as wt, AnalyticsPageDetailResponse as x, RedirectResponse as xt, HttpClient as y, ProjectResponse as yt, LegalDocLocalizationResponse as z };
|
|
@@ -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(/\/+$/,``),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}});
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./client-
|
|
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;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
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";
|
|
2
2
|
|
|
3
3
|
//#region src/code-injection.d.ts
|
|
4
4
|
/**
|
|
@@ -135,4 +135,4 @@ declare class ForjaNetworkError extends ForjaError {
|
|
|
135
135
|
constructor(message?: string, /** The underlying network error (e.g. `TypeError: Failed to fetch`). */cause?: Error | undefined);
|
|
136
136
|
}
|
|
137
137
|
//#endregion
|
|
138
|
-
export { type AnalyticsPageDetailResponse, type AnalyticsPageParams, type AnalyticsReportParams, type AnalyticsReportResponse, type BlogDetailResponse, type BlogDocumentResponse, type BlogListItem, type BlogResponse, type CategoryResponse, type CategoryTree, type CategoryWithCountResponse, type CodeInjection, type ContentStatus, type CvEntryParams, type CvEntryResponse, type CvEntryType, type DocumentLocalizationResponse, ForjaAuthError, ForjaClient, type ForjaClientConfig, ForjaError, ForjaNetworkError, ForjaNotFoundError, ForjaPermissionError, ForjaRateLimitError, ForjaServerError, ForjaValidationError, type FormBotProtection, type FormFieldDefinition, type FormFieldType, type FormFieldValidation, type FormSubmitData, type FormSubmitResponse, type HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type PublicFormDefinition, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SelfServiceLookup, type SelfServiceSubmission, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type SubmitFormOptions, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint, type ValidationErrorMap, renderCodeInjection, validateSubmission };
|
|
138
|
+
export { type AnalyticsPageDetailResponse, type AnalyticsPageParams, type AnalyticsReportParams, type AnalyticsReportResponse, type BlogDetailResponse, type BlogDocumentResponse, type BlogListItem, type BlogResponse, type CategoryResponse, type CategoryTree, type CategoryWithCountResponse, type CodeInjection, CollectionsResource, type ContentStatus, type CvEntryParams, type CvEntryResponse, type CvEntryType, type DocumentLocalizationResponse, ForjaAuthError, ForjaClient, type ForjaClientConfig, ForjaError, ForjaNetworkError, ForjaNotFoundError, ForjaPermissionError, ForjaRateLimitError, ForjaServerError, ForjaValidationError, type FormBotProtection, type FormFieldDefinition, type FormFieldType, type FormFieldValidation, type FormSubmitData, type FormSubmitResponse, type HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type PublicCollectionEntry, type PublicCollectionField, type PublicCollectionListParams, type PublicCollectionSchema, type PublicFormDefinition, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SelfServiceLookup, type SelfServiceSubmission, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type SubmitFormOptions, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint, type ValidationErrorMap, renderCodeInjection, validateSubmission };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
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";
|
|
2
2
|
|
|
3
3
|
//#region src/code-injection.d.ts
|
|
4
4
|
/**
|
|
@@ -135,4 +135,4 @@ declare class ForjaNetworkError extends ForjaError {
|
|
|
135
135
|
constructor(message?: string, /** The underlying network error (e.g. `TypeError: Failed to fetch`). */cause?: Error | undefined);
|
|
136
136
|
}
|
|
137
137
|
//#endregion
|
|
138
|
-
export { type AnalyticsPageDetailResponse, type AnalyticsPageParams, type AnalyticsReportParams, type AnalyticsReportResponse, type BlogDetailResponse, type BlogDocumentResponse, type BlogListItem, type BlogResponse, type CategoryResponse, type CategoryTree, type CategoryWithCountResponse, type CodeInjection, type ContentStatus, type CvEntryParams, type CvEntryResponse, type CvEntryType, type DocumentLocalizationResponse, ForjaAuthError, ForjaClient, type ForjaClientConfig, ForjaError, ForjaNetworkError, ForjaNotFoundError, ForjaPermissionError, ForjaRateLimitError, ForjaServerError, ForjaValidationError, type FormBotProtection, type FormFieldDefinition, type FormFieldType, type FormFieldValidation, type FormSubmitData, type FormSubmitResponse, type HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type PublicFormDefinition, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SelfServiceLookup, type SelfServiceSubmission, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type SubmitFormOptions, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint, type ValidationErrorMap, renderCodeInjection, validateSubmission };
|
|
138
|
+
export { type AnalyticsPageDetailResponse, type AnalyticsPageParams, type AnalyticsReportParams, type AnalyticsReportResponse, type BlogDetailResponse, type BlogDocumentResponse, type BlogListItem, type BlogResponse, type CategoryResponse, type CategoryTree, type CategoryWithCountResponse, type CodeInjection, CollectionsResource, type ContentStatus, type CvEntryParams, type CvEntryResponse, type CvEntryType, type DocumentLocalizationResponse, ForjaAuthError, ForjaClient, type ForjaClientConfig, ForjaError, ForjaNetworkError, ForjaNotFoundError, ForjaPermissionError, ForjaRateLimitError, ForjaServerError, ForjaValidationError, type FormBotProtection, type FormFieldDefinition, type FormFieldType, type FormFieldValidation, type FormSubmitData, type FormSubmitResponse, type HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type PublicCollectionEntry, type PublicCollectionField, type PublicCollectionListParams, type PublicCollectionSchema, type PublicFormDefinition, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SelfServiceLookup, type SelfServiceSubmission, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type SubmitFormOptions, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint, type ValidationErrorMap, renderCodeInjection, validateSubmission };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,
|
|
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};
|
package/package.json
CHANGED
package/dist/client-BsrJVReZ.cjs
DELETED
|
@@ -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){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}}},_=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 v=/^[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}$/;function y(e,t){let n={};for(let r of e.fields){let e=t[r.label],i=b(r,e);i&&(n[r.label]=i)}return n}function b(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`?v.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 x=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`)}},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}/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}}},C=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}}},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}/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`)}},T=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}}},E=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}}},D=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??``}}},O=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},k=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`)}},A=class{constructor(e){let t=f(e);this.blogs=new h(t,e.siteId),this.pages=new w(t,e.siteId),this.navigation=new C(t,e.siteId),this.taxonomy=new k(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new g(t,e.siteId),this.legal=new x(t,e.siteId),this.projects=new T(t,e.siteId),this.redirects=new E(t,e.siteId),this.site=new D(t,e.siteId),this.media=new S(t,e.siteId),this.social=new O(t,e.siteId),this.forms=new _(t)}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return a}});
|
package/dist/client-CMLPs3ca.mjs
DELETED
|
@@ -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){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}}},_=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 v=/^[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}$/;function y(e,t){let n={};for(let r of e.fields){let e=t[r.label],i=b(r,e);i&&(n[r.label]=i)}return n}function b(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`?v.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 x=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`)}},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}/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}}},C=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}}},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}/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`)}},T=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}}},E=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}}},D=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??``}}},O=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},k=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`)}},A=class{constructor(e){let t=f(e);this.blogs=new h(t,e.siteId),this.pages=new w(t,e.siteId),this.navigation=new C(t,e.siteId),this.taxonomy=new k(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new g(t,e.siteId),this.legal=new x(t,e.siteId),this.projects=new T(t,e.siteId),this.redirects=new E(t,e.siteId),this.site=new D(t,e.siteId),this.media=new S(t,e.siteId),this.social=new O(t,e.siteId),this.forms=new _(t)}};export{s as a,i as c,e as i,o as l,y as n,r as o,t as r,n as s,A as t,a as u};
|