@magda/utils 2.3.3 → 3.0.0-alpha.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/dist/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  /// <reference types="node" />
2
+
2
3
  import { Arguments } from 'yargs';
3
- import { CoreOptions } from 'request';
4
- import { Request as Request_2 } from 'request';
5
- import { RequestAPI } from 'request';
6
- import { RequiredUriUrl } from 'request';
4
+ import requestOriginal from 'request';
7
5
 
8
6
  /**
9
7
  * Checks to see whether the passed argv has a jwtSecret object. If not,
@@ -45,7 +43,7 @@ export declare class BadRequestError extends ServiceError {
45
43
  constructor(statusCode: number, errorResponse: ApiError, e: any);
46
44
  }
47
45
 
48
- export declare function buildJwt(jwtSecret: string, userId: string, session?: any): any;
46
+ export declare function buildJwt(jwtSecret: string, userId: string, session?: any): string;
49
47
 
50
48
  export declare const coerceJson: (param: string) => (json?: string | object | any[]) => any;
51
49
 
@@ -66,7 +64,7 @@ export declare function createNoCacheFetchOptions(fetchOptions?: RequestInit): {
66
64
  referrer?: string;
67
65
  referrerPolicy?: ReferrerPolicy;
68
66
  signal?: AbortSignal;
69
- window?: any;
67
+ window?: null;
70
68
  };
71
69
 
72
70
  /**
@@ -113,7 +111,7 @@ export declare const isUuid: (id: any) => boolean;
113
111
 
114
112
  declare class Maybe<T> implements Monad<T>, Functor<T>, Eq<Maybe<T>> {
115
113
  private type;
116
- private value;
114
+ private value?;
117
115
  constructor(type: MaybeType, value?: T);
118
116
  static sequence<T>(t: {
119
117
  [k: string]: Maybe<T>;
@@ -125,9 +123,11 @@ declare class Maybe<T> implements Monad<T>, Functor<T>, Eq<Maybe<T>> {
125
123
  }) => Maybe<{
126
124
  [k: string]: any;
127
125
  }>;
128
- static maybe<T>(t: T): Maybe<T>;
126
+ static maybe<T>(t?: T | null): Maybe<T>;
129
127
  static just<T>(t: T): Maybe<T>;
130
128
  static nothing<T>(): Maybe<T>;
129
+ static isJust<T>(t: Maybe<T>): boolean;
130
+ static isNothing<T>(t: Maybe<T>): boolean;
131
131
  unit<U>(u: U): Maybe<U>;
132
132
  bind<U>(f: (t: T) => Maybe<U>): Maybe<U>;
133
133
  of: <U>(u: U) => Maybe<U>;
@@ -141,7 +141,7 @@ declare class Maybe<T> implements Monad<T>, Functor<T>, Eq<Maybe<T>> {
141
141
  valueOr<U extends T>(defaultValue: U): T | U;
142
142
  valueOrCompute<U extends T>(defaultValueFunction: () => U): T | U;
143
143
  valueOrThrow(error?: Error): T;
144
- do(patterns?: OptionalMaybePatterns<T, void>): Maybe<T>;
144
+ do(patterns?: Partial<MaybePatterns<T, void>>): Maybe<T>;
145
145
  }
146
146
 
147
147
  declare interface MaybePatterns<T, U> {
@@ -151,7 +151,7 @@ declare interface MaybePatterns<T, U> {
151
151
 
152
152
  declare enum MaybeType {
153
153
  Nothing = 0,
154
- Just = 1,
154
+ Just = 1
155
155
  }
156
156
 
157
157
  declare interface Monad<T> {
@@ -161,12 +161,7 @@ declare interface Monad<T> {
161
161
  chain<U>(f: (t: T) => Monad<U>): Monad<U>;
162
162
  }
163
163
 
164
- declare interface OptionalMaybePatterns<T, U> {
165
- just?: (t: T) => U;
166
- nothing?: () => U;
167
- }
168
-
169
- export declare const request: RequestAPI<Request_2, CoreOptions, RequiredUriUrl>;
164
+ export declare const request: requestOriginal.RequestAPI<requestOriginal.Request, requestOriginal.CoreOptions, requestOriginal.RequiredUriUrl>;
170
165
 
171
166
  declare type RequestContentType = RequestContentTypeJson | RequestContentTypePlainText | RequestContentTypeForm | RequestContentTypeBinary | RequestContentTypeMultipartForm;
172
167
 
@@ -180,7 +175,7 @@ declare type RequestContentTypeMultipartForm = "multipart/form-data";
180
175
 
181
176
  declare type RequestContentTypePlainText = "text/plain";
182
177
 
183
- export declare function retry<T>(op: () => Promise<T>, delaySeconds: number, retries: number, onRetry: (e: any, retries: number) => any, shouldRetry?: (e: any) => boolean): Promise<T>;
178
+ export declare function retry<T = any>(op: () => Promise<T>, delaySeconds: number, retries: number, onRetry: (e: any, retries: number) => any, shouldRetry?: (e: any) => boolean): Promise<T>;
184
179
 
185
180
  export declare function retryBackoff<T>(op: () => Promise<T>, delaySeconds: number, retries: number, onRetry: (e: any, retries: number) => any, easing?: (delaySeconds: number) => number): Promise<T>;
186
181