@studyportals/campaign-management-api-interface 16.4.3-5 → 17.0.2-2

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 (49) hide show
  1. package/index.d.ts +3 -5
  2. package/index.js +3 -6
  3. package/index.js.map +1 -1
  4. package/package.json +4 -7
  5. package/src/auditor-campaign-management-api.client.d.ts +0 -5
  6. package/src/auditor-campaign-management-api.client.js +8 -28
  7. package/src/auditor-campaign-management-api.client.js.map +1 -1
  8. package/src/campaign-management-api.client.d.ts +12 -25
  9. package/src/campaign-management-api.client.js +65 -220
  10. package/src/campaign-management-api.client.js.map +1 -1
  11. package/src/domain/campaign/index.d.ts +1 -3
  12. package/src/domain/campaign/index.js +1 -3
  13. package/src/domain/campaign/index.js.map +1 -1
  14. package/src/errors/http-error.d.ts +12 -0
  15. package/src/errors/http-error.js +12 -0
  16. package/src/errors/http-error.js.map +1 -0
  17. package/src/links-campaign-management-api.client.js +2 -5
  18. package/src/links-campaign-management-api.client.js.map +1 -1
  19. package/src/organisations-campaign-management-api.client.d.ts +1 -0
  20. package/src/organisations-campaign-management-api.client.js +8 -17
  21. package/src/organisations-campaign-management-api.client.js.map +1 -1
  22. package/src/private-campaign-management-api.client.d.ts +1 -43
  23. package/src/private-campaign-management-api.client.js +23 -97
  24. package/src/private-campaign-management-api.client.js.map +1 -1
  25. package/src/products-campaign-management-api.client.js +2 -5
  26. package/src/products-campaign-management-api.client.js.map +1 -1
  27. package/src/study-campaign-management-api.client.js +2 -5
  28. package/src/study-campaign-management-api.client.js.map +1 -1
  29. package/src/user-campaign-management-api.client.d.ts +1 -0
  30. package/src/user-campaign-management-api.client.js +8 -16
  31. package/src/user-campaign-management-api.client.js.map +1 -1
  32. package/src/utils/http-request.d.ts +33 -0
  33. package/src/utils/http-request.js +57 -0
  34. package/src/utils/http-request.js.map +1 -0
  35. package/src/campaign-saving/index.d.ts +0 -3
  36. package/src/campaign-saving/index.js +0 -6
  37. package/src/campaign-saving/index.js.map +0 -1
  38. package/src/campaign-saving/websocket-data-type.d.ts +0 -19
  39. package/src/campaign-saving/websocket-data-type.js +0 -3
  40. package/src/campaign-saving/websocket-data-type.js.map +0 -1
  41. package/src/campaign-saving/websocket-lambda-topics.enum.d.ts +0 -3
  42. package/src/campaign-saving/websocket-lambda-topics.enum.js +0 -8
  43. package/src/campaign-saving/websocket-lambda-topics.enum.js.map +0 -1
  44. package/src/domain/campaign/entity-geotargeting.dto.d.ts +0 -5
  45. package/src/domain/campaign/entity-geotargeting.dto.js +0 -3
  46. package/src/domain/campaign/entity-geotargeting.dto.js.map +0 -1
  47. package/src/domain/campaign/targeted-countries.dto.d.ts +0 -8
  48. package/src/domain/campaign/targeted-countries.dto.js +0 -10
  49. package/src/domain/campaign/targeted-countries.dto.js.map +0 -1
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Parse raw response text into a typed value.
3
+ *
4
+ * - Empty / whitespace-only → `null`
5
+ * - Valid JSON → parsed value
6
+ * - Anything else → raw string
7
+ */
8
+ export declare const parseResponseBody: (text: string) => unknown;
9
+ /**
10
+ * Consume a `Response`, parse its body, and throw an `HttpError` when the
11
+ * status is not OK. Always drains the response body exactly once via
12
+ * `response.text()`, so callers must not read the body again.
13
+ */
14
+ export declare const handleFetchResponse: (response: Response) => Promise<{
15
+ body: unknown;
16
+ status: number;
17
+ text: string;
18
+ }>;
19
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
20
+ /**
21
+ * Perform a JSON fetch request with an optional `Authorization` bearer token.
22
+ *
23
+ * @param method - HTTP verb.
24
+ * @param url - Fully-qualified URL string.
25
+ * @param jwt - Bearer token (sent as-is in the `Authorization` header).
26
+ * @param data - Request body; serialised to JSON when provided.
27
+ */
28
+ export declare const fetchJson: (method: HttpMethod, url: string, jwt?: string, data?: unknown) => Promise<{
29
+ body: unknown;
30
+ status: number;
31
+ text: string;
32
+ }>;
33
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchJson = exports.handleFetchResponse = exports.parseResponseBody = void 0;
4
+ const http_error_1 = require("../errors/http-error");
5
+ /**
6
+ * Parse raw response text into a typed value.
7
+ *
8
+ * - Empty / whitespace-only → `null`
9
+ * - Valid JSON → parsed value
10
+ * - Anything else → raw string
11
+ */
12
+ const parseResponseBody = (text) => {
13
+ if (text.trim() === '')
14
+ return null;
15
+ try {
16
+ return JSON.parse(text);
17
+ }
18
+ catch (_a) {
19
+ return text;
20
+ }
21
+ };
22
+ exports.parseResponseBody = parseResponseBody;
23
+ /**
24
+ * Consume a `Response`, parse its body, and throw an `HttpError` when the
25
+ * status is not OK. Always drains the response body exactly once via
26
+ * `response.text()`, so callers must not read the body again.
27
+ */
28
+ const handleFetchResponse = async (response) => {
29
+ const text = await response.text();
30
+ const body = (0, exports.parseResponseBody)(text);
31
+ if (!response.ok) {
32
+ throw new http_error_1.HttpError(response.statusText, { body, status: response.status, text });
33
+ }
34
+ return { body, status: response.status, text };
35
+ };
36
+ exports.handleFetchResponse = handleFetchResponse;
37
+ /**
38
+ * Perform a JSON fetch request with an optional `Authorization` bearer token.
39
+ *
40
+ * @param method - HTTP verb.
41
+ * @param url - Fully-qualified URL string.
42
+ * @param jwt - Bearer token (sent as-is in the `Authorization` header).
43
+ * @param data - Request body; serialised to JSON when provided.
44
+ */
45
+ const fetchJson = async (method, url, jwt = "", data) => {
46
+ const response = await fetch(url, {
47
+ method,
48
+ headers: {
49
+ 'Content-Type': 'application/json',
50
+ 'Authorization': jwt
51
+ },
52
+ body: data !== undefined ? JSON.stringify(data) : undefined
53
+ });
54
+ return (0, exports.handleFetchResponse)(response);
55
+ };
56
+ exports.fetchJson = fetchJson;
57
+ //# sourceMappingURL=http-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-request.js","sourceRoot":"","sources":["../../../src/utils/http-request.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAEjD;;;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C;IACH,OAAO,IAAA,2BAAmB,EAAC,QAAQ,CAAC,CAAC;AACtC,CAAC,CAAC;AAfW,QAAA,SAAS,aAepB"}
@@ -1,3 +0,0 @@
1
- import { WebsocketDataType, WebsocketLambdaErrorResponse, WebSocketLambdaResponse, WebSocketLambdaResponseType, WebSocketWhoAmIResponse } from "./websocket-data-type";
2
- import { WebsocketLambdaTopics } from "./websocket-lambda-topics.enum";
3
- export { WebsocketLambdaTopics, WebsocketDataType, WebSocketLambdaResponseType, WebsocketLambdaErrorResponse, WebSocketLambdaResponse, WebSocketWhoAmIResponse };
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebsocketLambdaTopics = void 0;
4
- const websocket_lambda_topics_enum_1 = require("./websocket-lambda-topics.enum");
5
- Object.defineProperty(exports, "WebsocketLambdaTopics", { enumerable: true, get: function () { return websocket_lambda_topics_enum_1.WebsocketLambdaTopics; } });
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/campaign-saving/index.ts"],"names":[],"mappings":";;;AACA,iFAAuE;AAGtE,sGAHQ,oDAAqB,OAGR"}
@@ -1,19 +0,0 @@
1
- import { WebsocketLambdaTopics } from "./websocket-lambda-topics.enum";
2
- export type WebSocketWhoAmIResponse = {
3
- connectionId: string;
4
- };
5
- export type WebsocketLambdaErrorResponse = {
6
- topic: WebsocketLambdaTopics;
7
- message: {
8
- status: 'failed';
9
- error: Record<string, any>;
10
- };
11
- };
12
- export type WebSocketLambdaResponse = {
13
- topic: WebsocketLambdaTopics;
14
- message: {
15
- status: 'success' | 'start';
16
- };
17
- };
18
- export type WebSocketLambdaResponseType = WebsocketLambdaErrorResponse | WebSocketLambdaResponse;
19
- export type WebsocketDataType = WebSocketWhoAmIResponse | WebSocketLambdaResponseType;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=websocket-data-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"websocket-data-type.js","sourceRoot":"","sources":["../../../src/campaign-saving/websocket-data-type.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- export declare enum WebsocketLambdaTopics {
2
- CAMPAIGN_SAVING = "campaign-saving"
3
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebsocketLambdaTopics = void 0;
4
- var WebsocketLambdaTopics;
5
- (function (WebsocketLambdaTopics) {
6
- WebsocketLambdaTopics["CAMPAIGN_SAVING"] = "campaign-saving";
7
- })(WebsocketLambdaTopics || (exports.WebsocketLambdaTopics = WebsocketLambdaTopics = {}));
8
- //# sourceMappingURL=websocket-lambda-topics.enum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"websocket-lambda-topics.enum.js","sourceRoot":"","sources":["../../../src/campaign-saving/websocket-lambda-topics.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,qBAEX;AAFD,WAAY,qBAAqB;IAC9B,4DAAmC,CAAA;AACtC,CAAC,EAFW,qBAAqB,qCAArB,qBAAqB,QAEhC"}
@@ -1,5 +0,0 @@
1
- import { GeotargetingEntity } from "../types/geotarginator/geotargeting-entity";
2
- /**
3
- * @deprecated Use GeotargetingEntity instead.
4
- */
5
- export type EntityGeotargetingDto = GeotargetingEntity;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=entity-geotargeting.dto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entity-geotargeting.dto.js","sourceRoot":"","sources":["../../../../src/domain/campaign/entity-geotargeting.dto.ts"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
1
- /**
2
- * @deprecated Use TargetedCountries instead.
3
- */
4
- export declare class TargetedCountriesDto {
5
- lp: number[];
6
- p: number[];
7
- sp: number[];
8
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TargetedCountriesDto = void 0;
4
- /**
5
- * @deprecated Use TargetedCountries instead.
6
- */
7
- class TargetedCountriesDto {
8
- }
9
- exports.TargetedCountriesDto = TargetedCountriesDto;
10
- //# sourceMappingURL=targeted-countries.dto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"targeted-countries.dto.js","sourceRoot":"","sources":["../../../../src/domain/campaign/targeted-countries.dto.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,oBAAoB;CAIhC;AAJD,oDAIC"}