@salutejs/scenario
Advanced tools
Comparing version 0.12.0-canary.200.e9020dfde3cdd7c82fcd5576d2b9d3dc6ec47c9a.0 to 0.12.0
@@ -0,1 +1,13 @@ | ||
# v0.12.0 (Thu Jul 15 2021) | ||
#### 🚀 Enhancement | ||
- feat: SmartPush support [#200](https://github.com/sberdevices/salutejs/pull/200) ([@sasha-tlt](https://github.com/sasha-tlt)) | ||
#### Authors: 1 | ||
- Alexander Salmin ([@sasha-tlt](https://github.com/sasha-tlt)) | ||
--- | ||
# v0.11.0 (Tue Jul 13 2021) | ||
@@ -2,0 +14,0 @@ |
@@ -1,6 +0,8 @@ | ||
import { DeliveryConfig, SmartPushResponse } from './types/push'; | ||
import { DeliveryConfig, Destination, SmartPushResponse } from './types/push'; | ||
export interface SendPushConfiguration { | ||
projectId: string; | ||
clientIdSub: string; | ||
deliveryConfig: DeliveryConfig; | ||
deliveryConfig: { | ||
destinations: Omit<Destination, 'channel'>[]; | ||
} & Omit<DeliveryConfig, 'destinations'>; | ||
} | ||
@@ -10,5 +12,3 @@ export declare const createSmartPushSender: ({ clientId, secret }?: { | ||
secret: string; | ||
}) => Promise<{ | ||
send: (push: SendPushConfiguration) => Promise<SmartPushResponse>; | ||
}>; | ||
}) => Promise<(push: SendPushConfiguration) => Promise<SmartPushResponse>>; | ||
//# sourceMappingURL=smartpush.d.ts.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -38,2 +49,13 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -75,6 +97,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
var body, answer; | ||
var destinations, delivery, body, answer; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
destinations = deliveryConfig.destinations, delivery = __rest(deliveryConfig, ["destinations"]); | ||
body = { | ||
@@ -94,3 +117,6 @@ protocolVersion: 'V1', | ||
}, | ||
deliveryConfig: deliveryConfig, | ||
deliveryConfig: __assign(__assign({}, delivery), { destinations: destinations.map(function (_a) { | ||
var surface = _a.surface, destination = __rest(_a, ["surface"]); | ||
return (__assign(__assign({}, destination), { surface: surface, channel: surface === 'COMPANION' ? 'COMPANION_B2C' : 'B2C' })); | ||
}) }), | ||
}, | ||
@@ -140,5 +166,3 @@ }; | ||
messageId = 0; | ||
return [2 /*return*/, { | ||
send: function (push) { return sendPush(access_token, uuidv4(), ++messageId, push); }, | ||
}]; | ||
return [2 /*return*/, function (push) { return sendPush(access_token, uuidv4(), ++messageId, push); }]; | ||
} | ||
@@ -145,0 +169,0 @@ }); |
{ | ||
"name": "@salutejs/scenario", | ||
"version": "0.12.0-canary.200.e9020dfde3cdd7c82fcd5576d2b9d3dc6ec47c9a.0", | ||
"version": "0.12.0", | ||
"description": "Tiny helpers to make scenario for Salute family", | ||
@@ -39,3 +39,3 @@ "author": "SberDevices Frontend Team <sberdevices.frontend@gmail.com>", | ||
}, | ||
"gitHead": "e9020dfde3cdd7c82fcd5576d2b9d3dc6ec47c9a" | ||
"gitHead": "783af7a3c2a8a5af1d9acd5f0c9203a1bfca18c6" | ||
} |
@@ -161,4 +161,3 @@ # @salutejs/scenario | ||
{ | ||
channel: 'COMPANION_B2C', // Канал Сбер Салют, всегда B2C и только с поверхностью COMPANION - COMPANION_B2C | ||
surface: 'COMPANION', // поверхность Сбер Салют | ||
surface: 'COMPANION', // поверхность (Сбер салют) | ||
templateContent: { | ||
@@ -173,5 +172,5 @@ id: '', // id шаблона уведомления из студии | ||
}]; | ||
const sender = await createSmartPushSender(); | ||
pushes.map((push) => | ||
sender.send(push).then(({ payload }: SmartPushResponse) => { | ||
const sendPush = await createSmartPushSender(); | ||
pushes.forEach((push) => | ||
sendPush(push).then(({ payload }: SmartPushResponse) => { | ||
if (payload.validation.results.some(({ status }) => status.code !== 0)) { | ||
@@ -178,0 +177,0 @@ throw new Error('Уведомление не отправлено'); |
Sorry, the diff of this file is not supported yet
304729
3822
293