@studyportals/campaign-management-api-interface 3.8.1-1 → 3.8.1-3

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 (25) hide show
  1. package/package.json +1 -1
  2. package/src/errors/internal-error.d.ts +3 -0
  3. package/src/errors/internal-error.js +12 -0
  4. package/src/errors/internal-error.js.map +1 -0
  5. package/src/organisations-campaign-management-api.client.d.ts +4 -4
  6. package/src/organisations-campaign-management-api.client.js +34 -6
  7. package/src/organisations-campaign-management-api.client.js.map +1 -1
  8. package/src/validation/dto/organisations/create-source-links.request.d.ts +2 -2
  9. package/src/validation/dto/organisations/create-source-links.request.js +3 -2
  10. package/src/validation/dto/organisations/create-source-links.request.js.map +1 -1
  11. package/src/validation/dto/organisations/index.d.ts +3 -3
  12. package/src/validation/dto/organisations/index.js +4 -4
  13. package/src/validation/dto/organisations/index.js.map +1 -1
  14. package/src/validation/dto/organisations/{create-source-link-validator.d.ts → source-link-create.dto.d.ts} +2 -2
  15. package/src/validation/dto/organisations/{create-source-link-validator.js → source-link-create.dto.js} +12 -10
  16. package/src/validation/dto/organisations/source-link-create.dto.js.map +1 -0
  17. package/src/validation/dto/organisations/source-link-update.dto.d.ts +4 -0
  18. package/src/validation/dto/organisations/{update-source-link-validator.js → source-link-update.dto.js} +7 -7
  19. package/src/validation/dto/organisations/source-link-update.dto.js.map +1 -0
  20. package/src/validation/dto/organisations/update-source-links.request.d.ts +2 -2
  21. package/src/validation/dto/organisations/update-source-links.request.js +3 -2
  22. package/src/validation/dto/organisations/update-source-links.request.js.map +1 -1
  23. package/src/validation/dto/organisations/create-source-link-validator.js.map +0 -1
  24. package/src/validation/dto/organisations/update-source-link-validator.d.ts +0 -4
  25. package/src/validation/dto/organisations/update-source-link-validator.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studyportals/campaign-management-api-interface",
3
- "version": "3.8.1-1",
3
+ "version": "3.8.1-3",
4
4
  "scripts": {
5
5
  "compile": "rm -fR bin && npx tsc",
6
6
  "test-u": "jest -c jest.config.unit.json --maxWorkers=1",
@@ -0,0 +1,3 @@
1
+ export declare class InternalError extends Error {
2
+ constructor(message: string);
3
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InternalError = void 0;
4
+ class InternalError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'InternalError';
8
+ this.message = message;
9
+ }
10
+ }
11
+ exports.InternalError = InternalError;
12
+ //# sourceMappingURL=internal-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-error.js","sourceRoot":"","sources":["../../../src/errors/internal-error.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;IACvC,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD;AAND,sCAMC"}
@@ -1,16 +1,16 @@
1
1
  import "reflect-metadata";
2
2
  import { MinimalOrganisationDto } from "./domain/organisations/minimal-organisations.dto";
3
3
  import { SourceLinkDto } from "./domain/organisations";
