getstream
Advanced tools
Comparing version 8.5.1 to 8.6.1
import { StreamClient, APIResponse, DefaultGenerics } from './client'; | ||
import { StreamUser } from './user'; | ||
type BaseFollowRelation = { | ||
@@ -45,2 +46,11 @@ source: string; | ||
declare function unfollowMany(this: StreamClient, unfollows: UnfollowRelation[]): Promise<APIResponse>; | ||
export type AddUsersResponse = APIResponse & { | ||
created_users: StreamUser[]; | ||
}; | ||
export type GetUsersResponse = APIResponse & { | ||
users: StreamUser[]; | ||
}; | ||
declare function addUsers(this: StreamClient, users: StreamUser[], overrideExisting?: boolean): Promise<AddUsersResponse>; | ||
declare function getUsers(this: StreamClient, ids: string[]): Promise<GetUsersResponse>; | ||
declare function deleteUsers(this: StreamClient, ids: string[]): Promise<string[]>; | ||
declare const _default: { | ||
@@ -50,4 +60,7 @@ addToMany: typeof addToMany; | ||
unfollowMany: typeof unfollowMany; | ||
addUsers: typeof addUsers; | ||
getUsers: typeof getUsers; | ||
deleteUsers: typeof deleteUsers; | ||
}; | ||
export default _default; | ||
//# sourceMappingURL=batch_operations.d.ts.map |
@@ -71,6 +71,38 @@ "use strict"; | ||
} | ||
function addUsers(users) { | ||
var overrideExisting = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
return this.post({ | ||
url: 'users/', | ||
body: { | ||
users: users, | ||
override: overrideExisting | ||
}, | ||
token: this.getOrCreateToken() | ||
}); | ||
} | ||
function getUsers(ids) { | ||
return this.get({ | ||
url: 'users/', | ||
qs: { | ||
ids: ids.join(',') | ||
}, | ||
token: this.getOrCreateToken() | ||
}); | ||
} | ||
function deleteUsers(ids) { | ||
return this.delete({ | ||
url: 'users/', | ||
qs: { | ||
ids: ids.join(',') | ||
}, | ||
token: this.getOrCreateToken() | ||
}); | ||
} | ||
var _default = exports.default = { | ||
addToMany: addToMany, | ||
followMany: followMany, | ||
unfollowMany: unfollowMany | ||
unfollowMany: unfollowMany, | ||
addUsers: addUsers, | ||
getUsers: getUsers, | ||
deleteUsers: deleteUsers | ||
}; |
@@ -17,3 +17,3 @@ /// <reference path="../types/modules.d.ts" /> | ||
import { StreamUser } from './user'; | ||
import { FollowRelation, UnfollowRelation } from './batch_operations'; | ||
import { AddUsersResponse, FollowRelation, GetUsersResponse, UnfollowRelation } from './batch_operations'; | ||
import { StreamFeed, UpdateActivity, Activity, EnrichOptions, PersonalizationFeedAPIResponse, GetActivitiesAPIResponse, GetFeedOptions, EnrichedActivity } from './feed'; | ||
@@ -167,2 +167,5 @@ export type UR = Record<string, unknown>; | ||
createRedirectUrl?: (this: StreamClient, targetUrl: string, userId: string, events: unknown[]) => string; | ||
addUsers?: (this: StreamClient, users: StreamUser[], overrideExisting: boolean) => Promise<AddUsersResponse>; | ||
getUsers?: (this: StreamClient, ids: string[]) => Promise<GetUsersResponse>; | ||
deleteUsers?: (this: StreamClient, ids: string[]) => Promise<string[]>; | ||
/** | ||
@@ -274,3 +277,3 @@ * Initialize a client | ||
replaceReactionOptions: (options: { | ||
rankingVars?: Record<string, string | number>; | ||
rankingVars?: string | Record<string, string | number>; | ||
reactionKindsFilter?: string[]; | ||
@@ -277,0 +280,0 @@ reactions?: Record<string, string | boolean | string[] | Record<string, string | number>>; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
var _typeof3 = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -13,2 +13,3 @@ value: true | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
@@ -38,3 +39,3 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } | ||
@@ -49,3 +50,2 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /// <reference path="../types/modules.d.ts" /> | ||
// eslint-disable-line no-use-before-define | ||
/** | ||
@@ -113,2 +113,8 @@ * Initialize a client | ||
(0, _defineProperty2.default)(this, "createRedirectUrl", void 0); | ||
// eslint-disable-line no-use-before-define | ||
(0, _defineProperty2.default)(this, "addUsers", void 0); | ||
// eslint-disable-line no-use-before-define | ||
(0, _defineProperty2.default)(this, "getUsers", void 0); | ||
// eslint-disable-line no-use-before-define | ||
(0, _defineProperty2.default)(this, "deleteUsers", void 0); | ||
(0, _defineProperty2.default)(this, "replaceReactionOptions", function (options) { | ||
@@ -124,4 +130,12 @@ // Shortcut options for reaction enrichment | ||
if (options.reactions.ranking_vars != null) { | ||
options.rankingVars = options.reactions.ranking_vars; | ||
if ((0, _typeof2.default)(options.reactions.ranking_vars) === 'object') { | ||
options.rankingVars = options.reactions.ranking_vars; | ||
} else if (typeof options.reactions.ranking_vars === 'string') { | ||
options.rankingVars = options.reactions.ranking_vars; | ||
} | ||
} | ||
// if ranking vars are Record, json stringify them | ||
if (options.rankingVars && (0, _typeof2.default)(options.rankingVars) === 'object') { | ||
options.rankingVars = JSON.stringify(options.rankingVars); | ||
} | ||
if (options.reactions.score_vars != null) { | ||
@@ -261,2 +275,5 @@ options.withScoreVars = options.reactions.score_vars; | ||
this.createRedirectUrl = _redirect_url.default; | ||
this.addUsers = _batch_operations.default.addUsers; | ||
this.getUsers = _batch_operations.default.getUsers; | ||
this.deleteUsers = _batch_operations.default.deleteUsers; | ||
} | ||
@@ -263,0 +280,0 @@ } |
@@ -36,3 +36,3 @@ /// <reference path="../types/modules.d.ts" /> | ||
ranking?: string; | ||
rankingVars?: Record<string, string | number>; | ||
rankingVars?: string | Record<string, string | number>; | ||
session?: string; | ||
@@ -39,0 +39,0 @@ withScoreVars?: boolean; |
@@ -14,3 +14,3 @@ { | ||
"license": "BSD-3-Clause", | ||
"version": "8.5.1", | ||
"version": "8.6.1", | ||
"scripts": { | ||
@@ -17,0 +17,0 @@ "changelog": "standard-version --release-as $VERSION --skip.tag --skip.commit --tag-prefix=v", |
import { StreamClient, APIResponse, DefaultGenerics } from './client'; | ||
import utils from './utils'; | ||
import { StreamUser } from './user'; | ||
@@ -87,3 +88,36 @@ type BaseFollowRelation = { | ||
} | ||
export type AddUsersResponse = APIResponse & { | ||
created_users: StreamUser[]; | ||
}; | ||
export type GetUsersResponse = APIResponse & { | ||
users: StreamUser[]; | ||
}; | ||
function addUsers(this: StreamClient, users: StreamUser[], overrideExisting: boolean = false) { | ||
return this.post<AddUsersResponse>({ | ||
url: 'users/', | ||
body: { | ||
users, | ||
override: overrideExisting, | ||
}, | ||
token: this.getOrCreateToken(), | ||
}); | ||
} | ||
function getUsers(this: StreamClient, ids: string[]) { | ||
return this.get<GetUsersResponse>({ | ||
url: 'users/', | ||
qs: { ids: ids.join(',') }, | ||
token: this.getOrCreateToken(), | ||
}); | ||
} | ||
function deleteUsers(this: StreamClient, ids: string[]) { | ||
return this.delete<string[]>({ | ||
url: 'users/', | ||
qs: { ids: ids.join(',') }, | ||
token: this.getOrCreateToken(), | ||
}); | ||
} | ||
export default { | ||
@@ -93,2 +127,5 @@ addToMany, | ||
unfollowMany, | ||
addUsers, | ||
getUsers, | ||
deleteUsers, | ||
}; |
@@ -19,3 +19,8 @@ /// <reference path="../types/modules.d.ts" /> | ||
import utils from './utils'; | ||
import BatchOperations, { FollowRelation, UnfollowRelation } from './batch_operations'; | ||
import BatchOperations, { | ||
AddUsersResponse, | ||
FollowRelation, | ||
GetUsersResponse, | ||
UnfollowRelation, | ||
} from './batch_operations'; | ||
import createRedirectUrl from './redirect_url'; | ||
@@ -192,3 +197,5 @@ import { | ||
createRedirectUrl?: (this: StreamClient, targetUrl: string, userId: string, events: unknown[]) => string; // eslint-disable-line no-use-before-define | ||
addUsers?: (this: StreamClient, users: StreamUser[], overrideExisting: boolean) => Promise<AddUsersResponse>; // eslint-disable-line no-use-before-define | ||
getUsers?: (this: StreamClient, ids: string[]) => Promise<GetUsersResponse>; // eslint-disable-line no-use-before-define | ||
deleteUsers?: (this: StreamClient, ids: string[]) => Promise<string[]>; // eslint-disable-line no-use-before-define | ||
/** | ||
@@ -291,2 +298,5 @@ * Initialize a client | ||
this.createRedirectUrl = createRedirectUrl; | ||
this.addUsers = BatchOperations.addUsers; | ||
this.getUsers = BatchOperations.getUsers; | ||
this.deleteUsers = BatchOperations.deleteUsers; | ||
} | ||
@@ -499,3 +509,3 @@ } | ||
replaceReactionOptions = (options: { | ||
rankingVars?: Record<string, string | number>; | ||
rankingVars?: string | Record<string, string | number>; | ||
reactionKindsFilter?: string[]; | ||
@@ -519,4 +529,12 @@ reactions?: Record<string, string | boolean | string[] | Record<string, string | number>>; | ||
if (options.reactions.ranking_vars != null) { | ||
options.rankingVars = options.reactions.ranking_vars as Record<string, string | number>; | ||
if (typeof options.reactions.ranking_vars === 'object') { | ||
options.rankingVars = options.reactions.ranking_vars as Record<string, string | number>; | ||
} else if (typeof options.reactions.ranking_vars === 'string') { | ||
options.rankingVars = options.reactions.ranking_vars as string; | ||
} | ||
} | ||
// if ranking vars are Record, json stringify them | ||
if (options.rankingVars && typeof options.rankingVars === 'object') { | ||
options.rankingVars = JSON.stringify(options.rankingVars); | ||
} | ||
if (options.reactions.score_vars != null) { | ||
@@ -523,0 +541,0 @@ options.withScoreVars = options.reactions.score_vars as boolean; |
@@ -44,3 +44,3 @@ /// <reference path="../types/modules.d.ts" /> | ||
ranking?: string; | ||
rankingVars?: Record<string, string | number>; | ||
rankingVars?: string | Record<string, string | number>; | ||
session?: string; | ||
@@ -47,0 +47,0 @@ withScoreVars?: boolean; |
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 not supported yet
823259
16811