@streamscloud/streams-analytics-collector 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +1 -0
  2. package/dist/adcampaignsquery.graphql.js +3 -0
  3. package/dist/articlequery.graphql.js +3 -0
  4. package/dist/components/index.d.ts +2 -0
  5. package/dist/components/index.js +1 -0
  6. package/dist/components/types.d.ts +19 -0
  7. package/dist/components/types.js +12 -0
  8. package/dist/components-data/component-data-provider.service.d.ts +3 -0
  9. package/dist/components-data/component-data-provider.service.js +35 -0
  10. package/dist/components-data/components-data-fetcher.service.d.ts +5 -0
  11. package/dist/components-data/components-data-fetcher.service.js +35 -0
  12. package/dist/components-data/components-data-parameters-reader.service.d.ts +2 -0
  13. package/dist/components-data/components-data-parameters-reader.service.js +20 -0
  14. package/dist/components-data/index.d.ts +4 -0
  15. package/dist/components-data/index.js +3 -0
  16. package/dist/components-data/types.d.ts +24 -0
  17. package/dist/components-data/types.js +6 -0
  18. package/dist/contentlistsquery.graphql.js +3 -0
  19. package/dist/data-loaders/index.d.ts +2 -0
  20. package/dist/data-loaders/index.js +2 -0
  21. package/dist/data-loaders/short-videos-data-loader/index.d.ts +2 -0
  22. package/dist/data-loaders/short-videos-data-loader/loader.d.ts +4 -0
  23. package/dist/data-loaders/short-videos-data-loader/loader.js +14 -0
  24. package/dist/data-loaders/short-videos-data-loader/mapper.d.ts +3 -0
  25. package/dist/data-loaders/short-videos-data-loader/mapper.js +27 -0
  26. package/dist/data-loaders/short-videos-data-loader/types.d.ts +14 -0
  27. package/dist/data-loaders/streams-data-loader/index.d.ts +2 -0
  28. package/dist/data-loaders/streams-data-loader/loader.d.ts +4 -0
  29. package/dist/data-loaders/streams-data-loader/loader.js +14 -0
  30. package/dist/data-loaders/streams-data-loader/mapper.d.ts +3 -0
  31. package/dist/data-loaders/streams-data-loader/mapper.js +11 -0
  32. package/dist/data-loaders/streams-data-loader/types.d.ts +4 -0
  33. package/dist/data-loaders/types.d.ts +3 -0
  34. package/dist/index.d.ts +4 -0
  35. package/dist/index.js +4 -0
  36. package/dist/postsquery.graphql.js +3 -0
  37. package/dist/services/embed-content-api-client.d.ts +8 -0
  38. package/dist/services/embed-content-api-client.js +48 -0
  39. package/dist/services/embed-content-client.service.d.ts +2 -0
  40. package/dist/services/embed-content-client.service.js +5 -0
  41. package/dist/services/index.d.ts +2 -0
  42. package/dist/services/index.js +2 -0
  43. package/dist/services/operations/posts-query.graphql.js +3 -0
  44. package/dist/services/operations/streams-query.graphql.js +3 -0
  45. package/dist/services/types.d.ts +303 -0
  46. package/dist/streams-api-client-model.d.ts +5 -0
  47. package/dist/streams-content-api-client.d.ts +14 -0
  48. package/dist/streams-content-api-client.js +89 -0
  49. package/dist/types.d.ts +790 -0
  50. package/dist/types.js +222 -0
  51. package/package.json +54 -0
