@segment/actions-core 1.3.0-next.1 → 2.0.1

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.
Files changed (133) hide show
  1. package/dist/cjs/create-request-client.d.ts +4 -3
  2. package/dist/cjs/create-request-client.js +24 -14
  3. package/dist/cjs/create-request-client.js.map +1 -0
  4. package/dist/cjs/create-test-event.d.ts +2 -0
  5. package/dist/cjs/create-test-event.js +45 -0
  6. package/dist/cjs/create-test-event.js.map +1 -0
  7. package/dist/cjs/create-test-integration.d.ts +36 -0
  8. package/dist/cjs/create-test-integration.js +34 -0
  9. package/dist/cjs/create-test-integration.js.map +1 -0
  10. package/dist/cjs/dayjs.js +1 -1
  11. package/dist/cjs/dayjs.js.map +1 -0
  12. package/dist/cjs/defaults.js +1 -1
  13. package/dist/cjs/defaults.js.map +1 -0
  14. package/dist/cjs/destination-kit/action.d.ts +7 -5
  15. package/dist/cjs/destination-kit/action.js +27 -30
  16. package/dist/cjs/destination-kit/action.js.map +1 -0
  17. package/dist/cjs/destination-kit/fields-to-jsonschema.js +1 -1
  18. package/dist/cjs/destination-kit/fields-to-jsonschema.js.map +1 -0
  19. package/dist/cjs/destination-kit/index.d.ts +10 -5
  20. package/dist/cjs/destination-kit/index.js +6 -14
  21. package/dist/cjs/destination-kit/index.js.map +1 -0
  22. package/dist/cjs/destination-kit/step.d.ts +1 -1
  23. package/dist/cjs/destination-kit/step.js +1 -1
  24. package/dist/cjs/destination-kit/step.js.map +1 -0
  25. package/dist/cjs/destination-kit/types.d.ts +3 -19
  26. package/dist/cjs/destination-kit/types.js +1 -1
  27. package/dist/cjs/destination-kit/types.js.map +1 -0
  28. package/dist/cjs/errors.js +1 -1
  29. package/dist/cjs/errors.js.map +1 -0
  30. package/dist/cjs/fetch.d.ts +3 -0
  31. package/dist/cjs/fetch.js +29 -0
  32. package/dist/cjs/fetch.js.map +1 -0
  33. package/dist/cjs/get.js +1 -1
  34. package/dist/cjs/get.js.map +1 -0
  35. package/dist/cjs/index.d.ts +7 -2
  36. package/dist/cjs/index.js +16 -2
  37. package/dist/cjs/index.js.map +1 -0
  38. package/dist/cjs/json-object.js +1 -1
  39. package/dist/cjs/json-object.js.map +1 -0
  40. package/dist/cjs/map-values.d.ts +7 -0
  41. package/dist/cjs/map-values.js +16 -0
  42. package/dist/cjs/map-values.js.map +1 -0
  43. package/dist/cjs/mapping-kit/index.js +1 -1
  44. package/dist/cjs/mapping-kit/index.js.map +1 -0
  45. package/dist/cjs/mapping-kit/is-directive.js +1 -1
  46. package/dist/cjs/mapping-kit/is-directive.js.map +1 -0
  47. package/dist/cjs/mapping-kit/placeholders.js +1 -1
  48. package/dist/cjs/mapping-kit/placeholders.js.map +1 -0
  49. package/dist/cjs/mapping-kit/validate.js +1 -1
  50. package/dist/cjs/mapping-kit/validate.js.map +1 -0
  51. package/dist/cjs/middleware/add-basic-auth-header.d.ts +3 -0
  52. package/dist/cjs/middleware/add-basic-auth-header.js +21 -0
  53. package/dist/cjs/middleware/add-basic-auth-header.js.map +1 -0
  54. package/dist/cjs/omit.js +1 -1
  55. package/dist/cjs/omit.js.map +1 -0
  56. package/dist/cjs/real-type-of.js +1 -1
  57. package/dist/cjs/real-type-of.js.map +1 -0
  58. package/dist/cjs/remove-undefined.js +1 -1
  59. package/dist/cjs/remove-undefined.js.map +1 -0
  60. package/dist/cjs/request-client.d.ts +95 -0
  61. package/dist/cjs/request-client.js +227 -0
  62. package/dist/cjs/request-client.js.map +1 -0
  63. package/dist/cjs/segment-event.js +1 -1
  64. package/dist/cjs/segment-event.js.map +1 -0
  65. package/dist/cjs/time.js +1 -1
  66. package/dist/cjs/time.js.map +1 -0
  67. package/dist/esm/create-request-client.d.ts +4 -3
  68. package/dist/esm/create-request-client.js +24 -14
  69. package/dist/esm/create-request-client.js.map +1 -0
  70. package/dist/esm/create-test-event.d.ts +2 -0
  71. package/dist/esm/create-test-event.js +41 -0
  72. package/dist/esm/create-test-event.js.map +1 -0
  73. package/dist/esm/create-test-integration.d.ts +36 -0
  74. package/dist/esm/create-test-integration.js +30 -0
  75. package/dist/esm/create-test-integration.js.map +1 -0
  76. package/dist/esm/dayjs.js +1 -1
  77. package/dist/esm/dayjs.js.map +1 -0
  78. package/dist/esm/defaults.js +1 -1
  79. package/dist/esm/defaults.js.map +1 -0
  80. package/dist/esm/destination-kit/action.d.ts +7 -5
  81. package/dist/esm/destination-kit/action.js +27 -30
  82. package/dist/esm/destination-kit/action.js.map +1 -0
  83. package/dist/esm/destination-kit/fields-to-jsonschema.js +1 -1
  84. package/dist/esm/destination-kit/fields-to-jsonschema.js.map +1 -0
  85. package/dist/esm/destination-kit/index.d.ts +10 -5
  86. package/dist/esm/destination-kit/index.js +6 -14
  87. package/dist/esm/destination-kit/index.js.map +1 -0
  88. package/dist/esm/destination-kit/step.d.ts +1 -1
  89. package/dist/esm/destination-kit/step.js +1 -1
  90. package/dist/esm/destination-kit/step.js.map +1 -0
  91. package/dist/esm/destination-kit/types.d.ts +3 -19
  92. package/dist/esm/destination-kit/types.js +1 -1
  93. package/dist/esm/destination-kit/types.js.map +1 -0
  94. package/dist/esm/errors.js +1 -1
  95. package/dist/esm/errors.js.map +1 -0
  96. package/dist/esm/fetch.d.ts +3 -0
  97. package/dist/esm/fetch.js +5 -0
  98. package/dist/esm/fetch.js.map +1 -0
  99. package/dist/esm/get.js +1 -1
  100. package/dist/esm/get.js.map +1 -0
  101. package/dist/esm/index.d.ts +7 -2
  102. package/dist/esm/index.js +5 -1
  103. package/dist/esm/index.js.map +1 -0
  104. package/dist/esm/json-object.js +1 -1
  105. package/dist/esm/json-object.js.map +1 -0
  106. package/dist/esm/map-values.d.ts +7 -0
  107. package/dist/esm/map-values.js +12 -0
  108. package/dist/esm/map-values.js.map +1 -0
  109. package/dist/esm/mapping-kit/index.js +1 -1
  110. package/dist/esm/mapping-kit/index.js.map +1 -0
  111. package/dist/esm/mapping-kit/is-directive.js +1 -1
  112. package/dist/esm/mapping-kit/is-directive.js.map +1 -0
  113. package/dist/esm/mapping-kit/placeholders.js +1 -1
  114. package/dist/esm/mapping-kit/placeholders.js.map +1 -0
  115. package/dist/esm/mapping-kit/validate.js +1 -1
  116. package/dist/esm/mapping-kit/validate.js.map +1 -0
  117. package/dist/esm/middleware/add-basic-auth-header.d.ts +3 -0
  118. package/dist/esm/middleware/add-basic-auth-header.js +16 -0
  119. package/dist/esm/middleware/add-basic-auth-header.js.map +1 -0
  120. package/dist/esm/omit.js +1 -1
  121. package/dist/esm/omit.js.map +1 -0
  122. package/dist/esm/real-type-of.js +1 -1
  123. package/dist/esm/real-type-of.js.map +1 -0
  124. package/dist/esm/remove-undefined.js +1 -1
  125. package/dist/esm/remove-undefined.js.map +1 -0
  126. package/dist/esm/request-client.d.ts +95 -0
  127. package/dist/esm/request-client.js +199 -0
  128. package/dist/esm/request-client.js.map +1 -0
  129. package/dist/esm/segment-event.js +1 -1
  130. package/dist/esm/segment-event.js.map +1 -0
  131. package/dist/esm/time.js +1 -1
  132. package/dist/esm/time.js.map +1 -0
  133. package/package.json +9 -7
