@studyportals/campaign-management-api-interface 7.0.1-0 → 7.0.1-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.
- package/package.json +1 -1
- package/src/validation/campaign/campaign-lift-excluded-field-validator.d.ts +22 -0
- package/src/validation/campaign/campaign-lift-excluded-field-validator.js +43 -0
- package/src/validation/campaign/campaign-lift-excluded-field-validator.js.map +1 -0
- package/src/validation/index.d.ts +2 -1
- package/src/validation/index.js +3 -1
- package/src/validation/index.js.map +1 -1
- package/src/validation/types/ValidationResult.d.ts +6 -3
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PartnershipType } from "../../domain/campaign";
|
|
2
|
+
export declare const USERS_ALLOWED_EDITING_CAMPAIGN_LIFT: number[];
|
|
3
|
+
export declare const CAMPAIGN_LIFT_EXCLUDED_ALLOWED_PARTNERSHIP_TYPES: PartnershipType[];
|
|
4
|
+
export declare class CampaignLiftExcludedFieldValidator {
|
|
5
|
+
/**
|
|
6
|
+
* Simple function checking if provided user has rights to edit the campaign lift excluded field.
|
|
7
|
+
*
|
|
8
|
+
* @param userId - ID of a user trying to edit the campaign lift excluded field
|
|
9
|
+
* @returns boolean - true if user has the rights, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
static validateRights(userId: number): boolean;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* Function validates whether campaign with provided partnership type can be excluded from campaign lift.
|
|
15
|
+
* If campaign is not excluded from campaign lift, function returns true.
|
|
16
|
+
*
|
|
17
|
+
* @param isExcludedFromCampaignLift
|
|
18
|
+
* @param partnershipType
|
|
19
|
+
* @returns boolean - true if the data is valid, false if partnership type is not allowed to be excluded from campaign lift
|
|
20
|
+
*/
|
|
21
|
+
static validateData(isExcludedFromCampaignLift: boolean, partnershipType: PartnershipType): boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CampaignLiftExcludedFieldValidator = exports.CAMPAIGN_LIFT_EXCLUDED_ALLOWED_PARTNERSHIP_TYPES = exports.USERS_ALLOWED_EDITING_CAMPAIGN_LIFT = void 0;
|
|
4
|
+
const campaign_1 = require("../../domain/campaign");
|
|
5
|
+
exports.USERS_ALLOWED_EDITING_CAMPAIGN_LIFT = [
|
|
6
|
+
3032728,
|
|
7
|
+
2089507
|
|
8
|
+
];
|
|
9
|
+
exports.CAMPAIGN_LIFT_EXCLUDED_ALLOWED_PARTNERSHIP_TYPES = [
|
|
10
|
+
campaign_1.PartnershipType.RBP,
|
|
11
|
+
campaign_1.PartnershipType.HYBRID_EBP,
|
|
12
|
+
];
|
|
13
|
+
class CampaignLiftExcludedFieldValidator {
|
|
14
|
+
/**
|
|
15
|
+
* Simple function checking if provided user has rights to edit the campaign lift excluded field.
|
|
16
|
+
*
|
|
17
|
+
* @param userId - ID of a user trying to edit the campaign lift excluded field
|
|
18
|
+
* @returns boolean - true if user has the rights, false otherwise
|
|
19
|
+
*/
|
|
20
|
+
static validateRights(userId) {
|
|
21
|
+
return exports.USERS_ALLOWED_EDITING_CAMPAIGN_LIFT.includes(userId);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* Function validates whether campaign with provided partnership type can be excluded from campaign lift.
|
|
26
|
+
* If campaign is not excluded from campaign lift, function returns true.
|
|
27
|
+
*
|
|
28
|
+
* @param isExcludedFromCampaignLift
|
|
29
|
+
* @param partnershipType
|
|
30
|
+
* @returns boolean - true if the data is valid, false if partnership type is not allowed to be excluded from campaign lift
|
|
31
|
+
*/
|
|
32
|
+
static validateData(isExcludedFromCampaignLift, partnershipType) {
|
|
33
|
+
if (isExcludedFromCampaignLift === false) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (!exports.CAMPAIGN_LIFT_EXCLUDED_ALLOWED_PARTNERSHIP_TYPES.includes(partnershipType)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.CampaignLiftExcludedFieldValidator = CampaignLiftExcludedFieldValidator;
|
|
43
|
+
//# sourceMappingURL=campaign-lift-excluded-field-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaign-lift-excluded-field-validator.js","sourceRoot":"","sources":["../../../../src/validation/campaign/campaign-lift-excluded-field-validator.ts"],"names":[],"mappings":";;;AAAA,oDAAwD;AAE3C,QAAA,mCAAmC,GAAI;IACnD,OAAO;IACP,OAAO;CACP,CAAC;AAEW,QAAA,gDAAgD,GAAG;IAC/D,0BAAe,CAAC,GAAG;IACnB,0BAAe,CAAC,UAAU;CAC1B,CAAC;AAEF,MAAa,kCAAkC;IAC9C;;;;;OAKG;IACI,MAAM,CAAC,cAAc,CAAC,MAAc;QAC1C,OAAO,2CAAmC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,YAAY,CAAC,0BAAmC,EAAE,eAAgC;QAE/F,IAAI,0BAA0B,KAAK,KAAK,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QACb,CAAC;QAED,IAAI,CAAC,wDAAgD,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;YACjF,OAAO,KAAK,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAhCD,gFAgCC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { CampaignLiftExcludedFieldValidator } from "./campaign/campaign-lift-excluded-field-validator";
|
|
1
2
|
import { CampaignMandatoryFieldsValidator } from "./campaign/mandatory-fields-validator";
|
|
2
3
|
import { SpecificResult } from "./types/SpecificResult";
|
|
3
4
|
import { ValidationResult } from "./types/ValidationResult";
|
|
4
5
|
export * from "./dto/organisations";
|
|
5
|
-
export { ValidationResult, SpecificResult, CampaignMandatoryFieldsValidator };
|
|
6
|
+
export { ValidationResult, SpecificResult, CampaignMandatoryFieldsValidator, CampaignLiftExcludedFieldValidator };
|
package/src/validation/index.js
CHANGED
|
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.CampaignMandatoryFieldsValidator = exports.SpecificResult = void 0;
|
|
17
|
+
exports.CampaignLiftExcludedFieldValidator = exports.CampaignMandatoryFieldsValidator = exports.SpecificResult = void 0;
|
|
18
|
+
const campaign_lift_excluded_field_validator_1 = require("./campaign/campaign-lift-excluded-field-validator");
|
|
19
|
+
Object.defineProperty(exports, "CampaignLiftExcludedFieldValidator", { enumerable: true, get: function () { return campaign_lift_excluded_field_validator_1.CampaignLiftExcludedFieldValidator; } });
|
|
18
20
|
const mandatory_fields_validator_1 = require("./campaign/mandatory-fields-validator");
|
|
19
21
|
Object.defineProperty(exports, "CampaignMandatoryFieldsValidator", { enumerable: true, get: function () { return mandatory_fields_validator_1.CampaignMandatoryFieldsValidator; } });
|
|
20
22
|
const SpecificResult_1 = require("./types/SpecificResult");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,sFAAyF;AASxF,iHATQ,6DAAgC,OASR;AARjC,2DAAwD;AAOvD,+FAPQ,+BAAc,OAOR;AAJf,sDAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8GAAuG;AAWtG,mHAXQ,2EAAkC,OAWR;AAVnC,sFAAyF;AASxF,iHATQ,6DAAgC,OASR;AARjC,2DAAwD;AAOvD,+FAPQ,+BAAc,OAOR;AAJf,sDAAoC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { CampaignEditorGetResultDto } from "../../domain/campaign";
|
|
2
|
+
type Properties = keyof CampaignEditorGetResultDto | "data";
|
|
1
3
|
export type ValidationResult = {
|
|
2
|
-
missing:
|
|
3
|
-
invalid:
|
|
4
|
-
valid:
|
|
4
|
+
missing: Properties[];
|
|
5
|
+
invalid: Properties[];
|
|
6
|
+
valid: Properties[];
|
|
5
7
|
};
|
|
8
|
+
export {};
|