4
- import { CreateSourceLinkValidator } from "./validation/dto/organisations/create-source-link-validator";
5
- import { UpdateSourceLinkValidator } from "./validation/dto/organisations/update-source-link-validator";
4
+ import { SourceLinkCreateDto } from "./validation/dto/organisations/source-link-create.dto";
5
+ import { SourceLinkUpdateDto } from "./validation/dto/organisations/source-link-update.dto";
6
6
  export declare class OrganisationsCampaignManagementAPIClient {
7
7
  private readonly baseUrl;
8
8
  constructor(baseUrl: string);
9
9
  getMinimalOrganisation(organisationID: number, jwt?: string): Promise<MinimalOrganisationDto>;
10
10
  searchOrganisations(searchTerm: string, jwt?: string, limit?: number): Promise<MinimalOrganisationDto[]>;
11
11
  getSourceLinks(organisationID: number, jwt?: string): Promise<SourceLinkDto[]>;
12
- createSourceLinks(organisationID: number, sourceLinks: CreateSourceLinkValidator[], jwt?: string): Promise<void>;
13
- updateSourceLinks(organisationID: number, sourceLinks: UpdateSourceLinkValidator[], jwt?: string): Promise<void>;
12
+ createSourceLinks(organisationID: number, sourceLinks: SourceLinkCreateDto[], jwt?: string): Promise<void>;
13
+ updateSourceLinks(organisationID: number, sourceLinks: SourceLinkUpdateDto[], jwt?: string): Promise<void>;
14
14
  private postRequest;
15
15
  private putRequest;
16
16
  private getRequest;
@@ -13,9 +13,12 @@ exports.OrganisationsCampaignManagementAPIClient = void 0;
13
13
  require("reflect-metadata");
14
14
  const inversify_1 = require("inversify");
15
15
  const superagent = require("superagent");
16
+ const source_link_create_dto_1 = require("./validation/dto/organisations/source-link-create.dto");
17
+ const source_link_update_dto_1 = require("./validation/dto/organisations/source-link-update.dto");
16
18
  const update_source_links_request_1 = require("./validation/dto/organisations/update-source-links.request");
17
19
  const class_validator_1 = require("class-validator");
18
20
  const create_source_links_request_1 = require("./validation/dto/organisations/create-source-links.request");
21
+ const internal_error_1 = require("./errors/internal-error");
19
22
  let OrganisationsCampaignManagementAPIClient = class OrganisationsCampaignManagementAPIClient {
20
23
  constructor(baseUrl) {
21
24
  this.baseUrl = baseUrl;
@@ -56,36 +59,61 @@ let OrganisationsCampaignManagementAPIClient = class OrganisationsCampaignManage
56
59
  async createSourceLinks(organisationID, sourceLinks, jwt = "") {
57
60
  try {
58
61
  const path = `organisations/${organisationID}/source-links`;
62
+ const sourceLinksValidatorMap = sourceLinks.map(dto => {
63
+ const validator = new source_link_create_dto_1.SourceLinkCreateDto();
64
+ validator.level = dto.level;
65
+ validator.type = dto.type;
66
+ validator.subType = dto.subType;
67
+ validator.url = dto.url;
68
+ validator.doesExist = dto.doesExist;
69
+ return validator;
70
+ });
59
71
  const data = new create_source_links_request_1.CreateSourceLinksRequest();
60
- data.sourceLinks = sourceLinks;
72
+ data.sourceLinks = sourceLinksValidatorMap;
61
73
  const errors = await (0, class_validator_1.validate)(data);
62
74
  if (errors.length > 0) {
63
- throw new Error(`createSourceLinks validation error: ${errors}`);
75
+ throw new internal_error_1.InternalError(`createSourceLinks validation error: ${errors}`);
64
76
  }
65
77
  const result = await this.postRequest(path, data, jwt);
66
78
  if (result.status !== 201) {
67
- throw new Error(`createSourceLinks status is not 201. ${result.body}`);
79
+ throw new internal_error_1.InternalError(`createSourceLinks status is not 201. ${result.body}`);
68
80
  }
69
81
  }
70
82
  catch (error) {
83
+ if (error instanceof internal_error_1.InternalError) {
84
+ throw error;
85
+ }
71
86
  throw new Error(`createSourceLinks error: ${error}`);
72
87
  }
73
88
  }
74
89
  async updateSourceLinks(organisationID, sourceLinks, jwt = "") {
75
90
  try {
76
91
  const path = `organisations/${organisationID}/source-links`;
92
+ const sourceLinksValidatorMap = sourceLinks.map(dto => {
93
+ const validator = new source_link_update_dto_1.SourceLinkUpdateDto();
94
+ validator.level = dto.level;
95
+ validator.type = dto.type;
96
+ validator.subType = dto.subType;
97
+ validator.url = dto.url;
98
+ validator.doesExist = dto.doesExist;
99
+ validator.id = dto.id;
100
+ return validator;
101
+ });
77
102
  const data = new update_source_links_request_1.UpdateSourceLinksRequest();
78
- data.sourceLinks = sourceLinks;
103
+ data.sourceLinks = sourceLinksValidatorMap;
79
104
  const errors = await (0, class_validator_1.validate)(data);
80
105
  if (errors.length > 0) {
81
- throw new Error(`updateSourceLinks validation error: ${errors}`);
106
+ throw new internal_error_1.InternalError(`updateSourceLinks validation error: ${errors}`);
82
107
  }
83
108
  const result = await this.putRequest(path, data, jwt);
84
109
  if (result.status !== 200) {
85
- throw new Error(`updateSourceLinks status is not 200. ${result.body}`);
110
+ throw new internal_error_1.InternalError(`updateSourceLinks status is not 200. ${result.body}`);
86
111
  }
87
112
  }
88
113
  catch (error) {
114
+ if (error instanceof internal_error_1.InternalError) {
115
+ throw error;
116
+ }
89
117
  throw new Error(`updateSourceLinks error: ${error}`);
90
118
  }
91
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"organisations-campaign-management-api.client.js","sourceRoot":"","sources":["../../src/organisations-campaign-management-api.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAA0B;AAG1B,yCAAuC;AAEvC,yCAAyC;AAKzC,4GAAsG;AACtG,qDAA2C;AAC3C,4GAAsG;AAG/F,IAAM,wCAAwC,GAA9C,MAAM,wCAAwC;IACpD,YACkB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAC7B,CAAC;IAEE,KAAK,CAAC,sBAAsB,CAAC,cAAsB,EAAE,GAAG,GAAG,EAAE;QACnE,IAAI;YACH,MAAM,IAAI,GAAG,yBAAyB,cAAc,EAAE,CAAC;YACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAEhD,OAAO,MAAM,CAAC,IAA8B,CAAC;SAC7C;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;SAC1D;IACF,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,UAAkB,EAAE,GAAG,GAAG,EAAE,EAAE,KAAK,GAAG,EAAE;QACxE,IAAI;YACH,MAAM,IAAI,GAAG,sBAAsB,CAAC;YACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;gBAC3C,UAAU;gBACV,KAAK;aACL,EAAE,GAAG,CAAC,CAAC;YAER,OAAO,MAAM,CAAC,IAAgC,CAAC;SAC/C;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,EAAE,CAAC,CAAC;SACvD;IACF,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,cAAsB,EAAE,GAAG,GAAG,EAAE;QAC3D,IAAI;YACH,MAAM,IAAI,GAAG,iBAAiB,cAAc,eAAe,CAAC;YAC5D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,C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EAAE,kBAAkB,CAAC;aACvC,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC;aACzB,IAAI,EAAE,CAAC;IACV,CAAC;IAGO,YAAY,CAAC,QAAgB;QACpC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,EAAE,CAAC;IACtC,CAAC;CACD,CAAA;AA3GY,wCAAwC;IADpD,IAAA,sBAAU,GAAE;;GACA,wCAAwC,CA2GpD;AA3GY,4FAAwC"}
1
+ {"version":3,"file":"organisations-campaign-management-api.client.js","sourceRoot":"","sources":["../../src/organisations-campaign-management-api.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAA0B;AAG1B,yCAAuC;AAEvC,yCAAyC;AAGzC,kGAA4F;AAC5F,kGAA4F;AAC5F,4GAAsG;AACtG,qDAA2C;AAC3C,4GAAsG;AACtG,4DAAwD;AAGjD,IAAM,wCAAwC,GAA9C,MAAM,wCAAwC;IACpD,YACkB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAC7B,CAAC;IAEE,KAAK,CAAC,sBAAsB,CAAC,cAAsB,EAAE,GAAG,GAAG,EAAE;QACnE,IAAI;YACH,MAAM,IAAI,GAAG,yBAAyB,cAAc,EAAE,CAAC;YACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAEhD,OAAO,MAAM,CAAC,IAA8B,CAAC;SAC7C;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;SAC1D;IACF,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,UAAkB,EAAE,GAAG,GAAG,EAAE,EAAE,KAAK,GAAG,EAAE;QACxE,IAAI;YACH,MAAM,IAAI,GAAG,sBAAsB,CAAC;YACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;gBAC3C,UAAU;gBACV,KAAK;aACL,EA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C,IAAI,CAAC,CAAC;IACd,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,WAAmB,EAAE,EAAE,GAAG,GAAG,EAAE;QACvD,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;aACtD,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC;aACvC,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC;aACzB,IAAI,EAAE,CAAC;IACV,CAAC;IAGO,YAAY,CAAC,QAAgB;QACpC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,EAAE,CAAC;IACtC,CAAC;CACD,CAAA;AAxIY,wCAAwC;IADpD,IAAA,sBAAU,GAAE;;GACA,wCAAwC,CAwIpD;AAxIY,4FAAwC"}
@@ -1,4 +1,4 @@
1
- import { CreateSourceLinkValidator } from "./create-source-link-validator";
1
+ import { SourceLinkCreateDto } from "./source-link-create.dto";
2
2
  export declare class CreateSourceLinksRequest {
3
- sourceLinks: CreateSourceLinkValidator[];
3
+ sourceLinks: SourceLinkCreateDto[];
4
4
  }
@@ -12,12 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CreateSourceLinksRequest = void 0;
13
13
  const class_transformer_1 = require("class-transformer");
14
14
  const class_validator_1 = require("class-validator");
15
- const create_source_link_validator_1 = require("./create-source-link-validator");
15
+ const source_link_create_dto_1 = require("./source-link-create.dto");
16
16
  class CreateSourceLinksRequest {
17
17
  }
18
18
  __decorate([
19
+ (0, class_validator_1.IsArray)(),
19
20
  (0, class_validator_1.ValidateNested)({ each: true }),
20
- (0, class_transformer_1.Type)(() => create_source_link_validator_1.CreateSourceLinkValidator),
21
+ (0, class_transformer_1.Type)(() => source_link_create_dto_1.SourceLinkCreateDto),
21
22
  __metadata("design:type", Array)
22
23
  ], CreateSourceLinksRequest.prototype, "sourceLinks", void 0);
23
24
  exports.CreateSourceLinksRequest = CreateSourceLinksRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"create-source-links.request.js","sourceRoot":"","sources":["../../../../../src/validation/dto/organisations/create-source-links.request.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAA6D;AAC7D,iFAA2E;AAE3E,MAAa,wBAAwB;CAIpC;AAHA;IAAC,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAC,CAAC;IAC7B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,wDAAyB,CAAC;;6DACG;AAH1C,4DAIC"}
1
+ {"version":3,"file":"create-source-links.request.js","sourceRoot":"","sources":["../../../../../src/validation/dto/organisations/create-source-links.request.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAA0D;AAC1D,qEAA+D;AAE/D,MAAa,wBAAwB;CAKpC;AAJA;IAAC,IAAA,yBAAO,GAAE;IACT,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAC,CAAC;IAC7B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,4CAAmB,CAAC;;6DACG;AAJpC,4DAKC"}
@@ -1,5 +1,5 @@
1
- import { CreateSourceLinkValidator } from "./create-source-link-validator";
1
+ import { SourceLinkCreateDto } from "./source-link-create.dto";
2
2
  import { CreateSourceLinksRequest } from "./create-source-links.request";
3
- import { UpdateSourceLinkValidator } from "./update-source-link-validator";
3
+ import { SourceLinkUpdateDto } from "./source-link-update.dto";
4
4
  import { UpdateSourceLinksRequest } from "./update-source-links.request";
5
- export { CreateSourceLinksRequest, CreateSourceLinkValidator, UpdateSourceLinkValidator, UpdateSourceLinksRequest };
5
+ export { CreateSourceLinksRequest, SourceLinkCreateDto as CreateSourceLinkValidator, SourceLinkUpdateDto as UpdateSourceLinkValidator, UpdateSourceLinksRequest };
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UpdateSourceLinksRequest = exports.UpdateSourceLinkValidator = exports.CreateSourceLinkValidator = exports.CreateSourceLinksRequest = void 0;
4
- const create_source_link_validator_1 = require("./create-source-link-validator");
5
- Object.defineProperty(exports, "CreateSourceLinkValidator", { enumerable: true, get: function () { return create_source_link_validator_1.CreateSourceLinkValidator; } });
4
+ const source_link_create_dto_1 = require("./source-link-create.dto");
5
+ Object.defineProperty(exports, "CreateSourceLinkValidator", { enumerable: true, get: function () { return source_link_create_dto_1.SourceLinkCreateDto; } });
6
6
  const create_source_links_request_1 = require("./create-source-links.request");
7
7
  Object.defineProperty(exports, "CreateSourceLinksRequest", { enumerable: true, get: function () { return create_source_links_request_1.CreateSourceLinksRequest; } });
8
- const update_source_link_validator_1 = require("./update-source-link-validator");
9
- Object.defineProperty(exports, "UpdateSourceLinkValidator", { enumerable: true, get: function () { return update_source_link_validator_1.UpdateSourceLinkValidator; } });
8
+ const source_link_update_dto_1 = require("./source-link-update.dto");
9
+ Object.defineProperty(exports, "UpdateSourceLinkValidator", { enumerable: true, get: function () { return source_link_update_dto_1.SourceLinkUpdateDto; } });
10
10
  const update_source_links_request_1 = require("./update-source-links.request");
11
11
  Object.defineProperty(exports, "UpdateSourceLinksRequest", { enumerable: true, get: function () { return update_source_links_request_1.UpdateSourceLinksRequest; } });
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/validation/dto/organisations/index.ts"],"names":[],"mappings":";;;AAAA,iFAA2E;AAO1E,0GAPQ,wDAAyB,OAOR;AAN1B,+EAAyE;AAKxE,yGALQ,sDAAwB,OAKR;AAJzB,iFAA2E;AAM1E,0GANQ,wDAAyB,OAMR;AAL1B,+EAAyE;AAMxE,yGANQ,sDAAwB,OAMR"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/validation/dto/organisations/index.ts"],"names":[],"mappings":";;;AAAA,qEAA+D;AAOvC,0GAPf,4CAAmB,OAOqB;AANjD,+EAAyE;AAKxE,yGALQ,sDAAwB,OAKR;AAJzB,qEAA+D;AAMvC,0GANf,4CAAmB,OAMqB;AALjD,+EAAyE;AAMxE,yGANQ,sDAAwB,OAMR"}
@@ -1,8 +1,8 @@
1
1
  import { SourceLinkLevels, SourceLinkTypes, SourceLinkSubTypes } from "../../../domain/organisations";
2
- export declare class CreateSourceLinkValidator {
2
+ export declare class SourceLinkCreateDto {
3
3
  level: SourceLinkLevels;
4
4
  type: SourceLinkTypes;
5
5
  subType: SourceLinkSubTypes;
6
- url: string;
6
+ url: string | null;
7
7
  doesExist: boolean;
8
8
  }
@@ -9,30 +9,32 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CreateSourceLinkValidator = void 0;
12
+ exports.SourceLinkCreateDto = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
14
  const organisations_1 = require("../../../domain/organisations");
15
- class CreateSourceLinkValidator {
15
+ class SourceLinkCreateDto {
16
16
  }
17
17
  __decorate([
18
18
  (0, class_validator_1.IsEnum)(organisations_1.SourceLinkLevels),
19
19
  __metadata("design:type", String)
20
- ], CreateSourceLinkValidator.prototype, "level", void 0);
20
+ ], SourceLinkCreateDto.prototype, "level", void 0);
21
21
  __decorate([
22
22
  (0, class_validator_1.IsEnum)(organisations_1.SourceLinkTypes),
23
23
  __metadata("design:type", String)
24
- ], CreateSourceLinkValidator.prototype, "type", void 0);
24
+ ], SourceLinkCreateDto.prototype, "type", void 0);
25
25
  __decorate([
26
26
  (0, class_validator_1.IsEnum)(organisations_1.SourceLinkSubTypes),
27
27
  __metadata("design:type", String)
28
- ], CreateSourceLinkValidator.prototype, "subType", void 0);
28
+ ], SourceLinkCreateDto.prototype, "subType", void 0);
29
29
  __decorate([
30
30
  (0, class_validator_1.IsString)(),
31
- __metadata("design:type", String)
32
- ], CreateSourceLinkValidator.prototype, "url", void 0);
31
+ (0, class_validator_1.ValidateIf)((_, value) => value !== null) // Allows only null, but disallows undefined
32
+ ,
33
+ __metadata("design:type", Object)
34
+ ], SourceLinkCreateDto.prototype, "url", void 0);
33
35
  __decorate([
34
36
  (0, class_validator_1.IsBoolean)(),
35
37
  __metadata("design:type", Boolean)
36
- ], CreateSourceLinkValidator.prototype, "doesExist", void 0);
37
- exports.CreateSourceLinkValidator = CreateSourceLinkValidator;
38
- //# sourceMappingURL=create-source-link-validator.js.map
38
+ ], SourceLinkCreateDto.prototype, "doesExist", void 0);
39
+ exports.SourceLinkCreateDto = SourceLinkCreateDto;
40
+ //# sourceMappingURL=source-link-create.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-link-create.dto.js","sourceRoot":"","sources":["../../../../../src/validation/dto/organisations/source-link-create.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA0E;AAC1E,iEAAsG;AAEtG,MAAa,mBAAmB;CAgB/B;AAfA;IAAC,IAAA,wBAAM,EAAC,gCAAgB,CAAC;;kDACD;AAExB;IAAC,IAAA,wBAAM,EAAC,+BAAe,CAAC;;iDACF;AAEtB;IAAC,IAAA,wBAAM,EAAC,kCAAkB,CAAC;;oDACC;AAE5B;IAAC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,EAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,4CAA4C;;;gDACnE;AAEnB;IAAC,IAAA,2BAAS,GAAE;;sDACO;AAfpB,kDAgBC"}
@@ -0,0 +1,4 @@
1
+ import { SourceLinkCreateDto } from "./source-link-create.dto";
2
+ export declare class SourceLinkUpdateDto extends SourceLinkCreateDto {
3
+ id: number;
4
+ }
@@ -9,15 +9,15 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.UpdateSourceLinkValidator = void 0;
12
+ exports.SourceLinkUpdateDto = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
- const create_source_link_validator_1 = require("./create-source-link-validator");
15
- class UpdateSourceLinkValidator extends create_source_link_validator_1.CreateSourceLinkValidator {
14
+ const source_link_create_dto_1 = require("./source-link-create.dto");
15
+ class SourceLinkUpdateDto extends source_link_create_dto_1.SourceLinkCreateDto {
16
16
  }
17
17
  __decorate([
18
- (0, class_validator_1.IsInt)(),
19
18
  (0, class_validator_1.Min)(1),
19
+ (0, class_validator_1.IsInt)(),
20
20
  __metadata("design:type", Number)
21
- ], UpdateSourceLinkValidator.prototype, "id", void 0);
22
- exports.UpdateSourceLinkValidator = UpdateSourceLinkValidator;
23
- //# sourceMappingURL=update-source-link-validator.js.map
21
+ ], SourceLinkUpdateDto.prototype, "id", void 0);
22
+ exports.SourceLinkUpdateDto = SourceLinkUpdateDto;
23
+ //# sourceMappingURL=source-link-update.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-link-update.dto.js","sourceRoot":"","sources":["../../../../../src/validation/dto/organisations/source-link-update.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA6C;AAC7C,qEAA+D;AAE/D,MAAa,mBAAoB,SAAQ,4CAAmB;CAI3D;AAHA;IAAC,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,uBAAK,GAAE;;+CACG;AAHZ,kDAIC"}
@@ -1,4 +1,4 @@
1
- import { UpdateSourceLinkValidator } from "./update-source-link-validator";
1
+ import { SourceLinkUpdateDto } from "./source-link-update.dto";
2
2
  export declare class UpdateSourceLinksRequest {
3
- sourceLinks: UpdateSourceLinkValidator[];
3
+ sourceLinks: SourceLinkUpdateDto[];
4
4
  }
