smartling-api-sdk-nodejs 2.21.1 → 2.23.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.
Files changed (132) hide show
  1. package/.scannerwork/report-task.txt +2 -2
  2. package/api/base/index.ts +2 -1
  3. package/api/tags/dto/project-id-tag-dto.ts +5 -0
  4. package/api/tags/dto/string-tags-dto.ts +6 -0
  5. package/api/tags/dto/tag-dto.ts +3 -0
  6. package/api/tags/index.ts +87 -0
  7. package/api/tags/params/add-tags-to-strings-parameters.ts +4 -0
  8. package/api/tags/params/base-tags-strings-parameters.ts +40 -0
  9. package/api/tags/params/list-account-tags-parameters.ts +40 -0
  10. package/api/tags/params/list-project-tags-parameters.ts +30 -0
  11. package/api/tags/params/remove-all-tags-from-strings-parameters.ts +18 -0
  12. package/api/tags/params/remove-tags-from-strings-parameters.ts +4 -0
  13. package/api/tags/params/search-string-tags-parameters.ts +18 -0
  14. package/api/webhooks/dto/scrollable-response.ts +7 -0
  15. package/api/webhooks/dto/subscription-attempted-event-dto.ts +10 -0
  16. package/api/webhooks/dto/subscription-dto.ts +18 -0
  17. package/api/webhooks/dto/subscription-event-attempt-dto.ts +16 -0
  18. package/api/webhooks/dto/subscription-event-attempt-status.ts +8 -0
  19. package/api/webhooks/dto/subscription-event-dto.ts +8 -0
  20. package/api/webhooks/dto/subscription-event-trigger-type.ts +6 -0
  21. package/api/webhooks/dto/subscription-secret-dto.ts +5 -0
  22. package/api/webhooks/dto/subscription-statistics-dto.ts +8 -0
  23. package/api/webhooks/dto/webhook-event-type.dto.ts +7 -0
  24. package/api/webhooks/index.ts +17 -0
  25. package/api/webhooks/params/create-subscription-parameters.ts +9 -0
  26. package/api/webhooks/params/create-update-subscription-parameters.ts +70 -0
  27. package/api/webhooks/params/get-subscription-events-parameters.ts +38 -0
  28. package/api/webhooks/params/subscription-event.ts +6 -0
  29. package/api/webhooks/params/subscription-request-header.ts +6 -0
  30. package/api/webhooks/params/update-subscription-parameters.ts +19 -0
  31. package/api/webhooks/params/update-subscription-secret-parameters.ts +14 -0
  32. package/api/webhooks/smartling-webhooks-api.ts +190 -0
  33. package/built/api/base/index.js +2 -1
  34. package/built/api/base/index.js.map +1 -1
  35. package/built/api/tags/dto/project-id-tag-dto.d.ts +4 -0
  36. package/built/api/tags/dto/project-id-tag-dto.js +3 -0
  37. package/built/api/tags/dto/project-id-tag-dto.js.map +1 -0
  38. package/built/api/tags/dto/string-tags-dto.d.ts +5 -0
  39. package/built/api/tags/dto/string-tags-dto.js +3 -0
  40. package/built/api/tags/dto/string-tags-dto.js.map +1 -0
  41. package/built/api/tags/dto/tag-dto.d.ts +3 -0
  42. package/built/api/tags/dto/tag-dto.js +3 -0
  43. package/built/api/tags/dto/tag-dto.js.map +1 -0
  44. package/built/api/tags/index.d.ts +22 -0
  45. package/built/api/tags/index.js +52 -0
  46. package/built/api/tags/index.js.map +1 -0
  47. package/built/api/tags/params/add-tags-to-strings-parameters.d.ts +3 -0
  48. package/built/api/tags/params/add-tags-to-strings-parameters.js +8 -0
  49. package/built/api/tags/params/add-tags-to-strings-parameters.js.map +1 -0
  50. package/built/api/tags/params/base-tags-strings-parameters.d.ts +5 -0
  51. package/built/api/tags/params/base-tags-strings-parameters.js +34 -0
  52. package/built/api/tags/params/base-tags-strings-parameters.js.map +1 -0
  53. package/built/api/tags/params/list-account-tags-parameters.d.ts +7 -0
  54. package/built/api/tags/params/list-account-tags-parameters.js +34 -0
  55. package/built/api/tags/params/list-account-tags-parameters.js.map +1 -0
  56. package/built/api/tags/params/list-project-tags-parameters.d.ts +6 -0
  57. package/built/api/tags/params/list-project-tags-parameters.js +27 -0
  58. package/built/api/tags/params/list-project-tags-parameters.js.map +1 -0
  59. package/built/api/tags/params/remove-all-tags-from-strings-parameters.d.ts +4 -0
  60. package/built/api/tags/params/remove-all-tags-from-strings-parameters.js +19 -0
  61. package/built/api/tags/params/remove-all-tags-from-strings-parameters.js.map +1 -0
  62. package/built/api/tags/params/remove-tags-from-strings-parameters.d.ts +3 -0
  63. package/built/api/tags/params/remove-tags-from-strings-parameters.js +8 -0
  64. package/built/api/tags/params/remove-tags-from-strings-parameters.js.map +1 -0
  65. package/built/api/tags/params/search-string-tags-parameters.d.ts +4 -0
  66. package/built/api/tags/params/search-string-tags-parameters.js +19 -0
  67. package/built/api/tags/params/search-string-tags-parameters.js.map +1 -0
  68. package/built/api/webhooks/dto/scrollable-response.d.ts +6 -0
  69. package/built/api/webhooks/dto/scrollable-response.js +3 -0
  70. package/built/api/webhooks/dto/scrollable-response.js.map +1 -0
  71. package/built/api/webhooks/dto/subscription-attempted-event-dto.d.ts +8 -0
  72. package/built/api/webhooks/dto/subscription-attempted-event-dto.js +3 -0
  73. package/built/api/webhooks/dto/subscription-attempted-event-dto.js.map +1 -0
  74. package/built/api/webhooks/dto/subscription-dto.d.ts +16 -0
  75. package/built/api/webhooks/dto/subscription-dto.js +3 -0
  76. package/built/api/webhooks/dto/subscription-dto.js.map +1 -0
  77. package/built/api/webhooks/dto/subscription-event-attempt-dto.d.ts +14 -0
  78. package/built/api/webhooks/dto/subscription-event-attempt-dto.js +3 -0
  79. package/built/api/webhooks/dto/subscription-event-attempt-dto.js.map +1 -0
  80. package/built/api/webhooks/dto/subscription-event-attempt-status.d.ts +7 -0
  81. package/built/api/webhooks/dto/subscription-event-attempt-status.js +12 -0
  82. package/built/api/webhooks/dto/subscription-event-attempt-status.js.map +1 -0
  83. package/built/api/webhooks/dto/subscription-event-dto.d.ts +7 -0
  84. package/built/api/webhooks/dto/subscription-event-dto.js +3 -0
  85. package/built/api/webhooks/dto/subscription-event-dto.js.map +1 -0
  86. package/built/api/webhooks/dto/subscription-event-trigger-type.d.ts +5 -0
  87. package/built/api/webhooks/dto/subscription-event-trigger-type.js +10 -0
  88. package/built/api/webhooks/dto/subscription-event-trigger-type.js.map +1 -0
  89. package/built/api/webhooks/dto/subscription-secret-dto.d.ts +4 -0
  90. package/built/api/webhooks/dto/subscription-secret-dto.js +3 -0
  91. package/built/api/webhooks/dto/subscription-secret-dto.js.map +1 -0
  92. package/built/api/webhooks/dto/subscription-statistics-dto.d.ts +7 -0
  93. package/built/api/webhooks/dto/subscription-statistics-dto.js +3 -0
  94. package/built/api/webhooks/dto/subscription-statistics-dto.js.map +1 -0
  95. package/built/api/webhooks/dto/webhook-event-type.dto.d.ts +6 -0
  96. package/built/api/webhooks/dto/webhook-event-type.dto.js +7 -0
  97. package/built/api/webhooks/dto/webhook-event-type.dto.js.map +1 -0
  98. package/built/api/webhooks/index.d.ts +17 -0
  99. package/built/api/webhooks/index.js +20 -0
  100. package/built/api/webhooks/index.js.map +1 -0
  101. package/built/api/webhooks/params/create-subscription-parameters.d.ts +4 -0
  102. package/built/api/webhooks/params/create-subscription-parameters.js +12 -0
  103. package/built/api/webhooks/params/create-subscription-parameters.js.map +1 -0
  104. package/built/api/webhooks/params/create-update-subscription-parameters.d.ts +9 -0
  105. package/built/api/webhooks/params/create-update-subscription-parameters.js +54 -0
  106. package/built/api/webhooks/params/create-update-subscription-parameters.js.map +1 -0
  107. package/built/api/webhooks/params/get-subscription-events-parameters.d.ts +11 -0
  108. package/built/api/webhooks/params/get-subscription-events-parameters.js +35 -0
  109. package/built/api/webhooks/params/get-subscription-events-parameters.js.map +1 -0
  110. package/built/api/webhooks/params/subscription-event.d.ts +5 -0
  111. package/built/api/webhooks/params/subscription-event.js +3 -0
  112. package/built/api/webhooks/params/subscription-event.js.map +1 -0
  113. package/built/api/webhooks/params/subscription-request-header.d.ts +5 -0
  114. package/built/api/webhooks/params/subscription-request-header.js +3 -0
  115. package/built/api/webhooks/params/subscription-request-header.js.map +1 -0
  116. package/built/api/webhooks/params/update-subscription-parameters.d.ts +5 -0
  117. package/built/api/webhooks/params/update-subscription-parameters.js +12 -0
  118. package/built/api/webhooks/params/update-subscription-parameters.js.map +1 -0
  119. package/built/api/webhooks/params/update-subscription-secret-parameters.d.ts +4 -0
  120. package/built/api/webhooks/params/update-subscription-secret-parameters.js +16 -0
  121. package/built/api/webhooks/params/update-subscription-secret-parameters.js.map +1 -0
  122. package/built/api/webhooks/smartling-webhooks-api.d.ts +35 -0
  123. package/built/api/webhooks/smartling-webhooks-api.js +61 -0
  124. package/built/api/webhooks/smartling-webhooks-api.js.map +1 -0
  125. package/built/index.d.ts +12 -0
  126. package/built/index.js +12 -0
  127. package/built/index.js.map +1 -1
  128. package/built/package.json +3 -3
  129. package/index.ts +12 -0
  130. package/package.json +3 -3
  131. package/test/tags.spec.ts +472 -0
  132. package/test/webhooks.spec.ts +610 -0
