@ysk-kit/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/http.d.ts +18 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +113 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +341 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/ports/device.d.ts +5 -0
- package/dist/ports/device.d.ts.map +1 -0
- package/dist/ports/device.js +2 -0
- package/dist/ports/device.js.map +1 -0
- package/dist/ports/file-picker.d.ts +7 -0
- package/dist/ports/file-picker.d.ts.map +1 -0
- package/dist/ports/file-picker.js +2 -0
- package/dist/ports/file-picker.js.map +1 -0
- package/dist/realtime.d.ts +11 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +17 -0
- package/dist/realtime.js.map +1 -0
- package/dist/resources/api-keys.d.ts +27 -0
- package/dist/resources/api-keys.d.ts.map +1 -0
- package/dist/resources/api-keys.js +9 -0
- package/dist/resources/api-keys.js.map +1 -0
- package/dist/resources/audit.d.ts +18 -0
- package/dist/resources/audit.d.ts.map +1 -0
- package/dist/resources/audit.js +13 -0
- package/dist/resources/audit.js.map +1 -0
- package/dist/resources/auth.d.ts +103 -0
- package/dist/resources/auth.d.ts.map +1 -0
- package/dist/resources/auth.js +74 -0
- package/dist/resources/auth.js.map +1 -0
- package/dist/resources/billing.d.ts +36 -0
- package/dist/resources/billing.d.ts.map +1 -0
- package/dist/resources/billing.js +20 -0
- package/dist/resources/billing.js.map +1 -0
- package/dist/resources/devices.d.ts +20 -0
- package/dist/resources/devices.d.ts.map +1 -0
- package/dist/resources/devices.js +6 -0
- package/dist/resources/devices.js.map +1 -0
- package/dist/resources/llm.d.ts +30 -0
- package/dist/resources/llm.d.ts.map +1 -0
- package/dist/resources/llm.js +49 -0
- package/dist/resources/llm.js.map +1 -0
- package/dist/resources/notifications.d.ts +20 -0
- package/dist/resources/notifications.d.ts.map +1 -0
- package/dist/resources/notifications.js +12 -0
- package/dist/resources/notifications.js.map +1 -0
- package/dist/resources/organizations.d.ts +62 -0
- package/dist/resources/organizations.d.ts.map +1 -0
- package/dist/resources/organizations.js +33 -0
- package/dist/resources/organizations.js.map +1 -0
- package/dist/resources/users.d.ts +38 -0
- package/dist/resources/users.d.ts.map +1 -0
- package/dist/resources/users.js +15 -0
- package/dist/resources/users.js.map +1 -0
- package/dist/token-store.d.ts +13 -0
- package/dist/token-store.d.ts.map +1 -0
- package/dist/token-store.js +35 -0
- package/dist/token-store.js.map +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CreateApiKeyCommand } from '@ysk-kit/contracts';
|
|
2
|
+
import type { HttpClient } from '../http';
|
|
3
|
+
export declare const apiKeysResource: (http: HttpClient) => {
|
|
4
|
+
list: () => Promise<{
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
prefix: string;
|
|
8
|
+
last4: string;
|
|
9
|
+
permissions: ("user.create" | "user.suspend" | "audit.read" | "file.upload" | "llm.use" | "billing.checkout")[];
|
|
10
|
+
createdAt: string;
|
|
11
|
+
lastUsedAt: string | null;
|
|
12
|
+
}[]>;
|
|
13
|
+
create: (body: CreateApiKeyCommand) => Promise<{
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
prefix: string;
|
|
17
|
+
last4: string;
|
|
18
|
+
permissions: ("user.create" | "user.suspend" | "audit.read" | "file.upload" | "llm.use" | "billing.checkout")[];
|
|
19
|
+
createdAt: string;
|
|
20
|
+
lastUsedAt: string | null;
|
|
21
|
+
token: string;
|
|
22
|
+
}>;
|
|
23
|
+
revoke: (id: string) => Promise<{
|
|
24
|
+
revoked: true;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=api-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/resources/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,mBAAmB,EAAoB,MAAM,oBAAoB,CAAC;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,eAAe,GAAI,MAAM,UAAU;;;;;;;;;;mBAE/B,mBAAmB;;;;;;;;;;iBAKrB,MAAM;iBACO,IAAI;;CAC9B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const apiKeysResource = (http) => ({
|
|
2
|
+
list: () => http.request('/v1/me/api-keys'),
|
|
3
|
+
create: (body) => http.request('/v1/me/api-keys', {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
body: JSON.stringify(body),
|
|
6
|
+
}),
|
|
7
|
+
revoke: (id) => http.request(`/v1/me/api-keys/${id}`, { method: 'DELETE' }),
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=api-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../../src/resources/api-keys.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAgB,EAAE,EAAE,CAAC,CAAC;IACpD,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAc,iBAAiB,CAAC;IACxD,MAAM,EAAE,CAAC,IAAyB,EAAE,EAAE,CACpC,IAAI,CAAC,OAAO,CAAmB,iBAAiB,EAAE;QAChD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC;IACJ,MAAM,EAAE,CAAC,EAAU,EAAE,EAAE,CACrB,IAAI,CAAC,OAAO,CAAoB,mBAAmB,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;CACjF,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HttpClient } from '../http';
|
|
2
|
+
export declare const auditResource: (http: HttpClient) => {
|
|
3
|
+
list: (query?: {
|
|
4
|
+
cursor?: string;
|
|
5
|
+
limit?: number;
|
|
6
|
+
}) => Promise<{
|
|
7
|
+
items: {
|
|
8
|
+
id: string;
|
|
9
|
+
actorId: string | null;
|
|
10
|
+
action: "user.create" | "user.suspend" | "file.upload" | "auth.register" | "auth.login" | "auth.logout" | "auth.reset" | "org.create" | "org.invite" | "org.member.remove" | "api_key.create" | "api_key.revoke";
|
|
11
|
+
resourceType: string;
|
|
12
|
+
resourceId: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}[];
|
|
15
|
+
nextCursor: string | null;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/resources/audit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAU1C,eAAO,MAAM,aAAa,GAAI,MAAM,UAAU;mBAC7B;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;CAElD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const toQuery = (query) => {
|
|
2
|
+
const params = new URLSearchParams();
|
|
3
|
+
if (query?.cursor)
|
|
4
|
+
params.set('cursor', query.cursor);
|
|
5
|
+
if (query?.limit)
|
|
6
|
+
params.set('limit', String(query.limit));
|
|
7
|
+
const encoded = params.toString();
|
|
8
|
+
return encoded.length > 0 ? `?${encoded}` : '';
|
|
9
|
+
};
|
|
10
|
+
export const auditResource = (http) => ({
|
|
11
|
+
list: (query) => http.request(`/v1/audit-logs${toQuery(query)}`),
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/resources/audit.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,GAAG,CAAC,KAA2C,EAAU,EAAE;IACtE,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,IAAI,KAAK,EAAE,MAAM;QAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,KAAK,EAAE,KAAK;QAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClC,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAgB,EAAE,EAAE,CAAC,CAAC;IAClD,IAAI,EAAE,CAAC,KAA2C,EAAE,EAAE,CACpD,IAAI,CAAC,OAAO,CAAqB,iBAAiB,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;CACtE,CAAC,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { LoginPasswordCommand, RefreshCommand, RegisterCommand, RequestAdminOtpCommand, RequestOtpCommand, VerifyAdminOtpCommand, VerifyOtpCommand } from '@ysk-kit/contracts';
|
|
2
|
+
import type { HttpClient } from '../http';
|
|
3
|
+
import type { TokenStore } from '../token-store';
|
|
4
|
+
export declare const authResource: (http: HttpClient, store: TokenStore) => {
|
|
5
|
+
register: (body: RegisterCommand) => Promise<{
|
|
6
|
+
accessToken: string;
|
|
7
|
+
refreshToken: string;
|
|
8
|
+
expiresIn: number;
|
|
9
|
+
user: {
|
|
10
|
+
id: string;
|
|
11
|
+
email: string | null;
|
|
12
|
+
phone: string | null;
|
|
13
|
+
displayName: string;
|
|
14
|
+
role: "USER" | "ADMIN" | "OPS";
|
|
15
|
+
status: "ACTIVE" | "INVITED" | "SUSPENDED" | "DELETED";
|
|
16
|
+
createdAt: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
login: (body: LoginPasswordCommand) => Promise<{
|
|
20
|
+
accessToken: string;
|
|
21
|
+
refreshToken: string;
|
|
22
|
+
expiresIn: number;
|
|
23
|
+
user: {
|
|
24
|
+
id: string;
|
|
25
|
+
email: string | null;
|
|
26
|
+
phone: string | null;
|
|
27
|
+
displayName: string;
|
|
28
|
+
role: "USER" | "ADMIN" | "OPS";
|
|
29
|
+
status: "ACTIVE" | "INVITED" | "SUSPENDED" | "DELETED";
|
|
30
|
+
createdAt: string;
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
33
|
+
requestOtp: (body: RequestOtpCommand) => Promise<{
|
|
34
|
+
sent: true;
|
|
35
|
+
}>;
|
|
36
|
+
verifyOtp: (body: VerifyOtpCommand) => Promise<{
|
|
37
|
+
accessToken: string;
|
|
38
|
+
refreshToken: string;
|
|
39
|
+
expiresIn: number;
|
|
40
|
+
user: {
|
|
41
|
+
id: string;
|
|
42
|
+
email: string | null;
|
|
43
|
+
phone: string | null;
|
|
44
|
+
displayName: string;
|
|
45
|
+
role: "USER" | "ADMIN" | "OPS";
|
|
46
|
+
status: "ACTIVE" | "INVITED" | "SUSPENDED" | "DELETED";
|
|
47
|
+
createdAt: string;
|
|
48
|
+
};
|
|
49
|
+
}>;
|
|
50
|
+
refresh: (body: RefreshCommand) => Promise<{
|
|
51
|
+
accessToken: string;
|
|
52
|
+
refreshToken: string;
|
|
53
|
+
expiresIn: number;
|
|
54
|
+
user: {
|
|
55
|
+
id: string;
|
|
56
|
+
email: string | null;
|
|
57
|
+
phone: string | null;
|
|
58
|
+
displayName: string;
|
|
59
|
+
role: "USER" | "ADMIN" | "OPS";
|
|
60
|
+
status: "ACTIVE" | "INVITED" | "SUSPENDED" | "DELETED";
|
|
61
|
+
createdAt: string;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
logout: () => Promise<void>;
|
|
65
|
+
me: () => Promise<{
|
|
66
|
+
id: string;
|
|
67
|
+
email: string | null;
|
|
68
|
+
phone: string | null;
|
|
69
|
+
displayName: string;
|
|
70
|
+
role: "USER" | "ADMIN" | "OPS";
|
|
71
|
+
status: "ACTIVE" | "INVITED" | "SUSPENDED" | "DELETED";
|
|
72
|
+
createdAt: string;
|
|
73
|
+
}>;
|
|
74
|
+
requestAdminOtp: (body: RequestAdminOtpCommand) => Promise<{
|
|
75
|
+
sent: true;
|
|
76
|
+
}>;
|
|
77
|
+
verifyAdminOtp: (body: VerifyAdminOtpCommand) => Promise<{
|
|
78
|
+
accessToken: string;
|
|
79
|
+
refreshToken: string;
|
|
80
|
+
expiresIn: number;
|
|
81
|
+
user: {
|
|
82
|
+
id: string;
|
|
83
|
+
email: string | null;
|
|
84
|
+
phone: string | null;
|
|
85
|
+
displayName: string;
|
|
86
|
+
role: "USER" | "ADMIN" | "OPS";
|
|
87
|
+
status: "ACTIVE" | "INVITED" | "SUSPENDED" | "DELETED";
|
|
88
|
+
createdAt: string;
|
|
89
|
+
};
|
|
90
|
+
}>;
|
|
91
|
+
forgot: (body: {
|
|
92
|
+
email: string;
|
|
93
|
+
}) => Promise<{
|
|
94
|
+
accepted: true;
|
|
95
|
+
}>;
|
|
96
|
+
reset: (body: {
|
|
97
|
+
token: string;
|
|
98
|
+
password: string;
|
|
99
|
+
}) => Promise<{
|
|
100
|
+
accepted: true;
|
|
101
|
+
}>;
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/resources/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EAGjB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAOjD,eAAO,MAAM,YAAY,GAAI,MAAM,UAAU,EAAE,OAAO,UAAU;qBACvC,eAAe;;;;;;;;;;;;;;kBAQlB,oBAAoB;;;;;;;;;;;;;;uBAQrB,iBAAiB;cACb,IAAI;;sBAIH,gBAAgB;;;;;;;;;;;;;;oBAQlB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;4BAgBZ,sBAAsB;cACvB,IAAI;;2BAIE,qBAAqB;;;;;;;;;;;;;;mBAQnC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;kBACL,IAAI;;kBAIjB;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;kBACtB,IAAI;;CAI/B,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const persist = async (store, pair) => {
|
|
2
|
+
if (store.setPair)
|
|
3
|
+
await store.setPair(pair.accessToken, pair.refreshToken);
|
|
4
|
+
else
|
|
5
|
+
await store.set(pair.accessToken);
|
|
6
|
+
};
|
|
7
|
+
export const authResource = (http, store) => ({
|
|
8
|
+
register: async (body) => {
|
|
9
|
+
const pair = await http.request('/v1/auth/register', {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
body: JSON.stringify(body),
|
|
12
|
+
});
|
|
13
|
+
await persist(store, pair);
|
|
14
|
+
return pair;
|
|
15
|
+
},
|
|
16
|
+
login: async (body) => {
|
|
17
|
+
const pair = await http.request('/v1/auth/login', {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
body: JSON.stringify(body),
|
|
20
|
+
});
|
|
21
|
+
await persist(store, pair);
|
|
22
|
+
return pair;
|
|
23
|
+
},
|
|
24
|
+
requestOtp: (body) => http.request('/v1/auth/otp/request', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
body: JSON.stringify(body),
|
|
27
|
+
}),
|
|
28
|
+
verifyOtp: async (body) => {
|
|
29
|
+
const pair = await http.request('/v1/auth/otp/verify', {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: JSON.stringify(body),
|
|
32
|
+
});
|
|
33
|
+
await persist(store, pair);
|
|
34
|
+
return pair;
|
|
35
|
+
},
|
|
36
|
+
refresh: async (body) => {
|
|
37
|
+
const pair = await http.request('/v1/auth/refresh', {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
body: JSON.stringify(body),
|
|
40
|
+
});
|
|
41
|
+
await persist(store, pair);
|
|
42
|
+
return pair;
|
|
43
|
+
},
|
|
44
|
+
logout: async () => {
|
|
45
|
+
try {
|
|
46
|
+
await http.request('/v1/auth/logout', { method: 'POST', body: '{}' });
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
await store.clear();
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
me: () => http.request('/v1/me'),
|
|
53
|
+
requestAdminOtp: (body) => http.request('/v1/auth/admin/otp/request', {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
body: JSON.stringify(body),
|
|
56
|
+
}),
|
|
57
|
+
verifyAdminOtp: async (body) => {
|
|
58
|
+
const pair = await http.request('/v1/auth/admin/otp/verify', {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
body: JSON.stringify(body),
|
|
61
|
+
});
|
|
62
|
+
await persist(store, pair);
|
|
63
|
+
return pair;
|
|
64
|
+
},
|
|
65
|
+
forgot: (body) => http.request('/v1/auth/forgot', {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
body: JSON.stringify(body),
|
|
68
|
+
}),
|
|
69
|
+
reset: (body) => http.request('/v1/auth/reset', {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
body: JSON.stringify(body),
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=au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,OAAO,CAAe,2BAA2B,EAAE;YACzE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,CAAC,IAAuB,EAAE,EAAE,CAClC,IAAI,CAAC,OAAO,CAAqB,iBAAiB,EAAE;QAClD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC;IACJ,KAAK,EAAE,CAAC,IAAyC,EAAE,EAAE,CACnD,IAAI,CAAC,OAAO,CAAqB,gBAAgB,EAAE;QACjD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC;CACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CancelCommand, CheckoutCommand, PortalCommand } from '@ysk-kit/contracts';
|
|
2
|
+
import type { HttpClient } from '../http';
|
|
3
|
+
export declare const billingResource: (http: HttpClient) => {
|
|
4
|
+
plans: () => Promise<{
|
|
5
|
+
code: "free" | "pro";
|
|
6
|
+
name: string;
|
|
7
|
+
amountHkdCents: number;
|
|
8
|
+
interval: "month";
|
|
9
|
+
}[]>;
|
|
10
|
+
subscription: (organizationId: string) => Promise<{
|
|
11
|
+
planCode: "free" | "pro";
|
|
12
|
+
status: "active" | "canceled";
|
|
13
|
+
currentPeriodEnd: string | null;
|
|
14
|
+
seatCount: number;
|
|
15
|
+
}>;
|
|
16
|
+
invoices: (organizationId: string) => Promise<{
|
|
17
|
+
id: string;
|
|
18
|
+
number: string | null;
|
|
19
|
+
status: string;
|
|
20
|
+
amountDue: number;
|
|
21
|
+
currency: string;
|
|
22
|
+
hostedInvoiceUrl: string | null;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
}[]>;
|
|
25
|
+
invoicePdfUrl: (id: string, organizationId: string) => Promise<string>;
|
|
26
|
+
checkout: (body: CheckoutCommand) => Promise<{
|
|
27
|
+
url: string;
|
|
28
|
+
}>;
|
|
29
|
+
cancel: (body: CancelCommand) => Promise<{
|
|
30
|
+
canceled: true;
|
|
31
|
+
}>;
|
|
32
|
+
portal: (body: PortalCommand) => Promise<{
|
|
33
|
+
url: string;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=billing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACb,eAAe,EAGf,aAAa,EAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,eAAO,MAAM,eAAe,GAAI,MAAM,UAAU;;;;;;;mCAEf,MAAM;;;;;;+BAEV,MAAM;;;;;;;;;wBAEb,MAAM,kBAAkB,MAAM;qBAEjC,eAAe;;;mBAKjB,aAAa;kBACD,IAAI;;mBAIhB,aAAa;;;CAK5B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const withOrg = (path, organizationId) => `${path}?organizationId=${encodeURIComponent(organizationId)}`;
|
|
2
|
+
export const billingResource = (http) => ({
|
|
3
|
+
plans: () => http.request('/v1/billing/plans'),
|
|
4
|
+
subscription: (organizationId) => http.request(withOrg('/v1/billing/subscription', organizationId)),
|
|
5
|
+
invoices: (organizationId) => http.request(withOrg('/v1/billing/invoices', organizationId)),
|
|
6
|
+
invoicePdfUrl: (id, organizationId) => http.requestLocation(withOrg(`/v1/billing/invoices/${id}/pdf`, organizationId)),
|
|
7
|
+
checkout: (body) => http.request('/v1/billing/checkout', {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: JSON.stringify(body),
|
|
10
|
+
}),
|
|
11
|
+
cancel: (body) => http.request('/v1/billing/cancel', {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
body: JSON.stringify(body),
|
|
14
|
+
}),
|
|
15
|
+
portal: (body) => http.request('/v1/billing/portal', {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
body: JSON.stringify(body),
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,cAAsB,EAAU,EAAE,CAC/D,GAAG,IAAI,mBAAmB,kBAAkB,CAAC,cAAc,CAAC,EAAE,CAAC;AAEjE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAgB,EAAE,EAAE,CAAC,CAAC;IACpD,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAmB,mBAAmB,CAAC;IAChE,YAAY,EAAE,CAAC,cAAsB,EAAE,EAAE,CACvC,IAAI,CAAC,OAAO,CAAkB,OAAO,CAAC,0BAA0B,EAAE,cAAc,CAAC,CAAC;IACpF,QAAQ,EAAE,CAAC,cAAsB,EAAE,EAAE,CACnC,IAAI,CAAC,OAAO,CAAe,OAAO,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;IAC7E,aAAa,EAAE,CAAC,EAAU,EAAE,cAAsB,EAAE,EAAE,CACpD,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,wBAAwB,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;IACjF,QAAQ,EAAE,CAAC,IAAqB,EAAE,EAAE,CAClC,IAAI,CAAC,OAAO,CAAc,sBAAsB,EAAE;QAChD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC;IACJ,MAAM,EAAE,CAAC,IAAmB,EAAE,EAAE,CAC9B,IAAI,CAAC,OAAO,CAAqB,oBAAoB,EAAE;QACrD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC;IACJ,MAAM,EAAE,CAAC,IAAmB,EAAE,EAAE,CAC9B,IAAI,CAAC,OAAO,CAAc,oBAAoB,EAAE;QAC9C,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC;CACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RegisterDeviceCommand } from '@ysk-kit/contracts';
|
|
2
|
+
import type { HttpClient } from '../http';
|
|
3
|
+
export declare const devicesResource: (http: HttpClient) => {
|
|
4
|
+
list: () => Promise<{
|
|
5
|
+
id: string;
|
|
6
|
+
platform: "ios" | "android";
|
|
7
|
+
tokenSuffix: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
}[]>;
|
|
10
|
+
register: (body: RegisterDeviceCommand) => Promise<{
|
|
11
|
+
id: string;
|
|
12
|
+
platform: "ios" | "android";
|
|
13
|
+
tokenSuffix: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
}>;
|
|
16
|
+
remove: (id: string) => Promise<{
|
|
17
|
+
removed: true;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=devices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devices.d.ts","sourceRoot":"","sources":["../../src/resources/devices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,eAAe,GAAI,MAAM,UAAU;;;;;;;qBAE7B,qBAAqB;;;;;;iBAEzB,MAAM;iBACO,IAAI;;CAC9B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const devicesResource = (http) => ({
|
|
2
|
+
list: () => http.request('/v1/me/devices'),
|
|
3
|
+
register: (body) => http.request('/v1/me/devices', { method: 'PUT', body: JSON.stringify(body) }),
|
|
4
|
+
remove: (id) => http.request(`/v1/me/devices/${id}`, { method: 'DELETE' }),
|
|
5
|
+
});
|
|
6
|
+
//# sourceMappingURL=devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devices.js","sourceRoot":"","sources":["../../src/resources/devices.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAgB,EAAE,EAAE,CAAC,CAAC;IACpD,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAc,gBAAgB,CAAC;IACvD,QAAQ,EAAE,CAAC,IAA2B,EAAE,EAAE,CACxC,IAAI,CAAC,OAAO,CAAY,gBAAgB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1F,MAAM,EAAE,CAAC,EAAU,EAAE,EAAE,CACrB,IAAI,CAAC,OAAO,CAAoB,kBAAkB,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;CAChF,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { LlmCompleteCommand, LlmUsage, Platform } from '@ysk-kit/contracts';
|
|
2
|
+
import type { HttpClient } from '../http';
|
|
3
|
+
import type { TokenStore } from '../token-store';
|
|
4
|
+
export declare const llmResource: (http: HttpClient, ctx: {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
platform: Platform;
|
|
7
|
+
tokenStore: TokenStore;
|
|
8
|
+
fetchImpl?: typeof fetch;
|
|
9
|
+
}) => {
|
|
10
|
+
complete: (body: LlmCompleteCommand) => Promise<{
|
|
11
|
+
text: string;
|
|
12
|
+
model: string;
|
|
13
|
+
usage: {
|
|
14
|
+
promptTokens: number;
|
|
15
|
+
completionTokens: number;
|
|
16
|
+
totalTokens: number;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
models: () => Promise<{
|
|
20
|
+
items: {
|
|
21
|
+
id: string;
|
|
22
|
+
}[];
|
|
23
|
+
}>;
|
|
24
|
+
stream: (body: LlmCompleteCommand, handlers: {
|
|
25
|
+
onDelta: (delta: string) => void;
|
|
26
|
+
onDone: (usage?: LlmUsage) => void;
|
|
27
|
+
onError?: (message: string) => void;
|
|
28
|
+
}) => Promise<void>;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/resources/llm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAGlB,QAAQ,EACR,QAAQ,EACT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,WAAW,GACtB,MAAM,UAAU,EAChB,KAAK;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CAAE;qBAE7E,kBAAkB;;;;;;;;;;;;;;mBAO3B,kBAAkB,YACd;QACR,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QACjC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;QACnC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;KACrC;CAyCH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const llmResource = (http, ctx) => ({
|
|
2
|
+
complete: (body) => http.request('/v1/llm/complete', {
|
|
3
|
+
method: 'POST',
|
|
4
|
+
body: JSON.stringify(body),
|
|
5
|
+
}),
|
|
6
|
+
models: () => http.request('/v1/llm/models'),
|
|
7
|
+
stream: async (body, handlers) => {
|
|
8
|
+
const fetchImpl = ctx.fetchImpl ?? fetch;
|
|
9
|
+
const token = await ctx.tokenStore.get();
|
|
10
|
+
const headers = new Headers({
|
|
11
|
+
'content-type': 'application/json',
|
|
12
|
+
'x-ysk-platform': ctx.platform,
|
|
13
|
+
});
|
|
14
|
+
if (token)
|
|
15
|
+
headers.set('authorization', `Bearer ${token}`);
|
|
16
|
+
const res = await fetchImpl(`${ctx.baseUrl}/v1/llm/stream`, {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
headers,
|
|
19
|
+
body: JSON.stringify(body),
|
|
20
|
+
});
|
|
21
|
+
if (!res.ok || !res.body) {
|
|
22
|
+
handlers.onError?.(`HTTP ${res.status}`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const reader = res.body.getReader();
|
|
26
|
+
const decoder = new TextDecoder();
|
|
27
|
+
let buffer = '';
|
|
28
|
+
while (true) {
|
|
29
|
+
const { value, done } = await reader.read();
|
|
30
|
+
if (done)
|
|
31
|
+
break;
|
|
32
|
+
buffer += decoder.decode(value, { stream: true });
|
|
33
|
+
const parts = buffer.split('\n\n');
|
|
34
|
+
buffer = parts.pop() ?? '';
|
|
35
|
+
for (const part of parts) {
|
|
36
|
+
const eventLine = part.split('\n').find((line) => line.startsWith('event:'));
|
|
37
|
+
const dataLine = part.split('\n').find((line) => line.startsWith('data:'));
|
|
38
|
+
if (!dataLine)
|
|
39
|
+
continue;
|
|
40
|
+
const json = JSON.parse(dataLine.slice(5).trim());
|
|
41
|
+
if (eventLine?.includes('done') || json.done)
|
|
42
|
+
handlers.onDone(json.usage);
|
|
43
|
+
else if (json.delta)
|
|
44
|
+
handlers.onDelta(json.delta);
|
|
45
|
+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AC,KAAK,CAAC,CAAC;qBACrE,IAAI,IAAI,CAAC,KAAK;oBAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { NotificationDto } from '@ysk-kit/contracts';
|
|
2
|
+
import type { HttpClient } from '../http';
|
|
3
|
+
export declare const notificationsResource: (http: HttpClient) => {
|
|
4
|
+
list: () => Promise<{
|
|
5
|
+
items: {
|
|
6
|
+
id: string;
|
|
7
|
+
type: "auth.reset" | "auth.welcome" | "user.created" | "org.invited";
|
|
8
|
+
title: string;
|
|
9
|
+
body: string;
|
|
10
|
+
readAt: string | null;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
}[];
|
|
13
|
+
nextCursor: string | null;
|
|
14
|
+
}>;
|
|
15
|
+
markRead: (id: string) => Promise<{
|
|
16
|
+
read: true;
|
|
17
|
+
}>;
|
|
18
|
+
unread: () => Promise<NotificationDto[]>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=notifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/resources/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,qBAAqB,GAAI,MAAM,UAAU;;;;;;;;;;;;mBAErC,MAAM;cACE,IAAI;;kBAIT,OAAO,CAAC,eAAe,EAAE,CAAC;CAI5C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const notificationsResource = (http) => ({
|
|
2
|
+
list: () => http.request('/v1/notifications'),
|
|
3
|
+
markRead: (id) => http.request(`/v1/notifications/${id}/read`, {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
body: '{}',
|
|
6
|
+
}),
|
|
7
|
+
unread: async () => {
|
|
8
|
+
const page = await http.request('/v1/notifications');
|
|
9
|
+
return page.items.filter((item) => item.readAt === null);
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/resources/notifications.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAgB,EAAE,EAAE,CAAC,CAAC;IAC1D,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAyB,mBAAmB,CAAC;IACrE,QAAQ,EAAE,CAAC,EAAU,EAAE,EAAE,CACvB,IAAI,CAAC,OAAO,CAAiB,qBAAqB,EAAE,OAAO,EAAE;QAC3D,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI;KACX,CAAC;IACJ,MAAM,EAAE,KAAK,IAAgC,EAAE;QAC7C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAyB,mBAAmB,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;IAC3D,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { AcceptInviteCommand, CreateOrganizationCommand, InviteMemberCommand, UpdateOrganizationCommand } from '@ysk-kit/contracts';
|
|
2
|
+
import type { HttpClient } from '../http';
|
|
3
|
+
export declare const organizationsResource: (http: HttpClient) => {
|
|
4
|
+
create: (body: CreateOrganizationCommand) => Promise<{
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
createdAt: string;
|
|
8
|
+
}>;
|
|
9
|
+
list: () => Promise<{
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
}[]>;
|
|
14
|
+
get: (organizationId: string) => Promise<{
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
}>;
|
|
19
|
+
update: (organizationId: string, body: UpdateOrganizationCommand) => Promise<{
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
}>;
|
|
24
|
+
members: (organizationId: string) => Promise<{
|
|
25
|
+
id: string;
|
|
26
|
+
organizationId: string;
|
|
27
|
+
userId: string;
|
|
28
|
+
email: string | null;
|
|
29
|
+
displayName: string;
|
|
30
|
+
role: "ADMIN" | "OWNER" | "MEMBER";
|
|
31
|
+
createdAt: string;
|
|
32
|
+
}[]>;
|
|
33
|
+
invite: (organizationId: string, body: InviteMemberCommand) => Promise<{
|
|
34
|
+
id: string;
|
|
35
|
+
organizationId: string;
|
|
36
|
+
email: string;
|
|
37
|
+
role: "ADMIN" | "MEMBER";
|
|
38
|
+
createdAt: string;
|
|
39
|
+
expiresAt: string;
|
|
40
|
+
}>;
|
|
41
|
+
invites: (organizationId: string) => Promise<{
|
|
42
|
+
id: string;
|
|
43
|
+
organizationId: string;
|
|
44
|
+
email: string;
|
|
45
|
+
role: "ADMIN" | "MEMBER";
|
|
46
|
+
createdAt: string;
|
|
47
|
+
expiresAt: string;
|
|
48
|
+
}[]>;
|
|
49
|
+
revokeInvite: (organizationId: string, id: string) => Promise<{
|
|
50
|
+
removed: true;
|
|
51
|
+
}>;
|
|
52
|
+
removeMember: (organizationId: string, userId: string) => Promise<{
|
|
53
|
+
removed: true;
|
|
54
|
+
}>;
|
|
55
|
+
leave: (organizationId: string) => Promise<{
|
|
56
|
+
left: true;
|
|
57
|
+
}>;
|
|
58
|
+
acceptInvite: (body: AcceptInviteCommand) => Promise<{
|
|
59
|
+
accepted: true;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=organizations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizations.d.ts","sourceRoot":"","sources":["../../src/resources/organizations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EAInB,yBAAyB,EAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,qBAAqB,GAAI,MAAM,UAAU;mBACrC,yBAAyB;;;;;;;;;;0BAMlB,MAAM;;;;;6BAEH,MAAM,QAAQ,yBAAyB;;;;;8BAKtC,MAAM;;;;;;;;;6BAEP,MAAM,QAAQ,mBAAmB;;;;;;;;8BAKhC,MAAM;;;;;;;;mCAED,MAAM,MAAM,MAAM;iBACvB,IAAI;;mCAGC,MAAM,UAAU,MAAM;iBAC3B,IAAI;;4BAGN,MAAM;cACP,IAAI;;yBAIN,mBAAmB;kBACb,IAAI;;CAI/B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const organizationsResource = (http) => ({
|
|
2
|
+
create: (body) => http.request('/v1/organizations', {
|
|
3
|
+
method: 'POST',
|
|
4
|
+
body: JSON.stringify(body),
|
|
5
|
+
}),
|
|
6
|
+
list: () => http.request('/v1/organizations'),
|
|
7
|
+
get: (organizationId) => http.request(`/v1/organizations/${organizationId}`),
|
|
8
|
+
update: (organizationId, body) => http.request(`/v1/organizations/${organizationId}`, {
|
|
9
|
+
method: 'PATCH',
|
|
10
|
+
body: JSON.stringify(body),
|
|
11
|
+
}),
|
|
12
|
+
members: (organizationId) => http.request(`/v1/organizations/${organizationId}/members`),
|
|
13
|
+
invite: (organizationId, body) => http.request(`/v1/organizations/${organizationId}/invites`, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
body: JSON.stringify(body),
|
|
16
|
+
}),
|
|
17
|
+
invites: (organizationId) => http.request(`/v1/organizations/${organizationId}/invites`),
|
|
18
|
+
revokeInvite: (organizationId, id) => http.request(`/v1/organizations/${organizationId}/invites/${id}`, {
|
|
19
|
+
method: 'DELETE',
|
|
20
|
+
}),
|
|
21
|
+
removeMember: (organizationId, userId) => http.request(`/v1/organizations/${organizationId}/members/${userId}`, {
|
|
22
|
+
method: 'DELETE',
|
|
23
|
+
}),
|
|
24
|
+
leave: (organizationId) => http.request(`/v1/organizations/${organizationId}/leave`, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
body: '{}',
|
|
27
|
+
}),
|
|
28
|
+
acceptInvite: (body) => http.request('/v1/organizations/invites/accept', {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
body: JSON.stringify(body),
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=organizations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizations.js","sourceRoot":"","sources":["../../src/resources/organizations.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAgB,EAAE,EAAE,CAAC,CAAC;IAC1D,MAAM,EAAE,CAAC,IAA+B,EAAE,EAAE,CAC1C,IAAI,CAAC,OAAO,CAAkB,mBAAmB,EAAE;QACjD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC;IACJ,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAoB,mBAAmB,CAAC;IAChE,GAAG,EAAE,CAAC,cAAsB,EAAE,EAAE,CAC9B,IAAI,CAAC,OAAO,CAAkB,qBAAqB,cAAc,EAAE,CAAC;IACtE,MAAM,EAAE,CAAC,cAAsB,EAAE,IAA+B,EAAE,EAAE,CAClE,IAAI,CAAC,OAAO,CAAkB,qBAAqB,cAAc,EAAE,EAAE;QACnE,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC;IACJ,OAAO,E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