decap-cms-backend-github 3.0.1 → 3.0.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.0.2](https://github.com/decaporg/decap-cms/compare/decap-cms-backend-github@3.0.1...decap-cms-backend-github@3.0.2) (2023-09-06)
7
+
8
+
9
+ ### Performance Improvements
10
+
11
+ * filter by path when loading collection from github backend ([#6898](https://github.com/decaporg/decap-cms/issues/6898)) ([18ef773](https://github.com/decaporg/decap-cms/commit/18ef773f35db1b7ef3ab5a0f25527d87745b9c73))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [3.0.1](https://github.com/decaporg/decap-cms/compare/decap-cms-backend-github@3.0.0...decap-cms-backend-github@3.0.1) (2023-08-25)
7
18
 
8
19
 
@@ -308,5 +308,5 @@
308
308
  If the repo is private, make sure you're logged into a GitHub account with access.
309
309
 
310
310
  If your repo is under an organization, ensure the organization has granted access to Decap CMS.
311
- `,e})))throw new Error("Your GitHub user account does not have access to this repo.");return ca(ca({},r),{},{token:e.token,useOpenAuthoring:this.useOpenAuthoring})}logout(){if(this.token=null,this.api&&this.api.reset&&"function"==typeof this.api.reset)return this.api.reset()}getToken(){return Promise.resolve(this.token)}async entriesByFolder(e,t,r){const n=this.api.originRepoURL;let i;const o=await(0,S.entriesByFolder)((()=>this.api.listFiles(e,{repoURL:n,depth:r}).then((e=>{const r=e.filter((e=>(0,S.filterByExtension)(e,t))),n=this.getCursorAndFiles(r,1);return i=n.cursor,n.files}))),((e,t)=>this.api.readFile(e,t,{repoURL:n})),this.api.readFileMetadata.bind(this.api),nt);return o[S.CURSOR_COMPATIBILITY_SYMBOL]=i,o}async allEntriesByFolder(e,t,r){const n=this.api.originRepoURL;return await(0,S.entriesByFolder)((()=>this.api.listFiles(e,{repoURL:n,depth:r}).then((e=>e.filter((e=>(0,S.filterByExtension)(e,t)))))),((e,t)=>this.api.readFile(e,t,{repoURL:n})),this.api.readFileMetadata.bind(this.api),nt)}entriesByFiles(e){const t=this.useOpenAuthoring?this.api.originRepoURL:this.api.repoURL;return(0,S.entriesByFiles)(e,((e,r)=>this.api.readFile(e,r,{repoURL:t}).catch((()=>""))),this.api.readFileMetadata.bind(this.api),nt)}getEntry(e){const t=this.api.originRepoURL;return this.api.readFile(e,null,{repoURL:t}).then((t=>({file:{path:e,id:null},data:t}))).catch((()=>({file:{path:e,id:null},data:""})))}getMedia(e=this.mediaFolder){return this.api.listFiles(e).then((e=>e.map((({id:e,name:t,size:r,path:n})=>({id:e,name:t,size:r,displayURL:{id:e,path:n},path:n})))))}async getMediaFile(e){const t=await(0,S.getMediaAsBlob)(e,null,this.api.readFile.bind(this.api)),r=(0,S.basename)(e),n=(0,S.blobToFileObj)(r,t),i=URL.createObjectURL(n);return{id:await(0,S.getBlobSHA)(t),displayURL:i,path:e,name:r,size:n.size,file:n,url:i}}getMediaDisplayURL(e){return this._mediaDisplayURLSem=this._mediaDisplayURLSem||o()(10),(0,S.getMediaDisplayURL)(e,this.api.readFile.bind(this.api),this._mediaDisplayURLSem)}persistEntry(e,t){return(0,S.runWithLock)(this.lock,(()=>this.api.persistFiles(e.dataFiles,e.assets,t)),"Failed to acquire persist entry lock")}async persistMedia(e,t){try{await this.api.persistFiles([],[e],t);const{sha:r,path:n,fileObj:i}=e,o=i?URL.createObjectURL(i):"";return{id:r,name:i.name,size:i.size,displayURL:o,path:s()(n,"/")}}catch(e){throw console.error(e),e}}deleteFiles(e,t){return this.api.deleteFiles(e,t)}async traverseCursor(e,t){const r=e.meta,n=e.data.get("files").toJS();let i;switch(t){case"first":default:i=this.getCursorAndFiles(n,1);break;case"last":i=this.getCursorAndFiles(n,r.get("pageCount"));break;case"next":i=this.getCursorAndFiles(n,r.get("page")+1);break;case"prev":i=this.getCursorAndFiles(n,r.get("page")-1)}return{entries:await(0,S.entriesByFiles)(i.files,((e,t)=>this.api.readFile(e,t,{repoURL:this.api.originRepoURL}).catch((()=>""))),this.api.readFileMetadata.bind(this.api),nt),cursor:i.cursor}}async loadMediaFile(e,t){const r=await(0,S.getMediaAsBlob)(t.path,t.id,((t,r,{parseText:n})=>this.api.readFile(t,r,{branch:e,parseText:n}))),n=(0,S.basename)(t.path),i=(0,S.blobToFileObj)(n,r);return{id:t.id,displayURL:URL.createObjectURL(i),path:t.path,name:n,size:i.size,file:i}}async unpublishedEntries(){const e=await(0,S.unpublishedEntries)((()=>this.api.listUnpublishedBranches().then((e=>e.map((e=>(0,S.contentKeyFromBranch)(e)))))));return e}async unpublishedEntry({id:e,collection:t,slug:r}){if(e)return await this.api.retrieveUnpublishedEntryData(e);if(t&&r){const e=this.api.generateContentKey(t,r);return await this.api.retrieveUnpublishedEntryData(e)}throw new Error("Missing unpublished entry id or collection and slug")}getBranch(e,t){const r=this.api.generateContentKey(e,t);return(0,S.branchFromContentKey)(r)}async unpublishedEntryDataFile(e,t,r,n){const i=this.getBranch(e,t);return await this.api.readFile(r,n,{branch:i})}async unpublishedEntryMediaFile(e,t,r,n){const i=this.getBranch(e,t);return await this.loadMediaFile(i,{path:r,id:n})}async getDeployPreview(e,t){try{const r=await this.api.getStatuses(e,t),n=(0,S.getPreviewStatus)(r,this.previewContext);if(n){const{target_url:e,state:t}=n;return{url:e,status:t}}return null}catch(e){return null}}updateUnpublishedEntryStatus(e,t,r){return(0,S.runWithLock)(this.lock,(()=>this.api.updateUnpublishedEntryStatus(e,t,r)),"Failed to acquire update entry status lock")}deleteUnpublishedEntry(e,t){return(0,S.runWithLock)(this.lock,(()=>this.api.deleteUnpublishedEntry(e,t)),"Failed to acquire delete entry lock")}publishUnpublishedEntry(e,t){return(0,S.runWithLock)(this.lock,(()=>this.api.publishUnpublishedEntry(e,t)),"Failed to acquire publish entry lock")}},API:lt,AuthenticationPage:ne}})(),c.DecapCmsBackendGithub})()));
311
+ `,e})))throw new Error("Your GitHub user account does not have access to this repo.");return ca(ca({},r),{},{token:e.token,useOpenAuthoring:this.useOpenAuthoring})}logout(){if(this.token=null,this.api&&this.api.reset&&"function"==typeof this.api.reset)return this.api.reset()}getToken(){return Promise.resolve(this.token)}async entriesByFolder(e,t,r){const n=this.api.originRepoURL;let i;const o=await(0,S.entriesByFolder)((()=>this.api.listFiles(e,{repoURL:n,depth:r}).then((e=>{const r=e.filter((e=>(0,S.filterByExtension)(e,t))),n=this.getCursorAndFiles(r,1);return i=n.cursor,n.files}))),((e,t)=>this.api.readFile(e,t,{repoURL:n})),this.api.readFileMetadata.bind(this.api),nt);return o[S.CURSOR_COMPATIBILITY_SYMBOL]=i,o}async allEntriesByFolder(e,t,r,n){const i=this.api.originRepoURL;return await(0,S.entriesByFolder)((()=>this.api.listFiles(e,{repoURL:i,depth:r}).then((e=>e.filter((e=>(!n||n.test(e.path))&&(0,S.filterByExtension)(e,t)))))),((e,t)=>this.api.readFile(e,t,{repoURL:i})),this.api.readFileMetadata.bind(this.api),nt)}entriesByFiles(e){const t=this.useOpenAuthoring?this.api.originRepoURL:this.api.repoURL;return(0,S.entriesByFiles)(e,((e,r)=>this.api.readFile(e,r,{repoURL:t}).catch((()=>""))),this.api.readFileMetadata.bind(this.api),nt)}getEntry(e){const t=this.api.originRepoURL;return this.api.readFile(e,null,{repoURL:t}).then((t=>({file:{path:e,id:null},data:t}))).catch((()=>({file:{path:e,id:null},data:""})))}getMedia(e=this.mediaFolder){return this.api.listFiles(e).then((e=>e.map((({id:e,name:t,size:r,path:n})=>({id:e,name:t,size:r,displayURL:{id:e,path:n},path:n})))))}async getMediaFile(e){const t=await(0,S.getMediaAsBlob)(e,null,this.api.readFile.bind(this.api)),r=(0,S.basename)(e),n=(0,S.blobToFileObj)(r,t),i=URL.createObjectURL(n);return{id:await(0,S.getBlobSHA)(t),displayURL:i,path:e,name:r,size:n.size,file:n,url:i}}getMediaDisplayURL(e){return this._mediaDisplayURLSem=this._mediaDisplayURLSem||o()(10),(0,S.getMediaDisplayURL)(e,this.api.readFile.bind(this.api),this._mediaDisplayURLSem)}persistEntry(e,t){return(0,S.runWithLock)(this.lock,(()=>this.api.persistFiles(e.dataFiles,e.assets,t)),"Failed to acquire persist entry lock")}async persistMedia(e,t){try{await this.api.persistFiles([],[e],t);const{sha:r,path:n,fileObj:i}=e,o=i?URL.createObjectURL(i):"";return{id:r,name:i.name,size:i.size,displayURL:o,path:s()(n,"/")}}catch(e){throw console.error(e),e}}deleteFiles(e,t){return this.api.deleteFiles(e,t)}async traverseCursor(e,t){const r=e.meta,n=e.data.get("files").toJS();let i;switch(t){case"first":default:i=this.getCursorAndFiles(n,1);break;case"last":i=this.getCursorAndFiles(n,r.get("pageCount"));break;case"next":i=this.getCursorAndFiles(n,r.get("page")+1);break;case"prev":i=this.getCursorAndFiles(n,r.get("page")-1)}return{entries:await(0,S.entriesByFiles)(i.files,((e,t)=>this.api.readFile(e,t,{repoURL:this.api.originRepoURL}).catch((()=>""))),this.api.readFileMetadata.bind(this.api),nt),cursor:i.cursor}}async loadMediaFile(e,t){const r=await(0,S.getMediaAsBlob)(t.path,t.id,((t,r,{parseText:n})=>this.api.readFile(t,r,{branch:e,parseText:n}))),n=(0,S.basename)(t.path),i=(0,S.blobToFileObj)(n,r);return{id:t.id,displayURL:URL.createObjectURL(i),path:t.path,name:n,size:i.size,file:i}}async unpublishedEntries(){const e=await(0,S.unpublishedEntries)((()=>this.api.listUnpublishedBranches().then((e=>e.map((e=>(0,S.contentKeyFromBranch)(e)))))));return e}async unpublishedEntry({id:e,collection:t,slug:r}){if(e)return await this.api.retrieveUnpublishedEntryData(e);if(t&&r){const e=this.api.generateContentKey(t,r);return await this.api.retrieveUnpublishedEntryData(e)}throw new Error("Missing unpublished entry id or collection and slug")}getBranch(e,t){const r=this.api.generateContentKey(e,t);return(0,S.branchFromContentKey)(r)}async unpublishedEntryDataFile(e,t,r,n){const i=this.getBranch(e,t);return await this.api.readFile(r,n,{branch:i})}async unpublishedEntryMediaFile(e,t,r,n){const i=this.getBranch(e,t);return await this.loadMediaFile(i,{path:r,id:n})}async getDeployPreview(e,t){try{const r=await this.api.getStatuses(e,t),n=(0,S.getPreviewStatus)(r,this.previewContext);if(n){const{target_url:e,state:t}=n;return{url:e,status:t}}return null}catch(e){return null}}updateUnpublishedEntryStatus(e,t,r){return(0,S.runWithLock)(this.lock,(()=>this.api.updateUnpublishedEntryStatus(e,t,r)),"Failed to acquire update entry status lock")}deleteUnpublishedEntry(e,t){return(0,S.runWithLock)(this.lock,(()=>this.api.deleteUnpublishedEntry(e,t)),"Failed to acquire delete entry lock")}publishUnpublishedEntry(e,t){return(0,S.runWithLock)(this.lock,(()=>this.api.publishUnpublishedEntry(e,t)),"Failed to acquire publish entry lock")}},API:lt,AuthenticationPage:ne}})(),c.DecapCmsBackendGithub})()));
312
312
  //# sourceMappingURL=decap-cms-backend-github.js.map