@gitbeaker/requester-utils 35.8.0 → 36.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -15
- package/dist/index.d.ts +74 -0
- package/dist/index.js +103 -175
- package/dist/index.mjs +111 -0
- package/package.json +44 -36
- package/LICENSE.md +0 -22
- package/dist/index.es.js +0 -181
- package/dist/index.es.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types/BaseResource.d.ts +0 -27
- package/dist/types/RequesterUtils.d.ts +0 -44
- package/dist/types/index.d.ts +0 -2
package/README.md
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<br>
|
|
3
|
-
<img alt="gitbeaker" src="
|
|
3
|
+
<img alt="gitbeaker" src="../../.github/ASSETS/header.svg">
|
|
4
4
|
</div>
|
|
5
5
|
<br>
|
|
6
6
|
<p align="center">
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
<a href="https://gitlab.com/jdalrymple/gitbeaker/-/commits/main"><img alt="pipeline status" src="https://gitlab.com/jdalrymple/gitbeaker/badges/main/pipeline.svg" /></a>
|
|
8
|
+
<a href="https://gitlab.com/jdalrymple/gitbeaker/-/commits/main"><img alt="coverage report" src="https://gitlab.com/jdalrymple/gitbeaker/badges/main/coverage.svg" /></a>
|
|
9
|
+
|
|
10
10
|
<a href="https://codeclimate.com/github/jdalrymple/gitbeaker">
|
|
11
11
|
<img src="https://codeclimate.com/github/jdalrymple/gitbeaker/badges/gpa.svg" alt="Code Climate maintainability">
|
|
12
12
|
</a>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<a href="https://david-dm.org/jdalrymple/gitbeaker?path=packages/requester-utils">
|
|
17
|
-
<img src="https://status.david-dm.org/gh/jdalrymple/gitbeaker.svg?path=packages/requester-utils" alt="Dependency Status" />
|
|
13
|
+
|
|
14
|
+
<a href="https://david-dm.org/jdalrymple/gitbeaker">
|
|
15
|
+
<img src="https://status.david-dm.org/gh/jdalrymple/gitbeaker.svg" alt="Dependency Status" />
|
|
18
16
|
</a>
|
|
19
|
-
<a href="https://david-dm.org/jdalrymple/gitbeaker?
|
|
20
|
-
<img src="https://status.david-dm.org/gh/jdalrymple/gitbeaker.svg?
|
|
17
|
+
<a href="https://david-dm.org/jdalrymple/gitbeaker?type=dev">
|
|
18
|
+
<img src="https://status.david-dm.org/gh/jdalrymple/gitbeaker.svg?type=dev" alt="Dev Dependency Status" />
|
|
21
19
|
</a>
|
|
22
20
|
<a href="https://github.com/intuit/auto">
|
|
23
21
|
<img src="https://img.shields.io/badge/release-auto.svg?colorA=888888&colorB=9B065A&label=auto" alt="Auto">
|
|
@@ -25,15 +23,174 @@
|
|
|
25
23
|
<a href="#contributors-">
|
|
26
24
|
<img src="https://img.shields.io/badge/all_contributors-orange.svg?style=round" alt="All Contributors" />
|
|
27
25
|
</a>
|
|
28
|
-
<img src="https://img.shields.io/badge/code%20style-prettier-ff69b4.svg" alt="Prettier">
|
|
26
|
+
<img src="https://img.shields.io/badge/code%20style-prettier-ff69b4.svg" alt="Prettier">
|
|
29
27
|
<a href="LICENSE.md">
|
|
30
28
|
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Licence: MIT">
|
|
31
29
|
</a>
|
|
32
30
|
<a href="https://packagephobia.now.sh/result?p=@gitbeaker/requester-utils">
|
|
33
|
-
<img src="https://packagephobia.now.sh/badge?p=@gitbeaker/requester-utils" alt="Install Size:
|
|
31
|
+
<img src="https://packagephobia.now.sh/badge?p=@gitbeaker/requester-utils" alt="Install Size: Core">
|
|
34
32
|
</a>
|
|
35
33
|
</p>
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
> Utility for creating custom wrappers around the [@gitbeaker/core](https://www.npmjs.com/package/@gitbeaker/core) [GitLab](https://gitlab.com/gitlab-org/gitlab/) SDK.
|
|
36
|
+
|
|
37
|
+
## Table of Contents
|
|
38
|
+
|
|
39
|
+
- [Usage](#usage)
|
|
40
|
+
- [Contributors](#contributors)
|
|
41
|
+
- [Changelog](./CHANGELOG.md)
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
<table>
|
|
46
|
+
<tbody valign=top align=left>
|
|
47
|
+
<tr><th>
|
|
48
|
+
Browsers
|
|
49
|
+
</th><td width=100%>
|
|
50
|
+
Load <code>@gitbeaker/requester-utils</code> directly from <a href="https://cdn.skypack.dev">cdn.skypack.dev</a>
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<script type="module">
|
|
54
|
+
import { RequesterUtils, BaseResource } from 'https://cdn.skypack.dev/@gitbeaker/requester-utils';
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
</td></tr>
|
|
59
|
+
<tr><th>
|
|
60
|
+
Deno
|
|
61
|
+
</th><td width=100%>
|
|
62
|
+
Load <code>@gitbeaker/requester-utils</code> directly from <a href="https://cdn.skypack.dev">cdn.skypack.dev</a>
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import {
|
|
66
|
+
RequesterUtils,
|
|
67
|
+
BaseResource,
|
|
68
|
+
} from 'https://cdn.skypack.dev/@gitbeaker/requester-utils?dts';
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
</td></tr>
|
|
72
|
+
<tr><th>
|
|
73
|
+
Node 18+
|
|
74
|
+
</th><td>
|
|
75
|
+
|
|
76
|
+
Install with <code>npm install @gitbeaker/requester-utils</code>, or <code>yarn add @gitbeaker/requester-utils</code>
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
import { RequesterUtils, BaseResource } from '@gitbeaker/requester-utils';
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
</td></tr>
|
|
83
|
+
</tbody>
|
|
84
|
+
</table>
|
|
85
|
+
|
|
86
|
+
## Contributors
|
|
87
|
+
|
|
88
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
89
|
+
<!-- prettier-ignore-start -->
|
|
90
|
+
<!-- markdownlint-disable -->
|
|
91
|
+
<p>
|
|
92
|
+
<tr>
|
|
93
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/jdalrymple"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/3743662?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Justin Dalrymple"/></td>
|
|
94
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/dylandesrosier"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/13701258?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Dylan DesRosier"/></td>
|
|
95
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/mikew"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/4729?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Mike Wyatt"/></td>
|
|
96
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/coryzibell"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/7986014?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Cory Zibeill"/></td>
|
|
97
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/shadygrove"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/5209850?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Martin Bour"/></td>
|
|
98
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/akira345"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/655764?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="akira345"/></td>
|
|
99
|
+
<td align="center" valign="top" width="3.7%"><a href="https://birukov.me"><img src="https://images.weserv.nl/?url=https://avatars2.githubusercontent.com/u/1861546?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Pavel Birukov "/></td>
|
|
100
|
+
<td align="center" valign="top" width="3.7%"><a href="http://jetersen.dev"><img src="https://images.weserv.nl/?url=https://avatars2.githubusercontent.com/u/1661688?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Joseph Petersen"/></td>
|
|
101
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/Musinux"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/563373?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Louis Cherel"/></td>
|
|
102
|
+
<td align="center" valign="top" width="3.7%"><a href="http://www.arsdehnel.net"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/1697162?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Adam Dehnel"/></td>
|
|
103
|
+
<td align="center" valign="top" width="3.7%"><a href="http://www.haus.gg/"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/226640?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Ev Haus"/></td>
|
|
104
|
+
<td align="center" valign="top" width="3.7%"><a href="http://iGLOO.be"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/900947?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Loïc Mahieu"/></td>
|
|
105
|
+
<td align="center" valign="top" width="3.7%"><a href="http://www.giuseppeangri.com"><img src="https://images.weserv.nl/?url=https://avatars2.githubusercontent.com/u/9075163?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Giuseppe Angri"/></td>
|
|
106
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/jennparise"><img src="https://images.weserv.nl/?url=https://avatars1.githubusercontent.com/u/4134086?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="jennparise"/></td>
|
|
107
|
+
<td align="center" valign="top" width="3.7%"><a href="http://obartra.github.io"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/3877773?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Oscar"/></td>
|
|
108
|
+
<td align="center" valign="top" width="3.7%"><a href="https://daniel-ruf.de"><img src="https://images.weserv.nl/?url=https://avatars1.githubusercontent.com/u/827205?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Daniel Ruf"/></td>
|
|
109
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/schindld"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/1659632?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="schindld"/></td>
|
|
110
|
+
<td align="center" valign="top" width="3.7%"><a href="https://alvarobg.com"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/12004383?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Alvaro"/></td>
|
|
111
|
+
<td align="center" valign="top" width="3.7%"><a href="http://northhorizon.net"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/616152?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Daniel Moore"/></td>
|
|
112
|
+
<td align="center" valign="top" width="3.7%"><a href="https://dylanmtaylor.com"><img src="https://images.weserv.nl/?url=https://avatars2.githubusercontent.com/u/277927?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Dylan M. Taylor"/></td>
|
|
113
|
+
<td align="center" valign="top" width="3.7%"><a href="https://pixelswap.fr/"><img src="https://images.weserv.nl/?url=https://avatars1.githubusercontent.com/u/4266283?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Corentin Mors"/></td>
|
|
114
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/xatavian"><img src="https://images.weserv.nl/?url=https://avatars1.githubusercontent.com/u/17217965?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="xatavian"/></td>
|
|
115
|
+
<td align="center" valign="top" width="3.7%"><a href="https://stackoverflow.com/story/yepninja"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/11796206?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Yevgeny Petukhov"/></td>
|
|
116
|
+
<td align="center" valign="top" width="3.7%"><a href="https://about.me/mickaeltr"><img src="https://images.weserv.nl/?url=https://avatars2.githubusercontent.com/u/378910?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Mickaël Tricot"/></td>
|
|
117
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/andreasciamanna"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/181780?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Andrea"/></td>
|
|
118
|
+
<td align="center" valign="top" width="3.7%"><a href="http://www.ircad.fr/"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/8638653?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Flavien Bridault"/></td>
|
|
119
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/s-kazuki"><img src="https://images.weserv.nl/?url=https://avatars2.githubusercontent.com/u/9253374?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="s-kazuki"/></td>
|
|
120
|
+
</tr><br />
|
|
121
|
+
<tr>
|
|
122
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/kiprasmel"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/29430509?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Kipras Melnikovas"/></td>
|
|
123
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/Gkxie"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/27680715?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="xieyu"/></td>
|
|
124
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/st1gok"><img src="https://images.weserv.nl/?url=https://avatars1.githubusercontent.com/u/13641693?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="st1gok"/></td>
|
|
125
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/max-wittig"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/6639323?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Max Wittig"/></td>
|
|
126
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/nlochschmidt"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/759624?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Niklas Lochschmidt"/></td>
|
|
127
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/illyaMs"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/26578665?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Ilya Dus"/></td>
|
|
128
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/wamry"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/32439651?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Omar Awamry"/></td>
|
|
129
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/Sumragen"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/15640910?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Hennadii Varava"/></td>
|
|
130
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/xiezht"><img src="https://images.weserv.nl/?url=https://avatars1.githubusercontent.com/u/18051618?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="xiezht"/></td>
|
|
131
|
+
<td align="center" valign="top" width="3.7%"><a href="http://www.martin-helmich.de/en"><img src="https://images.weserv.nl/?url=https://avatars3.githubusercontent.com/u/2538958?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Martin Helmich"/></td>
|
|
132
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/smcgivern"><img src="https://images.weserv.nl/?url=https://avatars0.githubusercontent.com/u/1120328?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Sean McGivern"/></td>
|
|
133
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/Vogel612"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/7288995?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Clemens Lieb"/></td>
|
|
134
|
+
<td align="center" valign="top" width="3.7%"><a href="https://sajdl.com/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/5222912?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Vojtěch Sajdl"/></td>
|
|
135
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/divido"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/4614626?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="divido"/></td>
|
|
136
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/vboulaye"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/652767?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Vincent Boulaye"/></td>
|
|
137
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/Aliyss"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/33941859?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Aliyss Snow"/></td>
|
|
138
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/saada"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/1087987?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Mahmoud Saada"/></td>
|
|
139
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/F3n67u"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/12343178?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Feng Yu"/></td>
|
|
140
|
+
<td align="center" valign="top" width="3.7%"><a href="https://datatra.sh/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/173822?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Roy Jacobs"/></td>
|
|
141
|
+
<td align="center" valign="top" width="3.7%"><a href="http://www.paullemke.com/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/976010?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Paul Lemke"/></td>
|
|
142
|
+
<td align="center" valign="top" width="3.7%"><a href="http://jenko.me/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/131355?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Ian Jenkins"/></td>
|
|
143
|
+
<td align="center" valign="top" width="3.7%"><a href="https://www.nilennoct.com/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/4055220?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="nilennoct"/></td>
|
|
144
|
+
<td align="center" valign="top" width="3.7%"><a href="http://michael.laffargue.fr/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/503129?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Laffargue Michael"/></td>
|
|
145
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/MartinHowarth"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/7187425?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Martin Howarth"/></td>
|
|
146
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/christophlehmann"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/4953689?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Christoph Lehmann"/></td>
|
|
147
|
+
<td align="center" valign="top" width="3.7%"><a href="https://theopensourceu.org/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/253471?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Frank V"/></td>
|
|
148
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/Salimlou"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/357286?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Salim Benabbou"/></td>
|
|
149
|
+
</tr><br />
|
|
150
|
+
<tr>
|
|
151
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/tvtamas"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/1945260?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Tamás Török-Vistai"/></td>
|
|
152
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/MartinBenninger"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/20296116?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Martin Benninger"/></td>
|
|
153
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/fewieden"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/9334168?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="fewieden"/></td>
|
|
154
|
+
<td align="center" valign="top" width="3.7%"><a href="https://www.jeffpelton.com/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/36627?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Jeff Pelton"/></td>
|
|
155
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/claude-abounegm"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/11809881?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Claude Abounegm"/></td>
|
|
156
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/Marethyu1"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/17978203?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Stefan Hall"/></td>
|
|
157
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/Mr-Wallet"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/799000?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Jordan Wallet"/></td>
|
|
158
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/zhao0"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/7556666?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="zhao0"/></td>
|
|
159
|
+
<td align="center" valign="top" width="3.7%"><a href="https://www.linkedin.com/in/joshuagrosso"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/4530584?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Joshua Grosso"/></td>
|
|
160
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/yonguelink"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/9469187?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Isaac Ouellet Therrien"/></td>
|
|
161
|
+
<td align="center" valign="top" width="3.7%"><a href="https://wearecws.com/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/24895138?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Rajat Sharma"/></td>
|
|
162
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/Casz"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/65105345?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Cesar B."/></td>
|
|
163
|
+
<td align="center" valign="top" width="3.7%"><a href="https://blog.katsuba.dev/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/10637135?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Igor Katsuba"/></td>
|
|
164
|
+
<td align="center" valign="top" width="3.7%"><a href="http://www.doublespeakgames.com/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/4884483?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Michael Townsend"/></td>
|
|
165
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/bodtx"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/1039550?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="bodtx"/></td>
|
|
166
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/arthot"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/1815294?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Artem"/></td>
|
|
167
|
+
<td align="center" valign="top" width="3.7%"><a href="https://muniftanjim.dev/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/8050659?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Munif Tanjim"/></td>
|
|
168
|
+
<td align="center" valign="top" width="3.7%"><a href="https://www.qkdreyer.dev/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/717869?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Quentin Dreyer"/></td>
|
|
169
|
+
<td align="center" valign="top" width="3.7%"><a href="https://iwritethe.codes/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/192728?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Norm MacLennan"/></td>
|
|
170
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/jnovick"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/7881319?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="jnovick"/></td>
|
|
171
|
+
<td align="center" valign="top" width="3.7%"><a href="https://www.fabianaussems.com/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/57530?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Fabian Aussems"/></td>
|
|
172
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/mima0815"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/14311597?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Michael Matzka"/></td>
|
|
173
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/CraigAllardyce"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/9052289?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="CraigAllardyce"/></td>
|
|
174
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/brunobastosg"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/320122?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Bruno Guimarães"/></td>
|
|
175
|
+
<td align="center" valign="top" width="3.7%"><a href="http://leipert.io/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/2906107?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Lukas Eipert"/></td>
|
|
176
|
+
<td align="center" valign="top" width="3.7%"><a href="https://max.krauss.io/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/914671?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Maximilian Krauß"/></td>
|
|
177
|
+
<td align="center" valign="top" width="3.7%"><a href="https://eng.evolution.com/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/15799569?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Evolution Engineering"/></td>
|
|
178
|
+
</tr><br />
|
|
179
|
+
<tr>
|
|
180
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/Neonox31"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/1135958?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="WEBER Logan"/></td>
|
|
181
|
+
<td align="center" valign="top" width="3.7%"><a href="https://t.me/mister_cheater"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/5055654?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Anton Zhukov"/></td>
|
|
182
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/beaverusiv"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/4149031?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Nicholas Loomans"/></td>
|
|
183
|
+
<td align="center" valign="top" width="3.7%"><a href="https://icedream.pw/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/807772?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Carl Kittelberger"/></td>
|
|
184
|
+
<td align="center" valign="top" width="3.7%"><a href="https://patrik.votocek.cz/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/112567?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Patrik Votoček"/></td>
|
|
185
|
+
<td align="center" valign="top" width="3.7%"><a href="https://kyr.github.io/CV/"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/426462?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Kyrylo Fedorov"/></td>
|
|
186
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/claudio-vellage"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/28930612?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Claudio Vellage"/></td>
|
|
187
|
+
<td align="center" valign="top" width="3.7%"><a href="https://github.com/seb0uil"><img src="https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/5122626?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="Seb0uil"/></td>
|
|
188
|
+
</tr>
|
|
189
|
+
</p>
|
|
190
|
+
|
|
191
|
+
<!-- markdownlint-restore -->
|
|
192
|
+
<!-- prettier-ignore-end -->
|
|
193
|
+
|
|
194
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
38
195
|
|
|
39
|
-
[
|
|
196
|
+
This started as a fork from [node-gitlab-legacy](https://github.com/rest-gitlab/rest-gitlab-legacy) but I ended up rewriting much of the code. Here are the original work's [contributors](https://github.com/rest-gitlab/rest-gitlab-legacy#contributors).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
type ResponseBodyTypes = Record<string, unknown> | Record<string, unknown>[] | ReadableStream | Blob | string | string[] | number | void;
|
|
2
|
+
interface FormattedResponse<T extends ResponseBodyTypes = ResponseBodyTypes> {
|
|
3
|
+
body: T;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
status: number;
|
|
6
|
+
}
|
|
7
|
+
interface RequesterType {
|
|
8
|
+
get<T extends ResponseBodyTypes>(endpoint: string, options?: Record<string, unknown>): Promise<FormattedResponse<T>>;
|
|
9
|
+
post<T extends ResponseBodyTypes>(endpoint: string, options?: Record<string, unknown>): Promise<FormattedResponse<T>>;
|
|
10
|
+
put<T extends ResponseBodyTypes>(endpoint: string, options?: Record<string, unknown>): Promise<FormattedResponse<T>>;
|
|
11
|
+
patch<T extends ResponseBodyTypes>(endpoint: string, options?: Record<string, unknown>): Promise<FormattedResponse<T>>;
|
|
12
|
+
delete<T extends ResponseBodyTypes>(endpoint: string, options?: Record<string, unknown>): Promise<FormattedResponse<T>>;
|
|
13
|
+
}
|
|
14
|
+
interface Constructable<T = any> {
|
|
15
|
+
new (...args: any[]): T;
|
|
16
|
+
}
|
|
17
|
+
type DefaultResourceOptions = {
|
|
18
|
+
headers: {
|
|
19
|
+
[header: string]: string;
|
|
20
|
+
};
|
|
21
|
+
requestTimeout: number;
|
|
22
|
+
url: string;
|
|
23
|
+
rejectUnauthorized: boolean;
|
|
24
|
+
};
|
|
25
|
+
type DefaultRequestOptions = {
|
|
26
|
+
body?: FormData | Record<string, unknown>;
|
|
27
|
+
searchParams?: Record<string, unknown>;
|
|
28
|
+
sudo?: string;
|
|
29
|
+
method?: string;
|
|
30
|
+
asStream?: boolean;
|
|
31
|
+
};
|
|
32
|
+
type RequestOptions = {
|
|
33
|
+
headers: Record<string, string>;
|
|
34
|
+
timeout?: number;
|
|
35
|
+
method: string;
|
|
36
|
+
searchParams?: string;
|
|
37
|
+
prefixUrl: string;
|
|
38
|
+
body?: string | FormData;
|
|
39
|
+
asStream?: boolean;
|
|
40
|
+
};
|
|
41
|
+
declare function formatQuery(params?: Record<string, unknown>): string;
|
|
42
|
+
type OptionsHandlerFn = (serviceOptions: DefaultResourceOptions, requestOptions: DefaultRequestOptions) => Promise<RequestOptions>;
|
|
43
|
+
declare function defaultOptionsHandler(resourceOptions: DefaultResourceOptions, { body, searchParams, sudo, asStream, method }?: DefaultRequestOptions): Promise<RequestOptions>;
|
|
44
|
+
type RequestHandlerFn<T extends ResponseBodyTypes = ResponseBodyTypes> = (endpoint: string, options?: Record<string, unknown>) => Promise<FormattedResponse<T>>;
|
|
45
|
+
declare function createRequesterFn(optionsHandler: OptionsHandlerFn, requestHandler: RequestHandlerFn): (serviceOptions: DefaultResourceOptions) => RequesterType;
|
|
46
|
+
declare function presetResourceArguments<T extends Record<string, Constructable>>(resources: T, customConfig?: Record<string, unknown>): T;
|
|
47
|
+
|
|
48
|
+
interface BaseResourceOptions<C> {
|
|
49
|
+
oauthToken?: string;
|
|
50
|
+
token?: string;
|
|
51
|
+
jobToken?: string;
|
|
52
|
+
host?: string;
|
|
53
|
+
prefixUrl?: string;
|
|
54
|
+
rejectUnauthorized?: boolean;
|
|
55
|
+
camelize?: C;
|
|
56
|
+
requesterFn?: (resourceOptions: DefaultResourceOptions) => RequesterType;
|
|
57
|
+
requestTimeout?: number;
|
|
58
|
+
profileToken?: string;
|
|
59
|
+
sudo?: string | number;
|
|
60
|
+
profileMode?: 'execution' | 'memory';
|
|
61
|
+
}
|
|
62
|
+
declare class BaseResource<C extends boolean = false> {
|
|
63
|
+
readonly url: string;
|
|
64
|
+
readonly requester: RequesterType;
|
|
65
|
+
readonly requestTimeout: number;
|
|
66
|
+
readonly headers: {
|
|
67
|
+
[header: string]: string;
|
|
68
|
+
};
|
|
69
|
+
readonly camelize: C | undefined;
|
|
70
|
+
readonly rejectUnauthorized: boolean;
|
|
71
|
+
constructor({ token, jobToken, oauthToken, sudo, profileToken, requesterFn, camelize, profileMode, host, prefixUrl, rejectUnauthorized, requestTimeout, }?: BaseResourceOptions<C>);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { BaseResource, BaseResourceOptions, Constructable, DefaultRequestOptions, DefaultResourceOptions, FormattedResponse, OptionsHandlerFn, RequestHandlerFn, RequestOptions, RequesterType, ResponseBodyTypes, createRequesterFn, defaultOptionsHandler, formatQuery, presetResourceArguments };
|
package/dist/index.js
CHANGED
|
@@ -1,189 +1,117 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var xcase = require('xcase');
|
|
6
4
|
var qs = require('qs');
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
purpose with or without fee is hereby granted.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
-
***************************************************************************** */
|
|
22
|
-
/* global Reflect, Promise */
|
|
23
|
-
|
|
24
|
-
var extendStatics = function(d, b) {
|
|
25
|
-
extendStatics = Object.setPrototypeOf ||
|
|
26
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
27
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
28
|
-
return extendStatics(d, b);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
function __extends(d, b) {
|
|
32
|
-
if (typeof b !== "function" && b !== null)
|
|
33
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
34
|
-
extendStatics(d, b);
|
|
35
|
-
function __() { this.constructor = d; }
|
|
36
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var __assign = function() {
|
|
40
|
-
__assign = Object.assign || function __assign(t) {
|
|
41
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
42
|
-
s = arguments[i];
|
|
43
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
44
|
-
}
|
|
45
|
-
return t;
|
|
46
|
-
};
|
|
47
|
-
return __assign.apply(this, arguments);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
function __read(o, n) {
|
|
51
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
52
|
-
if (!m) return o;
|
|
53
|
-
var i = m.call(o), r, ar = [], e;
|
|
54
|
-
try {
|
|
55
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
56
|
-
}
|
|
57
|
-
catch (error) { e = { error: error }; }
|
|
58
|
-
finally {
|
|
59
|
-
try {
|
|
60
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
61
|
-
}
|
|
62
|
-
finally { if (e) throw e.error; }
|
|
63
|
-
}
|
|
64
|
-
return ar;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function __spreadArray(to, from, pack) {
|
|
68
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
69
|
-
if (ar || !(i in from)) {
|
|
70
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
71
|
-
ar[i] = from[i];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
6
|
+
// src/RequesterUtils.ts
|
|
7
|
+
function formatQuery(params = {}) {
|
|
8
|
+
const decamelized = xcase.decamelizeKeys(params);
|
|
9
|
+
return qs.stringify(decamelized, { arrayFormat: "brackets" });
|
|
75
10
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return _this;
|
|
132
|
-
}
|
|
133
|
-
return class_1;
|
|
134
|
-
}(Base));
|
|
135
|
-
}
|
|
136
|
-
function presetResourceArguments(resources, customConfig) {
|
|
137
|
-
if (customConfig === void 0) { customConfig = {}; }
|
|
138
|
-
var updated = {};
|
|
139
|
-
Object.entries(resources)
|
|
140
|
-
.filter(function (_a) {
|
|
141
|
-
var _b = __read(_a, 2), s = _b[1];
|
|
142
|
-
return typeof s === 'function';
|
|
143
|
-
}) // FIXME: Odd default artifact included in this list during testing
|
|
144
|
-
.forEach(function (_a) {
|
|
145
|
-
var _b = __read(_a, 2), k = _b[0], r = _b[1];
|
|
146
|
-
updated[k] = extendClass(r, customConfig);
|
|
147
|
-
});
|
|
148
|
-
return updated;
|
|
11
|
+
function isFormData(object) {
|
|
12
|
+
return typeof object === "object" && object.constructor.name === "FormData";
|
|
13
|
+
}
|
|
14
|
+
function defaultOptionsHandler(resourceOptions, { body, searchParams, sudo, asStream = false, method = "get" } = {}) {
|
|
15
|
+
const { headers: preconfiguredHeaders, requestTimeout, url } = resourceOptions;
|
|
16
|
+
const headers = { ...preconfiguredHeaders };
|
|
17
|
+
const defaultOptions = {
|
|
18
|
+
headers,
|
|
19
|
+
timeout: requestTimeout,
|
|
20
|
+
method,
|
|
21
|
+
asStream,
|
|
22
|
+
prefixUrl: url
|
|
23
|
+
};
|
|
24
|
+
if (sudo)
|
|
25
|
+
defaultOptions.headers.sudo = sudo;
|
|
26
|
+
if (body) {
|
|
27
|
+
if (isFormData(body)) {
|
|
28
|
+
defaultOptions.body = body;
|
|
29
|
+
} else {
|
|
30
|
+
defaultOptions.body = JSON.stringify(xcase.decamelizeKeys(body));
|
|
31
|
+
headers["content-type"] = "application/json";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const q = formatQuery(searchParams);
|
|
35
|
+
if (q)
|
|
36
|
+
defaultOptions.searchParams = q;
|
|
37
|
+
return Promise.resolve(defaultOptions);
|
|
38
|
+
}
|
|
39
|
+
function createRequesterFn(optionsHandler, requestHandler) {
|
|
40
|
+
const methods = ["get", "post", "put", "patch", "delete"];
|
|
41
|
+
return (serviceOptions) => {
|
|
42
|
+
const requester = {};
|
|
43
|
+
methods.forEach((m) => {
|
|
44
|
+
requester[m] = async (endpoint, options) => {
|
|
45
|
+
const requestOptions = await optionsHandler(serviceOptions, { ...options, method: m });
|
|
46
|
+
return requestHandler(endpoint, requestOptions);
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
return requester;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function extendClass(Base, customConfig = {}) {
|
|
53
|
+
return class extends Base {
|
|
54
|
+
constructor(...options) {
|
|
55
|
+
const [config, ...opts] = options;
|
|
56
|
+
super({ ...customConfig, ...config }, ...opts);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function presetResourceArguments(resources, customConfig = {}) {
|
|
61
|
+
const updated = {};
|
|
62
|
+
Object.entries(resources).filter(([, s]) => typeof s === "function").forEach(([k, r]) => {
|
|
63
|
+
updated[k] = extendClass(r, customConfig);
|
|
64
|
+
});
|
|
65
|
+
return updated;
|
|
149
66
|
}
|
|
150
67
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
68
|
+
// src/BaseResource.ts
|
|
69
|
+
var BaseResource = class {
|
|
70
|
+
url;
|
|
71
|
+
requester;
|
|
72
|
+
requestTimeout;
|
|
73
|
+
headers;
|
|
74
|
+
camelize;
|
|
75
|
+
rejectUnauthorized;
|
|
76
|
+
constructor({
|
|
77
|
+
token,
|
|
78
|
+
jobToken,
|
|
79
|
+
oauthToken,
|
|
80
|
+
sudo,
|
|
81
|
+
profileToken,
|
|
82
|
+
requesterFn,
|
|
83
|
+
camelize,
|
|
84
|
+
profileMode = "execution",
|
|
85
|
+
host = "https://gitlab.com",
|
|
86
|
+
prefixUrl = "",
|
|
87
|
+
rejectUnauthorized = true,
|
|
88
|
+
requestTimeout = 3e5
|
|
89
|
+
} = {}) {
|
|
90
|
+
if (!requesterFn)
|
|
91
|
+
throw new ReferenceError("requesterFn must be passed");
|
|
92
|
+
this.url = [host, "api", "v4", prefixUrl].join("/");
|
|
93
|
+
this.headers = {};
|
|
94
|
+
this.rejectUnauthorized = rejectUnauthorized;
|
|
95
|
+
this.camelize = camelize;
|
|
96
|
+
this.requestTimeout = requestTimeout;
|
|
97
|
+
if (oauthToken)
|
|
98
|
+
this.headers.authorization = `Bearer ${oauthToken}`;
|
|
99
|
+
else if (jobToken)
|
|
100
|
+
this.headers["job-token"] = jobToken;
|
|
101
|
+
else if (token)
|
|
102
|
+
this.headers["private-token"] = token;
|
|
103
|
+
if (profileToken) {
|
|
104
|
+
this.headers["X-Profile-Token"] = profileToken;
|
|
105
|
+
this.headers["X-Profile-Mode"] = profileMode;
|
|
106
|
+
}
|
|
107
|
+
if (sudo)
|
|
108
|
+
this.headers.Sudo = `${sudo}`;
|
|
109
|
+
this.requester = requesterFn({ ...this });
|
|
110
|
+
}
|
|
111
|
+
};
|
|
183
112
|
|
|
184
113
|
exports.BaseResource = BaseResource;
|
|
185
114
|
exports.createRequesterFn = createRequesterFn;
|
|
186
115
|
exports.defaultOptionsHandler = defaultOptionsHandler;
|
|
187
116
|
exports.formatQuery = formatQuery;
|
|
188
117
|
exports.presetResourceArguments = presetResourceArguments;
|
|
189
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { decamelizeKeys } from 'xcase';
|
|
2
|
+
import { stringify } from 'qs';
|
|
3
|
+
|
|
4
|
+
// src/RequesterUtils.ts
|
|
5
|
+
function formatQuery(params = {}) {
|
|
6
|
+
const decamelized = decamelizeKeys(params);
|
|
7
|
+
return stringify(decamelized, { arrayFormat: "brackets" });
|
|
8
|
+
}
|
|
9
|
+
function isFormData(object) {
|
|
10
|
+
return typeof object === "object" && object.constructor.name === "FormData";
|
|
11
|
+
}
|
|
12
|
+
function defaultOptionsHandler(resourceOptions, { body, searchParams, sudo, asStream = false, method = "get" } = {}) {
|
|
13
|
+
const { headers: preconfiguredHeaders, requestTimeout, url } = resourceOptions;
|
|
14
|
+
const headers = { ...preconfiguredHeaders };
|
|
15
|
+
const defaultOptions = {
|
|
16
|
+
headers,
|
|
17
|
+
timeout: requestTimeout,
|
|
18
|
+
method,
|
|
19
|
+
asStream,
|
|
20
|
+
prefixUrl: url
|
|
21
|
+
};
|
|
22
|
+
if (sudo)
|
|
23
|
+
defaultOptions.headers.sudo = sudo;
|
|
24
|
+
if (body) {
|
|
25
|
+
if (isFormData(body)) {
|
|
26
|
+
defaultOptions.body = body;
|
|
27
|
+
} else {
|
|
28
|
+
defaultOptions.body = JSON.stringify(decamelizeKeys(body));
|
|
29
|
+
headers["content-type"] = "application/json";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const q = formatQuery(searchParams);
|
|
33
|
+
if (q)
|
|
34
|
+
defaultOptions.searchParams = q;
|
|
35
|
+
return Promise.resolve(defaultOptions);
|
|
36
|
+
}
|
|
37
|
+
function createRequesterFn(optionsHandler, requestHandler) {
|
|
38
|
+
const methods = ["get", "post", "put", "patch", "delete"];
|
|
39
|
+
return (serviceOptions) => {
|
|
40
|
+
const requester = {};
|
|
41
|
+
methods.forEach((m) => {
|
|
42
|
+
requester[m] = async (endpoint, options) => {
|
|
43
|
+
const requestOptions = await optionsHandler(serviceOptions, { ...options, method: m });
|
|
44
|
+
return requestHandler(endpoint, requestOptions);
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
return requester;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function extendClass(Base, customConfig = {}) {
|
|
51
|
+
return class extends Base {
|
|
52
|
+
constructor(...options) {
|
|
53
|
+
const [config, ...opts] = options;
|
|
54
|
+
super({ ...customConfig, ...config }, ...opts);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function presetResourceArguments(resources, customConfig = {}) {
|
|
59
|
+
const updated = {};
|
|
60
|
+
Object.entries(resources).filter(([, s]) => typeof s === "function").forEach(([k, r]) => {
|
|
61
|
+
updated[k] = extendClass(r, customConfig);
|
|
62
|
+
});
|
|
63
|
+
return updated;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/BaseResource.ts
|
|
67
|
+
var BaseResource = class {
|
|
68
|
+
url;
|
|
69
|
+
requester;
|
|
70
|
+
requestTimeout;
|
|
71
|
+
headers;
|
|
72
|
+
camelize;
|
|
73
|
+
rejectUnauthorized;
|
|
74
|
+
constructor({
|
|
75
|
+
token,
|
|
76
|
+
jobToken,
|
|
77
|
+
oauthToken,
|
|
78
|
+
sudo,
|
|
79
|
+
profileToken,
|
|
80
|
+
requesterFn,
|
|
81
|
+
camelize,
|
|
82
|
+
profileMode = "execution",
|
|
83
|
+
host = "https://gitlab.com",
|
|
84
|
+
prefixUrl = "",
|
|
85
|
+
rejectUnauthorized = true,
|
|
86
|
+
requestTimeout = 3e5
|
|
87
|
+
} = {}) {
|
|
88
|
+
if (!requesterFn)
|
|
89
|
+
throw new ReferenceError("requesterFn must be passed");
|
|
90
|
+
this.url = [host, "api", "v4", prefixUrl].join("/");
|
|
91
|
+
this.headers = {};
|
|
92
|
+
this.rejectUnauthorized = rejectUnauthorized;
|
|
93
|
+
this.camelize = camelize;
|
|
94
|
+
this.requestTimeout = requestTimeout;
|
|
95
|
+
if (oauthToken)
|
|
96
|
+
this.headers.authorization = `Bearer ${oauthToken}`;
|
|
97
|
+
else if (jobToken)
|
|
98
|
+
this.headers["job-token"] = jobToken;
|
|
99
|
+
else if (token)
|
|
100
|
+
this.headers["private-token"] = token;
|
|
101
|
+
if (profileToken) {
|
|
102
|
+
this.headers["X-Profile-Token"] = profileToken;
|
|
103
|
+
this.headers["X-Profile-Mode"] = profileMode;
|
|
104
|
+
}
|
|
105
|
+
if (sudo)
|
|
106
|
+
this.headers.Sudo = `${sudo}`;
|
|
107
|
+
this.requester = requesterFn({ ...this });
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export { BaseResource, createRequesterFn, defaultOptionsHandler, formatQuery, presetResourceArguments };
|
package/package.json
CHANGED
|
@@ -1,51 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitbeaker/requester-utils",
|
|
3
|
+
"version": "36.0.0-rc.0",
|
|
3
4
|
"description": "Utility functions for requester implementatons used in @gitbeaker",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=18.0.0"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/jdalrymple/gitbeaker"
|
|
7
12
|
},
|
|
8
13
|
"bugs": {
|
|
9
14
|
"url": "https://github.com/jdalrymple/gitbeaker/issues"
|
|
10
15
|
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"form-data": "^4.0.0",
|
|
13
|
-
"qs": "^6.10.1",
|
|
14
|
-
"xcase": "^2.0.1"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@types/node": "^18.0.3",
|
|
18
|
-
"@types/qs": "^6.9.7",
|
|
19
|
-
"jest-extended": "^3.0.0",
|
|
20
|
-
"rollup": "^2.47.0",
|
|
21
|
-
"rollup-plugin-typescript2": "^0.31.1",
|
|
22
|
-
"tslib": "^2.3.1",
|
|
23
|
-
"typescript": "^4.2.4"
|
|
24
|
-
},
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">=14.2.0"
|
|
27
|
-
},
|
|
28
|
-
"files": [
|
|
29
|
-
"dist"
|
|
30
|
-
],
|
|
31
16
|
"homepage": "https://github.com/jdalrymple/gitbeaker#readme",
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Justin Dalrymple"
|
|
19
|
+
},
|
|
32
20
|
"keywords": [
|
|
33
21
|
"gitbeaker",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
22
|
+
"gitlab",
|
|
23
|
+
"utils"
|
|
36
24
|
],
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.mjs",
|
|
30
|
+
"require": "./dist/index.js"
|
|
31
|
+
}
|
|
44
32
|
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
45
36
|
"scripts": {
|
|
46
|
-
"build": "
|
|
47
|
-
"test:
|
|
48
|
-
"test:
|
|
37
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --treeshake",
|
|
38
|
+
"test:types": "tsc",
|
|
39
|
+
"test:integration": "jest --maxWorkers=50% test/integration",
|
|
40
|
+
"test:unit": "jest --maxWorkers=50% test/unit",
|
|
41
|
+
"format:docs": "prettier '**/(*.json|.yml|.js|.md)' --ignore-path ../../.prettierignore",
|
|
42
|
+
"format:docs:fix": "yarn format:docs --write",
|
|
43
|
+
"format:src": "prettier '{src,test}/**/*.ts' --ignore-path ../../.prettierignore",
|
|
44
|
+
"format:src:fix": "yarn format:src --write",
|
|
45
|
+
"format": "yarn format:src && yarn format:docs",
|
|
46
|
+
"format:fix": "yarn format:src:fix && yarn format:docs:fix",
|
|
47
|
+
"lint": "eslint '{src,test}/**/*.ts'",
|
|
48
|
+
"lint:fix": "yarn lint --fix"
|
|
49
49
|
},
|
|
50
|
-
"
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"qs": "^6.11.1",
|
|
52
|
+
"xcase": "^2.0.1"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": "^18.15.0",
|
|
56
|
+
"tsup": "^6.6.3",
|
|
57
|
+
"typescript": "^4.9.5"
|
|
58
|
+
}
|
|
51
59
|
}
|
package/LICENSE.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# The MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c)
|
|
4
|
-
**2020 Justin Dalrymple**
|
|
5
|
-
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
in the Software without restriction, including without limitation the rights
|
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
furnished to do so, subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be included in
|
|
14
|
-
all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
-
THE SOFTWARE.
|
package/dist/index.es.js
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { decamelizeKeys } from 'xcase';
|
|
2
|
-
import { stringify } from 'qs';
|
|
3
|
-
|
|
4
|
-
/*! *****************************************************************************
|
|
5
|
-
Copyright (c) Microsoft Corporation.
|
|
6
|
-
|
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
8
|
-
purpose with or without fee is hereby granted.
|
|
9
|
-
|
|
10
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
11
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
12
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
13
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
15
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
17
|
-
***************************************************************************** */
|
|
18
|
-
/* global Reflect, Promise */
|
|
19
|
-
|
|
20
|
-
var extendStatics = function(d, b) {
|
|
21
|
-
extendStatics = Object.setPrototypeOf ||
|
|
22
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
23
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
24
|
-
return extendStatics(d, b);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function __extends(d, b) {
|
|
28
|
-
if (typeof b !== "function" && b !== null)
|
|
29
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
30
|
-
extendStatics(d, b);
|
|
31
|
-
function __() { this.constructor = d; }
|
|
32
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var __assign = function() {
|
|
36
|
-
__assign = Object.assign || function __assign(t) {
|
|
37
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
38
|
-
s = arguments[i];
|
|
39
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
40
|
-
}
|
|
41
|
-
return t;
|
|
42
|
-
};
|
|
43
|
-
return __assign.apply(this, arguments);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
function __read(o, n) {
|
|
47
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
48
|
-
if (!m) return o;
|
|
49
|
-
var i = m.call(o), r, ar = [], e;
|
|
50
|
-
try {
|
|
51
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
52
|
-
}
|
|
53
|
-
catch (error) { e = { error: error }; }
|
|
54
|
-
finally {
|
|
55
|
-
try {
|
|
56
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
57
|
-
}
|
|
58
|
-
finally { if (e) throw e.error; }
|
|
59
|
-
}
|
|
60
|
-
return ar;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function __spreadArray(to, from, pack) {
|
|
64
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
65
|
-
if (ar || !(i in from)) {
|
|
66
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
67
|
-
ar[i] = from[i];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Utility methods
|
|
74
|
-
function formatQuery(params) {
|
|
75
|
-
if (params === void 0) { params = {}; }
|
|
76
|
-
var decamelized = decamelizeKeys(params);
|
|
77
|
-
return stringify(decamelized, { arrayFormat: 'brackets' });
|
|
78
|
-
}
|
|
79
|
-
function defaultOptionsHandler(resourceOptions, _a) {
|
|
80
|
-
var _b = _a === void 0 ? {} : _a, body = _b.body, query = _b.query, sudo = _b.sudo, _c = _b.method, method = _c === void 0 ? 'get' : _c;
|
|
81
|
-
var preconfiguredHeaders = resourceOptions.headers, requestTimeout = resourceOptions.requestTimeout, url = resourceOptions.url;
|
|
82
|
-
var headers = __assign({}, preconfiguredHeaders);
|
|
83
|
-
var bod;
|
|
84
|
-
if (sudo)
|
|
85
|
-
headers.sudo = sudo;
|
|
86
|
-
// FIXME: Not the best comparison, but...it will have to do for now.
|
|
87
|
-
if (typeof body === 'object' && body.constructor.name !== 'FormData') {
|
|
88
|
-
bod = JSON.stringify(decamelizeKeys(body));
|
|
89
|
-
headers['content-type'] = 'application/json';
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
bod = body;
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
headers: headers,
|
|
96
|
-
timeout: requestTimeout,
|
|
97
|
-
method: method,
|
|
98
|
-
searchParams: formatQuery(query),
|
|
99
|
-
prefixUrl: url,
|
|
100
|
-
body: bod,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function createRequesterFn(optionsHandler, requestHandler) {
|
|
104
|
-
var methods = ['get', 'post', 'put', 'delete', 'stream'];
|
|
105
|
-
return function (serviceOptions) {
|
|
106
|
-
var requester = {};
|
|
107
|
-
methods.forEach(function (m) {
|
|
108
|
-
requester[m] = function (endpoint, options) {
|
|
109
|
-
var requestOptions = optionsHandler(serviceOptions, __assign(__assign({}, options), { method: m }));
|
|
110
|
-
return requestHandler(endpoint, requestOptions);
|
|
111
|
-
};
|
|
112
|
-
});
|
|
113
|
-
return requester;
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function extendClass(Base, customConfig) {
|
|
117
|
-
return /** @class */ (function (_super) {
|
|
118
|
-
__extends(class_1, _super);
|
|
119
|
-
function class_1() {
|
|
120
|
-
var options = [];
|
|
121
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
122
|
-
options[_i] = arguments[_i];
|
|
123
|
-
}
|
|
124
|
-
var _this = this;
|
|
125
|
-
var _a = __read(options), config = _a[0], opts = _a.slice(1);
|
|
126
|
-
_this = _super.apply(this, __spreadArray([__assign(__assign({}, customConfig), config)], __read(opts), false)) || this;
|
|
127
|
-
return _this;
|
|
128
|
-
}
|
|
129
|
-
return class_1;
|
|
130
|
-
}(Base));
|
|
131
|
-
}
|
|
132
|
-
function presetResourceArguments(resources, customConfig) {
|
|
133
|
-
if (customConfig === void 0) { customConfig = {}; }
|
|
134
|
-
var updated = {};
|
|
135
|
-
Object.entries(resources)
|
|
136
|
-
.filter(function (_a) {
|
|
137
|
-
var _b = __read(_a, 2), s = _b[1];
|
|
138
|
-
return typeof s === 'function';
|
|
139
|
-
}) // FIXME: Odd default artifact included in this list during testing
|
|
140
|
-
.forEach(function (_a) {
|
|
141
|
-
var _b = __read(_a, 2), k = _b[0], r = _b[1];
|
|
142
|
-
updated[k] = extendClass(r, customConfig);
|
|
143
|
-
});
|
|
144
|
-
return updated;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
var BaseResource = /** @class */ (function () {
|
|
148
|
-
function BaseResource(_a) {
|
|
149
|
-
var _b = _a === void 0 ? {} : _a, token = _b.token, jobToken = _b.jobToken, oauthToken = _b.oauthToken, sudo = _b.sudo, profileToken = _b.profileToken, requesterFn = _b.requesterFn, camelize = _b.camelize, _c = _b.profileMode, profileMode = _c === void 0 ? 'execution' : _c, _d = _b.host, host = _d === void 0 ? 'https://gitlab.com' : _d, _e = _b.prefixUrl, prefixUrl = _e === void 0 ? '' : _e, _f = _b.version, version = _f === void 0 ? 4 : _f, _g = _b.rejectUnauthorized, rejectUnauthorized = _g === void 0 ? true : _g, _h = _b.requestTimeout, requestTimeout = _h === void 0 ? 300000 : _h;
|
|
150
|
-
if (!requesterFn)
|
|
151
|
-
throw new ReferenceError('requesterFn must be passed');
|
|
152
|
-
this.url = [host, 'api', "v".concat(version), prefixUrl].join('/');
|
|
153
|
-
this.headers = {
|
|
154
|
-
'user-agent': 'gitbeaker',
|
|
155
|
-
};
|
|
156
|
-
this.rejectUnauthorized = rejectUnauthorized;
|
|
157
|
-
this.camelize = camelize;
|
|
158
|
-
this.requestTimeout = requestTimeout;
|
|
159
|
-
// Handle auth tokens
|
|
160
|
-
if (oauthToken)
|
|
161
|
-
this.headers.authorization = "Bearer ".concat(oauthToken);
|
|
162
|
-
else if (jobToken)
|
|
163
|
-
this.headers['job-token'] = jobToken;
|
|
164
|
-
else if (token)
|
|
165
|
-
this.headers['private-token'] = token;
|
|
166
|
-
// Profiling
|
|
167
|
-
if (profileToken) {
|
|
168
|
-
this.headers['X-Profile-Token'] = profileToken;
|
|
169
|
-
this.headers['X-Profile-Mode'] = profileMode;
|
|
170
|
-
}
|
|
171
|
-
// Set sudo
|
|
172
|
-
if (sudo)
|
|
173
|
-
this.headers.Sudo = "".concat(sudo);
|
|
174
|
-
// Set requester instance using this information
|
|
175
|
-
this.requester = requesterFn(__assign({}, this));
|
|
176
|
-
}
|
|
177
|
-
return BaseResource;
|
|
178
|
-
}());
|
|
179
|
-
|
|
180
|
-
export { BaseResource, createRequesterFn, defaultOptionsHandler, formatQuery, presetResourceArguments };
|
|
181
|
-
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/RequesterUtils.ts","../src/BaseResource.ts"],"sourcesContent":["import { decamelizeKeys } from 'xcase';\nimport FormData, { Headers } from 'form-data';\nimport { stringify } from 'qs';\n\n// Types\nexport interface Constructable<T = any> {\n new (...args: any[]): T;\n}\n\nexport interface RequesterType {\n get(endpoint: string, options?: Record<string, unknown>): Promise<any>;\n post(endpoint: string, options?: Record<string, unknown>): Promise<any>;\n put(endpoint: string, options?: Record<string, unknown>): Promise<any>;\n delete(endpoint: string, options?: Record<string, unknown>): Promise<any>;\n stream?(endpoint: string, options?: Record<string, unknown>): NodeJS.ReadableStream;\n}\n\nexport type DefaultResourceOptions = {\n headers: { [header: string]: string };\n requestTimeout: number;\n url: string;\n rejectUnauthorized: boolean;\n};\n\nexport type DefaultRequestOptions = {\n body?: FormData | Record<string, unknown>;\n query?: Record<string, unknown>;\n sudo?: string;\n method?: string;\n};\n\nexport type DefaultRequestReturn = {\n headers: Record<string, string> | Headers;\n timeout?: number;\n method: string;\n searchParams?: string;\n prefixUrl?: string;\n body?: string | FormData;\n};\n\n// Utility methods\nexport function formatQuery(params: Record<string, unknown> = {}): string {\n const decamelized = decamelizeKeys(params);\n\n return stringify(decamelized, { arrayFormat: 'brackets' });\n}\n\nexport type OptionsHandlerFn = (\n serviceOptions: DefaultResourceOptions,\n requestOptions: DefaultRequestOptions,\n) => DefaultRequestReturn;\nexport function defaultOptionsHandler(\n resourceOptions: DefaultResourceOptions,\n { body, query, sudo, method = 'get' }: DefaultRequestOptions = {},\n): DefaultRequestReturn {\n const { headers: preconfiguredHeaders, requestTimeout, url } = resourceOptions;\n const headers = { ...preconfiguredHeaders };\n let bod: FormData | string;\n\n if (sudo) headers.sudo = sudo;\n\n // FIXME: Not the best comparison, but...it will have to do for now.\n if (typeof body === 'object' && body.constructor.name !== 'FormData') {\n bod = JSON.stringify(decamelizeKeys(body));\n headers['content-type'] = 'application/json';\n } else {\n bod = body as FormData;\n }\n\n return {\n headers,\n timeout: requestTimeout,\n method,\n searchParams: formatQuery(query),\n prefixUrl: url,\n body: bod,\n };\n}\n\nexport type RequestHandlerFn = (\n endpoint: string,\n options?: Record<string, unknown>,\n) =>\n | any\n | Promise<{\n body: Record<string, unknown> | Record<string, unknown>[];\n headers: Record<string, unknown> | Headers;\n status: number;\n }>;\n\nexport function createRequesterFn(\n optionsHandler: OptionsHandlerFn,\n requestHandler: RequestHandlerFn,\n): (serviceOptions: DefaultResourceOptions) => RequesterType {\n const methods = ['get', 'post', 'put', 'delete', 'stream'];\n\n return (serviceOptions) => {\n const requester: RequesterType = {} as RequesterType;\n\n methods.forEach((m) => {\n requester[m] = (endpoint: string, options: Record<string, unknown>) => {\n const requestOptions = optionsHandler(serviceOptions, { ...options, method: m });\n\n return requestHandler(endpoint, requestOptions);\n };\n });\n\n return requester;\n };\n}\n\nfunction extendClass<T extends Constructable>(Base: T, customConfig: Record<string, unknown>): T {\n return class extends Base {\n constructor(...options: any[]) {\n const [config, ...opts] = options;\n\n super({ ...customConfig, ...config }, ...opts);\n }\n };\n}\n\nexport function presetResourceArguments<T>(\n resources: T,\n customConfig: Record<string, unknown> = {},\n) {\n const updated = {};\n\n Object.entries(resources)\n .filter(([, s]) => typeof s === 'function') // FIXME: Odd default artifact included in this list during testing\n .forEach(([k, r]) => {\n updated[k] = extendClass(r, customConfig);\n });\n\n return updated as T;\n}\n","import { RequesterType, DefaultResourceOptions } from './RequesterUtils';\n\nexport interface BaseResourceOptions<C> {\n oauthToken?: string;\n token?: string;\n jobToken?: string;\n host?: string;\n prefixUrl?: string;\n version?: 3 | 4;\n rejectUnauthorized?: boolean;\n camelize?: C;\n requesterFn?: (resourceOptions: DefaultResourceOptions) => RequesterType;\n requestTimeout?: number;\n profileToken?: string;\n sudo?: string | number;\n profileMode?: 'execution' | 'memory';\n}\n\nexport class BaseResource<C extends boolean = false> {\n public readonly url: string;\n\n public readonly requester: RequesterType;\n\n public readonly requestTimeout: number;\n\n public readonly headers: { [header: string]: string };\n\n public readonly camelize: C | undefined;\n\n public readonly rejectUnauthorized: boolean;\n\n constructor({\n token,\n jobToken,\n oauthToken,\n sudo,\n profileToken,\n requesterFn,\n camelize,\n profileMode = 'execution',\n host = 'https://gitlab.com',\n prefixUrl = '',\n version = 4,\n rejectUnauthorized = true,\n requestTimeout = 300000,\n }: BaseResourceOptions<C> = {}) {\n if (!requesterFn) throw new ReferenceError('requesterFn must be passed');\n\n this.url = [host, 'api', `v${version}`, prefixUrl].join('/');\n\n this.headers = {\n 'user-agent': 'gitbeaker',\n };\n this.rejectUnauthorized = rejectUnauthorized;\n this.camelize = camelize;\n this.requestTimeout = requestTimeout;\n\n // Handle auth tokens\n if (oauthToken) this.headers.authorization = `Bearer ${oauthToken}`;\n else if (jobToken) this.headers['job-token'] = jobToken;\n else if (token) this.headers['private-token'] = token;\n\n // Profiling\n if (profileToken) {\n this.headers['X-Profile-Token'] = profileToken;\n this.headers['X-Profile-Mode'] = profileMode;\n }\n\n // Set sudo\n if (sudo) this.headers.Sudo = `${sudo}`;\n\n // Set requester instance using this information\n this.requester = requesterFn({ ...this });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;AACM,SAAU,WAAW,CAAC,MAAoC,EAAA;AAApC,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I,CAAC,GAAG,CAAC,CAAC;QAE7D,IAAI,CAAC,OAAO,GAAG;AACb,YAAA,YAAY,EAAE,WAAW;SAC1B,CAAC;AACF,QAAA,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAC7C,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,QAAA,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;;AAGrC,QAAA,IAAI,UAAU;YAAE,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,SAAU,CAAA,MAAA,CAAA,UAAU,CAAE,CAAC;AAC/D,aAAA,IAAI,QAAQ;AAAE,YAAA,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC;AACnD,aAAA,IAAI,KAAK;AAAE,YAAA,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC;;AAGtD,QAAA,IAAI,YAAY,EAAE;AAChB,YAAA,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,YAAY,CAAC;AAC/C,YAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,WAAW,CAAC;AAC9C,SAAA;;AAGD,QAAA,IAAI,IAAI;YAAE,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,EAAG,CAAA,MAAA,CAAA,IAAI,CAAE,CAAC;;AAGxC,QAAA,IAAI,CAAC,SAAS,GAAG,WAAW,CAAM,QAAA,CAAA,EAAA,EAAA,IAAI,EAAG,CAAC;KAC3C;IACH,OAAC,YAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/RequesterUtils.ts","../src/BaseResource.ts"],"sourcesContent":["import { decamelizeKeys } from 'xcase';\nimport FormData, { Headers } from 'form-data';\nimport { stringify } from 'qs';\n\n// Types\nexport interface Constructable<T = any> {\n new (...args: any[]): T;\n}\n\nexport interface RequesterType {\n get(endpoint: string, options?: Record<string, unknown>): Promise<any>;\n post(endpoint: string, options?: Record<string, unknown>): Promise<any>;\n put(endpoint: string, options?: Record<string, unknown>): Promise<any>;\n delete(endpoint: string, options?: Record<string, unknown>): Promise<any>;\n stream?(endpoint: string, options?: Record<string, unknown>): NodeJS.ReadableStream;\n}\n\nexport type DefaultResourceOptions = {\n headers: { [header: string]: string };\n requestTimeout: number;\n url: string;\n rejectUnauthorized: boolean;\n};\n\nexport type DefaultRequestOptions = {\n body?: FormData | Record<string, unknown>;\n query?: Record<string, unknown>;\n sudo?: string;\n method?: string;\n};\n\nexport type DefaultRequestReturn = {\n headers: Record<string, string> | Headers;\n timeout?: number;\n method: string;\n searchParams?: string;\n prefixUrl?: string;\n body?: string | FormData;\n};\n\n// Utility methods\nexport function formatQuery(params: Record<string, unknown> = {}): string {\n const decamelized = decamelizeKeys(params);\n\n return stringify(decamelized, { arrayFormat: 'brackets' });\n}\n\nexport type OptionsHandlerFn = (\n serviceOptions: DefaultResourceOptions,\n requestOptions: DefaultRequestOptions,\n) => DefaultRequestReturn;\nexport function defaultOptionsHandler(\n resourceOptions: DefaultResourceOptions,\n { body, query, sudo, method = 'get' }: DefaultRequestOptions = {},\n): DefaultRequestReturn {\n const { headers: preconfiguredHeaders, requestTimeout, url } = resourceOptions;\n const headers = { ...preconfiguredHeaders };\n let bod: FormData | string;\n\n if (sudo) headers.sudo = sudo;\n\n // FIXME: Not the best comparison, but...it will have to do for now.\n if (typeof body === 'object' && body.constructor.name !== 'FormData') {\n bod = JSON.stringify(decamelizeKeys(body));\n headers['content-type'] = 'application/json';\n } else {\n bod = body as FormData;\n }\n\n return {\n headers,\n timeout: requestTimeout,\n method,\n searchParams: formatQuery(query),\n prefixUrl: url,\n body: bod,\n };\n}\n\nexport type RequestHandlerFn = (\n endpoint: string,\n options?: Record<string, unknown>,\n) =>\n | any\n | Promise<{\n body: Record<string, unknown> | Record<string, unknown>[];\n headers: Record<string, unknown> | Headers;\n status: number;\n }>;\n\nexport function createRequesterFn(\n optionsHandler: OptionsHandlerFn,\n requestHandler: RequestHandlerFn,\n): (serviceOptions: DefaultResourceOptions) => RequesterType {\n const methods = ['get', 'post', 'put', 'delete', 'stream'];\n\n return (serviceOptions) => {\n const requester: RequesterType = {} as RequesterType;\n\n methods.forEach((m) => {\n requester[m] = (endpoint: string, options: Record<string, unknown>) => {\n const requestOptions = optionsHandler(serviceOptions, { ...options, method: m });\n\n return requestHandler(endpoint, requestOptions);\n };\n });\n\n return requester;\n };\n}\n\nfunction extendClass<T extends Constructable>(Base: T, customConfig: Record<string, unknown>): T {\n return class extends Base {\n constructor(...options: any[]) {\n const [config, ...opts] = options;\n\n super({ ...customConfig, ...config }, ...opts);\n }\n };\n}\n\nexport function presetResourceArguments<T>(\n resources: T,\n customConfig: Record<string, unknown> = {},\n) {\n const updated = {};\n\n Object.entries(resources)\n .filter(([, s]) => typeof s === 'function') // FIXME: Odd default artifact included in this list during testing\n .forEach(([k, r]) => {\n updated[k] = extendClass(r, customConfig);\n });\n\n return updated as T;\n}\n","import { RequesterType, DefaultResourceOptions } from './RequesterUtils';\n\nexport interface BaseResourceOptions<C> {\n oauthToken?: string;\n token?: string;\n jobToken?: string;\n host?: string;\n prefixUrl?: string;\n version?: 3 | 4;\n rejectUnauthorized?: boolean;\n camelize?: C;\n requesterFn?: (resourceOptions: DefaultResourceOptions) => RequesterType;\n requestTimeout?: number;\n profileToken?: string;\n sudo?: string | number;\n profileMode?: 'execution' | 'memory';\n}\n\nexport class BaseResource<C extends boolean = false> {\n public readonly url: string;\n\n public readonly requester: RequesterType;\n\n public readonly requestTimeout: number;\n\n public readonly headers: { [header: string]: string };\n\n public readonly camelize: C | undefined;\n\n public readonly rejectUnauthorized: boolean;\n\n constructor({\n token,\n jobToken,\n oauthToken,\n sudo,\n profileToken,\n requesterFn,\n camelize,\n profileMode = 'execution',\n host = 'https://gitlab.com',\n prefixUrl = '',\n version = 4,\n rejectUnauthorized = true,\n requestTimeout = 300000,\n }: BaseResourceOptions<C> = {}) {\n if (!requesterFn) throw new ReferenceError('requesterFn must be passed');\n\n this.url = [host, 'api', `v${version}`, prefixUrl].join('/');\n\n this.headers = {\n 'user-agent': 'gitbeaker',\n };\n this.rejectUnauthorized = rejectUnauthorized;\n this.camelize = camelize;\n this.requestTimeout = requestTimeout;\n\n // Handle auth tokens\n if (oauthToken) this.headers.authorization = `Bearer ${oauthToken}`;\n else if (jobToken) this.headers['job-token'] = jobToken;\n else if (token) this.headers['private-token'] = token;\n\n // Profiling\n if (profileToken) {\n this.headers['X-Profile-Token'] = profileToken;\n this.headers['X-Profile-Mode'] = profileMode;\n }\n\n // Set sudo\n if (sudo) this.headers.Sudo = `${sudo}`;\n\n // Set requester instance using this information\n this.requester = requesterFn({ ...this });\n }\n}\n"],"names":["decamelizeKeys","stringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;AACM,SAAU,WAAW,CAAC,MAAoC,EAAA;AAApC,IAAA,IAAA,MAAA,KAAA,KAAA,CAAA,EAAA,EAAA,MAAoC,GAAA,EAAA,CAAA,EAAA;AAC9D,IAAA,IAAM,WAAW,GAAGA,oBAAc,CAAC,MAAM,CAAC,CAAC;IAE3C,OAAOC,YAAS,CAAC,WAAW,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AAC7D,CAAC;AAMe,SAAA,qBAAqB,CACnC,eAAuC,EACvC,EAAiE,EAAA;AAAjE,IAAA,IAAA,EAAA,GAAA,EAAA,KAAA,KAAA,CAAA,GAA+D,EAAE,GAAA,EAAA,EAA/D,IAAI,GAAA,EAAA,CAAA,IAAA,EAAE,KAAK,GAAA,EAAA,CAAA,KAAA,EAAE,IAAI,UAAA,EAAE,EAAA,GAAA,EAAA,CAAA,MAAc,EAAd,MAAM,GAAA,EAAA,KAAA,KAAA,CAAA,GAAG,KAAK,GAAA,EAAA,CA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AAI,YAAY,EAAE;AAChB,YAAA,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,YAAY,CAAC;AAC/C,YAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,WAAW,CAAC;AAC9C,SAAA;;AAGD,QAAA,IAAI,IAAI;YAAE,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,EAAG,CAAA,MAAA,CAAA,IAAI,CAAE,CAAC;;AAGxC,QAAA,IAAI,CAAC,SAAS,GAAG,WAAW,CAAM,QAAA,CAAA,EAAA,EAAA,IAAI,EAAG,CAAC;KAC3C;IACH,OAAC,YAAA,CAAA;AAAD,CAAC,EAAA;;;;;;;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { RequesterType, DefaultResourceOptions } from './RequesterUtils';
|
|
2
|
-
export interface BaseResourceOptions<C> {
|
|
3
|
-
oauthToken?: string;
|
|
4
|
-
token?: string;
|
|
5
|
-
jobToken?: string;
|
|
6
|
-
host?: string;
|
|
7
|
-
prefixUrl?: string;
|
|
8
|
-
version?: 3 | 4;
|
|
9
|
-
rejectUnauthorized?: boolean;
|
|
10
|
-
camelize?: C;
|
|
11
|
-
requesterFn?: (resourceOptions: DefaultResourceOptions) => RequesterType;
|
|
12
|
-
requestTimeout?: number;
|
|
13
|
-
profileToken?: string;
|
|
14
|
-
sudo?: string | number;
|
|
15
|
-
profileMode?: 'execution' | 'memory';
|
|
16
|
-
}
|
|
17
|
-
export declare class BaseResource<C extends boolean = false> {
|
|
18
|
-
readonly url: string;
|
|
19
|
-
readonly requester: RequesterType;
|
|
20
|
-
readonly requestTimeout: number;
|
|
21
|
-
readonly headers: {
|
|
22
|
-
[header: string]: string;
|
|
23
|
-
};
|
|
24
|
-
readonly camelize: C | undefined;
|
|
25
|
-
readonly rejectUnauthorized: boolean;
|
|
26
|
-
constructor({ token, jobToken, oauthToken, sudo, profileToken, requesterFn, camelize, profileMode, host, prefixUrl, version, rejectUnauthorized, requestTimeout, }?: BaseResourceOptions<C>);
|
|
27
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import FormData, { Headers } from 'form-data';
|
|
3
|
-
export interface Constructable<T = any> {
|
|
4
|
-
new (...args: any[]): T;
|
|
5
|
-
}
|
|
6
|
-
export interface RequesterType {
|
|
7
|
-
get(endpoint: string, options?: Record<string, unknown>): Promise<any>;
|
|
8
|
-
post(endpoint: string, options?: Record<string, unknown>): Promise<any>;
|
|
9
|
-
put(endpoint: string, options?: Record<string, unknown>): Promise<any>;
|
|
10
|
-
delete(endpoint: string, options?: Record<string, unknown>): Promise<any>;
|
|
11
|
-
stream?(endpoint: string, options?: Record<string, unknown>): NodeJS.ReadableStream;
|
|
12
|
-
}
|
|
13
|
-
export declare type DefaultResourceOptions = {
|
|
14
|
-
headers: {
|
|
15
|
-
[header: string]: string;
|
|
16
|
-
};
|
|
17
|
-
requestTimeout: number;
|
|
18
|
-
url: string;
|
|
19
|
-
rejectUnauthorized: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare type DefaultRequestOptions = {
|
|
22
|
-
body?: FormData | Record<string, unknown>;
|
|
23
|
-
query?: Record<string, unknown>;
|
|
24
|
-
sudo?: string;
|
|
25
|
-
method?: string;
|
|
26
|
-
};
|
|
27
|
-
export declare type DefaultRequestReturn = {
|
|
28
|
-
headers: Record<string, string> | Headers;
|
|
29
|
-
timeout?: number;
|
|
30
|
-
method: string;
|
|
31
|
-
searchParams?: string;
|
|
32
|
-
prefixUrl?: string;
|
|
33
|
-
body?: string | FormData;
|
|
34
|
-
};
|
|
35
|
-
export declare function formatQuery(params?: Record<string, unknown>): string;
|
|
36
|
-
export declare type OptionsHandlerFn = (serviceOptions: DefaultResourceOptions, requestOptions: DefaultRequestOptions) => DefaultRequestReturn;
|
|
37
|
-
export declare function defaultOptionsHandler(resourceOptions: DefaultResourceOptions, { body, query, sudo, method }?: DefaultRequestOptions): DefaultRequestReturn;
|
|
38
|
-
export declare type RequestHandlerFn = (endpoint: string, options?: Record<string, unknown>) => any | Promise<{
|
|
39
|
-
body: Record<string, unknown> | Record<string, unknown>[];
|
|
40
|
-
headers: Record<string, unknown> | Headers;
|
|
41
|
-
status: number;
|
|
42
|
-
}>;
|
|
43
|
-
export declare function createRequesterFn(optionsHandler: OptionsHandlerFn, requestHandler: RequestHandlerFn): (serviceOptions: DefaultResourceOptions) => RequesterType;
|
|
44
|
-
export declare function presetResourceArguments<T>(resources: T, customConfig?: Record<string, unknown>): T;
|
package/dist/types/index.d.ts
DELETED