Skip to content

Commit a488bd8

Browse files
authored
chore: add non-empty ID validation to resource clients (#168)
1 parent adc2b7e commit a488bd8

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.2.0 / NEXT
2+
===================
3+
- Added validation for resource IDs to be non-empty. This is non-breaking and prevents cryptic errors like `We have bad news: there is no API endpoint at this URL.`
4+
15
1.1.1 / 2021/04/14
26
===================
37
- Fixed slow parsing of large responses due to a [bug in `axios`](https://github.com/axios/axios/issues/2829).

src/index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class ApifyClient {
104104
* @return {ActorClient}
105105
*/
106106
actor(id) {
107-
ow(id, ow.string);
107+
ow(id, ow.string.nonEmpty);
108108
return new ActorClient({
109109
id,
110110
...this._options(),
@@ -125,7 +125,7 @@ class ApifyClient {
125125
* @return {BuildClient}
126126
*/
127127
build(id) {
128-
ow(id, ow.string);
128+
ow(id, ow.string.nonEmpty);
129129
return new BuildClient({
130130
id,
131131
...this._options(),
@@ -146,7 +146,7 @@ class ApifyClient {
146146
* @return {DatasetClient}
147147
*/
148148
dataset(id) {
149-
ow(id, ow.string);
149+
ow(id, ow.string.nonEmpty);
150150
return new DatasetClient({
151151
id,
152152
...this._options(),
@@ -167,7 +167,7 @@ class ApifyClient {
167167
* @return {KeyValueStoreClient}
168168
*/
169169
keyValueStore(id) {
170-
ow(id, ow.string);
170+
ow(id, ow.string.nonEmpty);
171171
return new KeyValueStoreClient({
172172
id,
173173
...this._options(),
@@ -180,7 +180,7 @@ class ApifyClient {
180180
* @return {LogClient}
181181
*/
182182
log(buildOrRunId) {
183-
ow(buildOrRunId, ow.string);
183+
ow(buildOrRunId, ow.string.nonEmpty);
184184
return new LogClient({
185185
id: buildOrRunId,
186186
...this._options(),
@@ -203,9 +203,9 @@ class ApifyClient {
203203
* @return {RequestQueueClient}
204204
*/
205205
requestQueue(id, options = {}) {
206-
ow(id, ow.string);
206+
ow(id, ow.string.nonEmpty);
207207
ow(options, ow.object.exactShape({
208-
clientKey: ow.optional.string,
208+
clientKey: ow.optional.string.nonEmpty,
209209
}));
210210
const apiClientOptions = {
211211
id,
@@ -228,7 +228,7 @@ class ApifyClient {
228228
* @return {RunClient}
229229
*/
230230
run(id) {
231-
ow(id, ow.string);
231+
ow(id, ow.string.nonEmpty);
232232
return new RunClient({
233233
id,
234234
...this._options(),
@@ -249,7 +249,7 @@ class ApifyClient {
249249
* @return {TaskClient}
250250
*/
251251
task(id) {
252-
ow(id, ow.string);
252+
ow(id, ow.string.nonEmpty);
253253
return new TaskClient({
254254
id,
255255
...this._options(),
@@ -270,7 +270,7 @@ class ApifyClient {
270270
* @return {ScheduleClient}
271271
*/
272272
schedule(id) {
273-
ow(id, ow.string);
273+
ow(id, ow.string.nonEmpty);
274274
return new ScheduleClient({
275275
id,
276276
...this._options(),
@@ -283,7 +283,7 @@ class ApifyClient {
283283
* @return {UserClient}
284284
*/
285285
user(id = ME_USER_NAME_PLACEHOLDER) {
286-
ow(id, ow.string);
286+
ow(id, ow.string.nonEmpty);
287287
return new UserClient({
288288
id,
289289
...this._options(),
@@ -304,7 +304,7 @@ class ApifyClient {
304304
* @return {WebhookClient}
305305
*/
306306
webhook(id) {
307-
ow(id, ow.string);
307+
ow(id, ow.string.nonEmpty);
308308
return new WebhookClient({
309309
id,
310310
...this._options(),
@@ -325,7 +325,7 @@ class ApifyClient {
325325
* @return {WebhookDispatchClient}
326326
*/
327327
webhookDispatch(id) {
328-
ow(id, ow.string);
328+
ow(id, ow.string.nonEmpty);
329329
return new WebhookDispatchClient({
330330
id,
331331
...this._options(),

0 commit comments

Comments
 (0)