@segment/actions-core 2.0.2 → 2.1.0-next.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/cjs/create-request-client.d.ts +0 -3
- package/dist/cjs/create-request-client.js +0 -7
- package/dist/cjs/create-request-client.js.map +1 -1
- package/dist/cjs/create-test-event.js +1 -1
- package/dist/cjs/create-test-event.js.map +1 -1
- package/dist/cjs/create-test-integration.d.ts +0 -19
- package/dist/cjs/create-test-integration.js +0 -1
- package/dist/cjs/create-test-integration.js.map +1 -1
- package/dist/cjs/destination-kit/action.d.ts +0 -30
- package/dist/cjs/destination-kit/action.js +0 -38
- package/dist/cjs/destination-kit/action.js.map +1 -1
- package/dist/cjs/destination-kit/fields-to-jsonschema.js +0 -2
- package/dist/cjs/destination-kit/fields-to-jsonschema.js.map +1 -1
- package/dist/cjs/destination-kit/index.d.ts +0 -10
- package/dist/cjs/destination-kit/index.js +3 -6
- package/dist/cjs/destination-kit/index.js.map +1 -1
- package/dist/cjs/destination-kit/step.d.ts +0 -12
- package/dist/cjs/destination-kit/step.js +0 -7
- package/dist/cjs/destination-kit/step.js.map +1 -1
- package/dist/cjs/destination-kit/types.d.ts +0 -4
- package/dist/cjs/fetch.js +0 -1
- package/dist/cjs/fetch.js.map +1 -1
- package/dist/cjs/get.d.ts +0 -4
- package/dist/cjs/get.js +1 -11
- package/dist/cjs/get.js.map +1 -1
- package/dist/cjs/map-values.d.ts +0 -4
- package/dist/cjs/map-values.js +0 -5
- package/dist/cjs/map-values.js.map +1 -1
- package/dist/cjs/mapping-kit/index.d.ts +0 -6
- package/dist/cjs/mapping-kit/index.js +0 -87
- package/dist/cjs/mapping-kit/index.js.map +1 -1
- package/dist/cjs/mapping-kit/is-directive.js +0 -1
- package/dist/cjs/mapping-kit/is-directive.js.map +1 -1
- package/dist/cjs/mapping-kit/placeholders.d.ts +0 -3
- package/dist/cjs/mapping-kit/placeholders.js +0 -8
- package/dist/cjs/mapping-kit/placeholders.js.map +1 -1
- package/dist/cjs/mapping-kit/validate.js +0 -84
- package/dist/cjs/mapping-kit/validate.js.map +1 -1
- package/dist/cjs/middleware/after-response/prepare-headers.js +0 -3
- package/dist/cjs/middleware/after-response/prepare-headers.js.map +1 -1
- package/dist/cjs/middleware/after-response/prepare-response.js +0 -4
- package/dist/cjs/middleware/after-response/prepare-response.js.map +1 -1
- package/dist/cjs/omit.d.ts +0 -3
- package/dist/cjs/omit.js +0 -3
- package/dist/cjs/omit.js.map +1 -1
- package/dist/cjs/real-type-of.d.ts +0 -5
- package/dist/cjs/real-type-of.js +0 -5
- package/dist/cjs/real-type-of.js.map +1 -1
- package/dist/cjs/request-client.d.ts +0 -53
- package/dist/cjs/request-client.js +0 -35
- package/dist/cjs/request-client.js.map +1 -1
- package/dist/cjs/segment-event.d.ts +0 -40
- package/dist/cjs/time.d.ts +0 -6
- package/dist/cjs/time.js +0 -6
- package/dist/cjs/time.js.map +1 -1
- package/dist/cjs/types.d.ts +0 -4
- package/dist/esm/create-request-client.d.ts +0 -3
- package/dist/esm/create-request-client.js +0 -7
- package/dist/esm/create-request-client.js.map +1 -1
- package/dist/esm/create-test-event.js +1 -1
- package/dist/esm/create-test-event.js.map +1 -1
- package/dist/esm/create-test-integration.d.ts +0 -19
- package/dist/esm/create-test-integration.js +0 -1
- package/dist/esm/create-test-integration.js.map +1 -1
- package/dist/esm/destination-kit/action.d.ts +0 -30
- package/dist/esm/destination-kit/action.js +0 -38
- package/dist/esm/destination-kit/action.js.map +1 -1
- package/dist/esm/destination-kit/fields-to-jsonschema.js +0 -2
- package/dist/esm/destination-kit/fields-to-jsonschema.js.map +1 -1
- package/dist/esm/destination-kit/index.d.ts +0 -10
- package/dist/esm/destination-kit/index.js +3 -6
- package/dist/esm/destination-kit/index.js.map +1 -1
- package/dist/esm/destination-kit/step.d.ts +0 -12
- package/dist/esm/destination-kit/step.js +0 -7
- package/dist/esm/destination-kit/step.js.map +1 -1
- package/dist/esm/destination-kit/types.d.ts +0 -4
- package/dist/esm/fetch.js +0 -1
- package/dist/esm/fetch.js.map +1 -1
- package/dist/esm/get.d.ts +0 -4
- package/dist/esm/get.js +1 -11
- package/dist/esm/get.js.map +1 -1
- package/dist/esm/map-values.d.ts +0 -4
- package/dist/esm/map-values.js +0 -5
- package/dist/esm/map-values.js.map +1 -1
- package/dist/esm/mapping-kit/index.d.ts +0 -6
- package/dist/esm/mapping-kit/index.js +1 -88
- package/dist/esm/mapping-kit/index.js.map +1 -1
- package/dist/esm/mapping-kit/is-directive.js +0 -1
- package/dist/esm/mapping-kit/is-directive.js.map +1 -1
- package/dist/esm/mapping-kit/placeholders.d.ts +0 -3
- package/dist/esm/mapping-kit/placeholders.js +0 -8
- package/dist/esm/mapping-kit/placeholders.js.map +1 -1
- package/dist/esm/mapping-kit/validate.js +0 -84
- package/dist/esm/mapping-kit/validate.js.map +1 -1
- package/dist/esm/middleware/after-response/prepare-headers.js +0 -3
- package/dist/esm/middleware/after-response/prepare-headers.js.map +1 -1
- package/dist/esm/middleware/after-response/prepare-response.js +0 -4
- package/dist/esm/middleware/after-response/prepare-response.js.map +1 -1
- package/dist/esm/omit.d.ts +0 -3
- package/dist/esm/omit.js +0 -3
- package/dist/esm/omit.js.map +1 -1
- package/dist/esm/real-type-of.d.ts +0 -5
- package/dist/esm/real-type-of.js +0 -5
- package/dist/esm/real-type-of.js.map +1 -1
- package/dist/esm/request-client.d.ts +0 -53
- package/dist/esm/request-client.js +0 -35
- package/dist/esm/request-client.js.map +1 -1
- package/dist/esm/segment-event.d.ts +0 -40
- package/dist/esm/time.d.ts +0 -6
- package/dist/esm/time.js +0 -6
- package/dist/esm/time.js.map +1 -1
- package/dist/esm/types.d.ts +0 -4
- package/package.json +15 -11
- package/dist/cjs/dayjs.d.ts +0 -2
- package/dist/cjs/dayjs.js +0 -10
- package/dist/cjs/dayjs.js.map +0 -1
- package/dist/esm/dayjs.d.ts +0 -2
- package/dist/esm/dayjs.js +0 -5
- package/dist/esm/dayjs.js.map +0 -1
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
const headersToObject = (headers) => {
|
|
2
2
|
const obj = {};
|
|
3
|
-
// @ts-ignore the types are wrong for Headers
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
5
3
|
for (const [key, value] of headers.entries()) {
|
|
6
4
|
obj[key] = value;
|
|
7
5
|
}
|
|
8
6
|
return obj;
|
|
9
7
|
};
|
|
10
8
|
const prepareHeaders = async (_request, _options, response) => {
|
|
11
|
-
// Adds `toJSON()` support for headers to get a plain object
|
|
12
9
|
Object.defineProperty(response.headers, 'toJSON', {
|
|
13
10
|
enumerable: false,
|
|
14
11
|
value: () => headersToObject(response.headers)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-headers.js","sourceRoot":"","sources":["../../../../src/middleware/after-response/prepare-headers.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC3C,MAAM,GAAG,GAA2B,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"prepare-headers.js","sourceRoot":"","sources":["../../../../src/middleware/after-response/prepare-headers.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC3C,MAAM,GAAG,GAA2B,EAAE,CAAA;IAItC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE;QAC5C,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;KACjB;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,cAAc,GAAsB,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAE/E,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE;QAChD,UAAU,EAAE,KAAK;QACjB,KAAK,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC;KAC/C,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
const prepareResponse = async (_request, _options, response) => {
|
|
2
2
|
var _a;
|
|
3
3
|
const modifiedResponse = response;
|
|
4
|
-
// Clone the response before reading the body to avoid
|
|
5
|
-
// `TypeError: body used already` elsewhere
|
|
6
4
|
const clone = response.clone();
|
|
7
5
|
const content = await clone.text();
|
|
8
6
|
let data;
|
|
@@ -11,12 +9,10 @@ const prepareResponse = async (_request, _options, response) => {
|
|
|
11
9
|
data = JSON.parse(content);
|
|
12
10
|
}
|
|
13
11
|
else {
|
|
14
|
-
// TODO handle form urlencoded responses?
|
|
15
12
|
data = content;
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
15
|
catch (_error) {
|
|
19
|
-
// do nothing
|
|
20
16
|
}
|
|
21
17
|
modifiedResponse.content = content;
|
|
22
18
|
modifiedResponse.data = data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-response.js","sourceRoot":"","sources":["../../../../src/middleware/after-response/prepare-response.ts"],"names":[],"mappings":"AAGA,MAAM,eAAe,GAAsB,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;;IAChF,MAAM,gBAAgB,GAAG,QAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"prepare-response.js","sourceRoot":"","sources":["../../../../src/middleware/after-response/prepare-response.ts"],"names":[],"mappings":"AAGA,MAAM,eAAe,GAAsB,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;;IAChF,MAAM,gBAAgB,GAAG,QAA4B,CAAA;IAIrD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAA;IAC9B,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;IAClC,IAAI,IAAa,CAAA;IAEjB,IAAI;QACF,IAAI,MAAA,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,0CAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE;YAC9E,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;SAC3B;aAAM;YAEL,IAAI,GAAG,OAAO,CAAA;SACf;KACF;IAAC,OAAO,MAAM,EAAE;KAEhB;IAED,gBAAgB,CAAC,OAAO,GAAG,OAAO,CAAA;IAClC,gBAAgB,CAAC,IAAI,GAAG,IAAI,CAAA;IAE5B,OAAO,gBAAgB,CAAA;AACzB,CAAC,CAAA;AAED,eAAe,eAAe,CAAA"}
|
package/dist/esm/omit.d.ts
CHANGED
package/dist/esm/omit.js
CHANGED
package/dist/esm/omit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"omit.js","sourceRoot":"","sources":["../../src/omit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"omit.js","sourceRoot":"","sources":["../../src/omit.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,IAAI,CAAuC,GAAM,EAAE,IAAO;IACxE,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE;QAChD,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAAE,SAAS,CAAC,GAAG,CAAC,GAAI,GAA+B,CAAC,GAAG,CAAC,CAAA;QACpF,OAAO,SAAS,CAAA;IAClB,CAAC,EAAE,EAA6B,CAAqB,CAAA;AACvD,CAAC"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the "true" type of an object, since JS `typeof` often returns `'object'`
|
|
3
|
-
* for arrays, date, regexp, and null
|
|
4
|
-
* @param obj - the object to get the real type of
|
|
5
|
-
*/
|
|
6
1
|
export declare function realTypeOf(obj: unknown): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null" | "array" | "regexp";
|
|
7
2
|
export interface Dictionary<T = unknown> {
|
|
8
3
|
[key: string]: T;
|
package/dist/esm/real-type-of.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the "true" type of an object, since JS `typeof` often returns `'object'`
|
|
3
|
-
* for arrays, date, regexp, and null
|
|
4
|
-
* @param obj - the object to get the real type of
|
|
5
|
-
*/
|
|
6
1
|
export function realTypeOf(obj) {
|
|
7
2
|
return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();
|
|
8
3
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"real-type-of.js","sourceRoot":"","sources":["../../src/real-type-of.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"real-type-of.js","sourceRoot":"","sources":["../../src/real-type-of.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,UAAU,CAAC,GAAY;IACrC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAWvD,CAAA;AACd,CAAC;AAMD,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,UAAU,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAA;AAClC,CAAC"}
|
|
@@ -1,61 +1,16 @@
|
|
|
1
1
|
import { CustomError } from 'ts-custom-error';
|
|
2
|
-
/**
|
|
3
|
-
* The supported request options you can use with the request client
|
|
4
|
-
*/
|
|
5
2
|
export interface RequestOptions extends Omit<RequestInit, 'headers'> {
|
|
6
|
-
/**
|
|
7
|
-
* Simplified header format to reduce variation
|
|
8
|
-
*/
|
|
9
3
|
headers?: Record<string, string>;
|
|
10
|
-
/**
|
|
11
|
-
* Shortcut for sending JSON. Use instead of `body`.
|
|
12
|
-
* Accepts any plain object or value, which will be `JSON.stringify()`'d and sent in the body with the correct header set.
|
|
13
|
-
*/
|
|
14
4
|
json?: unknown;
|
|
15
|
-
/**
|
|
16
|
-
* HTTP method used to make the request.
|
|
17
|
-
* Internally, the standard methods (`GET`, `POST`, `PUT`, `PATCH`, `HEAD` and `DELETE`) are uppercased in order to avoid server errors due to case sensitivity.
|
|
18
|
-
* @default 'get'
|
|
19
|
-
*/
|
|
20
5
|
method?: 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';
|
|
21
|
-
/**
|
|
22
|
-
* When provided, will automatically apply basic authentication
|
|
23
|
-
*/
|
|
24
6
|
password?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Search parameters to include int he request URL. Setting this will override existing search parameters in the input URL.
|
|
27
|
-
* Accepts [`URLSearchParams()`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams)
|
|
28
|
-
*/
|
|
29
7
|
searchParams?: URLSearchParams | Record<string, string | number | boolean>;
|
|
30
|
-
/**
|
|
31
|
-
* Throw an error when, after redirects, the response has a non-2xx status code.
|
|
32
|
-
* @default true
|
|
33
|
-
*/
|
|
34
8
|
throwHttpErrors?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Timeout in milliseconds for getting a response.
|
|
37
|
-
* If set to `false` there will be no timeout.
|
|
38
|
-
* @default 10000
|
|
39
|
-
*/
|
|
40
9
|
timeout?: number | false;
|
|
41
|
-
/**
|
|
42
|
-
* When provided, will automatically apply basic authentication
|
|
43
|
-
*/
|
|
44
10
|
username?: string;
|
|
45
11
|
}
|
|
46
|
-
/**
|
|
47
|
-
* All request options including before/after hooks
|
|
48
|
-
*/
|
|
49
12
|
export interface AllRequestOptions extends RequestOptions {
|
|
50
|
-
/**
|
|
51
|
-
* Hooks that execute before a request is sent.
|
|
52
|
-
* Useful to modify the options that a request will use
|
|
53
|
-
*/
|
|
54
13
|
beforeRequest?: BeforeRequestHook[];
|
|
55
|
-
/**
|
|
56
|
-
* Hooks that executes after a response is received.
|
|
57
|
-
* Useful for logging, cleanup, or modifying the response object
|
|
58
|
-
*/
|
|
59
14
|
afterResponse?: AfterResponseHook[];
|
|
60
15
|
}
|
|
61
16
|
export interface NormalizedOptions extends Omit<AllRequestOptions, 'headers'> {
|
|
@@ -63,27 +18,19 @@ export interface NormalizedOptions extends Omit<AllRequestOptions, 'headers'> {
|
|
|
63
18
|
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';
|
|
64
19
|
}
|
|
65
20
|
declare type MaybePromise<T> = Promise<T> | T;
|
|
66
|
-
/** A hook that executes before a request is executed. Useful to modify the options that a request will use */
|
|
67
21
|
export declare type BeforeRequestHook = (options: NormalizedOptions) => MaybePromise<RequestOptions | void>;
|
|
68
|
-
/** A hook that executes after a response is received. Useful for logging, cleanup, or modifying the response object */
|
|
69
22
|
export declare type AfterResponseHook<OutputResponse extends Response = Response> = (request: Request, options: NormalizedOptions, response: Response) => MaybePromise<OutputResponse | void>;
|
|
70
|
-
/** Error thrown when a response has a non-2xx response. */
|
|
71
23
|
export declare class HTTPError extends CustomError {
|
|
72
24
|
request: Request;
|
|
73
25
|
response: Response;
|
|
74
26
|
options: NormalizedOptions;
|
|
75
27
|
constructor(response: Response, request: Request, options: NormalizedOptions);
|
|
76
28
|
}
|
|
77
|
-
/** Error thrown when a request is aborted because of a client timeout. */
|
|
78
29
|
export declare class TimeoutError extends CustomError {
|
|
79
30
|
request: Request;
|
|
80
31
|
options: NormalizedOptions;
|
|
81
32
|
constructor(request: Request, options: NormalizedOptions);
|
|
82
33
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Creates a new instance of the fetch request client,
|
|
85
|
-
* optionally with default configuration to apply to all requests made with the client
|
|
86
|
-
*/
|
|
87
34
|
export default function createInstance(defaults?: AllRequestOptions): {
|
|
88
35
|
<R extends Response = Response>(url: string, options?: RequestOptions): Promise<R>;
|
|
89
36
|
extend(newDefaults: AllRequestOptions): any;
|
|
@@ -2,16 +2,13 @@ import AbortController from 'abort-controller';
|
|
|
2
2
|
import { CustomError } from 'ts-custom-error';
|
|
3
3
|
import fetch, { Headers, Request, Response } from './fetch';
|
|
4
4
|
import { isObject } from './real-type-of';
|
|
5
|
-
// We need the loose definition of "object" to iterate over things like `[object Headers]`
|
|
6
5
|
const isObjectLike = (value) => {
|
|
7
6
|
return value !== null && typeof value === 'object';
|
|
8
7
|
};
|
|
9
|
-
/** Merges two sets of headers intelligently */
|
|
10
8
|
function mergeHeaders(source1, source2) {
|
|
11
9
|
const result = new Headers(source1 || {});
|
|
12
10
|
const source = new Headers(source2 || {});
|
|
13
11
|
source.forEach((value, key) => {
|
|
14
|
-
// `value` may be the string `undefined` when the source is a Headers object
|
|
15
12
|
if (value === 'undefined') {
|
|
16
13
|
result.delete(key);
|
|
17
14
|
}
|
|
@@ -21,9 +18,7 @@ function mergeHeaders(source1, source2) {
|
|
|
21
18
|
});
|
|
22
19
|
return result;
|
|
23
20
|
}
|
|
24
|
-
/** Deeply merge multiple objects or arrays. Arrays get concatenated. */
|
|
25
21
|
function merge(...sources) {
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
22
|
let result = {};
|
|
28
23
|
let headers = {};
|
|
29
24
|
for (const source of sources) {
|
|
@@ -31,32 +26,23 @@ function merge(...sources) {
|
|
|
31
26
|
if (!Array.isArray(result)) {
|
|
32
27
|
result = [];
|
|
33
28
|
}
|
|
34
|
-
// Concatenate arrays (e.g. hooks)
|
|
35
29
|
result = [...result, ...source];
|
|
36
30
|
}
|
|
37
31
|
else if (isObjectLike(source)) {
|
|
38
|
-
// eslint-disable-next-line prefer-const
|
|
39
32
|
for (let [key, value] of Object.entries(source)) {
|
|
40
|
-
// Recurse over objects
|
|
41
33
|
if (isObjectLike(value) && key in result) {
|
|
42
34
|
value = merge(result[key], value);
|
|
43
35
|
}
|
|
44
|
-
// Update the key's value in our copy
|
|
45
36
|
result[key] = value;
|
|
46
37
|
}
|
|
47
|
-
// Merge headers more carefully to handle duplicates
|
|
48
38
|
if (isObjectLike(source.headers)) {
|
|
49
39
|
headers = mergeHeaders(headers, source.headers);
|
|
50
40
|
}
|
|
51
41
|
}
|
|
52
|
-
// Assign after we've merged all the headers because they are handled specially
|
|
53
42
|
result.headers = headers;
|
|
54
43
|
}
|
|
55
44
|
return result;
|
|
56
45
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Validates and merges request options
|
|
59
|
-
*/
|
|
60
46
|
function mergeOptions(...sources) {
|
|
61
47
|
for (const source of sources) {
|
|
62
48
|
if (!isObject(source)) {
|
|
@@ -68,7 +54,6 @@ function mergeOptions(...sources) {
|
|
|
68
54
|
function getRequestMethod(method) {
|
|
69
55
|
return method.toUpperCase();
|
|
70
56
|
}
|
|
71
|
-
/** Error thrown when a response has a non-2xx response. */
|
|
72
57
|
export class HTTPError extends CustomError {
|
|
73
58
|
constructor(response, request, options) {
|
|
74
59
|
var _a, _b;
|
|
@@ -78,7 +63,6 @@ export class HTTPError extends CustomError {
|
|
|
78
63
|
this.options = options;
|
|
79
64
|
}
|
|
80
65
|
}
|
|
81
|
-
/** Error thrown when a request is aborted because of a client timeout. */
|
|
82
66
|
export class TimeoutError extends CustomError {
|
|
83
67
|
constructor(request, options) {
|
|
84
68
|
super(`Request timed out`);
|
|
@@ -86,9 +70,6 @@ export class TimeoutError extends CustomError {
|
|
|
86
70
|
this.options = options;
|
|
87
71
|
}
|
|
88
72
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Given a request, reject the request when a timeout is exceeded
|
|
91
|
-
*/
|
|
92
73
|
function timeoutFetch(request, abortController, options) {
|
|
93
74
|
return new Promise((resolve, reject) => {
|
|
94
75
|
const timer = setTimeout(() => {
|
|
@@ -115,29 +96,20 @@ class RequestClient {
|
|
|
115
96
|
throwHttpErrors: options.throwHttpErrors !== false,
|
|
116
97
|
timeout: (_b = options.timeout) !== null && _b !== void 0 ? _b : 10000
|
|
117
98
|
};
|
|
118
|
-
// Timeout support. Use our own abort controller so consumers can pass in their own `signal`
|
|
119
|
-
// if they wish to use timeouts alongside other logic to abort a request
|
|
120
99
|
this.abortController = new AbortController();
|
|
121
100
|
if (this.options.signal) {
|
|
122
|
-
// Listen to consumer abort events to also abort our internal controller
|
|
123
101
|
this.options.signal.addEventListener('abort', () => {
|
|
124
102
|
this.abortController.abort();
|
|
125
103
|
});
|
|
126
104
|
}
|
|
127
|
-
// Use our internal abort controller for fetch
|
|
128
105
|
this.options.signal = this.abortController.signal;
|
|
129
|
-
// Construct a request object to send to the Fetch API
|
|
130
106
|
this.request = new Request(url, this.options);
|
|
131
|
-
// Parse search params and merge them with the request URL
|
|
132
107
|
if (this.options.searchParams) {
|
|
133
|
-
// The type is a bit too restrictive, since you can pass in other primitives like `{ foo: 1, bar: true }`
|
|
134
108
|
const searchParams = new URLSearchParams(this.options.searchParams);
|
|
135
109
|
const url = new URL(this.request.url);
|
|
136
110
|
url.search = searchParams.toString();
|
|
137
|
-
// Update the request object with the new url including the search params
|
|
138
111
|
this.request = new Request(new Request(url.toString(), this.request), this.options);
|
|
139
112
|
}
|
|
140
|
-
// Automatically handle json header + stringification as a convenience when using `json` option
|
|
141
113
|
if (this.options.json !== undefined) {
|
|
142
114
|
this.options.body = JSON.stringify(this.options.json);
|
|
143
115
|
this.request.headers.set('content-type', 'application/json');
|
|
@@ -158,9 +130,6 @@ class RequestClient {
|
|
|
158
130
|
}
|
|
159
131
|
return response;
|
|
160
132
|
}
|
|
161
|
-
/**
|
|
162
|
-
* Make a fetch request, running all beforeRequest hooks, and optionally wrap in a timeout
|
|
163
|
-
*/
|
|
164
133
|
async fetch() {
|
|
165
134
|
var _a;
|
|
166
135
|
for (const hook of (_a = this.options.beforeRequest) !== null && _a !== void 0 ? _a : []) {
|
|
@@ -175,10 +144,6 @@ class RequestClient {
|
|
|
175
144
|
return timeoutFetch(this.request.clone(), this.abortController, this.options);
|
|
176
145
|
}
|
|
177
146
|
}
|
|
178
|
-
/**
|
|
179
|
-
* Creates a new instance of the fetch request client,
|
|
180
|
-
* optionally with default configuration to apply to all requests made with the client
|
|
181
|
-
*/
|
|
182
147
|
export default function createInstance(defaults = {}) {
|
|
183
148
|
const client = (url, options = {}) => new RequestClient(url, mergeOptions(defaults, options)).executeRequest();
|
|
184
149
|
client.extend = (newDefaults) => createInstance(mergeOptions(defaults, newDefaults));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-client.js","sourceRoot":"","sources":["../../src/request-client.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"request-client.js","sourceRoot":"","sources":["../../src/request-client.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAmFzC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAuC,EAAE;IAC3E,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAA;AACpD,CAAC,CAAA;AAGD,SAAS,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YAAY,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAA;IACvG,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -22,9 +22,6 @@ export declare type Options = {
|
|
|
22
22
|
};
|
|
23
23
|
interface AnalyticsContext {
|
|
24
24
|
page?: {
|
|
25
|
-
/**
|
|
26
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L151}
|
|
27
|
-
*/
|
|
28
25
|
path?: string;
|
|
29
26
|
referrer?: string;
|
|
30
27
|
search?: string;
|
|
@@ -32,54 +29,26 @@ interface AnalyticsContext {
|
|
|
32
29
|
url?: string;
|
|
33
30
|
};
|
|
34
31
|
metrics?: CompactMetric[];
|
|
35
|
-
/**
|
|
36
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L285}
|
|
37
|
-
*/
|
|
38
32
|
userAgent?: string;
|
|
39
|
-
/**
|
|
40
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L286-L289}
|
|
41
|
-
*/
|
|
42
33
|
locale?: string;
|
|
43
|
-
/**
|
|
44
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L290-L291}
|
|
45
|
-
*/
|
|
46
34
|
library?: {
|
|
47
35
|
name: string;
|
|
48
36
|
version: string;
|
|
49
37
|
};
|
|
50
|
-
/**
|
|
51
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L292-L301}
|
|
52
|
-
*/
|
|
53
38
|
traits?: {
|
|
54
39
|
crossDomainId: string;
|
|
55
40
|
};
|
|
56
|
-
/**
|
|
57
|
-
* utm params
|
|
58
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L303-L305}
|
|
59
|
-
* {@link https://github.com/segmentio/utm-params/blob/master/lib/index.js#L49}
|
|
60
|
-
*/
|
|
61
41
|
campaign?: {
|
|
62
|
-
/**
|
|
63
|
-
* This can also come from the "utm_campaign" param
|
|
64
|
-
*
|
|
65
|
-
* {@link https://github.com/segmentio/utm-params/blob/master/lib/index.js#L40}
|
|
66
|
-
*/
|
|
67
42
|
name: string;
|
|
68
43
|
term: string;
|
|
69
44
|
source: string;
|
|
70
45
|
medium: string;
|
|
71
46
|
content: string;
|
|
72
47
|
};
|
|
73
|
-
/**
|
|
74
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L415}
|
|
75
|
-
*/
|
|
76
48
|
referrer?: {
|
|
77
49
|
btid?: string;
|
|
78
50
|
urid?: string;
|
|
79
51
|
};
|
|
80
|
-
/**
|
|
81
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L322}
|
|
82
|
-
*/
|
|
83
52
|
amp?: {
|
|
84
53
|
id: string;
|
|
85
54
|
};
|
|
@@ -104,18 +73,9 @@ export interface SegmentEvent {
|
|
|
104
73
|
groupId?: ID;
|
|
105
74
|
previousId?: ID;
|
|
106
75
|
event?: string;
|
|
107
|
-
/**
|
|
108
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L284}
|
|
109
|
-
*/
|
|
110
76
|
writeKey?: string;
|
|
111
77
|
receivedAt?: Date | string;
|
|
112
|
-
/**
|
|
113
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L151}
|
|
114
|
-
*/
|
|
115
78
|
sentAt?: Date | string;
|
|
116
|
-
/**
|
|
117
|
-
* {@link https://github.com/segmentio/analytics.js-integrations/blob/2d5c637c022d2661c23449aed237d0d546bf062d/integrations/segmentio/lib/index.js#L311-L320}
|
|
118
|
-
*/
|
|
119
79
|
_metadata?: {
|
|
120
80
|
failedInitializations?: unknown[];
|
|
121
81
|
bundled?: string[];
|
package/dist/esm/time.d.ts
CHANGED
package/dist/esm/time.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets hrtime for logging/metrics.
|
|
3
|
-
*/
|
|
4
1
|
export function time() {
|
|
5
2
|
return process.hrtime.bigint();
|
|
6
3
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Calculates the duration in decimal milliseconds for logging/metrics purposes.
|
|
9
|
-
*/
|
|
10
4
|
export function duration(start, stop) {
|
|
11
5
|
return Number(stop - start) / 1000000;
|
|
12
6
|
}
|
package/dist/esm/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/time.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/time.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,IAAI;IAClB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA;AAChC,CAAC;AAKD,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,IAAY;IAClD,OAAO,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAA;AACvC,CAAC"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
/** A modified response object that is handled by the `prepareResponse` hook */
|
|
2
1
|
export interface ModifiedResponse<T = unknown> extends Response {
|
|
3
|
-
/** The raw response content as a string – same as `await response.text()` */
|
|
4
2
|
content: string;
|
|
5
|
-
/** The parsed content string into a JavaScript object, if applicable */
|
|
6
3
|
data: unknown extends T ? undefined | unknown : T;
|
|
7
|
-
/** The headers object with a shortcut method to get headers as an object */
|
|
8
4
|
headers: Headers & {
|
|
9
5
|
toJSON: () => Record<string, string>;
|
|
10
6
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segment/actions-core",
|
|
3
3
|
"description": "Core runtime for Destinations Actions.",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.1.0-next.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/fab-5-engine",
|
|
@@ -10,8 +10,14 @@
|
|
|
10
10
|
"main": "dist/cjs/index.js",
|
|
11
11
|
"module": "dist/esm/index.js",
|
|
12
12
|
"exports": {
|
|
13
|
-
".":
|
|
14
|
-
|
|
13
|
+
".": {
|
|
14
|
+
"require": "./dist/cjs/index.js",
|
|
15
|
+
"default": "./dist/esm/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./": {
|
|
18
|
+
"require": "./dist/cjs/",
|
|
19
|
+
"default": "./dist/esm/"
|
|
20
|
+
}
|
|
15
21
|
},
|
|
16
22
|
"types": "dist/esm/index.d.ts",
|
|
17
23
|
"files": [
|
|
@@ -40,13 +46,14 @@
|
|
|
40
46
|
"devDependencies": {
|
|
41
47
|
"@types/btoa-lite": "^1.0.0",
|
|
42
48
|
"@types/express": "^4.17.11",
|
|
43
|
-
"@types/jest": "^26.0.
|
|
49
|
+
"@types/jest": "^26.0.23",
|
|
44
50
|
"@types/json-schema": "^7.0.7",
|
|
45
|
-
"
|
|
51
|
+
"benny": "^3.6.15",
|
|
46
52
|
"create-test-server": "^3.0.1",
|
|
47
53
|
"jest": "^26.6.3"
|
|
48
54
|
},
|
|
49
55
|
"dependencies": {
|
|
56
|
+
"@lukeed/uuid": "^2.0.0",
|
|
50
57
|
"@segment/ajv-human-errors": "^1.1.0",
|
|
51
58
|
"@segment/fab5-subscriptions": "^2.0.1",
|
|
52
59
|
"abort-controller": "^3.0.0",
|
|
@@ -54,18 +61,15 @@
|
|
|
54
61
|
"ajv": "^6.12.4",
|
|
55
62
|
"btoa-lite": "^1.0.0",
|
|
56
63
|
"cross-fetch": "^3.1.4",
|
|
57
|
-
"dayjs": "^1.10.3",
|
|
58
64
|
"node-cache": "^5.1.2",
|
|
59
|
-
"ts-custom-error": "^3.2.0"
|
|
60
|
-
"uuid": "^8.3.2"
|
|
65
|
+
"ts-custom-error": "^3.2.0"
|
|
61
66
|
},
|
|
62
67
|
"jest": {
|
|
63
68
|
"preset": "ts-jest",
|
|
64
69
|
"testEnvironment": "node",
|
|
65
70
|
"modulePathIgnorePatterns": [
|
|
66
71
|
"<rootDir>/dist/"
|
|
67
|
-
]
|
|
68
|
-
"forceExit": true
|
|
72
|
+
]
|
|
69
73
|
},
|
|
70
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "b0aba4efd0098902397c8d07b2bddbfedf96a600"
|
|
71
75
|
}
|
package/dist/cjs/dayjs.d.ts
DELETED
package/dist/cjs/dayjs.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
7
|
-
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
8
|
-
dayjs_1.default.extend(utc_1.default);
|
|
9
|
-
exports.default = dayjs_1.default;
|
|
10
|
-
//# sourceMappingURL=dayjs.js.map
|
package/dist/cjs/dayjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dayjs.js","sourceRoot":"","sources":["../../src/dayjs.ts"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,2DAAkC;AAElC,eAAK,CAAC,MAAM,CAAC,aAAG,CAAC,CAAA;AAEjB,kBAAe,eAAK,CAAA"}
|
package/dist/esm/dayjs.d.ts
DELETED
package/dist/esm/dayjs.js
DELETED
package/dist/esm/dayjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dayjs.js","sourceRoot":"","sources":["../../src/dayjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,GAAG,MAAM,kBAAkB,CAAA;AAElC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAEjB,eAAe,KAAK,CAAA"}
|