@content-island/api-client 0.5.0 → 0.7.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/README.md CHANGED
@@ -90,11 +90,11 @@ Retrieves a content by id.
90
90
 
91
91
  The query parameters to filter the list of contents.
92
92
 
93
- | Key | Value | Description |
94
- | ------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
95
- | `id` | `Filter` | The id of the content to retrieve. This is useful to retrieve a list of contents by id. For example: `client.getContentList({ ids: { in: ['1', '2', '3']})` |
96
- | `contentType` | `Filter` | The content type to filter the list of contents. For example: `post` |
97
- | `language` | `Filter` | The language to filter the list of contents. For example: `en` |
93
+ | Key | Value | Description |
94
+ | ------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
95
+ | `id` | `Filter` | The id of the content to retrieve. This is useful to retrieve a list of contents by id. For example: `client.getContentList({ id: { in: ['1', '2', '3']})` |
96
+ | `contentType` | `Filter` | The content type to filter the list of contents. For example: `post` |
97
+ | `language` | `Filter` | The language to filter the list of contents. For example: `en` |
98
98
 
99
99
  | Filter type | Description | Example |
100
100
  | ------------------ | ------------------------------------------------------------------ | ------------------------------------ |
package/dist/index.d.ts CHANGED
@@ -53,6 +53,11 @@ declare type Filter =
53
53
 
54
54
  export declare const mapContentToModel: <Model extends BaseModel<Language>, Language = Model["language"]>(content: Content, language?: Language) => Model;
55
55
 
