@forge/notification 0.1.0-next.1 → 0.1.0-next.1-experimental-9065145
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/CHANGELOG.md +11 -0
- package/out/index.d.ts +1 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +2 -4
- package/out/notification-api.d.ts +1 -2
- package/out/notification-api.d.ts.map +1 -1
- package/out/notification-api.js +3 -33
- package/out/util.d.ts +4 -0
- package/out/util.d.ts.map +1 -0
- package/out/util.js +36 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @forge/notification
|
|
2
2
|
|
|
3
|
+
## 0.1.0-next.1-experimental-9065145
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e9d727f: Add implementation code for notification SDK
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 7046f29: Fix types
|
|
12
|
+
- @forge/api@6.4.1-next.0-experimental-9065145
|
|
13
|
+
|
|
3
14
|
## 0.1.0-next.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/out/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { NotificationApi } from './notification-api';
|
|
2
2
|
export { NotificationApi as default } from './notification-api';
|
|
3
|
-
export { NotificationPayload, DeliveryChannel,
|
|
3
|
+
export { NotificationPayload, DeliveryChannel, RecipientType, StatusDetails, MessageTemplateContext, NotificationResponse, NotificationStatusResponse, EmailRecipient } from './types';
|
|
4
4
|
export { NotificationError, InvalidPayloadError, RateLimitError, InternalServerError } from './errors';
|
|
5
5
|
export { validateAPIResponse } from './validators';
|
|
6
|
-
export { post, POST_OFFICE_FORGE_NOTIFICATION_PATH } from './fetch';
|
|
7
6
|
export type { APIResponse, FetchMethod } from '@forge/api';
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGhE,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGhE,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,0BAA0B,EAC1B,cAAc,EACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAGvG,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.validateAPIResponse = exports.InternalServerError = exports.RateLimitError = exports.InvalidPayloadError = exports.NotificationError = exports.RecipientType = exports.DeliveryChannel = exports.default = exports.NotificationApi = void 0;
|
|
4
4
|
var notification_api_1 = require("./notification-api");
|
|
5
5
|
Object.defineProperty(exports, "NotificationApi", { enumerable: true, get: function () { return notification_api_1.NotificationApi; } });
|
|
6
6
|
var notification_api_2 = require("./notification-api");
|
|
7
7
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return notification_api_2.NotificationApi; } });
|
|
8
8
|
var types_1 = require("./types");
|
|
9
9
|
Object.defineProperty(exports, "DeliveryChannel", { enumerable: true, get: function () { return types_1.DeliveryChannel; } });
|
|
10
|
+
Object.defineProperty(exports, "RecipientType", { enumerable: true, get: function () { return types_1.RecipientType; } });
|
|
10
11
|
var errors_1 = require("./errors");
|
|
11
12
|
Object.defineProperty(exports, "NotificationError", { enumerable: true, get: function () { return errors_1.NotificationError; } });
|
|
12
13
|
Object.defineProperty(exports, "InvalidPayloadError", { enumerable: true, get: function () { return errors_1.InvalidPayloadError; } });
|
|
@@ -14,6 +15,3 @@ Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: functi
|
|
|
14
15
|
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return errors_1.InternalServerError; } });
|
|
15
16
|
var validators_1 = require("./validators");
|
|
16
17
|
Object.defineProperty(exports, "validateAPIResponse", { enumerable: true, get: function () { return validators_1.validateAPIResponse; } });
|
|
17
|
-
var fetch_1 = require("./fetch");
|
|
18
|
-
Object.defineProperty(exports, "post", { enumerable: true, get: function () { return fetch_1.post; } });
|
|
19
|
-
Object.defineProperty(exports, "POST_OFFICE_FORGE_NOTIFICATION_PATH", { enumerable: true, get: function () { return fetch_1.POST_OFFICE_FORGE_NOTIFICATION_PATH; } });
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { FetchMethod } from '@forge/api';
|
|
2
|
-
import { DeliveryChannel, NotificationPayload,
|
|
2
|
+
import { DeliveryChannel, NotificationPayload, NotificationResponse, NotificationStatusResponse, RecipientType } from './types';
|
|
3
3
|
export declare class NotificationApi {
|
|
4
4
|
private readonly apiClient;
|
|
5
5
|
constructor(apiClient?: FetchMethod);
|
|
6
6
|
sendNotification(payload: NotificationPayload): Promise<NotificationResponse>;
|
|
7
7
|
getNotificationStatus(triggerId: string, recipient: string, recipientType: RecipientType, deliveryChannel: DeliveryChannel): Promise<NotificationStatusResponse>;
|
|
8
|
-
createNotificationPORequest(input: NotificationPayload, triggerId: string): NotificationPORequest;
|
|
9
8
|
}
|
|
10
9
|
//# sourceMappingURL=notification-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-api.d.ts","sourceRoot":"","sources":["../src/notification-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,WAAW,EAAE,MAAM,YAAY,CAAC;AAGlE,OAAO,EACL,eAAe,
|
|
1
|
+
{"version":3,"file":"notification-api.d.ts","sourceRoot":"","sources":["../src/notification-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,WAAW,EAAE,MAAM,YAAY,CAAC;AAGlE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,aAAa,EACd,MAAM,SAAS,CAAC;AAIjB,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,GAAE,WAAqC;IAEvE,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAe7E,qBAAqB,CACzB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,0BAA0B,CAAC;CAmBvC"}
|
package/out/notification-api.js
CHANGED
|
@@ -6,12 +6,7 @@ const uuid_1 = require("uuid");
|
|
|
6
6
|
const fetch_1 = require("./fetch");
|
|
7
7
|
const types_1 = require("./types");
|
|
8
8
|
const validators_1 = require("./validators");
|
|
9
|
-
const
|
|
10
|
-
const ECOSYSTEM_FORGE_NOTIFICATION_TEMPLATE = 'ecosystem-forge-notifications-spike';
|
|
11
|
-
const userIdToIdentityAri = (userId) => ({
|
|
12
|
-
userId,
|
|
13
|
-
toString: () => `ari:cloud:identity::user/${userId}`
|
|
14
|
-
});
|
|
9
|
+
const util_1 = require("./util");
|
|
15
10
|
class NotificationApi {
|
|
16
11
|
apiClient;
|
|
17
12
|
constructor(apiClient = api_1.__requestAtlassianAsApp) {
|
|
@@ -20,7 +15,7 @@ class NotificationApi {
|
|
|
20
15
|
async sendNotification(payload) {
|
|
21
16
|
(0, validators_1.validateNotificationPayload)(payload);
|
|
22
17
|
const triggerId = (0, uuid_1.v4)();
|
|
23
|
-
const notificationPORequest =
|
|
18
|
+
const notificationPORequest = (0, util_1.createNotificationPORequest)(payload, triggerId);
|
|
24
19
|
const response = await (0, fetch_1.post)(fetch_1.POST_OFFICE_FORGE_NOTIFICATION_PATH, notificationPORequest, this.apiClient);
|
|
25
20
|
await (0, validators_1.validateAPIResponse)(response, 'notification');
|
|
26
21
|
return {
|
|
@@ -30,7 +25,7 @@ class NotificationApi {
|
|
|
30
25
|
}
|
|
31
26
|
async getNotificationStatus(triggerId, recipient, recipientType, deliveryChannel) {
|
|
32
27
|
(0, validators_1.validateNotificationStatusParams)(triggerId, recipient, recipientType, deliveryChannel);
|
|
33
|
-
const endpoint = `${fetch_1.POST_OFFICE_FORGE_STATUS_PATH}?triggerId=${encodeURIComponent(triggerId)}&recipient=${encodeURIComponent(recipientType === types_1.RecipientType.ACCOUNT_ID ? userIdToIdentityAri(recipient).toString() : recipient)}&recipientType=${encodeURIComponent(recipientType)}&deliveryChannel=${encodeURIComponent(deliveryChannel)}`;
|
|
28
|
+
const endpoint = `${fetch_1.POST_OFFICE_FORGE_STATUS_PATH}?triggerId=${encodeURIComponent(triggerId)}&recipient=${encodeURIComponent(recipientType === types_1.RecipientType.ACCOUNT_ID ? (0, util_1.userIdToIdentityAri)(recipient).toString() : recipient)}&recipientType=${encodeURIComponent(recipientType)}&deliveryChannel=${encodeURIComponent(deliveryChannel)}`;
|
|
34
29
|
const response = await (0, fetch_1.get)(endpoint, this.apiClient);
|
|
35
30
|
await (0, validators_1.validateAPIResponse)(response, 'status');
|
|
36
31
|
const responseData = await response.json();
|
|
@@ -44,30 +39,5 @@ class NotificationApi {
|
|
|
44
39
|
errors: responseData.errors
|
|
45
40
|
};
|
|
46
41
|
}
|
|
47
|
-
createNotificationPORequest(input, triggerId) {
|
|
48
|
-
const recipientsToProcess = {};
|
|
49
|
-
if (input.recipientsUserIds && input.recipientsUserIds.length > 0) {
|
|
50
|
-
const userAriList = input.recipientsUserIds.map((userId) => userIdToIdentityAri(userId).toString());
|
|
51
|
-
recipientsToProcess.users = {
|
|
52
|
-
userAri: userAriList
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (input.recipientEmails && input.recipientEmails.length > 0) {
|
|
56
|
-
recipientsToProcess.emails = {
|
|
57
|
-
emailAddresses: input.recipientEmails
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const messageTemplateData = {
|
|
61
|
-
id: ECOSYSTEM_FORGE_NOTIFICATION_TEMPLATE,
|
|
62
|
-
context: input.context
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
triggerId,
|
|
66
|
-
messageTemplateData,
|
|
67
|
-
recipientsToProcess: recipientsToProcess,
|
|
68
|
-
eventTime: new Date().toISOString(),
|
|
69
|
-
client: CLIENT_FORGE_NOTIFICATION_SDK
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
42
|
}
|
|
73
43
|
exports.NotificationApi = NotificationApi;
|
package/out/util.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IdentityUserAri, NotificationPayload, NotificationPORequest } from './types';
|
|
2
|
+
export declare const userIdToIdentityAri: (userId: string) => IdentityUserAri;
|
|
3
|
+
export declare const createNotificationPORequest: (input: NotificationPayload, triggerId: string) => NotificationPORequest;
|
|
4
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,mBAAmB,EACnB,qBAAqB,EAEtB,MAAM,SAAS,CAAC;AAKjB,eAAO,MAAM,mBAAmB,WAAY,MAAM,KAAG,eAGnD,CAAC;AAEH,eAAO,MAAM,2BAA2B,UAAW,mBAAmB,aAAa,MAAM,KAAG,qBAiC3F,CAAC"}
|
package/out/util.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNotificationPORequest = exports.userIdToIdentityAri = void 0;
|
|
4
|
+
const CLIENT_FORGE_NOTIFICATION_SDK = 'forge-notification-sdk';
|
|
5
|
+
const ECOSYSTEM_FORGE_NOTIFICATION_TEMPLATE = 'ecosystem-forge-notifications-spike';
|
|
6
|
+
const userIdToIdentityAri = (userId) => ({
|
|
7
|
+
userId,
|
|
8
|
+
toString: () => `ari:cloud:identity::user/${userId}`
|
|
9
|
+
});
|
|
10
|
+
exports.userIdToIdentityAri = userIdToIdentityAri;
|
|
11
|
+
const createNotificationPORequest = (input, triggerId) => {
|
|
12
|
+
const recipientsToProcess = {};
|
|
13
|
+
if (input.recipientsUserIds && input.recipientsUserIds.length > 0) {
|
|
14
|
+
const userAriList = input.recipientsUserIds.map((userId) => (0, exports.userIdToIdentityAri)(userId).toString());
|
|
15
|
+
recipientsToProcess.users = {
|
|
16
|
+
userAri: userAriList
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (input.recipientEmails && input.recipientEmails.length > 0) {
|
|
20
|
+
recipientsToProcess.emails = {
|
|
21
|
+
emailAddresses: input.recipientEmails
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const messageTemplateData = {
|
|
25
|
+
id: ECOSYSTEM_FORGE_NOTIFICATION_TEMPLATE,
|
|
26
|
+
context: input.context
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
triggerId,
|
|
30
|
+
messageTemplateData,
|
|
31
|
+
recipientsToProcess: recipientsToProcess,
|
|
32
|
+
eventTime: new Date().toISOString(),
|
|
33
|
+
client: CLIENT_FORGE_NOTIFICATION_SDK
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.createNotificationPORequest = createNotificationPORequest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/notification",
|
|
3
|
-
"version": "0.1.0-next.1",
|
|
3
|
+
"version": "0.1.0-next.1-experimental-9065145",
|
|
4
4
|
"description": "Forge Notification SDK",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"types": "out/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"compile": "tsc -b -v"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@forge/api": "^6.4.1-next.0",
|
|
13
|
+
"@forge/api": "^6.4.1-next.0-experimental-9065145",
|
|
14
14
|
"uuid": "^9.0.1"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|