Skip to content

Commit 3845c99

Browse files
chore: Namananand/ins 3646 update documentation for the latest version (#70)
Because - update documentation for the latest version This commit - update documentation for the latest version
1 parent 401317b commit 3845c99

File tree

8 files changed

+176
-31
lines changed

8 files changed

+176
-31
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -359,17 +359,17 @@ client.AuthClient.createApiTokenMutation({
359359
360360
```
361361

362-
| function | params |
363-
| :--------------------- | :---------------------: |
364-
| getUserQuery | userName |
365-
| getUserMeQuery | |
366-
| checkUserIdExist | id |
367-
| getApiTokenQuery | tokenName |
368-
| listApiTokensQuery | pageSize, nextPageToken |
369-
| updateUserMutation | payload |
370-
| createApiTokenMutation | payload |
371-
| deleteApiTokenMutation | tokenName |
372-
| checkNamespace | id |
362+
| function | params |
363+
| :--------------------- | :---------------------: |
364+
| getUserQuery | userName |
365+
| getAuthenticatedUserQuery | |
366+
| checkUserIdExist | id |
367+
| getApiTokenQuery | tokenName |
368+
| listApiTokensQuery | pageSize, nextPageToken |
369+
| updateAuthenticatedUserMutation | payload |
370+
| createApiTokenMutation | payload |
371+
| deleteApiTokenMutation | tokenName |
372+
| checkNamespace | id |
373373

374374
## Contribution Guidelines:
375375

src/connector/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22

33
import { AirbyteFieldValues } from "@instill-ai/toolkit";
4-
import { Spec } from "../types";
4+
import { Owner, Spec } from "../types";
55

66
export type ConnectorState =
77
| "STATE_CONNECTED"
@@ -19,7 +19,7 @@ export type ConnectorType =
1919
| "CONNECTOR_TYPE_OPERATOR"
2020
| "CONNECTOR_TYPE_DATA"
2121
| "CONNECTOR_TYPE_AI"
22-
| "CONNECTOR_TYPE_BLOCKCHAIN";
22+
| "CONNECTOR_TYPE_APPLICATION";
2323

2424
export type Connector = {
2525
name: string;
@@ -37,6 +37,7 @@ export type Connector = {
3737
create_time: string;
3838
update_time: string;
3939
visibility: ConnectorVisibility;
40+
owner: Owner;
4041
};
4142

4243
export type ConnectorWithDefinition = Omit<

src/mgmt/AuthClient.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import {
99
import {
1010
checkUserIdExist,
1111
getApiTokenQuery,
12-
getUserMeQuery,
12+
getAuthenticatedUserQuery,
1313
getUserQuery,
1414
listApiTokensQuery,
1515
} from "./queries";
1616
import {
1717
changePasswordMutation,
1818
createApiTokenMutation,
1919
deleteApiTokenMutation,
20-
updateUserMutation,
20+
updateAuthenticatedUserMutation,
2121
} from "./mutation";
2222
import {
2323
authLoginAction,
@@ -44,8 +44,8 @@ class AuthClient {
4444
* MGMT Queries
4545
* -----------------------------------------------------------------------*/
4646

47-
async getUserMeQuery() {
48-
return getUserMeQuery(this.axiosInstance);
47+
async getAuthenticatedUserQuery() {
48+
return getAuthenticatedUserQuery(this.axiosInstance);
4949
}
5050

5151
async getUserQuery({ userName }: { userName: string }) {
@@ -84,8 +84,8 @@ class AuthClient {
8484
* MGMT Mutation
8585
* -----------------------------------------------------------------------*/
8686

87-
async updateUserMutation({ payload }: { payload: Partial<User> }) {
88-
return updateUserMutation({
87+
async updateAuthenticatedUserMutation({ payload }: { payload: Partial<User> }) {
88+
return updateAuthenticatedUserMutation({
8989
axiosInstance: this.axiosInstance,
9090
payload: payload,
9191
});

src/mgmt/mutation.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import { AxiosInstance } from "axios";
22
import {
3+
AuthenticatedUser,
34
ChangePasswordPayload,
45
CreateApiTokenPayload,
56
CreateApiTokenResponse,
67
UpdateUserResponse,
78
User,
89
} from "./types";
910

10-
export async function updateUserMutation({
11-
axiosInstance,
11+
export async function updateAuthenticatedUserMutation({
1212
payload,
13+
axiosInstance,
1314
}: {
15+
payload: Partial<AuthenticatedUser>;
1416
axiosInstance: AxiosInstance;
15-
payload: Partial<User>;
1617
}) {
1718
try {
1819
const { data } = await axiosInstance.patch<UpdateUserResponse>(
19-
"/users/me",
20+
"/user",
2021
payload
2122
);
2223

src/mgmt/queries.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
ApiToken,
44
CheckUserIdExistResponse,
55
GetApiTokenResponse,
6+
GetAuthenticatedResponse,
7+
GetAuthenticatedUserSubscriptionsResponse,
68
GetUserResponse,
79
ListApiTokensResponse,
810
ListUsersResponse,
@@ -11,16 +13,33 @@ import {
1113
import { getQueryString } from "../helper";
1214
import { Nullable } from "../types";
1315

14-
export async function getUserMeQuery(axiosInstance: AxiosInstance) {
16+
export async function getAuthenticatedUserQuery(axiosInstance: AxiosInstance) {
1517
try {
16-
const { data } = await axiosInstance.get<GetUserResponse>("/users/me");
18+
const { data } = await axiosInstance.get<GetAuthenticatedResponse>("/user");
1719

1820
return Promise.resolve(data.user);
1921
} catch (err) {
2022
return Promise.reject(err);
2123
}
2224
}
2325

26+
export async function getAuthenticatedUserSubscriptionsQuery({
27+
axiosInstance,
28+
}: {
29+
axiosInstance: AxiosInstance;
30+
}) {
31+
try {
32+
const { data } =
33+
await axiosInstance.get<GetAuthenticatedUserSubscriptionsResponse>(
34+
"/user/subscription"
35+
);
36+
37+
return Promise.resolve(data.subscription);
38+
} catch (err) {
39+
return Promise.reject(err);
40+
}
41+
}
42+
2443
export async function getUserQuery({
2544
userName,
2645
axiosInstance,

src/mgmt/types.ts

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { GeneralRecord } from "@instill-ai/toolkit";
2+
import { Nullable } from "../types";
23

34
export type User = {
45
name: string;
@@ -52,7 +53,7 @@ export type AuthLoginActionResponse = {
5253
};
5354

5455
export type UpdateUserResponse = {
55-
user: User;
56+
user: AuthenticatedUser;
5657
};
5758

5859
export type CreateApiTokenPayload = {
@@ -69,6 +70,9 @@ export type ChangePasswordPayload = {
6970
new_password: string;
7071
};
7172

73+
export type GetAuthenticatedResponse = {
74+
user: AuthenticatedUser;
75+
};
7276
export type GetUserResponse = {
7377
user: User;
7478
};
@@ -96,3 +100,72 @@ export type ListUsersResponse = {
96100
export type CheckNamespaceResponse = {
97101
type: NamespaceType;
98102
};
103+
104+
export type UserProfile = {
105+
display_name?: string;
106+
bio?: string;
107+
public_email?: string;
108+
company_name?: string;
109+
avatar?: string;
110+
social_profiles_links?: {
111+
webiste?: string;
112+
x?: string;
113+
github?: string;
114+
};
115+
};
116+
117+
export type OnboardingStatus =
118+
| "ONBOARDING_STATUS_UNSPECIFIED"
119+
| "ONBOARDING_STATUS_IN_PROGRESS"
120+
| "ONBOARDING_STATUS_COMPLETED";
121+
122+
export type AuthenticatedUser = {
123+
name: string;
124+
uid: string;
125+
id: string;
126+
create_time: string;
127+
update_time: string;
128+
customer_id: string;
129+
email: string;
130+
newsletter_subscription: boolean;
131+
role: string;
132+
onboarding_status: OnboardingStatus;
133+
cookie_token?: string;
134+
profile?: UserProfile;
135+
};
136+
137+
export type StripeSubscriptionStatus =
138+
| "STATUS_UNSPECIFIED"
139+
| "STATUS_INCOMPLETE"
140+
| "STATUS_INCOMPLETE_EXPIRED"
141+
| "STATUS_TRIALING"
142+
| "STATUS_ACTIVE"
143+
| "STATUS_PAST_DUE"
144+
| "STATUS_CANCELED"
145+
| "STATUS_UNPAID"
146+
| "STATUS_PAUSED";
147+
148+
export type StripeSubscriptionDetail = {
149+
product_name: string;
150+
id: string;
151+
item_id: string;
152+
price: number;
153+
canceled_at?: number;
154+
trial_end?: number;
155+
status: StripeSubscriptionStatus;
156+
description: string;
157+
};
158+
159+
export type UserSubscriptionPlan =
160+
| "PLAN_UNSPECIFIED"
161+
| "PLAN_FREEMIUM"
162+
| "PLAN_PRO";
163+
164+
export type UserSubscription = {
165+
plan: UserSubscriptionPlan;
166+
detail: Nullable<StripeSubscriptionDetail>;
167+
};
168+
169+
export type GetAuthenticatedUserSubscriptionsResponse = {
170+
subscription: UserSubscription;
171+
};

src/pipeline/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export type PipelineComponentType =
4343
| "COMPONENT_TYPE_UNSPECIFIED"
4444
| "COMPONENT_TYPE_CONNECTOR_AI"
4545
| "COMPONENT_TYPE_CONNECTOR_DATA"
46-
| "COMPONENT_TYPE_CONNECTOR_BLOCKCHAIN"
46+
| "COMPONENT_TYPE_CONNECTOR_APPLICATION"
4747
| "COMPONENT_TYPE_OPERATOR";
4848

4949
export type PipelineReleasesWatchState = Record<

src/types.ts

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ export type Violation = {
1818
subject: string;
1919
};
2020

21-
export type ResourceState =
22-
| ModelState
23-
| PipelineReleaseState
24-
| ConnectorState;
21+
export type ResourceState = ModelState | PipelineReleaseState | ConnectorState;
2522

2623
export type Spec = {
2724
resource_specification: JSONSchema7;
@@ -35,3 +32,57 @@ export type Visibility =
3532
| "VISIBILITY_PUBLIC";
3633

3734
export type Nullable<T> = T | null;
35+
36+
export type OrganizationProfile = {
37+
display_name?: string;
38+
bio?: string;
39+
public_email?: string;
40+
avatar?: string;
41+
social_profiles_links?: {
42+
webiste?: string;
43+
x?: string;
44+
github?: string;
45+
};
46+
};
47+
48+
export type Organization = {
49+
name: string;
50+
uid: string;
51+
id: string;
52+
create_time: string;
53+
update_time: string;
54+
owner: User;
55+
profile?: OrganizationProfile;
56+
};
57+
58+
export type UserProfile = {
59+
display_name?: string;
60+
bio?: string;
61+
public_email?: string;
62+
company_name?: string;
63+
avatar?: string;
64+
social_profiles_links?: {
65+
webiste?: string;
66+
x?: string;
67+
github?: string;
68+
};
69+
};
70+
71+
export type User = {
72+
name: string;
73+
uid: string;
74+
id: string;
75+
create_time: string;
76+
update_time: string;
77+
profile?: UserProfile;
78+
};
79+
80+
export type UserOwner = {
81+
user: User;
82+
};
83+
84+
export type OrganizationOwner = {
85+
organization: Organization;
86+
};
87+
88+
export type Owner = UserOwner | OrganizationOwner;

0 commit comments

Comments
 (0)