@segment/actions-core 2.0.3-next.0 → 2.1.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 +7 -37
- package/dist/cjs/destination-kit/action.js +28 -52
- package/dist/cjs/destination-kit/action.js.map +1 -1
- package/dist/cjs/destination-kit/fields-to-jsonschema.js +80 -12
- 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 +13 -8
- 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 +31 -9
- package/dist/cjs/errors.d.ts +15 -5
- package/dist/cjs/errors.js +22 -8
- package/dist/cjs/errors.js.map +1 -1
- 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/index.d.ts +2 -2
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/map-values.d.ts +1 -5
- 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 +4 -48
- 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 +7 -37
- package/dist/esm/destination-kit/action.js +28 -52
- package/dist/esm/destination-kit/action.js.map +1 -1
- package/dist/esm/destination-kit/fields-to-jsonschema.js +80 -12
- 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 +12 -7
- 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 +31 -9
- package/dist/esm/errors.d.ts +15 -5
- package/dist/esm/errors.js +18 -6
- package/dist/esm/errors.js.map +1 -1
- 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/index.d.ts +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/map-values.d.ts +1 -5
- 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 +4 -48
- 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 +16 -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
|
@@ -33,7 +33,6 @@ function realTypeOrDirective(value) {
|
|
|
33
33
|
}
|
|
34
34
|
const directives = {};
|
|
35
35
|
function validateDirective(obj, stack = []) {
|
|
36
|
-
// "allow" non-directive objects so that we can throw a more descriptive error below
|
|
37
36
|
if (!is_directive_1.isDirective(obj) && !real_type_of_1.isObject(obj)) {
|
|
38
37
|
const type = real_type_of_1.realTypeOf(obj);
|
|
39
38
|
throw new ValidationError(`should be a directive object but it is ${indefiniteArticle(type)} ${type}`, stack);
|
|
@@ -43,7 +42,6 @@ function validateDirective(obj, stack = []) {
|
|
|
43
42
|
if (directiveKeys.length > 1) {
|
|
44
43
|
throw new ValidationError(`should only have one @-prefixed key but it has ${directiveKeys.length} keys`, stack);
|
|
45
44
|
}
|
|
46
|
-
// Check that there aren't other keys besides @directive or _metadata
|
|
47
45
|
const otherKeys = keys.filter((key) => !key.startsWith('@') && key !== '_metadata');
|
|
48
46
|
if (otherKeys.length > 0) {
|
|
49
47
|
throw new ValidationError(`should only have one @-prefixed key but it has ${keys.length} keys`, stack);
|
|
@@ -82,28 +80,6 @@ function validateDirectiveOrString(v, stack = []) {
|
|
|
82
80
|
throw new ValidationError(`should be a string or a mapping directive but it is ${indefiniteArticle(type)} ${type}`, stack);
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
|
-
function validateDirectiveOrObject(v, stack = []) {
|
|
86
|
-
const type = realTypeOrDirective(v);
|
|
87
|
-
switch (type) {
|
|
88
|
-
case 'directive':
|
|
89
|
-
return validateDirective(v, stack);
|
|
90
|
-
case 'object':
|
|
91
|
-
return validateObject(v, stack);
|
|
92
|
-
default:
|
|
93
|
-
throw new ValidationError(`should be a mapping directive or an object but it is ${indefiniteArticle(type)} ${type}`, stack);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function validateDirectiveOrArray(v, stack = []) {
|
|
97
|
-
const type = realTypeOrDirective(v);
|
|
98
|
-
switch (type) {
|
|
99
|
-
case 'directive':
|
|
100
|
-
return validateDirective(v, stack);
|
|
101
|
-
case 'array':
|
|
102
|
-
return validateArray(v, stack);
|
|
103
|
-
default:
|
|
104
|
-
throw new ValidationError(`should be a mapping directive or an array but it is ${indefiniteArticle(type)} ${type}`, stack);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
83
|
function validateObject(value, stack = []) {
|
|
108
84
|
const type = realTypeOrDirective(value);
|
|
109
85
|
if (type !== 'object') {
|
|
@@ -178,9 +154,6 @@ function directive(names, fn) {
|
|
|
178
154
|
};
|
|
179
155
|
});
|
|
180
156
|
}
|
|
181
|
-
directive('@base64', (v, stack) => {
|
|
182
|
-
validateDirectiveOrString(v, stack);
|
|
183
|
-
});
|
|
184
157
|
directive('@if', (v, stack) => {
|
|
185
158
|
validateObjectWithFields(v, {
|
|
186
159
|
exists: { optional: validateDirectiveOrRaw },
|
|
@@ -189,68 +162,12 @@ directive('@if', (v, stack) => {
|
|
|
189
162
|
else: { optional: validateDirectiveOrRaw }
|
|
190
163
|
}, stack);
|
|
191
164
|
});
|
|
192
|
-
directive('@json', (v, stack) => {
|
|
193
|
-
validateDirectiveOrRaw(v, stack);
|
|
194
|
-
});
|
|
195
|
-
directive('@lowercase', (v, stack) => {
|
|
196
|
-
validateDirectiveOrString(v, stack);
|
|
197
|
-
});
|
|
198
|
-
directive('@merge', (v, stack = []) => {
|
|
199
|
-
validateArray(v, stack);
|
|
200
|
-
const arr = v;
|
|
201
|
-
const errors = [];
|
|
202
|
-
arr.forEach((obj, i) => {
|
|
203
|
-
try {
|
|
204
|
-
validateDirectiveOrObject(obj, [...stack, `${i}`]);
|
|
205
|
-
}
|
|
206
|
-
catch (error) {
|
|
207
|
-
errors.push(error);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
if (errors.length) {
|
|
211
|
-
throw new aggregate_error_1.default(errors);
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
directive(['@omit', '@pick'], (v, stack = []) => {
|
|
215
|
-
validateObjectWithFields(v, {
|
|
216
|
-
object: { required: validateDirectiveOrObject },
|
|
217
|
-
fields: { required: validateDirectiveOrArray }
|
|
218
|
-
}, stack);
|
|
219
|
-
const obj = v;
|
|
220
|
-
if (Array.isArray(obj.fields)) {
|
|
221
|
-
const errors = [];
|
|
222
|
-
obj.fields.forEach((field, i) => {
|
|
223
|
-
try {
|
|
224
|
-
validateDirectiveOrString(field, [...stack, i.toString()]);
|
|
225
|
-
}
|
|
226
|
-
catch (error) {
|
|
227
|
-
errors.push(error);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
if (errors.length) {
|
|
231
|
-
throw new aggregate_error_1.default(errors);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
165
|
directive('@path', (v, stack) => {
|
|
236
166
|
validateDirectiveOrString(v, stack);
|
|
237
167
|
});
|
|
238
|
-
directive('@root', () => {
|
|
239
|
-
// no-op
|
|
240
|
-
});
|
|
241
168
|
directive('@template', (v, stack) => {
|
|
242
169
|
validateDirectiveOrString(v, stack);
|
|
243
170
|
});
|
|
244
|
-
directive('@timestamp', (v, stack) => {
|
|
245
|
-
validateObjectWithFields(v, {
|
|
246
|
-
format: { required: validateDirectiveOrString },
|
|
247
|
-
inputFormat: { optional: validateDirectiveOrString },
|
|
248
|
-
timestamp: { required: validateDirectiveOrString }
|
|
249
|
-
}, stack);
|
|
250
|
-
});
|
|
251
|
-
directive('@uuid', () => {
|
|
252
|
-
// no-op
|
|
253
|
-
});
|
|
254
171
|
function indefiniteArticle(s) {
|
|
255
172
|
switch (s.charAt(0)) {
|
|
256
173
|
case 'a':
|
|
@@ -272,7 +189,6 @@ function validate(mapping, stack = []) {
|
|
|
272
189
|
case 'array':
|
|
273
190
|
return validateArray(mapping, stack);
|
|
274
191
|
default:
|
|
275
|
-
// All other types are valid "raw" mappings
|
|
276
192
|
return null;
|
|
277
193
|
}
|
|
278
194
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/mapping-kit/validate.ts"],"names":[],"mappings":";;;;;AAAA,sEAA4C;AAC5C,qDAA6C;AAC7C,iDAA4C;AAC5C,kDAAkE;AAElE,MAAM,eAAgB,SAAQ,6BAAW;IACvC,YAAY,OAAe,EAAE,QAAkB,EAAE;QAC/C,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,CAAA;IAC1C,CAAC;CACF;AAED,SAAS,aAAa,CAAC,MAAe;IACpC,MAAM,MAAM,GAAY,EAAE,CAAA;IAE1B,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,IAAI,KAAK,YAAY,yBAAc,EAAE;YACnC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;SACtB;aAAM;YACL,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;SACnB;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,MAAM,IAAI,GAAG,yBAAU,CAAC,KAAK,CAAC,CAAA;IAC9B,IAAI,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE;QACpF,OAAO,WAAW,CAAA;KACnB;IACD,OAAO,IAA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vC,KAAK,OAAO;YACV,OAAO,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACtC;YAEE,OAAO,IAAI,CAAA;KACd;AACH,CAAC;AAZD,2BAYC"}
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const headersToObject = (headers) => {
|
|
4
4
|
const obj = {};
|
|
5
|
-
// @ts-ignore the types are wrong for Headers
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
7
5
|
for (const [key, value] of headers.entries()) {
|
|
8
6
|
obj[key] = value;
|
|
9
7
|
}
|
|
10
8
|
return obj;
|
|
11
9
|
};
|
|
12
10
|
const prepareHeaders = async (_request, _options, response) => {
|
|
13
|
-
// Adds `toJSON()` support for headers to get a plain object
|
|
14
11
|
Object.defineProperty(response.headers, 'toJSON', {
|
|
15
12
|
enumerable: false,
|
|
16
13
|
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,kBAAe,cAAc,CAAA"}
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const prepareResponse = async (_request, _options, response) => {
|
|
4
4
|
var _a;
|
|
5
5
|
const modifiedResponse = response;
|
|
6
|
-
// Clone the response before reading the body to avoid
|
|
7
|
-
// `TypeError: body used already` elsewhere
|
|
8
6
|
const clone = response.clone();
|
|
9
7
|
const content = await clone.text();
|
|
10
8
|
let data;
|
|
@@ -13,12 +11,10 @@ const prepareResponse = async (_request, _options, response) => {
|
|
|
13
11
|
data = JSON.parse(content);
|
|
14
12
|
}
|
|
15
13
|
else {
|
|
16
|
-
// TODO handle form urlencoded responses?
|
|
17
14
|
data = content;
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
17
|
catch (_error) {
|
|
21
|
-
// do nothing
|
|
22
18
|
}
|
|
23
19
|
modifiedResponse.content = content;
|
|
24
20
|
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,kBAAe,eAAe,CAAA"}
|
package/dist/cjs/omit.d.ts
CHANGED
package/dist/cjs/omit.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.omit = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Lightweight alternative to lodash.omit. Faster, and way less code.
|
|
6
|
-
*/
|
|
7
4
|
function omit(obj, keys) {
|
|
8
5
|
return Object.keys(obj).reduce((newObject, key) => {
|
|
9
6
|
if (keys.indexOf(key) === -1)
|
package/dist/cjs/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,SAAgB,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;AALD,oBAKC"}
|
|
@@ -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/cjs/real-type-of.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isString = exports.isArray = exports.isObject = exports.realTypeOf = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Gets the "true" type of an object, since JS `typeof` often returns `'object'`
|
|
6
|
-
* for arrays, date, regexp, and null
|
|
7
|
-
* @param obj - the object to get the real type of
|
|
8
|
-
*/
|
|
9
4
|
function realTypeOf(obj) {
|
|
10
5
|
return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();
|
|
11
6
|
}
|
|
@@ -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,SAAgB,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;AAbD,gCAaC;AAMD,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,UAAU,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAA;AACvC,CAAC;AAFD,4BAEC;AAED,SAAgB,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC;AAFD,0BAEC;AAED,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAA;AAClC,CAAC;AAFD,4BAEC"}
|
|
@@ -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;
|
|
@@ -26,18 +26,14 @@ exports.TimeoutError = exports.HTTPError = void 0;
|
|
|
26
26
|
const abort_controller_1 = __importDefault(require("abort-controller"));
|
|
27
27
|
const ts_custom_error_1 = require("ts-custom-error");
|
|
28
28
|
const fetch_1 = __importStar(require("./fetch"));
|
|
29
|
-
const omit_1 = require("./omit");
|
|
30
29
|
const real_type_of_1 = require("./real-type-of");
|
|
31
|
-
// We need the loose definition of "object" to iterate over things like `[object Headers]`
|
|
32
30
|
const isObjectLike = (value) => {
|
|
33
31
|
return value !== null && typeof value === 'object';
|
|
34
32
|
};
|
|
35
|
-
/** Merges two sets of headers intelligently */
|
|
36
33
|
function mergeHeaders(source1, source2) {
|
|
37
34
|
const result = new fetch_1.Headers(source1 || {});
|
|
38
35
|
const source = new fetch_1.Headers(source2 || {});
|
|
39
36
|
source.forEach((value, key) => {
|
|
40
|
-
// `value` may be the string `undefined` when the source is a Headers object
|
|
41
37
|
if (value === 'undefined') {
|
|
42
38
|
result.delete(key);
|
|
43
39
|
}
|
|
@@ -47,9 +43,7 @@ function mergeHeaders(source1, source2) {
|
|
|
47
43
|
});
|
|
48
44
|
return result;
|
|
49
45
|
}
|
|
50
|
-
/** Deeply merge multiple objects or arrays. Arrays get concatenated. */
|
|
51
46
|
function merge(...sources) {
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
47
|
let result = {};
|
|
54
48
|
let headers = {};
|
|
55
49
|
for (const source of sources) {
|
|
@@ -57,32 +51,23 @@ function merge(...sources) {
|
|
|
57
51
|
if (!Array.isArray(result)) {
|
|
58
52
|
result = [];
|
|
59
53
|
}
|
|
60
|
-
// Concatenate arrays (e.g. hooks)
|
|
61
54
|
result = [...result, ...source];
|
|
62
55
|
}
|
|
63
56
|
else if (isObjectLike(source)) {
|
|
64
|
-
// eslint-disable-next-line prefer-const
|
|
65
57
|
for (let [key, value] of Object.entries(source)) {
|
|
66
|
-
// Recurse over objects
|
|
67
58
|
if (isObjectLike(value) && key in result) {
|
|
68
59
|
value = merge(result[key], value);
|
|
69
60
|
}
|
|
70
|
-
// Update the key's value in our copy
|
|
71
61
|
result[key] = value;
|
|
72
62
|
}
|
|
73
|
-
// Merge headers more carefully to handle duplicates
|
|
74
63
|
if (isObjectLike(source.headers)) {
|
|
75
64
|
headers = mergeHeaders(headers, source.headers);
|
|
76
65
|
}
|
|
77
66
|
}
|
|
78
|
-
// Assign after we've merged all the headers because they are handled specially
|
|
79
67
|
result.headers = headers;
|
|
80
68
|
}
|
|
81
69
|
return result;
|
|
82
70
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Validates and merges request options
|
|
85
|
-
*/
|
|
86
71
|
function mergeOptions(...sources) {
|
|
87
72
|
for (const source of sources) {
|
|
88
73
|
if (!real_type_of_1.isObject(source)) {
|
|
@@ -94,7 +79,6 @@ function mergeOptions(...sources) {
|
|
|
94
79
|
function getRequestMethod(method) {
|
|
95
80
|
return method.toUpperCase();
|
|
96
81
|
}
|
|
97
|
-
/** Error thrown when a response has a non-2xx response. */
|
|
98
82
|
class HTTPError extends ts_custom_error_1.CustomError {
|
|
99
83
|
constructor(response, request, options) {
|
|
100
84
|
var _a, _b;
|
|
@@ -105,7 +89,6 @@ class HTTPError extends ts_custom_error_1.CustomError {
|
|
|
105
89
|
}
|
|
106
90
|
}
|
|
107
91
|
exports.HTTPError = HTTPError;
|
|
108
|
-
/** Error thrown when a request is aborted because of a client timeout. */
|
|
109
92
|
class TimeoutError extends ts_custom_error_1.CustomError {
|
|
110
93
|
constructor(request, options) {
|
|
111
94
|
super(`Request timed out`);
|
|
@@ -114,9 +97,6 @@ class TimeoutError extends ts_custom_error_1.CustomError {
|
|
|
114
97
|
}
|
|
115
98
|
}
|
|
116
99
|
exports.TimeoutError = TimeoutError;
|
|
117
|
-
/**
|
|
118
|
-
* Given a request, reject the request when a timeout is exceeded
|
|
119
|
-
*/
|
|
120
100
|
function timeoutFetch(request, abortController, options) {
|
|
121
101
|
return new Promise((resolve, reject) => {
|
|
122
102
|
const timer = setTimeout(() => {
|
|
@@ -143,41 +123,24 @@ class RequestClient {
|
|
|
143
123
|
throwHttpErrors: options.throwHttpErrors !== false,
|
|
144
124
|
timeout: (_b = options.timeout) !== null && _b !== void 0 ? _b : 10000
|
|
145
125
|
};
|
|
146
|
-
// Timeout support. Use our own abort controller so consumers can pass in their own `signal`
|
|
147
|
-
// if they wish to use timeouts alongside other logic to abort a request
|
|
148
126
|
this.abortController = new abort_controller_1.default();
|
|
149
127
|
if (this.options.signal) {
|
|
150
|
-
// Listen to consumer abort events to also abort our internal controller
|
|
151
128
|
this.options.signal.addEventListener('abort', () => {
|
|
152
129
|
this.abortController.abort();
|
|
153
130
|
});
|
|
154
131
|
}
|
|
155
|
-
// Use our internal abort controller for fetch
|
|
156
132
|
this.options.signal = this.abortController.signal;
|
|
157
|
-
this.
|
|
158
|
-
'json',
|
|
159
|
-
'password',
|
|
160
|
-
'searchParams',
|
|
161
|
-
'throwHttpErrors',
|
|
162
|
-
'timeout',
|
|
163
|
-
'username'
|
|
164
|
-
]);
|
|
165
|
-
// Construct a request object to send to the Fetch API
|
|
166
|
-
this.request = new fetch_1.Request(url, this.cleanedOptions);
|
|
167
|
-
// Parse search params and merge them with the request URL
|
|
133
|
+
this.request = new fetch_1.Request(url, this.options);
|
|
168
134
|
if (this.options.searchParams) {
|
|
169
|
-
// The type is a bit too restrictive, since you can pass in other primitives like `{ foo: 1, bar: true }`
|
|
170
135
|
const searchParams = new URLSearchParams(this.options.searchParams);
|
|
171
136
|
const url = new URL(this.request.url);
|
|
172
137
|
url.search = searchParams.toString();
|
|
173
|
-
|
|
174
|
-
this.request = new fetch_1.Request(new fetch_1.Request(url.toString(), this.request), this.cleanedOptions);
|
|
138
|
+
this.request = new fetch_1.Request(new fetch_1.Request(url.toString(), this.request), this.options);
|
|
175
139
|
}
|
|
176
|
-
// Automatically handle json header + stringification as a convenience when using `json` option
|
|
177
140
|
if (this.options.json !== undefined) {
|
|
178
|
-
this.
|
|
141
|
+
this.options.body = JSON.stringify(this.options.json);
|
|
179
142
|
this.request.headers.set('content-type', 'application/json');
|
|
180
|
-
this.request = new fetch_1.Request(this.request, { body: this.
|
|
143
|
+
this.request = new fetch_1.Request(this.request, { body: this.options.body });
|
|
181
144
|
}
|
|
182
145
|
}
|
|
183
146
|
async executeRequest() {
|
|
@@ -194,9 +157,6 @@ class RequestClient {
|
|
|
194
157
|
}
|
|
195
158
|
return response;
|
|
196
159
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Make a fetch request, running all beforeRequest hooks, and optionally wrap in a timeout
|
|
199
|
-
*/
|
|
200
160
|
async fetch() {
|
|
201
161
|
var _a;
|
|
202
162
|
for (const hook of (_a = this.options.beforeRequest) !== null && _a !== void 0 ? _a : []) {
|
|
@@ -211,10 +171,6 @@ class RequestClient {
|
|
|
211
171
|
return timeoutFetch(this.request.clone(), this.abortController, this.options);
|
|
212
172
|
}
|
|
213
173
|
}
|
|
214
|
-
/**
|
|
215
|
-
* Creates a new instance of the fetch request client,
|
|
216
|
-
* optionally with default configuration to apply to all requests made with the client
|
|
217
|
-
*/
|
|
218
174
|
function createInstance(defaults = {}) {
|
|
219
175
|
const client = (url, options = {}) => new RequestClient(url, mergeOptions(defaults, options)).executeRequest();
|
|
220
176
|
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,wEAA8C;AAC9C,qDAA6C;AAC7C,iDAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"request-client.js","sourceRoot":"","sources":["../../src/request-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wEAA8C;AAC9C,qDAA6C;AAC7C,iDAA2D;AAC3D,iDAAyC;AAmFzC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAuC,EAAE;IAC3E,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAA;AACpD,CAAC,CAAA;AAGD,SAAS,YAAY,CAAC,OAA+B,EAAE,OAA+B;IACpF,MAAM,MAAM,GAAG,IAAI,eAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;IACzC,MAAM,MAAM,GAAG,IAAI,eAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;IAEzC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAE5B,IAAI,KAAK,KAAK,W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CAAC;IAKO,KAAK,CAAC,KAAK;;QACjB,KAAK,MAAM,IAAI,IAAI,MAAA,IAAI,CAAC,OAAO,CAAC,aAAa,mCAAI,EAAE,EAAE;YACnD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;YAClD,IAAI,UAAU,IAAI,uBAAQ,CAAC,UAAU,CAAC,EAAE;gBACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;aAC1E;SACF;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,KAAK,EAAE;YAClC,OAAO,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;SACnC;QAED,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IAC/E,CAAC;CACF;AAMD,SAAwB,cAAc,CAAC,WAA8B,EAAE;IACrE,MAAM,MAAM,GAAG,CAAgC,GAAW,EAAE,UAA0B,EAAE,EAAE,EAAE,CAC1F,IAAI,aAAa,CAAC,GAAG,EAAE,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc,EAAK,CAAA;IAC7E,MAAM,CAAC,MAAM,GAAG,CAAC,WAA8B,EAAE,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAA;IACvG,OAAO,MAAM,CAAA;AACf,CAAC;AALD,iCAKC"}
|
|
@@ -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/cjs/time.d.ts
CHANGED