@forjacms/client 1.7.5 → 1.7.7
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-BsrJVReZ.cjs +1 -0
- package/dist/client-CMLPs3ca.mjs +1 -0
- package/dist/{client-CUbs1rkJ.d.cts → client-DnlMLCQX.d.cts} +22 -0
- package/dist/{client-HGIKi26O.d.mts → client-suk46QJJ.d.mts} +22 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/client-CWajZ1IX.mjs +0 -1
- package/dist/client-DVY5u6LJ.cjs +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-BsrJVReZ.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 { N as ForjaClientConfig, t as ForjaClient } from "../client-
|
|
1
|
+
import { N as ForjaClientConfig, t as ForjaClient } from "../client-DnlMLCQX.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 { N as ForjaClientConfig, t as ForjaClient } from "../client-
|
|
1
|
+
import { N as ForjaClientConfig, t as ForjaClient } from "../client-suk46QJJ.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-CMLPs3ca.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){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}});
|
|
@@ -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){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};
|
|
@@ -1063,6 +1063,21 @@ interface PublicFormDefinition {
|
|
|
1063
1063
|
bot_protection: FormBotProtection;
|
|
1064
1064
|
fields: FormFieldDefinition[];
|
|
1065
1065
|
}
|
|
1066
|
+
/**
|
|
1067
|
+
* A self-hosted ALTCHA challenge (#770), issued per form when the site uses
|
|
1068
|
+
* ALTCHA bot protection. Passed verbatim to the `<altcha-widget>` via its
|
|
1069
|
+
* `challenge` attribute (altcha v3; a JSON string is treated as inline
|
|
1070
|
+
* challenge data, a URL as an endpoint to fetch from). The widget solves it
|
|
1071
|
+
* client-side; the solved payload is submitted as
|
|
1072
|
+
* {@link SubmitFormOptions.botProtectionToken}.
|
|
1073
|
+
*/
|
|
1074
|
+
interface AltchaChallenge {
|
|
1075
|
+
algorithm: string;
|
|
1076
|
+
challenge: string;
|
|
1077
|
+
maxnumber: number;
|
|
1078
|
+
salt: string;
|
|
1079
|
+
signature: string;
|
|
1080
|
+
}
|
|
1066
1081
|
interface FormSubmitData {
|
|
1067
1082
|
[fieldLabel: string]: unknown;
|
|
1068
1083
|
}
|
|
@@ -1109,6 +1124,13 @@ declare class FormsResource {
|
|
|
1109
1124
|
getForm(slug: string, opts?: {
|
|
1110
1125
|
locale?: string;
|
|
1111
1126
|
}): Promise<PublicFormDefinition>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Fetch a fresh self-hosted ALTCHA challenge for a form (#770). Call this
|
|
1129
|
+
* only when {@link PublicFormDefinition.bot_protection} is `'mandatory'`
|
|
1130
|
+
* and the site uses ALTCHA mode; the server returns 409 otherwise. Each
|
|
1131
|
+
* call yields a fresh, single-use challenge.
|
|
1132
|
+
*/
|
|
1133
|
+
getAltchaChallenge(slug: string): Promise<AltchaChallenge>;
|
|
1112
1134
|
/**
|
|
1113
1135
|
* Submit a form. Throws a {@link ForjaValidationError} if the server
|
|
1114
1136
|
* rejects the payload with field-level errors.
|
|
@@ -1063,6 +1063,21 @@ interface PublicFormDefinition {
|
|
|
1063
1063
|
bot_protection: FormBotProtection;
|
|
1064
1064
|
fields: FormFieldDefinition[];
|
|
1065
1065
|
}
|
|
1066
|
+
/**
|
|
1067
|
+
* A self-hosted ALTCHA challenge (#770), issued per form when the site uses
|
|
1068
|
+
* ALTCHA bot protection. Passed verbatim to the `<altcha-widget>` via its
|
|
1069
|
+
* `challenge` attribute (altcha v3; a JSON string is treated as inline
|
|
1070
|
+
* challenge data, a URL as an endpoint to fetch from). The widget solves it
|
|
1071
|
+
* client-side; the solved payload is submitted as
|
|
1072
|
+
* {@link SubmitFormOptions.botProtectionToken}.
|
|
1073
|
+
*/
|
|
1074
|
+
interface AltchaChallenge {
|
|
1075
|
+
algorithm: string;
|
|
1076
|
+
challenge: string;
|
|
1077
|
+
maxnumber: number;
|
|
1078
|
+
salt: string;
|
|
1079
|
+
signature: string;
|
|
1080
|
+
}
|
|
1066
1081
|
interface FormSubmitData {
|
|
1067
1082
|
[fieldLabel: string]: unknown;
|
|
1068
1083
|
}
|
|
@@ -1109,6 +1124,13 @@ declare class FormsResource {
|
|
|
1109
1124
|
getForm(slug: string, opts?: {
|
|
1110
1125
|
locale?: string;
|
|
1111
1126
|
}): Promise<PublicFormDefinition>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Fetch a fresh self-hosted ALTCHA challenge for a form (#770). Call this
|
|
1129
|
+
* only when {@link PublicFormDefinition.bot_protection} is `'mandatory'`
|
|
1130
|
+
* and the site uses ALTCHA mode; the server returns 409 otherwise. Each
|
|
1131
|
+
* call yields a fresh, single-use challenge.
|
|
1132
|
+
*/
|
|
1133
|
+
getAltchaChallenge(slug: string): Promise<AltchaChallenge>;
|
|
1112
1134
|
/**
|
|
1113
1135
|
* Submit a form. Throws a {@link ForjaValidationError} if the server
|
|
1114
1136
|
* rejects the payload with field-level errors.
|
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-BsrJVReZ.cjs`);function t(e){return{head:e.code_injection_head,footer:e.code_injection_footer}}exports.ForjaAuthError=e.r,exports.ForjaClient=e.t,exports.ForjaError=e.i,exports.ForjaNetworkError=e.a,exports.ForjaNotFoundError=e.o,exports.ForjaPermissionError=e.s,exports.ForjaRateLimitError=e.c,exports.ForjaServerError=e.l,exports.ForjaValidationError=e.u,exports.renderCodeInjection=t,exports.validateSubmission=e.n;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as NavigationTree, A as CvEntryResponse, At as TranslationStatus, B as LegalGroupResponse, C as BlogResponse, Ct as SkillCategory, D as CodeInjection, Dt as TopContentItem, E as CategoryWithCountResponse, Et as TagResponse, F as LegalDocType, G as LocalizationResponse, H as LegalItemResponse, I as LegalDocumentDetailResponse, J as MediaResponse, K as MediaListItem, L as LegalDocumentFullDetailResponse, M as DocumentLocalizationResponse, N as ForjaClientConfig, O as ContentStatus, Ot as TrackPageviewRequest, P as LegalDocLocalizationResponse, Q as NavigationMenuResponse, R as LegalDocumentResponse, S as BlogListItem, St as SiteResponse, T as CategoryTree, Tt as SocialLinkResponse, U as LegalVersionResponse, V as LegalGroupWithItems, W as LocaleFilterParams, X as NavigationItemLocalizationResponse, Y as MediaVariantResponse, Z as NavigationItemResponse, _ as AnalyticsPageParams, _t as ReferrerItem, a as FormFieldValidation, at as Paginated, b as BlogDetailResponse, bt as SectionType, c as PublicFormDefinition, ct as ProjectDetailResponse, d as SubmitFormOptions, dt as ProjectListParams, et as PageDetailResponse, f as ValidationErrorMap, ft as ProjectLocalizationResponse, g as AnalyticsPageDetailResponse, gt as RedirectResponse, h as PaginatedResult, ht as RedirectLookupResponse, i as FormFieldType, it as PageType, j as CvEntryType, jt as TrendDataPoint, k as CvEntryParams, kt as TrackPageviewResponse, l as SelfServiceLookup, lt as ProjectLinkResponse, m as HttpClient, mt as ProjectResponse, n as FormBotProtection, nt as PageResponse, o as FormSubmitData, ot as PaginationMeta, p as validateSubmission, pt as ProjectMediaResponse, q as MediaListParams, r as FormFieldDefinition, rt as PageSectionResponse, s as FormSubmitResponse, st as PaginationParams, t as ForjaClient, tt as PageListItem, u as SelfServiceSubmission, ut as ProjectLinkType, v as AnalyticsReportParams, vt as SearchablePaginationParams, w as CategoryResponse, wt as SkillResponse, x as BlogDocumentResponse, xt as SiteLocaleResponse, y as AnalyticsReportResponse, yt as SectionLocalizationResponse, z as LegalDocumentWithGroups } from "./client-
|
|
1
|
+
import { $ as NavigationTree, A as CvEntryResponse, At as TranslationStatus, B as LegalGroupResponse, C as BlogResponse, Ct as SkillCategory, D as CodeInjection, Dt as TopContentItem, E as CategoryWithCountResponse, Et as TagResponse, F as LegalDocType, G as LocalizationResponse, H as LegalItemResponse, I as LegalDocumentDetailResponse, J as MediaResponse, K as MediaListItem, L as LegalDocumentFullDetailResponse, M as DocumentLocalizationResponse, N as ForjaClientConfig, O as ContentStatus, Ot as TrackPageviewRequest, P as LegalDocLocalizationResponse, Q as NavigationMenuResponse, R as LegalDocumentResponse, S as BlogListItem, St as SiteResponse, T as CategoryTree, Tt as SocialLinkResponse, U as LegalVersionResponse, V as LegalGroupWithItems, W as LocaleFilterParams, X as NavigationItemLocalizationResponse, Y as MediaVariantResponse, Z as NavigationItemResponse, _ as AnalyticsPageParams, _t as ReferrerItem, a as FormFieldValidation, at as Paginated, b as BlogDetailResponse, bt as SectionType, c as PublicFormDefinition, ct as ProjectDetailResponse, d as SubmitFormOptions, dt as ProjectListParams, et as PageDetailResponse, f as ValidationErrorMap, ft as ProjectLocalizationResponse, g as AnalyticsPageDetailResponse, gt as RedirectResponse, h as PaginatedResult, ht as RedirectLookupResponse, i as FormFieldType, it as PageType, j as CvEntryType, jt as TrendDataPoint, k as CvEntryParams, kt as TrackPageviewResponse, l as SelfServiceLookup, lt as ProjectLinkResponse, m as HttpClient, mt as ProjectResponse, n as FormBotProtection, nt as PageResponse, o as FormSubmitData, ot as PaginationMeta, p as validateSubmission, pt as ProjectMediaResponse, q as MediaListParams, r as FormFieldDefinition, rt as PageSectionResponse, s as FormSubmitResponse, st as PaginationParams, t as ForjaClient, tt as PageListItem, u as SelfServiceSubmission, ut as ProjectLinkType, v as AnalyticsReportParams, vt as SearchablePaginationParams, w as CategoryResponse, wt as SkillResponse, x as BlogDocumentResponse, xt as SiteLocaleResponse, y as AnalyticsReportResponse, yt as SectionLocalizationResponse, z as LegalDocumentWithGroups } from "./client-DnlMLCQX.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/code-injection.d.ts
|
|
4
4
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as NavigationTree, A as CvEntryResponse, At as TranslationStatus, B as LegalGroupResponse, C as BlogResponse, Ct as SkillCategory, D as CodeInjection, Dt as TopContentItem, E as CategoryWithCountResponse, Et as TagResponse, F as LegalDocType, G as LocalizationResponse, H as LegalItemResponse, I as LegalDocumentDetailResponse, J as MediaResponse, K as MediaListItem, L as LegalDocumentFullDetailResponse, M as DocumentLocalizationResponse, N as ForjaClientConfig, O as ContentStatus, Ot as TrackPageviewRequest, P as LegalDocLocalizationResponse, Q as NavigationMenuResponse, R as LegalDocumentResponse, S as BlogListItem, St as SiteResponse, T as CategoryTree, Tt as SocialLinkResponse, U as LegalVersionResponse, V as LegalGroupWithItems, W as LocaleFilterParams, X as NavigationItemLocalizationResponse, Y as MediaVariantResponse, Z as NavigationItemResponse, _ as AnalyticsPageParams, _t as ReferrerItem, a as FormFieldValidation, at as Paginated, b as BlogDetailResponse, bt as SectionType, c as PublicFormDefinition, ct as ProjectDetailResponse, d as SubmitFormOptions, dt as ProjectListParams, et as PageDetailResponse, f as ValidationErrorMap, ft as ProjectLocalizationResponse, g as AnalyticsPageDetailResponse, gt as RedirectResponse, h as PaginatedResult, ht as RedirectLookupResponse, i as FormFieldType, it as PageType, j as CvEntryType, jt as TrendDataPoint, k as CvEntryParams, kt as TrackPageviewResponse, l as SelfServiceLookup, lt as ProjectLinkResponse, m as HttpClient, mt as ProjectResponse, n as FormBotProtection, nt as PageResponse, o as FormSubmitData, ot as PaginationMeta, p as validateSubmission, pt as ProjectMediaResponse, q as MediaListParams, r as FormFieldDefinition, rt as PageSectionResponse, s as FormSubmitResponse, st as PaginationParams, t as ForjaClient, tt as PageListItem, u as SelfServiceSubmission, ut as ProjectLinkType, v as AnalyticsReportParams, vt as SearchablePaginationParams, w as CategoryResponse, wt as SkillResponse, x as BlogDocumentResponse, xt as SiteLocaleResponse, y as AnalyticsReportResponse, yt as SectionLocalizationResponse, z as LegalDocumentWithGroups } from "./client-
|
|
1
|
+
import { $ as NavigationTree, A as CvEntryResponse, At as TranslationStatus, B as LegalGroupResponse, C as BlogResponse, Ct as SkillCategory, D as CodeInjection, Dt as TopContentItem, E as CategoryWithCountResponse, Et as TagResponse, F as LegalDocType, G as LocalizationResponse, H as LegalItemResponse, I as LegalDocumentDetailResponse, J as MediaResponse, K as MediaListItem, L as LegalDocumentFullDetailResponse, M as DocumentLocalizationResponse, N as ForjaClientConfig, O as ContentStatus, Ot as TrackPageviewRequest, P as LegalDocLocalizationResponse, Q as NavigationMenuResponse, R as LegalDocumentResponse, S as BlogListItem, St as SiteResponse, T as CategoryTree, Tt as SocialLinkResponse, U as LegalVersionResponse, V as LegalGroupWithItems, W as LocaleFilterParams, X as NavigationItemLocalizationResponse, Y as MediaVariantResponse, Z as NavigationItemResponse, _ as AnalyticsPageParams, _t as ReferrerItem, a as FormFieldValidation, at as Paginated, b as BlogDetailResponse, bt as SectionType, c as PublicFormDefinition, ct as ProjectDetailResponse, d as SubmitFormOptions, dt as ProjectListParams, et as PageDetailResponse, f as ValidationErrorMap, ft as ProjectLocalizationResponse, g as AnalyticsPageDetailResponse, gt as RedirectResponse, h as PaginatedResult, ht as RedirectLookupResponse, i as FormFieldType, it as PageType, j as CvEntryType, jt as TrendDataPoint, k as CvEntryParams, kt as TrackPageviewResponse, l as SelfServiceLookup, lt as ProjectLinkResponse, m as HttpClient, mt as ProjectResponse, n as FormBotProtection, nt as PageResponse, o as FormSubmitData, ot as PaginationMeta, p as validateSubmission, pt as ProjectMediaResponse, q as MediaListParams, r as FormFieldDefinition, rt as PageSectionResponse, s as FormSubmitResponse, st as PaginationParams, t as ForjaClient, tt as PageListItem, u as SelfServiceSubmission, ut as ProjectLinkType, v as AnalyticsReportParams, vt as SearchablePaginationParams, w as CategoryResponse, wt as SkillResponse, x as BlogDocumentResponse, xt as SiteLocaleResponse, y as AnalyticsReportResponse, yt as SectionLocalizationResponse, z as LegalDocumentWithGroups } from "./client-suk46QJJ.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/code-injection.d.ts
|
|
4
4
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./client-
|
|
1
|
+
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./client-CMLPs3ca.mjs";function u(e){return{head:e.code_injection_head,footer:e.code_injection_footer}}export{o as ForjaAuthError,c as ForjaClient,n as ForjaError,e as ForjaNetworkError,a as ForjaNotFoundError,s as ForjaPermissionError,t as ForjaRateLimitError,r as ForjaServerError,l as ForjaValidationError,u as renderCodeInjection,i as validateSubmission};
|
package/package.json
CHANGED
package/dist/client-CWajZ1IX.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 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};
|
package/dist/client-DVY5u6LJ.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 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}});
|