umami-api-js 0.1.2 → 0.1.4

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 v3.0.1](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](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
- 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.2**, so make sure your package is up to date! Report any bug on [Codeberg](https://codeberg.org/Taevas/umami-api-js/issues).
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.4**, 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 note that this package is expected to work with self-hosted instances of **Umami v3.0.1**, and is *not* expected to work with [Umami Cloud](https://umami.is/docs/cloud), the instance of Umami hosted by its creators.
5
+ Please note that this package is expected to work with self-hosted instances of **Umami v3.0.3**, 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
@@ -11,26 +11,9 @@ import { Users } from "./namespaces/Users.js";
11
11
  import { Websites } from "./namespaces/Websites.js";
12
12
  import { WebsiteStats } from "./namespaces/WebsiteStats.js";
13
13
  export { Admin, Events, Links, Me, Pixels, Websites, WebsiteStats, Realtime, Reports, Sessions, Teams, Users };
14
- export interface GenericObject {
15
- id: string;
16
- createdAt: Date;
17
- updatedAt: Date | null;
18
- deletedAt: Date | null;
19
- }
20
14
  export interface DeletionResult {
21
15
  ok: boolean;
22
16
  }
23
- export interface Report extends Omit<GenericObject, "deletedAt"> {
24
- userId: Users.User["id"];
25
- websiteId: Websites.Website["id"];
26
- type: string;
27
- name: string;
28
- description: string;
29
- parameters: {
30
- type: string;
31
- value: string;
32
- };
33
- }
34
17
  export interface NameValue {
35
18
  name: string;
36
19
  value: number;
package/dist/index.js CHANGED
@@ -140,6 +140,7 @@ export class API {
140
140
  this.log(true, "Unable to obtain a token! Here's what was received from the API:", json);
141
141
  reject(new APIError(error_message, this.server, "post", ["auth", "login"], body, response.status));
142
142
  }
143
+ // Note: `json` currently only has `token` & `user`
143
144
  this.token = json.token;
144
145
  this.user = json.user;
145
146
  const expiration_date = new Date();
@@ -1,16 +1,8 @@
1
- import { API, GenericObject, GenericRequestParameters, Teams, Users, Websites } from "../index.js";
1
+ import { API, GenericRequestParameters, Teams, Users, Websites } from "../index.js";
2
2
  /** Operations around admin management: https://umami.is/docs/api/admin */
3
3
  export declare namespace Admin {
4
4
  /** Returns all users: https://umami.is/docs/api/admin#get-apiadminusers */
5
- function getUsers(this: API, parameters?: GenericRequestParameters): Promise<(GenericObject & {
6
- username: string;
7
- role: Users.Role;
8
- logoUrl: string | null;
9
- displayName: string | null;
10
- _count: {
11
- websites: number;
12
- };
13
- })[]>;
5
+ function getUsers(this: API, parameters?: GenericRequestParameters): Promise<Users.DetailedUser[]>;
14
6
  /** Returns all websites: https://umami.is/docs/api/admin#get-apiadminwebsites */
15
7
  function getWebsites(this: API, parameters?: GenericRequestParameters): Promise<(Websites.WebsiteWithUser & {
16
8
  /** @remarks TODO Documentation says it can be null but doesn't actually say what else it can be, ***presumed* to be string**, check */
@@ -1,10 +1,10 @@
1
- import { API, Filters, GenericRequestParameters, Timestamps, Websites } from "../index.js";
1
+ import { API, Filters, GenericRequestParameters, Sessions, Timestamps, Websites } from "../index.js";
2
2
  /** Operations around Events and Event data: https://umami.is/docs/api/events */
3
3
  export declare namespace Events {
4
4
  interface Event {
5
5
  id: string;
6
6
  websiteId: Websites.Website["id"];
7
- sessionId: string;
7
+ sessionId: Sessions.Session["id"];
8
8
  createdAt: Date;
9
9
  hostname: string;
10
10
  urlPath: string;
@@ -27,7 +27,7 @@ export declare namespace Events {
27
27
  /** Gets event-data for a individual event: https://umami.is/docs/api/events#get-apiwebsiteswebsiteidevent-dataeventid */
28
28
  function get_WEBSITEID_Eventdata_EVENTID(this: API, websiteId: Websites.Website["id"], eventId: Event["id"]): Promise<{
29
29
  websiteId: Websites.Website["id"];
30
- sessionId?: string;
30
+ sessionId?: Sessions.Session["id"];
31
31
  eventId: Event["id"];
32
32
  urlPath?: string;
33
33
  eventName: Event["eventName"];
@@ -1,12 +1,16 @@
1
- import { API, DeletionResult, GenericObject, GenericRequestParameters, Users } from "../index.js";
1
+ import { API, DeletionResult, GenericRequestParameters, Users } from "../index.js";
2
2
  /** Operations around Links management: https://umami.is/docs/api/links */
3
3
  export declare namespace Links {
4
- interface Link extends GenericObject {
4
+ interface Link {
5
+ id: string;
5
6
  name: string;
6
7
  url: string;
7
8
  slug: string;
8
9
  userId: Users.User["id"];
9
- teamid: string | null;
10
+ teamId: string | null;
11
+ createdAt: Date;
12
+ updatedAt: Date;
13
+ deletedAt: Date | null;
10
14
  }
11
15
  /** Returns all user links: https://umami.is/docs/api/links#get-apilinks (TODO UNTESTED) */
12
16
  function get(this: API, parameters?: GenericRequestParameters): Promise<Link[]>;
@@ -1,24 +1,16 @@
1
- import { API, GenericObject, Teams, Users } from "../index.js";
1
+ import { API, Teams, Users, Websites } from "../index.js";
2
2
  /** All information about your session: https://umami.is/docs/api/me */
3
3
  export declare namespace Me {
4
- /** Get information based on your auth token: https://umami.is/docs/api/me#get-apime */
5
- function get(this: API): Promise<{
6
- token: string;
4
+ interface TokenInformation {
5
+ token: API["token"];
7
6
  authKey: string;
8
7
  shareToken: string | null;
9
8
  user: Users.User;
10
- }>;
9
+ }
10
+ /** Get information based on your auth token: https://umami.is/docs/api/me#get-apime */
11
+ function get(this: API): Promise<TokenInformation>;
11
12
  /** Get all your teams: https://umami.is/docs/api/me#get-apimeteams */
12
13
  function getTeams(this: API): Promise<Teams.TeamWithMembersCount[]>;
13
14
  /** Get all your websites: https://umami.is/docs/api/me#get-apimeteams */
14
- function getWebsites(this: API): Promise<(GenericObject & {
15
- name: string;
16
- domain: string;
17
- shareId: string | null;
18
- resetAt: Date | null;
19
- userId: Users.User["id"];
20
- teamId: string | null;
21
- createdBy: string;
22
- user: Users.MinimalUser;
23
- })[]>;
15
+ function getWebsites(this: API): Promise<Websites.WebsiteWithUser[]>;
24
16
  }
@@ -1,11 +1,15 @@
1
- import { API, DeletionResult, GenericObject, GenericRequestParameters, Users } from "../index.js";
1
+ import { API, DeletionResult, GenericRequestParameters, Users } from "../index.js";
2
2
  /** Operations around Pixels management: https://umami.is/docs/api/pixels */
3
3
  export declare namespace Pixels {
4
- interface Pixel extends GenericObject {
4
+ interface Pixel {
5
+ id: string;
5
6
  name: string;
6
7
  slug: string;
7
8
  userId: Users.User["id"];
8
- teamid: string | null;
9
+ teamId: string | null;
10
+ createdAt: Date;
11
+ updatedAt: Date;
12
+ deletedAt: Date | null;
9
13
  }
10
14
  /** Returns all user pixels: https://umami.is/docs/api/pixels#get-apipixels (TODO UNTESTED) */
11
15
  function get(this: API, parameters?: GenericRequestParameters): Promise<Pixel[]>;
@@ -1,7 +1,7 @@
1
- import { API, Websites } from "../index.js";
1
+ import { API, Sessions, Websites } from "../index.js";
2
2
  /** Realtime data for your website: https://umami.is/docs/api/realtime */
3
3
  export declare namespace Realtime {
4
- /** Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime#get-apirealtimewebsiteid (TODO UNTESTED) */
4
+ /** Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime#get-apirealtimewebsiteid */
5
5
  function get_WEBSITEID(this: API, websiteId: Websites.Website["id"]): Promise<{
6
6
  countries: {
7
7
  [k: string]: number;
@@ -14,7 +14,7 @@ export declare namespace Realtime {
14
14
  };
15
15
  events: {
16
16
  __type: string;
17
- sessionId: string;
17
+ sessionId: Sessions.Session["id"];
18
18
  eventName: string;
19
19
  createdAt: Date;
20
20
  browser: string;
@@ -1,9 +1,9 @@
1
1
  /** Realtime data for your website: https://umami.is/docs/api/realtime */
2
2
  export var Realtime;
3
3
  (function (Realtime) {
4
- /** Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime#get-apirealtimewebsiteid (TODO UNTESTED) */
4
+ /** Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime#get-apirealtimewebsiteid */
5
5
  async function get_WEBSITEID(websiteId) {
6
- return await this.request("post", ["realtime", websiteId]);
6
+ return await this.request("get", ["realtime", websiteId]);
7
7
  }
8
8
  Realtime.get_WEBSITEID = get_WEBSITEID;
9
9
  })(Realtime || (Realtime = {}));
@@ -1,6 +1,20 @@
1
- import { API, DeletionResult, Filters, GenericRequestParameters, NameValue, Report, Timestamps, Websites, XTY } from "../index.js";
1
+ import { API, DeletionResult, Filters, GenericRequestParameters, NameValue, Timestamps, Users, Websites, XTY } from "../index.js";
2
2
  /** Using reports throught the api: https://umami.is/docs/api/reports */
3
3
  export declare namespace Reports {
4
+ interface Report {
5
+ id: string;
6
+ userId: Users.User["id"];
7
+ websiteId: Websites.Website["id"];
8
+ type: ReportType;
9
+ name: string;
10
+ description: string;
11
+ parameters: {
12
+ type: string;
13
+ value: string;
14
+ };
15
+ createdAt: Date;
16
+ updatedAt: Date;
17
+ }
4
18
  type ReportType = {
5
19
  type: "attribution" | "breakdown" | "funnel" | "goal" | "journey" | "retention" | "revenue" | "utm";
6
20
  };
@@ -13,25 +27,25 @@ export declare namespace Reports {
13
27
  /** Creates a report: https://umami.is/docs/api/reports#post-apireports (TODO UNTESTED) */
14
28
  function post(this: API, websiteId: Websites.Website["id"], parameters: ReportType & {
15
29
  /** Name of report */
16
- name: string;
30
+ name: Report["name"];
17
31
  /** Description of report */
18
- description?: string;
32
+ description?: Report["description"];
19
33
  /** Parameters for report */
20
34
  parameters?: any;
21
35
  }): Promise<Report>;
22
36
  /** Gets a report by ID: https://umami.is/docs/api/reports#get-apireportsreportid (TODO UNTESTED) */
23
- function get_REPORTID(this: API, reportId: string): Promise<Report>;
37
+ function get_REPORTID(this: API, reportId: Report["id"]): Promise<Report>;
24
38
  /** Updates a report: https://umami.is/docs/api/reports#post-apireportsreportid (TODO UNTESTED) */
25
- function post_REPORTID(this: API, reportId: string, websiteId: Websites.Website["id"], parameters: ReportType & {
39
+ function post_REPORTID(this: API, reportId: Report["id"], websiteId: Websites.Website["id"], parameters: ReportType & {
26
40
  /** Name of report */
27
- name: string;
41
+ name: Report["name"];
28
42
  /** Description of report */
29
- description?: string;
43
+ description?: Report["description"];
30
44
  /** Parameters for report */
31
45
  parameters?: any;
32
46
  }): Promise<Report>;
33
47
  /** Deletes a report: https://umami.is/docs/api/reports#delete-apireportsreportid (TODO UNTESTED) */
34
- function delete_REPORTID(this: API, reportId: string): Promise<DeletionResult>;
48
+ function delete_REPORTID(this: API, reportId: Report["id"]): Promise<DeletionResult>;
35
49
  /** See how users engage with your marketing and what drives conversions: https://umami.is/docs/api/reports#post-apireportsattribution (TODO UNTESTED) */
36
50
  function postAttribution(this: API, websiteId: Websites.Website["id"], parameters: ReportType & Filters & Timestamps & {
37
51
  /** Attribution model */
@@ -1,14 +1,14 @@
1
- import { API, Filters, GenericRequestParameters, Timestamps, Websites } from "../index.js";
1
+ import { API, Events, Filters, GenericRequestParameters, Timestamps, Websites } from "../index.js";
2
2
  /** Operations around Sessions and Session data: https://umami.is/docs/api/sessions */
3
3
  export declare namespace Sessions {
4
- interface GenericSession {
4
+ interface Session {
5
5
  id: string;
6
6
  websiteId: Websites.Website["id"];
7
- browser: string;
8
- os: string;
7
+ browser: string | null;
8
+ os: string | null;
9
9
  device: string;
10
10
  screen: string;
11
- language: string;
11
+ language: string | null;
12
12
  country: string;
13
13
  region: string;
14
14
  city: string;
@@ -17,12 +17,18 @@ export declare namespace Sessions {
17
17
  visits: number;
18
18
  views: number;
19
19
  }
20
- /** Gets website session details within a given time range: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessions (TODO UNTESTED) */
21
- function get_WEBSITEID_Sessions(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & GenericRequestParameters): Promise<(GenericSession & {
20
+ interface SessionWithHostnameCreatedat extends Session {
22
21
  hostname: string;
23
22
  createdAt: Date;
24
- })[]>;
25
- /** Gets summarized website session statistics: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsstats (TODO UNTESTED) */
23
+ }
24
+ interface SessionWithDistinctidEventsTotaltime extends Session {
25
+ distinctId: string | null;
26
+ events: number;
27
+ totaltime: number;
28
+ }
29
+ /** Gets website session details within a given time range: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessions */
30
+ function get_WEBSITEID_Sessions(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & GenericRequestParameters): Promise<SessionWithHostnameCreatedat[]>;
31
+ /** Gets summarized website session statistics: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsstats */
26
32
  function get_WEBSITEID_SessionsStats(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<{
27
33
  /** Pages hits */
28
34
  pageviews: {
@@ -36,41 +42,51 @@ export declare namespace Sessions {
36
42
  visits: {
37
43
  value: number;
38
44
  };
39
- /** Number of visitors who only visit a single page */
40
- bounces: {
45
+ /** @remarks Undocumented */
46
+ countries: {
47
+ value: number;
48
+ };
49
+ /** @remarks Undocumented */
50
+ events: {
41
51
  value: number;
42
52
  };
43
- /** Time spent on the website */
44
- totaltime: {
53
+ /**
54
+ * Number of visitors who only visit a single page
55
+ * @remarks While featured in the documentation, it doesn't seem to exist
56
+ */
57
+ bounces?: {
58
+ value: number;
59
+ };
60
+ /**
61
+ * Time spent on the website
62
+ * @remarks While featured in the documentation, it doesn't seem to exist
63
+ */
64
+ totaltime?: {
45
65
  value: number;
46
66
  };
47
67
  }>;
48
- /** Get collected count of sessions by hour of weekday: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsweekly (TODO UNTESTED) */
68
+ /** Get collected count of sessions by hour of weekday: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsweekly */
49
69
  function get_WEBSITEID_SessionsWeekly(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & {
50
70
  timezone: string;
51
71
  }): Promise<number[][]>;
52
- /** Gets session details for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionid (TODO UNTESTED) */
53
- function get_WEBSITEID_Sessions_SESSIONID(this: API, websiteId: Websites.Website["id"], sessionId: string): Promise<GenericSession & {
54
- distinctId: string;
55
- events: number;
56
- totaltime: number;
57
- }>;
58
- /** Gets session activity for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidactivity (TODO UNTESTED) */
59
- function get_WEBSITEID_Sessions_SESSIONID_Activity(this: API, websiteId: Websites.Website["id"], sessionId: string, parameters: Timestamps): Promise<{
72
+ /** Gets session details for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionid */
73
+ function get_WEBSITEID_Sessions_SESSIONID(this: API, websiteId: Websites.Website["id"], sessionId: Session["id"]): Promise<SessionWithDistinctidEventsTotaltime>;
74
+ /** Gets session activity for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidactivity */
75
+ function get_WEBSITEID_Sessions_SESSIONID_Activity(this: API, websiteId: Websites.Website["id"], sessionId: Session["id"], parameters: Timestamps): Promise<{
60
76
  createdAt: Date;
61
77
  urlPath: string;
62
78
  urlQuery: string;
63
- referrerDomain: string;
64
- eventId: string;
65
- eventType: number;
66
- eventName: string;
79
+ referrerDomain: string | null;
80
+ eventId: Events.Event["id"];
81
+ eventType: Events.Event["eventType"];
82
+ eventName: Events.Event["eventName"] | null;
67
83
  visitId: string;
68
- hasData: number;
84
+ hasData: boolean;
69
85
  }[]>;
70
- /** Gets session properties for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidproperties (TODO UNTESTED) */
71
- function get_WEBSITEID_Sessions_SESSIONID_Properties(this: API, websiteId: Websites.Website["id"], sessionId: string): Promise<{
86
+ /** Gets session properties for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidproperties (TODO Server returns empty array) */
87
+ function get_WEBSITEID_Sessions_SESSIONID_Properties(this: API, websiteId: Websites.Website["id"], sessionId: Session["id"]): Promise<{
72
88
  websiteId: Websites.Website["id"];
73
- sessionid: string;
89
+ sessionId: Session["id"];
74
90
  dataKey: string;
75
91
  dataType: number;
76
92
  stringValue: string;
@@ -78,12 +94,12 @@ export declare namespace Sessions {
78
94
  dateValue: Date | null;
79
95
  createdAt: Date;
80
96
  }[]>;
81
- /** Gets session data counts by property name: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-dataproperties (TODO UNTESTED) */
97
+ /** Gets session data counts by property name: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-dataproperties (TODO Server returns empty array) */
82
98
  function get_WEBSITEID_SessiondataProperties(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps): Promise<{
83
99
  propertyName: string;
84
100
  total: number;
85
101
  }[]>;
86
- /** Gets session data counts for a given property: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-datavalues (TODO UNTESTED) */
102
+ /** Gets session data counts for a given property: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-datavalues (TODO Server returns empty array) */
87
103
  function get_WEBSITEID_SessiondataValues(this: API, websiteId: Websites.Website["id"], parameters: Filters & Timestamps & {
88
104
  propertyName: string;
89
105
  }): Promise<{
@@ -1,43 +1,45 @@
1
1
  /** Operations around Sessions and Session data: https://umami.is/docs/api/sessions */
2
2
  export var Sessions;
3
3
  (function (Sessions) {
4
- /** Gets website session details within a given time range: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessions (TODO UNTESTED) */
4
+ /** Gets website session details within a given time range: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessions */
5
5
  async function get_WEBSITEID_Sessions(websiteId, parameters) {
6
6
  const response = await this.request("get", ["websites", websiteId, "sessions"], parameters);
7
7
  return response.data;
8
8
  }
9
9
  Sessions.get_WEBSITEID_Sessions = get_WEBSITEID_Sessions;
10
- /** Gets summarized website session statistics: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsstats (TODO UNTESTED) */
10
+ /** Gets summarized website session statistics: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsstats */
11
11
  async function get_WEBSITEID_SessionsStats(websiteId, parameters) {
12
- return await this.request("get", ["websites", websiteId, "sessions"], parameters);
12
+ const response = await this.request("get", ["websites", websiteId, "sessions", "stats"], parameters);
13
+ Object.values(response).forEach((v) => { v.value = Number(v.value); });
14
+ return response;
13
15
  }
14
16
  Sessions.get_WEBSITEID_SessionsStats = get_WEBSITEID_SessionsStats;
15
- /** Get collected count of sessions by hour of weekday: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsweekly (TODO UNTESTED) */
17
+ /** Get collected count of sessions by hour of weekday: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionsweekly */
16
18
  async function get_WEBSITEID_SessionsWeekly(websiteId, parameters) {
17
19
  return await this.request("get", ["websites", websiteId, "sessions", "weekly"], parameters);
18
20
  }
19
21
  Sessions.get_WEBSITEID_SessionsWeekly = get_WEBSITEID_SessionsWeekly;
20
- /** Gets session details for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionid (TODO UNTESTED) */
22
+ /** Gets session details for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionid */
21
23
  async function get_WEBSITEID_Sessions_SESSIONID(websiteId, sessionId) {
22
24
  return await this.request("get", ["websites", websiteId, "sessions", sessionId]);
23
25
  }
24
26
  Sessions.get_WEBSITEID_Sessions_SESSIONID = get_WEBSITEID_Sessions_SESSIONID;
25
- /** Gets session activity for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidactivity (TODO UNTESTED) */
27
+ /** Gets session activity for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidactivity */
26
28
  async function get_WEBSITEID_Sessions_SESSIONID_Activity(websiteId, sessionId, parameters) {
27
29
  return await this.request("get", ["websites", websiteId, "sessions", sessionId, "activity"], parameters);
28
30
  }
29
31
  Sessions.get_WEBSITEID_Sessions_SESSIONID_Activity = get_WEBSITEID_Sessions_SESSIONID_Activity;
30
- /** Gets session properties for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidproperties (TODO UNTESTED) */
32
+ /** Gets session properties for a individual session: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsessionssessionidproperties (TODO Server returns empty array) */
31
33
  async function get_WEBSITEID_Sessions_SESSIONID_Properties(websiteId, sessionId) {
32
- return await this.request("get", ["websites", websiteId, "sessions", sessionId, "activity", "properties"]);
34
+ return await this.request("get", ["websites", websiteId, "sessions", sessionId, "properties"]);
33
35
  }
34
36
  Sessions.get_WEBSITEID_Sessions_SESSIONID_Properties = get_WEBSITEID_Sessions_SESSIONID_Properties;
35
- /** Gets session data counts by property name: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-dataproperties (TODO UNTESTED) */
37
+ /** Gets session data counts by property name: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-dataproperties (TODO Server returns empty array) */
36
38
  async function get_WEBSITEID_SessiondataProperties(websiteId, parameters) {
37
39
  return await this.request("get", ["websites", websiteId, "session-data", "properties"], parameters);
38
40
  }
39
41
  Sessions.get_WEBSITEID_SessiondataProperties = get_WEBSITEID_SessiondataProperties;
40
- /** Gets session data counts for a given property: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-datavalues (TODO UNTESTED) */
42
+ /** Gets session data counts for a given property: https://umami.is/docs/api/sessions#get-apiwebsiteswebsiteidsession-datavalues (TODO Server returns empty array) */
41
43
  async function get_WEBSITEID_SessiondataValues(websiteId, parameters) {
42
44
  return await this.request("get", ["websites", websiteId, "session-data", "values"], parameters);
43
45
  }
@@ -7,7 +7,7 @@ export declare namespace Teams {
7
7
  accessCode: string;
8
8
  logoUrl: string | null;
9
9
  createdAt: Date;
10
- updatedAt: Date | null;
10
+ updatedAt: Date;
11
11
  deletedAt: Date | null;
12
12
  }
13
13
  interface TeamMember {
@@ -30,41 +30,42 @@ export declare namespace Teams {
30
30
  members: number;
31
31
  };
32
32
  }
33
- type TeamRole = "team-manager" | "team-member" | "team-view-only";
34
- /** Returns all teams: https://umami.is/docs/api/teams#get-apiteams (TODO UNTESTED) */
33
+ type TeamRole = "team-owner" | "team-manager" | "team-member" | "team-view-only";
34
+ /** Returns all teams: https://umami.is/docs/api/teams#get-apiteams */
35
35
  function get(this: API, parameters?: Omit<GenericRequestParameters, "search">): Promise<TeamWithMembersCount[]>;
36
- /** Creates a team: https://umami.is/docs/api/teams#post-apiteams (TODO UNTESTED) */
37
- function post(this: API, name: string): Promise<[Team, TeamMember]>;
38
- /** Join a team: https://umami.is/docs/api/teams#post-apiteamsjoin (TODO UNTESTED) */
39
- function postJoin(this: API, accessCode: string): Promise<TeamMember>;
40
- /** Get a team: https://umami.is/docs/api/teams#get-apiteamsteamid (TODO UNTESTED) */
41
- function get_TEAMID(this: API, teamId: string): Promise<Team & {
42
- members: TeamMember[];
43
- }>;
44
- /** Update a team: https://umami.is/docs/api/teams#post-apiteamsteamid (TODO UNTESTED) */
45
- function post_TEAMID(this: API, teamId: string, parameters: {
36
+ /**
37
+ * Creates a team: https://umami.is/docs/api/teams#post-apiteams
38
+ * @returns An Array where its first element is the created team, and its second element is its owner
39
+ */
40
+ function post(this: API, name: Team["name"]): Promise<[Team, TeamMember]>;
41
+ /** Join a team: https://umami.is/docs/api/teams#post-apiteamsjoin */
42
+ function postJoin(this: API, accessCode: Team["accessCode"]): Promise<TeamMember>;
43
+ /** Get a team: https://umami.is/docs/api/teams#get-apiteamsteamid */
44
+ function get_TEAMID(this: API, teamId: Team["id"]): Promise<TeamWithMembers>;
45
+ /** Update a team: https://umami.is/docs/api/teams#post-apiteamsteamid */
46
+ function post_TEAMID(this: API, teamId: Team["id"], parameters: {
46
47
  /** The team's name */
47
- name?: string;
48
+ name?: Team["name"];
48
49
  /** The team's access code */
49
- accessCode?: string;
50
+ accessCode?: Team["accessCode"];
50
51
  }): Promise<Team>;
51
- /** Delete a team: https://umami.is/docs/api/teams#delete-apiteamsteamid (TODO UNTESTED) */
52
- function delete_TEAMID(this: API, teamId: string): Promise<DeletionResult>;
53
- /** Get all users that belong to a team: https://umami.is/docs/api/teams#get-apiteamsteamidusers (TODO UNTESTED) */
54
- function get_TEAMID_Users(this: API, teamId: string, parameters: GenericRequestParameters): Promise<TeamMemberWithUser[]>;
55
- /** Add a user to a team: https://umami.is/docs/api/teams#post-apiteamsteamidusers (TODO UNTESTED) */
56
- function post_TEAMID_Users(this: API, teamId: string, parameters: {
52
+ /** Delete a team: https://umami.is/docs/api/teams#delete-apiteamsteamid */
53
+ function delete_TEAMID(this: API, teamId: Team["id"]): Promise<DeletionResult>;
54
+ /** Get all users that belong to a team: https://umami.is/docs/api/teams#get-apiteamsteamidusers */
55
+ function get_TEAMID_Users(this: API, teamId: Team["id"], parameters?: GenericRequestParameters): Promise<TeamMemberWithUser[]>;
56
+ /** Add a user to a team: https://umami.is/docs/api/teams#post-apiteamsteamidusers */
57
+ function post_TEAMID_Users(this: API, teamId: Team["id"], parameters: {
57
58
  /** ID of user to be added */
58
59
  userId: Users.User["id"];
59
60
  /** Team role for user */
60
- role: TeamRole;
61
+ role: Exclude<TeamRole, "team-owner">;
61
62
  }): Promise<TeamMember>;
62
- /** Get a user belonging to a team: https://umami.is/docs/api/teams#get-apiteamsteamidusersuserid (TODO UNTESTED) */
63
- function get_TEAMID_Users_USERID(this: API, teamId: string, userId: Users.User["id"]): Promise<TeamMember>;
64
- /** Update a user's role on a team: https://umami.is/docs/api/teams#post-apiteamsteamidusersuserid (TODO UNTESTED) */
65
- function post_TEAMID_Users_USERID(this: API, teamId: string, userId: Users.User["id"], role: TeamRole): Promise<TeamMember>;
66
- /** Remove a user from a team: https://umami.is/docs/api/teams#delete-apiteamsteamidusersuserid (TODO UNTESTED) */
67
- function delete_TEAMID_Users_USERID(this: API, teamId: string, userId: Users.User["id"]): Promise<DeletionResult>;
68
- /** Get all websites that belong to a team: https://umami.is/docs/api/teams#get-apiteamsteamidwebsites (TODO UNTESTED) */
69
- function get_TEAMID_Websites(this: API, teamId: string, parameters: GenericRequestParameters): Promise<Websites.WebsiteWithCreateuser[]>;
63
+ /** Get a user belonging to a team: https://umami.is/docs/api/teams#get-apiteamsteamidusersuserid */
64
+ function get_TEAMID_Users_USERID(this: API, teamId: Team["id"], userId: Users.User["id"]): Promise<TeamMember>;
65
+ /** Update a user's role on a team: https://umami.is/docs/api/teams#post-apiteamsteamidusersuserid */
66
+ function post_TEAMID_Users_USERID(this: API, teamId: Team["id"], userId: Users.User["id"], role: Exclude<TeamRole, "team-owner">): Promise<TeamMember>;
67
+ /** Remove a user from a team: https://umami.is/docs/api/teams#delete-apiteamsteamidusersuserid */
68
+ function delete_TEAMID_Users_USERID(this: API, teamId: Team["id"], userId: Users.User["id"]): Promise<DeletionResult>;
69
+ /** Get all websites that belong to a team: https://umami.is/docs/api/teams#get-apiteamsteamidwebsites */
70
+ function get_TEAMID_Websites(this: API, teamId: Team["id"], parameters?: GenericRequestParameters): Promise<Websites.WebsiteWithCreateuser[]>;
70
71
  }
@@ -1,64 +1,67 @@
1
1
  /** Operations around Team management: https://umami.is/docs/api/teams */
2
2
  export var Teams;
3
3
  (function (Teams) {
4
- /** Returns all teams: https://umami.is/docs/api/teams#get-apiteams (TODO UNTESTED) */
4
+ /** Returns all teams: https://umami.is/docs/api/teams#get-apiteams */
5
5
  async function get(parameters) {
6
6
  const response = await this.request("get", ["teams"], parameters);
7
7
  return response.data;
8
8
  }
9
9
  Teams.get = get;
10
- /** Creates a team: https://umami.is/docs/api/teams#post-apiteams (TODO UNTESTED) */
10
+ /**
11
+ * Creates a team: https://umami.is/docs/api/teams#post-apiteams
12
+ * @returns An Array where its first element is the created team, and its second element is its owner
13
+ */
11
14
  async function post(name) {
12
15
  return await this.request("post", ["teams"], { name });
13
16
  }
14
17
  Teams.post = post;
15
- /** Join a team: https://umami.is/docs/api/teams#post-apiteamsjoin (TODO UNTESTED) */
18
+ /** Join a team: https://umami.is/docs/api/teams#post-apiteamsjoin */
16
19
  async function postJoin(accessCode) {
17
20
  return await this.request("post", ["teams", "join"], { accessCode });
18
21
  }
19
22
  Teams.postJoin = postJoin;
20
- /** Get a team: https://umami.is/docs/api/teams#get-apiteamsteamid (TODO UNTESTED) */
23
+ /** Get a team: https://umami.is/docs/api/teams#get-apiteamsteamid */
21
24
  async function get_TEAMID(teamId) {
22
25
  return await this.request("get", ["teams", teamId]);
23
26
  }
24
27
  Teams.get_TEAMID = get_TEAMID;
25
- /** Update a team: https://umami.is/docs/api/teams#post-apiteamsteamid (TODO UNTESTED) */
28
+ /** Update a team: https://umami.is/docs/api/teams#post-apiteamsteamid */
26
29
  async function post_TEAMID(teamId, parameters) {
27
30
  return await this.request("post", ["teams", teamId], parameters);
28
31
  }
29
32
  Teams.post_TEAMID = post_TEAMID;
30
- /** Delete a team: https://umami.is/docs/api/teams#delete-apiteamsteamid (TODO UNTESTED) */
33
+ /** Delete a team: https://umami.is/docs/api/teams#delete-apiteamsteamid */
31
34
  async function delete_TEAMID(teamId) {
32
35
  return await this.request("delete", ["teams", teamId]);
33
36
  }
34
37
  Teams.delete_TEAMID = delete_TEAMID;
35
- /** Get all users that belong to a team: https://umami.is/docs/api/teams#get-apiteamsteamidusers (TODO UNTESTED) */
38
+ /** Get all users that belong to a team: https://umami.is/docs/api/teams#get-apiteamsteamidusers */
36
39
  async function get_TEAMID_Users(teamId, parameters) {
37
40
  const response = await this.request("get", ["teams", teamId, "users"], parameters);
38
41
  return response.data;
39
42
  }
40
43
  Teams.get_TEAMID_Users = get_TEAMID_Users;
41
- /** Add a user to a team: https://umami.is/docs/api/teams#post-apiteamsteamidusers (TODO UNTESTED) */
44
+ /** Add a user to a team: https://umami.is/docs/api/teams#post-apiteamsteamidusers */
42
45
  async function post_TEAMID_Users(teamId, parameters) {
43
46
  return await this.request("post", ["teams", teamId, "users"], parameters);
44
47
  }
45
48
  Teams.post_TEAMID_Users = post_TEAMID_Users;
46
- /** Get a user belonging to a team: https://umami.is/docs/api/teams#get-apiteamsteamidusersuserid (TODO UNTESTED) */
49
+ /** Get a user belonging to a team: https://umami.is/docs/api/teams#get-apiteamsteamidusersuserid */
47
50
  async function get_TEAMID_Users_USERID(teamId, userId) {
48
51
  return await this.request("get", ["teams", teamId, "users", userId]);
49
52
  }
50
53
  Teams.get_TEAMID_Users_USERID = get_TEAMID_Users_USERID;
51
- /** Update a user's role on a team: https://umami.is/docs/api/teams#post-apiteamsteamidusersuserid (TODO UNTESTED) */
54
+ /** Update a user's role on a team: https://umami.is/docs/api/teams#post-apiteamsteamidusersuserid */
52
55
  async function post_TEAMID_Users_USERID(teamId, userId, role) {
53
56
  return await this.request("post", ["teams", teamId, "users", userId], { role });
54
57
  }
55
58
  Teams.post_TEAMID_Users_USERID = post_TEAMID_Users_USERID;
56
- /** Remove a user from a team: https://umami.is/docs/api/teams#delete-apiteamsteamidusersuserid (TODO UNTESTED) */
59
+ /** Remove a user from a team: https://umami.is/docs/api/teams#delete-apiteamsteamidusersuserid */
57
60
  async function delete_TEAMID_Users_USERID(teamId, userId) {
58
61
  return await this.request("delete", ["teams", teamId, "users", userId]);
59
62
  }
60
63
  Teams.delete_TEAMID_Users_USERID = delete_TEAMID_Users_USERID;
61
- /** Get all websites that belong to a team: https://umami.is/docs/api/teams#get-apiteamsteamidwebsites (TODO UNTESTED) */
64
+ /** Get all websites that belong to a team: https://umami.is/docs/api/teams#get-apiteamsteamidwebsites */
62
65
  async function get_TEAMID_Websites(teamId, parameters) {
63
66
  const response = await this.request("get", ["teams", teamId, "websites"], parameters);
64
67
  return response.data;
@@ -17,6 +17,15 @@ export declare namespace Users {
17
17
  interface User extends MinimalUserWithCreatedAt {
18
18
  isAdmin: boolean;
19
19
  }
20
+ interface DetailedUser extends MinimalUserWithRole, MinimalUserWithCreatedAt {
21
+ logoUrl: string | null;
22
+ displayName: string | null;
23
+ updatedAt: Date;
24
+ deletedAt: Date | null;
25
+ _count: {
26
+ websites: number;
27
+ };
28
+ }
20
29
  /** Creates a user: https://umami.is/docs/api/users#post-apiusers */
21
30
  function post(this: API, parameters: {
22
31
  /** The user's username */
@@ -30,11 +30,11 @@ export declare namespace WebsiteStats {
30
30
  totaltime: number;
31
31
  }
32
32
  type MetricsTypes = "path" | "entry" | "exit" | "title" | "query" | "referrer" | "channel" | "domain" | "country" | "region" | "city" | "browser" | "os" | "device" | "language" | "screen" | "event" | "hostname" | "tag";
33
- /** Gets the number of active users on a website: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidactive (TODO UNTESTED) */
33
+ /** Gets the number of active users on a website: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidactive */
34
34
  function get_WEBSITEID_Active(this: API, websiteId: Websites.Website["id"]): Promise<{
35
35
  visitors: number;
36
36
  }>;
37
- /** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries (TODO UNTESTED) */
37
+ /** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries */
38
38
  function get_WEBSITEID_EventsSeries(this: API, websiteId: Websites.Website["id"], parameters: Timestamps & Units & Filters & {
39
39
  /** Timezone (ex. America/Los_Angeles) */
40
40
  timezone: string;
@@ -1,14 +1,16 @@
1
1
  /** Operations around Website statistics: https://umami.is/docs/api/website-stats */
2
2
  export var WebsiteStats;
3
3
  (function (WebsiteStats) {
4
- /** Gets the number of active users on a website: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidactive (TODO UNTESTED) */
4
+ /** Gets the number of active users on a website: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidactive */
5
5
  async function get_WEBSITEID_Active(websiteId) {
6
6
  return await this.request("get", ["websites", websiteId, "active"]);
7
7
  }
8
8
  WebsiteStats.get_WEBSITEID_Active = get_WEBSITEID_Active;
9
- /** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries (TODO UNTESTED) */
9
+ /** Gets events within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteideventsseries */
10
10
  async function get_WEBSITEID_EventsSeries(websiteId, parameters) {
11
- return await this.request("get", ["websites", websiteId, "events", "series"], parameters);
11
+ const response = await this.request("get", ["websites", websiteId, "events", "series"], parameters);
12
+ response.t = new Date(response.t);
13
+ return response;
12
14
  }
13
15
  WebsiteStats.get_WEBSITEID_EventsSeries = get_WEBSITEID_EventsSeries;
14
16
  /** Gets metrics for a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidmetrics (TODO UNTESTED) */
@@ -23,7 +25,10 @@ export var WebsiteStats;
23
25
  WebsiteStats.get_WEBSITEID_MetricsExpanded = get_WEBSITEID_MetricsExpanded;
24
26
  /** Gets pageviews within a given time range: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidpageviews (TODO UNTESTED) */
25
27
  async function get_WEBSITEID_Pageviews(websiteId, parameters) {
26
- return await this.request("get", ["websites", websiteId, "pageviews"], parameters);
28
+ const response = await this.request("get", ["websites", websiteId, "pageviews"], parameters);
29
+ response.pageviews = response.pageviews.map((v) => { v.x = new Date(v.x); return v; });
30
+ response.sessions = response.sessions.map((s) => { s.x = new Date(s.x); return s; });
31
+ return response;
27
32
  }
28
33
  WebsiteStats.get_WEBSITEID_Pageviews = get_WEBSITEID_Pageviews;
29
34
  /** Gets summarized website statistics: https://umami.is/docs/api/website-stats#get-apiwebsiteswebsiteidstats (TODO UNTESTED) */
@@ -16,7 +16,7 @@ export declare namespace Websites {
16
16
  deletedAt: Date | null;
17
17
  }
18
18
  interface WebsiteWithCreateuser extends Website {
19
- user: Users.MinimalUser;
19
+ createUser: Users.MinimalUser;
20
20
  }
21
21
  interface WebsiteWithUser extends Website {
22
22
  user: Users.MinimalUser;
package/dist/utilities.js CHANGED
@@ -56,7 +56,7 @@ export function correctType(x, force_string) {
56
56
  const vals = Object.values(x);
57
57
  // If a key is any of those, the value is expected to be a string, so we use `force_string` to make correctType convert them to string for us
58
58
  const unconvertables = ["value"];
59
- const unconvertables_substrings = ["string", "name"]; // or if the key contains any of those substrings
59
+ const unconvertables_substrings = ["string", "name", "Id"]; // or if the key contains any of those substrings
60
60
  for (let i = 0; i < keys.length; i++) {
61
61
  x[keys[i]] = correctType(vals[i], unconvertables.some((u) => keys[i] === u) || unconvertables_substrings.some((s) => keys[i].toLowerCase().includes(s)));
62
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umami-api-js",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Package to easily access the umami api!",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,9 +30,9 @@
30
30
  "devDependencies": {
31
31
  "@types/chai": "^5.2.3",
32
32
  "@types/node": "^24.9.2",
33
- "chai": "^6.2.0",
33
+ "chai": "^6.2.2",
34
34
  "dotenv": "^17.2.3",
35
- "typedoc": "^0.28.14",
35
+ "typedoc": "^0.28.16",
36
36
  "typescript": "^5.9.3"
37
37
  }
38
38
  }