@@ -2,5 +2,5 @@ projectKey=smartling-api-sdk-nodejs
2
2
  serverUrl=https://sonar-next.connectors.stg.smartling.net
3
3
  serverVersion=8.6.1.40680
4
4
  dashboardUrl=https://sonar-next.connectors.stg.smartling.net/dashboard?id=smartling-api-sdk-nodejs
5
- ceTaskId=AZg2oi-ALw_GP6qdp7B5
6
- ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AZg2oi-ALw_GP6qdp7B5
5
+ ceTaskId=AZh0732vF9ynshTVs21w
6
+ ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AZh0732vF9ynshTVs21w
package/api/base/index.ts CHANGED
@@ -162,7 +162,8 @@ export class SmartlingBaseApi {
162
162
  "dueDate",
163
163
  "actionTime",
164
164
  "publishDate",
165
- "lastModified"
165
+ "lastModified",
166
+ "attemptDate"
166
167
  ];
167
168
 
168
169
  if (dateProperties.includes(key) && value) {
@@ -0,0 +1,5 @@
1
+ import { TagDto } from "./tag-dto";
2
+
3
+ export interface ProjectIdTagDto extends TagDto {
4
+ projectId: string;
5
+ }
@@ -0,0 +1,6 @@
1
+ import { TagDto } from "./tag-dto";
2
+
3
+ export interface StringTagsDto {
4
+ stringHashcode: string;
5
+ tags: Array<TagDto>;
6
+ }
@@ -0,0 +1,3 @@
1
+ export interface TagDto {
2
+ tag: string;
3
+ }
@@ -0,0 +1,87 @@
1
+ import { SmartlingBaseApi } from "../base/index";
2
+ import { AccessTokenProvider } from "../auth/access-token-provider";
3
+ import { Logger } from "../logger";
4
+ import { SmartlingListResponse } from "../http/smartling-list-response";
5
+ import { TagDto } from "./dto/tag-dto";
6
+ import { StringTagsDto } from "./dto/string-tags-dto";
7
+ import { ListAccountTagsParameters } from "./params/list-account-tags-parameters";
8
+ import { ListProjectTagsParameters } from "./params/list-project-tags-parameters";
9
+ import { SearchStringTagsParameters } from "./params/search-string-tags-parameters";
10
+ import { AddTagsToStringsParameters } from "./params/add-tags-to-strings-parameters";
11
+ import { RemoveTagsFromStringsParameters } from "./params/remove-tags-from-strings-parameters";
12
+ import { RemoveAllTagsFromStringsParameters } from "./params/remove-all-tags-from-strings-parameters";
13
+ import { ProjectIdTagDto } from "./dto/project-id-tag-dto";
14
+
15
+ export class SmartlingTagsApi extends SmartlingBaseApi {
16
+ constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
17
+ super(logger);
18
+ this.authApi = authApi;
19
+ this.entrypoint = `${smartlingApiBaseUrl}/tags-api/v2`;
20
+ }
21
+
22
+ async listAccountTags(
23
+ accountUid: string,
24
+ params: ListAccountTagsParameters
25
+ ): Promise<SmartlingListResponse<ProjectIdTagDto>> {
26
+ return await this.makeRequest(
27
+ "post",
28
+ `${this.entrypoint}/accounts/${accountUid}/tags`,
29
+ JSON.stringify(params.export())
30
+ );
31
+ }
32
+
33
+ async listProjectTags(
34
+ projectId: string,
35
+ params: ListProjectTagsParameters
36
+ ): Promise<SmartlingListResponse<TagDto>> {
37
+ return await this.makeRequest(
38
+ "get",
39
+ `${this.entrypoint}/projects/${projectId}/tags`,
40
+ params.export()
41
+ );
42
+ }
43
+
44
+ async searchStringTags(
45
+ projectId: string,
46
+ params: SearchStringTagsParameters
47
+ ): Promise<Array<StringTagsDto>> {
48
+ return await this.makeRequest(
49
+ "post",
50
+ `${this.entrypoint}/projects/${projectId}/strings/tags/search`,
51
+ JSON.stringify(params.export())
52
+ );
53
+ }
54
+
55
+ async addTagsToStrings(
56
+ projectId: string,
57
+ params: AddTagsToStringsParameters
58
+ ): Promise<void> {
59
+ return await this.makeRequest(
60
+ "post",
61
+ `${this.entrypoint}/projects/${projectId}/strings/tags/add`,
62
+ JSON.stringify(params.export())
63
+ );
64
+ }
65
+
66
+ async removeTagsFromStrings(
67
+ projectId: string,
68
+ params: RemoveTagsFromStringsParameters
69
+ ): Promise<void> {
70
+ return await this.makeRequest(
71
+ "post",
72
+ `${this.entrypoint}/projects/${projectId}/strings/tags/remove`,
73
+ JSON.stringify(params.export())
74
+ );
75
+ }
76
+
77
+ async removeAllTagsFromStrings(
78
+ projectId: string,
79
+ params: RemoveAllTagsFromStringsParameters
80
+ ): Promise<Record<string, unknown>> {
81
+ return await this.makeRequest(
82
+ "post",
83
+ `${this.entrypoint}/projects/${projectId}/strings/tags/remove/all`,
84
+ JSON.stringify(params.export())
85
+ );
86
+ }
87
+ }
@@ -0,0 +1,4 @@
1
+ import { BaseTagsStringsParameters } from "./base-tags-strings-parameters";
2
+
3
+ export class AddTagsToStringsParameters
4
+ extends BaseTagsStringsParameters<AddTagsToStringsParameters> {}
@@ -0,0 +1,40 @@
1
+ import { BaseParameters } from "../../parameters";
2
+ import { SmartlingException } from "../../exception";
3
+
4
+ export abstract class BaseTagsStringsParameters<
5
+ T extends BaseTagsStringsParameters<T>
6
+ > extends BaseParameters {
7
+ setTags(tags: Array<string>): T {
8
+ if (!tags || tags.length === 0) {
9
+ throw new SmartlingException("Tags array is required");
10
+ }
11
+
12
+ if (tags.length > 100) {
13
+ throw new SmartlingException("Tags array must not exceed 100 items");
14
+ }
15
+
16
+ tags.forEach((tag) => {
17
+ if (tag.length > 128) {
18
+ throw new SmartlingException("Tag length must not exceed 128 characters");
19
+ }
20
+ });
21
+
22
+ this.set("tags", tags);
23
+
24
+ return this as unknown as T;
25
+ }
26
+
27
+ setStringHashcodes(stringHashcodes: Array<string>): T {
28
+ if (!stringHashcodes || stringHashcodes.length === 0) {
29
+ throw new SmartlingException("String hashcodes array is required");
30
+ }
31
+
32
+ if (stringHashcodes.length > 1000) {
33
+ throw new SmartlingException("String hashcodes array must not exceed 1000 items");
34
+ }
35
+
36
+ this.set("stringHashcodes", stringHashcodes);
37
+
38
+ return this as unknown as T;
39
+ }
40
+ }
@@ -0,0 +1,40 @@
1
+ import { BaseParameters } from "../../parameters";
2
+ import { SmartlingException } from "../../exception";
3
+
4
+ export class ListAccountTagsParameters extends BaseParameters {
5
+ setProjectIds(projectIds: Array<string>): ListAccountTagsParameters {
6
+ if (projectIds && projectIds.length > 1000) {
7
+ throw new SmartlingException("Project IDs array must not exceed 1000 items");
8
+ }
9
+
10
+ this.set("projectIds", projectIds);
11
+
12
+ return this;
13
+ }
14
+
15
+ setTagMask(tagMask: string): ListAccountTagsParameters {
16
+ this.set("tagMask", tagMask);
17
+
18
+ return this;
19
+ }
20
+
21
+ setLimit(limit: number): ListAccountTagsParameters {
22
+ if (limit < 1 || limit > 1500) {
23
+ throw new SmartlingException("Limit must be between 1 and 1500");
24
+ }
25
+
26
+ this.set("limit", limit);
27
+
28
+ return this;
29
+ }
30
+
31
+ setOffset(offset: number): ListAccountTagsParameters {
32
+ if (offset < 0) {
33
+ throw new SmartlingException("Offset must be non-negative");
34
+ }
35
+
36
+ this.set("offset", offset);
37
+
38
+ return this;
39
+ }
40
+ }
@@ -0,0 +1,30 @@
1
+ import { BaseParameters } from "../../parameters";
2
+ import { SmartlingException } from "../../exception";
3
+
4
+ export class ListProjectTagsParameters extends BaseParameters {
5
+ setTagMask(tagMask: string): ListProjectTagsParameters {
6
+ this.set("tagMask", tagMask);
7
+
8
+ return this;
9
+ }
10
+
11
+ setLimit(limit: number): ListProjectTagsParameters {
12
+ if (limit < 0 || limit > 100) {
13
+ throw new SmartlingException("Limit must be between 0 and 100");
14
+ }
15
+
16
+ this.set("limit", limit);
17
+
18
+ return this;
19
+ }
20
+
21
+ setOffset(offset: number): ListProjectTagsParameters {
22
+ if (offset < 0) {
23
+ throw new SmartlingException("Offset must be non-negative");
24
+ }
25
+
26
+ this.set("offset", offset);
27
+
28
+ return this;
29
+ }
30
+ }
@@ -0,0 +1,18 @@
1
+ import { BaseParameters } from "../../parameters";
2
+ import { SmartlingException } from "../../exception";
3
+
4
+ export class RemoveAllTagsFromStringsParameters extends BaseParameters {
5
+ setStringHashcodes(stringHashcodes: Array<string>): RemoveAllTagsFromStringsParameters {
6
+ if (!stringHashcodes || stringHashcodes.length === 0) {
7
+ throw new SmartlingException("String hashcodes array is required");
8
+ }
9
+
10
+ if (stringHashcodes.length > 1000) {
11
+ throw new SmartlingException("String hashcodes array must not exceed 1000 items");
12
+ }
13
+
14
+ this.set("stringHashcodes", stringHashcodes);
15
+
16
+ return this;
17
+ }
18
+ }
@@ -0,0 +1,4 @@
1
+ import { BaseTagsStringsParameters } from "./base-tags-strings-parameters";
2
+
3
+ export class RemoveTagsFromStringsParameters
4
+ extends BaseTagsStringsParameters<RemoveTagsFromStringsParameters> {}
@@ -0,0 +1,18 @@
1
+ import { BaseParameters } from "../../parameters";
2
+ import { SmartlingException } from "../../exception";
3
+
4
+ export class SearchStringTagsParameters extends BaseParameters {
5
+ setStringHashcodes(stringHashcodes: Array<string>): SearchStringTagsParameters {
6
+ if (!stringHashcodes || stringHashcodes.length === 0) {
7
+ throw new SmartlingException("String hashcodes array is required");
8
+ }
9
+
10
+ if (stringHashcodes.length > 1000) {
11
+ throw new SmartlingException("String hashcodes array must not exceed 1000 items");
12
+ }
13
+
14
+ this.set("stringHashcodes", stringHashcodes);
15
+
16
+ return this;
17
+ }
18
+ }
@@ -0,0 +1,7 @@
1
+ interface ScrollableResponse<T> {
2
+ items: Array<T>;
3
+ hasMore: boolean;
4
+ scrollId: string | null;
5
+ }
6
+
7
+ export { ScrollableResponse };
@@ -0,0 +1,10 @@
1
+ import { SubscriptionEventAttemptStatus } from "./subscription-event-attempt-status";
2
+
3
+ interface SubscriptionAttemptedEventDto {
4
+ eventId: string;
5
+ eventType: string;
6
+ createdDate: Date;
7
+ lastAttemptStatus: SubscriptionEventAttemptStatus
8
+ }
9
+
10
+ export { SubscriptionAttemptedEventDto };
@@ -0,0 +1,18 @@
1
+ import { SubscriptionEvent } from "../params/subscription-event";
2
+ import { SubscriptionRequestHeader } from "../params/subscription-request-header";
3
+
4
+ interface SubscriptionDto {
5
+ subscriptionUid: string;
6
+ subscriptionName: string;
7
+ subscriptionUrl: string;
8
+ accountUid: string;
9
+ enabled: boolean;
10
+ userUid: string;
11
+ description: string | null;
12
+ createdDate: string;
13
+ requestHeaders: SubscriptionRequestHeader[];
14
+ events: SubscriptionEvent[];
15
+ projectUids: string[];
16
+ }
17
+
18
+ export { SubscriptionDto };
@@ -0,0 +1,16 @@
1
+ import { SubscriptionEventAttemptStatus } from "./subscription-event-attempt-status";
2
+ import { SubscriptionEventTriggerType } from "./subscription-event-trigger-type";
3
+
4
+ interface SubscriptionEventAttemptDto {
5
+ attemptId: string;
6
+ eventId: string;
7
+ response: string | null;
8
+ responseDurationMs: number;
9
+ responseStatusCode: number;
10
+ attemptStatus: SubscriptionEventAttemptStatus;
11
+ attemptDate: Date;
12
+ url: string;
13
+ triggerType: SubscriptionEventTriggerType;
14
+ }
15
+
16
+ export { SubscriptionEventAttemptDto };
@@ -0,0 +1,8 @@
1
+ enum SubscriptionEventAttemptStatus {
2
+ SUCCESS = "SUCCESS",
3
+ PENDING = "PENDING",
4
+ FAIL = "FAIL",
5
+ SENDING = "SENDING"
6
+ }
7
+
8
+ export { SubscriptionEventAttemptStatus };
@@ -0,0 +1,8 @@
1
+ interface SubscriptionEventDto {
2
+ eventId: string;
3
+ eventType: string;
4
+ createdDate: Date;
5
+ payload: Record<string, unknown>;
6
+ }
7
+
8
+ export { SubscriptionEventDto };
@@ -0,0 +1,6 @@
1
+ enum SubscriptionEventTriggerType {
2
+ SCHEDULED = "SCHEDULED",
3
+ MANUAL = "MANUAL"
4
+ }
5
+
6
+ export { SubscriptionEventTriggerType };
@@ -0,0 +1,5 @@
1
+ interface SubscriptionSecretDto {
2
+ payloadSecret: string;
3
+ }
4
+
5
+ export { SubscriptionSecretDto };
@@ -0,0 +1,8 @@
1
+ interface SubscriptionStatisticsDto {
2
+ failEvents: number;
3
+ pendingEvents: number;
4
+ sendingEvents: number;
5
+ successEvents: number;
6
+ }
7
+
8
+ export { SubscriptionStatisticsDto };
@@ -0,0 +1,7 @@
1
+ class WebhookEventTypeDto {
2
+ eventType: string;
3
+ description: string;
4
+ schema: Record<string, unknown>;
5
+ }
6
+
7
+ export { WebhookEventTypeDto };
@@ -0,0 +1,17 @@
1
+ export { SmartlingWebhooksApi } from "./smartling-webhooks-api";
2
+ export { ScrollableResponse } from "./dto/scrollable-response";
3
+ export { SubscriptionAttemptedEventDto } from "./dto/subscription-attempted-event-dto";
4
+ export { SubscriptionEventDto } from "./dto/subscription-event-dto";
5
+ export { SubscriptionEventAttemptDto } from "./dto/subscription-event-attempt-dto";
6
+ export { SubscriptionEventAttemptStatus } from "./dto/subscription-event-attempt-status";
7
+ export { SubscriptionEventTriggerType } from "./dto/subscription-event-trigger-type";
8
+ export { SubscriptionStatisticsDto } from "./dto/subscription-statistics-dto";
9
+ export { SubscriptionDto } from "./dto/subscription-dto";
10
+ export { SubscriptionSecretDto } from "./dto/subscription-secret-dto";
11
+ export { WebhookEventTypeDto } from "./dto/webhook-event-type.dto";
12
+ export { SubscriptionEvent } from "./params/subscription-event";
13
+ export { CreateSubscriptionParameters } from "./params/create-subscription-parameters";
14
+ export { UpdateSubscriptionParameters } from "./params/update-subscription-parameters";
15
+ export { SubscriptionRequestHeader } from "./params/subscription-request-header";
16
+ export { UpdateSubscriptionSecretParameters } from "./params/update-subscription-secret-parameters";
17
+ export { GetSubscriptionEventsParameters } from "./params/get-subscription-events-parameters";
@@ -0,0 +1,9 @@
1
+ import { CreateUpdateSubscriptionParameters } from "./create-update-subscription-parameters";
2
+
3
+ export class CreateSubscriptionParameters extends CreateUpdateSubscriptionParameters {
4
+ setPayloadSecret(payloadSecret: string): this {
5
+ this.set("payloadSecret", payloadSecret);
6
+
7
+ return this;
8
+ }
9
+ }
@@ -0,0 +1,70 @@
1
+ import { BaseParameters } from "../../parameters";
2
+ import { SmartlingException } from "../../exception";
3
+ import { SubscriptionEvent } from "./subscription-event";
4
+ import { SubscriptionRequestHeader } from "./subscription-request-header";
5
+
6
+ const MAX_EVENTS_SIZE = 1000;
7
+ const MAX_SUBSCRIPTION_HEADERS_SIZE = 20;
8
+ const MAX_PROJECT_UIDS_SIZE = 10;
9
+
10
+ export abstract class CreateUpdateSubscriptionParameters extends BaseParameters {
11
+ constructor(
12
+ subscriptionName: string,
13
+ subscriptionUrl: string,
14
+ events: SubscriptionEvent[]
15
+ ) {
16
+ super();
17
+
18
+ if (!subscriptionName) {
19
+ throw new SmartlingException("Subscription name is required.");
20
+ }
21
+
22
+ if (!subscriptionUrl) {
23
+ throw new SmartlingException("Subscription url is required.");
24
+ }
25
+
26
+ if (!events.length) {
27
+ throw new SmartlingException("At least one event is required.");
28
+ }
29
+
30
+ if (events.length > MAX_EVENTS_SIZE) {
31
+ throw new SmartlingException(`The request contains too many events: ${events.length}. Maximum allowed events number is ${MAX_EVENTS_SIZE}.`);
32
+ }
33
+
34
+ this.set("subscriptionName", subscriptionName);
35
+ this.set("subscriptionUrl", subscriptionUrl);
36
+ this.set("events", events);
37
+ }
38
+
39
+ setDescription(description: string): this {
40
+ this.set("description", description);
41
+
42
+ return this;
43
+ }
44
+
45
+ setRequestHeaders(requestHeaders: SubscriptionRequestHeader[]): this {
46
+ if (!requestHeaders.length) {
47
+ throw new SmartlingException("At least one subscription header is required.");
48
+ }
49
+
50
+ if (requestHeaders.length > MAX_SUBSCRIPTION_HEADERS_SIZE) {
51
+ throw new SmartlingException(`The request contains too many subscription headers: ${requestHeaders.length}. Maximum allowed subscription headers number is ${MAX_SUBSCRIPTION_HEADERS_SIZE}.`);
52
+ }
53
+
54
+ this.set("requestHeaders", requestHeaders);
55
+ return this;
56
+ }
57
+
58
+ setProjectUids(projectUids: string[]): this {
59
+ if (!projectUids.length) {
60
+ throw new SmartlingException("At least one project uid is required.");
61
+ }
62
+
63
+ if (projectUids.length > MAX_PROJECT_UIDS_SIZE) {
64
+ throw new SmartlingException(`The request contains too many project uids: ${projectUids.length}. Maximum allowed project uids number is ${MAX_PROJECT_UIDS_SIZE}.`);
65
+ }
66
+ this.set("projectUids", projectUids);
67
+
68
+ return this;
69
+ }
70
+ }
@@ -0,0 +1,38 @@
1
+ import { BaseParameters } from "../../parameters";
2
+ import { SubscriptionEventAttemptStatus } from "../dto/subscription-event-attempt-status";
3
+
4
+ export class GetSubscriptionEventsParameters extends BaseParameters {
5
+ setLimit(limit: number): this {
6
+ this.set("limit", limit);
7
+ return this;
8
+ }
9
+
10
+ setScrollId(scrollId: string): this {
11
+ this.set("scrollId", scrollId);
12
+ return this;
13
+ }
14
+
15
+ setAttemptStatus(attemptStatus: SubscriptionEventAttemptStatus): this {
16
+ this.set("attemptStatus", attemptStatus);
17
+ return this;
18
+ }
19
+
20
+ setCreatedDateBefore(createdDateBefore: Date): this {
21
+ this.set("createdDateBefore", GetSubscriptionEventsParameters.prepareDateParameter(createdDateBefore));
22
+ return this;
23
+ }
24
+
25
+ setCreatedDateAfter(createdDateAfter: Date): this {
26
+ this.set("createdDateAfter", GetSubscriptionEventsParameters.prepareDateParameter(createdDateAfter));
27
+ return this;
28
+ }
29
+
30
+ setEventTypes(eventTypes: string[]): this {
31
+ this.set("eventTypes", eventTypes);
32
+ return this;
33
+ }
34
+
35
+ private static prepareDateParameter(date: Date): string {
36
+ return `${date.toISOString().split(".")[0]}Z`;
37
+ }
38
+ }
@@ -0,0 +1,6 @@
1
+ interface SubscriptionEvent {
2
+ type: string;
3
+ schemaVersion: string;
4
+ }
5
+
6
+ export { SubscriptionEvent };
@@ -0,0 +1,6 @@
1
+ interface SubscriptionRequestHeader {
2
+ headerName: string;
3
+ headerValue: string;
4
+ }
5
+
6
+ export { SubscriptionRequestHeader };
@@ -0,0 +1,19 @@
1
+ import { CreateUpdateSubscriptionParameters } from "./create-update-subscription-parameters";
2
+ import { SubscriptionEvent } from "./subscription-event";
3
+
4
+ export class UpdateSubscriptionParameters extends CreateUpdateSubscriptionParameters {
5
+ constructor(
6
+ subscriptionName: string,
7
+ subscriptionUrl: string,
8
+ events: SubscriptionEvent[],
9
+ enabled: boolean
10
+ ) {
11
+ super(
12
+ subscriptionName,
13
+ subscriptionUrl,
14
+ events
15
+ );
16
+
17
+ this.set("enabled", enabled);
18
+ }
19
+ }
@@ -0,0 +1,14 @@
1
+ import { BaseParameters } from "../../parameters";
2
+ import { SmartlingException } from "../../exception";
3
+
4
+ export class UpdateSubscriptionSecretParameters extends BaseParameters {
5
+ constructor(payloadSecret: string) {
6
+ super();
7
+
8
+ if (!payloadSecret) {
9
+ throw new SmartlingException("Payload secret is required.");
10
+ }
11
+
12
+ this.set("payloadSecret", payloadSecret);
13
+ }
14
+ }