@@ -0,0 +1,95 @@
1
+ import { CustomError } from 'ts-custom-error';
2
+ declare type LowerAndUpper<T extends string> = Lowercase<T> | Uppercase<T>;
3
+ /**
4
+ * The supported request options you can use with the request client
5
+ */
6
+ export interface RequestOptions extends Omit<RequestInit, 'headers'> {
7
+ /**
8
+ * Simplified header format to reduce variation
9
+ */
10
+ headers?: Record<string, string>;
11
+ /**
12
+ * Shortcut for sending JSON. Use instead of `body`.
13
+ * Accepts any plain object or value, which will be `JSON.stringify()`'d and sent in the body with the correct header set.
14
+ */
15
+ json?: unknown;
16
+ /**
17
+ * HTTP method used to make the request.
18
+ * Internally, the standard methods (`GET`, `POST`, `PUT`, `PATCH`, `HEAD` and `DELETE`) are uppercased in order to avoid server errors due to case sensitivity.
19
+ * @default 'get'
20
+ */
21
+ method?: LowerAndUpper<'get' | 'post' | 'put' | 'delete' | 'patch' | 'head'>;
22
+ /**
23
+ * When provided, will automatically apply basic authentication
24
+ */
25
+ password?: string;
26
+ /**
27
+ * Search parameters to include int he request URL. Setting this will override existing search parameters in the input URL.
28
+ * Accepts [`URLSearchParams()`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams)
29
+ */
30
+ searchParams?: URLSearchParams | Record<string, string | number | boolean>;
31
+ /**
32
+ * Throw an error when, after redirects, the response has a non-2xx status code.
33
+ * @default true
34
+ */
35
+ throwHttpErrors?: boolean;
36
+ /**
37
+ * Timeout in milliseconds for getting a response.
38
+ * If set to `false` there will be no timeout.
39
+ * @default 10000
40
+ */
41
+ timeout?: number | false;
42
+ /**
43
+ * When provided, will automatically apply basic authentication
44
+ */
45
+ username?: string;
46
+ }
47
+ /**
48
+ * All request options including before/after hooks
49
+ */
50
+ export interface AllRequestOptions extends RequestOptions {
51
+ /**
52
+ * Hooks that execute before a request is sent.
53
+ * Useful to modify the options that a request will use
54
+ */
55
+ beforeRequest?: BeforeRequestHook[];
56
+ /**
57
+ * Hooks that executes after a response is received.
58
+ * Useful for logging, cleanup, or modifying the response object
59
+ */
60
+ afterResponse?: AfterResponseHook[];
61
+ }
62
+ export interface NormalizedOptions extends Omit<AllRequestOptions, 'headers'> {
63
+ headers: RequestInit['headers'];
64
+ method: Uppercase<'get' | 'post' | 'put' | 'delete' | 'patch' | 'head'>;
65
+ }
66
+ declare type MaybePromise<T> = Promise<T> | T;
67
+ /** A hook that executes before a request is executed. Useful to modify the options that a request will use */
68
+ export declare type BeforeRequestHook = (options: NormalizedOptions) => MaybePromise<RequestOptions | void>;
69
+ /** A hook that executes after a response is received. Useful for logging, cleanup, or modifying the response object */
70
+ export declare type AfterResponseHook = (request: Request, options: NormalizedOptions, response: Response) => MaybePromise<Response | void>;
71
+ /** Error thrown when a response has a non-2xx response. */
72
+ export declare class HTTPError extends CustomError {
73
+ request: Request;
74
+ response: ModifiedResponse;
75
+ options: NormalizedOptions;
76
+ constructor(response: ModifiedResponse, request: Request, options: NormalizedOptions);
77
+ }
78
+ /** Error thrown when a request is aborted because of a client timeout. */
79
+ export declare class TimeoutError extends CustomError {
80
+ request: Request;
81
+ options: NormalizedOptions;
82
+ constructor(request: Request, options: NormalizedOptions);
83
+ }
84
+ export interface ModifiedResponse extends Response {
85
+ data?: unknown;
86
+ }
87
+ /**
88
+ * Creates a new instance of the fetch request client,
89
+ * optionally with default configuration to apply to all requests made with the client
90
+ */
91
+ export default function createInstance(defaults?: AllRequestOptions): {
92
+ (url: string, options?: RequestOptions): Promise<ModifiedResponse>;
93
+ extend(newDefaults: AllRequestOptions): any;
94
+ };
95
+ export {};
@@ -0,0 +1,199 @@
1
+ import AbortController from 'abort-controller';
2
+ import { CustomError } from 'ts-custom-error';
3
+ import fetch, { Headers, Request, Response } from './fetch';
4
+ import { isObject } from './real-type-of';
5
+ // We need the loose definition of "object" to iterate over things like `[object Headers]`
6
+ const isObjectLike = (value) => {
7
+ return value !== null && typeof value === 'object';
8
+ };
9
+ /** Merges two sets of headers intelligently */
10
+ function mergeHeaders(source1, source2) {
11
+ const result = new Headers(source1 || {});
12
+ const source = new Headers(source2 || {});
13
+ source.forEach((value, key) => {
14
+ // `value` may be the string `undefined` when the source is a Headers object
15
+ if (value === 'undefined') {
16
+ result.delete(key);
17
+ }
18
+ else {
19
+ result.set(key, value);
20
+ }
21
+ });
22
+ return result;
23
+ }
24
+ /** Deeply merge multiple objects or arrays. Arrays get concatenated. */
25
+ function merge(...sources) {
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ let result = {};
28
+ let headers = {};
29
+ for (const source of sources) {
30
+ if (Array.isArray(source)) {
31
+ if (!Array.isArray(result)) {
32
+ result = [];
33
+ }
34
+ // Concatenate arrays (e.g. hooks)
35
+ result = [...result, ...source];
36
+ }
37
+ else if (isObjectLike(source)) {
38
+ // eslint-disable-next-line prefer-const
39
+ for (let [key, value] of Object.entries(source)) {
40
+ // Recurse over objects
41
+ if (isObjectLike(value) && key in result) {
42
+ value = merge(result[key], value);
43
+ }
44
+ // Update the key's value in our copy
45
+ result[key] = value;
46
+ }
47
+ // Merge headers more carefully to handle duplicates
48
+ if (isObjectLike(source.headers)) {
49
+ headers = mergeHeaders(headers, source.headers);
50
+ }
51
+ }
52
+ // Assign after we've merged all the headers because they are handled specially
53
+ result.headers = headers;
54
+ }
55
+ return result;
56
+ }
57
+ /**
58
+ * Validates and merges request options
59
+ */
60
+ function mergeOptions(...sources) {
61
+ for (const source of sources) {
62
+ if (!isObject(source)) {
63
+ throw new TypeError(`The 'options' argument must be an object`);
64
+ }
65
+ }
66
+ return merge({}, ...sources);
67
+ }
68
+ function getRequestMethod(method) {
69
+ return method.toUpperCase();
70
+ }
71
+ /** Error thrown when a response has a non-2xx response. */
72
+ export class HTTPError extends CustomError {
73
+ constructor(response, request, options) {
74
+ var _a, _b;
75
+ super((_a = response.statusText) !== null && _a !== void 0 ? _a : String((_b = response.status) !== null && _b !== void 0 ? _b : 'Unknown response error'));
76
+ this.response = response;
77
+ this.request = request;
78
+ this.options = options;
79
+ }
80
+ }
81
+ /** Error thrown when a request is aborted because of a client timeout. */
82
+ export class TimeoutError extends CustomError {
83
+ constructor(request, options) {
84
+ super(`Request timed out`);
85
+ this.request = request;
86
+ this.options = options;
87
+ }
88
+ }
89
+ /**
90
+ * Given a request, reject the request when a timeout is exceeded
91
+ */
92
+ function timeoutFetch(request, abortController, options) {
93
+ return new Promise((resolve, reject) => {
94
+ const timer = setTimeout(() => {
95
+ if (abortController) {
96
+ abortController.abort();
97
+ }
98
+ reject(new TimeoutError(request, options));
99
+ }, options.timeout);
100
+ void fetch(request)
101
+ .then(resolve)
102
+ .catch(reject)
103
+ .then(() => clearTimeout(timer));
104
+ });
105
+ }
106
+ class RequestClient {
107
+ constructor(url, options = {}) {
108
+ this.setOptions(url, options);
109
+ }
110
+ setOptions(url, options) {
111
+ var _a, _b;
112
+ this.options = {
113
+ ...options,
114
+ method: getRequestMethod((_a = options.method) !== null && _a !== void 0 ? _a : 'get'),
115
+ throwHttpErrors: options.throwHttpErrors !== false,
116
+ timeout: (_b = options.timeout) !== null && _b !== void 0 ? _b : 10000
117
+ };
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
+ this.abortController = new AbortController();
121
+ if (this.options.signal) {
122
+ // Listen to consumer abort events to also abort our internal controller
123
+ this.options.signal.addEventListener('abort', () => {
124
+ this.abortController.abort();
125
+ });
126
+ }
127
+ // Use our internal abort controller for fetch
128
+ this.options.signal = this.abortController.signal;
129
+ // Construct a request object to send to the Fetch API
130
+ this.request = new Request(url, this.options);
131
+ // Parse search params and merge them with the request URL
132
+ 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
+ const searchParams = new URLSearchParams(this.options.searchParams);
135
+ const url = new URL(this.request.url);
136
+ url.search = searchParams.toString();
137
+ // Update the request object with the new url including the search params
138
+ this.request = new Request(new Request(url.toString(), this.request), this.options);
139
+ }
140
+ // Automatically handle json header + stringification as a convenience when using `json` option
141
+ if (this.options.json !== undefined) {
142
+ this.options.body = JSON.stringify(this.options.json);
143
+ this.request.headers.set('content-type', 'application/json');
144
+ this.request = new Request(this.request, { body: this.options.body });
145
+ }
146
+ }
147
+ async executeRequest() {
148
+ var _a;
149
+ let response = await this.fetch();
150
+ for (const hook of (_a = this.options.afterResponse) !== null && _a !== void 0 ? _a : []) {
151
+ const modifiedResponse = await hook(this.request, this.options, response.clone());
152
+ if (modifiedResponse instanceof Response) {
153
+ response = modifiedResponse;
154
+ }
155
+ }
156
+ // Automatically attempt to parse json responses, matching the content-type
157
+ const contentType = response.headers.get('content-type');
158
+ if (contentType === null || contentType === void 0 ? void 0 : contentType.includes('application/json')) {
159
+ try {
160
+ // call `.json` on a clone, to prevent `TypeError: body used already` in callers
161
+ response.data = await response.clone().json();
162
+ }
163
+ catch (_error) {
164
+ // Ignore the error
165
+ response.data = null;
166
+ }
167
+ }
168
+ if (!response.ok && this.options.throwHttpErrors) {
169
+ throw new HTTPError(response, this.request, this.options);
170
+ }
171
+ return response;
172
+ }
173
+ /**
174
+ * Make a fetch request, running all beforeRequest hooks, and optionally wrap in a timeout
175
+ */
176
+ async fetch() {
177
+ var _a;
178
+ for (const hook of (_a = this.options.beforeRequest) !== null && _a !== void 0 ? _a : []) {
179
+ const newOptions = await hook({ ...this.options });
180
+ if (newOptions && isObject(newOptions)) {
181
+ this.setOptions(this.request.url, mergeOptions(this.options, newOptions));
182
+ }
183
+ }
184
+ if (this.options.timeout === false) {
185
+ return fetch(this.request.clone());
186
+ }
187
+ return timeoutFetch(this.request.clone(), this.abortController, this.options);
188
+ }
189
+ }
190
+ /**
191
+ * Creates a new instance of the fetch request client,
192
+ * optionally with default configuration to apply to all requests made with the client
193
+ */
194
+ export default function createInstance(defaults = {}) {
195
+ const client = (url, options = {}) => new RequestClient(url, mergeOptions(defaults, options)).executeRequest();
196
+ client.extend = (newDefaults) => createInstance(mergeOptions(defaults, newDefaults));
197
+ return client;
198
+ }
199
+ //# sourceMappingURL=request-client.js.map
@@ -0,0 +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;AAoFzC,0FAA0F;AAC1F,MAAM,YAAY,GAAG,CAAC,KAAc,EAAuC,EAAE;IAC3E,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAA;AACpD,CAAC,CAAA;AAED,+CAA+C;AAC/C,SAAS,YAAY,CAAC,OAA+B,EAAE,OAA+B;IACpF,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,OA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,EAAE,UAAU,CAAC,CAAC,CAAA;aAC1E;SACF;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,KAAK,EAAE;YAClC,OAAO,KAAK,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;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,WAA8B,EAAE;IACrE,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,UAA0B,EAAE,EAAE,EAAE,CAC3D,IAAI,aAAa,CAAC,GAAG,EAAE,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc,EAAE,CAAA;IAC1E,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"}
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VnbWVudC1ldmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZWdtZW50LWV2ZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
2
+ //# sourceMappingURL=segment-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment-event.js","sourceRoot":"","sources":["../../src/segment-event.ts"],"names":[],"mappings":""}
package/dist/esm/time.js CHANGED
@@ -10,4 +10,4 @@ export function time() {
10
10
  export function duration(start, stop) {
11
11
  return Number(stop - start) / 1000000;
12
12
  }
13
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGltZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90aW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxVQUFVLElBQUk7SUFDbEIsT0FBTyxPQUFPLENBQUMsTUFBTSxDQUFDLE1BQU0sRUFBRSxDQUFBO0FBQ2hDLENBQUM7QUFFRDs7R0FFRztBQUNILE1BQU0sVUFBVSxRQUFRLENBQUMsS0FBYSxFQUFFLElBQVk7SUFDbEQsT0FBTyxNQUFNLENBQUMsSUFBSSxHQUFHLEtBQUssQ0FBQyxHQUFHLE9BQU8sQ0FBQTtBQUN2QyxDQUFDIn0=
13
+ //# sourceMappingURL=time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/time.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,IAAI;IAClB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,IAAY;IAClD,OAAO,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAA;AACvC,CAAC"}
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": "1.3.0-next.1",
4
+ "version": "2.0.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/segmentio/fab-5-engine",
@@ -14,7 +14,6 @@
14
14
  "./": "./dist/cjs/"
15
15
  },
