umami-api-js 0.1.2 → 0.1.3

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
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).
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.3**, 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
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.
@@ -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,4 +1,4 @@
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
4
  /** Get information based on your auth token: https://umami.is/docs/api/me#get-apime */
@@ -11,14 +11,5 @@ export declare namespace Me {
11
11
  /** Get all your teams: https://umami.is/docs/api/me#get-apimeteams */
12
12
  function getTeams(this: API): Promise<Teams.TeamWithMembersCount[]>;
13
13
  /** 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
- })[]>;
14
+ function getWebsites(this: API): Promise<Websites.WebsiteWithUser[]>;
24
15
  }
@@ -1,4 +1,4 @@
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
4
  /** Realtime stats within the last 30 minutes: https://umami.is/docs/api/realtime#get-apirealtimewebsiteid (TODO UNTESTED) */
@@ -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,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;
@@ -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.3",
4
4
  "description": "Package to easily access the umami api!",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",