@@ -12,12 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UpdateSourceLinksRequest = void 0;
13
13
  const class_transformer_1 = require("class-transformer");
14
14
  const class_validator_1 = require("class-validator");
15
- const update_source_link_validator_1 = require("./update-source-link-validator");
15
+ const source_link_update_dto_1 = require("./source-link-update.dto");
16
16
  class UpdateSourceLinksRequest {
17
17
  }
18
18
  __decorate([
19
+ (0, class_validator_1.IsArray)(),
19
20
  (0, class_validator_1.ValidateNested)({ each: true }),
20
- (0, class_transformer_1.Type)(() => update_source_link_validator_1.UpdateSourceLinkValidator),
21
+ (0, class_transformer_1.Type)(() => source_link_update_dto_1.SourceLinkUpdateDto),
21
22
  __metadata("design:type", Array)
22
23
  ], UpdateSourceLinksRequest.prototype, "sourceLinks", void 0);
23
24
  exports.UpdateSourceLinksRequest = UpdateSourceLinksRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"update-source-links.request.js","sourceRoot":"","sources":["../../../../../src/validation/dto/organisations/update-source-links.request.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAA6D;AAC7D,iFAA2E;AAE3E,MAAa,wBAAwB;CAIpC;AAHA;IAAC,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAC,CAAC;IAC7B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,wDAAyB,CAAC;;6DACG;AAH1C,4DAIC"}
