@ampsec/platform-client 59.3.1 → 59.5.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/build/src/dto/flows.dto.d.ts +583 -39
- package/build/src/dto/flows.dto.js +65 -13
- package/build/src/dto/flows.dto.js.map +1 -1
- package/build/src/dto/platform/platform.flows.dto.d.ts +340 -36
- package/build/src/dto/platform/platform.flows.dto.js +8 -2
- package/build/src/dto/platform/platform.flows.dto.js.map +1 -1
- package/build/src/services/flowSpecs.service.d.ts +9 -0
- package/build/src/services/flowSpecs.service.js +32 -0
- package/build/src/services/flowSpecs.service.js.map +1 -0
- package/package.json +1 -1
- package/src/dto/flows.dto.ts +74 -13
- package/src/dto/platform/platform.flows.dto.ts +9 -3
- package/src/services/flowSpecs.service.ts +36 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FlowSpecCreateDto, FlowSpecDto, FlowSpecUpsertDto, Page } from '../dto';
|
|
2
|
+
import { RestClient } from './rest';
|
|
3
|
+
import { AmpEntityServiceImpl, EntityCallOptions } from './entity.service';
|
|
4
|
+
export declare class FlowSpecsService extends AmpEntityServiceImpl<FlowSpecUpsertDto, FlowSpecDto> {
|
|
5
|
+
constructor(rest: RestClient);
|
|
6
|
+
/** @deprecated Use `createFromName` instead */
|
|
7
|
+
create: (_model: FlowSpecUpsertDto | FlowSpecUpsertDto[], _options?: EntityCallOptions) => Promise<Page<FlowSpecDto>>;
|
|
8
|
+
createFromName: (model: FlowSpecCreateDto) => Promise<FlowSpecDto>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowSpecsService = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const entity_service_1 = require("./entity.service");
|
|
6
|
+
class FlowSpecsService extends entity_service_1.AmpEntityServiceImpl {
|
|
7
|
+
constructor(rest) {
|
|
8
|
+
super(rest, constants_1.KIND.FINDINGS);
|
|
9
|
+
/** @deprecated Use `createFromName` instead */
|
|
10
|
+
this.create = (_model, _options) => {
|
|
11
|
+
throw new Error('Method not implemented.');
|
|
12
|
+
};
|
|
13
|
+
this.createFromName = async (model) => {
|
|
14
|
+
const res = await this.call({
|
|
15
|
+
url: `/${this.targetApi}/v1/${this.kind}`,
|
|
16
|
+
method: 'POST',
|
|
17
|
+
data: model,
|
|
18
|
+
}, (error) => {
|
|
19
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
20
|
+
return {
|
|
21
|
+
data: [],
|
|
22
|
+
kind: this.kind.toUpperCase(),
|
|
23
|
+
error: message,
|
|
24
|
+
hints: {},
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
return res.data[0];
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.FlowSpecsService = FlowSpecsService;
|
|
32
|
+
//# sourceMappingURL=flowSpecs.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowSpecs.service.js","sourceRoot":"","sources":["../../../src/services/flowSpecs.service.ts"],"names":[],"mappings":";;;AAGA,2CAAiC;AACjC,qDAAyE;AAEzE,MAAa,gBAAiB,SAAQ,qCAAoD;IACxF,YAAY,IAAgB;QAC1B,KAAK,CAAC,IAAI,EAAE,gBAAI,CAAC,QAAQ,CAAC,CAAC;QAG7B,+CAA+C;QAC/C,WAAM,GAAG,CAAC,MAA+C,EAAE,QAA4B,EAA8B,EAAE;YACrH,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC,CAAC;QAEF,mBAAc,GAAG,KAAK,EAAE,KAAwB,EAAwB,EAAE;YACxE,MAAM,GAAG,GAAsB,MAAM,IAAI,CAAC,IAAI,CAC5C;gBACE,GAAG,EAAE,IAAI,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC,IAAI,EAAE;gBACzC,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,KAAK;aACZ,EACD,CAAC,KAAc,EAAE,EAAE;gBACjB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;gBACzE,OAAO;oBACL,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;oBAC7B,KAAK,EAAE,OAAO;oBACd,KAAK,EAAE,EAAE;iBACV,CAAC;YACJ,CAAC,CACF,CAAC;YACF,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC;IAzBF,CAAC;CA0BF;AA7BD,4CA6BC"}
|
package/package.json
CHANGED
package/src/dto/flows.dto.ts
CHANGED
|
@@ -56,7 +56,8 @@ export const _FlowStateStatusDto = z.enum(['RUNNING', 'ERROR', 'SUCCESS', 'CANCE
|
|
|
56
56
|
export type FlowStateStatusDto = z.infer<typeof _FlowStateStatusDto>;
|
|
57
57
|
|
|
58
58
|
export const _FlowStateDto = _BaseDto.extend({
|
|
59
|
-
|
|
59
|
+
/** `undefined` on NOOP Actions */
|
|
60
|
+
specId: z.string().optional(),
|
|
60
61
|
uid: z.string().optional(),
|
|
61
62
|
fid: z.string().optional(),
|
|
62
63
|
status: _FlowStateStatusDto,
|
|
@@ -80,27 +81,87 @@ export type FlowStateFilter = z.infer<typeof _FlowStateFilter>;
|
|
|
80
81
|
* | FlowSpec |
|
|
81
82
|
* \====================/
|
|
82
83
|
*/
|
|
84
|
+
export const _FlowSpecCreateDto = z.object({
|
|
85
|
+
name: z.string(),
|
|
86
|
+
description: z.string(),
|
|
87
|
+
});
|
|
88
|
+
export type FlowSpecCreateDto = z.infer<typeof _FlowSpecCreateDto>;
|
|
89
|
+
|
|
90
|
+
export enum FlowSpecStatusKind {
|
|
91
|
+
ACTIVE = 'ACTIVE',
|
|
92
|
+
PAUSED = 'PAUSED',
|
|
93
|
+
ERROR = 'ERROR',
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const _FlowTrigger = z.object({
|
|
97
|
+
key: z.string(),
|
|
98
|
+
displayValue: z.string().optional(),
|
|
99
|
+
});
|
|
100
|
+
export type FlowTrigger = z.infer<typeof _FlowTrigger>;
|
|
101
|
+
|
|
102
|
+
const _FlowTriggerFilter = z.object({
|
|
103
|
+
trigger: z.array(_FlowTrigger),
|
|
104
|
+
custom: z.record(z.unknown()).optional(),
|
|
105
|
+
});
|
|
106
|
+
export type FlowTriggerFilter = z.infer<typeof _FlowTriggerFilter>;
|
|
107
|
+
const _FlowFilter = z.object({
|
|
108
|
+
cohorts: z.array(z.unknown()),
|
|
109
|
+
custom: z.record(z.unknown()).optional(),
|
|
110
|
+
});
|
|
111
|
+
const _FlowTone = z.object({
|
|
112
|
+
kind: z.string(),
|
|
113
|
+
});
|
|
114
|
+
export const _FlowInterval = z.object({
|
|
115
|
+
minutes: z.number(),
|
|
116
|
+
value: z.number().optional(),
|
|
117
|
+
units: z.string().optional(),
|
|
118
|
+
});
|
|
119
|
+
export type FlowInterval = z.infer<typeof _FlowInterval>;
|
|
120
|
+
|
|
121
|
+
export const _FlowActions = z.object({
|
|
122
|
+
includeInstructions: z.boolean().optional(),
|
|
123
|
+
// TODO instructions contact address???
|
|
124
|
+
expirationActionId: z.string().optional(),
|
|
125
|
+
});
|
|
126
|
+
export type FlowActions = z.infer<typeof _FlowActions>;
|
|
127
|
+
export const _FlowRewardsConfig = z.object({
|
|
128
|
+
isUpperBound: z.boolean(),
|
|
129
|
+
points: z.number(),
|
|
130
|
+
minutes: z.number(),
|
|
131
|
+
value: z.number().optional(),
|
|
132
|
+
units: z.string().optional(),
|
|
133
|
+
});
|
|
134
|
+
export type FlowRewardsConfig = z.infer<typeof _FlowRewardsConfig>;
|
|
135
|
+
|
|
83
136
|
export const _FlowSpecDto = _BaseDto.merge(
|
|
84
137
|
z.object({
|
|
85
138
|
id: z.string(),
|
|
86
|
-
tid: z.string()
|
|
139
|
+
tid: z.string(),
|
|
140
|
+
status: z.nativeEnum(FlowSpecStatusKind),
|
|
87
141
|
name: z.string(),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
custom: z.record(z.unknown()).optional(),
|
|
92
|
-
}),
|
|
142
|
+
description: z.string(),
|
|
143
|
+
fslStrategy: z.enum(['STANDARD']).optional().default('STANDARD'),
|
|
144
|
+
triggerFilter: _FlowTriggerFilter,
|
|
93
145
|
/** cohort filter */
|
|
94
|
-
filter:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
146
|
+
filter: _FlowFilter,
|
|
147
|
+
engagementChannelCids: z.array(z.string()),
|
|
148
|
+
tone: _FlowTone.optional(),
|
|
149
|
+
targetResolution: _FlowInterval.optional(),
|
|
150
|
+
reminderInterval: _FlowInterval.optional(),
|
|
151
|
+
actions: _FlowActions.optional(),
|
|
152
|
+
rewards: z.array(_FlowRewardsConfig).optional(),
|
|
153
|
+
activity: z
|
|
154
|
+
.object({
|
|
155
|
+
lastTriggered: z.string().optional(),
|
|
156
|
+
activeCount: z.number().default(0),
|
|
157
|
+
totalCount: z.number().default(0),
|
|
158
|
+
})
|
|
159
|
+
.optional(),
|
|
98
160
|
})
|
|
99
161
|
);
|
|
100
|
-
|
|
101
162
|
export type FlowSpecDto = z.infer<typeof _FlowSpecDto>;
|
|
102
163
|
|
|
103
|
-
export const _FlowSpecUpsertDto = _FlowSpecDto.merge(_BaseUpsertDto);
|
|
164
|
+
export const _FlowSpecUpsertDto = _FlowSpecDto.omit({activity: true}).merge(_BaseUpsertDto);
|
|
104
165
|
export type FlowSpecUpsertDto = z.infer<typeof _FlowSpecUpsertDto>;
|
|
105
166
|
|
|
106
167
|
export const _FlowSpecFilter = _FlowSpecDto.omit({triggerFilter: true, filter: true}).partial().merge(_PaginationFilter).merge(_SortFilter);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {z} from 'zod';
|
|
2
|
-
import {_FlowSpecDto, _FlowSpecUpsertDto, _FlowStateDto, _FlowStateUpsertDto} from '../flows.dto';
|
|
2
|
+
import {FlowSpecStatusKind, _FlowSpecDto, _FlowSpecUpsertDto, _FlowStateDto, _FlowStateUpsertDto} from '../flows.dto';
|
|
3
3
|
import {_TenantBased, _UpsertTenantBased} from './tenant.based.dto';
|
|
4
4
|
|
|
5
5
|
/*
|
|
@@ -26,13 +26,19 @@ export type PlatformFlowStateDto = z.infer<typeof _PlatformFlowStateDto>;
|
|
|
26
26
|
|
|
27
27
|
export const NOOP_FLOW_SPEC: PlatformFlowSpecDto = {
|
|
28
28
|
id: '000000000000',
|
|
29
|
+
tid: '000000000000',
|
|
30
|
+
status: FlowSpecStatusKind.ACTIVE,
|
|
31
|
+
engagementChannelCids: [],
|
|
29
32
|
createdAt: '2023-04-17T13:00:00.000Z',
|
|
30
33
|
updatedAt: '2023-04-17T13:00:00.000Z',
|
|
31
34
|
deletedAt: null,
|
|
32
35
|
name: 'NOOP - DROP TRIGGER EVENT',
|
|
36
|
+
description: 'Used internally to drop trigger events',
|
|
33
37
|
fslStrategy: 'STANDARD',
|
|
34
38
|
triggerFilter: {
|
|
35
|
-
trigger: 'noop',
|
|
39
|
+
trigger: [{key: 'noop', displayValue: 'NOOP'}],
|
|
40
|
+
},
|
|
41
|
+
filter: {
|
|
42
|
+
cohorts: [],
|
|
36
43
|
},
|
|
37
|
-
filter: {},
|
|
38
44
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import {FlowSpecCreateDto, FlowSpecDto, FlowSpecUpsertDto, Page} from '../dto';
|
|
3
|
+
import {RestClient} from './rest';
|
|
4
|
+
import {KIND} from './constants';
|
|
5
|
+
import {AmpEntityServiceImpl, EntityCallOptions} from './entity.service';
|
|
6
|
+
|
|
7
|
+
export class FlowSpecsService extends AmpEntityServiceImpl<FlowSpecUpsertDto, FlowSpecDto> {
|
|
8
|
+
constructor(rest: RestClient) {
|
|
9
|
+
super(rest, KIND.FINDINGS);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** @deprecated Use `createFromName` instead */
|
|
13
|
+
create = (_model: FlowSpecUpsertDto | FlowSpecUpsertDto[], _options?: EntityCallOptions): Promise<Page<FlowSpecDto>> => {
|
|
14
|
+
throw new Error('Method not implemented.');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
createFromName = async (model: FlowSpecCreateDto): Promise<FlowSpecDto> => {
|
|
18
|
+
const res: Page<FlowSpecDto> = await this.call(
|
|
19
|
+
{
|
|
20
|
+
url: `/${this.targetApi}/v1/${this.kind}`,
|
|
21
|
+
method: 'POST',
|
|
22
|
+
data: model,
|
|
23
|
+
},
|
|
24
|
+
(error: unknown) => {
|
|
25
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
26
|
+
return {
|
|
27
|
+
data: [],
|
|
28
|
+
kind: this.kind.toUpperCase(),
|
|
29
|
+
error: message,
|
|
30
|
+
hints: {},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
return res.data[0];
|
|
35
|
+
};
|
|
36
|
+
}
|