@heycharles/browser-sdk
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -0,1 +1,8 @@ | ||
# [2.5.0](https://github.com/c-commerce/charles-browser-sdk/compare/v2.4.0...v2.5.0) (2020-02-28) | ||
### Features | ||
* **feeds/messages:** add feed replyables ([f4f26fe](https://github.com/c-commerce/charles-browser-sdk/commit/f4f26fe62b0bac3048d33a5e19b87f13f15d0d0e)) | ||
# [2.4.0](https://github.com/c-commerce/charles-browser-sdk/compare/v2.3.0...v2.4.0) (2020-02-26) | ||
@@ -2,0 +9,0 @@ |
@@ -15,4 +15,52 @@ "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) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var events_1 = require("events"); | ||
var errors_1 = require("../../errors"); | ||
var Feed = /** @class */ (function (_super) { | ||
@@ -56,2 +104,5 @@ __extends(Feed, _super); | ||
}; | ||
Feed.prototype.reply = function (contentOptions) { | ||
return new FeedReply(__assign({ feed: this, http: this.http, universe: this.universe, rawPayload: __assign({}, contentOptions) }, contentOptions)); | ||
}; | ||
Feed.prototype.handleError = function (err) { | ||
@@ -64,2 +115,45 @@ if (this.listeners('error').length > 0) | ||
exports.Feed = Feed; | ||
var FeedReply = /** @class */ (function () { | ||
function FeedReply(options) { | ||
this.feed = options.feed; | ||
this.universe = options.universe; | ||
this.http = options.http; | ||
} | ||
FeedReply.prototype.send = function () { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var res, err_1; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, ((_a = this.http) === null || _a === void 0 ? void 0 : _a.getClient().post("" + this.universe.universeBase + this.feed.id, { | ||
content: this.content | ||
}))]; | ||
case 1: | ||
res = _b.sent(); | ||
return [2 /*return*/, res.data.data[0]]; | ||
case 2: | ||
err_1 = _b.sent(); | ||
throw new FeedReplyError(undefined, { error: err_1 }); | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return FeedReply; | ||
}()); | ||
exports.FeedReply = FeedReply; | ||
var FeedReplyError = /** @class */ (function (_super) { | ||
__extends(FeedReplyError, _super); | ||
function FeedReplyError(message, properties) { | ||
if (message === void 0) { message = 'Could not send feed reply unexpectedly.'; } | ||
var _this = _super.call(this, message, properties) || this; | ||
_this.message = message; | ||
_this.name = 'FeedReplyError'; | ||
return _this; | ||
} | ||
return FeedReplyError; | ||
}(errors_1.BaseError)); | ||
exports.FeedReplyError = FeedReplyError; | ||
//# sourceMappingURL=feed.js.map |
@@ -130,2 +130,5 @@ "use strict"; | ||
}; | ||
Message.prototype.replyFeed = function (contentOptions) { | ||
return new MessageFeedReply(__assign({ message: this, http: this.http, universe: this.universe, rawPayload: __assign({}, contentOptions) }, contentOptions)); | ||
}; | ||
Message.prototype.handleError = function (err) { | ||
@@ -145,2 +148,3 @@ if (this.listeners('error').length > 0) | ||
}(Message)); | ||
exports.Reply = Reply; | ||
var MessageReply = /** @class */ (function (_super) { | ||
@@ -177,2 +181,35 @@ __extends(MessageReply, _super); | ||
}(Reply)); | ||
exports.MessageReply = MessageReply; | ||
var MessageFeedReply = /** @class */ (function (_super) { | ||
__extends(MessageFeedReply, _super); | ||
function MessageFeedReply(options) { | ||
var _this = _super.call(this, options) || this; | ||
_this.message = options.message; | ||
return _this; | ||
} | ||
MessageFeedReply.prototype.send = function () { | ||
var _a, _b, _c; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var res, err_2; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
_d.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, ((_a = this.http) === null || _a === void 0 ? void 0 : _a.getClient().post("" + this.universe.universeBase + ((_c = (_b = this.message.replyables) === null || _b === void 0 ? void 0 : _b.reply_to_feed) === null || _c === void 0 ? void 0 : _c.options.uri), { | ||
content: this.content | ||
}))]; | ||
case 1: | ||
res = _d.sent(); | ||
return [2 /*return*/, res.data.data[0]]; | ||
case 2: | ||
err_2 = _d.sent(); | ||
throw new MessagesReplyError(undefined, { error: err_2 }); | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return MessageFeedReply; | ||
}(Reply)); | ||
exports.MessageFeedReply = MessageFeedReply; | ||
var MessagesReplyError = /** @class */ (function (_super) { | ||
@@ -179,0 +216,0 @@ __extends(MessagesReplyError, _super); |
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { Universe } from '../../universe'; | ||
import { BaseError } from '../../errors'; | ||
import { Reply, MessageRawPayload, MessageReplyContentOptions, ReplyResponse } from '../../messaging/message'; | ||
export interface FeedOptions { | ||
@@ -47,3 +49,28 @@ universe: Universe; | ||
serialize(): FeedRawPayload; | ||
reply(contentOptions: FeedReplyContentOptions): FeedReply; | ||
private handleError; | ||
} | ||
export interface FeedReplyContentOptions extends MessageReplyContentOptions { | ||
} | ||
export interface FeedReplyResponse extends ReplyResponse { | ||
} | ||
export interface FeedReplyOptions { | ||
feed: Feed; | ||
universe: Universe; | ||
http: Universe['http']; | ||
rawPayload?: MessageRawPayload; | ||
} | ||
export declare class FeedReply { | ||
private feed; | ||
private universe; | ||
private http; | ||
content: Reply['content']; | ||
contentType: Reply['contentType']; | ||
constructor(options: FeedReplyOptions); | ||
send(): Promise<FeedReplyResponse | undefined>; | ||
} | ||
export declare class FeedReplyError extends BaseError { | ||
message: string; | ||
name: string; | ||
constructor(message?: string, properties?: any); | ||
} |
@@ -42,2 +42,10 @@ /// <reference types="node" /> | ||
}; | ||
reply_to_feed?: { | ||
deadline: string | null; | ||
type: 'http' | string | null; | ||
options: { | ||
method: 'POST' | string; | ||
uri: 'string'; | ||
}; | ||
}; | ||
}; | ||
@@ -105,2 +113,3 @@ readonly person?: PersonRawPayload['id']; | ||
reply(contentOptions: MessageReplyContentOptions): MessageReply; | ||
replyFeed(contentOptions: MessageReplyContentOptions): MessageFeedReply; | ||
private handleError; | ||
@@ -118,6 +127,6 @@ } | ||
} | ||
declare class Reply extends Message { | ||
export declare class Reply extends Message { | ||
constructor(options: ReplyOptions); | ||
} | ||
declare class MessageReply extends Reply { | ||
export declare class MessageReply extends Reply { | ||
private message; | ||
@@ -127,2 +136,7 @@ constructor(options: MessageReplyOptions); | ||
} | ||
export declare class MessageFeedReply extends Reply { | ||
private message; | ||
constructor(options: MessageReplyOptions); | ||
send(): Promise<ReplyResponse | undefined>; | ||
} | ||
export declare class MessagesReplyError extends BaseError { | ||
@@ -133,2 +147,1 @@ message: string; | ||
} | ||
export {}; |
{ | ||
"name": "@heycharles/browser-sdk", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "The Browser SDK for the Charles APIs.", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
847070
21088