16
16
  "types": "dist/esm/index.d.ts",
17
- "sideEffects": false,
18
17
  "files": [
19
18
  "dist",
20
19
  "package.json"
@@ -39,21 +38,24 @@
39
38
  "typecheck": "tsc --noEmit"
40
39
  },
41
40
  "devDependencies": {
41
+ "@types/btoa-lite": "^1.0.0",
42
+ "@types/express": "^4.17.11",
42
43
  "@types/jest": "^26.0.20",
43
44
  "@types/json-schema": "^7.0.7",
44
- "@types/lodash": "^4.14.168",
45
45
  "@types/uuid": "^8.3.0",
46
+ "create-test-server": "^3.0.1",
46
47
  "jest": "^26.6.3",
47
- "lodash": "^4.17.20",
48
48
  "nock": "^13.0.4"
49
49
  },
50
50
  "dependencies": {
51
51
  "@segment/ajv-human-errors": "^1.1.0",
52
- "@segment/fab5-subscriptions": "^1.0.0",
52
+ "@segment/fab5-subscriptions": "^2.0.1",
53
+ "abort-controller": "^3.0.0",
53
54
  "aggregate-error": "^3.1.0",
54
55
  "ajv": "^6.12.4",
56
+ "btoa-lite": "^1.0.0",
57
+ "cross-fetch": "^3.1.4",
55
58
  "dayjs": "^1.10.3",
56
- "got": "^10.0.0",
57
59
  "node-cache": "^5.1.2",
58
60
  "ts-custom-error": "^3.2.0",
59
61
  "uuid": "^8.3.2"
@@ -69,5 +71,5 @@
69
71
  ],
70
72
  "forceExit": true
71
73
  },
72
- "gitHead": "7f5cdda9794c965160d6588170c98485cdc5269a"
74
+ "gitHead": "2203f5a0ae758d7b2c024e5aeed055094af4988d"
73
75
  }