@forjacms/client 1.4.5 → 1.5.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-B6llPNEv.d.cts → client-BTbTifpr.d.mts} +125 -1
- package/dist/client-C-2JZF6o.mjs +1 -0
- package/dist/{client-CyzDT4Ir.d.mts → client-CvbFQ08l.d.cts} +125 -1
- package/dist/client-FailsuXv.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-C6mKwSKr.mjs +0 -1
- package/dist/client-_Ak79dHS.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-FailsuXv.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 { N as ForjaClientConfig, t as ForjaClient } from "../client-CvbFQ08l.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 { N as ForjaClientConfig, t as ForjaClient } from "../client-BTbTifpr.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-C-2JZF6o.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};
|
|
@@ -4,6 +4,14 @@ interface ForjaClientConfig {
|
|
|
4
4
|
apiKey: string;
|
|
5
5
|
siteId: string;
|
|
6
6
|
fetch?: typeof globalThis.fetch;
|
|
7
|
+
/**
|
|
8
|
+
* Public site domain. Sent as the `X-Site-Domain` header on every
|
|
9
|
+
* request — required by the public Forms endpoints (#582/#584) which
|
|
10
|
+
* resolve the site from the domain rather than a path parameter.
|
|
11
|
+
* Optional: omit when only authenticated, site_id-scoped endpoints
|
|
12
|
+
* are used.
|
|
13
|
+
*/
|
|
14
|
+
siteDomain?: string;
|
|
7
15
|
}
|
|
8
16
|
interface PaginationMeta {
|
|
9
17
|
page: number;
|
|
@@ -544,6 +552,8 @@ interface HttpClient {
|
|
|
544
552
|
getText(path: string, params?: Record<string, string | undefined>): Promise<string>;
|
|
545
553
|
/** Send a POST request with a JSON body. */
|
|
546
554
|
post<T>(path: string, body?: unknown): Promise<T>;
|
|
555
|
+
/** Send a DELETE request. Resolves on any 2xx; throws on 4xx/5xx. */
|
|
556
|
+
delete(path: string): Promise<void>;
|
|
547
557
|
}
|
|
548
558
|
/**
|
|
549
559
|
* A paginated API response enriched with navigation helpers.
|
|
@@ -855,6 +865,118 @@ declare class CvResource {
|
|
|
855
865
|
listEntries(params?: CvEntryParams): Promise<PaginatedResult<CvEntryResponse>>;
|
|
856
866
|
}
|
|
857
867
|
//#endregion
|
|
868
|
+
//#region src/resources/forms.d.ts
|
|
869
|
+
type FormFieldType = 'text' | 'textarea' | 'email' | 'number' | 'select' | 'checkbox' | 'radio' | 'date' | 'custom';
|
|
870
|
+
type FormBotProtection = 'none' | 'mandatory';
|
|
871
|
+
/**
|
|
872
|
+
* Field-level validation rules. All optional — the form builder picks
|
|
873
|
+
* the rules that apply to the field's type.
|
|
874
|
+
*/
|
|
875
|
+
interface FormFieldValidation {
|
|
876
|
+
required?: boolean;
|
|
877
|
+
min_length?: number;
|
|
878
|
+
max_length?: number;
|
|
879
|
+
min?: number;
|
|
880
|
+
max?: number;
|
|
881
|
+
/** ECMAScript regex pattern. Server uses Rust's `regex` crate, which
|
|
882
|
+
* supports most ECMAScript syntax but not lookbehind/lookahead. */
|
|
883
|
+
pattern?: string;
|
|
884
|
+
}
|
|
885
|
+
interface FormFieldDefinition {
|
|
886
|
+
id: string;
|
|
887
|
+
/** Technical key used as the submission JSONB key. Never localized. */
|
|
888
|
+
label: string;
|
|
889
|
+
/** Visitor-facing label. Set by the public endpoint when ?locale= matches a
|
|
890
|
+
* localization; defaults to `label` when no translation applies. */
|
|
891
|
+
display_label?: string;
|
|
892
|
+
field_type: FormFieldType;
|
|
893
|
+
placeholder?: string | null;
|
|
894
|
+
help_text?: string | null;
|
|
895
|
+
validation: FormFieldValidation;
|
|
896
|
+
options?: unknown;
|
|
897
|
+
is_required: boolean;
|
|
898
|
+
display_order: number;
|
|
899
|
+
}
|
|
900
|
+
interface PublicFormDefinition {
|
|
901
|
+
id: string;
|
|
902
|
+
site_id: string;
|
|
903
|
+
name: string;
|
|
904
|
+
slug: string;
|
|
905
|
+
description?: string | null;
|
|
906
|
+
consent_required: boolean;
|
|
907
|
+
consent_text?: string | null;
|
|
908
|
+
bot_protection: FormBotProtection;
|
|
909
|
+
fields: FormFieldDefinition[];
|
|
910
|
+
}
|
|
911
|
+
interface FormSubmitData {
|
|
912
|
+
[fieldLabel: string]: unknown;
|
|
913
|
+
}
|
|
914
|
+
interface FormSubmitResponse {
|
|
915
|
+
submission_id: string;
|
|
916
|
+
reference_code: string;
|
|
917
|
+
}
|
|
918
|
+
interface SubmitFormOptions {
|
|
919
|
+
consentGiven?: boolean;
|
|
920
|
+
botProtectionToken?: string;
|
|
921
|
+
}
|
|
922
|
+
interface SelfServiceLookup {
|
|
923
|
+
status: string;
|
|
924
|
+
created_at: string;
|
|
925
|
+
}
|
|
926
|
+
interface SelfServiceSubmission {
|
|
927
|
+
reference_code: string;
|
|
928
|
+
status: string;
|
|
929
|
+
data: FormSubmitData;
|
|
930
|
+
consent_given: boolean;
|
|
931
|
+
consent_text_at_submission?: string | null;
|
|
932
|
+
created_at: string;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Client-side validation error map — keyed by field label, mirroring the
|
|
936
|
+
* server's field-keyed error shape.
|
|
937
|
+
*/
|
|
938
|
+
type ValidationErrorMap = Record<string, string>;
|
|
939
|
+
/**
|
|
940
|
+
* Forms module client (#586). Unauthenticated public endpoints; the site
|
|
941
|
+
* is resolved by the `X-Site-Domain` header set on the `ForjaClient`
|
|
942
|
+
* config — make sure `siteDomain` is set before calling these.
|
|
943
|
+
*/
|
|
944
|
+
declare class FormsResource {
|
|
945
|
+
private readonly http;
|
|
946
|
+
constructor(http: HttpClient);
|
|
947
|
+
/** Fetch a form definition by slug for rendering. */
|
|
948
|
+
/**
|
|
949
|
+
* Fetch a form definition for rendering. Pass `locale` (code or UUID) to
|
|
950
|
+
* receive localized text in `name` / `description` / `consent_text` and
|
|
951
|
+
* each field's `display_label` / `placeholder` / `help_text`. Unknown
|
|
952
|
+
* locales fall through to the form's canonical/default-locale values.
|
|
953
|
+
*/
|
|
954
|
+
getForm(slug: string, opts?: {
|
|
955
|
+
locale?: string;
|
|
956
|
+
}): Promise<PublicFormDefinition>;
|
|
957
|
+
/**
|
|
958
|
+
* Submit a form. Throws a {@link ForjaValidationError} if the server
|
|
959
|
+
* rejects the payload with field-level errors.
|
|
960
|
+
*/
|
|
961
|
+
submitForm(slug: string, data: FormSubmitData, opts?: SubmitFormOptions): Promise<FormSubmitResponse>;
|
|
962
|
+
/** Privacy-preserving lookup: status + submitted-at only. */
|
|
963
|
+
lookupSubmission(referenceCode: string): Promise<SelfServiceLookup>;
|
|
964
|
+
/** Visitor's own full view of their submission. */
|
|
965
|
+
getSubmission(referenceCode: string): Promise<SelfServiceSubmission>;
|
|
966
|
+
/** Idempotent self-service delete. Throws on 404/410. */
|
|
967
|
+
deleteSubmission(referenceCode: string): Promise<void>;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Validate a submission payload against a form definition. Mirrors the
|
|
971
|
+
* server-side rules in {@link `models/form_submission.rs:validate_submission`}.
|
|
972
|
+
* Returns an empty object on success; otherwise a `{ label: message }` map.
|
|
973
|
+
*
|
|
974
|
+
* Template authors call this before {@link FormsResource.submitForm} so
|
|
975
|
+
* visitors get inline feedback without a round-trip — but the server
|
|
976
|
+
* always re-validates, so this is purely a UX accelerator.
|
|
977
|
+
*/
|
|
978
|
+
declare function validateSubmission(form: PublicFormDefinition, data: FormSubmitData): ValidationErrorMap;
|
|
979
|
+
//#endregion
|
|
858
980
|
//#region src/resources/legal.d.ts
|
|
859
981
|
/**
|
|
860
982
|
* Legal document operations.
|
|
@@ -1690,6 +1812,8 @@ declare class ForjaClient {
|
|
|
1690
1812
|
readonly media: MediaResource;
|
|
1691
1813
|
/** Social media links — GitHub, Twitter, LinkedIn, etc. */
|
|
1692
1814
|
readonly social: SocialResource;
|
|
1815
|
+
/** Forms module — public form rendering, submission, and self-service. */
|
|
1816
|
+
readonly forms: FormsResource;
|
|
1693
1817
|
/**
|
|
1694
1818
|
* @param config - API connection settings.
|
|
1695
1819
|
* @param config.baseUrl - Full URL to the Forja API (e.g. `https://cms.example.com/api/v1`).
|
|
@@ -1700,4 +1824,4 @@ declare class ForjaClient {
|
|
|
1700
1824
|
constructor(config: ForjaClientConfig);
|
|
1701
1825
|
}
|
|
1702
1826
|
//#endregion
|
|
1703
|
-
export {
|
|
1827
|
+
export { NavigationTree as $, CvEntryResponse as A, TranslationStatus as At, LegalGroupResponse as B, BlogResponse as C, SkillCategory as Ct, CodeInjection as D, TopContentItem as Dt, CategoryWithCountResponse as E, TagResponse as Et, LegalDocType as F, LocalizationResponse as G, LegalItemResponse as H, LegalDocumentDetailResponse as I, MediaResponse as J, MediaListItem as K, LegalDocumentFullDetailResponse as L, DocumentLocalizationResponse as M, ForjaClientConfig as N, ContentStatus as O, TrackPageviewRequest as Ot, LegalDocLocalizationResponse as P, NavigationMenuResponse as Q, LegalDocumentResponse as R, BlogListItem as S, SiteResponse as St, CategoryTree as T, SocialLinkResponse as Tt, LegalVersionResponse as U, LegalGroupWithItems as V, LocaleFilterParams as W, NavigationItemLocalizationResponse as X, MediaVariantResponse as Y, NavigationItemResponse as Z, AnalyticsPageParams as _, ReferrerItem as _t, FormFieldValidation as a, Paginated as at, BlogDetailResponse as b, SectionType as bt, PublicFormDefinition as c, ProjectDetailResponse as ct, SubmitFormOptions as d, ProjectListParams as dt, PageDetailResponse as et, ValidationErrorMap as f, ProjectLocalizationResponse as ft, AnalyticsPageDetailResponse as g, RedirectResponse as gt, PaginatedResult as h, RedirectLookupResponse as ht, FormFieldType as i, PageType as it, CvEntryType as j, TrendDataPoint as jt, CvEntryParams as k, TrackPageviewResponse as kt, SelfServiceLookup as l, ProjectLinkResponse as lt, HttpClient as m, ProjectResponse as mt, FormBotProtection as n, PageResponse as nt, FormSubmitData as o, PaginationMeta as ot, validateSubmission as p, ProjectMediaResponse as pt, MediaListParams as q, FormFieldDefinition as r, PageSectionResponse as rt, FormSubmitResponse as s, PaginationParams as st, ForjaClient as t, PageListItem as tt, SelfServiceSubmission as u, ProjectLinkType as ut, AnalyticsReportParams as v, SearchablePaginationParams as vt, CategoryResponse as w, SkillResponse as wt, BlogDocumentResponse as x, SiteLocaleResponse as xt, AnalyticsReportResponse as y, SectionLocalizationResponse as yt, LegalDocumentWithGroups 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){try{let t=await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return await this.http.get(`/blogs/${t.id}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async get(e){try{return await this.http.get(`/blogs/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},g=class{constructor(e,t){this.http=e,this.siteId=t}async listSkills(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/skills`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getSkill(e){try{return await this.http.get(`/skills/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e){try{return await this.http.get(`/skills/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async listEntries(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/cv`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}},_=class{constructor(e){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){try{return await this.http.get(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCookieConsent(){try{return await this.http.get(`/sites/${this.siteId}/legal/cookie-consent`)}catch(e){if(e instanceof r)return null;throw e}}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async getDetail(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},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 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){try{return await this.http.get(`/projects/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},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};
|
|
@@ -4,6 +4,14 @@ interface ForjaClientConfig {
|
|
|
4
4
|
apiKey: string;
|
|
5
5
|
siteId: string;
|
|
6
6
|
fetch?: typeof globalThis.fetch;
|
|
7
|
+
/**
|
|
8
|
+
* Public site domain. Sent as the `X-Site-Domain` header on every
|
|
9
|
+
* request — required by the public Forms endpoints (#582/#584) which
|
|
10
|
+
* resolve the site from the domain rather than a path parameter.
|
|
11
|
+
* Optional: omit when only authenticated, site_id-scoped endpoints
|
|
12
|
+
* are used.
|
|
13
|
+
*/
|
|
14
|
+
siteDomain?: string;
|
|
7
15
|
}
|
|
8
16
|
interface PaginationMeta {
|
|
9
17
|
page: number;
|
|
@@ -544,6 +552,8 @@ interface HttpClient {
|
|
|
544
552
|
getText(path: string, params?: Record<string, string | undefined>): Promise<string>;
|
|
545
553
|
/** Send a POST request with a JSON body. */
|
|
546
554
|
post<T>(path: string, body?: unknown): Promise<T>;
|
|
555
|
+
/** Send a DELETE request. Resolves on any 2xx; throws on 4xx/5xx. */
|
|
556
|
+
delete(path: string): Promise<void>;
|
|
547
557
|
}
|
|
548
558
|
/**
|
|
549
559
|
* A paginated API response enriched with navigation helpers.
|
|
@@ -855,6 +865,118 @@ declare class CvResource {
|
|
|
855
865
|
listEntries(params?: CvEntryParams): Promise<PaginatedResult<CvEntryResponse>>;
|
|
856
866
|
}
|
|
857
867
|
//#endregion
|
|
868
|
+
//#region src/resources/forms.d.ts
|
|
869
|
+
type FormFieldType = 'text' | 'textarea' | 'email' | 'number' | 'select' | 'checkbox' | 'radio' | 'date' | 'custom';
|
|
870
|
+
type FormBotProtection = 'none' | 'mandatory';
|
|
871
|
+
/**
|
|
872
|
+
* Field-level validation rules. All optional — the form builder picks
|
|
873
|
+
* the rules that apply to the field's type.
|
|
874
|
+
*/
|
|
875
|
+
interface FormFieldValidation {
|
|
876
|
+
required?: boolean;
|
|
877
|
+
min_length?: number;
|
|
878
|
+
max_length?: number;
|
|
879
|
+
min?: number;
|
|
880
|
+
max?: number;
|
|
881
|
+
/** ECMAScript regex pattern. Server uses Rust's `regex` crate, which
|
|
882
|
+
* supports most ECMAScript syntax but not lookbehind/lookahead. */
|
|
883
|
+
pattern?: string;
|
|
884
|
+
}
|
|
885
|
+
interface FormFieldDefinition {
|
|
886
|
+
id: string;
|
|
887
|
+
/** Technical key used as the submission JSONB key. Never localized. */
|
|
888
|
+
label: string;
|
|
889
|
+
/** Visitor-facing label. Set by the public endpoint when ?locale= matches a
|
|
890
|
+
* localization; defaults to `label` when no translation applies. */
|
|
891
|
+
display_label?: string;
|
|
892
|
+
field_type: FormFieldType;
|
|
893
|
+
placeholder?: string | null;
|
|
894
|
+
help_text?: string | null;
|
|
895
|
+
validation: FormFieldValidation;
|
|
896
|
+
options?: unknown;
|
|
897
|
+
is_required: boolean;
|
|
898
|
+
display_order: number;
|
|
899
|
+
}
|
|
900
|
+
interface PublicFormDefinition {
|
|
901
|
+
id: string;
|
|
902
|
+
site_id: string;
|
|
903
|
+
name: string;
|
|
904
|
+
slug: string;
|
|
905
|
+
description?: string | null;
|
|
906
|
+
consent_required: boolean;
|
|
907
|
+
consent_text?: string | null;
|
|
908
|
+
bot_protection: FormBotProtection;
|
|
909
|
+
fields: FormFieldDefinition[];
|
|
910
|
+
}
|
|
911
|
+
interface FormSubmitData {
|
|
912
|
+
[fieldLabel: string]: unknown;
|
|
913
|
+
}
|
|
914
|
+
interface FormSubmitResponse {
|
|
915
|
+
submission_id: string;
|
|
916
|
+
reference_code: string;
|
|
917
|
+
}
|
|
918
|
+
interface SubmitFormOptions {
|
|
919
|
+
consentGiven?: boolean;
|
|
920
|
+
botProtectionToken?: string;
|
|
921
|
+
}
|
|
922
|
+
interface SelfServiceLookup {
|
|
923
|
+
status: string;
|
|
924
|
+
created_at: string;
|
|
925
|
+
}
|
|
926
|
+
interface SelfServiceSubmission {
|
|
927
|
+
reference_code: string;
|
|
928
|
+
status: string;
|
|
929
|
+
data: FormSubmitData;
|
|
930
|
+
consent_given: boolean;
|
|
931
|
+
consent_text_at_submission?: string | null;
|
|
932
|
+
created_at: string;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Client-side validation error map — keyed by field label, mirroring the
|
|
936
|
+
* server's field-keyed error shape.
|
|
937
|
+
*/
|
|
938
|
+
type ValidationErrorMap = Record<string, string>;
|
|
939
|
+
/**
|
|
940
|
+
* Forms module client (#586). Unauthenticated public endpoints; the site
|
|
941
|
+
* is resolved by the `X-Site-Domain` header set on the `ForjaClient`
|
|
942
|
+
* config — make sure `siteDomain` is set before calling these.
|
|
943
|
+
*/
|
|
944
|
+
declare class FormsResource {
|
|
945
|
+
private readonly http;
|
|
946
|
+
constructor(http: HttpClient);
|
|
947
|
+
/** Fetch a form definition by slug for rendering. */
|
|
948
|
+
/**
|
|
949
|
+
* Fetch a form definition for rendering. Pass `locale` (code or UUID) to
|
|
950
|
+
* receive localized text in `name` / `description` / `consent_text` and
|
|
951
|
+
* each field's `display_label` / `placeholder` / `help_text`. Unknown
|
|
952
|
+
* locales fall through to the form's canonical/default-locale values.
|
|
953
|
+
*/
|
|
954
|
+
getForm(slug: string, opts?: {
|
|
955
|
+
locale?: string;
|
|
956
|
+
}): Promise<PublicFormDefinition>;
|
|
957
|
+
/**
|
|
958
|
+
* Submit a form. Throws a {@link ForjaValidationError} if the server
|
|
959
|
+
* rejects the payload with field-level errors.
|
|
960
|
+
*/
|
|
961
|
+
submitForm(slug: string, data: FormSubmitData, opts?: SubmitFormOptions): Promise<FormSubmitResponse>;
|
|
962
|
+
/** Privacy-preserving lookup: status + submitted-at only. */
|
|
963
|
+
lookupSubmission(referenceCode: string): Promise<SelfServiceLookup>;
|
|
964
|
+
/** Visitor's own full view of their submission. */
|
|
965
|
+
getSubmission(referenceCode: string): Promise<SelfServiceSubmission>;
|
|
966
|
+
/** Idempotent self-service delete. Throws on 404/410. */
|
|
967
|
+
deleteSubmission(referenceCode: string): Promise<void>;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Validate a submission payload against a form definition. Mirrors the
|
|
971
|
+
* server-side rules in {@link `models/form_submission.rs:validate_submission`}.
|
|
972
|
+
* Returns an empty object on success; otherwise a `{ label: message }` map.
|
|
973
|
+
*
|
|
974
|
+
* Template authors call this before {@link FormsResource.submitForm} so
|
|
975
|
+
* visitors get inline feedback without a round-trip — but the server
|
|
976
|
+
* always re-validates, so this is purely a UX accelerator.
|
|
977
|
+
*/
|
|
978
|
+
declare function validateSubmission(form: PublicFormDefinition, data: FormSubmitData): ValidationErrorMap;
|
|
979
|
+
//#endregion
|
|
858
980
|
//#region src/resources/legal.d.ts
|
|
859
981
|
/**
|
|
860
982
|
* Legal document operations.
|
|
@@ -1690,6 +1812,8 @@ declare class ForjaClient {
|
|
|
1690
1812
|
readonly media: MediaResource;
|
|
1691
1813
|
/** Social media links — GitHub, Twitter, LinkedIn, etc. */
|
|
1692
1814
|
readonly social: SocialResource;
|
|
1815
|
+
/** Forms module — public form rendering, submission, and self-service. */
|
|
1816
|
+
readonly forms: FormsResource;
|
|
1693
1817
|
/**
|
|
1694
1818
|
* @param config - API connection settings.
|
|
1695
1819
|
* @param config.baseUrl - Full URL to the Forja API (e.g. `https://cms.example.com/api/v1`).
|
|
@@ -1700,4 +1824,4 @@ declare class ForjaClient {
|
|
|
1700
1824
|
constructor(config: ForjaClientConfig);
|
|
1701
1825
|
}
|
|
1702
1826
|
//#endregion
|
|
1703
|
-
export {
|
|
1827
|
+
export { NavigationTree as $, CvEntryResponse as A, TranslationStatus as At, LegalGroupResponse as B, BlogResponse as C, SkillCategory as Ct, CodeInjection as D, TopContentItem as Dt, CategoryWithCountResponse as E, TagResponse as Et, LegalDocType as F, LocalizationResponse as G, LegalItemResponse as H, LegalDocumentDetailResponse as I, MediaResponse as J, MediaListItem as K, LegalDocumentFullDetailResponse as L, DocumentLocalizationResponse as M, ForjaClientConfig as N, ContentStatus as O, TrackPageviewRequest as Ot, LegalDocLocalizationResponse as P, NavigationMenuResponse as Q, LegalDocumentResponse as R, BlogListItem as S, SiteResponse as St, CategoryTree as T, SocialLinkResponse as Tt, LegalVersionResponse as U, LegalGroupWithItems as V, LocaleFilterParams as W, NavigationItemLocalizationResponse as X, MediaVariantResponse as Y, NavigationItemResponse as Z, AnalyticsPageParams as _, ReferrerItem as _t, FormFieldValidation as a, Paginated as at, BlogDetailResponse as b, SectionType as bt, PublicFormDefinition as c, ProjectDetailResponse as ct, SubmitFormOptions as d, ProjectListParams as dt, PageDetailResponse as et, ValidationErrorMap as f, ProjectLocalizationResponse as ft, AnalyticsPageDetailResponse as g, RedirectResponse as gt, PaginatedResult as h, RedirectLookupResponse as ht, FormFieldType as i, PageType as it, CvEntryType as j, TrendDataPoint as jt, CvEntryParams as k, TrackPageviewResponse as kt, SelfServiceLookup as l, ProjectLinkResponse as lt, HttpClient as m, ProjectResponse as mt, FormBotProtection as n, PageResponse as nt, FormSubmitData as o, PaginationMeta as ot, validateSubmission as p, ProjectMediaResponse as pt, MediaListParams as q, FormFieldDefinition as r, PageSectionResponse as rt, FormSubmitResponse as s, PaginationParams as st, ForjaClient as t, PageListItem as tt, SelfServiceSubmission as u, ProjectLinkType as ut, AnalyticsReportParams as v, SearchablePaginationParams as vt, CategoryResponse as w, SkillResponse as wt, BlogDocumentResponse as x, SiteLocaleResponse as xt, AnalyticsReportResponse as y, SectionLocalizationResponse as yt, LegalDocumentWithGroups 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){try{let t=await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return await this.http.get(`/blogs/${t.id}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async get(e){try{return await this.http.get(`/blogs/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},g=class{constructor(e,t){this.http=e,this.siteId=t}async listSkills(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/skills`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getSkill(e){try{return await this.http.get(`/skills/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e){try{return await this.http.get(`/skills/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async listEntries(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/cv`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}},_=class{constructor(e){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){try{return await this.http.get(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCookieConsent(){try{return await this.http.get(`/sites/${this.siteId}/legal/cookie-consent`)}catch(e){if(e instanceof r)return null;throw e}}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async getDetail(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},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 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){try{return await this.http.get(`/projects/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},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/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-FailsuXv.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
|
|
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-CvbFQ08l.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 HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint, renderCodeInjection };
|
|
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 };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
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-BTbTifpr.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 HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint, renderCodeInjection };
|
|
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./client-
|
|
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-C-2JZF6o.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-C6mKwSKr.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`};async function i(e,i,a,o){let l=c(n,i,a),u;try{u=await t(l,{method:e,headers:r,body:o===void 0?void 0:JSON.stringify(o)})}catch(e){throw new s(`Failed to connect to the Forja API`,e instanceof Error?e:void 0)}return u.ok?u:d(u)}return{get:(e,t)=>i(`GET`,e,t).then(e=>e.json()),getText:(e,t)=>i(`GET`,e,t).then(e=>e.text()),post:(e,t)=>i(`POST`,e,void 0,t).then(e=>e.json())}}function p(e,t,n){return{data:e,meta:t,async fetchNext(){if(t.page>=t.total_pages)return null;let e=await n(t.page+1);return p(e.data,e.meta,n)},async fetchAll(){let r=[...e],i=t.page;for(;i<t.total_pages;){i++;let e=await n(i);r.push(...e.data)}return r},async*[Symbol.asyncIterator](){yield{data:e,meta:t};let r=t.page;for(;r<t.total_pages;)r++,yield await n(r)}}}var m=class{constructor(e,t){this.http=e,this.siteId=t}async trackPageview(e){return this.http.post(`/sites/${this.siteId}/analytics/pageview`,e)}async getReport(e){let t=e?l({days:e.days,top_n:e.topN,start_date:e.startDate,end_date:e.endDate}):void 0;return this.http.get(`/sites/${this.siteId}/analytics/report`,t)}async getPageAnalytics(e){let t=l({path:e.path,days:e.days,start_date:e.startDate,end_date:e.endDate});return this.http.get(`/sites/${this.siteId}/analytics/report/page`,t)}},h=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=e?.localeId?{locale_id:e.localeId}:{},r=async e=>this.http.get(`/sites/${this.siteId}/blogs/published`,{...t,...n,page:String(e)}),i=await r(e?.page??1);return p(i.data,i.meta,r)}async listByCategory(e,t){let n=t?l(t):void 0,r=t?.localeId?{locale_id:t.localeId}:{},i=async t=>this.http.get(`/sites/${this.siteId}/blogs/published/category/${encodeURIComponent(e)}`,{...n,...r,page:String(t)}),a=await i(t?.page??1);return p(a.data,a.meta,i)}async listFeatured(e){return this.http.get(`/sites/${this.siteId}/blogs/featured`,e?.limit===void 0?void 0:{limit:String(e.limit)})}async listSimilar(e,t){return this.http.get(`/sites/${this.siteId}/blogs/${encodeURIComponent(e)}/similar`,t?.limit===void 0?void 0:{limit:String(t.limit)})}async getBySlug(e){try{let t=await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return await this.http.get(`/blogs/${t.id}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async get(e){try{return await this.http.get(`/blogs/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},g=class{constructor(e,t){this.http=e,this.siteId=t}async listSkills(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/skills`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getSkill(e){try{return await this.http.get(`/skills/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e){try{return await this.http.get(`/skills/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async listEntries(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/cv`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}},_=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/legal`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCookieConsent(){try{return await this.http.get(`/sites/${this.siteId}/legal/cookie-consent`)}catch(e){if(e instanceof r)return null;throw e}}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async getDetail(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},v=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/media`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/media/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},y=class{constructor(e,t){this.http=e,this.siteId=t}async listMenus(){return this.http.get(`/sites/${this.siteId}/menus`)}async getMenu(e){try{return await this.http.get(`/menus/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getMenuBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/menus/slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTree(e,t){return this.http.get(`/menus/${encodeURIComponent(e)}/tree`,t?.locale?{locale:t.locale}:void 0)}async listItems(e){return this.http.get(`/menus/${encodeURIComponent(e)}/items`)}async getItem(e){try{return await this.http.get(`/navigation/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},b=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/pages`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getByRoute(e){let t=e.startsWith(`/`)?e.slice(1):e;try{return await this.http.get(`/sites/${this.siteId}/pages/by-route/${encodeURIComponent(t)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSections(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections`)}async getSectionLocalizations(e){return this.http.get(`/pages/sections/${encodeURIComponent(e)}/localizations`)}async getPageSectionLocalizations(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections/localizations`)}},x=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/projects/public`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/projects/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},S=class{constructor(e,t){this.http=e,this.siteId=t}async lookup(e){try{return await this.http.get(`/sites/${this.siteId}/redirects/lookup`,{path:e})}catch(e){if(e instanceof r)return null;throw e}}},C=class{constructor(e,t){this.http=e,this.siteId=t}async get(){return this.http.get(`/sites/${this.siteId}`)}async listLocales(){return this.http.get(`/sites/${this.siteId}/locales`)}async getCodeInjection(){let e=await this.http.get(`/sites/${this.siteId}/settings`);return{code_injection_head:e.code_injection_head??``,code_injection_footer:e.code_injection_footer??``}}},w=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},T=class{constructor(e,t){this.http=e,this.siteId=t}async listTags(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/tags`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async listCategories(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/categories`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getCategoriesWithBlogCounts(){return this.http.get(`/sites/${this.siteId}/categories/blog-counts`)}async getContentTags(e){return this.http.get(`/content/${encodeURIComponent(e)}/tags`)}async getContentCategories(e){return this.http.get(`/content/${encodeURIComponent(e)}/categories`)}async getTag(e){try{return await this.http.get(`/tags/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTagBySlug(e){try{return await this.http.get(`/tags/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategory(e){try{return await this.http.get(`/categories/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategoryChildren(e){return this.http.get(`/categories/${encodeURIComponent(e)}/children`)}},E=class{constructor(e){let t=f(e);this.blogs=new h(t,e.siteId),this.pages=new b(t,e.siteId),this.navigation=new y(t,e.siteId),this.taxonomy=new T(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new g(t,e.siteId),this.legal=new _(t,e.siteId),this.projects=new x(t,e.siteId),this.redirects=new S(t,e.siteId),this.site=new C(t,e.siteId),this.media=new v(t,e.siteId),this.social=new w(t,e.siteId)}};export{r as a,o as c,s as i,a as l,t as n,n as o,e as r,i as s,E as t};
|
package/dist/client-_Ak79dHS.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`};async function i(e,i,a,o){let l=c(n,i,a),u;try{u=await t(l,{method:e,headers:r,body:o===void 0?void 0:JSON.stringify(o)})}catch(e){throw new s(`Failed to connect to the Forja API`,e instanceof Error?e:void 0)}return u.ok?u:d(u)}return{get:(e,t)=>i(`GET`,e,t).then(e=>e.json()),getText:(e,t)=>i(`GET`,e,t).then(e=>e.text()),post:(e,t)=>i(`POST`,e,void 0,t).then(e=>e.json())}}function p(e,t,n){return{data:e,meta:t,async fetchNext(){if(t.page>=t.total_pages)return null;let e=await n(t.page+1);return p(e.data,e.meta,n)},async fetchAll(){let r=[...e],i=t.page;for(;i<t.total_pages;){i++;let e=await n(i);r.push(...e.data)}return r},async*[Symbol.asyncIterator](){yield{data:e,meta:t};let r=t.page;for(;r<t.total_pages;)r++,yield await n(r)}}}var m=class{constructor(e,t){this.http=e,this.siteId=t}async trackPageview(e){return this.http.post(`/sites/${this.siteId}/analytics/pageview`,e)}async getReport(e){let t=e?l({days:e.days,top_n:e.topN,start_date:e.startDate,end_date:e.endDate}):void 0;return this.http.get(`/sites/${this.siteId}/analytics/report`,t)}async getPageAnalytics(e){let t=l({path:e.path,days:e.days,start_date:e.startDate,end_date:e.endDate});return this.http.get(`/sites/${this.siteId}/analytics/report/page`,t)}},h=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=e?.localeId?{locale_id:e.localeId}:{},r=async e=>this.http.get(`/sites/${this.siteId}/blogs/published`,{...t,...n,page:String(e)}),i=await r(e?.page??1);return p(i.data,i.meta,r)}async listByCategory(e,t){let n=t?l(t):void 0,r=t?.localeId?{locale_id:t.localeId}:{},i=async t=>this.http.get(`/sites/${this.siteId}/blogs/published/category/${encodeURIComponent(e)}`,{...n,...r,page:String(t)}),a=await i(t?.page??1);return p(a.data,a.meta,i)}async listFeatured(e){return this.http.get(`/sites/${this.siteId}/blogs/featured`,e?.limit===void 0?void 0:{limit:String(e.limit)})}async listSimilar(e,t){return this.http.get(`/sites/${this.siteId}/blogs/${encodeURIComponent(e)}/similar`,t?.limit===void 0?void 0:{limit:String(t.limit)})}async getBySlug(e){try{let t=await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return await this.http.get(`/blogs/${t.id}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async get(e){try{return await this.http.get(`/blogs/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},g=class{constructor(e,t){this.http=e,this.siteId=t}async listSkills(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/skills`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getSkill(e){try{return await this.http.get(`/skills/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e){try{return await this.http.get(`/skills/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async listEntries(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/cv`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}},_=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/legal`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCookieConsent(){try{return await this.http.get(`/sites/${this.siteId}/legal/cookie-consent`)}catch(e){if(e instanceof r)return null;throw e}}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async getDetail(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},v=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/media`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/media/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},y=class{constructor(e,t){this.http=e,this.siteId=t}async listMenus(){return this.http.get(`/sites/${this.siteId}/menus`)}async getMenu(e){try{return await this.http.get(`/menus/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getMenuBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/menus/slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTree(e,t){return this.http.get(`/menus/${encodeURIComponent(e)}/tree`,t?.locale?{locale:t.locale}:void 0)}async listItems(e){return this.http.get(`/menus/${encodeURIComponent(e)}/items`)}async getItem(e){try{return await this.http.get(`/navigation/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},b=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/pages`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getByRoute(e){let t=e.startsWith(`/`)?e.slice(1):e;try{return await this.http.get(`/sites/${this.siteId}/pages/by-route/${encodeURIComponent(t)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSections(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections`)}async getSectionLocalizations(e){return this.http.get(`/pages/sections/${encodeURIComponent(e)}/localizations`)}async getPageSectionLocalizations(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections/localizations`)}},x=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/projects/public`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/projects/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},S=class{constructor(e,t){this.http=e,this.siteId=t}async lookup(e){try{return await this.http.get(`/sites/${this.siteId}/redirects/lookup`,{path:e})}catch(e){if(e instanceof r)return null;throw e}}},C=class{constructor(e,t){this.http=e,this.siteId=t}async get(){return this.http.get(`/sites/${this.siteId}`)}async listLocales(){return this.http.get(`/sites/${this.siteId}/locales`)}async getCodeInjection(){let e=await this.http.get(`/sites/${this.siteId}/settings`);return{code_injection_head:e.code_injection_head??``,code_injection_footer:e.code_injection_footer??``}}},w=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},T=class{constructor(e,t){this.http=e,this.siteId=t}async listTags(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/tags`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async listCategories(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/categories`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getCategoriesWithBlogCounts(){return this.http.get(`/sites/${this.siteId}/categories/blog-counts`)}async getContentTags(e){return this.http.get(`/content/${encodeURIComponent(e)}/tags`)}async getContentCategories(e){return this.http.get(`/content/${encodeURIComponent(e)}/categories`)}async getTag(e){try{return await this.http.get(`/tags/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTagBySlug(e){try{return await this.http.get(`/tags/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategory(e){try{return await this.http.get(`/categories/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategoryChildren(e){return this.http.get(`/categories/${encodeURIComponent(e)}/children`)}},E=class{constructor(e){let t=f(e);this.blogs=new h(t,e.siteId),this.pages=new b(t,e.siteId),this.navigation=new y(t,e.siteId),this.taxonomy=new T(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new g(t,e.siteId),this.legal=new _(t,e.siteId),this.projects=new x(t,e.siteId),this.redirects=new S(t,e.siteId),this.site=new C(t,e.siteId),this.media=new v(t,e.siteId),this.social=new w(t,e.siteId)}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return E}});
|