@magda/utils 2.0.0-alpha.1 → 2.0.0-alpha.4

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
@@ -53,6 +53,22 @@ declare interface CreateAsyncPage<T> {
53
53
  (): Promise<AsyncPage<T>>;
54
54
  }
55
55
 
56
+ export declare function createNoCacheFetchOptions(fetchOptions?: RequestInit): {
57
+ body?: BodyInit;
58
+ cache?: RequestCache;
59
+ credentials?: RequestCredentials;
60
+ headers?: HeadersInit;
61
+ integrity?: string;
62
+ keepalive?: boolean;
63
+ method?: string;
64
+ mode?: RequestMode;
65
+ redirect?: RequestRedirect;
66
+ referrer?: string;
67
+ referrerPolicy?: ReferrerPolicy;
68
+ signal?: AbortSignal;
69
+ window?: any;
70
+ };
71
+
56
72
  /**
57
73
  * Creates a {@link ServiceError} from the result of a failed call to an API generated
58
74
  * by swagger-codegen. The result typically includes `response` (with a status code) and
@@ -71,6 +87,10 @@ declare interface Eq<T> {
71
87
  equals(t: T): boolean;
72
88
  }
73
89
 
90
+ export declare function fetchRequest<T = any, CT = string>(method: string, url: string, body?: any, contentType?: CT | RequestContentType | undefined | null, returnHeaders?: false, extraRequestOptions?: RequestInit): Promise<T>;
91
+
92
+ export declare function fetchRequest<T = any, CT = string>(method: string, url: string, body?: any, contentType?: CT | RequestContentType | undefined | null, returnHeaders?: true, extraRequestOptions?: RequestInit): Promise<[T, Headers]>;
93
+
74
94
  export declare function forEachAsync<T>(page: AsyncPage<T[]>, maxConcurrency: number, callbackFn: (data: T) => Promise<void>): Promise<void>;
75
95
 
76
96
  export declare function formatServiceError(baseMessage: string, e: any, retriesLeft: number): string;
@@ -81,8 +101,14 @@ declare interface Functor<T> {
81
101
  map<U>(f: (t: T) => U): Functor<U>;
82
102
  }
83
103
 
104
+ export declare function getDefaultRequestInitOptions(): RequestInit;
105
+
84
106
  export declare function getMinikubeIP(): string;
85
107
 
108
+ export declare function getRequest<T = any, CT = string>(url: string, noCache?: boolean, extraFetchOptions?: RequestInit): Promise<T>;
109
+
110
+ export declare function getRequestNoCache<T = any, CT = string>(url: string, extraFetchOptions?: RequestInit): Promise<T>;
111
+
86
112
  export declare const isUuid: (id: any) => boolean;
87
113
 
88
114
  declare class Maybe<T> implements Monad<T>, Functor<T>, Eq<Maybe<T>> {
@@ -142,6 +168,18 @@ declare interface OptionalMaybePatterns<T, U> {
142
168
 
143
169
  export declare const request: RequestAPI<Request_2, CoreOptions, RequiredUriUrl>;
144
170
 
171
+ declare type RequestContentType = RequestContentTypeJson | RequestContentTypePlainText | RequestContentTypeForm | RequestContentTypeBinary | RequestContentTypeMultipartForm;
172
+
173
+ declare type RequestContentTypeBinary = "application/octet-stream";
174
+
175
+ declare type RequestContentTypeForm = "application/x-www-form-urlencoded";
176
+
177
+ declare type RequestContentTypeJson = "application/json";
178
+
179
+ declare type RequestContentTypeMultipartForm = "multipart/form-data";
180
+
181
+ declare type RequestContentTypePlainText = "text/plain";
182
+
145
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>;
146
184
 
147
185
  export declare function retryBackoff<T>(op: () => Promise<T>, delaySeconds: number, retries: number, onRetry: (e: any, retries: number) => any, easing?: (delaySeconds: number) => number): Promise<T>;
@@ -153,6 +191,8 @@ export declare class ServiceError extends Error {
153
191
  constructor(message: string, e: any);
154
192
  }
155
193
 
194
+ export declare function setDefaultRequestInitOptions(options: RequestInit): void;
195
+
156
196
  export declare function unionToThrowable<T>(input: T | Error): T;
157
197
 
158
198
  export { }