@segment/actions-core 2.0.3-next.0 → 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 +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 +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 +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 +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,7 +1,4 @@
|
|
|
1
1
|
import { AllRequestOptions, RequestOptions } from './request-client';
|
|
2
2
|
import type { ModifiedResponse } from './types';
|
|
3
3
|
export declare type RequestClient = ReturnType<typeof createRequestClient>;
|
|
4
|
-
/**
|
|
5
|
-
* Creates a request client instance with Segment's default configuration + custom options
|
|
6
|
-
*/
|
|
7
4
|
export default function createRequestClient(...requestOptions: AllRequestOptions[]): <Data = unknown>(url: string, options?: RequestOptions | undefined) => Promise<ModifiedResponse<Data>>;
|
|
@@ -13,22 +13,15 @@ const baseClient = request_client_1.default({
|
|
|
13
13
|
'user-agent': 'Segment'
|
|
14
14
|
},
|
|
15
15
|
beforeRequest: [
|
|
16
|
-
// Automatically handle username/password -> basic auth header
|
|
17
16
|
add_basic_auth_header_1.default
|
|
18
17
|
],
|
|
19
18
|
afterResponse: [prepare_response_1.default, prepare_headers_1.default]
|
|
20
19
|
});
|
|
21
|
-
/**
|
|
22
|
-
* Creates a request client instance with Segment's default configuration + custom options
|
|
23
|
-
*/
|
|
24
20
|
function createRequestClient(...requestOptions) {
|
|
25
21
|
let client = baseClient;
|
|
26
|
-
// TODO include `data` bundle in before/after hooks
|
|
27
|
-
// TODO expose before/after hooks to destination definition and action definition?
|
|
28
22
|
for (const options of requestOptions !== null && requestOptions !== void 0 ? requestOptions : []) {
|
|
29
23
|
client = client.extend(options);
|
|
30
24
|
}
|
|
31
|
-
// Limit request client interface and handle basic auth scheme
|
|
32
25
|
return (url, options) => {
|
|
33
26
|
return client(url, options);
|
|
34
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-request-client.js","sourceRoot":"","sources":["../../src/create-request-client.ts"],"names":[],"mappings":";;;;;AAAA,8GAAkF;AAClF,kGAAwE;AACxE,oGAA0E;AAC1E,sEAAoF;AAGpF,MAAM,UAAU,GAAG,wBAAc,CAAC;IAChC,OAAO,EAAE,KAAK;IACd,OAAO,EAAE;QACP,YAAY,EAAE,SAAS;KACxB;IACD,aAAa,EAAE;
|
|
1
|
+
{"version":3,"file":"create-request-client.js","sourceRoot":"","sources":["../../src/create-request-client.ts"],"names":[],"mappings":";;;;;AAAA,8GAAkF;AAClF,kGAAwE;AACxE,oGAA0E;AAC1E,sEAAoF;AAGpF,MAAM,UAAU,GAAG,wBAAc,CAAC;IAChC,OAAO,EAAE,KAAK;IACd,OAAO,EAAE;QACP,YAAY,EAAE,SAAS;KACxB;IACD,aAAa,EAAE;QAEb,+BAAkB;KACnB;IACD,aAAa,EAAE,CAAC,0BAAe,EAAE,yBAAc,CAAC;CACjD,CAAC,CAAA;AAOF,SAAwB,mBAAmB,CAAC,GAAG,cAAmC;IAChF,IAAI,MAAM,GAAG,UAAU,CAAA;IAIvB,KAAK,MAAM,OAAO,IAAI,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,EAAE,EAAE;QAC1C,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;KAChC;IAGD,OAAO,CAAiB,GAAW,EAAE,OAAwB,EAAE,EAAE;QAC/D,OAAO,MAAM,CAAyB,GAAG,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC,CAAA;AACH,CAAC;AAbD,sCAaC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTestEvent = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
4
|
+
const uuid_1 = require("@lukeed/uuid");
|
|
5
5
|
function createTestEvent(event = {}) {
|
|
6
6
|
return {
|
|
7
7
|
anonymousId: uuid_1.v4(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-test-event.js","sourceRoot":"","sources":["../../src/create-test-event.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"create-test-event.js","sourceRoot":"","sources":["../../src/create-test-event.ts"],"names":[],"mappings":";;;AAAA,uCAA2C;AAG3C,SAAgB,eAAe,CAAC,QAA+B,EAAE;IAC/D,OAAO;QACL,WAAW,EAAE,SAAM,EAAE;QACrB,OAAO,EAAE;YACP,EAAE,EAAE,SAAS;YACb,OAAO,EAAE;gBACP,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE,QAAQ;aAClB;YACD,MAAM,EAAE,OAAO;YACf,QAAQ,EAAE;gBACR,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,eAAe;gBACxB,QAAQ,EAAE,UAAU;gBACpB,SAAS,EAAE,CAAC,UAAU;gBACtB,KAAK,EAAE,CAAC;aACT;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,WAAW;gBACjB,QAAQ,EAAE,EAAE;gBACZ,MAAM,EAAE,EAAE;gBACV,KAAK,EAAE,mBAAmB;gBAC1B,GAAG,EAAE,8BAA8B;aACpC;YACD,QAAQ,EAAE,kBAAkB;YAC5B,SAAS,EACP,uIAAuI;SAC1I;QACD,KAAK,EAAE,YAAY;QACnB,SAAS,EAAE,SAAM,EAAE;QACnB,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAChC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,UAAU;QAClB,GAAG,KAAK;KACT,CAAA;AACH,CAAC;AAvCD,0CAuCC"}
|
|
@@ -3,33 +3,14 @@ import type { DestinationDefinition } from './destination-kit';
|
|
|
3
3
|
import type { JSONObject } from './json-object';
|
|
4
4
|
import type { SegmentEvent } from './segment-event';
|
|
5
5
|
interface InputData<Settings> {
|
|
6
|
-
/**
|
|
7
|
-
* The Segment event. You can use `createTestEvent` if you want
|
|
8
|
-
* to construct an event from partial data.
|
|
9
|
-
*/
|
|
10
6
|
event?: Partial<SegmentEvent>;
|
|
11
|
-
/**
|
|
12
|
-
* The raw input - this is what customers define. It may include
|
|
13
|
-
* literal values as well as mapping-kit directives.
|
|
14
|
-
*/
|
|
15
7
|
mapping?: JSONObject;
|
|
16
|
-
/**
|
|
17
|
-
* The settings for a destination instance. Includes things like
|
|
18
|
-
* `apiKey` or `subdomain`. Any fields that are used across all actions
|
|
19
|
-
* in a destination.
|
|
20
|
-
*/
|
|
21
8
|
settings?: Settings;
|
|
22
|
-
/**
|
|
23
|
-
* Whether or not to use default mappings in the test.
|
|
24
|
-
* Set to `false` or omit if you want to explicitly provide the raw input.
|
|
25
|
-
* Set to `true` if you want to test the defaultMappings (along with any mapping passed in)
|
|
26
|
-
*/
|
|
27
9
|
useDefaultMappings?: boolean;
|
|
28
10
|
}
|
|
29
11
|
declare class TestDestination<T> extends Destination<T> {
|
|
30
12
|
responses: Destination['responses'];
|
|
31
13
|
constructor(destination: DestinationDefinition<T>);
|
|
32
|
-
/** Testing method that runs an action e2e while allowing slightly more flexible inputs */
|
|
33
14
|
testAction(action: string, { event, mapping, settings, useDefaultMappings }: InputData<T>): Promise<Destination['responses']>;
|
|
34
15
|
}
|
|
35
16
|
export declare function createTestIntegration<T>(destination: DestinationDefinition<T>): TestDestination<T>;
|
|
@@ -9,7 +9,6 @@ class TestDestination extends destination_kit_1.Destination {
|
|
|
9
9
|
super(destination);
|
|
10
10
|
this.responses = [];
|
|
11
11
|
}
|
|
12
|
-
/** Testing method that runs an action e2e while allowing slightly more flexible inputs */
|
|
13
12
|
async testAction(action, { event, mapping, settings, useDefaultMappings }) {
|
|
14
13
|
mapping = mapping !== null && mapping !== void 0 ? mapping : {};
|
|
15
14
|
if (useDefaultMappings) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-test-integration.js","sourceRoot":"","sources":["../../src/create-test-integration.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AACrD,uDAA+C;AAC/C,6CAAwC;AA8BxC,MAAM,eAAmB,SAAQ,6BAAc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
@@ -9,39 +9,14 @@ declare type MaybePromise<T> = T | Promise<T>;
|
|
|
9
9
|
declare type RequestClient = ReturnType<typeof createRequestClient>;
|
|
10
10
|
export declare type RequestFn<Settings, Payload, Return = any> = (request: RequestClient, data: ExecuteInput<Settings, Payload>) => MaybePromise<Return>;
|
|
11
11
|
export interface ActionDefinition<Settings, Payload = any> {
|
|
12
|
-
/** The unique identifier for the action, e.g. `postToChannel` */
|
|
13
|
-
/** The display title of the action */
|
|
14
12
|
title: string;
|
|
15
|
-
/** The display description of the action */
|
|
16
13
|
description: string;
|
|
17
|
-
/** Whether the action is recommended for quick setup */
|
|
18
|
-
recommended?: boolean;
|
|
19
|
-
/** An optional fql query that will be used to prepopulate the action when it is first set up */
|
|
20
14
|
defaultSubscription?: string;
|
|
21
|
-
/** Whether or not this action should be visible/configurable in the UI */
|
|
22
15
|
hidden?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* The fields used to perform the action. These fields should match what the partner API expects.
|
|
25
|
-
*
|
|
26
|
-
* This is a set of JSON Schema properties right now.
|
|
27
|
-
* We may eventually auto-generate the JSON Schema from a definition object
|
|
28
|
-
* instead of requiring devs to build and modify JSON Schema directly.
|
|
29
|
-
*
|
|
30
|
-
* Plus, JSON Schema cannot fully represent our action or field definitions
|
|
31
|
-
* without many custom keywords.
|
|
32
|
-
*/
|
|
33
16
|
fields: Record<string, InputField>;
|
|
34
|
-
/**
|
|
35
|
-
* Temporary way to "register" autocomplete fields.
|
|
36
|
-
* This is likely going to change as we productionalize the data model and definition object
|
|
37
|
-
*/
|
|
38
17
|
autocompleteFields?: {
|
|
39
18
|
[K in keyof Payload]?: RequestFn<Settings, Payload, AutocompleteResponse>;
|
|
40
19
|
};
|
|
41
|
-
/**
|
|
42
|
-
* Register fields that should be executed, cached and provided
|
|
43
|
-
* to the action's `perform` function
|
|
44
|
-
*/
|
|
45
20
|
cachedFields?: {
|
|
46
21
|
[field: string]: {
|
|
47
22
|
key: (data: ExecuteInput<Settings, Payload>) => string;
|
|
@@ -50,7 +25,6 @@ export interface ActionDefinition<Settings, Payload = any> {
|
|
|
50
25
|
negative?: boolean;
|
|
51
26
|
};
|
|
52
27
|
};
|
|
53
|
-
/** The operation to perform when this action is triggered */
|
|
54
28
|
perform: RequestFn<Settings, Payload>;
|
|
55
29
|
}
|
|
56
30
|
export declare class Validate<Settings, Payload> extends Step<Settings, Payload> {
|
|
@@ -68,10 +42,6 @@ interface ExecuteAutocompleteInput<Settings, Payload> {
|
|
|
68
42
|
page?: string;
|
|
69
43
|
}
|
|
70
44
|
declare type ExecuteInputField = 'payload' | 'settings';
|
|
71
|
-
/**
|
|
72
|
-
* Action is the beginning step for all partner actions. Entrypoints always start with the
|
|
73
|
-
* MapAndValidateInput step.
|
|
74
|
-
*/
|
|
75
45
|
export declare class Action<Settings, Payload extends JSONLikeObject> extends EventEmitter {
|
|
76
46
|
readonly steps: Steps<Settings, Payload>;
|
|
77
47
|
private extendRequest;
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Action = exports.Validate = void 0;
|
|
7
|
-
// @ts-ignore no types
|
|
8
7
|
const ajv_human_errors_1 = require("@segment/ajv-human-errors");
|
|
9
8
|
const ajv_1 = __importDefault(require("ajv"));
|
|
10
9
|
const events_1 = require("events");
|
|
@@ -17,12 +16,7 @@ const fetch_1 = require("../fetch");
|
|
|
17
16
|
const step_1 = require("./step");
|
|
18
17
|
class MapInput extends step_1.Step {
|
|
19
18
|
executeStep(data) {
|
|
20
|
-
// Transforms the initial payload (event) + action settings (from `subscriptions[0].mapping`)
|
|
21
|
-
// into input data that the action can use to talk to partner apis
|
|
22
19
|
if (data.mapping) {
|
|
23
|
-
// Technically we can't know whether or not `transform` returns the exact shape of Payload here, hence the casting
|
|
24
|
-
// It will be validated in subsequent steps
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
20
|
data.payload = mapping_kit_1.transform(data.mapping, data.payload);
|
|
27
21
|
}
|
|
28
22
|
return Promise.resolve('MapInput completed');
|
|
@@ -33,31 +27,21 @@ class Validate extends step_1.Step {
|
|
|
33
27
|
super();
|
|
34
28
|
this.field = field;
|
|
35
29
|
const ajv = new ajv_1.default({
|
|
36
|
-
// Coerce types to be a bit more liberal.
|
|
37
30
|
coerceTypes: true,
|
|
38
|
-
// Return all validation errors, not just the first.
|
|
39
31
|
allErrors: true,
|
|
40
|
-
// Include reference to schema and data in error values.
|
|
41
32
|
verbose: true,
|
|
42
|
-
// Use a more parse-able format for JSON paths.
|
|
43
33
|
jsonPointers: true
|
|
44
34
|
});
|
|
45
35
|
this.validate = ajv.compile(schema);
|
|
46
36
|
}
|
|
47
37
|
executeStep(data) {
|
|
48
38
|
if (!this.validate(data[this.field])) {
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
50
39
|
throw new ajv_human_errors_1.AggregateAjvError(this.validate.errors);
|
|
51
40
|
}
|
|
52
41
|
return Promise.resolve('Validate completed');
|
|
53
42
|
}
|
|
54
43
|
}
|
|
55
44
|
exports.Validate = Validate;
|
|
56
|
-
/**
|
|
57
|
-
* Request handles delivering a payload to an external API. It uses the `fetch` API under the hood.
|
|
58
|
-
*
|
|
59
|
-
* The callback should be able to return the raw request instead of needing to do `return response.data` etc.
|
|
60
|
-
*/
|
|
61
45
|
class Request extends step_1.Step {
|
|
62
46
|
constructor(extendRequest, requestFn) {
|
|
63
47
|
super();
|
|
@@ -71,26 +55,17 @@ class Request extends step_1.Step {
|
|
|
71
55
|
}
|
|
72
56
|
const requestClient = this.createRequestClient(data);
|
|
73
57
|
const response = await this.requestFn(requestClient, data);
|
|
74
|
-
/**
|
|
75
|
-
* Try to use the parsed response `.data` or `.content` string
|
|
76
|
-
* @see {@link ../middleware/after-response/prepare-response.ts}
|
|
77
|
-
*/
|
|
78
58
|
if (response instanceof fetch_1.Response) {
|
|
79
59
|
return (_a = response.data) !== null && _a !== void 0 ? _a : response.content;
|
|
80
60
|
}
|
|
81
|
-
// otherwise, we don't really know what this is, so return as-is
|
|
82
61
|
return response;
|
|
83
62
|
}
|
|
84
63
|
createRequestClient(data) {
|
|
85
64
|
var _a, _b;
|
|
86
|
-
// TODO turn `extendRequest` into a beforeRequest hook
|
|
87
65
|
const options = (_b = (_a = this.extendRequest) === null || _a === void 0 ? void 0 : _a.call(this, data)) !== null && _b !== void 0 ? _b : {};
|
|
88
66
|
const client = create_request_client_1.default(options, {
|
|
89
67
|
afterResponse: [
|
|
90
|
-
// Keep track of the request(s) associated with a response
|
|
91
68
|
(request, options, response) => {
|
|
92
|
-
// TODO figure out the types here...
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
69
|
const modifiedResponse = response;
|
|
95
70
|
modifiedResponse.request = request;
|
|
96
71
|
modifiedResponse.options = options;
|
|
@@ -102,7 +77,6 @@ class Request extends step_1.Step {
|
|
|
102
77
|
return client;
|
|
103
78
|
}
|
|
104
79
|
}
|
|
105
|
-
// CachedRequest is like Request but cached. Next question.
|
|
106
80
|
class CachedRequest extends Request {
|
|
107
81
|
constructor(extension, config) {
|
|
108
82
|
super(extension);
|
|
@@ -134,20 +108,12 @@ class CachedRequest extends Request {
|
|
|
134
108
|
throw e;
|
|
135
109
|
}
|
|
136
110
|
}
|
|
137
|
-
// Only cache if value is not negative *or* negative option is set. Negative caching is off by
|
|
138
|
-
// default because the common cases are: A) auth token generation, which should never be
|
|
139
|
-
// negative, and B) create-or-update patterns, where the resource should exist after the first
|
|
140
|
-
// negative value.
|
|
141
111
|
if ((v !== null && v !== undefined) || this.negative) {
|
|
142
112
|
this.cache.set(k, v);
|
|
143
113
|
}
|
|
144
114
|
return 'cache miss';
|
|
145
115
|
}
|
|
146
116
|
}
|
|
147
|
-
/**
|
|
148
|
-
* Action is the beginning step for all partner actions. Entrypoints always start with the
|
|
149
|
-
* MapAndValidateInput step.
|
|
150
|
-
*/
|
|
151
117
|
class Action extends events_1.EventEmitter {
|
|
152
118
|
constructor(definition, extendRequest) {
|
|
153
119
|
super();
|
|
@@ -156,9 +122,6 @@ class Action extends events_1.EventEmitter {
|
|
|
156
122
|
this.steps.push(step);
|
|
157
123
|
this.autocompleteCache = {};
|
|
158
124
|
if (extendRequest) {
|
|
159
|
-
// This must come before we load the definition because
|
|
160
|
-
// it instantiates "steps" with whatever request extensions
|
|
161
|
-
// are defined at that moment in time
|
|
162
125
|
this.extendRequest = extendRequest;
|
|
163
126
|
}
|
|
164
127
|
this.loadDefinition(definition);
|
|
@@ -171,7 +134,6 @@ class Action extends events_1.EventEmitter {
|
|
|
171
134
|
}
|
|
172
135
|
return results;
|
|
173
136
|
}
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
175
137
|
executeAutocomplete(field, data) {
|
|
176
138
|
if (!this.autocompleteCache[field]) {
|
|
177
139
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../src/destination-kit/action.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../src/destination-kit/action.ts"],"names":[],"mappings":";;;;;;AACA,gEAA6D;AAC7D,8CAAqB;AACrB,mCAAqC;AACrC,4DAAkC;AAClC,qFAA0D;AAC1D,gCAA4B;AAE5B,gDAA0C;AAC1C,iEAA2D;AAC3D,oCAAmC;AACnC,iCAA8D;AAmE9D,MAAM,QAAmD,SAAQ,WAAuB;IACtF,WAAW,CAAC,IAAqC;QAG/C,IAAI,IAAI,CAAC,OAAO,EAAE;YAIhB,IAAI,CAAC,OAAO,GAAG,uBAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAc,CAAY,CAAA;SACvE;QAED,OAAO,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAA;IAC9C,CAAC;CACF;AAED,MAAa,QAA4B,SAAQ,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C,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;SACjC;IACH,CAAC;IAEO,eAAe,CAAC,MAAkC;QACxD,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,SAAS,EAAE,yCAAkB,CAAC,MAAM,CAAC,CAAC,CAAA;QAChE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEO,YAAY,CAAC,KAAa,EAAE,QAAsC;QACxE,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAA;IAC1C,CAAC;IAEO,OAAO,CAAC,SAAuC;QACrD,MAAM,IAAI,GAAG,IAAI,OAAO,CAAoB,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAA;QAC1E,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAA;QAClE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEO,aAAa,CAAC,MAA8C;QAClE,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;QAC1D,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;CACF;AAzFD,wBAyFC"}
|
|
@@ -6,10 +6,8 @@ function fieldsToJsonSchema(fields = {}) {
|
|
|
6
6
|
const properties = {};
|
|
7
7
|
for (const key of Object.keys(fields)) {
|
|
8
8
|
const field = fields[key];
|
|
9
|
-
// Remove the `required` property from fields because it'll get lifted up into an array of required keys
|
|
10
9
|
properties[key] = Object.assign({}, field);
|
|
11
10
|
delete properties[key].required;
|
|
12
|
-
// Grab all the field keys with `required: true`
|
|
13
11
|
if (field.required) {
|
|
14
12
|
required.push(key);
|
|
15
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields-to-jsonschema.js","sourceRoot":"","sources":["../../../src/destination-kit/fields-to-jsonschema.ts"],"names":[],"mappings":";;;AAGA,SAAgB,kBAAkB,CAAC,SAAqC,EAAE;IACxE,MAAM,QAAQ,GAAa,EAAE,CAAA;IAC7B,MAAM,UAAU,GAAgC,EAAE,CAAA;IAElD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"fields-to-jsonschema.js","sourceRoot":"","sources":["../../../src/destination-kit/fields-to-jsonschema.ts"],"names":[],"mappings":";;;AAGA,SAAgB,kBAAkB,CAAC,SAAqC,EAAE;IACxE,MAAM,QAAQ,GAAa,EAAE,CAAA;IAC7B,MAAM,UAAU,GAAgC,EAAE,CAAA;IAElD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;QAGzB,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAgB,CAAA;QACzD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAA;QAG/B,IAAI,KAAK,CAAC,QAAQ,EAAE;YAClB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;SACnB;KACF;IAED,OAAO;QACL,OAAO,EAAE,gCAAgC;QACzC,IAAI,EAAE,QAAQ;QACd,oBAAoB,EAAE,KAAK;QAC3B,UAAU;QACV,QAAQ;KACT,CAAA;AACH,CAAC;AAxBD,gDAwBC;AAED,SAAgB,kBAAkB,CAAC,SAAsB,EAAE;;IACzD,MAAM,cAAc,GAAG,MAAC,MAAM,CAAC,QAAqB,mCAAI,EAAE,CAAA;IAC1D,MAAM,UAAU,GAAG,MAAC,MAAM,CAAC,UAAyC,mCAAI,EAAE,CAAA;IAE1E,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;QACzC,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAChC,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAA;SAChC;KACF;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AAXD,gDAWC"}
|
|
@@ -23,17 +23,12 @@ interface PartnerActions<Settings, Payload extends JSONLikeObject> {
|
|
|
23
23
|
[key: string]: Action<Settings, Payload>;
|
|
24
24
|
}
|
|
25
25
|
export interface DestinationDefinition<Settings = unknown> {
|
|
26
|
-
/** The name of the destination */
|
|
27
26
|
name: string;
|
|
28
|
-
/** An optional function to extend requests sent from the destination (including all actions) */
|
|
29
27
|
extendRequest?: RequestExtension<Settings>;
|
|
30
|
-
/** Optional authentication configuration */
|
|
31
28
|
authentication?: AuthenticationScheme<Settings>;
|
|
32
|
-
/** Actions */
|
|
33
29
|
actions: {
|
|
34
30
|
[key: string]: ActionDefinition<Settings>;
|
|
35
31
|
};
|
|
36
|
-
/** Subscription presets automatically applied in quick setup */
|
|
37
32
|
presets?: Subscription[];
|
|
38
33
|
}
|
|
39
34
|
export interface Subscription {
|
|
@@ -51,7 +46,6 @@ interface Authentication<Settings> {
|
|
|
51
46
|
testAuthentication: (request: RequestClient, input: TestAuthSettings<Settings>) => Promise<unknown> | unknown;
|
|
52
47
|
}
|
|
53
48
|
export interface CustomAuthentication<Settings> extends Authentication<Settings> {
|
|
54
|
-
/** Typically used for "API Key" authentication. */
|
|
55
49
|
scheme: 'custom';
|
|
56
50
|
}
|
|
57
51
|
export interface BasicAuthentication<Settings> extends Authentication<Settings> {
|
|
@@ -80,10 +74,6 @@ export declare class Destination<Settings = JSONObject> {
|
|
|
80
74
|
private partnerAction;
|
|
81
75
|
protected executeAction(actionSlug: string, { event, mapping, settings }: EventInput<Settings>): Promise<StepResult[]>;
|
|
82
76
|
private onSubscription;
|
|
83
|
-
/**
|
|
84
|
-
* Note: Until we move subscriptions upstream (into int-consumer) we've opted
|
|
85
|
-
* to have failures abort the set of subscriptions and get potentially retried by centrifuge
|
|
86
|
-
*/
|
|
87
77
|
onEvent(event: SegmentEvent, settings: JSONObject, onComplete?: (stats: SubscriptionStats) => void): Promise<StepResult[]>;
|
|
88
78
|
private getSubscriptions;
|
|
89
79
|
private getDestinationSettings;
|
|
@@ -21,7 +21,6 @@ class Destination {
|
|
|
21
21
|
this.actions = {};
|
|
22
22
|
this.authentication = destination.authentication;
|
|
23
23
|
this.responses = [];
|
|
24
|
-
// Convert to complete JSON Schema
|
|
25
24
|
if ((_a = this.authentication) === null || _a === void 0 ? void 0 : _a.fields) {
|
|
26
25
|
this.settingsSchema = fields_to_jsonschema_1.fieldsToJsonSchema(this.authentication.fields);
|
|
27
26
|
}
|
|
@@ -99,6 +98,9 @@ class Destination {
|
|
|
99
98
|
catch (error) {
|
|
100
99
|
state = 'errored';
|
|
101
100
|
results = [{ error }];
|
|
101
|
+
if (error.name === 'AggregateAjvError' || error.name === 'ValidationError') {
|
|
102
|
+
error.status = 400;
|
|
103
|
+
}
|
|
102
104
|
throw error;
|
|
103
105
|
}
|
|
104
106
|
finally {
|
|
@@ -119,10 +121,6 @@ class Destination {
|
|
|
119
121
|
});
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Note: Until we move subscriptions upstream (into int-consumer) we've opted
|
|
124
|
-
* to have failures abort the set of subscriptions and get potentially retried by centrifuge
|
|
125
|
-
*/
|
|
126
124
|
async onEvent(event, settings, onComplete) {
|
|
127
125
|
const subscriptions = this.getSubscriptions(settings);
|
|
128
126
|
const destinationSettings = this.getDestinationSettings(settings);
|
|
@@ -133,7 +131,6 @@ class Destination {
|
|
|
133
131
|
getSubscriptions(settings) {
|
|
134
132
|
const { subscription, subscriptions } = settings;
|
|
135
133
|
let parsedSubscriptions;
|
|
136
|
-
// To support event tester we need to parse and validate multiple subscriptions from the settings
|
|
137
134
|
if (subscription) {
|
|
138
135
|
parsedSubscriptions = [subscription];
|
|
139
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destination-kit/index.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAgE;AAEhE,qCAAwE;AAExE,kCAAwC;AAGxC,iEAA+E;AAQtE,mGARA,yCAAkB,OAQA;AAAE,mGARA,yCAAkB,OAQA;AAP/C,sCAAkD;AAClD,qFAA6E;AA+E7E,MAAa,WAAW;IAUtB,YAAY,WAA4C;;QACtD,IAAI,CAAC,UAAU,GAAG,WAAW,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;QAC5B,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,aAAa,CAAA;QAC9C,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,cAAc,CAAA;QAChD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destination-kit/index.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAgE;AAEhE,qCAAwE;AAExE,kCAAwC;AAGxC,iEAA+E;AAQtE,mGARA,yCAAkB,OAQA;AAAE,mGARA,yCAAkB,OAQA;AAP/C,sCAAkD;AAClD,qFAA6E;AA+E7E,MAAa,WAAW;IAUtB,YAAY,WAA4C;;QACtD,IAAI,CAAC,UAAU,GAAG,WAAW,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;QAC5B,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,aAAa,CAAA;QAC9C,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,cAAc,CAAA;QAChD,IAAI,CAAC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settings, Payload> {
|
|
9
|
-
/** The subscription mapping definition */
|
|
10
9
|
readonly mapping?: JSONObject;
|
|
11
|
-
/** The global destination settings */
|
|
12
10
|
readonly settings: Settings;
|
|
13
|
-
/** The transformed input data, based on `mapping` + `event` */
|
|
14
11
|
payload: Payload;
|
|
15
|
-
/** The ids from cached requests */
|
|
16
12
|
cachedFields: {
|
|
17
13
|
[key: string]: string | null | undefined;
|
|
18
14
|
};
|
|
19
|
-
/** The page used in autocomplete */
|
|
20
15
|
page?: string;
|
|
21
16
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Step is the base class for all discrete execution steps. It handles executing the step, logging,
|
|
24
|
-
* catching errors, and returning a result object.
|
|
25
|
-
*/
|
|
26
17
|
export declare class Step<Settings, Payload> extends EventEmitter {
|
|
27
18
|
executeStep?(data: ExecuteInput<Settings, Payload>): Promise<JSONObject | string | null | undefined>;
|
|
28
19
|
execute(data: ExecuteInput<Settings, Payload>): Promise<StepResult>;
|
|
29
20
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Steps is a list of one or more Step instances that can be executed in-order.
|
|
32
|
-
*/
|
|
33
21
|
export declare class Steps<Settings, Payload> {
|
|
34
22
|
steps: Step<Settings, Payload>[];
|
|
35
23
|
constructor();
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Steps = exports.Step = void 0;
|
|
4
4
|
const events_1 = require("events");
|
|
5
|
-
/**
|
|
6
|
-
* Step is the base class for all discrete execution steps. It handles executing the step, logging,
|
|
7
|
-
* catching errors, and returning a result object.
|
|
8
|
-
*/
|
|
9
5
|
class Step extends events_1.EventEmitter {
|
|
10
6
|
async execute(data) {
|
|
11
7
|
const result = {
|
|
@@ -25,9 +21,6 @@ class Step extends events_1.EventEmitter {
|
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
exports.Step = Step;
|
|
28
|
-
/**
|
|
29
|
-
* Steps is a list of one or more Step instances that can be executed in-order.
|
|
30
|
-
*/
|
|
31
24
|
class Steps {
|
|
32
25
|
constructor() {
|
|
33
26
|
this.steps = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.js","sourceRoot":"","sources":["../../../src/destination-kit/step.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;
|
|
1
|
+
{"version":3,"file":"step.js","sourceRoot":"","sources":["../../../src/destination-kit/step.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAyBrC,MAAa,IAAwB,SAAQ,qBAAY;IAGvD,KAAK,CAAC,OAAO,CAAC,IAAqC;QACjD,MAAM,MAAM,GAAe;YACzB,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE,IAAI;SACZ,CAAA;QAED,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAO,MAAM,CAAA;SACd;QAED,IAAI;YACF,MAAM,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;SAC7C;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,GAAG,CAAC,CAAA;SACjB;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AArBD,oBAqBC;AAKD,MAAa,KAAK;IAGhB;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;IACjB,CAAC;IAED,IAAI,CAAC,IAA6B;QAChC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAqC;QACjD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;SACpC;QAED,MAAM,OAAO,GAAiB,EAAE,CAAA;QAEhC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAEvC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAEpB,IAAI,MAAM,CAAC,KAAK,EAAE;gBAChB,MAAK;aACN;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AA9BD,sBA8BC"}
|
|
@@ -16,8 +16,4 @@ export interface AutocompleteItem {
|
|
|
16
16
|
export interface InputField extends Omit<JSONSchema4, 'required'> {
|
|
17
17
|
required?: boolean;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
* A function to configure a request client instance with options
|
|
21
|
-
* that will be applied to every request made by that instance
|
|
22
|
-
*/
|
|
23
19
|
export declare type RequestExtension<Settings, Payload = unknown> = (data: ExecuteInput<Settings, Payload>) => RequestOptions;
|
package/dist/cjs/fetch.js
CHANGED
|
@@ -20,7 +20,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.Response = exports.Request = exports.Headers = void 0;
|
|
23
|
-
// import fetch ponyfill
|
|
24
23
|
const cross_fetch_1 = __importStar(require("cross-fetch"));
|
|
25
24
|
Object.defineProperty(exports, "Headers", { enumerable: true, get: function () { return cross_fetch_1.Headers; } });
|
|
26
25
|
Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return cross_fetch_1.Request; } });
|
package/dist/cjs/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,2DAA+D;AAEtD,wFAFO,qBAAO,OAEP;AAAE,wFAFO,qBAAO,OAEP;AAAE,yFAFO,sBAAQ,OAEP;AACnC,kBAAe,qBAAK,CAAA"}
|
package/dist/cjs/get.d.ts
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight alternative to lodash.get with similar coverage
|
|
3
|
-
* Supports basic path lookup via dot notation `'foo.bar[0].baz'` or an array ['foo', 'bar', '0', 'baz']
|
|
4
|
-
*/
|
|
5
1
|
export declare function get<T = unknown, Default = undefined>(obj: any, path: string | string[], defValue?: Default): T | Default | undefined;
|
package/dist/cjs/get.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.get = void 0;
|
|
4
|
-
|
|
5
|
-
* Lightweight alternative to lodash.get with similar coverage
|
|
6
|
-
* Supports basic path lookup via dot notation `'foo.bar[0].baz'` or an array ['foo', 'bar', '0', 'baz']
|
|
7
|
-
*/
|
|
8
|
-
function get(
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
obj, path, defValue) {
|
|
11
|
-
// If path is not defined or it has false value
|
|
4
|
+
function get(obj, path, defValue) {
|
|
12
5
|
if (!path)
|
|
13
6
|
return defValue;
|
|
14
|
-
// Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
|
|
15
|
-
// Regex explained: https://regexr.com/58j0k
|
|
16
7
|
const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
|
|
17
|
-
// Find value if exist return otherwise return undefined value
|
|
18
8
|
const value = pathArray.reduce((prevObj, key) => prevObj && prevObj[key], obj);
|
|
19
9
|
return typeof value !== 'undefined' ? value : defValue;
|
|
20
10
|
}
|
package/dist/cjs/get.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../src/get.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../src/get.ts"],"names":[],"mappings":";;;AAIA,SAAgB,GAAG,CAEjB,GAAQ,EACR,IAAuB,EACvB,QAAkB;IAGlB,IAAI,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAA;IAI1B,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAc,CAAA;IAGtF,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;IAC9E,OAAO,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxD,CAAC;AAhBD,kBAgBC"}
|
package/dist/cjs/map-values.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight alternative to lodash.mapValues
|
|
3
|
-
* Creates an object with the same keys as the input object
|
|
4
|
-
*/
|
|
5
1
|
export declare function mapValues<Values extends Record<string, unknown>, Obj extends Record<string, Values>, ValueKey extends keyof Values>(obj: Obj, key: ValueKey): {
|
|
6
2
|
[K in keyof Obj]: Obj[K][ValueKey];
|
|
7
3
|
};
|
package/dist/cjs/map-values.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapValues = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Lightweight alternative to lodash.mapValues
|
|
6
|
-
* Creates an object with the same keys as the input object
|
|
7
|
-
*/
|
|
8
4
|
function mapValues(obj, key) {
|
|
9
5
|
return Object.entries(obj).reduce((agg, [name, value]) => {
|
|
10
|
-
// @ts-ignore this is a pretty complex type, skipping for now
|
|
11
6
|
agg[name] = value[key];
|
|
12
7
|
return agg;
|
|
13
8
|
}, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-values.js","sourceRoot":"","sources":["../../src/map-values.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"map-values.js","sourceRoot":"","sources":["../../src/map-values.ts"],"names":[],"mappings":";;;AAIA,SAAgB,SAAS,CAIvB,GAAQ,EAAE,GAAa;IACvB,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QAEvD,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;QACtB,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAA4C,CAAC,CAAA;AAClD,CAAC;AAVD,8BAUC"}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import { JSONObject, JSONLikeObject } from '../json-object';
|
|
2
|
-
/**
|
|
3
|
-
* Validates and transforms a mapping by applying the input payload
|
|
4
|
-
* based on the directives and raw values defined in the mapping object
|
|
5
|
-
* @param mapping - the directives and raw values
|
|
6
|
-
* @param payload - the input data to apply to directives
|
|
7
|
-
*/
|
|
8
2
|
export declare function transform(mapping: JSONLikeObject, payload?: JSONObject): JSONObject;
|