@@ -0,0 +1,303 @@
1
+ import { MediaItem } from '../types';
2
+ export type EmbedContentApiClientModel = {
3
+ streamsGqlEndpoint: string;
4
+ };
5
+ export type EmbedPostsInput = {
6
+ filter: EmbedPostsFilterInput;
7
+ };
8
+ export type EmbedStreamsInput = {
9
+ filter: EmbedPostsFilterInput;
10
+ };
11
+ export interface Media {
12
+ type: MediaType;
13
+ url: string;
14
+ thumbnailUrl: string | null;
15
+ }
16
+ export type EmbedPostsFilterInput = {
17
+ ids: string[];
18
+ };
19
+ export type EmbedPostsData = {
20
+ embedPosts: CursorResultOfPost;
21
+ };
22
+ export type EmbedStreamsFilterInput = {
23
+ ids: string[];
24
+ };
25
+ export type EmbedStreamsData = {
26
+ embedStreams: CursorResultOfStreams;
27
+ };
28
+ export type GqlResponse<T> = {
29
+ data?: T;
30
+ errors?: unknown;
31
+ };
32
+ export type ContentMediaItem = IMediaItem & {
33
+ blobId: string;
34
+ mediaPageTags?: MediaPageTagPosition[];
35
+ metadata: MediaItemMetadata;
36
+ thumbnailBlobId?: string;
37
+ thumbnailUrl: string | null;
38
+ type: MediaType;
39
+ url: string;
40
+ userTags?: UserTagPosition[];
41
+ };
42
+ export type CtaButton = {
43
+ background: string;
44
+ border: string;
45
+ text: string;
46
+ textColor: string;
47
+ url: string;
48
+ };
49
+ export type IMediaItem = {
50
+ blobId: string;
51
+ metadata: MediaItemMetadata;
52
+ thumbnailBlobId?: string;
53
+ thumbnailUrl?: string;
54
+ type: MediaType;
55
+ url: string;
56
+ };
57
+ export declare enum MediaFormat {
58
+ W4H3 = "W4H3",
59
+ W16H9 = "W16H9"
60
+ }
61
+ export type MediaItemMetadata = {
62
+ durationSec?: number;
63
+ fileName?: string;
64
+ height: number;
65
+ width: number;
66
+ };
67
+ export type MediaPageTag = {
68
+ handle: string;
69
+ id: string;
70
+ image?: string;
71
+ name: string;
72
+ };
73
+ export type MediaPageTagPosition = TagPosition & {
74
+ itemId: string;
75
+ leftPCT: number;
76
+ mediaPage?: MediaPageTag;
77
+ topPCT: number;
78
+ };
79
+ export type MediaPostData = {
80
+ ctaButton?: CtaButton;
81
+ preferredMediaFormat: MediaFormat;
82
+ text?: string;
83
+ };
84
+ export declare enum MediaType {
85
+ Audio = "AUDIO",
86
+ Image = "IMAGE",
87
+ ShortVideo = "SHORT_VIDEO",
88
+ Video = "VIDEO"
89
+ }
90
+ export type MomentInfo = {
91
+ author: Profile;
92
+ cover: string;
93
+ displayDate: Date;
94
+ id: string;
95
+ isSeen: boolean;
96
+ text?: string;
97
+ };
98
+ export declare enum MomentLifetime {
99
+ Day = "DAY",
100
+ Week = "WEEK"
101
+ }
102
+ export type MomentPostData = {
103
+ lifetime: MomentLifetime;
104
+ text?: string;
105
+ };
106
+ export type MomentsContainerInfo = {
107
+ hideIfNoMoments: boolean;
108
+ image?: ScaledImageBlob;
109
+ momentsEnabled: boolean;
110
+ primaryColor?: string;
111
+ targetId: string;
112
+ targetType: PublishTargetType;
113
+ useImageAsMomentsCover: boolean;
114
+ };
115
+ export type MomentsInfo = {
116
+ containerInfo: MomentsContainerInfo;
117
+ moments: MomentInfo[];
118
+ unseenMomentsCount: number;
119
+ };
120
+ export type CursorResultOfStreams = {
121
+ continuationToken?: string;
122
+ items: Stream[];
123
+ };
124
+ export type CursorResultOfPost = {
125
+ continuationToken?: string;
126
+ items: Post[];
127
+ };
128
+ export type Post = {
129
+ authorProfile: Profile;
130
+ createdAt: Date;
131
+ createdBy: string;
132
+ displayDate: Date;
133
+ editorProfile: Profile;
134
+ enableSocialInteractions: boolean;
135
+ expiresOn?: Date;
136
+ generatedName: string;
137
+ id: string;
138
+ isPinned: boolean;
139
+ isSeen: boolean;
140
+ language: string;
141
+ mainImage?: string;
142
+ ownerProfile: Profile;
143
+ postData: PostData;
144
+ postHeading: PostHeading;
145
+ postProfile: Profile;
146
+ postType: PostType;
147
+ publishedTo?: PublishTarget;
148
+ scheduledOn?: Date;
149
+ sharesCount: number;
150
+ showInFeed: boolean;
151
+ social?: PostSocialInteractions;
152
+ status: Status;
153
+ updatedAt: Date;
154
+ updatedBy: string;
155
+ userReaction?: Reaction;
156
+ viewsCount: number;
157
+ };
158
+ export type PostData = {
159
+ media: ContentMediaItem[];
160
+ mediaData?: MediaPostData;
161
+ momentData?: MomentPostData;
162
+ postType: PostType;
163
+ shortVideoData?: ShortVideoPostData;
164
+ textData?: TextPostData;
165
+ videoData?: VideoPostData;
166
+ };
167
+ export type PostHeading = {
168
+ networkData?: PostHeadingNetworkTargetData;
169
+ postDisplayDate: string;
170
+ postViewsCount: number;
171
+ sourceHandle: string;
172
+ sourceId: string;
173
+ sourceImage?: string;
174
+ sourceIsRemoved: boolean;
175
+ sourceName: string;
176
+ sourceType: PostSourceType;
177
+ wasModified: boolean;
178
+ };
179
+ export type PostHeadingNetworkTargetData = {
180
+ momentsInfo: MomentsInfo;
181
+ primaryColor?: string;
182
+ };
183
+ export type PostSocialInteractions = {
184
+ commentsCount: number;
185
+ reactions: ReactionsCount;
186
+ sharesCount: number;
187
+ };
188
+ export declare enum PostSourceType {
189
+ Channel = "CHANNEL",
190
+ Group = "GROUP",
191
+ MediaPage = "MEDIA_PAGE",
192
+ Organization = "ORGANIZATION",
193
+ UserProfile = "USER_PROFILE"
194
+ }
195
+ export declare enum PostType {
196
+ Article = "ARTICLE",
197
+ Audio = "AUDIO",
198
+ Event = "EVENT",
199
+ Link = "LINK",
200
+ Media = "MEDIA",
201
+ Moment = "MOMENT",
202
+ ShortVideo = "SHORT_VIDEO",
203
+ Text = "TEXT",
204
+ Video = "VIDEO"
205
+ }
206
+ export type Profile = {
207
+ __typename?: 'Profile';
208
+ handle: string;
209
+ id: string;
210
+ image?: string;
211
+ isRemoved: boolean;
212
+ name: string;
213
+ type: ProfileType;
214
+ };
215
+ export declare enum ProfileType {
216
+ Channel = "CHANNEL",
217
+ Group = "GROUP",
218
+ Organization = "ORGANIZATION",
219
+ User = "USER"
220
+ }
221
+ export type PublishTarget = {
222
+ enableMoments: boolean;
223
+ enablePostsSocialInteractionsByDefault: boolean;
224
+ id: string;
225
+ image?: string;
226
+ isRemoved: boolean;
227
+ momentsLifetime: MomentLifetime;
228
+ name: string;
229
+ primaryColor?: string;
230
+ targetContentOwnerProfile?: Profile;
231
+ type: PublishTargetType;
232
+ };
233
+ export declare enum PublishTargetType {
234
+ Channel = "CHANNEL",
235
+ Group = "GROUP",
236
+ MediaPage = "MEDIA_PAGE",
237
+ User = "USER"
238
+ }
239
+ export declare enum ReactableType {
240
+ ChatMessage = "CHAT_MESSAGE",
241
+ Comment = "COMMENT",
242
+ CommunityMessage = "COMMUNITY_MESSAGE",
243
+ Post = "POST"
244
+ }
245
+ export type Reaction = {
246
+ code: string;
247
+ id: string;
248
+ reactableId: string;
249
+ reactableType: ReactableType;
250
+ userProfile: Profile;
251
+ };
252
+ export type ReactionCodeCount = {
253
+ code: string;
254
+ count: number;
255
+ };
256
+ export type ReactionsCount = {
257
+ perCode: ReactionCodeCount[];
258
+ total: number;
259
+ };
260
+ export type ScaledImageBlob = {
261
+ id: string;
262
+ url: string;
263
+ };
264
+ export type ShortVideoPostData = {
265
+ text?: string;
266
+ };
267
+ export declare enum Status {
268
+ Archived = "ARCHIVED",
269
+ Draft = "DRAFT",
270
+ Published = "PUBLISHED",
271
+ Scheduled = "SCHEDULED"
272
+ }
273
+ export type Stream = {
274
+ id: string;
275
+ cover: MediaItem;
276
+ };
277
+ export type TagPosition = {
278
+ itemId: string;
279
+ leftPCT: number;
280
+ topPCT: number;
281
+ };
282
+ export type TextPostData = {
283
+ ctaButton?: CtaButton;
284
+ text: string;
285
+ };
286
+ export type UserTag = {
287
+ id: string;
288
+ image: string;
289
+ name: string;
290
+ username?: string;
291
+ };
292
+ export type UserTagPosition = TagPosition & {
293
+ itemId: string;
294
+ leftPCT: number;
295
+ topPCT: number;
296
+ user?: UserTag;
297
+ };
298
+ export type VideoPostData = {
299
+ preferredMediaFormat: MediaFormat;
300
+ text?: string;
301
+ title?: string;
302
+ viewsCount?: number;
303
+ };
@@ -0,0 +1,5 @@
1
+ export type StreamsApiClientModel = {
2
+ streamsGqlEndpoint: string;
3
+ organizationId: string;
4
+ siteId: string;
5
+ };
@@ -0,0 +1,14 @@
1
+ import type { AdCampaign, Article, ContentList, Post } from './types';
2
+ export declare class StreamsContentApiClient {
3
+ private readonly gqlEndpoint;
4
+ private readonly organizationId;
5
+ private readonly siteId;
6
+ private readonly postStatus;
7
+ constructor(gqlEndpoint: string, organizationId: string, siteId: string);
8
+ getArticle(slug: string): Promise<Article | null>;
9
+ getPost(id: string): Promise<Post | undefined>;
10
+ getPosts(ids: string[] | null, types?: string[] | null, contentListId?: string | null): Promise<Post[] | undefined>;
11
+ getContentLists(): Promise<ContentList[] | undefined>;
12
+ getAdCampaigns(page: number, perPage: number): Promise<AdCampaign[] | undefined>;
13
+ private queryGql;
14
+ }
@@ -0,0 +1,89 @@
1
+ import SiteActiveCampaignsQuery from './adcampaignsquery.graphql.js';
2
+ import SiteArticleQuery from './articlequery.graphql.js';
3
+ import SiteContentListsQuery from './contentlistsquery.graphql.js';
4
+ import SitePostsQuery from './postsquery.graphql.js';
5
+ import { SitePostsOrderBy, SiteContentListsOrderBy, SiteAdCampaignsOrderBy } from './types.js';
6
+
7
+ class StreamsContentApiClient {
8
+ gqlEndpoint = '{{streamsGqlEndpoint}}';
9
+ organizationId = '{{organizationId}}';
10
+ siteId = '{{siteId}}';
11
+ postStatus = 'PUBLISHED';
12
+ constructor(gqlEndpoint, organizationId, siteId) {
13
+ this.gqlEndpoint = gqlEndpoint;
14
+ this.organizationId = organizationId;
15
+ this.siteId = siteId;
16
+ }
17
+ async getArticle(slug) {
18
+ const response = await this.queryGql(SiteArticleQuery, { organizationId: this.organizationId, slug });
19
+ return response.siteArticle;
20
+ }
21
+ async getPost(id) {
22
+ const response = await this.getPosts([id]);
23
+ return response?.pop();
24
+ }
25
+ async getPosts(ids, types = null, contentListId = null) {
26
+ const response = await this.queryGql(SitePostsQuery, {
27
+ cursor: {
28
+ sorting: {
29
+ orderBy: SitePostsOrderBy.Published
30
+ }
31
+ },
32
+ filter: {
33
+ ids: ids,
34
+ organizationId: this.organizationId,
35
+ postTypes: types,
36
+ statuses: [this.postStatus],
37
+ contentListId: contentListId
38
+ }
39
+ });
40
+ return response.sitePosts?.items;
41
+ }
42
+ async getContentLists() {
43
+ const response = await this.queryGql(SiteContentListsQuery, {
44
+ cursor: {
45
+ sorting: {
46
+ orderBy: SiteContentListsOrderBy.Name
47
+ }
48
+ },
49
+ filter: {
50
+ organizationId: this.organizationId
51
+ }
52
+ });
53
+ return response.siteContentLists?.items;
54
+ }
55
+ async getAdCampaigns(page, perPage) {
56
+ const response = await this.queryGql(SiteActiveCampaignsQuery, {
57
+ pageQuery: {
58
+ orderBy: SiteAdCampaignsOrderBy.Modified,
59
+ fetchTotal: false,
60
+ page: page,
61
+ perPage: perPage
62
+ },
63
+ filter: {
64
+ organizationId: this.organizationId,
65
+ siteId: this.siteId
66
+ }
67
+ });
68
+ return response.siteActiveCampaigns?.items;
69
+ }
70
+ queryGql = async (query, variables) => {
71
+ const response = await fetch(this.gqlEndpoint, {
72
+ method: 'POST',
73
+ headers: {
74
+ 'Content-Type': 'application/json'
75
+ },
76
+ body: JSON.stringify({
77
+ query,
78
+ variables
79
+ })
80
+ });
81
+ const gql = await response.json();
82
+ if (!gql.data) {
83
+ throw new Error(JSON.stringify(gql.errors));
84
+ }
85
+ return gql.data;
86
+ };
87
+ }
88
+
89
+ export { StreamsContentApiClient };