umami-api-js 0.0.3 → 0.1.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.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- A package to interact with [the API of self-hosted instances of Umami v2.19.0](https://umami.is/docs/api). It is a lightweight alternative to [@umami/api-client](https://github.com/umami-software/api-client), forked from [osu-api-v2-js](https://github.com/TTTaevas/osu-api-v2-js).
1
+ A package to interact with [the API of self-hosted instances of Umami v3.0.0](https://umami.is/docs/api). It is a lightweight alternative to [@umami/api-client](https://github.com/umami-software/api-client), forked from [osu-api-v2-js](https://github.com/TTTaevas/osu-api-v2-js).
2
2
 
3
- Please note that this package is not expected to work with Umami Cloud, the instance of Umami hosted by its creators.
3
+ If you are reading this from the [package's documentation](https://umami-api-js.taevas.xyz/), please be aware that the documentation is for **umami-api-js@0.1.0**, so make sure your package is up to date! Report any bug on [Codeberg](https://codeberg.org/Taevas/umami-api-js/issues).
4
4
 
5
- Please also note that this is currently being built mainly to serve as a component to my [taevas.xyz](https://codeberg.org/Taevas/taevas.xyz) project, meaning it currently doesn't perfectly cover the API!
5
+ Please note that this package is expected to work with self-hosted instances of **Umami v3.0.0**, and is *not* expected to work with [Umami Cloud](https://umami.is/docs/cloud), the instance of Umami hosted by its creators.
package/dist/index.d.ts CHANGED
@@ -1,23 +1,56 @@
1
1
  import { Admin } from "./namespaces/Admin.js";
2
2
  import { Events } from "./namespaces/Events.js";
3
+ import { Links } from "./namespaces/Links.js";
4
+ import { Me } from "./namespaces/Me.js";
5
+ import { Pixels } from "./namespaces/Pixels.js";
3
6
  import { Realtime } from "./namespaces/Realtime.js";
7
+ import { Reports } from "./namespaces/Reports.js";
4
8
  import { Sessions } from "./namespaces/Sessions.js";
5
9
  import { Teams } from "./namespaces/Teams.js";
6
10
  import { Users } from "./namespaces/Users.js";
7
11
  import { Websites } from "./namespaces/Websites.js";
8
- export { Admin, Users, Teams, Events, Sessions, Websites, Realtime };
12
+ import { WebsiteStats } from "./namespaces/WebsiteStats.js";
13
+ export { Admin, Events, Links, Me, Pixels, Websites, WebsiteStats, Realtime, Reports, Sessions, Teams, Users };
9
14
  export interface ValueAndPrev {
10
15
  /** The actual value for the given time period */
11
16
  value: number;
12
17
  /** The value for the same *timespan* for the time period that ends where the time period for value starts */
13
18
  prev: number;
14
19
  }
20
+ export interface MinimalUser {
21
+ id: string;
22
+ username: string;
23
+ }
15
24
  export interface GenericObject {
16
25
  id: string;
17
26
  createdAt: Date;
18
27
  updatedAt: Date | null;
19
28
  deletedAt: Date | null;
20
29
  }
30
+ export interface Website extends GenericObject {
31
+ name: string;
32
+ domain: string;
33
+ shareId: string | null;
34
+ resetAt: Date | null;
35
+ userId: string;
36
+ teamId: string | null;
37
+ createdBy: string;
38
+ }
39
+ export interface Report extends Omit<GenericObject, "deletedAt"> {
40
+ userId: string;
41
+ websiteId: string;
42
+ type: string;
43
+ name: string;
44
+ description: string;
45
+ parameters: {
46
+ type: string;
47
+ value: string;
48
+ };
49
+ }
50
+ export interface NameValue {
51
+ name: string;
52
+ value: number;
53
+ }
21
54
  export interface GenericRequestParameters {
22
55
  /** Search text */
23
56
  search?: string;
@@ -32,9 +65,17 @@ export interface Timestamps {
32
65
  /** Timestamp of end date */
33
66
  endAt: Date | number;
34
67
  }
68
+ export interface XTY {
69
+ /** Event name */
70
+ x: string;
71
+ /** Timestamp */
72
+ t: Date;
73
+ /** Number of events */
74
+ y: number;
75
+ }
35
76
  /**
36
77
  * Many endpoints can make use of the filters in this interface
37
- * @remarks As defined in the server documentation for the Endpoints in: Events, Sessions, Website stats
78
+ * @remarks As defined in the server documentation for the Endpoints in: Events, Sessions, Website stats, Reports
38
79
  */
39
80
  export interface Filters {
40
81
  /** Name of URL */
@@ -131,14 +172,14 @@ export declare class API {
131
172
  get user(): {
132
173
  id: string;
133
174
  username: string;
134
- role: string;
175
+ role: Role;
135
176
  createdAt: Date;
136
177
  isAdmin: boolean;
137
178
  };
138
179
  set user(user: {
139
180
  id: string;
140
181
  username: string;
141
- role: string;
182
+ role: Role;
142
183
  createdAt: Date;
143
184
  isAdmin: boolean;
144
185
  });
@@ -148,9 +189,9 @@ export declare class API {
148
189
  /** If {@link API.setNewToken} has been called, you can wait for it to be done through this promise */
149
190
  private token_promise;
150
191
  /**
151
- * This creates a new {@link API.token}, alongside a new {@link API.refresh_token} if arguments are provided or if a refresh_token already exists
192
+ * This contacts the server in order to get and set a new {@link API.token}!
152
193
  * @remarks The API object requires a {@link API.username} and a {@link API.password} to successfully get any token
153
- * @returns Whether or not the token has changed (this should never throw)
194
+ * @returns Whether or not the token has changed (**should be true** as otherwise the server would complain and an {@link APIError} would be thrown to give you some details)
154
195
  */
155
196
  setNewToken(): Promise<boolean>;
156
197
  private _set_token_on_401;
@@ -233,54 +274,185 @@ export declare class API {
233
274
  request(method: "get" | "post" | "put" | "delete", endpoint: Array<string | number>, parameters?: {
234
275
  [k: string]: any;
235
276
  }): Promise<any>;
236
- getWebsiteStats(website_id: string, startAt: Date, endAt: Date): Promise<{
237
- pageviews: ValueAndPrev;
238
- visitors: ValueAndPrev;
239
- visits: ValueAndPrev;
240
- bounces: ValueAndPrev;
241
- totaltime: ValueAndPrev;
277
+ /**
278
+ * To register an event
279
+ * (TODO UNTESTED)
280
+ * @group Sending stats
281
+ */
282
+ sendStats(payload: {
283
+ /** Name of host */
284
+ hostname: string;
285
+ /** Screen resolution (ex. "1920x1080") */
286
+ screen: string;
287
+ /** Language of visitor (ex. "en-US") */
288
+ language: string;
289
+ /** Page URL */
290
+ url: string;
291
+ /** Referrer URL */
292
+ referrer: string;
293
+ /** Page title */
294
+ title: string;
295
+ /** Additional tag description */
296
+ tag: string;
297
+ /** Session identifier */
298
+ id: string;
299
+ /** Website ID */
300
+ website: string;
301
+ /** Name of the event */
302
+ name: string;
303
+ /** Additional data for the event */
304
+ data?: {
305
+ [k: string]: any;
306
+ };
307
+ }): Promise<{
308
+ cache: string;
309
+ sessionid: string;
310
+ visitId: string;
242
311
  }>;
312
+ /** @group Admin endpoints */
243
313
  readonly getUsersAsAdmin: typeof Admin.getUsers;
314
+ /** @group Admin endpoints */
244
315
  readonly getWebsitesAsAdmin: typeof Admin.getWebsites;
316
+ /** @group Admin endpoints */
245
317
  readonly getTeamsAsAdmin: typeof Admin.getTeams;
246
- readonly createUser: typeof Users.createUser;
247
- readonly getUser: typeof Users.getUser;
248
- readonly updateUser: typeof Users.updateUser;
249
- readonly deleteUser: typeof Users.deleteUser;
250
- readonly getUserTeams: typeof Users.getUserTeams;
251
- readonly getUserWebsites: typeof Users.getUserWebsites;
252
- readonly getTeams: typeof Teams.getTeams;
253
- readonly createTeam: typeof Teams.createTeam;
254
- readonly joinTeam: typeof Teams.joinTeam;
255
- readonly getTeam: typeof Teams.getTeam;
256
- readonly updateTeam: typeof Teams.updateTeam;
257
- readonly deleteTeam: typeof Teams.deleteTeam;
258
- readonly getTeamUsers: typeof Teams.getTeamUsers;
259
- readonly addTeamUser: typeof Teams.addTeamUser;
260
- readonly getTeamUser: typeof Teams.getTeamUser;
261
- readonly updateTeamUser: typeof Teams.updateTeamUser;
262
- readonly removeTeamUser: typeof Teams.removeTeamUser;
263
- readonly getTeamWebsites: typeof Teams.getTeamWebsites;
264
- readonly getWebsiteEvents: typeof Events.getWebsiteEvents;
265
- readonly getWebsiteEventData: typeof Events.getWebsiteEventData;
266
- readonly getWebsiteEventsData: typeof Events.getWebsiteEventsData;
267
- readonly getWebsiteEventsDataFields: typeof Events.getWebsiteEventsDataFields;
268
- readonly getWebsiteEventsDataProperties: typeof Events.getWebsiteEventsDataProperties;
269
- readonly getWebsiteEventsDataValues: typeof Events.getWebsiteEventsDataValues;
270
- readonly getWebsiteEventsDataStats: typeof Events.getWebsiteEventsDataStats;
271
- readonly getWebsiteSessions: typeof Sessions.getWebsiteSessions;
272
- readonly getWebsiteSessionsStats: typeof Sessions.getWebsiteSessionsStats;
273
- readonly getWebsiteSessionsWeekly: typeof Sessions.getWebsiteSessionsWeekly;
274
- readonly getWebsiteSession: typeof Sessions.getWebsiteSession;
275
- readonly getWebsiteSessionActivity: typeof Sessions.getWebsiteSessionActivity;
276
- readonly getWebsiteSessionProperties: typeof Sessions.getWebsiteSessionProperties;
277
- readonly getWebsiteSessionDataProperties: typeof Sessions.getWebsiteSessionDataProperties;
278
- readonly getWebsiteSessionDataValues: typeof Sessions.getWebsiteSessionDataValues;
279
- readonly getWebsites: typeof Websites.getWebsites;
280
- readonly createWebsite: typeof Websites.createWebsite;
281
- readonly getWebsite: typeof Websites.getWebsite;
282
- readonly updateWebsite: typeof Websites.updateWebsite;
283
- readonly deleteWebsite: typeof Websites.deleteWebsite;
284
- readonly resetWebsite: typeof Websites.resetWebsite;
285
- readonly getRealtime: typeof Realtime.getRealtime;
318
+ /** @group Events endpoints */
319
+ readonly getWebsiteEvents: typeof Events.get_WEBSITEID_Events;
320
+ /** @group Events endpoints */
321
+ readonly getWebsiteEventData: typeof Events.get_WEBSITEID_Eventdata_EVENTID;
322
+ /** @group Events endpoints */
323
+ readonly getWebsiteEventsData: typeof Events.get_WEBSITEID_EventdataEvents;
324
+ /** @group Events endpoints */
325
+ readonly getWebsiteEventsDataFields: typeof Events.get_WEBSITEID_EventdataFields;
326
+ /** @group Events endpoints */
327
+ readonly getWebsiteEventsDataProperties: typeof Events.get_WEBSITEID_EventdataProperties;
328
+ /** @group Events endpoints */
329
+ readonly getWebsiteEventsDataValues: typeof Events.get_WEBSITEID_EventdataValues;
330
+ /** @group Events endpoints */
331
+ readonly getWebsiteEventsDataStats: typeof Events.get_WEBSITEID_EventdataStats;
332
+ /** @group Links endpoints */
333
+ readonly getLinks: typeof Links.get;
334
+ /** @group Links endpoints */
335
+ readonly getLink: typeof Links.get_LINKID;
336
+ /** @group Links endpoints */
337
+ readonly updateLink: typeof Links.post_LINKID;
338
+ /** @group Links endpoints */
339
+ readonly deleteLink: typeof Links.delete_LINKID;
340
+ /** @group Me endpoints */
341
+ readonly getMyself: typeof Me.get;
342
+ /** @group Me endpoints */
343
+ readonly getMyTeams: typeof Me.getTeams;
344
+ /** @group Me endpoints */
345
+ readonly getMyWebsites: typeof Me.getWebsites;
346
+ /** @group Links endpoints */
347
+ readonly getPixels: typeof Pixels.get;
348
+ /** @group Links endpoints */
349
+ readonly getPixel: typeof Pixels.get_PIXELID;
350
+ /** @group Links endpoints */
351
+ readonly updatePixel: typeof Pixels.post_PIXELID;
352
+ /** @group Links endpoints */
353
+ readonly deletePixel: typeof Pixels.delete_PIXELID;
354
+ /** @group Websites endpoints */
355
+ readonly getWebsites: typeof Websites.get;
356
+ /** @group Websites endpoints */
357
+ readonly createWebsite: typeof Websites.post;
358
+ /** @group Websites endpoints */
359
+ readonly getWebsite: typeof Websites.get_WEBSITEID;
360
+ /** @group Websites endpoints */
361
+ readonly updateWebsite: typeof Websites.post_WEBSITEID;
362
+ /** @group Websites endpoints */
363
+ readonly deleteWebsite: typeof Websites.delete_WEBSITEID;
364
+ /** @group Websites endpoints */
365
+ readonly resetWebsite: typeof Websites.post_WEBSITEID_Reset;
366
+ /** @group Website stats endpoints */
367
+ readonly getWebsiteActiveVisitors: typeof WebsiteStats.get_WEBSITEID_Active;
368
+ /** @group Website stats endpoints */
369
+ readonly getWebsiteEventsStats: typeof WebsiteStats.get_WEBSITEID_EventsSeries;
370
+ /** @group Website stats endpoints */
371
+ readonly getWebsiteMetrics: typeof WebsiteStats.get_WEBSITEID_Metrics;
372
+ /** @group Website stats endpoints */
373
+ readonly getWebsiteMetricsExpanded: typeof WebsiteStats.get_WEBSITEID_MetricsExpanded;
374
+ /** @group Website stats endpoints */
375
+ readonly getWebsitePageviews: typeof WebsiteStats.get_WEBSITEID_Pageviews;
376
+ /** @group Website stats endpoints */
377
+ readonly getWebsiteStats: typeof WebsiteStats.get_WEBSITEID_Stats;
378
+ /** @group Realtime endpoints */
379
+ readonly getRealtime: typeof Realtime.get_WEBSITEID;
380
+ /** @group Reports endpoints */
381
+ readonly getReports: typeof Reports.get;
382
+ /** @group Reports endpoints */
383
+ readonly createReport: typeof Reports.post;
384
+ /** @group Reports endpoints */
385
+ readonly getReport: typeof Reports.get_REPORTID;
386
+ /** @group Reports endpoints */
387
+ readonly updateReport: typeof Reports.post_REPORTID;
388
+ /** @group Reports endpoints */
389
+ readonly deleteReport: typeof Reports.delete_REPORTID;
390
+ /** @group Reports endpoints */
391
+ readonly getReportsAttribution: typeof Reports.postAttribution;
392
+ /** @group Reports endpoints */
393
+ readonly getReportsBreakdown: typeof Reports.postBreakdown;
394
+ /** @group Reports endpoints */
395
+ readonly getReportsFunnel: typeof Reports.postFunnel;
396
+ /** @group Reports endpoints */
397
+ readonly getReportsGoals: typeof Reports.postGoals;
398
+ /** @group Reports endpoints */
399
+ readonly getReportsJourney: typeof Reports.postJourney;
400
+ /** @group Reports endpoints */
401
+ readonly getReportsRetention: typeof Reports.postRetention;
402
+ /** @group Reports endpoints */
403
+ readonly getReportsRevenue: typeof Reports.postRevenue;
404
+ /** @group Reports endpoints */
405
+ readonly getReportsUTM: typeof Reports.postUTM;
406
+ /** @group Sessions endpoints */
407
+ readonly getWebsiteSessions: typeof Sessions.get_WEBSITEID_Sessions;
408
+ /** @group Sessions endpoints */
409
+ readonly getWebsiteSessionsStats: typeof Sessions.get_WEBSITEID_SessionsStats;
410
+ /** @group Sessions endpoints */
411
+ readonly getWebsiteSessionsWeekly: typeof Sessions.get_WEBSITEID_SessionsWeekly;
412
+ /** @group Sessions endpoints */
413
+ readonly getWebsiteSession: typeof Sessions.get_WEBSITEID_Sessions_SESSIONID;
414
+ /** @group Sessions endpoints */
415
+ readonly getWebsiteSessionActivity: typeof Sessions.get_WEBSITEID_Sessions_SESSIONID_Activity;
416
+ /** @group Sessions endpoints */
417
+ readonly getWebsiteSessionProperties: typeof Sessions.get_WEBSITEID_Sessions_SESSIONID_Properties;
418
+ /** @group Sessions endpoints */
419
+ readonly getWebsiteSessionDataProperties: typeof Sessions.get_WEBSITEID_SessiondataProperties;
420
+ /** @group Sessions endpoints */
421
+ readonly getWebsiteSessionDataValues: typeof Sessions.get_WEBSITEID_SessiondataValues;
422
+ /** @group Teams endpoints */
423
+ readonly getTeams: typeof Teams.get;
424
+ /** @group Teams endpoints */
425
+ readonly createTeam: typeof Teams.post;
426
+ /** @group Teams endpoints */
427
+ readonly joinTeam: typeof Teams.postJoin;
428
+ /** @group Teams endpoints */
429
+ readonly getTeam: typeof Teams.get_TEAMID;
430
+ /** @group Teams endpoints */
431
+ readonly updateTeam: typeof Teams.post_TEAMID;
432
+ /** @group Teams endpoints */
433
+ readonly deleteTeam: typeof Teams.delete_TEAMID;
434
+ /** @group Teams endpoints */
435
+ readonly getTeamUsers: typeof Teams.get_TEAMID_Users;
436
+ /** @group Teams endpoints */
437
+ readonly addTeamUser: typeof Teams.post_TEAMID_Users;
438
+ /** @group Teams endpoints */
439
+ readonly getTeamUser: typeof Teams.get_TEAMID_Users_USERID;
440
+ /** @group Teams endpoints */
441
+ readonly updateTeamUser: typeof Teams.post_TEAMID_Users_USERID;
442
+ /** @group Teams endpoints */
443
+ readonly removeTeamUser: typeof Teams.delete_TEAMID_Users_USERID;
444
+ /** @group Teams endpoints */
445
+ readonly getTeamWebsites: typeof Teams.get_TEAMID_Websites;
446
+ /** @group Users endpoints */
447
+ readonly createUser: typeof Users.post;
448
+ /** @group Users endpoints */
449
+ readonly getUser: typeof Users.get_USERID;
450
+ /** @group Users endpoints */
451
+ readonly updateUser: typeof Users.post_USERID;
452
+ /** @group Users endpoints */
453
+ readonly deleteUser: typeof Users.delete_USERID;
454
+ /** @group Users endpoints */
455
+ readonly getUserTeams: typeof Users.get_USERID_Teams;
456
+ /** @group Users endpoints */
457
+ readonly getUserWebsites: typeof Users.get_USERID_Websites;
286
458
  }
package/dist/index.js CHANGED
@@ -1,12 +1,17 @@
1
1
  import { Admin } from "./namespaces/Admin.js";
2
2
  import { Events } from "./namespaces/Events.js";
3
+ import { Links } from "./namespaces/Links.js";
4
+ import { Me } from "./namespaces/Me.js";
5
+ import { Pixels } from "./namespaces/Pixels.js";
3
6
  import { Realtime } from "./namespaces/Realtime.js";
7
+ import { Reports } from "./namespaces/Reports.js";
4
8
  import { Sessions } from "./namespaces/Sessions.js";
5
9
  import { Teams } from "./namespaces/Teams.js";
6
10
  import { Users } from "./namespaces/Users.js";
7
11
  import { Websites } from "./namespaces/Websites.js";
12
+ import { WebsiteStats } from "./namespaces/WebsiteStats.js";
8
13
  import { adaptParametersForGETRequests, correctType } from "./utilities.js";
9
- export { Admin, Users, Teams, Events, Sessions, Websites, Realtime };
14
+ export { Admin, Events, Links, Me, Pixels, Websites, WebsiteStats, Realtime, Reports, Sessions, Teams, Users };
10
15
  /** If the {@link API} throws an error, it should always be an {@link APIError}! */
11
16
  export class APIError extends Error {
12
17
  message;
@@ -111,9 +116,9 @@ export class API {
111
116
  /** If {@link API.setNewToken} has been called, you can wait for it to be done through this promise */
112
117
  token_promise = new Promise(r => r);
113
118
  /**
114
- * This creates a new {@link API.token}, alongside a new {@link API.refresh_token} if arguments are provided or if a refresh_token already exists
119
+ * This contacts the server in order to get and set a new {@link API.token}!
115
120
  * @remarks The API object requires a {@link API.username} and a {@link API.password} to successfully get any token
116
- * @returns Whether or not the token has changed (this should never throw)
121
+ * @returns Whether or not the token has changed (**should be true** as otherwise the server would complain and an {@link APIError} would be thrown to give you some details)
117
122
  */
118
123
  async setNewToken() {
119
124
  const old_token = this.token;
@@ -132,8 +137,8 @@ export class API {
132
137
  this.log(true, "Unable to obtain a token! Here's what was received from the API:", json);
133
138
  reject(new APIError(error_message, this.server, "post", ["auth", "login"], body, response.status));
134
139
  }
135
- this.token_type = json.token_type;
136
140
  this.token = json.token;
141
+ this.user = json.user;
137
142
  const expiration_date = new Date();
138
143
  expiration_date.setDate(expiration_date.getDate() + 1); // Assume 24 hours
139
144
  this.expires = expiration_date;
@@ -376,57 +381,171 @@ export class API {
376
381
  throw new APIError(`${e?.name} (${e?.message ?? e?.errno ?? e?.type})`, this.server, method, endpoint, parameters, undefined, e);
377
382
  }
378
383
  }
379
- async getWebsiteStats(website_id, startAt, endAt) {
380
- return await this.request("get", ["websites", website_id, "stats"], { startAt, endAt });
384
+ // UNCATEGORIZED
385
+ /**
386
+ * To register an event
387
+ * (TODO UNTESTED)
388
+ * @group Sending stats
389
+ */
390
+ async sendStats(payload) {
391
+ return await this.request("post", ["send"], { payload, type: "event" });
381
392
  }
382
393
  // ADMIN
394
+ /** @group Admin endpoints */
383
395
  getUsersAsAdmin = Admin.getUsers;
396
+ /** @group Admin endpoints */
384
397
  getWebsitesAsAdmin = Admin.getWebsites;
398
+ /** @group Admin endpoints */
385
399
  getTeamsAsAdmin = Admin.getTeams;
386
- // USERS
387
- createUser = Users.createUser;
388
- getUser = Users.getUser;
389
- updateUser = Users.updateUser;
390
- deleteUser = Users.deleteUser;
391
- getUserTeams = Users.getUserTeams;
392
- getUserWebsites = Users.getUserWebsites;
393
- // TEAMS
394
- getTeams = Teams.getTeams;
395
- createTeam = Teams.createTeam;
396
- joinTeam = Teams.joinTeam;
397
- getTeam = Teams.getTeam;
398
- updateTeam = Teams.updateTeam;
399
- deleteTeam = Teams.deleteTeam;
400
- getTeamUsers = Teams.getTeamUsers;
401
- addTeamUser = Teams.addTeamUser;
402
- getTeamUser = Teams.getTeamUser;
403
- updateTeamUser = Teams.updateTeamUser;
404
- removeTeamUser = Teams.removeTeamUser;
405
- getTeamWebsites = Teams.getTeamWebsites;
406
400
  // EVENTS
407
- getWebsiteEvents = Events.getWebsiteEvents;
408
- getWebsiteEventData = Events.getWebsiteEventData;
409
- getWebsiteEventsData = Events.getWebsiteEventsData;
410
- getWebsiteEventsDataFields = Events.getWebsiteEventsDataFields;
411
- getWebsiteEventsDataProperties = Events.getWebsiteEventsDataProperties;
412
- getWebsiteEventsDataValues = Events.getWebsiteEventsDataValues;
413
- getWebsiteEventsDataStats = Events.getWebsiteEventsDataStats;
414
- // SESSIONS
415
- getWebsiteSessions = Sessions.getWebsiteSessions;
416
- getWebsiteSessionsStats = Sessions.getWebsiteSessionsStats;
417
- getWebsiteSessionsWeekly = Sessions.getWebsiteSessionsWeekly;
418
- getWebsiteSession = Sessions.getWebsiteSession;
419
- getWebsiteSessionActivity = Sessions.getWebsiteSessionActivity;
420
- getWebsiteSessionProperties = Sessions.getWebsiteSessionProperties;
421
- getWebsiteSessionDataProperties = Sessions.getWebsiteSessionDataProperties;
422
- getWebsiteSessionDataValues = Sessions.getWebsiteSessionDataValues;
401
+ /** @group Events endpoints */
402
+ getWebsiteEvents = Events.get_WEBSITEID_Events;
403
+ /** @group Events endpoints */
404
+ getWebsiteEventData = Events.get_WEBSITEID_Eventdata_EVENTID;
405
+ /** @group Events endpoints */
406
+ getWebsiteEventsData = Events.get_WEBSITEID_EventdataEvents;
407
+ /** @group Events endpoints */
408
+ getWebsiteEventsDataFields = Events.get_WEBSITEID_EventdataFields;
409
+ /** @group Events endpoints */
410
+ getWebsiteEventsDataProperties = Events.get_WEBSITEID_EventdataProperties;
411
+ /** @group Events endpoints */
412
+ getWebsiteEventsDataValues = Events.get_WEBSITEID_EventdataValues;
413
+ /** @group Events endpoints */
414
+ getWebsiteEventsDataStats = Events.get_WEBSITEID_EventdataStats;
415
+ // LINKS
416
+ /** @group Links endpoints */
417
+ getLinks = Links.get;
418
+ /** @group Links endpoints */
419
+ getLink = Links.get_LINKID;
420
+ /** @group Links endpoints */
421
+ updateLink = Links.post_LINKID;
422
+ /** @group Links endpoints */
423
+ deleteLink = Links.delete_LINKID;
424
+ // ME
425
+ /** @group Me endpoints */
426
+ getMyself = Me.get;
427
+ /** @group Me endpoints */
428
+ getMyTeams = Me.getTeams;
429
+ /** @group Me endpoints */
430
+ getMyWebsites = Me.getWebsites;
431
+ // PIXELS
432
+ /** @group Links endpoints */
433
+ getPixels = Pixels.get;
434
+ /** @group Links endpoints */
435
+ getPixel = Pixels.get_PIXELID;
436
+ /** @group Links endpoints */
437
+ updatePixel = Pixels.post_PIXELID;
438
+ /** @group Links endpoints */
439
+ deletePixel = Pixels.delete_PIXELID;
423
440
  // WEBSITES
424
- getWebsites = Websites.getWebsites;
425
- createWebsite = Websites.createWebsite;
426
- getWebsite = Websites.getWebsite;
427
- updateWebsite = Websites.updateWebsite;
428
- deleteWebsite = Websites.deleteWebsite;
429
- resetWebsite = Websites.resetWebsite;
441
+ /** @group Websites endpoints */
442
+ getWebsites = Websites.get;
443
+ /** @group Websites endpoints */
444
+ createWebsite = Websites.post;
445
+ /** @group Websites endpoints */
446
+ getWebsite = Websites.get_WEBSITEID;
447
+ /** @group Websites endpoints */
448
+ updateWebsite = Websites.post_WEBSITEID;
449
+ /** @group Websites endpoints */
450
+ deleteWebsite = Websites.delete_WEBSITEID;
451
+ /** @group Websites endpoints */
452
+ resetWebsite = Websites.post_WEBSITEID_Reset;
453
+ // WEBSITE STATS
454
+ /** @group Website stats endpoints */
455
+ getWebsiteActiveVisitors = WebsiteStats.get_WEBSITEID_Active;
456
+ /** @group Website stats endpoints */
457
+ getWebsiteEventsStats = WebsiteStats.get_WEBSITEID_EventsSeries;
458
+ /** @group Website stats endpoints */
459
+ getWebsiteMetrics = WebsiteStats.get_WEBSITEID_Metrics;
460
+ /** @group Website stats endpoints */
461
+ getWebsiteMetricsExpanded = WebsiteStats.get_WEBSITEID_MetricsExpanded;
462
+ /** @group Website stats endpoints */
463
+ getWebsitePageviews = WebsiteStats.get_WEBSITEID_Pageviews;
464
+ /** @group Website stats endpoints */
465
+ getWebsiteStats = WebsiteStats.get_WEBSITEID_Stats;
430
466
  // REALTIME
431
- getRealtime = Realtime.getRealtime;
467
+ /** @group Realtime endpoints */
468
+ getRealtime = Realtime.get_WEBSITEID;
469
+ // REPORTS
470
+ /** @group Reports endpoints */
471
+ getReports = Reports.get;
472
+ /** @group Reports endpoints */
473
+ createReport = Reports.post;
474
+ /** @group Reports endpoints */
475
+ getReport = Reports.get_REPORTID;
476
+ /** @group Reports endpoints */
477
+ updateReport = Reports.post_REPORTID;
478
+ /** @group Reports endpoints */
479
+ deleteReport = Reports.delete_REPORTID;
480
+ /** @group Reports endpoints */
481
+ getReportsAttribution = Reports.postAttribution;
482
+ /** @group Reports endpoints */
483
+ getReportsBreakdown = Reports.postBreakdown;
484
+ /** @group Reports endpoints */
485
+ getReportsFunnel = Reports.postFunnel;
486
+ /** @group Reports endpoints */
487
+ getReportsGoals = Reports.postGoals;
488
+ /** @group Reports endpoints */
489
+ getReportsJourney = Reports.postJourney;
490
+ /** @group Reports endpoints */
491
+ getReportsRetention = Reports.postRetention;
492
+ /** @group Reports endpoints */
493
+ getReportsRevenue = Reports.postRevenue;
494
+ /** @group Reports endpoints */
495
+ getReportsUTM = Reports.postUTM;
496
+ // SESSIONS
497
+ /** @group Sessions endpoints */
498
+ getWebsiteSessions = Sessions.get_WEBSITEID_Sessions;
499
+ /** @group Sessions endpoints */
500
+ getWebsiteSessionsStats = Sessions.get_WEBSITEID_SessionsStats;
501
+ /** @group Sessions endpoints */
502
+ getWebsiteSessionsWeekly = Sessions.get_WEBSITEID_SessionsWeekly;
503
+ /** @group Sessions endpoints */
504
+ getWebsiteSession = Sessions.get_WEBSITEID_Sessions_SESSIONID;
505
+ /** @group Sessions endpoints */
506
+ getWebsiteSessionActivity = Sessions.get_WEBSITEID_Sessions_SESSIONID_Activity;
507
+ /** @group Sessions endpoints */
508
+ getWebsiteSessionProperties = Sessions.get_WEBSITEID_Sessions_SESSIONID_Properties;
509
+ /** @group Sessions endpoints */
510
+ getWebsiteSessionDataProperties = Sessions.get_WEBSITEID_SessiondataProperties;
511
+ /** @group Sessions endpoints */
512
+ getWebsiteSessionDataValues = Sessions.get_WEBSITEID_SessiondataValues;
513
+ // TEAMS
514
+ /** @group Teams endpoints */
515
+ getTeams = Teams.get;
516
+ /** @group Teams endpoints */
517
+ createTeam = Teams.post;
518
+ /** @group Teams endpoints */
519
+ joinTeam = Teams.postJoin;
520
+ /** @group Teams endpoints */
521
+ getTeam = Teams.get_TEAMID;
522
+ /** @group Teams endpoints */
523
+ updateTeam = Teams.post_TEAMID;
524
+ /** @group Teams endpoints */
525
+ deleteTeam = Teams.delete_TEAMID;
526
+ /** @group Teams endpoints */
527
+ getTeamUsers = Teams.get_TEAMID_Users;
528
+ /** @group Teams endpoints */
529
+ addTeamUser = Teams.post_TEAMID_Users;
530
+ /** @group Teams endpoints */
531
+ getTeamUser = Teams.get_TEAMID_Users_USERID;
532
+ /** @group Teams endpoints */
533
+ updateTeamUser = Teams.post_TEAMID_Users_USERID;
534
+ /** @group Teams endpoints */
535
+ removeTeamUser = Teams.delete_TEAMID_Users_USERID;
536
+ /** @group Teams endpoints */
537
+ getTeamWebsites = Teams.get_TEAMID_Websites;
538
+ // USERS
539
+ /** @group Users endpoints */
540
+ createUser = Users.post;
541
+ /** @group Users endpoints */
542
+ getUser = Users.get_USERID;
543
+ /** @group Users endpoints */
544
+ updateUser = Users.post_USERID;
545
+ /** @group Users endpoints */
546
+ deleteUser = Users.delete_USERID;
547
+ /** @group Users endpoints */
548
+ getUserTeams = Users.get_USERID_Teams;
549
+ /** @group Users endpoints */
550
+ getUserWebsites = Users.get_USERID_Websites;
432
551
  }
@@ -1,42 +1,23 @@
1
- import { API, GenericObject, GenericRequestParameters, Role, Teams } from "../index.js";
2
- /** For endpoints listed on: https://umami.is/docs/api/admin-api */
1
+ import { API, GenericObject, GenericRequestParameters, MinimalUser, Role, Teams, Website } from "../index.js";
2
+ /** Operations around admin management: https://umami.is/docs/api/admin */
3
3
  export declare namespace Admin {
4
- /** Returns all users: https://umami.is/docs/api/admin-api#get-apiadminusers */
4
+ /** Returns all users: https://umami.is/docs/api/admin#get-apiadminusers */
5
5
  function getUsers(this: API, parameters?: GenericRequestParameters): Promise<(GenericObject & {
6
6
  username: string;
7
- /** @remarks **UNDOCUMENTED** & seems encrypted (thankfully, lol) */
8
- password: string;
9
7
  role: Role;
10
8
  logoUrl: string | null;
11
9
  displayName: string | null;
12
10
  _count: {
13
- /** @remarks **UNDOCUMENTED**, documented uncorrectly as `websites`? */
14
- websiteUser: number;
11
+ websites: number;
15
12
  };
16
13
  })[]>;
17
- /**
18
- * Returns all websites: https://umami.is/docs/api/admin-api#get-apiadminwebsites
19
- * @remarks TODO Possibly doesn't work? (throws 400 on my end)
20
- */
21
- function getWebsites(this: API, parameters?: GenericRequestParameters): Promise<(GenericObject & {
22
- name: string;
23
- domain: string;
24
- shareId: number | null;
25
- resetAt: Date | null;
26
- userId: string;
27
- teamid: string | null;
28
- createdBy: string;
29
- user: {
30
- username: string;
31
- id: string;
32
- };
14
+ /** Returns all websites: https://umami.is/docs/api/admin#get-apiadminwebsites */
15
+ function getWebsites(this: API, parameters?: GenericRequestParameters): Promise<(Website & {
16
+ user: MinimalUser;
33
17
  /** @remarks TODO Documentation says it can be null but doesn't actually say what else it can be, ***presumed* to be string**, check */
34
18
  team: string | null;
35
19
  })[]>;
36
- /**
37
- * Returns all teams: https://umami.is/docs/api/admin-api#get-apiadminteams
38
- * @remarks TODO Possibly doesn't work? (throws 404 on my end)
39
- */
20
+ /** Returns all teams: https://umami.is/docs/api/admin#get-apiadminteams */
40
21
  function getTeams(this: API, parameters?: GenericRequestParameters): Promise<(GenericObject & {
41
22
  name: string;
42
23
  accessCode: string;