@openfn/language-common 2.0.0-rc3 → 2.0.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 +7 -7
- package/ast.json +1602 -0
- package/dist/index.cjs +690 -4957
- package/dist/index.js +611 -4930
- package/dist/metadata.cjs +59 -0
- package/dist/metadata.js +35 -0
- package/dist/util.cjs +322 -0
- package/dist/util.js +276 -0
- package/package.json +51 -57
- package/types/Adaptor.d.ts +429 -0
- package/types/beta.d.ts +21 -0
- package/types/dateFns.d.ts +1 -0
- package/types/http.d.ts +129 -0
- package/types/index.d.ts +8 -0
- package/types/metadata.d.ts +11 -0
- package/types/util/http.d.ts +76 -0
- package/types/util/index.d.ts +4 -0
- package/types/util/parse-date.d.ts +2 -0
- package/types/util/references.d.ts +2 -0
- package/dist/language-common.d.ts +0 -685
|
@@ -1,685 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* alias for "fn()"
|
|
3
|
-
*/
|
|
4
|
-
export declare function alterState(func: Operation): Operation;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Turns an array into a string, separated by X.
|
|
8
|
-
* @example
|
|
9
|
-
* field("destination_string__c", function(state) {
|
|
10
|
-
* return arrayToString(dataValue("path_of_array")(state), ', ')
|
|
11
|
-
* })
|
|
12
|
-
* @param arr - Array of toString'able primatives.
|
|
13
|
-
* @param separator - Separator string.
|
|
14
|
-
*/
|
|
15
|
-
export declare function arrayToString(arr: any[], separator: string): string[];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Scopes an array of data based on a JSONPath.
|
|
19
|
-
* Useful when the source data has `n` items you would like to map to
|
|
20
|
-
* an operation.
|
|
21
|
-
* The operation will receive a slice of the data based of each item
|
|
22
|
-
* of the JSONPath provided.
|
|
23
|
-
* @example
|
|
24
|
-
* map("$.[*]",
|
|
25
|
-
* create("SObject",
|
|
26
|
-
* field("FirstName", sourceValue("$.firstName"))
|
|
27
|
-
* )
|
|
28
|
-
* )
|
|
29
|
-
* @function
|
|
30
|
-
* @param {string} path - JSONPath referencing a point in `state.data`.
|
|
31
|
-
* @param {function} operation - The operation needed to be repeated.
|
|
32
|
-
* @param {State} state - Runtime state.
|
|
33
|
-
* @returns {<State>}
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* Simple switcher allowing other expressions to use either a JSONPath or
|
|
37
|
-
* object literals as a data source.
|
|
38
|
-
* - JSONPath referencing a point in `state`
|
|
39
|
-
* - Object Literal of the data itself.
|
|
40
|
-
* - Function to be called with state.
|
|
41
|
-
* @example
|
|
42
|
-
* asData('$.key'| key | callback)
|
|
43
|
-
* @param data
|
|
44
|
-
* @param state - The current state.
|
|
45
|
-
*/
|
|
46
|
-
export declare function asData(data: DataSource, state: State): any;
|
|
47
|
-
|
|
48
|
-
declare const axios: AxiosStatic;
|
|
49
|
-
|
|
50
|
-
declare interface AxiosAdapter {
|
|
51
|
-
(config: AxiosRequestConfig): AxiosPromise<any>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
declare interface AxiosBasicCredentials {
|
|
55
|
-
username: string;
|
|
56
|
-
password: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
declare interface AxiosError<T = any> extends Error {
|
|
60
|
-
config: AxiosRequestConfig;
|
|
61
|
-
code?: string;
|
|
62
|
-
request?: any;
|
|
63
|
-
response?: AxiosResponse<T>;
|
|
64
|
-
isAxiosError: boolean;
|
|
65
|
-
toJSON: () => object;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
declare interface AxiosInstance {
|
|
69
|
-
(config: AxiosRequestConfig): AxiosPromise;
|
|
70
|
-
(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
|
71
|
-
defaults: AxiosRequestConfig;
|
|
72
|
-
interceptors: {
|
|
73
|
-
request: AxiosInterceptorManager<AxiosRequestConfig>;
|
|
74
|
-
response: AxiosInterceptorManager<AxiosResponse>;
|
|
75
|
-
};
|
|
76
|
-
getUri(config?: AxiosRequestConfig): string;
|
|
77
|
-
request<T = any, R = AxiosResponse<T>> (config: AxiosRequestConfig): Promise<R>;
|
|
78
|
-
get<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
|
79
|
-
delete<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
|
80
|
-
head<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
|
81
|
-
options<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
|
82
|
-
post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
|
83
|
-
put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
|
84
|
-
patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
declare interface AxiosInterceptorManager<V> {
|
|
88
|
-
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
|
|
89
|
-
eject(id: number): void;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
declare interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
declare interface AxiosProxyConfig {
|
|
96
|
-
host: string;
|
|
97
|
-
port: number;
|
|
98
|
-
auth?: {
|
|
99
|
-
username: string;
|
|
100
|
-
password:string;
|
|
101
|
-
};
|
|
102
|
-
protocol?: string;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
declare interface AxiosRequestConfig {
|
|
106
|
-
url?: string;
|
|
107
|
-
method?: Method;
|
|
108
|
-
baseURL?: string;
|
|
109
|
-
transformRequest?: AxiosTransformer | AxiosTransformer[];
|
|
110
|
-
transformResponse?: AxiosTransformer | AxiosTransformer[];
|
|
111
|
-
headers?: any;
|
|
112
|
-
params?: any;
|
|
113
|
-
paramsSerializer?: (params: any) => string;
|
|
114
|
-
data?: any;
|
|
115
|
-
timeout?: number;
|
|
116
|
-
timeoutErrorMessage?: string;
|
|
117
|
-
withCredentials?: boolean;
|
|
118
|
-
adapter?: AxiosAdapter;
|
|
119
|
-
auth?: AxiosBasicCredentials;
|
|
120
|
-
responseType?: ResponseType_2;
|
|
121
|
-
xsrfCookieName?: string;
|
|
122
|
-
xsrfHeaderName?: string;
|
|
123
|
-
onUploadProgress?: (progressEvent: any) => void;
|
|
124
|
-
onDownloadProgress?: (progressEvent: any) => void;
|
|
125
|
-
maxContentLength?: number;
|
|
126
|
-
validateStatus?: ((status: number) => boolean) | null;
|
|
127
|
-
maxBodyLength?: number;
|
|
128
|
-
maxRedirects?: number;
|
|
129
|
-
socketPath?: string | null;
|
|
130
|
-
httpAgent?: any;
|
|
131
|
-
httpsAgent?: any;
|
|
132
|
-
proxy?: AxiosProxyConfig | false;
|
|
133
|
-
cancelToken?: CancelToken;
|
|
134
|
-
decompress?: boolean;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
declare interface AxiosResponse<T = any> {
|
|
138
|
-
data: T;
|
|
139
|
-
status: number;
|
|
140
|
-
statusText: string;
|
|
141
|
-
headers: any;
|
|
142
|
-
config: AxiosRequestConfig;
|
|
143
|
-
request?: any;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
declare interface AxiosStatic extends AxiosInstance {
|
|
147
|
-
create(config?: AxiosRequestConfig): AxiosInstance;
|
|
148
|
-
Cancel: CancelStatic;
|
|
149
|
-
CancelToken: CancelTokenStatic;
|
|
150
|
-
isCancel(value: any): boolean;
|
|
151
|
-
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
|
|
152
|
-
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
|
153
|
-
isAxiosError(payload: any): payload is AxiosError;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
declare interface AxiosTransformer {
|
|
157
|
-
(data: any, headers?: any): any;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export declare namespace beta {
|
|
161
|
-
/**
|
|
162
|
-
* Scopes an array of data based on a JSONPath.
|
|
163
|
-
* Useful when the source data has `n` items you would like to map to
|
|
164
|
-
* an operation.
|
|
165
|
-
* The operation will receive a slice of the data based of each item
|
|
166
|
-
* of the JSONPath provided.
|
|
167
|
-
*
|
|
168
|
-
* It also ensures the results of an operation make their way back into
|
|
169
|
-
* the state's references.
|
|
170
|
-
* @example
|
|
171
|
-
* each("$.[*]",
|
|
172
|
-
* create("SObject",
|
|
173
|
-
* field("FirstName", sourceValue("$.firstName")))
|
|
174
|
-
* )
|
|
175
|
-
* @param dataSource - JSONPath referencing a point in `state`.
|
|
176
|
-
* @param operation - The operation needed to be repeated.
|
|
177
|
-
*/
|
|
178
|
-
export function each(dataSource: DataSource, operation: Operation): Operation;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
declare interface Cancel {
|
|
182
|
-
message: string;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
declare interface Canceler {
|
|
186
|
-
(message?: string): void;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
declare interface CancelStatic {
|
|
190
|
-
new (message?: string): Cancel;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
declare interface CancelToken {
|
|
194
|
-
promise: Promise<Cancel>;
|
|
195
|
-
reason?: Cancel;
|
|
196
|
-
throwIfRequested(): void;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
declare interface CancelTokenSource {
|
|
200
|
-
token: CancelToken;
|
|
201
|
-
cancel: Canceler;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
declare interface CancelTokenStatic {
|
|
205
|
-
new (executor: (cancel: Canceler) => void): CancelToken;
|
|
206
|
-
source(): CancelTokenSource;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Chunks an array into an array of arrays, each with no more than a certain size.
|
|
211
|
-
* @public
|
|
212
|
-
* @example
|
|
213
|
-
* chunk([1,2,3,4,5], 2)
|
|
214
|
-
* @function
|
|
215
|
-
* @param {Object} array - Array to be chunked
|
|
216
|
-
* @param {Integer} chunkSize - The maxiumum size of each chunks
|
|
217
|
-
*/
|
|
218
|
-
export declare function chunk(array: any[], chunkSize: number): any[][];
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Combines two operations into one
|
|
222
|
-
* @example
|
|
223
|
-
* combine(
|
|
224
|
-
* create('foo'),
|
|
225
|
-
* delete('bar')
|
|
226
|
-
* )
|
|
227
|
-
* @function
|
|
228
|
-
* @param operations - Operations to be performed.
|
|
229
|
-
*/
|
|
230
|
-
export declare function combine(...operations: Array<Operation>): Operation;
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Prepares next state
|
|
234
|
-
* @example
|
|
235
|
-
* composeNextState(state, response)
|
|
236
|
-
* @param state - state
|
|
237
|
-
* @param response - Response to be added
|
|
238
|
-
*/
|
|
239
|
-
export declare function composeNextState(state: State, response: any): State;
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Remove prepending `$.`, `$` or `.`, in order to ensure the root of the
|
|
243
|
-
* path starts with `$.data.`
|
|
244
|
-
* @example
|
|
245
|
-
* dataPath('key')
|
|
246
|
-
* @param path - JSONPath referencing a point in `data`.
|
|
247
|
-
*/
|
|
248
|
-
export declare function dataPath(path: string): string;
|
|
249
|
-
|
|
250
|
-
export declare type DataSource = object | string | Selector<object | string>;
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Picks out a single value from the source data object—usually `state.data`.
|
|
254
|
-
* If a JSONPath returns more than one value for the reference, the first
|
|
255
|
-
* item will be returned.
|
|
256
|
-
* @example
|
|
257
|
-
* dataValue('key')
|
|
258
|
-
* @param path - JSONPath referencing a point in `data`.
|
|
259
|
-
*/
|
|
260
|
-
export declare function dataValue(path: string): Selector<(Object | String)[]>;
|
|
261
|
-
|
|
262
|
-
declare namespace dateFns {
|
|
263
|
-
export {
|
|
264
|
-
parse,
|
|
265
|
-
format
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
export { dateFns }
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Make a DELETE request
|
|
272
|
-
* @public
|
|
273
|
-
* @function
|
|
274
|
-
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
275
|
-
* @example <caption>Deleting a record with data that comes from state</caption>
|
|
276
|
-
* delete({
|
|
277
|
-
* url: state => `https://www.example.com/api/items/${state.id}`,
|
|
278
|
-
* })(state);
|
|
279
|
-
* @returns {Operation} - Function which takes state and returns a Promise
|
|
280
|
-
*/
|
|
281
|
-
declare function del(requestParams: any): (state: any) => AxiosPromise<any>;
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Scopes an array of data based on a JSONPath.
|
|
285
|
-
* Useful when the source data has `n` items you would like to map to
|
|
286
|
-
* an operation.
|
|
287
|
-
* The operation will receive a slice of the data based of each item
|
|
288
|
-
* of the JSONPath provided.
|
|
289
|
-
*
|
|
290
|
-
* It also ensures the results of an operation make their way back into
|
|
291
|
-
* the state's references.
|
|
292
|
-
* @example
|
|
293
|
-
* each("$.[*]",
|
|
294
|
-
* create("SObject",
|
|
295
|
-
* field("FirstName", sourceValue("$.firstName"))
|
|
296
|
-
* )
|
|
297
|
-
* )
|
|
298
|
-
* @param dataSource - JSONPath referencing a point in `state`.
|
|
299
|
-
* @param operation - The operation needed to be repeated.
|
|
300
|
-
*/
|
|
301
|
-
export declare function each(dataSource: DataSource, operation: Function): Operation;
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Execute a sequence of operations.
|
|
305
|
-
* Main outer API for executing expressions.
|
|
306
|
-
* @example
|
|
307
|
-
* execute(
|
|
308
|
-
* create('foo'),
|
|
309
|
-
* delete('bar')
|
|
310
|
-
* )
|
|
311
|
-
*/
|
|
312
|
-
export declare function execute(...operations: Array<Operation>): Operation;
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Recursively resolves objects that have resolvable values (functions).
|
|
316
|
-
* @function
|
|
317
|
-
* @param value - data
|
|
318
|
-
* @param [skipFilter] - a function which returns true if a value should be skipped
|
|
319
|
-
*/
|
|
320
|
-
export declare function expandReferences(value: any[] | object | Function, skipFilter?: (val: any) => Boolean): Selector<any>;
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Recursively resolves objects that have resolvable values (functions), but
|
|
324
|
-
* omits HTTP request specific modules like `FormData`.
|
|
325
|
-
* @public
|
|
326
|
-
* @function
|
|
327
|
-
* @param {object} value - data
|
|
328
|
-
* @returns {<Operation>}
|
|
329
|
-
*/
|
|
330
|
-
declare function expandRequestReferences(params: any): (state: any) => any;
|
|
331
|
-
|
|
332
|
-
export declare type Field = [string, string | object | any[]];
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Returns a key, value pair in an array.
|
|
336
|
-
* @example
|
|
337
|
-
* field('destination_field_name__c', 'value')
|
|
338
|
-
* @param key - Name of the field
|
|
339
|
-
* @param value - The value itself or a sourceable operation.
|
|
340
|
-
*/
|
|
341
|
-
export declare function field(key: string, value: any): Field;
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Zips key value pairs into an object.
|
|
345
|
-
* @example
|
|
346
|
-
* fields(list_of_fields)
|
|
347
|
-
* @param fields - a list of fields
|
|
348
|
-
*/
|
|
349
|
-
export declare function fields(...fields: Field[]): object;
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Creates a custom step (or operation) for more flexible job writing.
|
|
353
|
-
* @example
|
|
354
|
-
* fn(state => {
|
|
355
|
-
* // do some things to state
|
|
356
|
-
* return state;
|
|
357
|
-
* });
|
|
358
|
-
*/
|
|
359
|
-
export declare function fn(func: Operation): Operation;
|
|
360
|
-
|
|
361
|
-
declare function format(...parameters: formatParams): string;
|
|
362
|
-
|
|
363
|
-
declare type formatParams = [
|
|
364
|
-
date: Date | number,
|
|
365
|
-
format: string,
|
|
366
|
-
options?: {
|
|
367
|
-
locale?: Locale;
|
|
368
|
-
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
369
|
-
firstWeekContainsDate?: number;
|
|
370
|
-
useAdditionalWeekYearTokens?: boolean;
|
|
371
|
-
useAdditionalDayOfYearTokens?: boolean;
|
|
372
|
-
}
|
|
373
|
-
];
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Make a GET request
|
|
377
|
-
* @public
|
|
378
|
-
* @function
|
|
379
|
-
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
380
|
-
* @returns {Operation} - Function which takes state and returns a Promise
|
|
381
|
-
* @example <caption>Get an item with a specified id from state</caption>
|
|
382
|
-
* get({
|
|
383
|
-
* url: state => `https://www.example.com/api/items/${state.id},
|
|
384
|
-
* headers: {"content-type": "application/json"}
|
|
385
|
-
* });
|
|
386
|
-
*/
|
|
387
|
-
declare function get(requestParams: any): (state: State) => AxiosPromise<any>;
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Make a HEAD request
|
|
391
|
-
* @public
|
|
392
|
-
* @function
|
|
393
|
-
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
394
|
-
* @example <caption>Gets the headers that would be returned if the HEAD request's URL was instead requested with the HTTP GET method</caption>
|
|
395
|
-
* head({
|
|
396
|
-
* url: 'https://www.example.com/api/items',
|
|
397
|
-
* });
|
|
398
|
-
* @returns {Operation} - Function which takes state and returns a Promise
|
|
399
|
-
*/
|
|
400
|
-
declare function head(requestParams: any): (state: any) => AxiosPromise<any>;
|
|
401
|
-
|
|
402
|
-
declare namespace http {
|
|
403
|
-
export {
|
|
404
|
-
expandRequestReferences,
|
|
405
|
-
get,
|
|
406
|
-
post,
|
|
407
|
-
head,
|
|
408
|
-
put,
|
|
409
|
-
patch,
|
|
410
|
-
options,
|
|
411
|
-
axios,
|
|
412
|
-
del as delete
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
export { http }
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* Subsitutes underscores for spaces and proper-cases a string
|
|
419
|
-
* @public
|
|
420
|
-
* @example
|
|
421
|
-
* field("destination_string__c", humanProper(state.data.path_to_string))
|
|
422
|
-
* @function
|
|
423
|
-
* @param str - String that needs converting
|
|
424
|
-
*/
|
|
425
|
-
export declare function humanProper(str: string): string;
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Returns the index of the current array being iterated.
|
|
429
|
-
* To be used with `each` as a data source.
|
|
430
|
-
* @example
|
|
431
|
-
* index()
|
|
432
|
-
*/
|
|
433
|
-
export declare function index(): Selector<number | undefined>;
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Adds data from a target object
|
|
437
|
-
* @example
|
|
438
|
-
* join('$.key','$.data','newKey')
|
|
439
|
-
* @function
|
|
440
|
-
* @param targetPath - Target path
|
|
441
|
-
* @param sourcePath - Source path
|
|
442
|
-
* @param targetKey - Target Key
|
|
443
|
-
*/
|
|
444
|
-
export declare function join(targetPath: string, sourcePath: string, targetKey: string): Operation;
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Picks out a single value from a JSON object.
|
|
448
|
-
* If a JSONPath returns more than one value for the reference, the first
|
|
449
|
-
* item will be returned.
|
|
450
|
-
* @public
|
|
451
|
-
* @example
|
|
452
|
-
* jsonValue({ a:1 }, 'a')
|
|
453
|
-
* @function
|
|
454
|
-
* @param {object} obj - A valid JSON object.
|
|
455
|
-
* @param {String} path - JSONPath referencing a point in given JSON object.
|
|
456
|
-
*/
|
|
457
|
-
export declare function jsonValue(obj: {}, path: string): Array<String | Object>;
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* Picks out the last reference value from source data.
|
|
461
|
-
* @example
|
|
462
|
-
* lastReferenceValue('key')
|
|
463
|
-
* @param path - JSONPath referencing a point in `references`.
|
|
464
|
-
*/
|
|
465
|
-
export declare function lastReferenceValue(path: string): Selector<(Object | String)[]>;
|
|
466
|
-
|
|
467
|
-
declare type Locale = {
|
|
468
|
-
code?: string;
|
|
469
|
-
formatDistance?: (...args: Array<any>) => any;
|
|
470
|
-
formatRelative?: (...args: Array<any>) => any;
|
|
471
|
-
localize?: {
|
|
472
|
-
ordinalNumber: (...args: Array<any>) => any;
|
|
473
|
-
era: (...args: Array<any>) => any;
|
|
474
|
-
quarter: (...args: Array<any>) => any;
|
|
475
|
-
month: (...args: Array<any>) => any;
|
|
476
|
-
day: (...args: Array<any>) => any;
|
|
477
|
-
dayPeriod: (...args: Array<any>) => any;
|
|
478
|
-
};
|
|
479
|
-
formatLong?: {
|
|
480
|
-
date: (...args: Array<any>) => any;
|
|
481
|
-
time: (...args: Array<any>) => any;
|
|
482
|
-
dateTime: (...args: Array<any>) => any;
|
|
483
|
-
};
|
|
484
|
-
match?: {
|
|
485
|
-
ordinalNumber: (...args: Array<any>) => any;
|
|
486
|
-
era: (...args: Array<any>) => any;
|
|
487
|
-
quarter: (...args: Array<any>) => any;
|
|
488
|
-
month: (...args: Array<any>) => any;
|
|
489
|
-
day: (...args: Array<any>) => any;
|
|
490
|
-
dayPeriod: (...args: Array<any>) => any;
|
|
491
|
-
};
|
|
492
|
-
options?: {
|
|
493
|
-
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
494
|
-
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
495
|
-
};
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* Merges fields into each item in an array.
|
|
500
|
-
* @public
|
|
501
|
-
* @example
|
|
502
|
-
* merge(
|
|
503
|
-
* "$.books[*]",
|
|
504
|
-
* fields(
|
|
505
|
-
* field( "publisher", sourceValue("$.publisher") )
|
|
506
|
-
* )
|
|
507
|
-
* )
|
|
508
|
-
* @param dataSource
|
|
509
|
-
* @param {Object} fields - Group of fields to merge in.
|
|
510
|
-
* @returns {DataSource}
|
|
511
|
-
*/
|
|
512
|
-
export declare function merge(dataSource: string, fields: object): Operation;
|
|
513
|
-
|
|
514
|
-
declare type Method =
|
|
515
|
-
| 'get' | 'GET'
|
|
516
|
-
| 'delete' | 'DELETE'
|
|
517
|
-
| 'head' | 'HEAD'
|
|
518
|
-
| 'options' | 'OPTIONS'
|
|
519
|
-
| 'post' | 'POST'
|
|
520
|
-
| 'put' | 'PUT'
|
|
521
|
-
| 'patch' | 'PATCH'
|
|
522
|
-
| 'purge' | 'PURGE'
|
|
523
|
-
| 'link' | 'LINK'
|
|
524
|
-
| 'unlink' | 'UNLINK'
|
|
525
|
-
|
|
526
|
-
export declare interface Operation<T = Promise<State> | State> {
|
|
527
|
-
(state: State): T;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* Make a OPTIONS request
|
|
532
|
-
* @public
|
|
533
|
-
* @function
|
|
534
|
-
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
535
|
-
* @example <caption>Requests permitted communication options for a given URL or server, with data from state.</caption>
|
|
536
|
-
* options({
|
|
537
|
-
* url: 'https://www.example.com/api/items',
|
|
538
|
-
* });
|
|
539
|
-
* @returns {Operation} - Function which takes state and returns a Promise
|
|
540
|
-
*/
|
|
541
|
-
declare function options(requestParams: any): (state: any) => AxiosPromise<any>;
|
|
542
|
-
|
|
543
|
-
declare function parse(...parameters: parseParams): Date;
|
|
544
|
-
|
|
545
|
-
declare type parseParams = [
|
|
546
|
-
dateString: string,
|
|
547
|
-
formatString: string,
|
|
548
|
-
referenceDate: Date | number,
|
|
549
|
-
options?: {
|
|
550
|
-
locale?: Locale;
|
|
551
|
-
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
552
|
-
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
553
|
-
useAdditionalWeekYearTokens?: boolean;
|
|
554
|
-
useAdditionalDayOfYearTokens?: boolean;
|
|
555
|
-
}
|
|
556
|
-
];
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* Make a PATCH request
|
|
560
|
-
* @public
|
|
561
|
-
* @function
|
|
562
|
-
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
563
|
-
* @example <caption>Applies partial modifications to a resource, with data from state.</caption>
|
|
564
|
-
* patch({
|
|
565
|
-
* url: state => `https://www.example.com/api/items/${state.id}`,
|
|
566
|
-
* data: state => state.data
|
|
567
|
-
* });
|
|
568
|
-
* @returns {Operation} - Function which takes state and returns a Promise
|
|
569
|
-
*/
|
|
570
|
-
declare function patch(requestParams: any): (state: any) => AxiosPromise<any>;
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Make a POST request
|
|
574
|
-
* @public
|
|
575
|
-
* @function
|
|
576
|
-
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
577
|
-
* @example <caption>Sending a payload with data that comes from state</caption>
|
|
578
|
-
* post({
|
|
579
|
-
* url: "https://example.com",
|
|
580
|
-
* data: (state) => state.data
|
|
581
|
-
* });
|
|
582
|
-
* @example <caption> Capturing the response for later use in state </caption>
|
|
583
|
-
* alterState((state) => {
|
|
584
|
-
* return post({
|
|
585
|
-
* url: "https://example.com",
|
|
586
|
-
* data: (state) => state.data
|
|
587
|
-
* })(state).then(({response}) => {
|
|
588
|
-
* state.responseData = response.data
|
|
589
|
-
* })
|
|
590
|
-
* });
|
|
591
|
-
* @returns {Operation} - Function which takes state and returns a Promise
|
|
592
|
-
*/
|
|
593
|
-
declare function post(requestParams: any): (state: any) => AxiosPromise<any>;
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* Make a PUT request
|
|
597
|
-
* @public
|
|
598
|
-
* @function
|
|
599
|
-
* @param {object} requestParams - Supports the exact parameters as Axios. See {@link https://github.com/axios/axios#axios-api here}
|
|
600
|
-
* @example <caption>Creates a new resource or replaces a representation of the target resource with the request payload, with data from state.</caption>
|
|
601
|
-
* put({
|
|
602
|
-
* url: state => `https://www.example.com/api/items/${state.id}`,
|
|
603
|
-
* data: state => state.data
|
|
604
|
-
* });
|
|
605
|
-
* @returns {Operation} - Function which takes state and returns a Promise
|
|
606
|
-
*/
|
|
607
|
-
declare function put(requestParams: any): (state: any) => AxiosPromise<any>;
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* Ensures a path points at references.
|
|
611
|
-
* @example
|
|
612
|
-
* referencePath('key')
|
|
613
|
-
* @param path - JSONPath referencing a point in `references`.
|
|
614
|
-
*/
|
|
615
|
-
export declare function referencePath(path: string): string;
|
|
616
|
-
|
|
617
|
-
export declare interface Resolvable<T> {
|
|
618
|
-
(state: State): T;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
declare type ResponseType_2 =
|
|
622
|
-
| 'arraybuffer'
|
|
623
|
-
| 'blob'
|
|
624
|
-
| 'document'
|
|
625
|
-
| 'json'
|
|
626
|
-
| 'text'
|
|
627
|
-
| 'stream'
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Replaces emojis in a string.
|
|
631
|
-
* @public
|
|
632
|
-
* @example
|
|
633
|
-
* scrubEmojis('Dove🕊️⭐ 29')
|
|
634
|
-
* @function
|
|
635
|
-
* @param {string} text - String that needs to be cleaned
|
|
636
|
-
* @param {string} replacementChars - Characters that replace the emojis
|
|
637
|
-
* @returns {string}
|
|
638
|
-
*/
|
|
639
|
-
export declare function scrubEmojis(text: string, replacementChars: string): string;
|
|
640
|
-
|
|
641
|
-
export declare interface Selector<T> {
|
|
642
|
-
(state: State): T;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Picks out a value from source data.
|
|
647
|
-
* Will return whatever JSONPath returns, which will always be an array.
|
|
648
|
-
* If you need a single value use `sourceValue` instead.
|
|
649
|
-
* @example
|
|
650
|
-
* source('$.key')
|
|
651
|
-
* @param path - JSONPath referencing a point in `state`.
|
|
652
|
-
*/
|
|
653
|
-
export declare function source(path: string): Selector<Array<any>>;
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* Picks out a single value from source data.
|
|
657
|
-
* If a JSONPath returns more than one value for the reference, the first
|
|
658
|
-
* item will be returned.
|
|
659
|
-
* @example
|
|
660
|
-
* sourceValue('$.key')
|
|
661
|
-
* @param path - JSONPath referencing a point in `state`.
|
|
662
|
-
*/
|
|
663
|
-
export declare function sourceValue(path: string): Selector<Array<String | Object>>;
|
|
664
|
-
|
|
665
|
-
export declare function splitKeys(obj: object, keys: string[]): {}[];
|
|
666
|
-
|
|
667
|
-
export declare interface State {
|
|
668
|
-
configuration: object;
|
|
669
|
-
data: object;
|
|
670
|
-
references?: Array<any>;
|
|
671
|
-
index?: number;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
/**
|
|
675
|
-
* Ensures primitive data types are wrapped in an array.
|
|
676
|
-
* Does not affect array objects.
|
|
677
|
-
* @example
|
|
678
|
-
* each(function(state) {
|
|
679
|
-
* return toArray( dataValue("path_of_array")(state) )
|
|
680
|
-
* }, ...)
|
|
681
|
-
* @param arg - Data required to be in an array
|
|
682
|
-
*/
|
|
683
|
-
export declare function toArray<T>(arg: T): T[];
|
|
684
|
-
|
|
685
|
-
export { }
|