@visulima/pagination 3.0.15 → 3.0.17
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 +39 -0
- package/LICENSE.md +80 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +399 -0
- package/dist/index.d.mts +322 -2
- package/dist/index.d.ts +322 -2
- package/dist/index.mjs +1 -7
- package/package.json +120 -123
- package/dist/index.js +0 -12
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
## @visulima/pagination [3.0.17](https://github.com/visulima/visulima/compare/@visulima/pagination@3.0.16...@visulima/pagination@3.0.17) (2024-07-16)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **pagination:** switched qs to qs-esm and tsup to packem ([cd07c52](https://github.com/visulima/visulima/commit/cd07c52778ce5f03236973d75aa9631b08e92ae5))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* changed typescript version back to 5.4.5 ([55d28bb](https://github.com/visulima/visulima/commit/55d28bbdc103718d19f844034b38a0e8e5af798a))
|
|
10
|
+
* updated all dev deps ([ef143ce](https://github.com/visulima/visulima/commit/ef143ce2e15952a0910aa5c8bd78d25de9ebd7f3))
|
|
11
|
+
* updated dev dependencies ([34df456](https://github.com/visulima/visulima/commit/34df4569f2fc074823a406c44a131c8fbae2b147))
|
|
12
|
+
|
|
13
|
+
### Build System
|
|
14
|
+
|
|
15
|
+
* fixed found audit error, updated all dev package deps, updated deps in apps and examples ([4c51950](https://github.com/visulima/visulima/commit/4c519500dc5504579d35725572920658999885cb))
|
|
16
|
+
|
|
17
|
+
## @visulima/pagination [3.0.16](https://github.com/visulima/visulima/compare/@visulima/pagination@3.0.15...@visulima/pagination@3.0.16) (2024-06-06)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* allow node v22 ([890d457](https://github.com/visulima/visulima/commit/890d4570f18428e2463944813c0c638b3f142803))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Styles
|
|
26
|
+
|
|
27
|
+
* cs fixes on some package.json files ([12fc0f7](https://github.com/visulima/visulima/commit/12fc0f74e206cef77863b0b89ec41174ca9ff0bd))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Miscellaneous Chores
|
|
31
|
+
|
|
32
|
+
* changed semantic-release-npm to pnpm ([b6d100a](https://github.com/visulima/visulima/commit/b6d100a2bf3fd026577be48726a37754947f0973))
|
|
33
|
+
* **deps:** updated dev deps ([d91ac38](https://github.com/visulima/visulima/commit/d91ac389cea85a6c6bdc8de97905252a6c467abc))
|
|
34
|
+
* updated dev dependencies ([a2e0504](https://github.com/visulima/visulima/commit/a2e0504dc239049434c2482756ff15bdbaac9b54))
|
|
35
|
+
* updated dev dependencies ([abd319c](https://github.com/visulima/visulima/commit/abd319c23576aa1dc751ac874e806bddbc977d51))
|
|
36
|
+
* updated dev dependencies ([0767afe](https://github.com/visulima/visulima/commit/0767afe9be83da6698c1343724400171f952599e))
|
|
37
|
+
* updated dev dependencies ([d7791e3](https://github.com/visulima/visulima/commit/d7791e327917e438757636573b1e5549a97bba7b))
|
|
38
|
+
* updated dev dependencies ([6005345](https://github.com/visulima/visulima/commit/60053456717a3889fc77b4fb5b05d50a662475b2))
|
|
39
|
+
|
|
1
40
|
## @visulima/pagination [3.0.15](https://github.com/visulima/visulima/compare/@visulima/pagination@3.0.14...@visulima/pagination@3.0.15) (2024-04-17)
|
|
2
41
|
|
|
3
42
|
|
package/LICENSE.md
CHANGED
|
@@ -19,3 +19,83 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
<!-- DEPENDENCIES -->
|
|
24
|
+
|
|
25
|
+
# Licenses of bundled dependencies
|
|
26
|
+
The published @visulima/pagination artifact additionally contains code with the following licenses:
|
|
27
|
+
BSD-3-Clause
|
|
28
|
+
|
|
29
|
+
# Bundled dependencies:
|
|
30
|
+
## qs-esm
|
|
31
|
+
License: BSD-3-Clause
|
|
32
|
+
By: Jordan Harband
|
|
33
|
+
Repository: https://github.com/payloadcms/qs-esm.git
|
|
34
|
+
|
|
35
|
+
> BSD 3-Clause License
|
|
36
|
+
>
|
|
37
|
+
> Copyright (c) 2014, Nathan LaFreniere and other [contributors](https://github.com/ljharb/qs/graphs/contributors)
|
|
38
|
+
> All rights reserved.
|
|
39
|
+
>
|
|
40
|
+
> Redistribution and use in source and binary forms, with or without
|
|
41
|
+
> modification, are permitted provided that the following conditions are met:
|
|
42
|
+
>
|
|
43
|
+
> 1. Redistributions of source code must retain the above copyright notice, this
|
|
44
|
+
> list of conditions and the following disclaimer.
|
|
45
|
+
>
|
|
46
|
+
> 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
47
|
+
> this list of conditions and the following disclaimer in the documentation
|
|
48
|
+
> and/or other materials provided with the distribution.
|
|
49
|
+
>
|
|
50
|
+
> 3. Neither the name of the copyright holder nor the names of its
|
|
51
|
+
> contributors may be used to endorse or promote products derived from
|
|
52
|
+
> this software without specific prior written permission.
|
|
53
|
+
>
|
|
54
|
+
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
55
|
+
> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
56
|
+
> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
57
|
+
> DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
58
|
+
> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
59
|
+
> DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
60
|
+
> SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
61
|
+
> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
62
|
+
> OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
63
|
+
> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
64
|
+
|
|
65
|
+
<!-- DEPENDENCIES -->
|
|
66
|
+
|
|
67
|
+
<!-- TYPE_DEPENDENCIES -->
|
|
68
|
+
|
|
69
|
+
# Licenses of bundled types
|
|
70
|
+
The published @visulima/pagination artifact additionally contains code with the following licenses:
|
|
71
|
+
MIT
|
|
72
|
+
|
|
73
|
+
# Bundled types:
|
|
74
|
+
## openapi-types
|
|
75
|
+
License: MIT
|
|
76
|
+
By: Joseph Spencer
|
|
77
|
+
Repository: https://github.com/kogosoftwarellc/open-api/tree/master/packages/openapi-types
|
|
78
|
+
|
|
79
|
+
> The MIT License (MIT)
|
|
80
|
+
>
|
|
81
|
+
> Copyright (c) 2018 Kogo Softare LLC
|
|
82
|
+
>
|
|
83
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
84
|
+
> of this software and associated documentation files (the "Software"), to deal
|
|
85
|
+
> in the Software without restriction, including without limitation the rights
|
|
86
|
+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
87
|
+
> copies of the Software, and to permit persons to whom the Software is
|
|
88
|
+
> furnished to do so, subject to the following conditions:
|
|
89
|
+
>
|
|
90
|
+
> The above copyright notice and this permission notice shall be included in
|
|
91
|
+
> all copies or substantial portions of the Software.
|
|
92
|
+
>
|
|
93
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
94
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
95
|
+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
96
|
+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
97
|
+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
98
|
+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
99
|
+
> THE SOFTWARE.
|
|
100
|
+
|
|
101
|
+
<!-- TYPE_DEPENDENCIES -->
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var W=Object.defineProperty;var l=(n,e)=>W(n,"name",{value:e,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=String.prototype.replace,J=/%20/g,L={RFC1738:"RFC1738",RFC3986:"RFC3986"},_={RFC1738:l(function(n){return G.call(n,J,"+")},"RFC1738"),RFC3986:l(function(n){return String(n)},"RFC3986")},X=L.RFC1738,Y=L.RFC3986,Z=Array.isArray,h=function(){const n=[];for(let e=0;e<256;++e)n.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return n}(),O=1024,V=l(function(e,i,t,s,m){if(e.length===0)return e;let g=e;if(typeof e=="symbol"?g=Symbol.prototype.toString.call(e):typeof e!="string"&&(g=String(e)),t==="iso-8859-1")return escape(g).replace(/%u[0-9a-f]{4}/gi,function(p){return"%26%23"+parseInt(p.slice(2),16)+"%3B"});let d="";for(let p=0;p<g.length;p+=O){const c=g.length>=O?g.slice(p,p+O):g,o=[];for(let f=0;f<c.length;++f){let r=c.charCodeAt(f);if(r===45||r===46||r===95||r===126||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||m===X&&(r===40||r===41)){o[o.length]=c.charAt(f);continue}if(r<128){o[o.length]=h[r];continue}if(r<2048){o[o.length]=h[192|r>>6]+h[128|r&63];continue}if(r<55296||r>=57344){o[o.length]=h[224|r>>12]+h[128|r>>6&63]+h[128|r&63];continue}f+=1,r=65536+((r&1023)<<10|c.charCodeAt(f)&1023),o[o.length]=h[240|r>>18]+h[128|r>>12&63]+h[128|r>>6&63]+h[128|r&63]}d+=o.join("")}return d},"encode"),ee=l(function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},"isBuffer"),q=l(function(e,i){if(Z(e)){const t=[];for(let s=0;s<e.length;s+=1)t.push(i(e[s]));return t}return i(e)},"maybeMap"),te={brackets:l(function(e){return e+"[]"},"brackets"),comma:"comma",indices:l(function(e,i){return e+"["+i+"]"},"indices"),repeat:l(function(e){return e},"repeat")},y=Array.isArray,ne=Array.prototype.push,$=l(function(n,e){ne.apply(n,y(e)?e:[e])},"pushToArray"),re=Date.prototype.toISOString,I=Y,w={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:V,encodeValuesOnly:!1,format:I,formatter:_[I],indices:!1,serializeDate:l(function(e){return re.call(e)},"serializeDate"),skipNulls:!1,strictNullHandling:!1},ie=l(function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},"isNonNullishPrimitive"),T={},z=l(function(e,i,t,s,m,g,d,p,c,o,f,r,P,j,x,S,v,C){let a=e,R=C,k=0,A=!1;for(;(R=R.get(T))!==void 0&&!A;){const u=R.get(e);if(k+=1,typeof u<"u"){if(u===k)throw new RangeError("Cyclic object value");A=!0}typeof R.get(T)>"u"&&(k=0)}if(typeof o=="function"?a=o(i,a):a instanceof Date?a=P(a):t==="comma"&&y(a)&&(a=q(a,function(u){return u instanceof Date?P(u):u})),a===null){if(g)return c&&!S?c(i,w.encoder,v,"key",j):i;a=""}if(ie(a)||ee(a)){if(c){const u=S?i:c(i,w.encoder,v,"key",j);return[x(u)+"="+x(c(a,w.encoder,v,"value",j))]}return[x(i)+"="+x(String(a))]}const F=[];if(typeof a>"u")return F;let U;if(t==="comma"&&y(a))S&&c&&(a=q(a,c)),U=[{value:a.length>0?a.join(",")||null:void 0}];else if(y(o))U=o;else{const u=Object.keys(a);U=f?u.sort(f):u}const E=p?i.replace(/\./g,"%2E"):i,N=s&&y(a)&&a.length===1?E+"[]":E;if(m&&y(a)&&a.length===0)return N+"[]";for(let u=0;u<U.length;++u){const b=U[u],B=typeof b=="object"&&typeof b.value<"u"?b.value:a[b];if(d&&B===null)continue;const M=r&&p?b.replace(/\./g,"%2E"):b,Q=y(a)?typeof t=="function"?t(N,M):N:N+(r?"."+M:"["+M+"]");C.set(e,k);const D=new WeakMap;D.set(T,C),$(F,z(B,Q,t,s,m,g,d,p,t==="comma"&&S&&y(a)?null:c,o,f,r,P,j,x,S,v,D))}return F},"stringify"),ae=l(function(e){return w},"normalizeStringifyOptions");function se(n,e){let i=n;const t=ae();let s,m;typeof t.filter=="function"?(m=t.filter,i=m("",i)):y(t.filter)&&(m=t.filter,s=m);const g=[];if(typeof i!="object"||i===null)return"";const d=te[t.arrayFormat],p=d==="comma"&&t.commaRoundTrip;s||(s=Object.keys(i)),t.sort&&s.sort(t.sort);const c=new WeakMap;for(let r=0;r<s.length;++r){const P=s[r];t.skipNulls&&i[P]===null||$(g,z(i[P],P,d,p,t.allowEmptyArrays,t.strictNullHandling,t.skipNulls,t.encodeDotInKeys,t.encode?t.encoder:null,t.filter,t.sort,t.allowDots,t.serializeDate,t.format,t.formatter,t.encodeValuesOnly,t.charset,c))}const o=g.join(t.delimiter);let f=t.addQueryPrefix===!0?"?":"";return t.charsetSentinel&&(t.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),o.length>0?f+o:""}l(se,"stringify");var oe=Object.defineProperty,le=l((n,e)=>oe(n,"name",{value:e,configurable:!0}),"n");class K extends Array{static{l(this,"g")}constructor(e,i,t,...s){super(...s),this.totalNumber=e,this.perPage=i,this.currentPage=t,this.totalNumber=Number(e),this.rows=s,this.isEmpty=this.rows.length===0}static{le(this,"Paginator")}firstPage=1;isEmpty;qs={};rows;url="/";all(){return this.rows}baseUrl(e){return this.url=e,this}getMeta(){return{firstPage:this.firstPage,firstPageUrl:this.getUrl(1),lastPage:this.lastPage,lastPageUrl:this.getUrl(this.lastPage),nextPageUrl:this.getNextPageUrl(),page:this.currentPage,perPage:this.perPage,previousPageUrl:this.getPreviousPageUrl(),total:this.total}}getNextPageUrl(){return this.hasMorePages?this.getUrl(this.currentPage+1):null}getPreviousPageUrl(){return this.currentPage>1?this.getUrl(this.currentPage-1):null}getUrl(e){const i=se({...this.qs,page:e<1?1:e});return`${this.url}?${i}`}getUrlsForRange(e,i){const t=[];for(let s=e;s<=i;s++)t.push({isActive:s===this.currentPage,page:s,url:this.getUrl(s)});return t}queryString(e){return this.qs=e,this}toJSON(){return{data:this.all(),meta:this.getMeta()}}get hasMorePages(){return this.lastPage>this.currentPage}get hasPages(){return this.lastPage!==1}get hasTotal(){return this.total>0}get lastPage(){return Math.max(Math.ceil(this.total/this.perPage),1)}get total(){return Number(this.totalNumber)}}var ce=Object.defineProperty,H=l((n,e)=>ce(n,"name",{value:e,configurable:!0}),"r");const ue=H((n="PaginationData")=>({[n]:{properties:{firstPage:{description:"Returns the number for the first page. It is always 1",minimum:0,type:"integer"},firstPageUrl:{description:"The URL for the first page",type:"string"},lastPage:{description:"Returns the value for the last page by taking the total of rows into account",minimum:0,type:"integer"},lastPageUrl:{description:"The URL for the last page",type:"string"},nextPageUrl:{description:"The URL for the next page",type:"string"},page:{description:"Current page number",minimum:1,type:"integer"},perPage:{description:"Returns the value for the limit passed to the paginate method",minimum:0,type:"integer"},previousPageUrl:{description:"The URL for the previous page",type:"string"},total:{description:"Holds the value for the total number of rows in the database",minimum:0,type:"integer"}},type:"object",xml:{name:n}}}),"createPaginationMetaSchemaObject"),fe=H((n,e,i="#/components/schemas/PaginationData")=>({[n]:{properties:{data:{items:e,type:"array",xml:{name:"data",wrapped:!0}},meta:{$ref:i}},type:"object",xml:{name:n}}}),"createPaginationSchemaObject");var ge=Object.defineProperty,pe=l((n,e)=>ge(n,"name",{value:e,configurable:!0}),"e");const he=pe((n,e,i,t)=>new K(i,Number(e),Number(n),...t),"paginate");exports.Paginator=K;exports.createPaginationMetaSchemaObject=ue;exports.createPaginationSchemaObject=fe;exports.paginate=he;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
interface PaginationMeta {
|
|
2
|
+
firstPage: number;
|
|
3
|
+
firstPageUrl: string | null;
|
|
4
|
+
lastPage: number;
|
|
5
|
+
lastPageUrl: string | null;
|
|
6
|
+
nextPageUrl: string | null;
|
|
7
|
+
page: number;
|
|
8
|
+
perPage: number;
|
|
9
|
+
previousPageUrl: string | null;
|
|
10
|
+
total: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface PaginationResult<Result> {
|
|
14
|
+
data: Result[];
|
|
15
|
+
meta: PaginationMeta;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Paginator$1<Result> extends Array<Result> {
|
|
19
|
+
all: () => Result[];
|
|
20
|
+
|
|
21
|
+
baseUrl: (url: string) => this;
|
|
22
|
+
readonly currentPage: number;
|
|
23
|
+
readonly firstPage: number;
|
|
24
|
+
getMeta: () => PaginationMeta;
|
|
25
|
+
getNextPageUrl: () => string | null;
|
|
26
|
+
getPreviousPageUrl: () => string | null;
|
|
27
|
+
getUrl: (page: number) => string;
|
|
28
|
+
getUrlsForRange: (start: number, end: number) => { isActive: boolean; page: number; url: string }[];
|
|
29
|
+
readonly hasMorePages: boolean;
|
|
30
|
+
|
|
31
|
+
readonly hasPages: boolean;
|
|
32
|
+
readonly hasTotal: boolean;
|
|
33
|
+
readonly isEmpty: boolean;
|
|
34
|
+
readonly lastPage: number;
|
|
35
|
+
readonly perPage: number;
|
|
36
|
+
queryString: (values: Record<string, unknown>) => this;
|
|
37
|
+
toJSON: () => PaginationResult<Result>;
|
|
38
|
+
readonly total: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type UrlsForRange = {
|
|
42
|
+
isActive: boolean;
|
|
43
|
+
page: number;
|
|
44
|
+
url: string;
|
|
45
|
+
}[];
|
|
46
|
+
declare class Paginator<T = unknown> extends Array<T> implements Paginator$1<T> {
|
|
47
|
+
private readonly totalNumber;
|
|
48
|
+
readonly perPage: number;
|
|
49
|
+
currentPage: number;
|
|
50
|
+
readonly firstPage: number;
|
|
51
|
+
readonly isEmpty: boolean;
|
|
52
|
+
private qs;
|
|
53
|
+
private readonly rows;
|
|
54
|
+
private url;
|
|
55
|
+
constructor(totalNumber: number, perPage: number, currentPage: number, ...rows: T[]);
|
|
56
|
+
all(): T[];
|
|
57
|
+
baseUrl(url: string): this;
|
|
58
|
+
getMeta(): PaginationMeta;
|
|
59
|
+
getNextPageUrl(): string | null;
|
|
60
|
+
getPreviousPageUrl(): string | null;
|
|
61
|
+
getUrl(page: number): string;
|
|
62
|
+
getUrlsForRange(start: number, end: number): UrlsForRange;
|
|
63
|
+
queryString(values: Record<string, unknown>): this;
|
|
64
|
+
toJSON(): PaginationResult<T>;
|
|
65
|
+
get hasMorePages(): boolean;
|
|
66
|
+
get hasPages(): boolean;
|
|
67
|
+
get hasTotal(): boolean;
|
|
68
|
+
get lastPage(): number;
|
|
69
|
+
get total(): number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare namespace OpenAPIV3 {
|
|
73
|
+
interface Document<T extends {} = {}> {
|
|
74
|
+
openapi: string;
|
|
75
|
+
info: InfoObject;
|
|
76
|
+
servers?: ServerObject[];
|
|
77
|
+
paths: PathsObject<T>;
|
|
78
|
+
components?: ComponentsObject;
|
|
79
|
+
security?: SecurityRequirementObject[];
|
|
80
|
+
tags?: TagObject[];
|
|
81
|
+
externalDocs?: ExternalDocumentationObject;
|
|
82
|
+
'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
|
|
83
|
+
'x-express-openapi-validation-strict'?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface InfoObject {
|
|
86
|
+
title: string;
|
|
87
|
+
description?: string;
|
|
88
|
+
termsOfService?: string;
|
|
89
|
+
contact?: ContactObject;
|
|
90
|
+
license?: LicenseObject;
|
|
91
|
+
version: string;
|
|
92
|
+
}
|
|
93
|
+
interface ContactObject {
|
|
94
|
+
name?: string;
|
|
95
|
+
url?: string;
|
|
96
|
+
email?: string;
|
|
97
|
+
}
|
|
98
|
+
interface LicenseObject {
|
|
99
|
+
name: string;
|
|
100
|
+
url?: string;
|
|
101
|
+
}
|
|
102
|
+
interface ServerObject {
|
|
103
|
+
url: string;
|
|
104
|
+
description?: string;
|
|
105
|
+
variables?: {
|
|
106
|
+
[variable: string]: ServerVariableObject;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
interface ServerVariableObject {
|
|
110
|
+
enum?: string[];
|
|
111
|
+
default: string;
|
|
112
|
+
description?: string;
|
|
113
|
+
}
|
|
114
|
+
interface PathsObject<T extends {} = {}, P extends {} = {}> {
|
|
115
|
+
[pattern: string]: (PathItemObject<T> & P) | undefined;
|
|
116
|
+
}
|
|
117
|
+
enum HttpMethods {
|
|
118
|
+
GET = "get",
|
|
119
|
+
PUT = "put",
|
|
120
|
+
POST = "post",
|
|
121
|
+
DELETE = "delete",
|
|
122
|
+
OPTIONS = "options",
|
|
123
|
+
HEAD = "head",
|
|
124
|
+
PATCH = "patch",
|
|
125
|
+
TRACE = "trace"
|
|
126
|
+
}
|
|
127
|
+
type PathItemObject<T extends {} = {}> = {
|
|
128
|
+
$ref?: string;
|
|
129
|
+
summary?: string;
|
|
130
|
+
description?: string;
|
|
131
|
+
servers?: ServerObject[];
|
|
132
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
|
133
|
+
} & {
|
|
134
|
+
[method in HttpMethods]?: OperationObject<T>;
|
|
135
|
+
};
|
|
136
|
+
type OperationObject<T extends {} = {}> = {
|
|
137
|
+
tags?: string[];
|
|
138
|
+
summary?: string;
|
|
139
|
+
description?: string;
|
|
140
|
+
externalDocs?: ExternalDocumentationObject;
|
|
141
|
+
operationId?: string;
|
|
142
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
|
143
|
+
requestBody?: ReferenceObject | RequestBodyObject;
|
|
144
|
+
responses: ResponsesObject;
|
|
145
|
+
callbacks?: {
|
|
146
|
+
[callback: string]: ReferenceObject | CallbackObject;
|
|
147
|
+
};
|
|
148
|
+
deprecated?: boolean;
|
|
149
|
+
security?: SecurityRequirementObject[];
|
|
150
|
+
servers?: ServerObject[];
|
|
151
|
+
} & T;
|
|
152
|
+
interface ExternalDocumentationObject {
|
|
153
|
+
description?: string;
|
|
154
|
+
url: string;
|
|
155
|
+
}
|
|
156
|
+
interface ParameterObject extends ParameterBaseObject {
|
|
157
|
+
name: string;
|
|
158
|
+
in: string;
|
|
159
|
+
}
|
|
160
|
+
interface HeaderObject extends ParameterBaseObject {
|
|
161
|
+
}
|
|
162
|
+
interface ParameterBaseObject {
|
|
163
|
+
description?: string;
|
|
164
|
+
required?: boolean;
|
|
165
|
+
deprecated?: boolean;
|
|
166
|
+
allowEmptyValue?: boolean;
|
|
167
|
+
style?: string;
|
|
168
|
+
explode?: boolean;
|
|
169
|
+
allowReserved?: boolean;
|
|
170
|
+
schema?: ReferenceObject | SchemaObject;
|
|
171
|
+
example?: any;
|
|
172
|
+
examples?: {
|
|
173
|
+
[media: string]: ReferenceObject | ExampleObject;
|
|
174
|
+
};
|
|
175
|
+
content?: {
|
|
176
|
+
[media: string]: MediaTypeObject;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
type NonArraySchemaObjectType = 'boolean' | 'object' | 'number' | 'string' | 'integer';
|
|
180
|
+
type ArraySchemaObjectType = 'array';
|
|
181
|
+
type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
|
|
182
|
+
interface ArraySchemaObject extends BaseSchemaObject {
|
|
183
|
+
type: ArraySchemaObjectType;
|
|
184
|
+
items: ReferenceObject | SchemaObject;
|
|
185
|
+
}
|
|
186
|
+
interface NonArraySchemaObject extends BaseSchemaObject {
|
|
187
|
+
type?: NonArraySchemaObjectType;
|
|
188
|
+
}
|
|
189
|
+
interface BaseSchemaObject {
|
|
190
|
+
title?: string;
|
|
191
|
+
description?: string;
|
|
192
|
+
format?: string;
|
|
193
|
+
default?: any;
|
|
194
|
+
multipleOf?: number;
|
|
195
|
+
maximum?: number;
|
|
196
|
+
exclusiveMaximum?: boolean;
|
|
197
|
+
minimum?: number;
|
|
198
|
+
exclusiveMinimum?: boolean;
|
|
199
|
+
maxLength?: number;
|
|
200
|
+
minLength?: number;
|
|
201
|
+
pattern?: string;
|
|
202
|
+
additionalProperties?: boolean | ReferenceObject | SchemaObject;
|
|
203
|
+
maxItems?: number;
|
|
204
|
+
minItems?: number;
|
|
205
|
+
uniqueItems?: boolean;
|
|
206
|
+
maxProperties?: number;
|
|
207
|
+
minProperties?: number;
|
|
208
|
+
required?: string[];
|
|
209
|
+
enum?: any[];
|
|
210
|
+
properties?: {
|
|
211
|
+
[name: string]: ReferenceObject | SchemaObject;
|
|
212
|
+
};
|
|
213
|
+
allOf?: (ReferenceObject | SchemaObject)[];
|
|
214
|
+
oneOf?: (ReferenceObject | SchemaObject)[];
|
|
215
|
+
anyOf?: (ReferenceObject | SchemaObject)[];
|
|
216
|
+
not?: ReferenceObject | SchemaObject;
|
|
217
|
+
nullable?: boolean;
|
|
218
|
+
discriminator?: DiscriminatorObject;
|
|
219
|
+
readOnly?: boolean;
|
|
220
|
+
writeOnly?: boolean;
|
|
221
|
+
xml?: XMLObject;
|
|
222
|
+
externalDocs?: ExternalDocumentationObject;
|
|
223
|
+
example?: any;
|
|
224
|
+
deprecated?: boolean;
|
|
225
|
+
}
|
|
226
|
+
interface DiscriminatorObject {
|
|
227
|
+
propertyName: string;
|
|
228
|
+
mapping?: {
|
|
229
|
+
[value: string]: string;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
interface XMLObject {
|
|
233
|
+
name?: string;
|
|
234
|
+
namespace?: string;
|
|
235
|
+
prefix?: string;
|
|
236
|
+
attribute?: boolean;
|
|
237
|
+
wrapped?: boolean;
|
|
238
|
+
}
|
|
239
|
+
interface ReferenceObject {
|
|
240
|
+
$ref: string;
|
|
241
|
+
}
|
|
242
|
+
interface ExampleObject {
|
|
243
|
+
summary?: string;
|
|
244
|
+
description?: string;
|
|
245
|
+
value?: any;
|
|
246
|
+
externalValue?: string;
|
|
247
|
+
}
|
|
248
|
+
interface MediaTypeObject {
|
|
249
|
+
schema?: ReferenceObject | SchemaObject;
|
|
250
|
+
example?: any;
|
|
251
|
+
examples?: {
|
|
252
|
+
[media: string]: ReferenceObject | ExampleObject;
|
|
253
|
+
};
|
|
254
|
+
encoding?: {
|
|
255
|
+
[media: string]: EncodingObject;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
interface EncodingObject {
|
|
259
|
+
contentType?: string;
|
|
260
|
+
headers?: {
|
|
261
|
+
[header: string]: ReferenceObject | HeaderObject;
|
|
262
|
+
};
|
|
263
|
+
style?: string;
|
|
264
|
+
explode?: boolean;
|
|
265
|
+
allowReserved?: boolean;
|
|
266
|
+
}
|
|
267
|
+
interface RequestBodyObject {
|
|
268
|
+
description?: string;
|
|
269
|
+
content: {
|
|
270
|
+
[media: string]: MediaTypeObject;
|
|
271
|
+
};
|
|
272
|
+
required?: boolean;
|
|
273
|
+
}
|
|
274
|
+
interface ResponsesObject {
|
|
275
|
+
[code: string]: ReferenceObject | ResponseObject;
|
|
276
|
+
}
|
|
277
|
+
interface ResponseObject {
|
|
278
|
+
description: string;
|
|
279
|
+
headers?: {
|
|
280
|
+
[header: string]: ReferenceObject | HeaderObject;
|
|
281
|
+
};
|
|
282
|
+
content?: {
|
|
283
|
+
[media: string]: MediaTypeObject;
|
|
284
|
+
};
|
|
285
|
+
links?: {
|
|
286
|
+
[link: string]: ReferenceObject | LinkObject;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
interface LinkObject {
|
|
290
|
+
operationRef?: string;
|
|
291
|
+
operationId?: string;
|
|
292
|
+
parameters?: {
|
|
293
|
+
[parameter: string]: any;
|
|
294
|
+
};
|
|
295
|
+
requestBody?: any;
|
|
296
|
+
description?: string;
|
|
297
|
+
server?: ServerObject;
|
|
298
|
+
}
|
|
299
|
+
interface CallbackObject {
|
|
300
|
+
[url: string]: PathItemObject;
|
|
301
|
+
}
|
|
302
|
+
interface SecurityRequirementObject {
|
|
303
|
+
[name: string]: string[];
|
|
304
|
+
}
|
|
305
|
+
interface ComponentsObject {
|
|
306
|
+
schemas?: {
|
|
307
|
+
[key: string]: ReferenceObject | SchemaObject;
|
|
308
|
+
};
|
|
309
|
+
responses?: {
|
|
310
|
+
[key: string]: ReferenceObject | ResponseObject;
|
|
311
|
+
};
|
|
312
|
+
parameters?: {
|
|
313
|
+
[key: string]: ReferenceObject | ParameterObject;
|
|
314
|
+
};
|
|
315
|
+
examples?: {
|
|
316
|
+
[key: string]: ReferenceObject | ExampleObject;
|
|
317
|
+
};
|
|
318
|
+
requestBodies?: {
|
|
319
|
+
[key: string]: ReferenceObject | RequestBodyObject;
|
|
320
|
+
};
|
|
321
|
+
headers?: {
|
|
322
|
+
[key: string]: ReferenceObject | HeaderObject;
|
|
323
|
+
};
|
|
324
|
+
securitySchemes?: {
|
|
325
|
+
[key: string]: ReferenceObject | SecuritySchemeObject;
|
|
326
|
+
};
|
|
327
|
+
links?: {
|
|
328
|
+
[key: string]: ReferenceObject | LinkObject;
|
|
329
|
+
};
|
|
330
|
+
callbacks?: {
|
|
331
|
+
[key: string]: ReferenceObject | CallbackObject;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
type SecuritySchemeObject = HttpSecurityScheme | ApiKeySecurityScheme | OAuth2SecurityScheme | OpenIdSecurityScheme;
|
|
335
|
+
interface HttpSecurityScheme {
|
|
336
|
+
type: 'http';
|
|
337
|
+
description?: string;
|
|
338
|
+
scheme: string;
|
|
339
|
+
bearerFormat?: string;
|
|
340
|
+
}
|
|
341
|
+
interface ApiKeySecurityScheme {
|
|
342
|
+
type: 'apiKey';
|
|
343
|
+
description?: string;
|
|
344
|
+
name: string;
|
|
345
|
+
in: string;
|
|
346
|
+
}
|
|
347
|
+
interface OAuth2SecurityScheme {
|
|
348
|
+
type: 'oauth2';
|
|
349
|
+
description?: string;
|
|
350
|
+
flows: {
|
|
351
|
+
implicit?: {
|
|
352
|
+
authorizationUrl: string;
|
|
353
|
+
refreshUrl?: string;
|
|
354
|
+
scopes: {
|
|
355
|
+
[scope: string]: string;
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
password?: {
|
|
359
|
+
tokenUrl: string;
|
|
360
|
+
refreshUrl?: string;
|
|
361
|
+
scopes: {
|
|
362
|
+
[scope: string]: string;
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
clientCredentials?: {
|
|
366
|
+
tokenUrl: string;
|
|
367
|
+
refreshUrl?: string;
|
|
368
|
+
scopes: {
|
|
369
|
+
[scope: string]: string;
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
authorizationCode?: {
|
|
373
|
+
authorizationUrl: string;
|
|
374
|
+
tokenUrl: string;
|
|
375
|
+
refreshUrl?: string;
|
|
376
|
+
scopes: {
|
|
377
|
+
[scope: string]: string;
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
interface OpenIdSecurityScheme {
|
|
383
|
+
type: 'openIdConnect';
|
|
384
|
+
description?: string;
|
|
385
|
+
openIdConnectUrl: string;
|
|
386
|
+
}
|
|
387
|
+
interface TagObject {
|
|
388
|
+
name: string;
|
|
389
|
+
description?: string;
|
|
390
|
+
externalDocs?: ExternalDocumentationObject;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
declare const createPaginationMetaSchemaObject: (name?: string) => Record<string, OpenAPIV3.SchemaObject>;
|
|
395
|
+
declare const createPaginationSchemaObject: (name: string, items: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject, metaReference?: string) => Record<string, OpenAPIV3.SchemaObject>;
|
|
396
|
+
|
|
397
|
+
declare const paginate: <Result>(page: number, perPage: number, total: number, rows: Result[]) => Paginator$1<Result>;
|
|
398
|
+
|
|
399
|
+
export { type PaginationMeta, type PaginationResult, Paginator, type Paginator$1 as PaginatorInterface, createPaginationMetaSchemaObject, createPaginationSchemaObject, paginate };
|