getstream
Advanced tools
Comparing version 7.4.1 to 8.0.0
@@ -1,2 +0,2 @@ | ||
import { StreamClient, APIResponse } from './client'; | ||
import { StreamClient, APIResponse, DefaultGenerics } from './client'; | ||
declare type BaseFollowRelation = { | ||
@@ -22,3 +22,3 @@ source: string; | ||
*/ | ||
declare function addToMany<ActivityType>(this: StreamClient, activity: ActivityType, feeds: string[]): Promise<APIResponse>; | ||
declare function addToMany<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics>(this: StreamClient, activity: StreamFeedGenerics['activityType'], feeds: string[]): Promise<APIResponse>; | ||
/** | ||
@@ -25,0 +25,0 @@ * Follow multiple feeds with one API call |
@@ -17,2 +17,10 @@ /// <reference path="../types/modules.d.ts" /> | ||
export declare type UnknownRecord = UR; | ||
export declare type DefaultGenerics = { | ||
activityType: UR; | ||
childReactionType: UR; | ||
collectionType: UR; | ||
personalizationType: UR; | ||
reactionType: UR; | ||
userType: UR; | ||
}; | ||
export declare type APIResponse = { | ||
@@ -88,11 +96,11 @@ duration?: string; | ||
}; | ||
export declare type ActivityPartialChanges<ActivityType extends UR = UR> = Partial<ForeignIDTimes> & { | ||
export declare type ActivityPartialChanges<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = Partial<ForeignIDTimes> & { | ||
id?: string; | ||
set?: Partial<ActivityType>; | ||
unset?: Array<Extract<keyof ActivityType, string>>; | ||
set?: Partial<StreamFeedGenerics['activityType']>; | ||
unset?: Array<Extract<keyof StreamFeedGenerics['activityType'], string>>; | ||
}; | ||
export declare type RealTimeMessage<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR> = { | ||
export declare type RealTimeMessage<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = { | ||
deleted: Array<string>; | ||
deleted_foreign_ids: Array<[id: string, time: string]>; | ||
new: Array<Omit<EnrichedActivity<UserType, ActivityType, CollectionType, ReactionType>, 'latest_reactions' | 'latest_reactions_extra' | 'own_reactions' | 'own_reactions_extra' | 'reaction_counts'> & { | ||
new: Array<Omit<EnrichedActivity<StreamFeedGenerics>, 'latest_reactions' | 'latest_reactions_extra' | 'own_reactions' | 'own_reactions_extra' | 'reaction_counts'> & { | ||
group?: string; | ||
@@ -110,3 +118,3 @@ }>; | ||
*/ | ||
export declare class StreamClient<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR, PersonalizationType extends UR = UR> { | ||
export declare class StreamClient<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
baseUrl: string; | ||
@@ -128,3 +136,3 @@ baseAnalyticsUrl: string; | ||
location: string; | ||
fayeClient: Faye.Client<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>> | null; | ||
fayeClient: Faye.Client<RealTimeMessage<StreamFeedGenerics>> | null; | ||
browser: boolean; | ||
@@ -143,12 +151,14 @@ node: boolean; | ||
handlers: Record<string, HandlerCallback>; | ||
currentUser?: StreamUser<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
personalization: Personalization<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
collections: Collections<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
currentUser?: StreamUser<StreamFeedGenerics>; | ||
personalization: Personalization<StreamFeedGenerics>; | ||
collections: Collections<StreamFeedGenerics>; | ||
files: StreamFileStore; | ||
images: StreamImageStore; | ||
reactions: StreamReaction<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>; | ||
reactions: StreamReaction<StreamFeedGenerics>; | ||
private _personalizationToken?; | ||
private _collectionsToken?; | ||
private _getOrCreateToken?; | ||
addToMany?: <ActivityType>(this: StreamClient, activity: ActivityType, feeds: string[]) => Promise<APIResponse>; | ||
addToMany?: <StreamFeedGenerics extends DefaultGenerics = DefaultGenerics>(// eslint-disable-line no-shadow | ||
this: StreamClient, // eslint-disable-line no-use-before-define | ||
activity: StreamFeedGenerics['activityType'], feeds: string[]) => Promise<APIResponse>; | ||
followMany?: (this: StreamClient, follows: FollowRelation[], activityCopyLimit?: number) => Promise<APIResponse>; | ||
@@ -251,3 +261,3 @@ unfollowMany?: (this: StreamClient, unfollows: UnfollowRelation[]) => Promise<APIResponse>; | ||
*/ | ||
feed(feedSlug: string, userId?: string | StreamUser<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, token?: string): StreamFeed<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
feed(feedSlug: string, userId?: string | StreamUser<StreamFeedGenerics>, token?: string): StreamFeed<StreamFeedGenerics>; | ||
/** | ||
@@ -296,4 +306,4 @@ * Combines the base url with version and the relative url | ||
getFayeAuthorization(): { | ||
incoming: (message: Faye.Message<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>, callback: Faye.Callback<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>) => unknown; | ||
outgoing: (message: Faye.Message<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>, callback: Faye.Callback<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>) => void; | ||
incoming: (message: Faye.Message<RealTimeMessage<StreamFeedGenerics>>, callback: Faye.Callback<RealTimeMessage<StreamFeedGenerics>>) => unknown; | ||
outgoing: (message: Faye.Message<RealTimeMessage<StreamFeedGenerics>>, callback: Faye.Callback<RealTimeMessage<StreamFeedGenerics>>) => void; | ||
}; | ||
@@ -308,3 +318,3 @@ /** | ||
*/ | ||
getFayeClient(timeout?: number): Faye.Client<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>; | ||
getFayeClient(timeout?: number): Faye.Client<RealTimeMessage<StreamFeedGenerics>>; | ||
handleResponse: <T>(response: axios.AxiosResponse<T>) => T; | ||
@@ -360,13 +370,13 @@ doAxiosRequest: <T>(method: axios.Method, options: AxiosConfig) => Promise<T>; | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js#updating-activities | ||
* @param {UpdateActivity<ActivityType>[]} activities list of activities to update | ||
* @param {UpdateActivity<StreamFeedGenerics>[]} activities list of activities to update | ||
* @return {Promise<APIResponse>} | ||
*/ | ||
updateActivities(activities: UpdateActivity<ActivityType>[]): Promise<APIResponse>; | ||
updateActivities(activities: UpdateActivity<StreamFeedGenerics>[]): Promise<APIResponse>; | ||
/** | ||
* Updates one activity on the stream | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js#updating-activities | ||
* @param {UpdateActivity<ActivityType>} activity The activity to update | ||
* @param {UpdateActivity<StreamFeedGenerics>} activity The activity to update | ||
* @return {Promise<APIResponse>} | ||
*/ | ||
updateActivity(activity: UpdateActivity<ActivityType>): Promise<APIResponse>; | ||
updateActivity(activity: UpdateActivity<StreamFeedGenerics>): Promise<APIResponse>; | ||
/** | ||
@@ -382,13 +392,13 @@ * Retrieve activities by ID or foreign_id and time | ||
reactions?: Record<string, boolean>; | ||
}): Promise<GetActivitiesAPIResponse<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>>; | ||
}): Promise<GetActivitiesAPIResponse<StreamFeedGenerics>>; | ||
getOrCreateToken(): string; | ||
user(userId: string): StreamUser<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
setUser(data: UserType): Promise<StreamUser<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>>; | ||
user(userId: string): StreamUser<StreamFeedGenerics>; | ||
setUser(data: StreamFeedGenerics['userType']): Promise<StreamUser<StreamFeedGenerics>>; | ||
og(url: string): Promise<OGAPIResponse>; | ||
personalizedFeed(options?: GetFeedOptions): Promise<PersonalizationFeedAPIResponse<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>>; | ||
personalizedFeed(options?: GetFeedOptions): Promise<PersonalizationFeedAPIResponse<StreamFeedGenerics>>; | ||
/** | ||
* Update a single activity with partial operations. | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js&q=partial+#activity-partial-update | ||
* @param {ActivityPartialChanges<ActivityType>} data object containing either the ID or the foreign_id and time of the activity and the operations to issue as set:{...} and unset:[...]. | ||
* @return {Promise<Activity<ActivityType>>} | ||
* @param {ActivityPartialChanges<StreamFeedGenerics>} data object containing either the ID or the foreign_id and time of the activity and the operations to issue as set:{...} and unset:[...]. | ||
* @return {Promise<Activity<StreamFeedGenerics>>} | ||
* @example | ||
@@ -421,8 +431,8 @@ * client.activityPartialUpdate({ | ||
*/ | ||
activityPartialUpdate(data: ActivityPartialChanges<ActivityType>): Promise<APIResponse & Activity<ActivityType>>; | ||
activityPartialUpdate(data: ActivityPartialChanges<StreamFeedGenerics>): Promise<APIResponse & Activity<StreamFeedGenerics>>; | ||
/** | ||
* Update multiple activities with partial operations. | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js&q=partial+#activity-partial-update | ||
* @param {ActivityPartialChanges<ActivityType>[]} changes array containing the changesets to be applied. Every changeset contains the activity identifier which is either the ID or the pair of of foreign ID and time of the activity. The operations to issue can be set:{...} and unset:[...]. | ||
* @return {Promise<{ activities: Activity<ActivityType>[] }>} | ||
* @param {ActivityPartialChanges<StreamFeedGenerics>[]} changes array containing the changesets to be applied. Every changeset contains the activity identifier which is either the ID or the pair of of foreign ID and time of the activity. The operations to issue can be set:{...} and unset:[...]. | ||
* @return {Promise<{ activities: Activity<StreamFeedGenerics>[] }>} | ||
* @example | ||
@@ -477,4 +487,4 @@ * client.activitiesPartialUpdate([ | ||
*/ | ||
activitiesPartialUpdate(changes: ActivityPartialChanges<ActivityType>[]): Promise<APIResponse & { | ||
activities: Activity<ActivityType>[]; | ||
activitiesPartialUpdate(changes: ActivityPartialChanges<StreamFeedGenerics>[]): Promise<APIResponse & { | ||
activities: Activity<StreamFeedGenerics>[]; | ||
}>; | ||
@@ -481,0 +491,0 @@ } |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _typeof = require("@babel/runtime/helpers/typeof"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -12,4 +12,2 @@ value: true | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
@@ -19,2 +17,4 @@ | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
@@ -62,6 +62,14 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
var _excluded = ["method", "token"], | ||
_excluded2 = ["ids", "foreignIDTimes"], | ||
_excluded3 = ["activities"]; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
// TODO: no import since typescript json loader shifts the final output structure | ||
@@ -76,3 +84,6 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var StreamClient = /*#__PURE__*/function () { | ||
// eslint-disable-next-line no-shadow | ||
// eslint-disable-line no-use-before-define | ||
// eslint-disable-line no-use-before-define | ||
// eslint-disable-line no-use-before-define | ||
// eslint-disable-line no-use-before-define | ||
@@ -175,3 +186,3 @@ /** | ||
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(method, options) { | ||
var response; | ||
var response, err; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
@@ -196,14 +207,15 @@ while (1) { | ||
_context.t0 = _context["catch"](1); | ||
err = _context.t0; | ||
if (!_context.t0.response) { | ||
_context.next = 12; | ||
if (!err.response) { | ||
_context.next = 13; | ||
break; | ||
} | ||
return _context.abrupt("return", _this.handleResponse(_context.t0.response)); | ||
return _context.abrupt("return", _this.handleResponse(err.response)); | ||
case 12: | ||
throw new _errors.SiteError(_context.t0.message); | ||
case 13: | ||
throw new _errors.SiteError(err.message); | ||
case 13: | ||
case 14: | ||
case "end": | ||
@@ -540,3 +552,3 @@ return _context.stop(); | ||
token = _ref2.token, | ||
kwargs = (0, _objectWithoutProperties2.default)(_ref2, ["method", "token"]); | ||
kwargs = (0, _objectWithoutProperties2.default)(_ref2, _excluded); | ||
return _objectSpread({ | ||
@@ -709,3 +721,3 @@ method: method, | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js#updating-activities | ||
* @param {UpdateActivity<ActivityType>[]} activities list of activities to update | ||
* @param {UpdateActivity<StreamFeedGenerics>[]} activities list of activities to update | ||
* @return {Promise<APIResponse>} | ||
@@ -738,3 +750,3 @@ */ | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js#updating-activities | ||
* @param {UpdateActivity<ActivityType>} activity The activity to update | ||
* @param {UpdateActivity<StreamFeedGenerics>} activity The activity to update | ||
* @return {Promise<APIResponse>} | ||
@@ -762,3 +774,3 @@ */ | ||
foreignIDTimes = _ref3.foreignIDTimes, | ||
params = (0, _objectWithoutProperties2.default)(_ref3, ["ids", "foreignIDTimes"]); | ||
params = (0, _objectWithoutProperties2.default)(_ref3, _excluded2); | ||
var extraParams = {}; | ||
@@ -891,4 +903,4 @@ | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js&q=partial+#activity-partial-update | ||
* @param {ActivityPartialChanges<ActivityType>} data object containing either the ID or the foreign_id and time of the activity and the operations to issue as set:{...} and unset:[...]. | ||
* @return {Promise<Activity<ActivityType>>} | ||
* @param {ActivityPartialChanges<StreamFeedGenerics>} data object containing either the ID or the foreign_id and time of the activity and the operations to issue as set:{...} and unset:[...]. | ||
* @return {Promise<Activity<StreamFeedGenerics>>} | ||
* @example | ||
@@ -938,3 +950,3 @@ * client.activityPartialUpdate({ | ||
activities = _yield$this$activitie.activities; | ||
response = (0, _objectWithoutProperties2.default)(_yield$this$activitie, ["activities"]); | ||
response = (0, _objectWithoutProperties2.default)(_yield$this$activitie, _excluded3); | ||
_activities = (0, _slicedToArray2.default)(activities, 1), activity = _activities[0]; | ||
@@ -960,4 +972,4 @@ return _context3.abrupt("return", _objectSpread(_objectSpread({}, activity), response)); | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js&q=partial+#activity-partial-update | ||
* @param {ActivityPartialChanges<ActivityType>[]} changes array containing the changesets to be applied. Every changeset contains the activity identifier which is either the ID or the pair of of foreign ID and time of the activity. The operations to issue can be set:{...} and unset:[...]. | ||
* @return {Promise<{ activities: Activity<ActivityType>[] }>} | ||
* @param {ActivityPartialChanges<StreamFeedGenerics>[]} changes array containing the changesets to be applied. Every changeset contains the activity identifier which is either the ID or the pair of of foreign ID and time of the activity. The operations to issue can be set:{...} and unset:[...]. | ||
* @return {Promise<{ activities: Activity<StreamFeedGenerics>[] }>} | ||
* @example | ||
@@ -964,0 +976,0 @@ * client.activitiesPartialUpdate([ |
@@ -1,12 +0,12 @@ | ||
import { StreamClient, APIResponse, UR } from './client'; | ||
declare type BaseCollection<CollectionType> = { | ||
import { StreamClient, APIResponse, DefaultGenerics } from './client'; | ||
declare type BaseCollection<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = { | ||
collection: string; | ||
data: CollectionType; | ||
data: StreamFeedGenerics['collectionType']; | ||
id: string; | ||
}; | ||
export declare type CollectionItem<CollectionType extends UR = UR> = CollectionType & { | ||
export declare type CollectionItem<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = StreamFeedGenerics['collectionType'] & { | ||
id: string; | ||
user_id?: string; | ||
}; | ||
export declare type CollectionResponse<CollectionType extends UR = UR> = BaseCollection<CollectionType> & { | ||
export declare type CollectionResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = BaseCollection<StreamFeedGenerics> & { | ||
created_at: string; | ||
@@ -16,26 +16,26 @@ foreign_id: string; | ||
}; | ||
export declare type NewCollectionEntry<CollectionType extends UR = UR> = BaseCollection<CollectionType> & { | ||
export declare type NewCollectionEntry<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = BaseCollection<StreamFeedGenerics> & { | ||
user_id?: string; | ||
}; | ||
export declare type CollectionAPIResponse<CollectionType extends UR = UR> = APIResponse & CollectionResponse<CollectionType>; | ||
export declare type SelectCollectionAPIResponse<CollectionType extends UR = UR> = APIResponse & { | ||
export declare type CollectionAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & CollectionResponse<StreamFeedGenerics>; | ||
export declare type SelectCollectionAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
response: { | ||
data: CollectionResponse<CollectionType>[]; | ||
data: CollectionResponse<StreamFeedGenerics>[]; | ||
}; | ||
}; | ||
export declare type UpsertCollectionAPIResponse<CollectionType extends UR = UR> = APIResponse & { | ||
export declare type UpsertCollectionAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
data: { | ||
[key: string]: CollectionItem<CollectionType>[]; | ||
[key: string]: CollectionItem<StreamFeedGenerics>[]; | ||
}; | ||
}; | ||
export declare type UpsertManyCollectionRequest<CollectionType extends UR = UR> = { | ||
[collection: string]: CollectionItem<CollectionType>[]; | ||
export declare type UpsertManyCollectionRequest<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = { | ||
[collection: string]: CollectionItem<StreamFeedGenerics>[]; | ||
}; | ||
export declare class CollectionEntry<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR, PersonalizationType extends UR = UR> { | ||
export declare class CollectionEntry<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
id: string; | ||
collection: string; | ||
store: Collections<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
data: CollectionType | null; | ||
store: Collections<StreamFeedGenerics>; | ||
data: StreamFeedGenerics['collectionType'] | null; | ||
full?: unknown; | ||
constructor(store: Collections<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, collection: string, id: string, data: CollectionType); | ||
constructor(store: Collections<StreamFeedGenerics>, collection: string, id: string, data: StreamFeedGenerics['collectionType']); | ||
ref(): string; | ||
@@ -46,6 +46,6 @@ /** | ||
* @memberof CollectionEntry.prototype | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.get("0c7db91c-67f9-11e8-bcd9-fe00a9219401") | ||
*/ | ||
get(): Promise<CollectionEntry<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>>; | ||
get(): Promise<CollectionEntry<StreamFeedGenerics>>; | ||
/** | ||
@@ -56,6 +56,6 @@ * Add item to collection | ||
* @memberof CollectionEntry.prototype | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.add("cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
*/ | ||
add(): Promise<CollectionEntry<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>>; | ||
add(): Promise<CollectionEntry<StreamFeedGenerics>>; | ||
/** | ||
@@ -66,7 +66,7 @@ * Update item in the object storage | ||
* @memberof CollectionEntry.prototype | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example store.update("0c7db91c-67f9-11e8-bcd9-fe00a9219401", {"name": "cheese burger","toppings": "cheese"}) | ||
* @example store.update("cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
*/ | ||
update(): Promise<CollectionEntry<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>>; | ||
update(): Promise<CollectionEntry<StreamFeedGenerics>>; | ||
/** | ||
@@ -82,4 +82,4 @@ * Delete item from collection | ||
} | ||
export declare class Collections<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR, PersonalizationType extends UR = UR> { | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export declare class Collections<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
client: StreamClient<StreamFeedGenerics>; | ||
token: string; | ||
@@ -93,5 +93,5 @@ /** | ||
*/ | ||
constructor(client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, token: string); | ||
constructor(client: StreamClient<StreamFeedGenerics>, token: string); | ||
buildURL: (collection: string, itemId?: string | undefined) => string; | ||
entry(collection: string, itemId: string, itemData: CollectionType): CollectionEntry<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
entry(collection: string, itemId: string, itemData: StreamFeedGenerics['collectionType']): CollectionEntry<StreamFeedGenerics>; | ||
/** | ||
@@ -104,6 +104,6 @@ * get item from collection | ||
* @param {string} itemId id for this entry | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.get("food", "0c7db91c-67f9-11e8-bcd9-fe00a9219401") | ||
*/ | ||
get(collection: string, itemId: string): Promise<CollectionEntry<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>>; | ||
get(collection: string, itemId: string): Promise<CollectionEntry<StreamFeedGenerics>>; | ||
/** | ||
@@ -117,6 +117,6 @@ * Add item to collection | ||
* @param {CollectionType} itemData ObjectStore data | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.add("food", "cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
*/ | ||
add(collection: string, itemId: string | null, itemData: CollectionType): Promise<CollectionEntry<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>>; | ||
add(collection: string, itemId: string | null, itemData: StreamFeedGenerics['collectionType']): Promise<CollectionEntry<StreamFeedGenerics>>; | ||
/** | ||
@@ -130,7 +130,7 @@ * Update entry in the collection | ||
* @param {CollectionType} data ObjectStore data | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example store.update("0c7db91c-67f9-11e8-bcd9-fe00a9219401", {"name": "cheese burger","toppings": "cheese"}) | ||
* @example store.update("food", "cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
*/ | ||
update(collection: string, entryId: string, data: CollectionType): Promise<CollectionEntry<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>>; | ||
update(collection: string, entryId: string, data: StreamFeedGenerics['collectionType']): Promise<CollectionEntry<StreamFeedGenerics>>; | ||
/** | ||
@@ -153,6 +153,6 @@ * Delete entry from collection | ||
* @param {string} collection collection name | ||
* @param {NewCollectionEntry<CollectionType> | NewCollectionEntry<CollectionType>[]} data - A single json object or an array of objects | ||
* @return {Promise<UpsertCollectionAPIResponse<CollectionType>>} | ||
* @param {NewCollectionEntry<StreamFeedGenerics> | NewCollectionEntry<StreamFeedGenerics>[]} data - A single json object or an array of objects | ||
* @return {Promise<UpsertCollectionAPIResponse<StreamFeedGenerics>>} | ||
*/ | ||
upsert(collection: string, data: CollectionItem<CollectionType> | CollectionItem<CollectionType>[]): Promise<UpsertCollectionAPIResponse<CollectionType>>; | ||
upsert(collection: string, data: CollectionItem<StreamFeedGenerics> | CollectionItem<StreamFeedGenerics>[]): Promise<UpsertCollectionAPIResponse<StreamFeedGenerics>>; | ||
/** | ||
@@ -165,5 +165,5 @@ * UpsertMany one or more items into many collections. | ||
* @param {UpsertManyCollectionRequest} items - A single json object that contains information of many collections | ||
* @return {Promise<UpsertCollectionAPIResponse<CollectionType>>} | ||
* @return {Promise<UpsertCollectionAPIResponse<StreamFeedGenerics>>} | ||
*/ | ||
upsertMany(items: UpsertManyCollectionRequest): Promise<UpsertCollectionAPIResponse<CollectionType>>; | ||
upsertMany(items: UpsertManyCollectionRequest): Promise<UpsertCollectionAPIResponse<StreamFeedGenerics>>; | ||
/** | ||
@@ -176,5 +176,5 @@ * Select all objects with ids from the collection. | ||
* @param {string | string[]} ids - A single object id or an array of ids | ||
* @return {Promise<SelectCollectionAPIResponse<CollectionType>>} | ||
* @return {Promise<SelectCollectionAPIResponse<StreamFeedGenerics>>} | ||
*/ | ||
select(collection: string, ids: string | string[]): Promise<SelectCollectionAPIResponse<CollectionType>>; | ||
select(collection: string, ids: string | string[]): Promise<SelectCollectionAPIResponse<StreamFeedGenerics>>; | ||
/** | ||
@@ -181,0 +181,0 @@ * Remove all objects by id from the collection. |
@@ -47,3 +47,3 @@ "use strict"; | ||
* @memberof CollectionEntry.prototype | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.get("0c7db91c-67f9-11e8-bcd9-fe00a9219401") | ||
@@ -89,3 +89,3 @@ */ | ||
* @memberof CollectionEntry.prototype | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.add("cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
@@ -131,3 +131,3 @@ */ | ||
* @memberof CollectionEntry.prototype | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example store.update("0c7db91c-67f9-11e8-bcd9-fe00a9219401", {"name": "cheese burger","toppings": "cheese"}) | ||
@@ -248,3 +248,3 @@ * @example store.update("cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
* @param {string} itemId id for this entry | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.get("food", "0c7db91c-67f9-11e8-bcd9-fe00a9219401") | ||
@@ -296,3 +296,3 @@ */ | ||
* @param {CollectionType} itemData ObjectStore data | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.add("food", "cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
@@ -348,3 +348,3 @@ */ | ||
* @param {CollectionType} data ObjectStore data | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example store.update("0c7db91c-67f9-11e8-bcd9-fe00a9219401", {"name": "cheese burger","toppings": "cheese"}) | ||
@@ -417,4 +417,4 @@ * @example store.update("food", "cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
* @param {string} collection collection name | ||
* @param {NewCollectionEntry<CollectionType> | NewCollectionEntry<CollectionType>[]} data - A single json object or an array of objects | ||
* @return {Promise<UpsertCollectionAPIResponse<CollectionType>>} | ||
* @param {NewCollectionEntry<StreamFeedGenerics> | NewCollectionEntry<StreamFeedGenerics>[]} data - A single json object or an array of objects | ||
* @return {Promise<UpsertCollectionAPIResponse<StreamFeedGenerics>>} | ||
*/ | ||
@@ -446,3 +446,3 @@ | ||
* @param {UpsertManyCollectionRequest} items - A single json object that contains information of many collections | ||
* @return {Promise<UpsertCollectionAPIResponse<CollectionType>>} | ||
* @return {Promise<UpsertCollectionAPIResponse<StreamFeedGenerics>>} | ||
*/ | ||
@@ -473,3 +473,3 @@ | ||
* @param {string | string[]} ids - A single object id or an array of ids | ||
* @return {Promise<SelectCollectionAPIResponse<CollectionType>>} | ||
* @return {Promise<SelectCollectionAPIResponse<StreamFeedGenerics>>} | ||
*/ | ||
@@ -476,0 +476,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { StreamClient, UR, ClientOptions } from './client'; | ||
import { StreamClient, ClientOptions, DefaultGenerics } from './client'; | ||
/** | ||
@@ -25,3 +25,3 @@ * Create StreamClient | ||
*/ | ||
export declare function connect<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR, PersonalizationType extends UR = UR>(apiKey: string, apiSecret: string | null, appId?: string, options?: ClientOptions): StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export declare function connect<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics>(apiKey: string, apiSecret: string | null, appId?: string, options?: ClientOptions): StreamClient<StreamFeedGenerics>; | ||
//# sourceMappingURL=connect.d.ts.map |
@@ -8,4 +8,6 @@ "use strict"; | ||
}); | ||
exports.StreamApiError = exports.MissingSchemaError = exports.SiteError = exports.FeedError = void 0; | ||
exports.StreamApiError = exports.SiteError = exports.MissingSchemaError = exports.FeedError = void 0; | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
@@ -62,3 +64,3 @@ | ||
return ErrorAbstract; | ||
return (0, _createClass2.default)(ErrorAbstract); | ||
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error)); | ||
@@ -85,3 +87,3 @@ /** | ||
return FeedError; | ||
return (0, _createClass2.default)(FeedError); | ||
}(ErrorAbstract); | ||
@@ -110,3 +112,3 @@ /** | ||
return SiteError; | ||
return (0, _createClass2.default)(SiteError); | ||
}(ErrorAbstract); | ||
@@ -135,3 +137,3 @@ /** | ||
return MissingSchemaError; | ||
return (0, _createClass2.default)(MissingSchemaError); | ||
}(ErrorAbstract); | ||
@@ -169,5 +171,5 @@ /** | ||
return StreamApiError; | ||
return (0, _createClass2.default)(StreamApiError); | ||
}(ErrorAbstract); | ||
exports.StreamApiError = StreamApiError; |
/// <reference path="../types/modules.d.ts" /> | ||
import * as Faye from 'faye'; | ||
import { StreamClient, APIResponse, UR, RealTimeMessage } from './client'; | ||
import { StreamClient, APIResponse, UR, RealTimeMessage, DefaultGenerics } from './client'; | ||
import { StreamUser, EnrichedUser } from './user'; | ||
@@ -71,3 +71,3 @@ import { EnrichedReaction } from './reaction'; | ||
}; | ||
export declare type NewActivity<ActivityType extends UR = UR> = ActivityType & BaseActivity & { | ||
export declare type NewActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = StreamFeedGenerics['activityType'] & BaseActivity & { | ||
actor: string | StreamUser; | ||
@@ -78,3 +78,3 @@ object: string | unknown; | ||
}; | ||
export declare type UpdateActivity<ActivityType extends UR = UR> = ActivityType & BaseActivity & { | ||
export declare type UpdateActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = StreamFeedGenerics['activityType'] & BaseActivity & { | ||
actor: string; | ||
@@ -85,3 +85,3 @@ foreign_id: string; | ||
}; | ||
export declare type Activity<ActivityType extends UR = UR> = ActivityType & BaseActivity & { | ||
export declare type Activity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = StreamFeedGenerics['activityType'] & BaseActivity & { | ||
actor: string; | ||
@@ -97,19 +97,19 @@ foreign_id: string; | ||
}; | ||
export declare type ReactionsRecords<ReactionType extends UR = UR, ChildReactionType extends UR = UR, UserType extends UR = UR> = Record<string, EnrichedReaction<ReactionType, ChildReactionType, UserType>[]>; | ||
export declare type EnrichedActivity<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR> = ActivityType & BaseActivity & Pick<Activity, 'foreign_id' | 'id' | 'time' | 'analytics' | 'extra_context' | 'origin' | 'score'> & { | ||
actor: EnrichedUser<UserType> | string; | ||
object: string | unknown | EnrichedActivity<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType> | EnrichedReaction<ReactionType, ChildReactionType, UserType> | CollectionResponse<CollectionType>; | ||
latest_reactions?: ReactionsRecords<ReactionType, ChildReactionType, UserType>; | ||
export declare type ReactionsRecords<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = Record<string, EnrichedReaction<StreamFeedGenerics>[]>; | ||
export declare type EnrichedActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = StreamFeedGenerics['activityType'] & BaseActivity & Pick<Activity, 'foreign_id' | 'id' | 'time' | 'analytics' | 'extra_context' | 'origin' | 'score'> & { | ||
actor: EnrichedUser<StreamFeedGenerics> | string; | ||
object: string | unknown | EnrichedActivity<StreamFeedGenerics> | EnrichedReaction<StreamFeedGenerics> | CollectionResponse<StreamFeedGenerics>; | ||
latest_reactions?: ReactionsRecords<StreamFeedGenerics>; | ||
latest_reactions_extra?: Record<string, { | ||
next?: string; | ||
}>; | ||
own_reactions?: ReactionsRecords<ReactionType, ChildReactionType, UserType>; | ||
own_reactions?: ReactionsRecords<StreamFeedGenerics>; | ||
own_reactions_extra?: Record<string, { | ||
next?: string; | ||
}>; | ||
reaction?: EnrichedReaction<ReactionType, ChildReactionType, UserType>; | ||
reaction?: EnrichedReaction<StreamFeedGenerics>; | ||
reaction_counts?: Record<string, number>; | ||
}; | ||
export declare type FlatActivity<ActivityType extends UR = UR> = Activity<ActivityType>; | ||
export declare type FlatActivityEnriched<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR> = EnrichedActivity<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>; | ||
export declare type FlatActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = Activity<StreamFeedGenerics>; | ||
export declare type FlatActivityEnriched<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = EnrichedActivity<StreamFeedGenerics>; | ||
declare type BaseAggregatedActivity = { | ||
@@ -125,7 +125,7 @@ activity_count: number; | ||
}; | ||
export declare type AggregatedActivity<ActivityType extends UR = UR> = BaseAggregatedActivity & { | ||
activities: Activity<ActivityType>[]; | ||
export declare type AggregatedActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = BaseAggregatedActivity & { | ||
activities: Activity<StreamFeedGenerics>[]; | ||
}; | ||
export declare type AggregatedActivityEnriched<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR> = BaseAggregatedActivity & { | ||
activities: EnrichedActivity<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[]; | ||
export declare type AggregatedActivityEnriched<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = BaseAggregatedActivity & { | ||
activities: EnrichedActivity<StreamFeedGenerics>[]; | ||
}; | ||
@@ -136,19 +136,19 @@ declare type BaseNotificationActivity = { | ||
}; | ||
export declare type NotificationActivity<ActivityType extends UR = UR> = AggregatedActivity<ActivityType> & BaseNotificationActivity; | ||
export declare type NotificationActivityEnriched<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR> = BaseNotificationActivity & AggregatedActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>; | ||
export declare type FeedAPIResponse<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR> = APIResponse & { | ||
export declare type NotificationActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = AggregatedActivity<StreamFeedGenerics> & BaseNotificationActivity; | ||
export declare type NotificationActivityEnriched<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = BaseNotificationActivity & AggregatedActivityEnriched<StreamFeedGenerics>; | ||
export declare type FeedAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
next: string; | ||
results: FlatActivity<ActivityType>[] | FlatActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[] | AggregatedActivity<ActivityType>[] | AggregatedActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[] | NotificationActivity<ActivityType>[] | NotificationActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[]; | ||
results: FlatActivity<StreamFeedGenerics>[] | FlatActivityEnriched<StreamFeedGenerics>[] | AggregatedActivity<StreamFeedGenerics>[] | AggregatedActivityEnriched<StreamFeedGenerics>[] | NotificationActivity<StreamFeedGenerics>[] | NotificationActivityEnriched<StreamFeedGenerics>[]; | ||
unread?: number; | ||
unseen?: number; | ||
}; | ||
export declare type PersonalizationFeedAPIResponse<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR> = APIResponse & { | ||
export declare type PersonalizationFeedAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
limit: number; | ||
next: string; | ||
offset: number; | ||
results: FlatActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[]; | ||
results: FlatActivityEnriched<StreamFeedGenerics>[]; | ||
version: string; | ||
}; | ||
export declare type GetActivitiesAPIResponse<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR> = APIResponse & { | ||
results: FlatActivity<ActivityType>[] | FlatActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[]; | ||
export declare type GetActivitiesAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
results: FlatActivity<StreamFeedGenerics>[] | FlatActivityEnriched<StreamFeedGenerics>[]; | ||
}; | ||
@@ -160,4 +160,4 @@ /** | ||
*/ | ||
export declare class StreamFeed<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR, PersonalizationType extends UR = UR> { | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export declare class StreamFeed<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
client: StreamClient<StreamFeedGenerics>; | ||
token: string; | ||
@@ -180,3 +180,3 @@ id: string; | ||
*/ | ||
constructor(client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, feedSlug: string, userId: string, token: string); | ||
constructor(client: StreamClient<StreamFeedGenerics>, feedSlug: string, userId: string, token: string); | ||
/** | ||
@@ -187,6 +187,6 @@ * Adds the given activity to the feed | ||
* @memberof StreamFeed.prototype | ||
* @param {NewActivity<ActivityType>} activity - The activity to add | ||
* @return {Promise<Activity<ActivityType>>} | ||
* @param {NewActivity<StreamFeedGenerics>} activity - The activity to add | ||
* @return {Promise<Activity<StreamFeedGenerics>>} | ||
*/ | ||
addActivity(activity: NewActivity<ActivityType>): Promise<Activity<ActivityType>>; | ||
addActivity(activity: NewActivity<StreamFeedGenerics>): Promise<Activity<StreamFeedGenerics>>; | ||
/** | ||
@@ -214,6 +214,6 @@ * Removes the activity by activityId or foreignId | ||
* @memberof StreamFeed.prototype | ||
* @param {NewActivity<ActivityType>[]} activities Array of activities to add | ||
* @return {Promise<Activity<ActivityType>[]>} | ||
* @param {NewActivity<StreamFeedGenerics>[]} activities Array of activities to add | ||
* @return {Promise<Activity<StreamFeedGenerics>[]>} | ||
*/ | ||
addActivities(activities: NewActivity<ActivityType>[]): Promise<Activity<ActivityType>[]>; | ||
addActivities(activities: NewActivity<StreamFeedGenerics>[]): Promise<Activity<StreamFeedGenerics>[]>; | ||
/** | ||
@@ -303,3 +303,3 @@ * Follows the given target feed | ||
*/ | ||
get(options?: GetFeedOptions): Promise<FeedAPIResponse<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>>; | ||
get(options?: GetFeedOptions): Promise<FeedAPIResponse<StreamFeedGenerics>>; | ||
/** | ||
@@ -318,3 +318,3 @@ * Retrieves one activity from a feed and adds enrichment | ||
*/ | ||
getActivityDetail(activityId: string, options: EnrichOptions): Promise<FeedAPIResponse<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>>; | ||
getActivityDetail(activityId: string, options: EnrichOptions): Promise<FeedAPIResponse<StreamFeedGenerics>>; | ||
/** | ||
@@ -327,3 +327,3 @@ * Returns the current faye client object | ||
*/ | ||
getFayeClient(): Faye.Client<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>; | ||
getFayeClient(): Faye.Client<RealTimeMessage<StreamFeedGenerics>>; | ||
/** | ||
@@ -334,3 +334,3 @@ * Subscribes to any changes in the feed, return a promise | ||
* @memberof StreamFeed.prototype | ||
* @param {function} Faye.Callback<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>> Callback to call on completion | ||
* @param {function} Faye.Callback<RealTimeMessage<StreamFeedGenerics>> Callback to call on completion | ||
* @return {Promise<Faye.Subscription>} | ||
@@ -342,3 +342,3 @@ * @example | ||
*/ | ||
subscribe(callback: Faye.SubscribeCallback<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>): Promise<Faye.Subscription>; | ||
subscribe(callback: Faye.SubscribeCallback<RealTimeMessage<StreamFeedGenerics>>): Promise<Faye.Subscription>; | ||
/** | ||
@@ -359,3 +359,3 @@ * Cancel updates created via feed.subscribe() | ||
*/ | ||
updateActivityToTargets(foreignId: string, time: string, newTargets?: string[], addedTargets?: string[], removedTargets?: string[]): Promise<APIResponse & ActivityType & BaseActivity & { | ||
updateActivityToTargets(foreignId: string, time: string, newTargets?: string[], addedTargets?: string[], removedTargets?: string[]): Promise<APIResponse & StreamFeedGenerics["activityType"] & BaseActivity & { | ||
actor: string; | ||
@@ -362,0 +362,0 @@ foreign_id: string; |
@@ -22,5 +22,5 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
@@ -86,4 +86,4 @@ /** | ||
* @memberof StreamFeed.prototype | ||
* @param {NewActivity<ActivityType>} activity - The activity to add | ||
* @return {Promise<Activity<ActivityType>>} | ||
* @param {NewActivity<StreamFeedGenerics>} activity - The activity to add | ||
* @return {Promise<Activity<StreamFeedGenerics>>} | ||
*/ | ||
@@ -135,4 +135,4 @@ | ||
* @memberof StreamFeed.prototype | ||
* @param {NewActivity<ActivityType>[]} activities Array of activities to add | ||
* @return {Promise<Activity<ActivityType>[]>} | ||
* @param {NewActivity<StreamFeedGenerics>[]} activities Array of activities to add | ||
* @return {Promise<Activity<StreamFeedGenerics>[]>} | ||
*/ | ||
@@ -374,3 +374,3 @@ | ||
* @memberof StreamFeed.prototype | ||
* @param {function} Faye.Callback<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>> Callback to call on completion | ||
* @param {function} Faye.Callback<RealTimeMessage<StreamFeedGenerics>> Callback to call on completion | ||
* @return {Promise<Faye.Subscription>} | ||
@@ -377,0 +377,0 @@ * @example |
@@ -1,2 +0,2 @@ | ||
import { StreamClient, APIResponse, UR } from './client'; | ||
import { StreamClient, APIResponse, UR, DefaultGenerics } from './client'; | ||
/** | ||
@@ -7,6 +7,6 @@ * Manage api calls for personalization | ||
*/ | ||
export declare type PersonalizationAPIResponse<PersonalizationType extends UR = UR> = APIResponse & { | ||
export declare type PersonalizationAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
app_id: string; | ||
next: string; | ||
results: PersonalizationType[]; | ||
results: Array<StreamFeedGenerics['personalizationType']>; | ||
limit?: number; | ||
@@ -16,4 +16,4 @@ offset?: number; | ||
}; | ||
export declare class Personalization<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR, PersonalizationType extends UR = UR> { | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export declare class Personalization<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
client: StreamClient<StreamFeedGenerics>; | ||
/** | ||
@@ -26,3 +26,3 @@ * Initialize the Personalization class | ||
*/ | ||
constructor(client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>); | ||
constructor(client: StreamClient<StreamFeedGenerics>); | ||
/** | ||
@@ -35,3 +35,3 @@ * Get personalized activities for this feed | ||
* @param {object} options Additional options | ||
* @return {Promise<PersonalizationAPIResponse<PersonalizationType>>} Promise object. Personalized feed | ||
* @return {Promise<PersonalizationAPIResponse<StreamFeedGenerics>>} Promise object. Personalized feed | ||
* @example client.personalization.get('follow_recommendations', {foo: 'bar', baz: 'qux'}) | ||
@@ -41,3 +41,3 @@ */ | ||
token?: string; | ||
}): Promise<PersonalizationAPIResponse<PersonalizationType>>; | ||
}): Promise<PersonalizationAPIResponse<StreamFeedGenerics>>; | ||
/** | ||
@@ -51,6 +51,6 @@ * Post data to personalization endpoint | ||
* @param {object} data - Data to send in the payload | ||
* @return {Promise<PersonalizationAPIResponse<PersonalizationType>>} Promise object. Data that was posted if successful, or an error. | ||
* @return {Promise<PersonalizationAPIResponse<StreamFeedGenerics>>} Promise object. Data that was posted if successful, or an error. | ||
* @example client.personalization.post('follow_recommendations', {foo: 'bar', baz: 'qux'}) | ||
*/ | ||
post(resource: string, options?: Record<string, string>, data?: UR): Promise<PersonalizationAPIResponse<PersonalizationType>>; | ||
post(resource: string, options?: Record<string, string>, data?: UR): Promise<PersonalizationAPIResponse<StreamFeedGenerics>>; | ||
/** | ||
@@ -63,7 +63,7 @@ * Delete metadata or activities | ||
* @param {object} options - Additional options | ||
* @return {Promise<PersonalizationAPIResponse<PersonalizationType>>} Promise object. Data that was deleted if successful, or an error. | ||
* @return {Promise<PersonalizationAPIResponse<StreamFeedGenerics>>} Promise object. Data that was deleted if successful, or an error. | ||
* @example client.personalization.delete('follow_recommendations', {foo: 'bar', baz: 'qux'}) | ||
*/ | ||
delete(resource: string, options?: Record<string, string>): Promise<PersonalizationAPIResponse<PersonalizationType>>; | ||
delete(resource: string, options?: Record<string, string>): Promise<PersonalizationAPIResponse<StreamFeedGenerics>>; | ||
} | ||
//# sourceMappingURL=personalization.d.ts.map |
@@ -41,3 +41,3 @@ "use strict"; | ||
* @param {object} options Additional options | ||
* @return {Promise<PersonalizationAPIResponse<PersonalizationType>>} Promise object. Personalized feed | ||
* @return {Promise<PersonalizationAPIResponse<StreamFeedGenerics>>} Promise object. Personalized feed | ||
* @example client.personalization.get('follow_recommendations', {foo: 'bar', baz: 'qux'}) | ||
@@ -66,3 +66,3 @@ */ | ||
* @param {object} data - Data to send in the payload | ||
* @return {Promise<PersonalizationAPIResponse<PersonalizationType>>} Promise object. Data that was posted if successful, or an error. | ||
* @return {Promise<PersonalizationAPIResponse<StreamFeedGenerics>>} Promise object. Data that was posted if successful, or an error. | ||
* @example client.personalization.post('follow_recommendations', {foo: 'bar', baz: 'qux'}) | ||
@@ -91,3 +91,3 @@ */ | ||
* @param {object} options - Additional options | ||
* @return {Promise<PersonalizationAPIResponse<PersonalizationType>>} Promise object. Data that was deleted if successful, or an error. | ||
* @return {Promise<PersonalizationAPIResponse<StreamFeedGenerics>>} Promise object. Data that was deleted if successful, or an error. | ||
* @example client.personalization.delete('follow_recommendations', {foo: 'bar', baz: 'qux'}) | ||
@@ -94,0 +94,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
import { StreamClient, APIResponse, UR } from './client'; | ||
import { StreamClient, APIResponse, UR, DefaultGenerics } from './client'; | ||
import { StreamFeed } from './feed'; | ||
@@ -20,17 +20,17 @@ import { EnrichedUser } from './user'; | ||
export declare type ReactionAPIResponse<T extends UR = UR> = APIResponse & Reaction<T>; | ||
export declare type ChildReactionsRecords<ReactionType extends UR = UR, ChildReactionType extends UR = UR, UserType extends UR = UR> = Record<string, EnrichedReaction<ReactionType, ChildReactionType, UserType>[]>; | ||
export declare type EnrichedReaction<ReactionType extends UR = UR, ChildReactionType extends UR = UR, UserType extends UR = UR> = Reaction<ReactionType | ChildReactionType> & { | ||
export declare type ChildReactionsRecords<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = Record<string, EnrichedReaction<StreamFeedGenerics>[]>; | ||
export declare type EnrichedReaction<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = Reaction<StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType']> & { | ||
children_counts: Record<string, number>; | ||
latest_children: ChildReactionsRecords<ReactionType, ChildReactionType, UserType>; | ||
latest_children: ChildReactionsRecords<StreamFeedGenerics>; | ||
latest_children_extra?: Record<string, { | ||
next?: string; | ||
}>; | ||
own_children?: ChildReactionsRecords<ReactionType, ChildReactionType, UserType>; | ||
user?: EnrichedUser<UserType>; | ||
own_children?: ChildReactionsRecords<StreamFeedGenerics>; | ||
user?: EnrichedUser<StreamFeedGenerics>; | ||
}; | ||
export declare type EnrichedReactionAPIResponse<ReactionType extends UR = UR, ChildReactionType extends UR = UR, UserType extends UR = UR> = APIResponse & EnrichedReaction<ReactionType, ChildReactionType, UserType>; | ||
export declare type ReactionFilterAPIResponse<ReactionType extends UR = UR, ChildReactionType extends UR = UR, ActivityType extends UR = UR, UserType extends UR = UR> = APIResponse & { | ||
export declare type EnrichedReactionAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & EnrichedReaction<StreamFeedGenerics>; | ||
export declare type ReactionFilterAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
next: string; | ||
results: ReactionAPIResponse<ReactionType | ChildReactionType>[] | EnrichedReactionAPIResponse<ReactionType, ChildReactionType, UserType>[]; | ||
activity?: ActivityType; | ||
results: ReactionAPIResponse<StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType']>[] | EnrichedReactionAPIResponse<StreamFeedGenerics>[]; | ||
activity?: StreamFeedGenerics['childReactionType']; | ||
}; | ||
@@ -61,4 +61,4 @@ export declare type ReactionFilterConditions = { | ||
}; | ||
export declare class StreamReaction<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR, PersonalizationType extends UR = UR> { | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export declare class StreamReaction<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
client: StreamClient<StreamFeedGenerics>; | ||
token: string; | ||
@@ -74,3 +74,3 @@ /** | ||
*/ | ||
constructor(client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, token: string); | ||
constructor(client: StreamClient<StreamFeedGenerics>, token: string); | ||
buildURL: (...args: string[]) => string; | ||
@@ -97,3 +97,3 @@ _convertTargetFeeds: (targetFeeds?: TargetFeeds) => string[]; | ||
id: string; | ||
}, data?: ReactionType, { id, targetFeeds, userId, targetFeedsExtraData }?: ReactionAddOptions): Promise<ReactionAPIResponse<ReactionType>>; | ||
}, data?: StreamFeedGenerics['reactionType'], { id, targetFeeds, userId, targetFeedsExtraData }?: ReactionAddOptions): Promise<ReactionAPIResponse<StreamFeedGenerics["reactionType"]>>; | ||
/** | ||
@@ -117,3 +117,3 @@ * add child reaction | ||
id: string; | ||
}, data?: ChildReactionType, { targetFeeds, userId, targetFeedsExtraData }?: ReactionAddChildOptions): Promise<ReactionAPIResponse<ChildReactionType>>; | ||
}, data?: StreamFeedGenerics['childReactionType'], { targetFeeds, userId, targetFeedsExtraData }?: ReactionAddChildOptions): Promise<ReactionAPIResponse<StreamFeedGenerics["childReactionType"]>>; | ||
/** | ||
@@ -125,6 +125,6 @@ * get reaction | ||
* @param {string} id Reaction Id | ||
* @return {Promise<EnrichedReactionAPIResponse<ReactionType, ChildReactionType, UserType>>} | ||
* @return {Promise<EnrichedReactionAPIResponse<StreamFeedGenerics>>} | ||
* @example reactions.get("67b3e3b5-b201-4697-96ac-482eb14f88ec") | ||
*/ | ||
get(id: string): Promise<EnrichedReactionAPIResponse<ReactionType, ChildReactionType, UserType>>; | ||
get(id: string): Promise<EnrichedReactionAPIResponse<StreamFeedGenerics>>; | ||
/** | ||
@@ -141,7 +141,7 @@ * retrieve reactions by activity_id, user_id or reaction_id (to paginate children reactions), pagination can be done using id_lt, id_lte, id_gt and id_gte parameters | ||
* @param {ReactionFilterConditions} conditions Reaction Id {activity_id|user_id|reaction_id:string, kind:string, limit:integer} | ||
* @return {Promise<ReactionFilterAPIResponse<ReactionType, ChildReactionType, ActivityType, UserType>>} | ||
* @return {Promise<ReactionFilterAPIResponse<StreamFeedGenerics>>} | ||
* @example reactions.filter({activity_id: "0c7db91c-67f9-11e8-bcd9-fe00a9219401", kind:"like"}) | ||
* @example reactions.filter({user_id: "john", kinds:"like"}) | ||
*/ | ||
filter(conditions: ReactionFilterConditions): Promise<ReactionFilterAPIResponse<ReactionType, ChildReactionType, ActivityType, UserType>>; | ||
filter(conditions: ReactionFilterConditions): Promise<ReactionFilterAPIResponse<StreamFeedGenerics>>; | ||
/** | ||
@@ -161,3 +161,3 @@ * update reaction | ||
*/ | ||
update(id: string, data?: ReactionType | ChildReactionType, { targetFeeds, targetFeedsExtraData }?: ReactionUpdateOptions): Promise<ReactionAPIResponse<ReactionType | ChildReactionType>>; | ||
update(id: string, data?: StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType'], { targetFeeds, targetFeedsExtraData }?: ReactionUpdateOptions): Promise<ReactionAPIResponse<StreamFeedGenerics["reactionType"] | StreamFeedGenerics["childReactionType"]>>; | ||
/** | ||
@@ -164,0 +164,0 @@ * delete reaction |
@@ -20,2 +20,4 @@ "use strict"; | ||
var _excluded = ["user_id", "activity_id", "reaction_id"]; | ||
var StreamReaction = /*#__PURE__*/function () { | ||
@@ -149,3 +151,3 @@ /** | ||
* @param {string} id Reaction Id | ||
* @return {Promise<EnrichedReactionAPIResponse<ReactionType, ChildReactionType, UserType>>} | ||
* @return {Promise<EnrichedReactionAPIResponse<StreamFeedGenerics>>} | ||
* @example reactions.get("67b3e3b5-b201-4697-96ac-482eb14f88ec") | ||
@@ -173,3 +175,3 @@ */ | ||
* @param {ReactionFilterConditions} conditions Reaction Id {activity_id|user_id|reaction_id:string, kind:string, limit:integer} | ||
* @return {Promise<ReactionFilterAPIResponse<ReactionType, ChildReactionType, ActivityType, UserType>>} | ||
* @return {Promise<ReactionFilterAPIResponse<StreamFeedGenerics>>} | ||
* @example reactions.filter({activity_id: "0c7db91c-67f9-11e8-bcd9-fe00a9219401", kind:"like"}) | ||
@@ -185,3 +187,3 @@ * @example reactions.filter({user_id: "john", kinds:"like"}) | ||
reactionId = conditions.reaction_id, | ||
qs = (0, _objectWithoutProperties2.default)(conditions, ["user_id", "activity_id", "reaction_id"]); | ||
qs = (0, _objectWithoutProperties2.default)(conditions, _excluded); | ||
@@ -188,0 +190,0 @@ if (!qs.limit) { |
@@ -15,5 +15,5 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
@@ -20,0 +20,0 @@ // for a claim in jwt |
@@ -1,18 +0,18 @@ | ||
import { StreamClient, APIResponse, UR } from './client'; | ||
export declare type EnrichedUser<UserType extends UR = UR> = { | ||
import { StreamClient, APIResponse, DefaultGenerics } from './client'; | ||
export declare type EnrichedUser<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = { | ||
created_at: string; | ||
data: UserType; | ||
data: StreamFeedGenerics['userType']; | ||
id: string; | ||
updated_at: string; | ||
}; | ||
export declare type UserAPIResponse<UserType extends UR = UR> = APIResponse & EnrichedUser<UserType> & { | ||
export declare type UserAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & EnrichedUser<StreamFeedGenerics> & { | ||
followers_count?: number; | ||
following_count?: number; | ||
}; | ||
export declare class StreamUser<UserType extends UR = UR, ActivityType extends UR = UR, CollectionType extends UR = UR, ReactionType extends UR = UR, ChildReactionType extends UR = UR, PersonalizationType extends UR = UR> { | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export declare class StreamUser<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
client: StreamClient<StreamFeedGenerics>; | ||
token: string; | ||
id: string; | ||
data?: UserType; | ||
full?: UserAPIResponse<UserType>; | ||
data?: StreamFeedGenerics['userType']; | ||
full?: UserAPIResponse<StreamFeedGenerics>; | ||
private url; | ||
@@ -29,3 +29,3 @@ /** | ||
*/ | ||
constructor(client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, userId: string, userAuthToken: string); | ||
constructor(client: StreamClient<StreamFeedGenerics>, userId: string, userAuthToken: string); | ||
/** | ||
@@ -58,3 +58,3 @@ * Create a stream user ref | ||
*/ | ||
create(data?: UserType, options?: { | ||
create(data?: StreamFeedGenerics['userType'], options?: { | ||
get_or_create?: boolean; | ||
@@ -68,3 +68,3 @@ }): Promise<this>; | ||
*/ | ||
update(data?: Partial<UserType>): Promise<this>; | ||
update(data?: Partial<StreamFeedGenerics['userType']>): Promise<this>; | ||
/** | ||
@@ -76,3 +76,3 @@ * Get or Create a new user in stream | ||
*/ | ||
getOrCreate(data: UserType): Promise<this>; | ||
getOrCreate(data: StreamFeedGenerics['userType']): Promise<this>; | ||
/** | ||
@@ -79,0 +79,0 @@ * Get the user profile, it includes the follow counts by default |
@@ -20,5 +20,5 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
@@ -25,0 +25,0 @@ var StreamUser = /*#__PURE__*/function () { |
@@ -14,3 +14,3 @@ { | ||
"license": "BSD-3-Clause", | ||
"version": "7.4.1", | ||
"version": "8.0.0", | ||
"scripts": { | ||
@@ -61,34 +61,34 @@ "transpile": "babel src --out-dir lib --extensions '.ts'", | ||
"devDependencies": { | ||
"@babel/cli": "^7.13.10", | ||
"@babel/core": "^7.13.10", | ||
"@babel/node": "^7.13.10", | ||
"@babel/plugin-proposal-class-properties": "^7.13.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.13.8", | ||
"@babel/plugin-transform-object-assign": "^7.12.13", | ||
"@babel/plugin-transform-runtime": "^7.13.10", | ||
"@babel/preset-env": "^7.13.10", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@babel/register": "^7.13.8", | ||
"@typescript-eslint/eslint-plugin": "^4.17.0", | ||
"@typescript-eslint/parser": "^4.17.0", | ||
"babel-eslint": "^10.1.0", | ||
"babel-loader": "^8.2.2", | ||
"chai": "^4.3.3", | ||
"dotenv": "^8.2.0", | ||
"eslint": "^7.21.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-chai-friendly": "^0.6.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-sonarjs": "^0.7.0", | ||
"eslint-plugin-typescript-sort-keys": "^1.5.0", | ||
"@babel/cli": "^7.16.7", | ||
"@babel/core": "^7.16.7", | ||
"@babel/eslint-parser": "^7.16.5", | ||
"@babel/node": "^7.16.7", | ||
"@babel/plugin-proposal-class-properties": "^7.16.7", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.16.7", | ||
"@babel/plugin-transform-object-assign": "^7.16.7", | ||
"@babel/plugin-transform-runtime": "^7.16.7", | ||
"@babel/preset-env": "^7.16.7", | ||
"@babel/preset-typescript": "^7.16.7", | ||
"@babel/register": "^7.16.7", | ||
"@typescript-eslint/eslint-plugin": "^5.8.1", | ||
"@typescript-eslint/parser": "^5.8.1", | ||
"babel-loader": "^8.2.3", | ||
"chai": "^4.3.4", | ||
"dotenv": "^10.0.0", | ||
"eslint": "^8.6.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-chai-friendly": "^0.7.2", | ||
"eslint-plugin-import": "^2.25.4", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-sonarjs": "^0.11.0", | ||
"eslint-plugin-typescript-sort-keys": "^2.1.0", | ||
"expect.js": "^0.3.1", | ||
"husky": "^4.3.8", | ||
"json-loader": "~0.5.7", | ||
"karma": "^6.1.2", | ||
"karma": "^6.3.9", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-mocha": "^2.0.1", | ||
"karma-mocha-reporter": "~2.2.5", | ||
"karma-sauce-launcher": "^4.3.5", | ||
"karma-sauce-launcher": "^4.3.6", | ||
"karma-sourcemap-loader": "~0.3.8", | ||
@@ -99,14 +99,14 @@ "karma-webpack": "^5.0.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.2.1", | ||
"prettier": "^2.5.1", | ||
"request": "^2.88.2", | ||
"testdouble": "^3.16.1", | ||
"typescript": "^4.2.3", | ||
"webpack": "^5.24.4", | ||
"webpack-cli": "^4.5.0" | ||
"testdouble": "^3.16.4", | ||
"typescript": "^4.5.4", | ||
"webpack": "^5.65.0", | ||
"webpack-cli": "^4.9.1" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.13.10", | ||
"@types/jsonwebtoken": "^8.5.0", | ||
"@babel/runtime": "^7.16.7", | ||
"@types/jsonwebtoken": "^8.5.6", | ||
"@types/jwt-decode": "^2.2.1", | ||
"@types/qs": "^6.9.6", | ||
"@types/qs": "^6.9.7", | ||
"axios": "^0.22.0", | ||
@@ -117,3 +117,3 @@ "faye": "^1.4.0", | ||
"jwt-decode": "^3.1.2", | ||
"qs": "^6.9.6" | ||
"qs": "^6.10.2" | ||
}, | ||
@@ -120,0 +120,0 @@ "peerDependencies": { |
@@ -270,3 +270,3 @@ # Stream-JS | ||
```ts | ||
import { connect, EnrichedActivity, NotificationActivity } from getstream; | ||
import { connect, UR, EnrichedActivity, NotificationActivity } from getstream; | ||
@@ -282,10 +282,13 @@ type User1Type = { name: string; username: string; image?: string }; | ||
const client = connect< | ||
User1Type | User2Type, | ||
ActivityType, | ||
Collection1Type | Collection2Type, | ||
ReactionType, | ||
ChildReactionType | ||
>('api_key', 'secret!', 'app_id'); | ||
type StreamType = { | ||
userType: User1Type | User2Type, | ||
activityType: ActivityType, | ||
collectionType: Collection1Type | Collection2Type, | ||
reactionType: ReactionType, | ||
childReactionType: ChildReactionType, | ||
personalizationType: UR, | ||
} | ||
const client = connect<StreamType>('api_key', 'secret!', 'app_id'); | ||
// if you have different union types like "User1Type | User2Type" you can use type guards as follow: | ||
@@ -306,9 +309,9 @@ // https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types | ||
// notification: StreamFeed<User1Type | User2Type, ActivityType, Collection1Type | Collection2Type, ReactionType, ChildReactionType> | ||
// notification: StreamFeed<StreamType> | ||
const timeline = client.feed('timeline', 'feed_id'); | ||
timeline.get({ withOwnChildren: true, withOwnReactions: true }).then((response) => { | ||
// response: FeedAPIResponse<User1Type | User2Type, ActivityType, Collection1Type | Collection2Type, ReactionType, ChildReactionType> | ||
// response: FeedAPIResponse<StreamType> | ||
if (response.next !== '') return response.next; | ||
return (response.results as EnrichedActivity<User2Type, ActivityType>[]).map((activity) => { | ||
return (response.results as EnrichedActivity<StreamType>[]).map((activity) => { | ||
return activity.id + activity.text + (activity.actor as User2Type).name; | ||
@@ -318,6 +321,6 @@ }); | ||
// notification: StreamFeed<User1Type | User2Type, ActivityType, Collection1Type | Collection2Type, ReactionType, ChildReactionType> | ||
// notification: StreamFeed<StreamType> | ||
const notification = client.feed('notification', 'feed_id'); | ||
notification.get({ mark_read: true, mark_seen: true }).then((response) => { | ||
// response: FeedAPIResponse<User1Type | User2Type, ActivityType, Collection1Type | Collection2Type, ReactionType, ChildReactionType> | ||
// response: FeedAPIResponse<StreamType> | ||
if (response.unread || response.unseen) return response.next; | ||
@@ -331,3 +334,3 @@ | ||
client.collections.get('collection_1', 'taco').then((item: CollectionEntry<Collection1Type>) => { | ||
client.collections.get('collection_1', 'taco').then((item: CollectionEntry<StreamType>) => { | ||
if (item.data.rating) return { [item.data.cid]: item.data.rating }; | ||
@@ -334,0 +337,0 @@ return item.id; |
@@ -1,2 +0,2 @@ | ||
import { StreamClient, APIResponse } from './client'; | ||
import { StreamClient, APIResponse, DefaultGenerics } from './client'; | ||
import utils from './utils'; | ||
@@ -27,3 +27,7 @@ | ||
*/ | ||
function addToMany<ActivityType>(this: StreamClient, activity: ActivityType, feeds: string[]) { | ||
function addToMany<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics>( | ||
this: StreamClient, | ||
activity: StreamFeedGenerics['activityType'], | ||
feeds: string[], | ||
) { | ||
this._throwMissingApiSecret(); | ||
@@ -30,0 +34,0 @@ |
@@ -38,2 +38,11 @@ /// <reference path="../types/modules.d.ts" /> | ||
export type DefaultGenerics = { | ||
activityType: UR; | ||
childReactionType: UR; | ||
collectionType: UR; | ||
personalizationType: UR; | ||
reactionType: UR; | ||
userType: UR; | ||
}; | ||
export type APIResponse = { duration?: string }; | ||
@@ -111,14 +120,10 @@ | ||
export type ActivityPartialChanges<ActivityType extends UR = UR> = Partial<ForeignIDTimes> & { | ||
id?: string; | ||
set?: Partial<ActivityType>; | ||
unset?: Array<Extract<keyof ActivityType, string>>; | ||
}; | ||
export type ActivityPartialChanges<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
Partial<ForeignIDTimes> & { | ||
id?: string; | ||
set?: Partial<StreamFeedGenerics['activityType']>; | ||
unset?: Array<Extract<keyof StreamFeedGenerics['activityType'], string>>; | ||
}; | ||
export type RealTimeMessage< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR | ||
> = { | ||
export type RealTimeMessage<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = { | ||
deleted: Array<string>; | ||
@@ -128,3 +133,3 @@ deleted_foreign_ids: Array<[id: string, time: string]>; | ||
Omit< | ||
EnrichedActivity<UserType, ActivityType, CollectionType, ReactionType>, | ||
EnrichedActivity<StreamFeedGenerics>, | ||
'latest_reactions' | 'latest_reactions_extra' | 'own_reactions' | 'own_reactions_extra' | 'reaction_counts' | ||
@@ -144,10 +149,3 @@ > & { group?: string } | ||
*/ | ||
export class StreamClient< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
PersonalizationType extends UR = UR | ||
> { | ||
export class StreamClient<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
baseUrl: string; | ||
@@ -169,3 +167,3 @@ baseAnalyticsUrl: string; | ||
location: string; | ||
fayeClient: Faye.Client<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>> | null; | ||
fayeClient: Faye.Client<RealTimeMessage<StreamFeedGenerics>> | null; | ||
browser: boolean; | ||
@@ -182,29 +180,8 @@ node: boolean; | ||
currentUser?: StreamUser< | ||
UserType, | ||
ActivityType, | ||
CollectionType, | ||
ReactionType, | ||
ChildReactionType, | ||
PersonalizationType | ||
>; | ||
personalization: Personalization< | ||
UserType, | ||
ActivityType, | ||
CollectionType, | ||
ReactionType, | ||
ChildReactionType, | ||
PersonalizationType | ||
>; | ||
collections: Collections< | ||
UserType, | ||
ActivityType, | ||
CollectionType, | ||
ReactionType, | ||
ChildReactionType, | ||
PersonalizationType | ||
>; | ||
currentUser?: StreamUser<StreamFeedGenerics>; | ||
personalization: Personalization<StreamFeedGenerics>; | ||
collections: Collections<StreamFeedGenerics>; | ||
files: StreamFileStore; | ||
images: StreamImageStore; | ||
reactions: StreamReaction<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>; | ||
reactions: StreamReaction<StreamFeedGenerics>; | ||
@@ -215,7 +192,10 @@ private _personalizationToken?: string; | ||
// eslint-disable-next-line no-shadow | ||
addToMany?: <ActivityType>(this: StreamClient, activity: ActivityType, feeds: string[]) => Promise<APIResponse>; | ||
followMany?: (this: StreamClient, follows: FollowRelation[], activityCopyLimit?: number) => Promise<APIResponse>; | ||
unfollowMany?: (this: StreamClient, unfollows: UnfollowRelation[]) => Promise<APIResponse>; | ||
createRedirectUrl?: (this: StreamClient, targetUrl: string, userId: string, events: unknown[]) => string; | ||
addToMany?: <StreamFeedGenerics extends DefaultGenerics = DefaultGenerics>( // eslint-disable-line no-shadow | ||
this: StreamClient, // eslint-disable-line no-use-before-define | ||
activity: StreamFeedGenerics['activityType'], | ||
feeds: string[], | ||
) => Promise<APIResponse>; // eslint-disable-line no-use-before-define | ||
followMany?: (this: StreamClient, follows: FollowRelation[], activityCopyLimit?: number) => Promise<APIResponse>; // eslint-disable-line no-use-before-define | ||
unfollowMany?: (this: StreamClient, unfollows: UnfollowRelation[]) => Promise<APIResponse>; // eslint-disable-line no-use-before-define | ||
createRedirectUrl?: (this: StreamClient, targetUrl: string, userId: string, events: unknown[]) => string; // eslint-disable-line no-use-before-define | ||
@@ -295,10 +275,3 @@ /** | ||
this.personalization = new Personalization< | ||
UserType, | ||
ActivityType, | ||
CollectionType, | ||
ReactionType, | ||
ChildReactionType, | ||
PersonalizationType | ||
>(this); | ||
this.personalization = new Personalization<StreamFeedGenerics>(this); | ||
@@ -310,20 +283,6 @@ if (this.browser && this.usingApiSecret) { | ||
} | ||
this.collections = new Collections< | ||
UserType, | ||
ActivityType, | ||
CollectionType, | ||
ReactionType, | ||
ChildReactionType, | ||
PersonalizationType | ||
>(this, this.getOrCreateToken()); | ||
this.collections = new Collections<StreamFeedGenerics>(this, this.getOrCreateToken()); | ||
this.files = new StreamFileStore(this as StreamClient, this.getOrCreateToken()); | ||
this.images = new StreamImageStore(this as StreamClient, this.getOrCreateToken()); | ||
this.reactions = new StreamReaction< | ||
UserType, | ||
ActivityType, | ||
CollectionType, | ||
ReactionType, | ||
ChildReactionType, | ||
PersonalizationType | ||
>(this, this.getOrCreateToken()); | ||
this.reactions = new StreamReaction<StreamFeedGenerics>(this, this.getOrCreateToken()); | ||
@@ -508,7 +467,5 @@ // If we are in a node environment and batchOperations/createRedirectUrl is available add the methods to the prototype of StreamClient | ||
feedSlug: string, | ||
userId?: | ||
| string | ||
| StreamUser<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, | ||
userId?: string | StreamUser<StreamFeedGenerics>, | ||
token?: string, | ||
): StreamFeed<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType> { | ||
): StreamFeed<StreamFeedGenerics> { | ||
if (userId instanceof StreamUser) userId = userId.id; | ||
@@ -524,8 +481,3 @@ | ||
return new StreamFeed<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>( | ||
this, | ||
feedSlug, | ||
userId || (this.userId as string), | ||
token, | ||
); | ||
return new StreamFeed<StreamFeedGenerics>(this, feedSlug, userId || (this.userId as string), token); | ||
} | ||
@@ -633,8 +585,8 @@ | ||
incoming: ( | ||
message: Faye.Message<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>, | ||
callback: Faye.Callback<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>, | ||
message: Faye.Message<RealTimeMessage<StreamFeedGenerics>>, | ||
callback: Faye.Callback<RealTimeMessage<StreamFeedGenerics>>, | ||
) => callback(message), | ||
outgoing: ( | ||
message: Faye.Message<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>, | ||
callback: Faye.Callback<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>, | ||
message: Faye.Message<RealTimeMessage<StreamFeedGenerics>>, | ||
callback: Faye.Callback<RealTimeMessage<StreamFeedGenerics>>, | ||
) => { | ||
@@ -666,6 +618,3 @@ if (message.subscription && this.subscriptions[message.subscription]) { | ||
if (this.fayeClient === null) { | ||
this.fayeClient = new Faye.Client<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>( | ||
this.fayeUrl, | ||
{ timeout }, | ||
); | ||
this.fayeClient = new Faye.Client<RealTimeMessage<StreamFeedGenerics>>(this.fayeUrl, { timeout }); | ||
const authExtension = this.getFayeAuthorization(); | ||
@@ -698,4 +647,5 @@ this.fayeClient.addExtension(authExtension); | ||
} catch (error) { | ||
if (error.response) return this.handleResponse(error.response); | ||
throw new SiteError(error.message); | ||
const err = error as StreamApiError<T>; | ||
if (err.response) return this.handleResponse(err.response); | ||
throw new SiteError(err.message); | ||
} | ||
@@ -792,6 +742,6 @@ }; | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js#updating-activities | ||
* @param {UpdateActivity<ActivityType>[]} activities list of activities to update | ||
* @param {UpdateActivity<StreamFeedGenerics>[]} activities list of activities to update | ||
* @return {Promise<APIResponse>} | ||
*/ | ||
updateActivities(activities: UpdateActivity<ActivityType>[]) { | ||
updateActivities(activities: UpdateActivity<StreamFeedGenerics>[]) { | ||
this._throwMissingApiSecret(); | ||
@@ -818,6 +768,6 @@ | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js#updating-activities | ||
* @param {UpdateActivity<ActivityType>} activity The activity to update | ||
* @param {UpdateActivity<StreamFeedGenerics>} activity The activity to update | ||
* @return {Promise<APIResponse>} | ||
*/ | ||
updateActivity(activity: UpdateActivity<ActivityType>) { | ||
updateActivity(activity: UpdateActivity<StreamFeedGenerics>) { | ||
this._throwMissingApiSecret(); | ||
@@ -881,3 +831,3 @@ | ||
return this.get<GetActivitiesAPIResponse<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>>({ | ||
return this.get<GetActivitiesAPIResponse<StreamFeedGenerics>>({ | ||
url: path, | ||
@@ -899,10 +849,6 @@ qs: { ...params, ...extraParams }, | ||
user(userId: string) { | ||
return new StreamUser<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>( | ||
this, | ||
userId, | ||
this.getOrCreateToken(), | ||
); | ||
return new StreamUser<StreamFeedGenerics>(this, userId, this.getOrCreateToken()); | ||
} | ||
async setUser(data: UserType) { | ||
async setUser(data: StreamFeedGenerics['userType']) { | ||
if (this.usingApiSecret) { | ||
@@ -915,10 +861,3 @@ throw new SiteError('This method can only be used client-side using a user token'); | ||
const user = await (this.currentUser as StreamUser< | ||
UserType, | ||
ActivityType, | ||
CollectionType, | ||
ReactionType, | ||
ChildReactionType, | ||
PersonalizationType | ||
>).getOrCreate(body); | ||
const user = await (this.currentUser as StreamUser<StreamFeedGenerics>).getOrCreate(body); | ||
this.currentUser = user; | ||
@@ -937,5 +876,3 @@ return user; | ||
personalizedFeed(options: GetFeedOptions = {}) { | ||
return this.get< | ||
PersonalizationFeedAPIResponse<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType> | ||
>({ | ||
return this.get<PersonalizationFeedAPIResponse<StreamFeedGenerics>>({ | ||
url: 'enrich/personalization/feed/', | ||
@@ -950,4 +887,4 @@ qs: options, | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js&q=partial+#activity-partial-update | ||
* @param {ActivityPartialChanges<ActivityType>} data object containing either the ID or the foreign_id and time of the activity and the operations to issue as set:{...} and unset:[...]. | ||
* @return {Promise<Activity<ActivityType>>} | ||
* @param {ActivityPartialChanges<StreamFeedGenerics>} data object containing either the ID or the foreign_id and time of the activity and the operations to issue as set:{...} and unset:[...]. | ||
* @return {Promise<Activity<StreamFeedGenerics>>} | ||
* @example | ||
@@ -981,4 +918,4 @@ * client.activityPartialUpdate({ | ||
async activityPartialUpdate( | ||
data: ActivityPartialChanges<ActivityType>, | ||
): Promise<APIResponse & Activity<ActivityType>> { | ||
data: ActivityPartialChanges<StreamFeedGenerics>, | ||
): Promise<APIResponse & Activity<StreamFeedGenerics>> { | ||
const { activities, ...response } = await this.activitiesPartialUpdate([data]); | ||
@@ -992,4 +929,4 @@ const [activity] = activities; | ||
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js&q=partial+#activity-partial-update | ||
* @param {ActivityPartialChanges<ActivityType>[]} changes array containing the changesets to be applied. Every changeset contains the activity identifier which is either the ID or the pair of of foreign ID and time of the activity. The operations to issue can be set:{...} and unset:[...]. | ||
* @return {Promise<{ activities: Activity<ActivityType>[] }>} | ||
* @param {ActivityPartialChanges<StreamFeedGenerics>[]} changes array containing the changesets to be applied. Every changeset contains the activity identifier which is either the ID or the pair of of foreign ID and time of the activity. The operations to issue can be set:{...} and unset:[...]. | ||
* @return {Promise<{ activities: Activity<StreamFeedGenerics>[] }>} | ||
* @example | ||
@@ -1044,23 +981,25 @@ * client.activitiesPartialUpdate([ | ||
*/ | ||
activitiesPartialUpdate(changes: ActivityPartialChanges<ActivityType>[]) { | ||
activitiesPartialUpdate(changes: ActivityPartialChanges<StreamFeedGenerics>[]) { | ||
if (!(changes instanceof Array)) { | ||
throw new TypeError('changes should be an Array'); | ||
} | ||
changes.forEach((item: ActivityPartialChanges<ActivityType> & { foreign_id?: string; foreignID?: string }) => { | ||
if (!(item instanceof Object)) { | ||
throw new TypeError(`changeset should be and Object`); | ||
} | ||
if (item.foreignID) { | ||
item.foreign_id = item.foreignID; | ||
} | ||
if (item.id === undefined && (item.foreign_id === undefined || item.time === undefined)) { | ||
throw new TypeError('missing id or foreign_id and time'); | ||
} | ||
if (item.set && !(item.set instanceof Object)) { | ||
throw new TypeError('set field should be an Object'); | ||
} | ||
if (item.unset && !(item.unset instanceof Array)) { | ||
throw new TypeError('unset field should be an Array'); | ||
} | ||
}); | ||
changes.forEach( | ||
(item: ActivityPartialChanges<StreamFeedGenerics> & { foreign_id?: string; foreignID?: string }) => { | ||
if (!(item instanceof Object)) { | ||
throw new TypeError(`changeset should be and Object`); | ||
} | ||
if (item.foreignID) { | ||
item.foreign_id = item.foreignID; | ||
} | ||
if (item.id === undefined && (item.foreign_id === undefined || item.time === undefined)) { | ||
throw new TypeError('missing id or foreign_id and time'); | ||
} | ||
if (item.set && !(item.set instanceof Object)) { | ||
throw new TypeError('set field should be an Object'); | ||
} | ||
if (item.unset && !(item.unset instanceof Array)) { | ||
throw new TypeError('unset field should be an Array'); | ||
} | ||
}, | ||
); | ||
@@ -1075,3 +1014,3 @@ let token = this.userToken as string; | ||
return this.post<APIResponse & { activities: Activity<ActivityType>[] }>({ | ||
return this.post<APIResponse & { activities: Activity<StreamFeedGenerics>[] }>({ | ||
url: 'activity/', | ||
@@ -1078,0 +1017,0 @@ body: { changes }, |
@@ -1,55 +0,52 @@ | ||
import { StreamClient, APIResponse, UR } from './client'; | ||
import { StreamClient, APIResponse, DefaultGenerics } from './client'; | ||
import { SiteError } from './errors'; | ||
type BaseCollection<CollectionType> = { | ||
type BaseCollection<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = { | ||
collection: string; | ||
data: CollectionType; | ||
data: StreamFeedGenerics['collectionType']; | ||
id: string; | ||
}; | ||
export type CollectionItem<CollectionType extends UR = UR> = CollectionType & { | ||
id: string; | ||
user_id?: string; | ||
}; | ||
export type CollectionItem<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
StreamFeedGenerics['collectionType'] & { | ||
id: string; | ||
user_id?: string; | ||
}; | ||
export type CollectionResponse<CollectionType extends UR = UR> = BaseCollection<CollectionType> & { | ||
created_at: string; | ||
foreign_id: string; | ||
updated_at: string; | ||
}; | ||
export type CollectionResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
BaseCollection<StreamFeedGenerics> & { | ||
created_at: string; | ||
foreign_id: string; | ||
updated_at: string; | ||
}; | ||
export type NewCollectionEntry<CollectionType extends UR = UR> = BaseCollection<CollectionType> & { | ||
user_id?: string; | ||
}; | ||
export type NewCollectionEntry<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
BaseCollection<StreamFeedGenerics> & { | ||
user_id?: string; | ||
}; | ||
export type CollectionAPIResponse<CollectionType extends UR = UR> = APIResponse & CollectionResponse<CollectionType>; | ||
export type CollectionAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & | ||
CollectionResponse<StreamFeedGenerics>; | ||
export type SelectCollectionAPIResponse<CollectionType extends UR = UR> = APIResponse & { | ||
export type SelectCollectionAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
response: { | ||
data: CollectionResponse<CollectionType>[]; | ||
data: CollectionResponse<StreamFeedGenerics>[]; | ||
}; | ||
}; | ||
export type UpsertCollectionAPIResponse<CollectionType extends UR = UR> = APIResponse & { | ||
export type UpsertCollectionAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
data: { | ||
[key: string]: CollectionItem<CollectionType>[]; | ||
[key: string]: CollectionItem<StreamFeedGenerics>[]; | ||
}; | ||
}; | ||
export type UpsertManyCollectionRequest<CollectionType extends UR = UR> = { | ||
[collection: string]: CollectionItem<CollectionType>[]; | ||
export type UpsertManyCollectionRequest<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = { | ||
[collection: string]: CollectionItem<StreamFeedGenerics>[]; | ||
}; | ||
export class CollectionEntry< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
PersonalizationType extends UR = UR | ||
> { | ||
export class CollectionEntry<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
id: string; | ||
collection: string; | ||
store: Collections<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; // eslint-disable-line no-use-before-define | ||
data: CollectionType | null; | ||
store: Collections<StreamFeedGenerics>; // eslint-disable-line no-use-before-define | ||
data: StreamFeedGenerics['collectionType'] | null; | ||
full?: unknown; | ||
@@ -59,6 +56,6 @@ | ||
// eslint-disable-next-line no-use-before-define | ||
store: Collections<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, | ||
store: Collections<StreamFeedGenerics>, | ||
collection: string, | ||
id: string, | ||
data: CollectionType, | ||
data: StreamFeedGenerics['collectionType'], | ||
) { | ||
@@ -79,3 +76,3 @@ this.collection = collection; | ||
* @memberof CollectionEntry.prototype | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.get("0c7db91c-67f9-11e8-bcd9-fe00a9219401") | ||
@@ -95,7 +92,7 @@ */ | ||
* @memberof CollectionEntry.prototype | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.add("cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
*/ | ||
async add() { | ||
const response = await this.store.add(this.collection, this.id, this.data as CollectionType); | ||
const response = await this.store.add(this.collection, this.id, this.data as StreamFeedGenerics['collectionType']); | ||
this.data = response.data; | ||
@@ -111,3 +108,3 @@ this.full = response; | ||
* @memberof CollectionEntry.prototype | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example store.update("0c7db91c-67f9-11e8-bcd9-fe00a9219401", {"name": "cheese burger","toppings": "cheese"}) | ||
@@ -117,3 +114,7 @@ * @example store.update("cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
async update() { | ||
const response = await this.store.update(this.collection, this.id, this.data as CollectionType); | ||
const response = await this.store.update( | ||
this.collection, | ||
this.id, | ||
this.data as StreamFeedGenerics['collectionType'], | ||
); | ||
this.data = response.data; | ||
@@ -140,11 +141,4 @@ this.full = response; | ||
export class Collections< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
PersonalizationType extends UR = UR | ||
> { | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export class Collections<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
client: StreamClient<StreamFeedGenerics>; | ||
token: string; | ||
@@ -159,6 +153,3 @@ | ||
*/ | ||
constructor( | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, | ||
token: string, | ||
) { | ||
constructor(client: StreamClient<StreamFeedGenerics>, token: string) { | ||
this.client = client; | ||
@@ -173,11 +164,4 @@ this.token = token; | ||
entry(collection: string, itemId: string, itemData: CollectionType) { | ||
return new CollectionEntry< | ||
UserType, | ||
ActivityType, | ||
CollectionType, | ||
ReactionType, | ||
ChildReactionType, | ||
PersonalizationType | ||
>(this, collection, itemId, itemData); | ||
entry(collection: string, itemId: string, itemData: StreamFeedGenerics['collectionType']) { | ||
return new CollectionEntry<StreamFeedGenerics>(this, collection, itemId, itemData); | ||
} | ||
@@ -192,7 +176,7 @@ | ||
* @param {string} itemId id for this entry | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.get("food", "0c7db91c-67f9-11e8-bcd9-fe00a9219401") | ||
*/ | ||
async get(collection: string, itemId: string) { | ||
const response = await this.client.get<CollectionAPIResponse<CollectionType>>({ | ||
const response = await this.client.get<CollectionAPIResponse<StreamFeedGenerics>>({ | ||
url: this.buildURL(collection, itemId), | ||
@@ -215,7 +199,7 @@ token: this.token, | ||
* @param {CollectionType} itemData ObjectStore data | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example collection.add("food", "cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
*/ | ||
async add(collection: string, itemId: string | null, itemData: CollectionType) { | ||
const response = await this.client.post<CollectionAPIResponse<CollectionType>>({ | ||
async add(collection: string, itemId: string | null, itemData: StreamFeedGenerics['collectionType']) { | ||
const response = await this.client.post<CollectionAPIResponse<StreamFeedGenerics>>({ | ||
url: this.buildURL(collection), | ||
@@ -242,8 +226,8 @@ body: { | ||
* @param {CollectionType} data ObjectStore data | ||
* @return {Promise<CollectionEntry<CollectionType>>} | ||
* @return {Promise<CollectionEntry<StreamFeedGenerics>>} | ||
* @example store.update("0c7db91c-67f9-11e8-bcd9-fe00a9219401", {"name": "cheese burger","toppings": "cheese"}) | ||
* @example store.update("food", "cheese101", {"name": "cheese burger","toppings": "cheese"}) | ||
*/ | ||
async update(collection: string, entryId: string, data: CollectionType) { | ||
const response = await this.client.put<CollectionAPIResponse<CollectionType>>({ | ||
async update(collection: string, entryId: string, data: StreamFeedGenerics['collectionType']) { | ||
const response = await this.client.put<CollectionAPIResponse<StreamFeedGenerics>>({ | ||
url: this.buildURL(collection, entryId), | ||
@@ -282,6 +266,6 @@ body: { data }, | ||
* @param {string} collection collection name | ||
* @param {NewCollectionEntry<CollectionType> | NewCollectionEntry<CollectionType>[]} data - A single json object or an array of objects | ||
* @return {Promise<UpsertCollectionAPIResponse<CollectionType>>} | ||
* @param {NewCollectionEntry<StreamFeedGenerics> | NewCollectionEntry<StreamFeedGenerics>[]} data - A single json object or an array of objects | ||
* @return {Promise<UpsertCollectionAPIResponse<StreamFeedGenerics>>} | ||
*/ | ||
upsert(collection: string, data: CollectionItem<CollectionType> | CollectionItem<CollectionType>[]) { | ||
upsert(collection: string, data: CollectionItem<StreamFeedGenerics> | CollectionItem<StreamFeedGenerics>[]) { | ||
if (!this.client.usingApiSecret) { | ||
@@ -293,3 +277,3 @@ throw new SiteError('This method can only be used server-side using your API Secret'); | ||
return this.client.post<UpsertCollectionAPIResponse<CollectionType>>({ | ||
return this.client.post<UpsertCollectionAPIResponse<StreamFeedGenerics>>({ | ||
url: 'collections/', | ||
@@ -309,3 +293,3 @@ serviceName: 'api', | ||
* @param {UpsertManyCollectionRequest} items - A single json object that contains information of many collections | ||
* @return {Promise<UpsertCollectionAPIResponse<CollectionType>>} | ||
* @return {Promise<UpsertCollectionAPIResponse<StreamFeedGenerics>>} | ||
*/ | ||
@@ -317,3 +301,3 @@ upsertMany(items: UpsertManyCollectionRequest) { | ||
return this.client.post<UpsertCollectionAPIResponse<CollectionType>>({ | ||
return this.client.post<UpsertCollectionAPIResponse<StreamFeedGenerics>>({ | ||
url: 'collections/', | ||
@@ -333,3 +317,3 @@ serviceName: 'api', | ||
* @param {string | string[]} ids - A single object id or an array of ids | ||
* @return {Promise<SelectCollectionAPIResponse<CollectionType>>} | ||
* @return {Promise<SelectCollectionAPIResponse<StreamFeedGenerics>>} | ||
*/ | ||
@@ -343,3 +327,3 @@ select(collection: string, ids: string | string[]) { | ||
return this.client.get<SelectCollectionAPIResponse<CollectionType>>({ | ||
return this.client.get<SelectCollectionAPIResponse<StreamFeedGenerics>>({ | ||
url: 'collections/', | ||
@@ -346,0 +330,0 @@ serviceName: 'api', |
@@ -1,2 +0,2 @@ | ||
import { StreamClient, UR, ClientOptions } from './client'; | ||
import { StreamClient, ClientOptions, DefaultGenerics } from './client'; | ||
@@ -26,10 +26,8 @@ /** | ||
*/ | ||
export function connect< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
PersonalizationType extends UR = UR | ||
>(apiKey: string, apiSecret: string | null, appId?: string, options?: ClientOptions) { | ||
export function connect<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics>( | ||
apiKey: string, | ||
apiSecret: string | null, | ||
appId?: string, | ||
options?: ClientOptions, | ||
) { | ||
if (typeof process !== 'undefined' && process.env?.STREAM_URL && !apiKey) { | ||
@@ -50,8 +48,3 @@ const parts = /https:\/\/(\w+):(\w+)@([\w-]*).*\?app_id=(\d+)/.exec(process.env.STREAM_URL) || []; | ||
return new StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>( | ||
apiKey, | ||
apiSecret, | ||
appId, | ||
options, | ||
); | ||
return new StreamClient<StreamFeedGenerics>(apiKey, apiSecret, appId, options); | ||
} |
255
src/feed.ts
/// <reference path="../types/modules.d.ts" /> | ||
import * as Faye from 'faye'; | ||
import { StreamClient, APIResponse, UR, RealTimeMessage } from './client'; | ||
import { StreamClient, APIResponse, UR, RealTimeMessage, DefaultGenerics } from './client'; | ||
import { StreamUser, EnrichedUser } from './user'; | ||
@@ -79,74 +79,66 @@ import { FeedError, SiteError } from './errors'; | ||
export type NewActivity<ActivityType extends UR = UR> = ActivityType & | ||
BaseActivity & { | ||
actor: string | StreamUser; | ||
object: string | unknown; | ||
foreign_id?: string; | ||
time?: string; | ||
}; | ||
export type NewActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
StreamFeedGenerics['activityType'] & | ||
BaseActivity & { | ||
actor: string | StreamUser; | ||
object: string | unknown; | ||
foreign_id?: string; | ||
time?: string; | ||
}; | ||
export type UpdateActivity<ActivityType extends UR = UR> = ActivityType & | ||
BaseActivity & { | ||
actor: string; | ||
foreign_id: string; | ||
object: string | unknown; | ||
time: string; | ||
}; | ||
export type UpdateActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
StreamFeedGenerics['activityType'] & | ||
BaseActivity & { | ||
actor: string; | ||
foreign_id: string; | ||
object: string | unknown; | ||
time: string; | ||
}; | ||
export type Activity<ActivityType extends UR = UR> = ActivityType & | ||
BaseActivity & { | ||
actor: string; | ||
foreign_id: string; | ||
id: string; | ||
object: string | unknown; | ||
time: string; | ||
analytics?: Record<string, number>; // ranked feeds only | ||
extra_context?: UR; | ||
origin?: string; | ||
score?: number; // ranked feeds only | ||
// ** Add new fields to EnrichedActivity as well ** | ||
}; | ||
export type Activity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
StreamFeedGenerics['activityType'] & | ||
BaseActivity & { | ||
actor: string; | ||
foreign_id: string; | ||
id: string; | ||
object: string | unknown; | ||
time: string; | ||
analytics?: Record<string, number>; // ranked feeds only | ||
extra_context?: UR; | ||
origin?: string; | ||
score?: number; // ranked feeds only | ||
// ** Add new fields to EnrichedActivity as well ** | ||
}; | ||
export type ReactionsRecords< | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
UserType extends UR = UR | ||
> = Record<string, EnrichedReaction<ReactionType, ChildReactionType, UserType>[]>; | ||
export type ReactionsRecords<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = Record< | ||
string, | ||
EnrichedReaction<StreamFeedGenerics>[] | ||
>; | ||
export type EnrichedActivity< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR | ||
> = ActivityType & | ||
BaseActivity & | ||
Pick<Activity, 'foreign_id' | 'id' | 'time' | 'analytics' | 'extra_context' | 'origin' | 'score'> & { | ||
actor: EnrichedUser<UserType> | string; | ||
// Object should be casted based on the verb | ||
object: | ||
| string | ||
| unknown | ||
| EnrichedActivity<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType> | ||
| EnrichedReaction<ReactionType, ChildReactionType, UserType> | ||
| CollectionResponse<CollectionType>; | ||
latest_reactions?: ReactionsRecords<ReactionType, ChildReactionType, UserType>; | ||
latest_reactions_extra?: Record<string, { next?: string }>; | ||
own_reactions?: ReactionsRecords<ReactionType, ChildReactionType, UserType>; | ||
own_reactions_extra?: Record<string, { next?: string }>; | ||
// Reaction posted to feed | ||
reaction?: EnrichedReaction<ReactionType, ChildReactionType, UserType>; | ||
// enriched reactions | ||
reaction_counts?: Record<string, number>; | ||
}; | ||
export type EnrichedActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
StreamFeedGenerics['activityType'] & | ||
BaseActivity & | ||
Pick<Activity, 'foreign_id' | 'id' | 'time' | 'analytics' | 'extra_context' | 'origin' | 'score'> & { | ||
actor: EnrichedUser<StreamFeedGenerics> | string; | ||
// Object should be casted based on the verb | ||
object: | ||
| string | ||
| unknown | ||
| EnrichedActivity<StreamFeedGenerics> | ||
| EnrichedReaction<StreamFeedGenerics> | ||
| CollectionResponse<StreamFeedGenerics>; | ||
latest_reactions?: ReactionsRecords<StreamFeedGenerics>; | ||
latest_reactions_extra?: Record<string, { next?: string }>; | ||
own_reactions?: ReactionsRecords<StreamFeedGenerics>; | ||
own_reactions_extra?: Record<string, { next?: string }>; | ||
// Reaction posted to feed | ||
reaction?: EnrichedReaction<StreamFeedGenerics>; | ||
// enriched reactions | ||
reaction_counts?: Record<string, number>; | ||
}; | ||
export type FlatActivity<ActivityType extends UR = UR> = Activity<ActivityType>; | ||
export type FlatActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = Activity<StreamFeedGenerics>; | ||
export type FlatActivityEnriched< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR | ||
> = EnrichedActivity<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>; | ||
export type FlatActivityEnriched<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
EnrichedActivity<StreamFeedGenerics>; | ||
@@ -164,45 +156,29 @@ type BaseAggregatedActivity = { | ||
export type AggregatedActivity<ActivityType extends UR = UR> = BaseAggregatedActivity & { | ||
activities: Activity<ActivityType>[]; | ||
}; | ||
export type AggregatedActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
BaseAggregatedActivity & { | ||
activities: Activity<StreamFeedGenerics>[]; | ||
}; | ||
export type AggregatedActivityEnriched< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR | ||
> = BaseAggregatedActivity & { | ||
activities: EnrichedActivity<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[]; | ||
}; | ||
export type AggregatedActivityEnriched<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
BaseAggregatedActivity & { | ||
activities: EnrichedActivity<StreamFeedGenerics>[]; | ||
}; | ||
type BaseNotificationActivity = { is_read: boolean; is_seen: boolean }; | ||
export type NotificationActivity<ActivityType extends UR = UR> = AggregatedActivity<ActivityType> & | ||
BaseNotificationActivity; | ||
export type NotificationActivity<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
AggregatedActivity<StreamFeedGenerics> & BaseNotificationActivity; | ||
export type NotificationActivityEnriched< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR | ||
> = BaseNotificationActivity & | ||
AggregatedActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>; | ||
export type NotificationActivityEnriched<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
BaseNotificationActivity & AggregatedActivityEnriched<StreamFeedGenerics>; | ||
export type FeedAPIResponse< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR | ||
> = APIResponse & { | ||
export type FeedAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
next: string; | ||
results: | ||
| FlatActivity<ActivityType>[] | ||
| FlatActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[] | ||
| AggregatedActivity<ActivityType>[] | ||
| AggregatedActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[] | ||
| NotificationActivity<ActivityType>[] | ||
| NotificationActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[]; | ||
| FlatActivity<StreamFeedGenerics>[] | ||
| FlatActivityEnriched<StreamFeedGenerics>[] | ||
| AggregatedActivity<StreamFeedGenerics>[] | ||
| AggregatedActivityEnriched<StreamFeedGenerics>[] | ||
| NotificationActivity<StreamFeedGenerics>[] | ||
| NotificationActivityEnriched<StreamFeedGenerics>[]; | ||
@@ -214,26 +190,13 @@ // Notification Feed only | ||
export type PersonalizationFeedAPIResponse< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR | ||
> = APIResponse & { | ||
limit: number; | ||
next: string; | ||
offset: number; | ||
results: FlatActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[]; | ||
version: string; | ||
}; | ||
export type PersonalizationFeedAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = | ||
APIResponse & { | ||
limit: number; | ||
next: string; | ||
offset: number; | ||
results: FlatActivityEnriched<StreamFeedGenerics>[]; | ||
version: string; | ||
}; | ||
export type GetActivitiesAPIResponse< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR | ||
> = APIResponse & { | ||
results: | ||
| FlatActivity<ActivityType>[] | ||
| FlatActivityEnriched<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>[]; | ||
export type GetActivitiesAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
results: FlatActivity<StreamFeedGenerics>[] | FlatActivityEnriched<StreamFeedGenerics>[]; | ||
}; | ||
@@ -246,11 +209,4 @@ | ||
*/ | ||
export class StreamFeed< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
PersonalizationType extends UR = UR | ||
> { | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export class StreamFeed<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
client: StreamClient<StreamFeedGenerics>; | ||
token: string; | ||
@@ -274,8 +230,3 @@ id: string; | ||
*/ | ||
constructor( | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, | ||
feedSlug: string, | ||
userId: string, | ||
token: string, | ||
) { | ||
constructor(client: StreamClient<StreamFeedGenerics>, feedSlug: string, userId: string, token: string) { | ||
if (!feedSlug || !userId) { | ||
@@ -315,6 +266,6 @@ throw new FeedError('Please provide a feed slug and user id, ie client.feed("user", "1")'); | ||
* @memberof StreamFeed.prototype | ||
* @param {NewActivity<ActivityType>} activity - The activity to add | ||
* @return {Promise<Activity<ActivityType>>} | ||
* @param {NewActivity<StreamFeedGenerics>} activity - The activity to add | ||
* @return {Promise<Activity<StreamFeedGenerics>>} | ||
*/ | ||
addActivity(activity: NewActivity<ActivityType>) { | ||
addActivity(activity: NewActivity<StreamFeedGenerics>) { | ||
activity = utils.replaceStreamObjects(activity); | ||
@@ -325,3 +276,3 @@ if (!activity.actor && this.client.currentUser) { | ||
return this.client.post<Activity<ActivityType>>({ | ||
return this.client.post<Activity<StreamFeedGenerics>>({ | ||
url: `feed/${this.feedUrl}/`, | ||
@@ -360,7 +311,7 @@ body: activity, | ||
* @memberof StreamFeed.prototype | ||
* @param {NewActivity<ActivityType>[]} activities Array of activities to add | ||
* @return {Promise<Activity<ActivityType>[]>} | ||
* @param {NewActivity<StreamFeedGenerics>[]} activities Array of activities to add | ||
* @return {Promise<Activity<StreamFeedGenerics>[]>} | ||
*/ | ||
addActivities(activities: NewActivity<ActivityType>[]) { | ||
return this.client.post<Activity<ActivityType>[]>({ | ||
addActivities(activities: NewActivity<StreamFeedGenerics>[]) { | ||
return this.client.post<Activity<StreamFeedGenerics>[]>({ | ||
url: `feed/${this.feedUrl}/`, | ||
@@ -529,3 +480,3 @@ body: { activities: utils.replaceStreamObjects(activities) }, | ||
return this.client.get<FeedAPIResponse<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType>>({ | ||
return this.client.get<FeedAPIResponse<StreamFeedGenerics>>({ | ||
url: `${path}${this.feedUrl}/`, | ||
@@ -575,3 +526,3 @@ qs: { ...options, ...extraOptions }, | ||
* @memberof StreamFeed.prototype | ||
* @param {function} Faye.Callback<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>> Callback to call on completion | ||
* @param {function} Faye.Callback<RealTimeMessage<StreamFeedGenerics>> Callback to call on completion | ||
* @return {Promise<Faye.Subscription>} | ||
@@ -583,3 +534,3 @@ * @example | ||
*/ | ||
subscribe(callback: Faye.SubscribeCallback<RealTimeMessage<UserType, ActivityType, CollectionType, ReactionType>>) { | ||
subscribe(callback: Faye.SubscribeCallback<RealTimeMessage<StreamFeedGenerics>>) { | ||
if (!this.client.appId) { | ||
@@ -665,3 +616,3 @@ throw new SiteError( | ||
return this.client.post<APIResponse & Activity<ActivityType> & { added?: string[]; removed?: string[] }>({ | ||
return this.client.post<APIResponse & Activity<StreamFeedGenerics> & { added?: string[]; removed?: string[] }>({ | ||
url: `feed_targets/${this.feedUrl}/activity_to_targets/`, | ||
@@ -668,0 +619,0 @@ token: this.token, |
@@ -1,2 +0,2 @@ | ||
import { StreamClient, APIResponse, UR } from './client'; | ||
import { StreamClient, APIResponse, UR, DefaultGenerics } from './client'; | ||
@@ -9,6 +9,6 @@ /** | ||
export type PersonalizationAPIResponse<PersonalizationType extends UR = UR> = APIResponse & { | ||
export type PersonalizationAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
app_id: string; | ||
next: string; | ||
results: PersonalizationType[]; | ||
results: Array<StreamFeedGenerics['personalizationType']>; | ||
limit?: number; | ||
@@ -19,11 +19,4 @@ offset?: number; | ||
export class Personalization< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
PersonalizationType extends UR = UR | ||
> { | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export class Personalization<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
client: StreamClient<StreamFeedGenerics>; | ||
@@ -37,5 +30,3 @@ /** | ||
*/ | ||
constructor( | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, | ||
) { | ||
constructor(client: StreamClient<StreamFeedGenerics>) { | ||
this.client = client; | ||
@@ -51,7 +42,7 @@ } | ||
* @param {object} options Additional options | ||
* @return {Promise<PersonalizationAPIResponse<PersonalizationType>>} Promise object. Personalized feed | ||
* @return {Promise<PersonalizationAPIResponse<StreamFeedGenerics>>} Promise object. Personalized feed | ||
* @example client.personalization.get('follow_recommendations', {foo: 'bar', baz: 'qux'}) | ||
*/ | ||
get(resource: string, options: Record<string, string> & { token?: string } = {}) { | ||
return this.client.get<PersonalizationAPIResponse<PersonalizationType>>({ | ||
return this.client.get<PersonalizationAPIResponse<StreamFeedGenerics>>({ | ||
url: `${resource}/`, | ||
@@ -72,7 +63,7 @@ serviceName: 'personalization', | ||
* @param {object} data - Data to send in the payload | ||
* @return {Promise<PersonalizationAPIResponse<PersonalizationType>>} Promise object. Data that was posted if successful, or an error. | ||
* @return {Promise<PersonalizationAPIResponse<StreamFeedGenerics>>} Promise object. Data that was posted if successful, or an error. | ||
* @example client.personalization.post('follow_recommendations', {foo: 'bar', baz: 'qux'}) | ||
*/ | ||
post(resource: string, options: Record<string, string> = {}, data: UR = {}) { | ||
return this.client.post<PersonalizationAPIResponse<PersonalizationType>>({ | ||
return this.client.post<PersonalizationAPIResponse<StreamFeedGenerics>>({ | ||
url: `${resource}/`, | ||
@@ -93,7 +84,7 @@ serviceName: 'personalization', | ||
* @param {object} options - Additional options | ||
* @return {Promise<PersonalizationAPIResponse<PersonalizationType>>} Promise object. Data that was deleted if successful, or an error. | ||
* @return {Promise<PersonalizationAPIResponse<StreamFeedGenerics>>} Promise object. Data that was deleted if successful, or an error. | ||
* @example client.personalization.delete('follow_recommendations', {foo: 'bar', baz: 'qux'}) | ||
*/ | ||
delete(resource: string, options: Record<string, string> = {}) { | ||
return this.client.delete<PersonalizationAPIResponse<PersonalizationType>>({ | ||
return this.client.delete<PersonalizationAPIResponse<StreamFeedGenerics>>({ | ||
url: `${resource}/`, | ||
@@ -100,0 +91,0 @@ serviceName: 'personalization', |
@@ -1,2 +0,2 @@ | ||
import { StreamClient, APIResponse, UR } from './client'; | ||
import { StreamClient, APIResponse, UR, DefaultGenerics } from './client'; | ||
import { StreamFeed } from './feed'; | ||
@@ -39,37 +39,25 @@ import { SiteError } from './errors'; | ||
export type ChildReactionsRecords< | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
UserType extends UR = UR | ||
StreamFeedGenerics extends DefaultGenerics = DefaultGenerics, | ||
// eslint-disable-next-line no-use-before-define | ||
> = Record<string, EnrichedReaction<ReactionType, ChildReactionType, UserType>[]>; | ||
> = Record<string, EnrichedReaction<StreamFeedGenerics>[]>; | ||
export type EnrichedReaction< | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
UserType extends UR = UR | ||
> = Reaction<ReactionType | ChildReactionType> & { | ||
export type EnrichedReaction<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = Reaction< | ||
StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType'] | ||
> & { | ||
children_counts: Record<string, number>; | ||
latest_children: ChildReactionsRecords<ReactionType, ChildReactionType, UserType>; | ||
latest_children: ChildReactionsRecords<StreamFeedGenerics>; | ||
latest_children_extra?: Record<string, { next?: string }>; | ||
own_children?: ChildReactionsRecords<ReactionType, ChildReactionType, UserType>; | ||
user?: EnrichedUser<UserType>; | ||
own_children?: ChildReactionsRecords<StreamFeedGenerics>; | ||
user?: EnrichedUser<StreamFeedGenerics>; | ||
}; | ||
export type EnrichedReactionAPIResponse< | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
UserType extends UR = UR | ||
> = APIResponse & EnrichedReaction<ReactionType, ChildReactionType, UserType>; | ||
export type EnrichedReactionAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & | ||
EnrichedReaction<StreamFeedGenerics>; | ||
export type ReactionFilterAPIResponse< | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
UserType extends UR = UR | ||
> = APIResponse & { | ||
export type ReactionFilterAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & { | ||
next: string; | ||
results: | ||
| ReactionAPIResponse<ReactionType | ChildReactionType>[] | ||
| EnrichedReactionAPIResponse<ReactionType, ChildReactionType, UserType>[]; | ||
activity?: ActivityType; | ||
| ReactionAPIResponse<StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType']>[] | ||
| EnrichedReactionAPIResponse<StreamFeedGenerics>[]; | ||
activity?: StreamFeedGenerics['childReactionType']; | ||
}; | ||
@@ -105,11 +93,4 @@ | ||
export class StreamReaction< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
PersonalizationType extends UR = UR | ||
> { | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export class StreamReaction<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
client: StreamClient<StreamFeedGenerics>; | ||
token: string; | ||
@@ -126,6 +107,3 @@ | ||
*/ | ||
constructor( | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, | ||
token: string, | ||
) { | ||
constructor(client: StreamClient<StreamFeedGenerics>, token: string) { | ||
this.client = client; | ||
@@ -163,6 +141,6 @@ this.token = token; | ||
activity: string | { id: string }, | ||
data?: ReactionType, | ||
data?: StreamFeedGenerics['reactionType'], | ||
{ id, targetFeeds = [], userId, targetFeedsExtraData }: ReactionAddOptions = {}, | ||
) { | ||
const body: ReactionBody<ReactionType> = { | ||
const body: ReactionBody<StreamFeedGenerics['reactionType']> = { | ||
id, | ||
@@ -178,3 +156,3 @@ activity_id: activity instanceof Object ? (activity as { id: string }).id : activity, | ||
} | ||
return this.client.post<ReactionAPIResponse<ReactionType>>({ | ||
return this.client.post<ReactionAPIResponse<StreamFeedGenerics['reactionType']>>({ | ||
url: this.buildURL(), | ||
@@ -205,6 +183,6 @@ body, | ||
reaction: string | { id: string }, | ||
data?: ChildReactionType, | ||
data?: StreamFeedGenerics['childReactionType'], | ||
{ targetFeeds = [], userId, targetFeedsExtraData }: ReactionAddChildOptions = {}, | ||
) { | ||
const body: ReactionBody<ChildReactionType> = { | ||
const body: ReactionBody<StreamFeedGenerics['childReactionType']> = { | ||
parent: reaction instanceof Object ? (reaction as { id: string }).id : reaction, | ||
@@ -219,3 +197,3 @@ kind, | ||
} | ||
return this.client.post<ReactionAPIResponse<ChildReactionType>>({ | ||
return this.client.post<ReactionAPIResponse<StreamFeedGenerics['childReactionType']>>({ | ||
url: this.buildURL(), | ||
@@ -233,7 +211,7 @@ body, | ||
* @param {string} id Reaction Id | ||
* @return {Promise<EnrichedReactionAPIResponse<ReactionType, ChildReactionType, UserType>>} | ||
* @return {Promise<EnrichedReactionAPIResponse<StreamFeedGenerics>>} | ||
* @example reactions.get("67b3e3b5-b201-4697-96ac-482eb14f88ec") | ||
*/ | ||
get(id: string) { | ||
return this.client.get<EnrichedReactionAPIResponse<ReactionType, ChildReactionType, UserType>>({ | ||
return this.client.get<EnrichedReactionAPIResponse<StreamFeedGenerics>>({ | ||
url: this.buildURL(id), | ||
@@ -255,3 +233,3 @@ token: this.token, | ||
* @param {ReactionFilterConditions} conditions Reaction Id {activity_id|user_id|reaction_id:string, kind:string, limit:integer} | ||
* @return {Promise<ReactionFilterAPIResponse<ReactionType, ChildReactionType, ActivityType, UserType>>} | ||
* @return {Promise<ReactionFilterAPIResponse<StreamFeedGenerics>>} | ||
* @example reactions.filter({activity_id: "0c7db91c-67f9-11e8-bcd9-fe00a9219401", kind:"like"}) | ||
@@ -277,3 +255,3 @@ * @example reactions.filter({user_id: "john", kinds:"like"}) | ||
return this.client.get<ReactionFilterAPIResponse<ReactionType, ChildReactionType, ActivityType, UserType>>({ | ||
return this.client.get<ReactionFilterAPIResponse<StreamFeedGenerics>>({ | ||
url, | ||
@@ -301,6 +279,6 @@ qs: qs as { [key: string]: unknown }, | ||
id: string, | ||
data?: ReactionType | ChildReactionType, | ||
data?: StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType'], | ||
{ targetFeeds = [], targetFeedsExtraData }: ReactionUpdateOptions = {}, | ||
) { | ||
const body: ReactionBody<ReactionType | ChildReactionType> = { | ||
const body: ReactionBody<StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType']> = { | ||
data, | ||
@@ -312,3 +290,5 @@ target_feeds: this._convertTargetFeeds(targetFeeds), | ||
} | ||
return this.client.put<ReactionAPIResponse<ReactionType | ChildReactionType>>({ | ||
return this.client.put< | ||
ReactionAPIResponse<StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType']> | ||
>({ | ||
url: this.buildURL(id), | ||
@@ -315,0 +295,0 @@ body, |
@@ -1,6 +0,6 @@ | ||
import { StreamClient, APIResponse, UR } from './client'; | ||
import { StreamClient, APIResponse, DefaultGenerics } from './client'; | ||
export type EnrichedUser<UserType extends UR = UR> = { | ||
export type EnrichedUser<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = { | ||
created_at: string; | ||
data: UserType; | ||
data: StreamFeedGenerics['userType']; | ||
id: string; | ||
@@ -10,4 +10,4 @@ updated_at: string; | ||
export type UserAPIResponse<UserType extends UR = UR> = APIResponse & | ||
EnrichedUser<UserType> & { | ||
export type UserAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & | ||
EnrichedUser<StreamFeedGenerics> & { | ||
// present only in profile response | ||
@@ -18,15 +18,8 @@ followers_count?: number; | ||
export class StreamUser< | ||
UserType extends UR = UR, | ||
ActivityType extends UR = UR, | ||
CollectionType extends UR = UR, | ||
ReactionType extends UR = UR, | ||
ChildReactionType extends UR = UR, | ||
PersonalizationType extends UR = UR | ||
> { | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>; | ||
export class StreamUser<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> { | ||
client: StreamClient<StreamFeedGenerics>; | ||
token: string; | ||
id: string; | ||
data?: UserType; | ||
full?: UserAPIResponse<UserType>; | ||
data?: StreamFeedGenerics['userType']; | ||
full?: UserAPIResponse<StreamFeedGenerics>; | ||
private url: string; | ||
@@ -44,7 +37,3 @@ | ||
*/ | ||
constructor( | ||
client: StreamClient<UserType, ActivityType, CollectionType, ReactionType, ChildReactionType, PersonalizationType>, | ||
userId: string, | ||
userAuthToken: string, | ||
) { | ||
constructor(client: StreamClient<StreamFeedGenerics>, userId: string, userAuthToken: string) { | ||
this.client = client; | ||
@@ -85,3 +74,3 @@ this.id = userId; | ||
async get(options?: { with_follow_counts?: boolean }) { | ||
const response = await this.client.get<UserAPIResponse<UserType>>({ | ||
const response = await this.client.get<UserAPIResponse<StreamFeedGenerics>>({ | ||
url: this.url, | ||
@@ -105,4 +94,4 @@ token: this.token, | ||
*/ | ||
async create(data?: UserType, options?: { get_or_create?: boolean }) { | ||
const response = await this.client.post<UserAPIResponse<UserType>>({ | ||
async create(data?: StreamFeedGenerics['userType'], options?: { get_or_create?: boolean }) { | ||
const response = await this.client.post<UserAPIResponse<StreamFeedGenerics>>({ | ||
url: 'user/', | ||
@@ -129,4 +118,4 @@ body: { | ||
*/ | ||
async update(data?: Partial<UserType>) { | ||
const response = await this.client.put<UserAPIResponse<UserType>>({ | ||
async update(data?: Partial<StreamFeedGenerics['userType']>) { | ||
const response = await this.client.put<UserAPIResponse<StreamFeedGenerics>>({ | ||
url: this.url, | ||
@@ -151,3 +140,3 @@ body: { | ||
*/ | ||
getOrCreate(data: UserType) { | ||
getOrCreate(data: StreamFeedGenerics['userType']) { | ||
return this.create(data, { get_or_create: true }); | ||
@@ -154,0 +143,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Possible typosquat attack
Supply chain riskThere is a package with a similar name that is downloaded much more often.
Did you mean |
---|
get-stream |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
386
0
774940
66
15585
Updated@babel/runtime@^7.16.7
Updated@types/jsonwebtoken@^8.5.6
Updated@types/qs@^6.9.7
Updatedqs@^6.10.2