56
+ export declare interface Media {
57
+ name: string;
58
+ url: string;
59
+ }
60
+
56
61
  export declare interface Options {
57
62
  accessToken: string;
58
63
  domain?: string;
@@ -63,7 +68,7 @@ export declare interface Project {
63
68
  id: string;
64
69
  name: string;
65
70
  languages: string[];
66
- entities?: ApiLookup[];
71
+ contentTypes?: ApiLookup[];
67
72
  }
68
73
 
69
74
  declare type Query<F = Filter> = {
@@ -76,9 +81,4 @@ declare type Query<F = Filter> = {
76
81
 
77
82
  export declare type QueryParams = Pick<Query<ClientFilter>, AllowedQueryKeys>;
78
83
 
79
- export declare interface Resource {
80
- name: string;
81
- link: string;
82
- }
83
-
84
84
  export { }
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ const T = {
13
13
  (n, [r, s], a) => a === 0 ? N(r, s) : `${n}${t}${N(r, s)}`,
14
14
  ""
15
15
  ), u = (e) => e && Object.keys(e).length > 0 ? `?${S(e, "&")}` : "", o = {
16
- PROYECT: "/project",
16
+ PROJECT: "/project",
17
17
  CONTENT_LIST: (e) => `/contents${u(e)}`,
18
18
  CONTENT: (e, t) => {
19
19
  const n = u(t);
@@ -36,7 +36,7 @@ const T = {
36
36
  })
37
37
  );
38
38
  }), $ = (e) => ({
39
- getProject: () => c(o.PROYECT, e),
39
+ getProject: () => c(o.PROJECT, e),
40
40
  getContentList: (t) => c(o.CONTENT_LIST(t), e),
41
41
  getContent: (t, n) => c(o.CONTENT(t, n), e)
42
42
  }), g = (e) => e.reduce((t, n) => ({ ...t, [n.name]: n.value }), {}), O = (e, t, n) => {
@@ -1 +1 @@
1
- (function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s.ApiClient={}))})(this,function(s){"use strict";const r={DEFAULT_API_CLIENT_DOMAIN:"api.contentisland.net",DEFAULT_API_CLIENT_VERSION:"1.0"},u={SESSION_KEY:"authorization",SESSION_TYPE:"Bearer"},l=(e,t)=>{if(typeof t=="string")return`${e}=${t}`;if(t.in)return`${e}[in]=${t.in.join(",")}`},N=(e,t)=>Object.entries(e).reduce((n,[o,a],i)=>i===0?l(o,a):`${n}${t}${l(o,a)}`,""),d=e=>e&&Object.keys(e).length>0?`?${N(e,"&")}`:"",c={PROYECT:"/project",CONTENT_LIST:e=>`/contents${d(e)}`,CONTENT:(e,t)=>{const n=d(t);return`/contents/${e}${n}`}},S=e=>{const t="https",n=e.domain?e.domain:r.DEFAULT_API_CLIENT_DOMAIN,o=e.apiVersion?e.apiVersion:r.DEFAULT_API_CLIENT_VERSION;return`${t}://${n}/api/${o}`},T=async(e,t)=>fetch(`${S(t)}${e}`,{headers:{[u.SESSION_KEY]:`${u.SESSION_TYPE} ${t.accessToken}`}}).then(n=>{if(n.ok)return n.json();throw Error(JSON.stringify({status:n.status,statusText:n.statusText}))}),f=e=>({getProject:()=>T(c.PROYECT,e),getContentList:t=>T(c.CONTENT_LIST(t),e),getContent:(t,n)=>T(c.CONTENT(t,n),e)}),g=e=>e.reduce((t,n)=>({...t,[n.name]:n.value}),{}),O=(e,t,n)=>{var E;const o=n??((E=e[0])==null?void 0:E.language),a=e.filter($=>$.language===o),i=g(a);return Object.keys(i).length===0&&console.warn(`No fields found for language "${o}" and content id "${t}"`),{id:t,language:o,...i}},_=(e,t)=>Array.isArray(e==null?void 0:e.fields)?O(e.fields,e.id,t):{};s.createClient=f,s.mapContentToModel=_,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s.ApiClient={}))})(this,function(s){"use strict";const r={DEFAULT_API_CLIENT_DOMAIN:"api.contentisland.net",DEFAULT_API_CLIENT_VERSION:"1.0"},u={SESSION_KEY:"authorization",SESSION_TYPE:"Bearer"},l=(e,t)=>{if(typeof t=="string")return`${e}=${t}`;if(t.in)return`${e}[in]=${t.in.join(",")}`},N=(e,t)=>Object.entries(e).reduce((n,[o,a],i)=>i===0?l(o,a):`${n}${t}${l(o,a)}`,""),d=e=>e&&Object.keys(e).length>0?`?${N(e,"&")}`:"",c={PROJECT:"/project",CONTENT_LIST:e=>`/contents${d(e)}`,CONTENT:(e,t)=>{const n=d(t);return`/contents/${e}${n}`}},S=e=>{const t="https",n=e.domain?e.domain:r.DEFAULT_API_CLIENT_DOMAIN,o=e.apiVersion?e.apiVersion:r.DEFAULT_API_CLIENT_VERSION;return`${t}://${n}/api/${o}`},T=async(e,t)=>fetch(`${S(t)}${e}`,{headers:{[u.SESSION_KEY]:`${u.SESSION_TYPE} ${t.accessToken}`}}).then(n=>{if(n.ok)return n.json();throw Error(JSON.stringify({status:n.status,statusText:n.statusText}))}),f=e=>({getProject:()=>T(c.PROJECT,e),getContentList:t=>T(c.CONTENT_LIST(t),e),getContent:(t,n)=>T(c.CONTENT(t,n),e)}),g=e=>e.reduce((t,n)=>({...t,[n.name]:n.value}),{}),O=(e,t,n)=>{var E;const o=n??((E=e[0])==null?void 0:E.language),a=e.filter($=>$.language===o),i=g(a);return Object.keys(i).length===0&&console.warn(`No fields found for language "${o}" and content id "${t}"`),{id:t,language:o,...i}},_=(e,t)=>Array.isArray(e==null?void 0:e.fields)?O(e.fields,e.id,t):{};s.createClient=f,s.mapContentToModel=_,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@content-island/api-client",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Content Island - REST API Client",
5
5
  "private": false,
6
6
  "sideEffects": false,