@flyo/nitro-astro 1.0.7 → 1.0.9
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/components/FallbackComponent.d.ts +2 -0
- package/dist/components/FlyoNitroBlock.d.ts +2 -0
- package/dist/components/FlyoNitroPage.d.ts +2 -0
- package/dist/index.d.ts +17 -0
- package/dist/nitro-astro.js +5 -5
- package/dist/nitro-astro.mjs +650 -39
- package/dist/vite-plugin-flyo-components.d.ts +2 -0
- package/package.json +3 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AstroIntegration } from "astro";
|
|
2
|
+
import { Configuration, ConfigApi, EntitiesApi, PagesApi, SearchApi, SitemapApi, VersionApi } from '@flyo/nitro-typescript';
|
|
3
|
+
export type IntegrationOptions = {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
liveEdit: boolean;
|
|
6
|
+
componentsDir: string;
|
|
7
|
+
components: object;
|
|
8
|
+
fallbackComponent?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function useConfiguration(): Configuration;
|
|
11
|
+
export declare function useConfigApi(): ConfigApi;
|
|
12
|
+
export declare function useEntitiesApi(): EntitiesApi;
|
|
13
|
+
export declare function usePagesApi(): PagesApi;
|
|
14
|
+
export declare function useSearchApi(): SearchApi;
|
|
15
|
+
export declare function useSitemapApi(): SitemapApi;
|
|
16
|
+
export declare function useVersionApi(): VersionApi;
|
|
17
|
+
export default function flyoNitroIntegration(options: IntegrationOptions): AstroIntegration;
|
package/dist/nitro-astro.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
(function(i,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(i=typeof globalThis<"u"?globalThis:i||self,d(i.flyoNitroIntegration={}))})(this,function(i){"use strict";const d=/[\p{Lu}]/u,C=/[\p{Ll}]/u,p=/^[\p{Lu}](?![\p{Lu}])/gu,y=/([\p{Alpha}\p{N}_]|$)/u,u=/[_.\- ]+/,m=new RegExp("^"+u.source),h=new RegExp(u.source+y.source,"gu"),v=new RegExp("\\d+"+y.source,"gu"),g=(e,o,s,a)=>{let c=!1,t=!1,n=!1,f=!1;for(let r=0;r<e.length;r++){const l=e[r];f=r>2?e[r-3]==="-":!0,c&&d.test(l)?(e=e.slice(0,r)+"-"+e.slice(r),c=!1,n=t,t=!0,r++):t&&n&&C.test(l)&&(!f||a)?(e=e.slice(0,r-1)+"-"+e.slice(r-1),n=t,t=!1,c=!0):(c=o(l)===l&&s(l)!==l,n=t,t=s(l)===l&&o(l)!==l)}return e},I=(e,o)=>(p.lastIndex=0,e.replace(p,s=>o(s))),E=(e,o)=>(h.lastIndex=0,v.lastIndex=0,e.replace(h,(s,a)=>o(a)).replace(v,s=>o(s)));function A(e,o){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(o={pascalCase:!1,preserveConsecutiveUppercase:!1,...o},Array.isArray(e)?e=e.map(t=>t.trim()).filter(t=>t.length).join("-"):e=e.trim(),e.length===0)return"";const s=o.locale===!1?t=>t.toLowerCase():t=>t.toLocaleLowerCase(o.locale),a=o.locale===!1?t=>t.toUpperCase():t=>t.toLocaleUpperCase(o.locale);return e.length===1?u.test(e)?"":o.pascalCase?a(e):s(e):(e!==s(e)&&(e=g(e,s,a,o.preserveConsecutiveUppercase)),e=e.replace(m,""),e=o.preserveConsecutiveUppercase?I(e,s):s(e),o.pascalCase&&(e=a(e.charAt(0))+e.slice(1)),E(e,a))}function L(e,o,s){const a="virtual:flyo-components",c="\0"+a;return{name:"vite-plugin-flyo-components",async resolveId(t){if(t===a)return c},async load(t){if(t===c){const n=[];for(const[r,l]of Object.entries(o)){const w=await this.resolve("/"+e+"/"+l+".astro");w&&n.push(`export { default as ${A(r)} } from "${w.id}"`)}let f=null;return s&&(f=await this.resolve("/"+e+"/"+s+".astro")),f?n.push(`export { default as fallback } from "${f.id}"`):n.push('export { default as fallback } from "@flyo/nitro-astro/src/components/FallbackComponent.astro"'),n.join(";")}}}}function N(){return globalThis.flyoNitroInstance||console.error("flyoNitroInstance has not been initialized correctly"),globalThis.flyoNitroInstance}function R(e){const o={accessToken:!1,liveEdit:!1,fallbackComponent:null,...e};return{name:"@flyo/nitro-astro",hooks:{"astro:config:setup":({injectScript:s,updateConfig:a})=>{a({vite:{plugins:[L(e.componentsDir,e.components,e.fallbackComponent)]}}),s("page-ssr",`
|
|
1
|
+
(function(l,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(l=typeof globalThis<"u"?globalThis:l||self,y(l.flyoNitroIntegration={}))})(this,function(l){"use strict";const y="https://api.flyo.cloud/nitro/v1".replace(/\/+$/,"");class j{constructor(i={}){this.configuration=i}set config(i){this.configuration=i}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:y}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||q}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const i=this.configuration.apiKey;if(i)return typeof i=="function"?i:()=>i}get accessToken(){const i=this.configuration.accessToken;if(i)return typeof i=="function"?i:async()=>i}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const L=new j,_=class P{constructor(i=L){this.configuration=i,this.fetchApi=async(t,r)=>{let a={url:t,init:r};for(const s of this.middleware)s.pre&&(a=await s.pre({fetch:this.fetchApi,...a})||a);let o;try{o=await(this.configuration.fetchApi||fetch)(a.url,a.init)}catch(s){for(const u of this.middleware)u.onError&&(o=await u.onError({fetch:this.fetchApi,url:a.url,init:a.init,error:s,response:o?o.clone():void 0})||o);if(o===void 0)throw s instanceof Error?new O(s,"The request failed and the interceptors did not return an alternative response"):s}for(const s of this.middleware)s.post&&(o=await s.post({fetch:this.fetchApi,url:a.url,init:a.init,response:o.clone()})||o);return o},this.middleware=i.middleware}withMiddleware(...i){const t=this.clone();return t.middleware=t.middleware.concat(...i),t}withPreMiddleware(...i){const t=i.map(r=>({pre:r}));return this.withMiddleware(...t)}withPostMiddleware(...i){const t=i.map(r=>({post:r}));return this.withMiddleware(...t)}isJsonMime(i){return i?P.jsonRegex.test(i):!1}async request(i,t){const{url:r,init:a}=await this.createFetchParams(i,t),o=await this.fetchApi(r,a);if(o&&o.status>=200&&o.status<300)return o;throw new N(o,"Response returned an error code")}async createFetchParams(i,t){let r=this.configuration.basePath+i.path;i.query!==void 0&&Object.keys(i.query).length!==0&&(r+="?"+this.configuration.queryParamsStringify(i.query));const a=Object.assign({},this.configuration.headers,i.headers);Object.keys(a).forEach(g=>a[g]===void 0?delete a[g]:{});const o=typeof t=="function"?t:async()=>t,s={method:i.method,headers:a,body:i.body,credentials:this.configuration.credentials},u={...s,...await o({init:s,context:i})};let c;x(u.body)||u.body instanceof URLSearchParams||K(u.body)?c=u.body:this.isJsonMime(a["Content-Type"])?c=JSON.stringify(u.body):c=u.body;const d={...u,body:c};return{url:r,init:d}}clone(){const i=this.constructor,t=new i(this.configuration);return t.middleware=this.middleware.slice(),t}};_.jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");let h=_;function K(e){return typeof Blob<"u"&&e instanceof Blob}function x(e){return typeof FormData<"u"&&e instanceof FormData}class N extends Error{constructor(i,t){super(t),this.response=i,this.name="ResponseError"}}class O extends Error{constructor(i,t){super(t),this.cause=i,this.name="FetchError"}}class v extends Error{constructor(i,t){super(t),this.field=i,this.name="RequiredError"}}function n(e,i){return e[i]!=null}function q(e,i=""){return Object.keys(e).map(t=>b(t,e[t],i)).filter(t=>t.length>0).join("&")}function b(e,i,t=""){const r=t+(t.length?`[${e}]`:e);if(i instanceof Array){const a=i.map(o=>encodeURIComponent(String(o))).join(`&${encodeURIComponent(r)}=`);return`${encodeURIComponent(r)}=${a}`}if(i instanceof Set){const a=Array.from(i);return b(e,a,t)}return i instanceof Date?`${encodeURIComponent(r)}=${encodeURIComponent(i.toISOString())}`:i instanceof Object?q(i,r):`${encodeURIComponent(r)}=${encodeURIComponent(String(i))}`}function m(e,i){return Object.keys(e).reduce((t,r)=>({...t,[r]:i(e[r])}),{})}class f{constructor(i,t=r=>r){this.raw=i,this.transformer=t}async value(){return this.transformer(await this.raw.json())}}function $(e){return M(e)}function M(e,i){return e==null?e:{identifier:n(e,"identifier")?e.identifier:void 0,content:n(e,"content")?e.content.map(R):void 0}}function R(e){return B(e)}function B(e,i){return e==null?e:{items:n(e,"items")?e.items:void 0,content:n(e,"content")?e.content:void 0,config:n(e,"config")?e.config:void 0,identifier:n(e,"identifier")?e.identifier:void 0,uid:n(e,"uid")?e.uid:void 0,component:n(e,"component")?e.component:void 0,slots:n(e,"slots")?m(e.slots,$):void 0}}function A(e){return F(e)}function F(e,i){return e==null?e:{type:n(e,"type")?e.type:void 0,target:n(e,"target")?e.target:void 0,label:n(e,"label")?e.label:void 0,href:n(e,"href")?e.href:void 0,slug:n(e,"slug")?e.slug:void 0,properties:n(e,"properties")?e.properties:void 0,children:n(e,"children")?e.children.map(A):void 0}}function D(e){return G(e)}function G(e,i){return e==null?e:{items:n(e,"items")?e.items.map(A):void 0,uid:n(e,"uid")?e.uid:void 0,identifier:n(e,"identifier")?e.identifier:void 0,label:n(e,"label")?e.label:void 0}}function J(e){return V(e)}function V(e,i){return e==null?e:{domain:n(e,"domain")?e.domain:void 0,slug:n(e,"slug")?e.slug:void 0,version:n(e,"version")?e.version:void 0,updatedAt:n(e,"updated_at")?e.updated_at:void 0,language:n(e,"language")?e.language:void 0}}function W(e){return z(e)}function z(e,i){return e==null?e:{nitro:n(e,"nitro")?J(e.nitro):void 0,pages:n(e,"pages")?e.pages:void 0,containers:n(e,"containers")?m(e.containers,D):void 0,globals:n(e,"globals")?e.globals:void 0}}function H(e){return X(e)}function X(e,i){return e==null?e:{api:n(e,"api")?e.api:void 0,image:n(e,"image")?e.image:void 0}}function Z(e){return Q(e)}function Q(e,i){return e==null?e:{version:n(e,"_version")?e._version:void 0,entityMetric:n(e,"entity_metric")?H(e.entity_metric):void 0,entityUniqueId:n(e,"entity_unique_id")?e.entity_unique_id:void 0,entityId:n(e,"entity_id")?e.entity_id:void 0,entityImage:n(e,"entity_image")?e.entity_image:void 0,entitySlug:n(e,"entity_slug")?e.entity_slug:void 0,entityTeaser:n(e,"entity_teaser")?e.entity_teaser:void 0,entityTimeEnd:n(e,"entity_time_end")?e.entity_time_end:void 0,entityTimeStart:n(e,"entity_time_start")?e.entity_time_start:void 0,entityTitle:n(e,"entity_title")?e.entity_title:void 0,entityType:n(e,"entity_type")?e.entity_type:void 0,entityTypeId:n(e,"entity_type_id")?e.entity_type_id:void 0,updatedAt:n(e,"updated_at")?e.updated_at:void 0,routes:n(e,"routes")?e.routes:void 0}}function E(e){return Y(e)}function Y(e,i){return e==null?e:{entity:n(e,"entity")?Z(e.entity):void 0,model:n(e,"model")?e.model:void 0,language:n(e,"language")?e.language:void 0,jsonld:n(e,"jsonld")?e.jsonld:void 0}}function I(e){return ee(e)}function ee(e,i){return e==null?e:{entityUniqueId:n(e,"entity_unique_id")?e.entity_unique_id:void 0,entityTitle:n(e,"entity_title")?e.entity_title:void 0,entityTeaser:n(e,"entity_teaser")?e.entity_teaser:void 0,entitySlug:n(e,"entity_slug")?e.entity_slug:void 0,entityTimeStart:n(e,"entity_time_start")?e.entity_time_start:void 0,entityType:n(e,"entity_type")?e.entity_type:void 0,entityTypeId:n(e,"entity_type_id")?e.entity_type_id:void 0,entityImage:n(e,"entity_image")?e.entity_image:void 0,routes:n(e,"routes")?e.routes:void 0}}function ie(e){return te(e)}function te(e,i){return e==null?e:{description:n(e,"description")?e.description:void 0,image:n(e,"image")?e.image:void 0,title:n(e,"title")?e.title:void 0}}function ne(e){return oe(e)}function oe(e,i){return e==null?e:{slug:n(e,"slug")?e.slug:void 0,title:n(e,"title")?e.title:void 0}}function re(e){return ae(e)}function ae(e,i){return e==null?e:{value:n(e,"value")?e.value:void 0,navigation:n(e,"navigation")?e.navigation:void 0,propagate:n(e,"propagate")?e.propagate:void 0}}function C(e){return se(e)}function se(e,i){return e==null?e:{id:n(e,"id")?e.id:void 0,title:n(e,"title")?e.title:void 0,href:n(e,"href")?e.href:void 0,slug:n(e,"slug")?e.slug:void 0,json:n(e,"json")?e.json.map(R):void 0,depth:n(e,"depth")?e.depth:void 0,isHome:n(e,"is_home")?e.is_home:void 0,createdAt:n(e,"created_at")?e.created_at:void 0,updatedAt:n(e,"updated_at")?e.updated_at:void 0,isVisible:n(e,"is_visible")?e.is_visible:void 0,metaJson:n(e,"meta_json")?ie(e.meta_json):void 0,properties:n(e,"properties")?m(e.properties,re):void 0,uid:n(e,"uid")?e.uid:void 0,type:n(e,"type")?e.type:void 0,target:n(e,"target")?e.target:void 0,container:n(e,"container")?e.container:void 0,breadcrumb:n(e,"breadcrumb")?e.breadcrumb.map(ne):void 0}}function ue(e){return ce(e)}function ce(e,i){return e==null?e:{version:n(e,"version")?e.version:void 0,updatedAt:n(e,"updated_at")?e.updated_at:void 0}}class de extends h{async configRaw(i){const t={},r={};this.configuration&&this.configuration.apiKey&&(t.token=this.configuration.apiKey("token"));const a=await this.request({path:"/config",method:"GET",headers:r,query:t},i);return new f(a,o=>W(o))}async config(i){return await(await this.configRaw(i)).value()}}class le extends h{async entityBySlugRaw(i,t){if(i.slug===null||i.slug===void 0)throw new v("slug","Required parameter requestParameters.slug was null or undefined when calling entityBySlug.");const r={};i.typeId!==void 0&&(r.typeId=i.typeId);const a={};this.configuration&&this.configuration.apiKey&&(r.token=this.configuration.apiKey("token"));const o=await this.request({path:"/entities/slug/{slug}".replace("{slug}",encodeURIComponent(String(i.slug))),method:"GET",headers:a,query:r},t);return new f(o,s=>E(s))}async entityBySlug(i,t){return await(await this.entityBySlugRaw(i,t)).value()}async entityByUniqueidRaw(i,t){if(i.uniqueid===null||i.uniqueid===void 0)throw new v("uniqueid","Required parameter requestParameters.uniqueid was null or undefined when calling entityByUniqueid.");const r={},a={};this.configuration&&this.configuration.apiKey&&(r.token=this.configuration.apiKey("token"));const o=await this.request({path:"/entities/uniqueid/{uniqueid}".replace("{uniqueid}",encodeURIComponent(String(i.uniqueid))),method:"GET",headers:a,query:r},t);return new f(o,s=>E(s))}async entityByUniqueid(i,t){return await(await this.entityByUniqueidRaw(i,t)).value()}}class fe extends h{async homeRaw(i){const t={},r={};this.configuration&&this.configuration.apiKey&&(t.token=this.configuration.apiKey("token"));const a=await this.request({path:"/pages/home",method:"GET",headers:r,query:t},i);return new f(a,o=>C(o))}async home(i){return await(await this.homeRaw(i)).value()}async pageRaw(i,t){const r={};i.slug!==void 0&&(r.slug=i.slug);const a={};this.configuration&&this.configuration.apiKey&&(r.token=this.configuration.apiKey("token"));const o=await this.request({path:"/pages",method:"GET",headers:a,query:r},t);return new f(o,s=>C(s))}async page(i={},t){return await(await this.pageRaw(i,t)).value()}}class pe extends h{async searchRaw(i,t){if(i.query===null||i.query===void 0)throw new v("query","Required parameter requestParameters.query was null or undefined when calling search.");const r={};i.query!==void 0&&(r.query=i.query);const a={};this.configuration&&this.configuration.apiKey&&(r.token=this.configuration.apiKey("token"));const o=await this.request({path:"/search",method:"GET",headers:a,query:r},t);return new f(o,s=>s.map(I))}async search(i,t){return await(await this.searchRaw(i,t)).value()}}class he extends h{async sitemapRaw(i){const t={},r={};this.configuration&&this.configuration.apiKey&&(t.token=this.configuration.apiKey("token"));const a=await this.request({path:"/sitemap",method:"GET",headers:r,query:t},i);return new f(a,o=>o.map(I))}async sitemap(i){return await(await this.sitemapRaw(i)).value()}}class ye extends h{async versionRaw(i){const t={},r={};this.configuration&&this.configuration.apiKey&&(t.token=this.configuration.apiKey("token"));const a=await this.request({path:"/version",method:"GET",headers:r,query:t},i);return new f(a,o=>ue(o))}async version(i){return await(await this.versionRaw(i)).value()}}const ge=/[\p{Lu}]/u,ve=/[\p{Ll}]/u,T=/^[\p{Lu}](?![\p{Lu}])/gu,S=/([\p{Alpha}\p{N}_]|$)/u,w=/[_.\- ]+/,me=new RegExp("^"+w.source),k=new RegExp(w.source+S.source,"gu"),U=new RegExp("\\d+"+S.source,"gu"),we=(e,i,t,r)=>{let a=!1,o=!1,s=!1,u=!1;for(let c=0;c<e.length;c++){const d=e[c];u=c>2?e[c-3]==="-":!0,a&&ge.test(d)?(e=e.slice(0,c)+"-"+e.slice(c),a=!1,s=o,o=!0,c++):o&&s&&ve.test(d)&&(!u||r)?(e=e.slice(0,c-1)+"-"+e.slice(c-1),s=o,o=!1,a=!0):(a=i(d)===d&&t(d)!==d,s=o,o=t(d)===d&&i(d)!==d)}return e},_e=(e,i)=>(T.lastIndex=0,e.replace(T,t=>i(t))),qe=(e,i)=>(k.lastIndex=0,U.lastIndex=0,e.replace(k,(t,r)=>i(r)).replace(U,t=>i(t)));function be(e,i){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(i={pascalCase:!1,preserveConsecutiveUppercase:!1,...i},Array.isArray(e)?e=e.map(o=>o.trim()).filter(o=>o.length).join("-"):e=e.trim(),e.length===0)return"";const t=i.locale===!1?o=>o.toLowerCase():o=>o.toLocaleLowerCase(i.locale),r=i.locale===!1?o=>o.toUpperCase():o=>o.toLocaleUpperCase(i.locale);return e.length===1?w.test(e)?"":i.pascalCase?r(e):t(e):(e!==t(e)&&(e=we(e,t,r,i.preserveConsecutiveUppercase)),e=e.replace(me,""),e=i.preserveConsecutiveUppercase?_e(e,t):t(e),i.pascalCase&&(e=r(e.charAt(0))+e.slice(1)),qe(e,r))}function Re(e,i,t){const r="virtual:flyo-components",a="\0"+r;return{name:"vite-plugin-flyo-components",async resolveId(o){if(o===r)return a},async load(o){if(o===a){const s=[];for(const[c,d]of Object.entries(i)){const g=await this.resolve("/"+e+"/"+d+".astro");g&&s.push(`export { default as ${be(c)} } from "${g.id}"`)}let u=null;return t&&(u=await this.resolve("/"+e+"/"+t+".astro")),u?s.push(`export { default as fallback } from "${u.id}"`):s.push('export { default as fallback } from "@flyo/nitro-astro/src/components/FallbackComponent.astro"'),s.join(";")}}}}function p(){return globalThis.flyoNitroInstance||console.error("flyoNitroInstance has not been initialized correctly"),globalThis.flyoNitroInstance}function Ae(){return new de(p())}function Ee(){return new le(p())}function Ie(){return new fe(p())}function Ce(){return new pe(p())}function Te(){return new he(p())}function Se(){return new ye(p())}function ke(e){const i={accessToken:!1,liveEdit:!1,fallbackComponent:null,...e};return{name:"@flyo/nitro-astro",hooks:{"astro:config:setup":({injectScript:t,updateConfig:r})=>{r({vite:{plugins:[Re(e.componentsDir,e.components,e.fallbackComponent)]}}),t("page-ssr",`
|
|
2
2
|
import { Configuration } from '@flyo/nitro-typescript'
|
|
3
3
|
|
|
4
|
-
var defaultConfig = Configuration({
|
|
5
|
-
apiKey: '${
|
|
4
|
+
var defaultConfig = new Configuration({
|
|
5
|
+
apiKey: '${i.accessToken}'
|
|
6
6
|
})
|
|
7
7
|
|
|
8
8
|
globalThis.flyoNitroInstance = defaultConfig;
|
|
9
|
-
`),
|
|
9
|
+
`),i.liveEdit&&t("page",`
|
|
10
10
|
window.addEventListener("message", (event) => {
|
|
11
11
|
if (event.data?.action === 'pageRefresh') {
|
|
12
12
|
window.location.reload(true);
|
|
@@ -28,4 +28,4 @@
|
|
|
28
28
|
data: JSON.parse(JSON.stringify({item:{uid: blockUid}}))
|
|
29
29
|
}, 'https://flyo.cloud')
|
|
30
30
|
}
|
|
31
|
-
`)}}}}
|
|
31
|
+
`)}}}}l.default=ke,l.useConfigApi=Ae,l.useConfiguration=p,l.useEntitiesApi=Ee,l.usePagesApi=Ie,l.useSearchApi=Ce,l.useSitemapApi=Te,l.useVersionApi=Se,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/nitro-astro.mjs
CHANGED
|
@@ -1,53 +1,658 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const U = "https://api.flyo.cloud/nitro/v1".replace(/\/+$/, "");
|
|
2
|
+
class x {
|
|
3
|
+
constructor(i = {}) {
|
|
4
|
+
this.configuration = i;
|
|
5
|
+
}
|
|
6
|
+
set config(i) {
|
|
7
|
+
this.configuration = i;
|
|
8
|
+
}
|
|
9
|
+
get basePath() {
|
|
10
|
+
return this.configuration.basePath != null ? this.configuration.basePath : U;
|
|
11
|
+
}
|
|
12
|
+
get fetchApi() {
|
|
13
|
+
return this.configuration.fetchApi;
|
|
14
|
+
}
|
|
15
|
+
get middleware() {
|
|
16
|
+
return this.configuration.middleware || [];
|
|
17
|
+
}
|
|
18
|
+
get queryParamsStringify() {
|
|
19
|
+
return this.configuration.queryParamsStringify || I;
|
|
20
|
+
}
|
|
21
|
+
get username() {
|
|
22
|
+
return this.configuration.username;
|
|
23
|
+
}
|
|
24
|
+
get password() {
|
|
25
|
+
return this.configuration.password;
|
|
26
|
+
}
|
|
27
|
+
get apiKey() {
|
|
28
|
+
const i = this.configuration.apiKey;
|
|
29
|
+
if (i)
|
|
30
|
+
return typeof i == "function" ? i : () => i;
|
|
31
|
+
}
|
|
32
|
+
get accessToken() {
|
|
33
|
+
const i = this.configuration.accessToken;
|
|
34
|
+
if (i)
|
|
35
|
+
return typeof i == "function" ? i : async () => i;
|
|
36
|
+
}
|
|
37
|
+
get headers() {
|
|
38
|
+
return this.configuration.headers;
|
|
39
|
+
}
|
|
40
|
+
get credentials() {
|
|
41
|
+
return this.configuration.credentials;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const P = new x(), R = class E {
|
|
45
|
+
constructor(i = P) {
|
|
46
|
+
this.configuration = i, this.fetchApi = async (t, r) => {
|
|
47
|
+
let a = { url: t, init: r };
|
|
48
|
+
for (const s of this.middleware)
|
|
49
|
+
s.pre && (a = await s.pre({
|
|
50
|
+
fetch: this.fetchApi,
|
|
51
|
+
...a
|
|
52
|
+
}) || a);
|
|
53
|
+
let o;
|
|
54
|
+
try {
|
|
55
|
+
o = await (this.configuration.fetchApi || fetch)(a.url, a.init);
|
|
56
|
+
} catch (s) {
|
|
57
|
+
for (const u of this.middleware)
|
|
58
|
+
u.onError && (o = await u.onError({
|
|
59
|
+
fetch: this.fetchApi,
|
|
60
|
+
url: a.url,
|
|
61
|
+
init: a.init,
|
|
62
|
+
error: s,
|
|
63
|
+
response: o ? o.clone() : void 0
|
|
64
|
+
}) || o);
|
|
65
|
+
if (o === void 0)
|
|
66
|
+
throw s instanceof Error ? new N(s, "The request failed and the interceptors did not return an alternative response") : s;
|
|
67
|
+
}
|
|
68
|
+
for (const s of this.middleware)
|
|
69
|
+
s.post && (o = await s.post({
|
|
70
|
+
fetch: this.fetchApi,
|
|
71
|
+
url: a.url,
|
|
72
|
+
init: a.init,
|
|
73
|
+
response: o.clone()
|
|
74
|
+
}) || o);
|
|
75
|
+
return o;
|
|
76
|
+
}, this.middleware = i.middleware;
|
|
77
|
+
}
|
|
78
|
+
withMiddleware(...i) {
|
|
79
|
+
const t = this.clone();
|
|
80
|
+
return t.middleware = t.middleware.concat(...i), t;
|
|
81
|
+
}
|
|
82
|
+
withPreMiddleware(...i) {
|
|
83
|
+
const t = i.map((r) => ({ pre: r }));
|
|
84
|
+
return this.withMiddleware(...t);
|
|
85
|
+
}
|
|
86
|
+
withPostMiddleware(...i) {
|
|
87
|
+
const t = i.map((r) => ({ post: r }));
|
|
88
|
+
return this.withMiddleware(...t);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Check if the given MIME is a JSON MIME.
|
|
92
|
+
* JSON MIME examples:
|
|
93
|
+
* application/json
|
|
94
|
+
* application/json; charset=UTF8
|
|
95
|
+
* APPLICATION/JSON
|
|
96
|
+
* application/vnd.company+json
|
|
97
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
98
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
99
|
+
*/
|
|
100
|
+
isJsonMime(i) {
|
|
101
|
+
return i ? E.jsonRegex.test(i) : !1;
|
|
102
|
+
}
|
|
103
|
+
async request(i, t) {
|
|
104
|
+
const { url: r, init: a } = await this.createFetchParams(i, t), o = await this.fetchApi(r, a);
|
|
105
|
+
if (o && o.status >= 200 && o.status < 300)
|
|
106
|
+
return o;
|
|
107
|
+
throw new K(o, "Response returned an error code");
|
|
108
|
+
}
|
|
109
|
+
async createFetchParams(i, t) {
|
|
110
|
+
let r = this.configuration.basePath + i.path;
|
|
111
|
+
i.query !== void 0 && Object.keys(i.query).length !== 0 && (r += "?" + this.configuration.queryParamsStringify(i.query));
|
|
112
|
+
const a = Object.assign({}, this.configuration.headers, i.headers);
|
|
113
|
+
Object.keys(a).forEach((h) => a[h] === void 0 ? delete a[h] : {});
|
|
114
|
+
const o = typeof t == "function" ? t : async () => t, s = {
|
|
115
|
+
method: i.method,
|
|
116
|
+
headers: a,
|
|
117
|
+
body: i.body,
|
|
118
|
+
credentials: this.configuration.credentials
|
|
119
|
+
}, u = {
|
|
120
|
+
...s,
|
|
121
|
+
...await o({
|
|
122
|
+
init: s,
|
|
123
|
+
context: i
|
|
124
|
+
})
|
|
125
|
+
};
|
|
126
|
+
let c;
|
|
127
|
+
L(u.body) || u.body instanceof URLSearchParams || j(u.body) ? c = u.body : this.isJsonMime(a["Content-Type"]) ? c = JSON.stringify(u.body) : c = u.body;
|
|
128
|
+
const d = {
|
|
129
|
+
...u,
|
|
130
|
+
body: c
|
|
131
|
+
};
|
|
132
|
+
return { url: r, init: d };
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Create a shallow clone of `this` by constructing a new instance
|
|
136
|
+
* and then shallow cloning data members.
|
|
137
|
+
*/
|
|
138
|
+
clone() {
|
|
139
|
+
const i = this.constructor, t = new i(this.configuration);
|
|
140
|
+
return t.middleware = this.middleware.slice(), t;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
R.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
|
|
144
|
+
let f = R;
|
|
145
|
+
function j(e) {
|
|
146
|
+
return typeof Blob < "u" && e instanceof Blob;
|
|
147
|
+
}
|
|
148
|
+
function L(e) {
|
|
149
|
+
return typeof FormData < "u" && e instanceof FormData;
|
|
150
|
+
}
|
|
151
|
+
class K extends Error {
|
|
152
|
+
constructor(i, t) {
|
|
153
|
+
super(t), this.response = i, this.name = "ResponseError";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
class N extends Error {
|
|
157
|
+
constructor(i, t) {
|
|
158
|
+
super(t), this.cause = i, this.name = "FetchError";
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
class y extends Error {
|
|
162
|
+
constructor(i, t) {
|
|
163
|
+
super(t), this.field = i, this.name = "RequiredError";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function n(e, i) {
|
|
167
|
+
return e[i] != null;
|
|
168
|
+
}
|
|
169
|
+
function I(e, i = "") {
|
|
170
|
+
return Object.keys(e).map((t) => A(t, e[t], i)).filter((t) => t.length > 0).join("&");
|
|
171
|
+
}
|
|
172
|
+
function A(e, i, t = "") {
|
|
173
|
+
const r = t + (t.length ? `[${e}]` : e);
|
|
174
|
+
if (i instanceof Array) {
|
|
175
|
+
const a = i.map((o) => encodeURIComponent(String(o))).join(`&${encodeURIComponent(r)}=`);
|
|
176
|
+
return `${encodeURIComponent(r)}=${a}`;
|
|
177
|
+
}
|
|
178
|
+
if (i instanceof Set) {
|
|
179
|
+
const a = Array.from(i);
|
|
180
|
+
return A(e, a, t);
|
|
181
|
+
}
|
|
182
|
+
return i instanceof Date ? `${encodeURIComponent(r)}=${encodeURIComponent(i.toISOString())}` : i instanceof Object ? I(i, r) : `${encodeURIComponent(r)}=${encodeURIComponent(String(i))}`;
|
|
183
|
+
}
|
|
184
|
+
function g(e, i) {
|
|
185
|
+
return Object.keys(e).reduce(
|
|
186
|
+
(t, r) => ({ ...t, [r]: i(e[r]) }),
|
|
187
|
+
{}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
class l {
|
|
191
|
+
constructor(i, t = (r) => r) {
|
|
192
|
+
this.raw = i, this.transformer = t;
|
|
193
|
+
}
|
|
194
|
+
async value() {
|
|
195
|
+
return this.transformer(await this.raw.json());
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function $(e) {
|
|
199
|
+
return O(e);
|
|
200
|
+
}
|
|
201
|
+
function O(e, i) {
|
|
202
|
+
return e == null ? e : {
|
|
203
|
+
identifier: n(e, "identifier") ? e.identifier : void 0,
|
|
204
|
+
content: n(e, "content") ? e.content.map(C) : void 0
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function C(e) {
|
|
208
|
+
return M(e);
|
|
209
|
+
}
|
|
210
|
+
function M(e, i) {
|
|
211
|
+
return e == null ? e : {
|
|
212
|
+
items: n(e, "items") ? e.items : void 0,
|
|
213
|
+
content: n(e, "content") ? e.content : void 0,
|
|
214
|
+
config: n(e, "config") ? e.config : void 0,
|
|
215
|
+
identifier: n(e, "identifier") ? e.identifier : void 0,
|
|
216
|
+
uid: n(e, "uid") ? e.uid : void 0,
|
|
217
|
+
component: n(e, "component") ? e.component : void 0,
|
|
218
|
+
slots: n(e, "slots") ? g(e.slots, $) : void 0
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function T(e) {
|
|
222
|
+
return B(e);
|
|
223
|
+
}
|
|
224
|
+
function B(e, i) {
|
|
225
|
+
return e == null ? e : {
|
|
226
|
+
type: n(e, "type") ? e.type : void 0,
|
|
227
|
+
target: n(e, "target") ? e.target : void 0,
|
|
228
|
+
label: n(e, "label") ? e.label : void 0,
|
|
229
|
+
href: n(e, "href") ? e.href : void 0,
|
|
230
|
+
slug: n(e, "slug") ? e.slug : void 0,
|
|
231
|
+
properties: n(e, "properties") ? e.properties : void 0,
|
|
232
|
+
children: n(e, "children") ? e.children.map(T) : void 0
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function F(e) {
|
|
236
|
+
return D(e);
|
|
237
|
+
}
|
|
238
|
+
function D(e, i) {
|
|
239
|
+
return e == null ? e : {
|
|
240
|
+
items: n(e, "items") ? e.items.map(T) : void 0,
|
|
241
|
+
uid: n(e, "uid") ? e.uid : void 0,
|
|
242
|
+
identifier: n(e, "identifier") ? e.identifier : void 0,
|
|
243
|
+
label: n(e, "label") ? e.label : void 0
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function G(e) {
|
|
247
|
+
return J(e);
|
|
248
|
+
}
|
|
249
|
+
function J(e, i) {
|
|
250
|
+
return e == null ? e : {
|
|
251
|
+
domain: n(e, "domain") ? e.domain : void 0,
|
|
252
|
+
slug: n(e, "slug") ? e.slug : void 0,
|
|
253
|
+
version: n(e, "version") ? e.version : void 0,
|
|
254
|
+
updatedAt: n(e, "updated_at") ? e.updated_at : void 0,
|
|
255
|
+
language: n(e, "language") ? e.language : void 0
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function V(e) {
|
|
259
|
+
return W(e);
|
|
260
|
+
}
|
|
261
|
+
function W(e, i) {
|
|
262
|
+
return e == null ? e : {
|
|
263
|
+
nitro: n(e, "nitro") ? G(e.nitro) : void 0,
|
|
264
|
+
pages: n(e, "pages") ? e.pages : void 0,
|
|
265
|
+
containers: n(e, "containers") ? g(e.containers, F) : void 0,
|
|
266
|
+
globals: n(e, "globals") ? e.globals : void 0
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function z(e) {
|
|
270
|
+
return H(e);
|
|
271
|
+
}
|
|
272
|
+
function H(e, i) {
|
|
273
|
+
return e == null ? e : {
|
|
274
|
+
api: n(e, "api") ? e.api : void 0,
|
|
275
|
+
image: n(e, "image") ? e.image : void 0
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function X(e) {
|
|
279
|
+
return Z(e);
|
|
280
|
+
}
|
|
281
|
+
function Z(e, i) {
|
|
282
|
+
return e == null ? e : {
|
|
283
|
+
version: n(e, "_version") ? e._version : void 0,
|
|
284
|
+
entityMetric: n(e, "entity_metric") ? z(e.entity_metric) : void 0,
|
|
285
|
+
entityUniqueId: n(e, "entity_unique_id") ? e.entity_unique_id : void 0,
|
|
286
|
+
entityId: n(e, "entity_id") ? e.entity_id : void 0,
|
|
287
|
+
entityImage: n(e, "entity_image") ? e.entity_image : void 0,
|
|
288
|
+
entitySlug: n(e, "entity_slug") ? e.entity_slug : void 0,
|
|
289
|
+
entityTeaser: n(e, "entity_teaser") ? e.entity_teaser : void 0,
|
|
290
|
+
entityTimeEnd: n(e, "entity_time_end") ? e.entity_time_end : void 0,
|
|
291
|
+
entityTimeStart: n(e, "entity_time_start") ? e.entity_time_start : void 0,
|
|
292
|
+
entityTitle: n(e, "entity_title") ? e.entity_title : void 0,
|
|
293
|
+
entityType: n(e, "entity_type") ? e.entity_type : void 0,
|
|
294
|
+
entityTypeId: n(e, "entity_type_id") ? e.entity_type_id : void 0,
|
|
295
|
+
updatedAt: n(e, "updated_at") ? e.updated_at : void 0,
|
|
296
|
+
routes: n(e, "routes") ? e.routes : void 0
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function m(e) {
|
|
300
|
+
return Q(e);
|
|
301
|
+
}
|
|
302
|
+
function Q(e, i) {
|
|
303
|
+
return e == null ? e : {
|
|
304
|
+
entity: n(e, "entity") ? X(e.entity) : void 0,
|
|
305
|
+
model: n(e, "model") ? e.model : void 0,
|
|
306
|
+
language: n(e, "language") ? e.language : void 0,
|
|
307
|
+
jsonld: n(e, "jsonld") ? e.jsonld : void 0
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function k(e) {
|
|
311
|
+
return Y(e);
|
|
312
|
+
}
|
|
313
|
+
function Y(e, i) {
|
|
314
|
+
return e == null ? e : {
|
|
315
|
+
entityUniqueId: n(e, "entity_unique_id") ? e.entity_unique_id : void 0,
|
|
316
|
+
entityTitle: n(e, "entity_title") ? e.entity_title : void 0,
|
|
317
|
+
entityTeaser: n(e, "entity_teaser") ? e.entity_teaser : void 0,
|
|
318
|
+
entitySlug: n(e, "entity_slug") ? e.entity_slug : void 0,
|
|
319
|
+
entityTimeStart: n(e, "entity_time_start") ? e.entity_time_start : void 0,
|
|
320
|
+
entityType: n(e, "entity_type") ? e.entity_type : void 0,
|
|
321
|
+
entityTypeId: n(e, "entity_type_id") ? e.entity_type_id : void 0,
|
|
322
|
+
entityImage: n(e, "entity_image") ? e.entity_image : void 0,
|
|
323
|
+
routes: n(e, "routes") ? e.routes : void 0
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function ee(e) {
|
|
327
|
+
return ie(e);
|
|
328
|
+
}
|
|
329
|
+
function ie(e, i) {
|
|
330
|
+
return e == null ? e : {
|
|
331
|
+
description: n(e, "description") ? e.description : void 0,
|
|
332
|
+
image: n(e, "image") ? e.image : void 0,
|
|
333
|
+
title: n(e, "title") ? e.title : void 0
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function te(e) {
|
|
337
|
+
return ne(e);
|
|
338
|
+
}
|
|
339
|
+
function ne(e, i) {
|
|
340
|
+
return e == null ? e : {
|
|
341
|
+
slug: n(e, "slug") ? e.slug : void 0,
|
|
342
|
+
title: n(e, "title") ? e.title : void 0
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function oe(e) {
|
|
346
|
+
return re(e);
|
|
347
|
+
}
|
|
348
|
+
function re(e, i) {
|
|
349
|
+
return e == null ? e : {
|
|
350
|
+
value: n(e, "value") ? e.value : void 0,
|
|
351
|
+
navigation: n(e, "navigation") ? e.navigation : void 0,
|
|
352
|
+
propagate: n(e, "propagate") ? e.propagate : void 0
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function w(e) {
|
|
356
|
+
return ae(e);
|
|
357
|
+
}
|
|
358
|
+
function ae(e, i) {
|
|
359
|
+
return e == null ? e : {
|
|
360
|
+
id: n(e, "id") ? e.id : void 0,
|
|
361
|
+
title: n(e, "title") ? e.title : void 0,
|
|
362
|
+
href: n(e, "href") ? e.href : void 0,
|
|
363
|
+
slug: n(e, "slug") ? e.slug : void 0,
|
|
364
|
+
json: n(e, "json") ? e.json.map(C) : void 0,
|
|
365
|
+
depth: n(e, "depth") ? e.depth : void 0,
|
|
366
|
+
isHome: n(e, "is_home") ? e.is_home : void 0,
|
|
367
|
+
createdAt: n(e, "created_at") ? e.created_at : void 0,
|
|
368
|
+
updatedAt: n(e, "updated_at") ? e.updated_at : void 0,
|
|
369
|
+
isVisible: n(e, "is_visible") ? e.is_visible : void 0,
|
|
370
|
+
metaJson: n(e, "meta_json") ? ee(e.meta_json) : void 0,
|
|
371
|
+
properties: n(e, "properties") ? g(e.properties, oe) : void 0,
|
|
372
|
+
uid: n(e, "uid") ? e.uid : void 0,
|
|
373
|
+
type: n(e, "type") ? e.type : void 0,
|
|
374
|
+
target: n(e, "target") ? e.target : void 0,
|
|
375
|
+
container: n(e, "container") ? e.container : void 0,
|
|
376
|
+
breadcrumb: n(e, "breadcrumb") ? e.breadcrumb.map(te) : void 0
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
function se(e) {
|
|
380
|
+
return ue(e);
|
|
381
|
+
}
|
|
382
|
+
function ue(e, i) {
|
|
383
|
+
return e == null ? e : {
|
|
384
|
+
version: n(e, "version") ? e.version : void 0,
|
|
385
|
+
updatedAt: n(e, "updated_at") ? e.updated_at : void 0
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
class ce extends f {
|
|
389
|
+
/**
|
|
390
|
+
* The config API endpoint provides comprehensive information required for configuring the layout of websites. It encompasses various essential elements, including containers with pages, an extensive list of available slugs, globals containing content pool data, and crucial details about the Nitro configuration itself. By accessing this endpoint, developers can gather all the necessary data to effectively design and structure their websites. The endpoint offers a holistic view of the website\'s layout, empowering developers to tailor the user experience and optimize the overall design.
|
|
391
|
+
* Get Config
|
|
392
|
+
*/
|
|
393
|
+
async configRaw(i) {
|
|
394
|
+
const t = {}, r = {};
|
|
395
|
+
this.configuration && this.configuration.apiKey && (t.token = this.configuration.apiKey("token"));
|
|
396
|
+
const a = await this.request({
|
|
397
|
+
path: "/config",
|
|
398
|
+
method: "GET",
|
|
399
|
+
headers: r,
|
|
400
|
+
query: t
|
|
401
|
+
}, i);
|
|
402
|
+
return new l(a, (o) => V(o));
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* The config API endpoint provides comprehensive information required for configuring the layout of websites. It encompasses various essential elements, including containers with pages, an extensive list of available slugs, globals containing content pool data, and crucial details about the Nitro configuration itself. By accessing this endpoint, developers can gather all the necessary data to effectively design and structure their websites. The endpoint offers a holistic view of the website\'s layout, empowering developers to tailor the user experience and optimize the overall design.
|
|
406
|
+
* Get Config
|
|
407
|
+
*/
|
|
408
|
+
async config(i) {
|
|
409
|
+
return await (await this.configRaw(i)).value();
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
class de extends f {
|
|
413
|
+
/**
|
|
414
|
+
*
|
|
415
|
+
* Find entity by slug and optional Type-ID
|
|
416
|
+
*/
|
|
417
|
+
async entityBySlugRaw(i, t) {
|
|
418
|
+
if (i.slug === null || i.slug === void 0)
|
|
419
|
+
throw new y("slug", "Required parameter requestParameters.slug was null or undefined when calling entityBySlug.");
|
|
420
|
+
const r = {};
|
|
421
|
+
i.typeId !== void 0 && (r.typeId = i.typeId);
|
|
422
|
+
const a = {};
|
|
423
|
+
this.configuration && this.configuration.apiKey && (r.token = this.configuration.apiKey("token"));
|
|
424
|
+
const o = await this.request({
|
|
425
|
+
path: "/entities/slug/{slug}".replace("{slug}", encodeURIComponent(String(i.slug))),
|
|
426
|
+
method: "GET",
|
|
427
|
+
headers: a,
|
|
428
|
+
query: r
|
|
429
|
+
}, t);
|
|
430
|
+
return new l(o, (s) => m(s));
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
*
|
|
434
|
+
* Find entity by slug and optional Type-ID
|
|
435
|
+
*/
|
|
436
|
+
async entityBySlug(i, t) {
|
|
437
|
+
return await (await this.entityBySlugRaw(i, t)).value();
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* The endpoint provides comprehensive information about a specified entity. An entity represents a collection of information pertaining to a specific data type and is defined by a key-value pair. You can use various data types such as blogs, events, or any other relevant data. However, in order to access an entity, it must be properly configured within the nitro config.
|
|
441
|
+
* Find entity by uniqueid
|
|
442
|
+
*/
|
|
443
|
+
async entityByUniqueidRaw(i, t) {
|
|
444
|
+
if (i.uniqueid === null || i.uniqueid === void 0)
|
|
445
|
+
throw new y("uniqueid", "Required parameter requestParameters.uniqueid was null or undefined when calling entityByUniqueid.");
|
|
446
|
+
const r = {}, a = {};
|
|
447
|
+
this.configuration && this.configuration.apiKey && (r.token = this.configuration.apiKey("token"));
|
|
448
|
+
const o = await this.request({
|
|
449
|
+
path: "/entities/uniqueid/{uniqueid}".replace("{uniqueid}", encodeURIComponent(String(i.uniqueid))),
|
|
450
|
+
method: "GET",
|
|
451
|
+
headers: a,
|
|
452
|
+
query: r
|
|
453
|
+
}, t);
|
|
454
|
+
return new l(o, (s) => m(s));
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* The endpoint provides comprehensive information about a specified entity. An entity represents a collection of information pertaining to a specific data type and is defined by a key-value pair. You can use various data types such as blogs, events, or any other relevant data. However, in order to access an entity, it must be properly configured within the nitro config.
|
|
458
|
+
* Find entity by uniqueid
|
|
459
|
+
*/
|
|
460
|
+
async entityByUniqueid(i, t) {
|
|
461
|
+
return await (await this.entityByUniqueidRaw(i, t)).value();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
class le extends f {
|
|
465
|
+
/**
|
|
466
|
+
* This endpoint allows you to retrieve the designated homepage of a website. Alternatively, you can utilize the pages endpoint by specifying an empty slug parameter to achieve the same result. By using either of these methods, you can effectively access the desired homepage of the website.
|
|
467
|
+
* Get Home
|
|
468
|
+
*/
|
|
469
|
+
async homeRaw(i) {
|
|
470
|
+
const t = {}, r = {};
|
|
471
|
+
this.configuration && this.configuration.apiKey && (t.token = this.configuration.apiKey("token"));
|
|
472
|
+
const a = await this.request({
|
|
473
|
+
path: "/pages/home",
|
|
474
|
+
method: "GET",
|
|
475
|
+
headers: r,
|
|
476
|
+
query: t
|
|
477
|
+
}, i);
|
|
478
|
+
return new l(a, (o) => w(o));
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* This endpoint allows you to retrieve the designated homepage of a website. Alternatively, you can utilize the pages endpoint by specifying an empty slug parameter to achieve the same result. By using either of these methods, you can effectively access the desired homepage of the website.
|
|
482
|
+
* Get Home
|
|
483
|
+
*/
|
|
484
|
+
async home(i) {
|
|
485
|
+
return await (await this.homeRaw(i)).value();
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* This endpoint retrieves comprehensive information from a specified page using either a slug or a path. The slug refers to a unique identifier for the page, while the path is the slug with a leading slash. By providing either the slug or the path as input, the function will gather all the relevant details associated with the page.
|
|
489
|
+
* Get Page by slug
|
|
490
|
+
*/
|
|
491
|
+
async pageRaw(i, t) {
|
|
492
|
+
const r = {};
|
|
493
|
+
i.slug !== void 0 && (r.slug = i.slug);
|
|
494
|
+
const a = {};
|
|
495
|
+
this.configuration && this.configuration.apiKey && (r.token = this.configuration.apiKey("token"));
|
|
496
|
+
const o = await this.request({
|
|
497
|
+
path: "/pages",
|
|
498
|
+
method: "GET",
|
|
499
|
+
headers: a,
|
|
500
|
+
query: r
|
|
501
|
+
}, t);
|
|
502
|
+
return new l(o, (s) => w(s));
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* This endpoint retrieves comprehensive information from a specified page using either a slug or a path. The slug refers to a unique identifier for the page, while the path is the slug with a leading slash. By providing either the slug or the path as input, the function will gather all the relevant details associated with the page.
|
|
506
|
+
* Get Page by slug
|
|
507
|
+
*/
|
|
508
|
+
async page(i = {}, t) {
|
|
509
|
+
return await (await this.pageRaw(i, t)).value();
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
class fe extends f {
|
|
513
|
+
/**
|
|
514
|
+
* This endpoint offers a powerful capability to search through the websites sitemap, encompassing both pages and entities. With this endpoint, users can efficiently explore and retrieve information from your sitemap by creating a paginated search experience.
|
|
515
|
+
* Get Search by query
|
|
516
|
+
*/
|
|
517
|
+
async searchRaw(i, t) {
|
|
518
|
+
if (i.query === null || i.query === void 0)
|
|
519
|
+
throw new y("query", "Required parameter requestParameters.query was null or undefined when calling search.");
|
|
520
|
+
const r = {};
|
|
521
|
+
i.query !== void 0 && (r.query = i.query);
|
|
522
|
+
const a = {};
|
|
523
|
+
this.configuration && this.configuration.apiKey && (r.token = this.configuration.apiKey("token"));
|
|
524
|
+
const o = await this.request({
|
|
525
|
+
path: "/search",
|
|
526
|
+
method: "GET",
|
|
527
|
+
headers: a,
|
|
528
|
+
query: r
|
|
529
|
+
}, t);
|
|
530
|
+
return new l(o, (s) => s.map(k));
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* This endpoint offers a powerful capability to search through the websites sitemap, encompassing both pages and entities. With this endpoint, users can efficiently explore and retrieve information from your sitemap by creating a paginated search experience.
|
|
534
|
+
* Get Search by query
|
|
535
|
+
*/
|
|
536
|
+
async search(i, t) {
|
|
537
|
+
return await (await this.searchRaw(i, t)).value();
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
class pe extends f {
|
|
541
|
+
/**
|
|
542
|
+
* This endpoint provides comprehensive data for generating the sitemap. It encompasses all the necessary information, including pages from containers, as well as all entities that have been mapped.
|
|
543
|
+
* Get Sitemap
|
|
544
|
+
*/
|
|
545
|
+
async sitemapRaw(i) {
|
|
546
|
+
const t = {}, r = {};
|
|
547
|
+
this.configuration && this.configuration.apiKey && (t.token = this.configuration.apiKey("token"));
|
|
548
|
+
const a = await this.request({
|
|
549
|
+
path: "/sitemap",
|
|
550
|
+
method: "GET",
|
|
551
|
+
headers: r,
|
|
552
|
+
query: t
|
|
553
|
+
}, i);
|
|
554
|
+
return new l(a, (o) => o.map(k));
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* This endpoint provides comprehensive data for generating the sitemap. It encompasses all the necessary information, including pages from containers, as well as all entities that have been mapped.
|
|
558
|
+
* Get Sitemap
|
|
559
|
+
*/
|
|
560
|
+
async sitemap(i) {
|
|
561
|
+
return await (await this.sitemapRaw(i)).value();
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
class he extends f {
|
|
565
|
+
/**
|
|
566
|
+
* The Version API endpoint offers a highly efficient solution for evaluating the current caching status of your application\'s caching mechanism. This functionality allows you to cache the entire application configuration and page responses indefinitely. However, utilizing this endpoint enables you to assess the validity of the cache by sending a request to determine its current status. This caching endpoint is specifically designed for optimal performance when compared to the configuration endpoint, which requires more thorough evaluation and encompasses a substantial response body.
|
|
567
|
+
* Get Version Information
|
|
568
|
+
*/
|
|
569
|
+
async versionRaw(i) {
|
|
570
|
+
const t = {}, r = {};
|
|
571
|
+
this.configuration && this.configuration.apiKey && (t.token = this.configuration.apiKey("token"));
|
|
572
|
+
const a = await this.request({
|
|
573
|
+
path: "/version",
|
|
574
|
+
method: "GET",
|
|
575
|
+
headers: r,
|
|
576
|
+
query: t
|
|
577
|
+
}, i);
|
|
578
|
+
return new l(a, (o) => se(o));
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* The Version API endpoint offers a highly efficient solution for evaluating the current caching status of your application\'s caching mechanism. This functionality allows you to cache the entire application configuration and page responses indefinitely. However, utilizing this endpoint enables you to assess the validity of the cache by sending a request to determine its current status. This caching endpoint is specifically designed for optimal performance when compared to the configuration endpoint, which requires more thorough evaluation and encompasses a substantial response body.
|
|
582
|
+
* Get Version Information
|
|
583
|
+
*/
|
|
584
|
+
async version(i) {
|
|
585
|
+
return await (await this.versionRaw(i)).value();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const ye = /[\p{Lu}]/u, ge = /[\p{Ll}]/u, _ = /^[\p{Lu}](?![\p{Lu}])/gu, S = /([\p{Alpha}\p{N}_]|$)/u, v = /[_.\- ]+/, ve = new RegExp("^" + v.source), q = new RegExp(v.source + S.source, "gu"), b = new RegExp("\\d+" + S.source, "gu"), me = (e, i, t, r) => {
|
|
589
|
+
let a = !1, o = !1, s = !1, u = !1;
|
|
590
|
+
for (let c = 0; c < e.length; c++) {
|
|
591
|
+
const d = e[c];
|
|
592
|
+
u = c > 2 ? e[c - 3] === "-" : !0, a && ye.test(d) ? (e = e.slice(0, c) + "-" + e.slice(c), a = !1, s = o, o = !0, c++) : o && s && ge.test(d) && (!u || r) ? (e = e.slice(0, c - 1) + "-" + e.slice(c - 1), s = o, o = !1, a = !0) : (a = i(d) === d && t(d) !== d, s = o, o = t(d) === d && i(d) !== d);
|
|
6
593
|
}
|
|
7
594
|
return e;
|
|
8
|
-
},
|
|
9
|
-
function
|
|
595
|
+
}, we = (e, i) => (_.lastIndex = 0, e.replace(_, (t) => i(t))), _e = (e, i) => (q.lastIndex = 0, b.lastIndex = 0, e.replace(q, (t, r) => i(r)).replace(b, (t) => i(t)));
|
|
596
|
+
function qe(e, i) {
|
|
10
597
|
if (!(typeof e == "string" || Array.isArray(e)))
|
|
11
598
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
12
|
-
if (
|
|
599
|
+
if (i = {
|
|
13
600
|
pascalCase: !1,
|
|
14
601
|
preserveConsecutiveUppercase: !1,
|
|
15
|
-
...
|
|
16
|
-
}, Array.isArray(e) ? e = e.map((
|
|
602
|
+
...i
|
|
603
|
+
}, Array.isArray(e) ? e = e.map((o) => o.trim()).filter((o) => o.length).join("-") : e = e.trim(), e.length === 0)
|
|
17
604
|
return "";
|
|
18
|
-
const
|
|
19
|
-
return e.length === 1 ?
|
|
605
|
+
const t = i.locale === !1 ? (o) => o.toLowerCase() : (o) => o.toLocaleLowerCase(i.locale), r = i.locale === !1 ? (o) => o.toUpperCase() : (o) => o.toLocaleUpperCase(i.locale);
|
|
606
|
+
return e.length === 1 ? v.test(e) ? "" : i.pascalCase ? r(e) : t(e) : (e !== t(e) && (e = me(e, t, r, i.preserveConsecutiveUppercase)), e = e.replace(ve, ""), e = i.preserveConsecutiveUppercase ? we(e, t) : t(e), i.pascalCase && (e = r(e.charAt(0)) + e.slice(1)), _e(e, r));
|
|
20
607
|
}
|
|
21
|
-
function
|
|
22
|
-
const r = "virtual:flyo-components",
|
|
608
|
+
function be(e, i, t) {
|
|
609
|
+
const r = "virtual:flyo-components", a = "\0" + r;
|
|
23
610
|
return {
|
|
24
611
|
name: "vite-plugin-flyo-components",
|
|
25
|
-
async resolveId(
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
612
|
+
async resolveId(o) {
|
|
613
|
+
if (o === r)
|
|
614
|
+
return a;
|
|
28
615
|
},
|
|
29
|
-
async load(
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
for (const [
|
|
33
|
-
const
|
|
34
|
-
"/" + e + "/" +
|
|
616
|
+
async load(o) {
|
|
617
|
+
if (o === a) {
|
|
618
|
+
const s = [];
|
|
619
|
+
for (const [c, d] of Object.entries(i)) {
|
|
620
|
+
const h = await this.resolve(
|
|
621
|
+
"/" + e + "/" + d + ".astro"
|
|
35
622
|
);
|
|
36
|
-
|
|
623
|
+
h && s.push(`export { default as ${qe(c)} } from "${h.id}"`);
|
|
37
624
|
}
|
|
38
|
-
let
|
|
39
|
-
return
|
|
40
|
-
"/" + e + "/" +
|
|
41
|
-
)),
|
|
625
|
+
let u = null;
|
|
626
|
+
return t && (u = await this.resolve(
|
|
627
|
+
"/" + e + "/" + t + ".astro"
|
|
628
|
+
)), u ? s.push(`export { default as fallback } from "${u.id}"`) : s.push('export { default as fallback } from "@flyo/nitro-astro/src/components/FallbackComponent.astro"'), s.join(";");
|
|
42
629
|
}
|
|
43
630
|
}
|
|
44
631
|
};
|
|
45
632
|
}
|
|
46
|
-
function
|
|
633
|
+
function p() {
|
|
47
634
|
return globalThis.flyoNitroInstance || console.error("flyoNitroInstance has not been initialized correctly"), globalThis.flyoNitroInstance;
|
|
48
635
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
636
|
+
function Re() {
|
|
637
|
+
return new ce(p());
|
|
638
|
+
}
|
|
639
|
+
function Ee() {
|
|
640
|
+
return new de(p());
|
|
641
|
+
}
|
|
642
|
+
function Ie() {
|
|
643
|
+
return new le(p());
|
|
644
|
+
}
|
|
645
|
+
function Ae() {
|
|
646
|
+
return new fe(p());
|
|
647
|
+
}
|
|
648
|
+
function Ce() {
|
|
649
|
+
return new pe(p());
|
|
650
|
+
}
|
|
651
|
+
function Te() {
|
|
652
|
+
return new he(p());
|
|
653
|
+
}
|
|
654
|
+
function ke(e) {
|
|
655
|
+
const i = {
|
|
51
656
|
accessToken: !1,
|
|
52
657
|
liveEdit: !1,
|
|
53
658
|
fallbackComponent: null,
|
|
@@ -56,29 +661,29 @@ function N(e) {
|
|
|
56
661
|
return {
|
|
57
662
|
name: "@flyo/nitro-astro",
|
|
58
663
|
hooks: {
|
|
59
|
-
"astro:config:setup": ({ injectScript:
|
|
664
|
+
"astro:config:setup": ({ injectScript: t, updateConfig: r }) => {
|
|
60
665
|
r({
|
|
61
666
|
vite: {
|
|
62
667
|
plugins: [
|
|
63
|
-
|
|
668
|
+
be(
|
|
64
669
|
e.componentsDir,
|
|
65
670
|
e.components,
|
|
66
671
|
e.fallbackComponent
|
|
67
672
|
)
|
|
68
673
|
]
|
|
69
674
|
}
|
|
70
|
-
}),
|
|
675
|
+
}), t(
|
|
71
676
|
"page-ssr",
|
|
72
677
|
`
|
|
73
678
|
import { Configuration } from '@flyo/nitro-typescript'
|
|
74
679
|
|
|
75
|
-
var defaultConfig = Configuration({
|
|
76
|
-
apiKey: '${
|
|
680
|
+
var defaultConfig = new Configuration({
|
|
681
|
+
apiKey: '${i.accessToken}'
|
|
77
682
|
})
|
|
78
683
|
|
|
79
684
|
globalThis.flyoNitroInstance = defaultConfig;
|
|
80
685
|
`
|
|
81
|
-
),
|
|
686
|
+
), i.liveEdit && t(
|
|
82
687
|
"page",
|
|
83
688
|
`
|
|
84
689
|
window.addEventListener("message", (event) => {
|
|
@@ -109,6 +714,12 @@ function N(e) {
|
|
|
109
714
|
};
|
|
110
715
|
}
|
|
111
716
|
export {
|
|
112
|
-
|
|
113
|
-
|
|
717
|
+
ke as default,
|
|
718
|
+
Re as useConfigApi,
|
|
719
|
+
p as useConfiguration,
|
|
720
|
+
Ee as useEntitiesApi,
|
|
721
|
+
Ie as usePagesApi,
|
|
722
|
+
Ae as useSearchApi,
|
|
723
|
+
Ce as useSitemapApi,
|
|
724
|
+
Te as useVersionApi
|
|
114
725
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flyo/nitro-astro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Astro Framework",
|
|
5
5
|
"main": "./dist/nitro-astro.js",
|
|
6
6
|
"module": "./dist/nitro-astro.mjs",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"dist",
|
|
10
10
|
"src/components"
|
|
11
11
|
],
|
|
12
|
+
"typings": "./dist/index.d.ts",
|
|
12
13
|
"author": "Basil Suter <git@nadar.io>",
|
|
13
14
|
"license": "MIT",
|
|
14
15
|
"scripts": {
|
|
@@ -26,6 +27,6 @@
|
|
|
26
27
|
"url": "https://github.com/flyocloud/nitro-astro"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@flyo/nitro-typescript": "^1.0.
|
|
30
|
+
"@flyo/nitro-typescript": "^1.0.5"
|
|
30
31
|
}
|
|
31
32
|
}
|