@forjacms/client 1.2.6

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.
@@ -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`};async function i(e,i,a,o){let l=c(n,i,a),u;try{u=await t(l,{method:e,headers:r,body:o===void 0?void 0:JSON.stringify(o)})}catch(e){throw new s(`Failed to connect to the Forja API`,e instanceof Error?e:void 0)}return u.ok?u:d(u)}return{get:(e,t)=>i(`GET`,e,t).then(e=>e.json()),getText:(e,t)=>i(`GET`,e,t).then(e=>e.text()),post:(e,t)=>i(`POST`,e,void 0,t).then(e=>e.json())}}function p(e,t,n){return{data:e,meta:t,async fetchNext(){if(t.page>=t.total_pages)return null;let e=await n(t.page+1);return p(e.data,e.meta,n)},async fetchAll(){let r=[...e],i=t.page;for(;i<t.total_pages;){i++;let e=await n(i);r.push(...e.data)}return r},async*[Symbol.asyncIterator](){yield{data:e,meta:t};let r=t.page;for(;r<t.total_pages;)r++,yield await n(r)}}}var m=class{constructor(e,t){this.http=e,this.siteId=t}async trackPageview(e){return this.http.post(`/sites/${this.siteId}/analytics/pageview`,e)}async getReport(e){let t=e?l({days:e.days,top_n:e.topN,start_date:e.startDate,end_date:e.endDate}):void 0;return this.http.get(`/sites/${this.siteId}/analytics/report`,t)}async getPageAnalytics(e){let t=l({path:e.path,days:e.days,start_date:e.startDate,end_date:e.endDate});return this.http.get(`/sites/${this.siteId}/analytics/report/page`,t)}},h=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=e?.localeId?{locale_id:e.localeId}:{},r=async e=>this.http.get(`/sites/${this.siteId}/blogs/published`,{...t,...n,page:String(e)}),i=await r(e?.page??1);return p(i.data,i.meta,r)}async listByCategory(e,t){let n=t?l(t):void 0,r=t?.localeId?{locale_id:t.localeId}:{},i=async t=>this.http.get(`/sites/${this.siteId}/blogs/published/category/${encodeURIComponent(e)}`,{...n,...r,page:String(t)}),a=await i(t?.page??1);return p(a.data,a.meta,i)}async listFeatured(e){return this.http.get(`/sites/${this.siteId}/blogs/featured`,e?.limit===void 0?void 0:{limit:String(e.limit)})}async listSimilar(e,t){return this.http.get(`/sites/${this.siteId}/blogs/${encodeURIComponent(e)}/similar`,t?.limit===void 0?void 0:{limit:String(t.limit)})}async getBySlug(e){try{let t=await this.http.get(`/sites/${this.siteId}/blogs/by-slug/${encodeURIComponent(e)}`);return await this.http.get(`/blogs/${t.id}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async get(e){try{return await this.http.get(`/blogs/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async rss(){return this.http.getText(`/sites/${this.siteId}/feed.rss`)}},g=class{constructor(e,t){this.http=e,this.siteId=t}async listSkills(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/skills`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getSkill(e){try{return await this.http.get(`/skills/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSkillBySlug(e){try{return await this.http.get(`/skills/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async listEntries(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/cv`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}},_=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/legal`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/legal/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCookieConsent(){try{return await this.http.get(`/sites/${this.siteId}/legal/cookie-consent`)}catch(e){if(e instanceof r)return null;throw e}}async getGroups(e){return this.http.get(`/legal/${encodeURIComponent(e)}/groups`)}async getGroupItems(e){return this.http.get(`/legal/groups/${encodeURIComponent(e)}/items`)}async getDetail(e){try{return await this.http.get(`/legal/${encodeURIComponent(e)}/detail`)}catch(e){if(e instanceof r)return null;throw e}}async listVersions(e){return this.http.get(`/legal/${encodeURIComponent(e)}/versions`)}},v=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/media`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/media/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},y=class{constructor(e,t){this.http=e,this.siteId=t}async listMenus(){return this.http.get(`/sites/${this.siteId}/menus`)}async getMenu(e){try{return await this.http.get(`/menus/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getMenuBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/menus/slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTree(e,t){return this.http.get(`/menus/${encodeURIComponent(e)}/tree`,t?.locale?{locale:t.locale}:void 0)}async listItems(e){return this.http.get(`/menus/${encodeURIComponent(e)}/items`)}async getItem(e){try{return await this.http.get(`/navigation/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},b=class{constructor(e,t){this.http=e,this.siteId=t}async list(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/pages`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getByRoute(e){let t=e.startsWith(`/`)?e.slice(1):e;try{return await this.http.get(`/sites/${this.siteId}/pages/by-route/${encodeURIComponent(t)}`)}catch(e){if(e instanceof r)return null;throw e}}async getSections(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections`)}async getSectionLocalizations(e){return this.http.get(`/pages/sections/${encodeURIComponent(e)}/localizations`)}async getPageSectionLocalizations(e){return this.http.get(`/pages/${encodeURIComponent(e)}/sections/localizations`)}},x=class{constructor(e,t){this.http=e,this.siteId=t}async listPublished(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/projects/public`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async get(e){try{return await this.http.get(`/projects/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getBySlug(e){try{return await this.http.get(`/sites/${this.siteId}/projects/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}},S=class{constructor(e,t){this.http=e,this.siteId=t}async lookup(e){try{return await this.http.get(`/sites/${this.siteId}/redirects/lookup`,{path:e})}catch(e){if(e instanceof r)return null;throw e}}},C=class{constructor(e,t){this.http=e,this.siteId=t}async get(){return this.http.get(`/sites/${this.siteId}`)}async listLocales(){return this.http.get(`/sites/${this.siteId}/locales`)}},w=class{constructor(e,t){this.http=e,this.siteId=t}async list(){return this.http.get(`/sites/${this.siteId}/social`)}},T=class{constructor(e,t){this.http=e,this.siteId=t}async listTags(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/tags`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async listCategories(e){let t=e?l(e):void 0,n=async e=>this.http.get(`/sites/${this.siteId}/categories`,{...t,page:String(e)}),r=await n(e?.page??1);return p(r.data,r.meta,n)}async getCategoriesWithBlogCounts(){return this.http.get(`/sites/${this.siteId}/categories/blog-counts`)}async getContentTags(e){return this.http.get(`/content/${encodeURIComponent(e)}/tags`)}async getContentCategories(e){return this.http.get(`/content/${encodeURIComponent(e)}/categories`)}async getTag(e){try{return await this.http.get(`/tags/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getTagBySlug(e){try{return await this.http.get(`/tags/by-slug/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategory(e){try{return await this.http.get(`/categories/${encodeURIComponent(e)}`)}catch(e){if(e instanceof r)return null;throw e}}async getCategoryChildren(e){return this.http.get(`/categories/${encodeURIComponent(e)}/children`)}},E=class{constructor(e){let t=f(e);this.blogs=new h(t,e.siteId),this.pages=new b(t,e.siteId),this.navigation=new y(t,e.siteId),this.taxonomy=new T(t,e.siteId),this.analytics=new m(t,e.siteId),this.cv=new g(t,e.siteId),this.legal=new _(t,e.siteId),this.projects=new x(t,e.siteId),this.redirects=new S(t,e.siteId),this.site=new C(t,e.siteId),this.media=new v(t,e.siteId),this.social=new w(t,e.siteId)}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return E}});
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./client-eFMh_n88.cjs`);exports.ForjaAuthError=e.n,exports.ForjaClient=e.t,exports.ForjaError=e.r,exports.ForjaNetworkError=e.i,exports.ForjaNotFoundError=e.a,exports.ForjaPermissionError=e.o,exports.ForjaRateLimitError=e.s,exports.ForjaServerError=e.c,exports.ForjaValidationError=e.l;
@@ -0,0 +1,104 @@
1
+ import { $ as ProjectLocalizationResponse, A as LegalVersionResponse, B as NavigationTree, C as LegalDocumentDetailResponse, D as LegalGroupResponse, E as LegalDocumentWithGroups, F as MediaResponse, G as PageType, H as PageListItem, I as MediaVariantResponse, J as PaginationParams, K as Paginated, L as NavigationItemLocalizationResponse, M as LocalizationResponse, N as MediaListItem, O as LegalGroupWithItems, P as MediaListParams, Q as ProjectListParams, R as NavigationItemResponse, S as LegalDocType, T as LegalDocumentResponse, U as PageResponse, V as PageDetailResponse, W as PageSectionResponse, X as ProjectLinkResponse, Y as ProjectDetailResponse, Z as ProjectLinkType, _ as CvEntryResponse, _t as TranslationStatus, a as AnalyticsPageParams, at as SearchablePaginationParams, b as ForjaClientConfig, c as BlogDetailResponse, ct as SiteLocaleResponse, d as BlogResponse, dt as SkillResponse, et as ProjectMediaResponse, f as CategoryResponse, ft as SocialLinkResponse, g as CvEntryParams, gt as TrackPageviewResponse, h as ContentStatus, ht as TrackPageviewRequest, i as AnalyticsPageDetailResponse, it as ReferrerItem, j as LocaleFilterParams, k as LegalItemResponse, l as BlogDocumentResponse, lt as SiteResponse, m as CategoryWithCountResponse, mt as TopContentItem, n as HttpClient, nt as RedirectLookupResponse, o as AnalyticsReportParams, ot as SectionLocalizationResponse, p as CategoryTree, pt as TagResponse, q as PaginationMeta, r as PaginatedResult, rt as RedirectResponse, s as AnalyticsReportResponse, st as SectionType, t as ForjaClient, tt as ProjectResponse, u as BlogListItem, ut as SkillCategory, v as CvEntryType, vt as TrendDataPoint, w as LegalDocumentFullDetailResponse, x as LegalDocLocalizationResponse, y as DocumentLocalizationResponse, z as NavigationMenuResponse } from "./client-BBAKLM2r.cjs";
2
+
3
+ //#region src/errors.d.ts
4
+ /**
5
+ * Base error class for all Forja SDK errors.
6
+ *
7
+ * Every error includes a machine-readable {@link code} following the pattern
8
+ * `AUTH_ERROR`, `NOT_FOUND`, `RATE_LIMIT`, etc. for programmatic handling.
9
+ */
10
+ declare class ForjaError extends Error {
11
+ /** Machine-readable error code (e.g. `AUTH_ERROR`, `NOT_FOUND`). */
12
+ readonly code: string;
13
+ constructor(message: string, /** Machine-readable error code (e.g. `AUTH_ERROR`, `NOT_FOUND`). */
14
+ code: string);
15
+ }
16
+ /**
17
+ * Thrown when the API returns HTTP 401 — the API key is invalid, expired, or missing.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * try {
22
+ * await forja.blogs.listPublished();
23
+ * } catch (err) {
24
+ * if (err instanceof ForjaAuthError) {
25
+ * console.error('Check your API key');
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ declare class ForjaAuthError extends ForjaError {
31
+ constructor(message?: string);
32
+ }
33
+ /**
34
+ * Thrown when the API returns HTTP 403 — the API key lacks the required permission
35
+ * level for the requested operation (e.g. a `Read` key trying to write).
36
+ */
37
+ declare class ForjaPermissionError extends ForjaError {
38
+ constructor(message?: string);
39
+ }
40
+ /**
41
+ * Thrown when the API returns HTTP 404 — the requested resource does not exist.
42
+ *
43
+ * Single-resource methods (e.g. `blogs.get()`, `media.get()`) catch this
44
+ * internally and return `null` instead. This error only surfaces if you call
45
+ * an endpoint that doesn't use the null-return pattern.
46
+ */
47
+ declare class ForjaNotFoundError extends ForjaError {
48
+ constructor(message?: string);
49
+ }
50
+ /**
51
+ * Thrown when the API returns HTTP 429 — the client has exceeded the rate limit.
52
+ *
53
+ * The {@link retryAfter} property contains the number of seconds to wait before
54
+ * retrying, parsed from the `Retry-After` response header (if present).
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * try {
59
+ * await forja.blogs.listPublished();
60
+ * } catch (err) {
61
+ * if (err instanceof ForjaRateLimitError) {
62
+ * await sleep(err.retryAfter ?? 5);
63
+ * // retry...
64
+ * }
65
+ * }
66
+ * ```
67
+ */
68
+ declare class ForjaRateLimitError extends ForjaError {
69
+ /** Seconds to wait before retrying, from the `Retry-After` header. */
70
+ readonly retryAfter?: number | undefined;
71
+ constructor(message?: string, /** Seconds to wait before retrying, from the `Retry-After` header. */retryAfter?: number | undefined);
72
+ }
73
+ /**
74
+ * Thrown when the API returns HTTP 422 — the request body failed validation
75
+ * (e.g. missing required fields, invalid format).
76
+ */
77
+ declare class ForjaValidationError extends ForjaError {
78
+ /** Additional validation details from the API response. */
79
+ readonly details?: string | undefined;
80
+ constructor(message?: string, /** Additional validation details from the API response. */details?: string | undefined);
81
+ }
82
+ /**
83
+ * Thrown when the API returns HTTP 5xx — an unexpected server-side failure.
84
+ *
85
+ * The {@link status} property contains the exact HTTP status code (500, 502, 503, etc.).
86
+ */
87
+ declare class ForjaServerError extends ForjaError {
88
+ /** The HTTP status code (e.g. 500, 502, 503). */
89
+ readonly status: number;
90
+ constructor(message?: string, /** The HTTP status code (e.g. 500, 502, 503). */status?: number);
91
+ }
92
+ /**
93
+ * Thrown when the HTTP request fails at the network level — the server is
94
+ * unreachable, DNS resolution failed, or the connection was reset.
95
+ *
96
+ * The original error is available via {@link cause}.
97
+ */
98
+ declare class ForjaNetworkError extends ForjaError {
99
+ /** The underlying network error (e.g. `TypeError: Failed to fetch`). */
100
+ readonly cause?: Error | undefined;
101
+ constructor(message?: string, /** The underlying network error (e.g. `TypeError: Failed to fetch`). */cause?: Error | undefined);
102
+ }
103
+ //#endregion
104
+ export { type AnalyticsPageDetailResponse, type AnalyticsPageParams, type AnalyticsReportParams, type AnalyticsReportResponse, type BlogDetailResponse, type BlogDocumentResponse, type BlogListItem, type BlogResponse, type CategoryResponse, type CategoryTree, type CategoryWithCountResponse, type ContentStatus, type CvEntryParams, type CvEntryResponse, type CvEntryType, type DocumentLocalizationResponse, ForjaAuthError, ForjaClient, type ForjaClientConfig, ForjaError, ForjaNetworkError, ForjaNotFoundError, ForjaPermissionError, ForjaRateLimitError, ForjaServerError, ForjaValidationError, type HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint };
@@ -0,0 +1,104 @@
1
+ import { $ as ProjectLocalizationResponse, A as LegalVersionResponse, B as NavigationTree, C as LegalDocumentDetailResponse, D as LegalGroupResponse, E as LegalDocumentWithGroups, F as MediaResponse, G as PageType, H as PageListItem, I as MediaVariantResponse, J as PaginationParams, K as Paginated, L as NavigationItemLocalizationResponse, M as LocalizationResponse, N as MediaListItem, O as LegalGroupWithItems, P as MediaListParams, Q as ProjectListParams, R as NavigationItemResponse, S as LegalDocType, T as LegalDocumentResponse, U as PageResponse, V as PageDetailResponse, W as PageSectionResponse, X as ProjectLinkResponse, Y as ProjectDetailResponse, Z as ProjectLinkType, _ as CvEntryResponse, _t as TranslationStatus, a as AnalyticsPageParams, at as SearchablePaginationParams, b as ForjaClientConfig, c as BlogDetailResponse, ct as SiteLocaleResponse, d as BlogResponse, dt as SkillResponse, et as ProjectMediaResponse, f as CategoryResponse, ft as SocialLinkResponse, g as CvEntryParams, gt as TrackPageviewResponse, h as ContentStatus, ht as TrackPageviewRequest, i as AnalyticsPageDetailResponse, it as ReferrerItem, j as LocaleFilterParams, k as LegalItemResponse, l as BlogDocumentResponse, lt as SiteResponse, m as CategoryWithCountResponse, mt as TopContentItem, n as HttpClient, nt as RedirectLookupResponse, o as AnalyticsReportParams, ot as SectionLocalizationResponse, p as CategoryTree, pt as TagResponse, q as PaginationMeta, r as PaginatedResult, rt as RedirectResponse, s as AnalyticsReportResponse, st as SectionType, t as ForjaClient, tt as ProjectResponse, u as BlogListItem, ut as SkillCategory, v as CvEntryType, vt as TrendDataPoint, w as LegalDocumentFullDetailResponse, x as LegalDocLocalizationResponse, y as DocumentLocalizationResponse, z as NavigationMenuResponse } from "./client-d-QwwKUW.mjs";
2
+
3
+ //#region src/errors.d.ts
4
+ /**
5
+ * Base error class for all Forja SDK errors.
6
+ *
7
+ * Every error includes a machine-readable {@link code} following the pattern
8
+ * `AUTH_ERROR`, `NOT_FOUND`, `RATE_LIMIT`, etc. for programmatic handling.
9
+ */
10
+ declare class ForjaError extends Error {
11
+ /** Machine-readable error code (e.g. `AUTH_ERROR`, `NOT_FOUND`). */
12
+ readonly code: string;
13
+ constructor(message: string, /** Machine-readable error code (e.g. `AUTH_ERROR`, `NOT_FOUND`). */
14
+ code: string);
15
+ }
16
+ /**
17
+ * Thrown when the API returns HTTP 401 — the API key is invalid, expired, or missing.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * try {
22
+ * await forja.blogs.listPublished();
23
+ * } catch (err) {
24
+ * if (err instanceof ForjaAuthError) {
25
+ * console.error('Check your API key');
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ declare class ForjaAuthError extends ForjaError {
31
+ constructor(message?: string);
32
+ }
33
+ /**
34
+ * Thrown when the API returns HTTP 403 — the API key lacks the required permission
35
+ * level for the requested operation (e.g. a `Read` key trying to write).
36
+ */
37
+ declare class ForjaPermissionError extends ForjaError {
38
+ constructor(message?: string);
39
+ }
40
+ /**
41
+ * Thrown when the API returns HTTP 404 — the requested resource does not exist.
42
+ *
43
+ * Single-resource methods (e.g. `blogs.get()`, `media.get()`) catch this
44
+ * internally and return `null` instead. This error only surfaces if you call
45
+ * an endpoint that doesn't use the null-return pattern.
46
+ */
47
+ declare class ForjaNotFoundError extends ForjaError {
48
+ constructor(message?: string);
49
+ }
50
+ /**
51
+ * Thrown when the API returns HTTP 429 — the client has exceeded the rate limit.
52
+ *
53
+ * The {@link retryAfter} property contains the number of seconds to wait before
54
+ * retrying, parsed from the `Retry-After` response header (if present).
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * try {
59
+ * await forja.blogs.listPublished();
60
+ * } catch (err) {
61
+ * if (err instanceof ForjaRateLimitError) {
62
+ * await sleep(err.retryAfter ?? 5);
63
+ * // retry...
64
+ * }
65
+ * }
66
+ * ```
67
+ */
68
+ declare class ForjaRateLimitError extends ForjaError {
69
+ /** Seconds to wait before retrying, from the `Retry-After` header. */
70
+ readonly retryAfter?: number | undefined;
71
+ constructor(message?: string, /** Seconds to wait before retrying, from the `Retry-After` header. */retryAfter?: number | undefined);
72
+ }
73
+ /**
74
+ * Thrown when the API returns HTTP 422 — the request body failed validation
75
+ * (e.g. missing required fields, invalid format).
76
+ */
77
+ declare class ForjaValidationError extends ForjaError {
78
+ /** Additional validation details from the API response. */
79
+ readonly details?: string | undefined;
80
+ constructor(message?: string, /** Additional validation details from the API response. */details?: string | undefined);
81
+ }
82
+ /**
83
+ * Thrown when the API returns HTTP 5xx — an unexpected server-side failure.
84
+ *
85
+ * The {@link status} property contains the exact HTTP status code (500, 502, 503, etc.).
86
+ */
87
+ declare class ForjaServerError extends ForjaError {
88
+ /** The HTTP status code (e.g. 500, 502, 503). */
89
+ readonly status: number;
90
+ constructor(message?: string, /** The HTTP status code (e.g. 500, 502, 503). */status?: number);
91
+ }
92
+ /**
93
+ * Thrown when the HTTP request fails at the network level — the server is
94
+ * unreachable, DNS resolution failed, or the connection was reset.
95
+ *
96
+ * The original error is available via {@link cause}.
97
+ */
98
+ declare class ForjaNetworkError extends ForjaError {
99
+ /** The underlying network error (e.g. `TypeError: Failed to fetch`). */
100
+ readonly cause?: Error | undefined;
101
+ constructor(message?: string, /** The underlying network error (e.g. `TypeError: Failed to fetch`). */cause?: Error | undefined);
102
+ }
103
+ //#endregion
104
+ export { type AnalyticsPageDetailResponse, type AnalyticsPageParams, type AnalyticsReportParams, type AnalyticsReportResponse, type BlogDetailResponse, type BlogDocumentResponse, type BlogListItem, type BlogResponse, type CategoryResponse, type CategoryTree, type CategoryWithCountResponse, type ContentStatus, type CvEntryParams, type CvEntryResponse, type CvEntryType, type DocumentLocalizationResponse, ForjaAuthError, ForjaClient, type ForjaClientConfig, ForjaError, ForjaNetworkError, ForjaNotFoundError, ForjaPermissionError, ForjaRateLimitError, ForjaServerError, ForjaValidationError, type HttpClient, type LegalDocLocalizationResponse, type LegalDocType, type LegalDocumentDetailResponse, type LegalDocumentFullDetailResponse, type LegalDocumentResponse, type LegalDocumentWithGroups, type LegalGroupResponse, type LegalGroupWithItems, type LegalItemResponse, type LegalVersionResponse, type LocaleFilterParams, type LocalizationResponse, type MediaListItem, type MediaListParams, type MediaResponse, type MediaVariantResponse, type NavigationItemLocalizationResponse, type NavigationItemResponse, type NavigationMenuResponse, type NavigationTree, type PageDetailResponse, type PageListItem, type PageResponse, type PageSectionResponse, type PageType, type Paginated, type PaginatedResult, type PaginationMeta, type PaginationParams, type ProjectDetailResponse, type ProjectLinkResponse, type ProjectLinkType, type ProjectListParams, type ProjectLocalizationResponse, type ProjectMediaResponse, type ProjectResponse, type RedirectLookupResponse, type RedirectResponse, type ReferrerItem, type SearchablePaginationParams, type SectionLocalizationResponse, type SectionType, type SiteLocaleResponse, type SiteResponse, type SkillCategory, type SkillResponse, type SocialLinkResponse, type TagResponse, type TopContentItem, type TrackPageviewRequest, type TrackPageviewResponse, type TranslationStatus, type TrendDataPoint };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./client-DTfhjUoX.mjs";export{i as ForjaAuthError,c as ForjaClient,o as ForjaError,n as ForjaNetworkError,e as ForjaNotFoundError,a as ForjaPermissionError,s as ForjaRateLimitError,t as ForjaServerError,r as ForjaValidationError};
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@forjacms/client",
3
+ "version": "1.2.6",
4
+ "description": "Typed TypeScript SDK for the Forja CMS content API",
5
+ "author": "Dominik Dorfstetter <dominik@dorfstetter.at>",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.mjs",
8
+ "types": "dist/index.d.cts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.mts",
13
+ "default": "./dist/index.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ },
20
+ "./angular": {
21
+ "import": {
22
+ "types": "./dist/angular/index.d.mts",
23
+ "default": "./dist/angular/index.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/angular/index.d.cts",
27
+ "default": "./dist/angular/index.cjs"
28
+ }
29
+ }
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "scripts": {
35
+ "build": "tsdown src/index.ts src/angular/index.ts --format cjs,esm --dts --minify",
36
+ "dev": "tsdown src/index.ts src/angular/index.ts --format cjs,esm --dts --watch",
37
+ "test": "vitest run --coverage",
38
+ "test:watch": "vitest",
39
+ "lint": "tsc --noEmit"
40
+ },
41
+ "keywords": [
42
+ "forja",
43
+ "cms",
44
+ "sdk",
45
+ "typescript",
46
+ "content-api",
47
+ "angular"
48
+ ],
49
+ "license": "AGPL-3.0-or-later",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "https://github.com/dominikdorfstetter/forja.git",
53
+ "directory": "libs/client"
54
+ },
55
+ "homepage": "https://github.com/dominikdorfstetter/forja/tree/main/libs/client#readme",
56
+ "bugs": "https://github.com/dominikdorfstetter/forja/issues",
57
+ "peerDependencies": {
58
+ "@angular/core": ">=17.0.0"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "@angular/core": {
62
+ "optional": true
63
+ }
64
+ },
65
+ "devDependencies": {
66
+ "@angular/core": "^19.2.20",
67
+ "@vitest/coverage-v8": "^4.0.18",
68
+ "rxjs": "^7.8.2",
69
+ "tsdown": "^0.21.4",
70
+ "typescript": "^6.0.2",
71
+ "vitest": "^4.0.18",
72
+ "zone.js": "^0.15.1"
73
+ },
74
+ "overrides": {
75
+ "typescript": "^6.0.2"
76
+ }
77
+ }