1
+ {"version":3,"file":"update-source-links.request.js","sourceRoot":"","sources":["../../../../../src/validation/dto/organisations/update-source-links.request.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAyC;AACzC,qDAA0D;AAC1D,qEAA+D;AAE/D,MAAa,wBAAwB;CAKpC;AAJA;IAAC,IAAA,yBAAO,GAAE;IACT,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,4CAAmB,CAAC;;6DACG;AAJpC,4DAKC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-source-link-validator.js","sourceRoot":"","sources":["../../../../../src/validation/dto/organisations/create-source-link-validator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAoE;AACpE,iEAAsG;AAEtG,MAAa,yBAAyB;CAerC;AAdA;IAAC,IAAA,wBAAM,EAAC,gCAAgB,CAAC;;wDACD;AAExB;IAAC,IAAA,wBAAM,EAAC,+BAAe,CAAC;;uDACF;AAEtB;IAAC,IAAA,wBAAM,EAAC,kCAAkB,CAAC;;0DACC;AAE5B;IAAC,IAAA,0BAAQ,GAAE;;sDACC;AAEZ;IAAC,IAAA,2BAAS,GAAE;;4DACO;AAdpB,8DAeC"}
@@ -1,4 +0,0 @@
1
- import { CreateSourceLinkValidator } from "./create-source-link-validator";
2
- export declare class UpdateSourceLinkValidator extends CreateSourceLinkValidator {
3
- id: number;
4
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-source-link-validator.js","sourceRoot":"","sources":["../../../../../src/validation/dto/organisations/update-source-link-validator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA6C;AAC7C,iFAA2E;AAE3E,MAAa,yBAA0B,SAAQ,wDAAyB;CAIvE;AAHA;IAAC,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;;qDACI;AAHZ,8DAIC"}