@sekolaos/shared-api 1.3.0 → 1.3.1
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/dist/{chunk-PMN2DTYF.js → chunk-H5WMOGLJ.js} +36 -4
- package/dist/chunk-H5WMOGLJ.js.map +1 -0
- package/dist/{chunk-OVHSXH7Z.cjs → chunk-NVU4IIMA.cjs} +38 -2
- package/dist/chunk-NVU4IIMA.cjs.map +1 -0
- package/dist/index.cjs +29 -13
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/modules/auth/index.cjs +29 -13
- package/dist/modules/auth/index.d.cts +33 -3
- package/dist/modules/auth/index.d.ts +33 -3
- package/dist/modules/auth/index.js +1 -1
- package/package.json +137 -138
- package/dist/chunk-OVHSXH7Z.cjs.map +0 -1
- package/dist/chunk-PMN2DTYF.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { API_ENDPOINTS } from './chunk-Q5ZX6TKB.js';
|
|
2
2
|
import { postData, getData, putData } from './chunk-6JGO2CUT.js';
|
|
3
3
|
import { authKeys } from './chunk-XNH67ORL.js';
|
|
4
|
-
import {
|
|
4
|
+
import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
|
|
5
5
|
|
|
6
6
|
var ENDPOINT = API_ENDPOINTS.auth;
|
|
7
7
|
async function login(payload) {
|
|
@@ -22,6 +22,38 @@ async function getMe() {
|
|
|
22
22
|
async function changePassword(payload) {
|
|
23
23
|
return putData(`${ENDPOINT}/change-password`, payload);
|
|
24
24
|
}
|
|
25
|
+
async function consumeImpersonation(payload) {
|
|
26
|
+
const res = await postData(
|
|
27
|
+
`${ENDPOINT}/impersonate/consume`,
|
|
28
|
+
payload
|
|
29
|
+
);
|
|
30
|
+
return res.session;
|
|
31
|
+
}
|
|
32
|
+
async function exitImpersonation() {
|
|
33
|
+
await postData(`${ENDPOINT}/impersonate/exit`);
|
|
34
|
+
}
|
|
35
|
+
function useConsumeImpersonation(options) {
|
|
36
|
+
const queryClient = useQueryClient();
|
|
37
|
+
return useMutation({
|
|
38
|
+
mutationFn: consumeImpersonation,
|
|
39
|
+
onSuccess: (data, variables, context) => {
|
|
40
|
+
queryClient.invalidateQueries({ queryKey: authKeys.all });
|
|
41
|
+
options?.onSuccess?.(data, variables, context);
|
|
42
|
+
},
|
|
43
|
+
...options
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function useExitImpersonation(options) {
|
|
47
|
+
const queryClient = useQueryClient();
|
|
48
|
+
return useMutation({
|
|
49
|
+
mutationFn: exitImpersonation,
|
|
50
|
+
onSuccess: () => {
|
|
51
|
+
queryClient.clear();
|
|
52
|
+
options?.onSuccess?.(void 0, void 0, void 0);
|
|
53
|
+
},
|
|
54
|
+
...options
|
|
55
|
+
});
|
|
56
|
+
}
|
|
25
57
|
function useMe(options) {
|
|
26
58
|
return useQuery({
|
|
27
59
|
queryKey: authKeys.me(),
|
|
@@ -84,6 +116,6 @@ function useChangePassword(options) {
|
|
|
84
116
|
});
|
|
85
117
|
}
|
|
86
118
|
|
|
87
|
-
export { changePassword, getMe, login, logout, selectTenant, switchRole, useChangePassword, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole };
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
119
|
+
export { changePassword, consumeImpersonation, exitImpersonation, getMe, login, logout, selectTenant, switchRole, useChangePassword, useConsumeImpersonation, useExitImpersonation, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole };
|
|
120
|
+
//# sourceMappingURL=chunk-H5WMOGLJ.js.map
|
|
121
|
+
//# sourceMappingURL=chunk-H5WMOGLJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/modules/auth/auth.api.ts"],"names":[],"mappings":";;;;;AAmBA,IAAM,WAAW,aAAA,CAAc,IAAA;AAgB/B,eAAsB,MAAM,OAAA,EA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","file":"chunk-H5WMOGLJ.js","sourcesContent":["import type {\r\n AuthSession,\r\n ChangePasswordRequest,\r\n ConsumeImpersonationRequest,\r\n LoginRequest,\r\n LoginResponse,\r\n Role,\r\n SelectTenantRequest,\r\n SwitchRoleRequest,\r\n Tenant,\r\n TenantOption,\r\n UserProfile,\r\n} from \"@sekolaos/shared-schema\";\r\nimport { API_ENDPOINTS } from \"../../common/endpoints\";\r\nimport { getData, postData, putData } from \"../../client/http\";\r\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\r\nimport { authKeys } from \"../../keys\";\r\nimport type { MutationOptionsCustom, QueryOptionsWithoutKey } from \"../../client/types\";\r\n\r\nconst ENDPOINT = API_ENDPOINTS.auth;\r\n\r\nexport interface AuthUserSummary {\r\n id: string;\r\n username: string;\r\n email: string | null;\r\n fullName: string;\r\n}\r\n\r\n/** Payload `GET /auth/me`: sesi + profil ringkas user + tenant aktif. */\r\nexport interface AuthSessionPayload {\r\n session: AuthSession;\r\n user: AuthUserSummary;\r\n tenant: Tenant;\r\n}\r\n\r\nexport async function login(payload: LoginRequest): Promise<LoginResponse> {\r\n return postData<LoginResponse, LoginRequest>(`${ENDPOINT}/login`, payload);\r\n}\r\n\r\nexport async function selectTenant(payload: SelectTenantRequest): Promise<LoginResponse> {\r\n return postData<LoginResponse, SelectTenantRequest>(`${ENDPOINT}/select-tenant`, payload);\r\n}\r\n\r\nexport async function switchRole(payload: SwitchRoleRequest): Promise<AuthSession> {\r\n return postData<AuthSession, SwitchRoleRequest>(`${ENDPOINT}/switch-role`, payload);\r\n}\r\n\r\nexport async function logout(): Promise<void> {\r\n await postData<void>(`${ENDPOINT}/logout`);\r\n}\r\n\r\nexport async function getMe(): Promise<AuthSession> {\r\n return getData<AuthSession>(`${ENDPOINT}/me`);\r\n}\r\n\r\nexport async function changePassword(payload: ChangePasswordRequest): Promise<{ message: string }> {\r\n return putData<{ message: string }, ChangePasswordRequest>(`${ENDPOINT}/change-password`, payload);\r\n}\r\n\r\n/** Konsumsi token impersonasi dari sekolaos-admin, terbitkan sesi sekolah dengan isImpersonating: true. */\r\nexport async function consumeImpersonation(payload: ConsumeImpersonationRequest): Promise<AuthSession> {\r\n const res = await postData<{ session: AuthSession }, ConsumeImpersonationRequest>(\r\n `${ENDPOINT}/impersonate/consume`,\r\n payload\r\n );\r\n return res.session;\r\n}\r\n\r\n/** Keluar dari mode penyamaran: hapus cookie sesi sekolah. */\r\nexport async function exitImpersonation(): Promise<void> {\r\n await postData<void>(`${ENDPOINT}/impersonate/exit`);\r\n}\r\n\r\nexport function useConsumeImpersonation(options?: MutationOptionsCustom<AuthSession, ConsumeImpersonationRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: consumeImpersonation,\r\n onSuccess: (data, variables, context) => {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useExitImpersonation(options?: MutationOptionsCustom<void, void>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: exitImpersonation,\r\n onSuccess: () => {\r\n queryClient.clear();\r\n options?.onSuccess?.(undefined, undefined, undefined);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useMe(options?: QueryOptionsWithoutKey<AuthSession> & { enabled?: boolean }) {\r\n return useQuery({\r\n queryKey: authKeys.me(),\r\n queryFn: getMe,\r\n enabled: options?.enabled ?? true,\r\n staleTime: 60_000,\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useLogin(options?: MutationOptionsCustom<LoginResponse, LoginRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: login,\r\n onSuccess: (data, variables, context) => {\r\n if (data.status === \"SUCCESS\") {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n }\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useSelectTenant(options?: MutationOptionsCustom<LoginResponse, SelectTenantRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: selectTenant,\r\n onSuccess: (data, variables, context) => {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useSwitchRole(options?: MutationOptionsCustom<AuthSession, SwitchRoleRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: switchRole,\r\n onSuccess: (data, variables, context) => {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useLogout(options?: MutationOptionsCustom<void, void>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: logout,\r\n onSuccess: () => {\r\n queryClient.clear();\r\n options?.onSuccess?.(undefined, undefined, undefined);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useChangePassword(options?: MutationOptionsCustom<{ message: string }, ChangePasswordRequest>) {\r\n return useMutation({\r\n mutationFn: changePassword,\r\n ...options,\r\n });\r\n}\r\n\r\nexport type {\r\n AuthSession,\r\n ChangePasswordRequest,\r\n ConsumeImpersonationRequest,\r\n LoginRequest,\r\n LoginResponse,\r\n Role,\r\n SelectTenantRequest,\r\n SwitchRoleRequest,\r\n TenantOption,\r\n UserProfile,\r\n};\r\n"]}
|
|
@@ -24,6 +24,38 @@ async function getMe() {
|
|
|
24
24
|
async function changePassword(payload) {
|
|
25
25
|
return chunkNGFFI4XQ_cjs.putData(`${ENDPOINT}/change-password`, payload);
|
|
26
26
|
}
|
|
27
|
+
async function consumeImpersonation(payload) {
|
|
28
|
+
const res = await chunkNGFFI4XQ_cjs.postData(
|
|
29
|
+
`${ENDPOINT}/impersonate/consume`,
|
|
30
|
+
payload
|
|
31
|
+
);
|
|
32
|
+
return res.session;
|
|
33
|
+
}
|
|
34
|
+
async function exitImpersonation() {
|
|
35
|
+
await chunkNGFFI4XQ_cjs.postData(`${ENDPOINT}/impersonate/exit`);
|
|
36
|
+
}
|
|
37
|
+
function useConsumeImpersonation(options) {
|
|
38
|
+
const queryClient = reactQuery.useQueryClient();
|
|
39
|
+
return reactQuery.useMutation({
|
|
40
|
+
mutationFn: consumeImpersonation,
|
|
41
|
+
onSuccess: (data, variables, context) => {
|
|
42
|
+
queryClient.invalidateQueries({ queryKey: chunkHISL2IF2_cjs.authKeys.all });
|
|
43
|
+
options?.onSuccess?.(data, variables, context);
|
|
44
|
+
},
|
|
45
|
+
...options
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function useExitImpersonation(options) {
|
|
49
|
+
const queryClient = reactQuery.useQueryClient();
|
|
50
|
+
return reactQuery.useMutation({
|
|
51
|
+
mutationFn: exitImpersonation,
|
|
52
|
+
onSuccess: () => {
|
|
53
|
+
queryClient.clear();
|
|
54
|
+
options?.onSuccess?.(void 0, void 0, void 0);
|
|
55
|
+
},
|
|
56
|
+
...options
|
|
57
|
+
});
|
|
58
|
+
}
|
|
27
59
|
function useMe(options) {
|
|
28
60
|
return reactQuery.useQuery({
|
|
29
61
|
queryKey: chunkHISL2IF2_cjs.authKeys.me(),
|
|
@@ -87,16 +119,20 @@ function useChangePassword(options) {
|
|
|
87
119
|
}
|
|
88
120
|
|
|
89
121
|
exports.changePassword = changePassword;
|
|
122
|
+
exports.consumeImpersonation = consumeImpersonation;
|
|
123
|
+
exports.exitImpersonation = exitImpersonation;
|
|
90
124
|
exports.getMe = getMe;
|
|
91
125
|
exports.login = login;
|
|
92
126
|
exports.logout = logout;
|
|
93
127
|
exports.selectTenant = selectTenant;
|
|
94
128
|
exports.switchRole = switchRole;
|
|
95
129
|
exports.useChangePassword = useChangePassword;
|
|
130
|
+
exports.useConsumeImpersonation = useConsumeImpersonation;
|
|
131
|
+
exports.useExitImpersonation = useExitImpersonation;
|
|
96
132
|
exports.useLogin = useLogin;
|
|
97
133
|
exports.useLogout = useLogout;
|
|
98
134
|
exports.useMe = useMe;
|
|
99
135
|
exports.useSelectTenant = useSelectTenant;
|
|
100
136
|
exports.useSwitchRole = useSwitchRole;
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
137
|
+
//# sourceMappingURL=chunk-NVU4IIMA.cjs.map
|
|
138
|
+
//# sourceMappingURL=chunk-NVU4IIMA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/modules/auth/auth.api.ts"],"names":["API_ENDPOINTS","postData","getData","putData","useQueryClient","useMutation","authKeys","useQuery"],"mappings":";;;;;;;AAmBA,IAAM,WAAWA,+BAAA,CAAc,IAAA;AAgB/B,eAAsB,MAAM,OAAA,EAA+C;AACzE,EAAA,OAAOC,0BAAA,CAAsC,CAAA,EAAG,QAAQ,CAAA,MAAA,CAAA,EAAU,OAAO,CAAA;AAC3E;AAEA,eAAsB,aAAa,OAAA,EAAsD;AACvF,EAAA,OAAOA,0BAAA,CAA6C,CAAA,EAAG,QAAQ,CAAA,cAAA,CAAA,EAAkB,OAAO,CAAA;AAC1F;AAEA,eAAsB,WAAW,OAAA,EAAkD;AACjF,EAAA,OAAOA,0BAAA,CAAyC,CAAA,EAAG,QAAQ,CAAA,YAAA,CAAA,EAAgB,OAAO,CAAA;AACpF;AAEA,eAAsB,MAAA,GAAwB;AAC5C,EAAA,MAAMA,0BAAA,CAAe,CAAA,EAAG,QAAQ,CAAA,OAAA,CAAS,CAAA;AAC3C;AAEA,eAAsB,KAAA,GAA8B;AAClD,EAAA,OAAOC,yBAAA,CAAqB,CAAA,EAAG,QAAQ,CAAA,GAAA,CAAK,CAAA;AAC9C;AAEA,eAAsB,eAAe,OAAA,EAA8D;AACjG,EAAA,OAAOC,yBAAA,CAAoD,CAAA,EAAG,QAAQ,CAAA,gBAAA,CAAA,EAAoB,OAAO,CAAA;AACnG;AAGA,eAAsB,qBAAqB,OAAA,EAA4D;AACrG,EAAA,MAAM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AAW,OAAO,CAAA;AAAA,IAC/C,CAAA;AAAA,IACA,GAAG;AAAA,GACJ,CAAA;AACH;AAEO,SAAS,UAAU,OAAA,EAA6C;AACrE,EAAA,MAAM,cAAcF,yBAAA,EAAe;AACnC,EAAA,OAAOC,sBAAA,CAAY;AAAA,IACjB,UAAA,EAAY,MAAA;AAAA,IACZ,WAAW,MAAM;AACf,MAAA,WAAA,CAAY,KAAA,EAAM;AAClB,MAAA,OAAA,EAAS,SAAA,GAAY,MAAA,EAAW,MAAA,EAAW,MAAS,CAAA;AAAA,IACtD,CAAA;AAAA,IACA,GAAG;AAAA,GACJ,CAAA;AACH;AAEO,SAAS,kBAAkB,OAAA,EAA6E;AAC7G,EAAA,OAAOA,sBAAA,CAAY;AAAA,IACjB,UAAA,EAAY,cAAA;AAAA,IACZ,GAAG;AAAA,GACJ,CAAA;AACH","file":"chunk-NVU4IIMA.cjs","sourcesContent":["import type {\r\n AuthSession,\r\n ChangePasswordRequest,\r\n ConsumeImpersonationRequest,\r\n LoginRequest,\r\n LoginResponse,\r\n Role,\r\n SelectTenantRequest,\r\n SwitchRoleRequest,\r\n Tenant,\r\n TenantOption,\r\n UserProfile,\r\n} from \"@sekolaos/shared-schema\";\r\nimport { API_ENDPOINTS } from \"../../common/endpoints\";\r\nimport { getData, postData, putData } from \"../../client/http\";\r\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\r\nimport { authKeys } from \"../../keys\";\r\nimport type { MutationOptionsCustom, QueryOptionsWithoutKey } from \"../../client/types\";\r\n\r\nconst ENDPOINT = API_ENDPOINTS.auth;\r\n\r\nexport interface AuthUserSummary {\r\n id: string;\r\n username: string;\r\n email: string | null;\r\n fullName: string;\r\n}\r\n\r\n/** Payload `GET /auth/me`: sesi + profil ringkas user + tenant aktif. */\r\nexport interface AuthSessionPayload {\r\n session: AuthSession;\r\n user: AuthUserSummary;\r\n tenant: Tenant;\r\n}\r\n\r\nexport async function login(payload: LoginRequest): Promise<LoginResponse> {\r\n return postData<LoginResponse, LoginRequest>(`${ENDPOINT}/login`, payload);\r\n}\r\n\r\nexport async function selectTenant(payload: SelectTenantRequest): Promise<LoginResponse> {\r\n return postData<LoginResponse, SelectTenantRequest>(`${ENDPOINT}/select-tenant`, payload);\r\n}\r\n\r\nexport async function switchRole(payload: SwitchRoleRequest): Promise<AuthSession> {\r\n return postData<AuthSession, SwitchRoleRequest>(`${ENDPOINT}/switch-role`, payload);\r\n}\r\n\r\nexport async function logout(): Promise<void> {\r\n await postData<void>(`${ENDPOINT}/logout`);\r\n}\r\n\r\nexport async function getMe(): Promise<AuthSession> {\r\n return getData<AuthSession>(`${ENDPOINT}/me`);\r\n}\r\n\r\nexport async function changePassword(payload: ChangePasswordRequest): Promise<{ message: string }> {\r\n return putData<{ message: string }, ChangePasswordRequest>(`${ENDPOINT}/change-password`, payload);\r\n}\r\n\r\n/** Konsumsi token impersonasi dari sekolaos-admin, terbitkan sesi sekolah dengan isImpersonating: true. */\r\nexport async function consumeImpersonation(payload: ConsumeImpersonationRequest): Promise<AuthSession> {\r\n const res = await postData<{ session: AuthSession }, ConsumeImpersonationRequest>(\r\n `${ENDPOINT}/impersonate/consume`,\r\n payload\r\n );\r\n return res.session;\r\n}\r\n\r\n/** Keluar dari mode penyamaran: hapus cookie sesi sekolah. */\r\nexport async function exitImpersonation(): Promise<void> {\r\n await postData<void>(`${ENDPOINT}/impersonate/exit`);\r\n}\r\n\r\nexport function useConsumeImpersonation(options?: MutationOptionsCustom<AuthSession, ConsumeImpersonationRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: consumeImpersonation,\r\n onSuccess: (data, variables, context) => {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useExitImpersonation(options?: MutationOptionsCustom<void, void>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: exitImpersonation,\r\n onSuccess: () => {\r\n queryClient.clear();\r\n options?.onSuccess?.(undefined, undefined, undefined);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useMe(options?: QueryOptionsWithoutKey<AuthSession> & { enabled?: boolean }) {\r\n return useQuery({\r\n queryKey: authKeys.me(),\r\n queryFn: getMe,\r\n enabled: options?.enabled ?? true,\r\n staleTime: 60_000,\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useLogin(options?: MutationOptionsCustom<LoginResponse, LoginRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: login,\r\n onSuccess: (data, variables, context) => {\r\n if (data.status === \"SUCCESS\") {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n }\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useSelectTenant(options?: MutationOptionsCustom<LoginResponse, SelectTenantRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: selectTenant,\r\n onSuccess: (data, variables, context) => {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useSwitchRole(options?: MutationOptionsCustom<AuthSession, SwitchRoleRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: switchRole,\r\n onSuccess: (data, variables, context) => {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useLogout(options?: MutationOptionsCustom<void, void>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: logout,\r\n onSuccess: () => {\r\n queryClient.clear();\r\n options?.onSuccess?.(undefined, undefined, undefined);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useChangePassword(options?: MutationOptionsCustom<{ message: string }, ChangePasswordRequest>) {\r\n return useMutation({\r\n mutationFn: changePassword,\r\n ...options,\r\n });\r\n}\r\n\r\nexport type {\r\n AuthSession,\r\n ChangePasswordRequest,\r\n ConsumeImpersonationRequest,\r\n LoginRequest,\r\n LoginResponse,\r\n Role,\r\n SelectTenantRequest,\r\n SwitchRoleRequest,\r\n TenantOption,\r\n UserProfile,\r\n};\r\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -13,7 +13,7 @@ var chunk2FTS6JMO_cjs = require('./chunk-2FTS6JMO.cjs');
|
|
|
13
13
|
require('./chunk-WF63F6RJ.cjs');
|
|
14
14
|
var chunkBBJBCD2K_cjs = require('./chunk-BBJBCD2K.cjs');
|
|
15
15
|
var chunkJVX37TC5_cjs = require('./chunk-JVX37TC5.cjs');
|
|
16
|
-
var
|
|
16
|
+
var chunkNVU4IIMA_cjs = require('./chunk-NVU4IIMA.cjs');
|
|
17
17
|
var chunkAMKVNGY4_cjs = require('./chunk-AMKVNGY4.cjs');
|
|
18
18
|
var chunk3TOBH3YY_cjs = require('./chunk-3TOBH3YY.cjs');
|
|
19
19
|
var chunkNGFFI4XQ_cjs = require('./chunk-NGFFI4XQ.cjs');
|
|
@@ -502,51 +502,67 @@ Object.defineProperty(exports, "verifyDynamicQr", {
|
|
|
502
502
|
});
|
|
503
503
|
Object.defineProperty(exports, "changePassword", {
|
|
504
504
|
enumerable: true,
|
|
505
|
-
get: function () { return
|
|
505
|
+
get: function () { return chunkNVU4IIMA_cjs.changePassword; }
|
|
506
|
+
});
|
|
507
|
+
Object.defineProperty(exports, "consumeImpersonation", {
|
|
508
|
+
enumerable: true,
|
|
509
|
+
get: function () { return chunkNVU4IIMA_cjs.consumeImpersonation; }
|
|
510
|
+
});
|
|
511
|
+
Object.defineProperty(exports, "exitImpersonation", {
|
|
512
|
+
enumerable: true,
|
|
513
|
+
get: function () { return chunkNVU4IIMA_cjs.exitImpersonation; }
|
|
506
514
|
});
|
|
507
515
|
Object.defineProperty(exports, "getMe", {
|
|
508
516
|
enumerable: true,
|
|
509
|
-
get: function () { return
|
|
517
|
+
get: function () { return chunkNVU4IIMA_cjs.getMe; }
|
|
510
518
|
});
|
|
511
519
|
Object.defineProperty(exports, "login", {
|
|
512
520
|
enumerable: true,
|
|
513
|
-
get: function () { return
|
|
521
|
+
get: function () { return chunkNVU4IIMA_cjs.login; }
|
|
514
522
|
});
|
|
515
523
|
Object.defineProperty(exports, "logout", {
|
|
516
524
|
enumerable: true,
|
|
517
|
-
get: function () { return
|
|
525
|
+
get: function () { return chunkNVU4IIMA_cjs.logout; }
|
|
518
526
|
});
|
|
519
527
|
Object.defineProperty(exports, "selectTenant", {
|
|
520
528
|
enumerable: true,
|
|
521
|
-
get: function () { return
|
|
529
|
+
get: function () { return chunkNVU4IIMA_cjs.selectTenant; }
|
|
522
530
|
});
|
|
523
531
|
Object.defineProperty(exports, "switchRole", {
|
|
524
532
|
enumerable: true,
|
|
525
|
-
get: function () { return
|
|
533
|
+
get: function () { return chunkNVU4IIMA_cjs.switchRole; }
|
|
526
534
|
});
|
|
527
535
|
Object.defineProperty(exports, "useChangePassword", {
|
|
528
536
|
enumerable: true,
|
|
529
|
-
get: function () { return
|
|
537
|
+
get: function () { return chunkNVU4IIMA_cjs.useChangePassword; }
|
|
538
|
+
});
|
|
539
|
+
Object.defineProperty(exports, "useConsumeImpersonation", {
|
|
540
|
+
enumerable: true,
|
|
541
|
+
get: function () { return chunkNVU4IIMA_cjs.useConsumeImpersonation; }
|
|
542
|
+
});
|
|
543
|
+
Object.defineProperty(exports, "useExitImpersonation", {
|
|
544
|
+
enumerable: true,
|
|
545
|
+
get: function () { return chunkNVU4IIMA_cjs.useExitImpersonation; }
|
|
530
546
|
});
|
|
531
547
|
Object.defineProperty(exports, "useLogin", {
|
|
532
548
|
enumerable: true,
|
|
533
|
-
get: function () { return
|
|
549
|
+
get: function () { return chunkNVU4IIMA_cjs.useLogin; }
|
|
534
550
|
});
|
|
535
551
|
Object.defineProperty(exports, "useLogout", {
|
|
536
552
|
enumerable: true,
|
|
537
|
-
get: function () { return
|
|
553
|
+
get: function () { return chunkNVU4IIMA_cjs.useLogout; }
|
|
538
554
|
});
|
|
539
555
|
Object.defineProperty(exports, "useMe", {
|
|
540
556
|
enumerable: true,
|
|
541
|
-
get: function () { return
|
|
557
|
+
get: function () { return chunkNVU4IIMA_cjs.useMe; }
|
|
542
558
|
});
|
|
543
559
|
Object.defineProperty(exports, "useSelectTenant", {
|
|
544
560
|
enumerable: true,
|
|
545
|
-
get: function () { return
|
|
561
|
+
get: function () { return chunkNVU4IIMA_cjs.useSelectTenant; }
|
|
546
562
|
});
|
|
547
563
|
Object.defineProperty(exports, "useSwitchRole", {
|
|
548
564
|
enumerable: true,
|
|
549
|
-
get: function () { return
|
|
565
|
+
get: function () { return chunkNVU4IIMA_cjs.useSwitchRole; }
|
|
550
566
|
});
|
|
551
567
|
Object.defineProperty(exports, "createClassroom", {
|
|
552
568
|
enumerable: true,
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export { apiClient, configureApiClient, deleteData, getApiClientConfig, getData,
|
|
|
5
5
|
export { academicYearKeys, attendanceKeys, authKeys, classroomKeys, leadKeys, platformAdminKeys, scheduleKeys, studentKeys, subjectKeys, systemKeys, tenantKeys, uploadKeys, userKeys } from './keys/index.cjs';
|
|
6
6
|
export { activateAcademicYear, createAcademicYear, listAcademicYears, updateAcademicYear, useAcademicYears, useActivateAcademicYear, useCreateAcademicYear, useUpdateAcademicYear } from './modules/academic/index.cjs';
|
|
7
7
|
export { batchSyncAttendance, createPicketAssignment, getAttendanceHistory, getDynamicQrStream, listPicketSchedules, updateClassAttendance, useAttendanceHistory, useBatchSyncAttendance, useCreatePicketAssignment, useDynamicQrStream, usePicketSchedules, useUpdateClassAttendance, useVerifyDynamicQr, verifyDynamicQr } from './modules/attendance/index.cjs';
|
|
8
|
-
export { AuthSessionPayload, AuthUserSummary, changePassword, getMe, login, logout, selectTenant, switchRole, useChangePassword, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole } from './modules/auth/index.cjs';
|
|
8
|
+
export { AuthSessionPayload, AuthUserSummary, changePassword, consumeImpersonation, exitImpersonation, getMe, login, logout, selectTenant, switchRole, useChangePassword, useConsumeImpersonation, useExitImpersonation, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole } from './modules/auth/index.cjs';
|
|
9
9
|
export { createClassroom, getClassroom, getClassroomStudents, listClassrooms, promoteClassStudents, updateClassroom, useClassroom, useClassroomStudents, useClassrooms, useCreateClassroom, usePromoteClassStudents, useUpdateClassroom } from './modules/classroom/index.cjs';
|
|
10
10
|
export { createLeadInquiry, listLeads, requestDemoSchedule, updateLeadStatus, useCreateLeadInquiry, useLeads, useRequestDemoSchedule, useUpdateLeadStatus } from './modules/lead/index.cjs';
|
|
11
11
|
export { ImpersonationTokenResult, createImpersonationToken, getPlatformAuditLogs, getPlatformLeads, getPlatformMe, getPlatformMetrics, getPlatformTenants, platformAdminLogin, platformAdminLogout, provisionTenant, updatePlatformLeadStatus, updatePlatformTenantModules, updatePlatformTenantStatus, useImpersonateTenantMutation, usePlatformLeads, usePlatformMe, usePlatformMetrics, usePlatformTenants, useProvisionTenantMutation, useUpdatePlatformLeadStatusMutation, useUpdatePlatformTenantModulesMutation, useUpdatePlatformTenantStatusMutation } from './modules/platform-admin/index.cjs';
|
|
@@ -16,7 +16,7 @@ export { AffectedRowsResult, ScheduleConflictResult, ScheduleConflictType, batch
|
|
|
16
16
|
export { UpsertAttendanceShiftsPayload, createTenant, getAttendanceShift, getCurrentTenant, getTenantModules, listAttendanceShifts, updateCurrentTenant, upsertAttendanceShifts, useAttendanceShift, useAttendanceShifts, useCreateTenant, useCurrentTenant, useTenantModules, useUpdateCurrentTenant, useUpsertAttendanceShifts } from './modules/tenant/index.cjs';
|
|
17
17
|
export { uploadStudentPhoto, uploadTenantLogo, useUploadStudentPhoto, useUploadTenantLogo } from './modules/upload/index.cjs';
|
|
18
18
|
export { assignUserRoles, createTeacher, getTeacher, listRoles, listTeachers, updateTeacher, useAssignUserRoles, useCreateTeacher, useRoles, useTeacher, useTeachers, useUpdateTeacher } from './modules/user/index.cjs';
|
|
19
|
-
export { AcademicYear, AcademicYearListQuery, AssignUserRolesRequest, AttendanceHistoryItem, AttendanceHistoryQuery, AttendanceHistoryResult, AttendanceShift, AuthSession, BatchCreateTeachingScheduleInput, BatchSyncAttendanceRequest, BatchSyncAttendanceResponse, BulkImportStudentRequest, BulkImportStudentResponse, ChangePasswordRequest, CheckScheduleConflictQuery, ClassRoom, ClassUpdateAttendanceResult, ClassroomListQuery, CopyRosterRequestInput, CreateAcademicYearInput, CreateClassroomInput, CreateLeadInquiryInput, CreatePicketAssignmentInput, CreateStudentInput, CreateSubjectInput, CreateTeacherInput, CreateTeachingScheduleInput, CreateTenantInput, DemoScheduleRequestInput, DynamicQrStreamQuery, DynamicQrStreamResult, DynamicQrVerifyResult, LeadInquiry, LeadStatus, LoginRequest, LoginResponse, PaginationQuery, PicketAssignment, PicketScheduleListQuery, PlatformLoginRequest, PlatformMetricsResponse, PlatformUser, PortalModuleItem, PromoteClassStudentsInput, ProvisionTenantRequest, Role, SelectTenantRequest, ShiftTargetType, Student, StudentListQuery, StudentOfflineCache, StudentQrPayload, Subject, SubjectListQuery, SwitchRoleRequest, TeacherListQuery, TeacherScanDynamicQrRequest, TeachingSchedule, TeachingScheduleListQuery, Tenant, TenantOption, TenantStatus, UpdateAcademicYearInput, UpdateClassAttendanceRequest, UpdateClassroomInput, UpdateStudentInput, UpdateSubjectInput, UpdateTeacherInput, UpdateTeachingScheduleInput, UpdateTenantModuleConfig, UpdateTenantProfileInput, UpdateTenantStatusRequest, UpsertAttendanceShiftInput, User, UserProfile } from '@sekolaos/shared-schema';
|
|
19
|
+
export { AcademicYear, AcademicYearListQuery, AssignUserRolesRequest, AttendanceHistoryItem, AttendanceHistoryQuery, AttendanceHistoryResult, AttendanceShift, AuthSession, BatchCreateTeachingScheduleInput, BatchSyncAttendanceRequest, BatchSyncAttendanceResponse, BulkImportStudentRequest, BulkImportStudentResponse, ChangePasswordRequest, CheckScheduleConflictQuery, ClassRoom, ClassUpdateAttendanceResult, ClassroomListQuery, ConsumeImpersonationRequest, CopyRosterRequestInput, CreateAcademicYearInput, CreateClassroomInput, CreateLeadInquiryInput, CreatePicketAssignmentInput, CreateStudentInput, CreateSubjectInput, CreateTeacherInput, CreateTeachingScheduleInput, CreateTenantInput, DemoScheduleRequestInput, DynamicQrStreamQuery, DynamicQrStreamResult, DynamicQrVerifyResult, LeadInquiry, LeadStatus, LoginRequest, LoginResponse, PaginationQuery, PicketAssignment, PicketScheduleListQuery, PlatformLoginRequest, PlatformMetricsResponse, PlatformUser, PortalModuleItem, PromoteClassStudentsInput, ProvisionTenantRequest, Role, SelectTenantRequest, ShiftTargetType, Student, StudentListQuery, StudentOfflineCache, StudentQrPayload, Subject, SubjectListQuery, SwitchRoleRequest, TeacherListQuery, TeacherScanDynamicQrRequest, TeachingSchedule, TeachingScheduleListQuery, Tenant, TenantOption, TenantStatus, UpdateAcademicYearInput, UpdateClassAttendanceRequest, UpdateClassroomInput, UpdateStudentInput, UpdateSubjectInput, UpdateTeacherInput, UpdateTeachingScheduleInput, UpdateTenantModuleConfig, UpdateTenantProfileInput, UpdateTenantStatusRequest, UpsertAttendanceShiftInput, User, UserProfile } from '@sekolaos/shared-schema';
|
|
20
20
|
import 'react/jsx-runtime';
|
|
21
21
|
import 'react';
|
|
22
22
|
import 'axios';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { apiClient, configureApiClient, deleteData, getApiClientConfig, getData,
|
|
|
5
5
|
export { academicYearKeys, attendanceKeys, authKeys, classroomKeys, leadKeys, platformAdminKeys, scheduleKeys, studentKeys, subjectKeys, systemKeys, tenantKeys, uploadKeys, userKeys } from './keys/index.js';
|
|
6
6
|
export { activateAcademicYear, createAcademicYear, listAcademicYears, updateAcademicYear, useAcademicYears, useActivateAcademicYear, useCreateAcademicYear, useUpdateAcademicYear } from './modules/academic/index.js';
|
|
7
7
|
export { batchSyncAttendance, createPicketAssignment, getAttendanceHistory, getDynamicQrStream, listPicketSchedules, updateClassAttendance, useAttendanceHistory, useBatchSyncAttendance, useCreatePicketAssignment, useDynamicQrStream, usePicketSchedules, useUpdateClassAttendance, useVerifyDynamicQr, verifyDynamicQr } from './modules/attendance/index.js';
|
|
8
|
-
export { AuthSessionPayload, AuthUserSummary, changePassword, getMe, login, logout, selectTenant, switchRole, useChangePassword, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole } from './modules/auth/index.js';
|
|
8
|
+
export { AuthSessionPayload, AuthUserSummary, changePassword, consumeImpersonation, exitImpersonation, getMe, login, logout, selectTenant, switchRole, useChangePassword, useConsumeImpersonation, useExitImpersonation, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole } from './modules/auth/index.js';
|
|
9
9
|
export { createClassroom, getClassroom, getClassroomStudents, listClassrooms, promoteClassStudents, updateClassroom, useClassroom, useClassroomStudents, useClassrooms, useCreateClassroom, usePromoteClassStudents, useUpdateClassroom } from './modules/classroom/index.js';
|
|
10
10
|
export { createLeadInquiry, listLeads, requestDemoSchedule, updateLeadStatus, useCreateLeadInquiry, useLeads, useRequestDemoSchedule, useUpdateLeadStatus } from './modules/lead/index.js';
|
|
11
11
|
export { ImpersonationTokenResult, createImpersonationToken, getPlatformAuditLogs, getPlatformLeads, getPlatformMe, getPlatformMetrics, getPlatformTenants, platformAdminLogin, platformAdminLogout, provisionTenant, updatePlatformLeadStatus, updatePlatformTenantModules, updatePlatformTenantStatus, useImpersonateTenantMutation, usePlatformLeads, usePlatformMe, usePlatformMetrics, usePlatformTenants, useProvisionTenantMutation, useUpdatePlatformLeadStatusMutation, useUpdatePlatformTenantModulesMutation, useUpdatePlatformTenantStatusMutation } from './modules/platform-admin/index.js';
|
|
@@ -16,7 +16,7 @@ export { AffectedRowsResult, ScheduleConflictResult, ScheduleConflictType, batch
|
|
|
16
16
|
export { UpsertAttendanceShiftsPayload, createTenant, getAttendanceShift, getCurrentTenant, getTenantModules, listAttendanceShifts, updateCurrentTenant, upsertAttendanceShifts, useAttendanceShift, useAttendanceShifts, useCreateTenant, useCurrentTenant, useTenantModules, useUpdateCurrentTenant, useUpsertAttendanceShifts } from './modules/tenant/index.js';
|
|
17
17
|
export { uploadStudentPhoto, uploadTenantLogo, useUploadStudentPhoto, useUploadTenantLogo } from './modules/upload/index.js';
|
|
18
18
|
export { assignUserRoles, createTeacher, getTeacher, listRoles, listTeachers, updateTeacher, useAssignUserRoles, useCreateTeacher, useRoles, useTeacher, useTeachers, useUpdateTeacher } from './modules/user/index.js';
|
|
19
|
-
export { AcademicYear, AcademicYearListQuery, AssignUserRolesRequest, AttendanceHistoryItem, AttendanceHistoryQuery, AttendanceHistoryResult, AttendanceShift, AuthSession, BatchCreateTeachingScheduleInput, BatchSyncAttendanceRequest, BatchSyncAttendanceResponse, BulkImportStudentRequest, BulkImportStudentResponse, ChangePasswordRequest, CheckScheduleConflictQuery, ClassRoom, ClassUpdateAttendanceResult, ClassroomListQuery, CopyRosterRequestInput, CreateAcademicYearInput, CreateClassroomInput, CreateLeadInquiryInput, CreatePicketAssignmentInput, CreateStudentInput, CreateSubjectInput, CreateTeacherInput, CreateTeachingScheduleInput, CreateTenantInput, DemoScheduleRequestInput, DynamicQrStreamQuery, DynamicQrStreamResult, DynamicQrVerifyResult, LeadInquiry, LeadStatus, LoginRequest, LoginResponse, PaginationQuery, PicketAssignment, PicketScheduleListQuery, PlatformLoginRequest, PlatformMetricsResponse, PlatformUser, PortalModuleItem, PromoteClassStudentsInput, ProvisionTenantRequest, Role, SelectTenantRequest, ShiftTargetType, Student, StudentListQuery, StudentOfflineCache, StudentQrPayload, Subject, SubjectListQuery, SwitchRoleRequest, TeacherListQuery, TeacherScanDynamicQrRequest, TeachingSchedule, TeachingScheduleListQuery, Tenant, TenantOption, TenantStatus, UpdateAcademicYearInput, UpdateClassAttendanceRequest, UpdateClassroomInput, UpdateStudentInput, UpdateSubjectInput, UpdateTeacherInput, UpdateTeachingScheduleInput, UpdateTenantModuleConfig, UpdateTenantProfileInput, UpdateTenantStatusRequest, UpsertAttendanceShiftInput, User, UserProfile } from '@sekolaos/shared-schema';
|
|
19
|
+
export { AcademicYear, AcademicYearListQuery, AssignUserRolesRequest, AttendanceHistoryItem, AttendanceHistoryQuery, AttendanceHistoryResult, AttendanceShift, AuthSession, BatchCreateTeachingScheduleInput, BatchSyncAttendanceRequest, BatchSyncAttendanceResponse, BulkImportStudentRequest, BulkImportStudentResponse, ChangePasswordRequest, CheckScheduleConflictQuery, ClassRoom, ClassUpdateAttendanceResult, ClassroomListQuery, ConsumeImpersonationRequest, CopyRosterRequestInput, CreateAcademicYearInput, CreateClassroomInput, CreateLeadInquiryInput, CreatePicketAssignmentInput, CreateStudentInput, CreateSubjectInput, CreateTeacherInput, CreateTeachingScheduleInput, CreateTenantInput, DemoScheduleRequestInput, DynamicQrStreamQuery, DynamicQrStreamResult, DynamicQrVerifyResult, LeadInquiry, LeadStatus, LoginRequest, LoginResponse, PaginationQuery, PicketAssignment, PicketScheduleListQuery, PlatformLoginRequest, PlatformMetricsResponse, PlatformUser, PortalModuleItem, PromoteClassStudentsInput, ProvisionTenantRequest, Role, SelectTenantRequest, ShiftTargetType, Student, StudentListQuery, StudentOfflineCache, StudentQrPayload, Subject, SubjectListQuery, SwitchRoleRequest, TeacherListQuery, TeacherScanDynamicQrRequest, TeachingSchedule, TeachingScheduleListQuery, Tenant, TenantOption, TenantStatus, UpdateAcademicYearInput, UpdateClassAttendanceRequest, UpdateClassroomInput, UpdateStudentInput, UpdateSubjectInput, UpdateTeacherInput, UpdateTeachingScheduleInput, UpdateTenantModuleConfig, UpdateTenantProfileInput, UpdateTenantStatusRequest, UpsertAttendanceShiftInput, User, UserProfile } from '@sekolaos/shared-schema';
|
|
20
20
|
import 'react/jsx-runtime';
|
|
21
21
|
import 'react';
|
|
22
22
|
import 'axios';
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { SekolaosQueryProvider, createDefaultQueryClient } from './chunk-CBTITLR
|
|
|
11
11
|
import './chunk-AGPMQFZM.js';
|
|
12
12
|
export { activateAcademicYear, createAcademicYear, listAcademicYears, updateAcademicYear, useAcademicYears, useActivateAcademicYear, useCreateAcademicYear, useUpdateAcademicYear } from './chunk-ROK2DEVT.js';
|
|
13
13
|
export { batchSyncAttendance, createPicketAssignment, getAttendanceHistory, getDynamicQrStream, listPicketSchedules, updateClassAttendance, useAttendanceHistory, useBatchSyncAttendance, useCreatePicketAssignment, useDynamicQrStream, usePicketSchedules, useUpdateClassAttendance, useVerifyDynamicQr, verifyDynamicQr } from './chunk-ID3UGFZZ.js';
|
|
14
|
-
export { changePassword, getMe, login, logout, selectTenant, switchRole, useChangePassword, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole } from './chunk-
|
|
14
|
+
export { changePassword, consumeImpersonation, exitImpersonation, getMe, login, logout, selectTenant, switchRole, useChangePassword, useConsumeImpersonation, useExitImpersonation, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole } from './chunk-H5WMOGLJ.js';
|
|
15
15
|
export { createClassroom, getClassroom, getClassroomStudents, listClassrooms, promoteClassStudents, updateClassroom, useClassroom, useClassroomStudents, useClassrooms, useCreateClassroom, usePromoteClassStudents, useUpdateClassroom } from './chunk-FVPR2MOB.js';
|
|
16
16
|
export { API_ENDPOINTS, API_V1_PREFIX } from './chunk-Q5ZX6TKB.js';
|
|
17
17
|
export { deleteData, getData, getEnvelope, getPaginated, patchData, postData, putData, uploadData } from './chunk-6JGO2CUT.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNVU4IIMA_cjs = require('../../chunk-NVU4IIMA.cjs');
|
|
4
4
|
require('../../chunk-3TOBH3YY.cjs');
|
|
5
5
|
require('../../chunk-NGFFI4XQ.cjs');
|
|
6
6
|
require('../../chunk-PPK3HQOY.cjs');
|
|
@@ -11,51 +11,67 @@ require('../../chunk-5KSKHZWB.cjs');
|
|
|
11
11
|
|
|
12
12
|
Object.defineProperty(exports, "changePassword", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkNVU4IIMA_cjs.changePassword; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "consumeImpersonation", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkNVU4IIMA_cjs.consumeImpersonation; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "exitImpersonation", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkNVU4IIMA_cjs.exitImpersonation; }
|
|
15
23
|
});
|
|
16
24
|
Object.defineProperty(exports, "getMe", {
|
|
17
25
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkNVU4IIMA_cjs.getMe; }
|
|
19
27
|
});
|
|
20
28
|
Object.defineProperty(exports, "login", {
|
|
21
29
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkNVU4IIMA_cjs.login; }
|
|
23
31
|
});
|
|
24
32
|
Object.defineProperty(exports, "logout", {
|
|
25
33
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkNVU4IIMA_cjs.logout; }
|
|
27
35
|
});
|
|
28
36
|
Object.defineProperty(exports, "selectTenant", {
|
|
29
37
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkNVU4IIMA_cjs.selectTenant; }
|
|
31
39
|
});
|
|
32
40
|
Object.defineProperty(exports, "switchRole", {
|
|
33
41
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkNVU4IIMA_cjs.switchRole; }
|
|
35
43
|
});
|
|
36
44
|
Object.defineProperty(exports, "useChangePassword", {
|
|
37
45
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkNVU4IIMA_cjs.useChangePassword; }
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "useConsumeImpersonation", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () { return chunkNVU4IIMA_cjs.useConsumeImpersonation; }
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, "useExitImpersonation", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () { return chunkNVU4IIMA_cjs.useExitImpersonation; }
|
|
39
55
|
});
|
|
40
56
|
Object.defineProperty(exports, "useLogin", {
|
|
41
57
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkNVU4IIMA_cjs.useLogin; }
|
|
43
59
|
});
|
|
44
60
|
Object.defineProperty(exports, "useLogout", {
|
|
45
61
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkNVU4IIMA_cjs.useLogout; }
|
|
47
63
|
});
|
|
48
64
|
Object.defineProperty(exports, "useMe", {
|
|
49
65
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkNVU4IIMA_cjs.useMe; }
|
|
51
67
|
});
|
|
52
68
|
Object.defineProperty(exports, "useSelectTenant", {
|
|
53
69
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunkNVU4IIMA_cjs.useSelectTenant; }
|
|
55
71
|
});
|
|
56
72
|
Object.defineProperty(exports, "useSwitchRole", {
|
|
57
73
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkNVU4IIMA_cjs.useSwitchRole; }
|
|
59
75
|
});
|
|
60
76
|
//# sourceMappingURL=index.cjs.map
|
|
61
77
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
2
|
import { M as MutationOptionsCustom, S as SekolaosApiError, Q as QueryOptionsWithoutKey } from '../../types-BxV0BtVp.cjs';
|
|
3
|
-
import { AuthSession, Tenant, ChangePasswordRequest, LoginRequest, LoginResponse, SelectTenantRequest, SwitchRoleRequest } from '@sekolaos/shared-schema';
|
|
4
|
-
export { AuthSession, ChangePasswordRequest, LoginRequest, LoginResponse, Role, SelectTenantRequest, SwitchRoleRequest, TenantOption, UserProfile } from '@sekolaos/shared-schema';
|
|
3
|
+
import { AuthSession, Tenant, ChangePasswordRequest, ConsumeImpersonationRequest, LoginRequest, LoginResponse, SelectTenantRequest, SwitchRoleRequest } from '@sekolaos/shared-schema';
|
|
4
|
+
export { AuthSession, ChangePasswordRequest, ConsumeImpersonationRequest, LoginRequest, LoginResponse, Role, SelectTenantRequest, SwitchRoleRequest, TenantOption, UserProfile } from '@sekolaos/shared-schema';
|
|
5
5
|
import 'axios';
|
|
6
6
|
|
|
7
7
|
interface AuthUserSummary {
|
|
@@ -24,6 +24,32 @@ declare function getMe(): Promise<AuthSession>;
|
|
|
24
24
|
declare function changePassword(payload: ChangePasswordRequest): Promise<{
|
|
25
25
|
message: string;
|
|
26
26
|
}>;
|
|
27
|
+
/** Konsumsi token impersonasi dari sekolaos-admin, terbitkan sesi sekolah dengan isImpersonating: true. */
|
|
28
|
+
declare function consumeImpersonation(payload: ConsumeImpersonationRequest): Promise<AuthSession>;
|
|
29
|
+
/** Keluar dari mode penyamaran: hapus cookie sesi sekolah. */
|
|
30
|
+
declare function exitImpersonation(): Promise<void>;
|
|
31
|
+
declare function useConsumeImpersonation(options?: MutationOptionsCustom<AuthSession, ConsumeImpersonationRequest>): _tanstack_react_query.UseMutationResult<{
|
|
32
|
+
tenantId: string;
|
|
33
|
+
userId: string;
|
|
34
|
+
tenantSlug: string;
|
|
35
|
+
activeAcademicYearId: string;
|
|
36
|
+
activeRole: {
|
|
37
|
+
permissions: Record<string, string[]>;
|
|
38
|
+
roleId: string;
|
|
39
|
+
roleName: string;
|
|
40
|
+
roleSlug: string;
|
|
41
|
+
};
|
|
42
|
+
availableRoles: {
|
|
43
|
+
permissions: Record<string, string[]>;
|
|
44
|
+
roleId: string;
|
|
45
|
+
roleName: string;
|
|
46
|
+
roleSlug: string;
|
|
47
|
+
}[];
|
|
48
|
+
isImpersonating: boolean;
|
|
49
|
+
}, SekolaosApiError, {
|
|
50
|
+
token: string;
|
|
51
|
+
}, unknown>;
|
|
52
|
+
declare function useExitImpersonation(options?: MutationOptionsCustom<void, void>): _tanstack_react_query.UseMutationResult<void, SekolaosApiError, void, unknown>;
|
|
27
53
|
declare function useMe(options?: QueryOptionsWithoutKey<AuthSession> & {
|
|
28
54
|
enabled?: boolean;
|
|
29
55
|
}): _tanstack_react_query.UseQueryResult<{
|
|
@@ -43,6 +69,7 @@ declare function useMe(options?: QueryOptionsWithoutKey<AuthSession> & {
|
|
|
43
69
|
roleName: string;
|
|
44
70
|
roleSlug: string;
|
|
45
71
|
}[];
|
|
72
|
+
isImpersonating: boolean;
|
|
46
73
|
}, SekolaosApiError>;
|
|
47
74
|
declare function useLogin(options?: MutationOptionsCustom<LoginResponse, LoginRequest>): _tanstack_react_query.UseMutationResult<{
|
|
48
75
|
status: "SUCCESS" | "REQUIRES_TENANT_SELECTION" | "REQUIRES_ROLE_SELECTION";
|
|
@@ -63,6 +90,7 @@ declare function useLogin(options?: MutationOptionsCustom<LoginResponse, LoginRe
|
|
|
63
90
|
roleName: string;
|
|
64
91
|
roleSlug: string;
|
|
65
92
|
}[];
|
|
93
|
+
isImpersonating: boolean;
|
|
66
94
|
} | undefined;
|
|
67
95
|
availableTenants?: {
|
|
68
96
|
id: string;
|
|
@@ -95,6 +123,7 @@ declare function useSelectTenant(options?: MutationOptionsCustom<LoginResponse,
|
|
|
95
123
|
roleName: string;
|
|
96
124
|
roleSlug: string;
|
|
97
125
|
}[];
|
|
126
|
+
isImpersonating: boolean;
|
|
98
127
|
} | undefined;
|
|
99
128
|
availableTenants?: {
|
|
100
129
|
id: string;
|
|
@@ -124,6 +153,7 @@ declare function useSwitchRole(options?: MutationOptionsCustom<AuthSession, Swit
|
|
|
124
153
|
roleName: string;
|
|
125
154
|
roleSlug: string;
|
|
126
155
|
}[];
|
|
156
|
+
isImpersonating: boolean;
|
|
127
157
|
}, SekolaosApiError, {
|
|
128
158
|
academicYearId: string;
|
|
129
159
|
targetRoleId: string;
|
|
@@ -138,4 +168,4 @@ declare function useChangePassword(options?: MutationOptionsCustom<{
|
|
|
138
168
|
newPassword: string;
|
|
139
169
|
}, unknown>;
|
|
140
170
|
|
|
141
|
-
export { type AuthSessionPayload, type AuthUserSummary, changePassword, getMe, login, logout, selectTenant, switchRole, useChangePassword, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole };
|
|
171
|
+
export { type AuthSessionPayload, type AuthUserSummary, changePassword, consumeImpersonation, exitImpersonation, getMe, login, logout, selectTenant, switchRole, useChangePassword, useConsumeImpersonation, useExitImpersonation, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
2
|
import { M as MutationOptionsCustom, S as SekolaosApiError, Q as QueryOptionsWithoutKey } from '../../types-BxV0BtVp.js';
|
|
3
|
-
import { AuthSession, Tenant, ChangePasswordRequest, LoginRequest, LoginResponse, SelectTenantRequest, SwitchRoleRequest } from '@sekolaos/shared-schema';
|
|
4
|
-
export { AuthSession, ChangePasswordRequest, LoginRequest, LoginResponse, Role, SelectTenantRequest, SwitchRoleRequest, TenantOption, UserProfile } from '@sekolaos/shared-schema';
|
|
3
|
+
import { AuthSession, Tenant, ChangePasswordRequest, ConsumeImpersonationRequest, LoginRequest, LoginResponse, SelectTenantRequest, SwitchRoleRequest } from '@sekolaos/shared-schema';
|
|
4
|
+
export { AuthSession, ChangePasswordRequest, ConsumeImpersonationRequest, LoginRequest, LoginResponse, Role, SelectTenantRequest, SwitchRoleRequest, TenantOption, UserProfile } from '@sekolaos/shared-schema';
|
|
5
5
|
import 'axios';
|
|
6
6
|
|
|
7
7
|
interface AuthUserSummary {
|
|
@@ -24,6 +24,32 @@ declare function getMe(): Promise<AuthSession>;
|
|
|
24
24
|
declare function changePassword(payload: ChangePasswordRequest): Promise<{
|
|
25
25
|
message: string;
|
|
26
26
|
}>;
|
|
27
|
+
/** Konsumsi token impersonasi dari sekolaos-admin, terbitkan sesi sekolah dengan isImpersonating: true. */
|
|
28
|
+
declare function consumeImpersonation(payload: ConsumeImpersonationRequest): Promise<AuthSession>;
|
|
29
|
+
/** Keluar dari mode penyamaran: hapus cookie sesi sekolah. */
|
|
30
|
+
declare function exitImpersonation(): Promise<void>;
|
|
31
|
+
declare function useConsumeImpersonation(options?: MutationOptionsCustom<AuthSession, ConsumeImpersonationRequest>): _tanstack_react_query.UseMutationResult<{
|
|
32
|
+
tenantId: string;
|
|
33
|
+
userId: string;
|
|
34
|
+
tenantSlug: string;
|
|
35
|
+
activeAcademicYearId: string;
|
|
36
|
+
activeRole: {
|
|
37
|
+
permissions: Record<string, string[]>;
|
|
38
|
+
roleId: string;
|
|
39
|
+
roleName: string;
|
|
40
|
+
roleSlug: string;
|
|
41
|
+
};
|
|
42
|
+
availableRoles: {
|
|
43
|
+
permissions: Record<string, string[]>;
|
|
44
|
+
roleId: string;
|
|
45
|
+
roleName: string;
|
|
46
|
+
roleSlug: string;
|
|
47
|
+
}[];
|
|
48
|
+
isImpersonating: boolean;
|
|
49
|
+
}, SekolaosApiError, {
|
|
50
|
+
token: string;
|
|
51
|
+
}, unknown>;
|
|
52
|
+
declare function useExitImpersonation(options?: MutationOptionsCustom<void, void>): _tanstack_react_query.UseMutationResult<void, SekolaosApiError, void, unknown>;
|
|
27
53
|
declare function useMe(options?: QueryOptionsWithoutKey<AuthSession> & {
|
|
28
54
|
enabled?: boolean;
|
|
29
55
|
}): _tanstack_react_query.UseQueryResult<{
|
|
@@ -43,6 +69,7 @@ declare function useMe(options?: QueryOptionsWithoutKey<AuthSession> & {
|
|
|
43
69
|
roleName: string;
|
|
44
70
|
roleSlug: string;
|
|
45
71
|
}[];
|
|
72
|
+
isImpersonating: boolean;
|
|
46
73
|
}, SekolaosApiError>;
|
|
47
74
|
declare function useLogin(options?: MutationOptionsCustom<LoginResponse, LoginRequest>): _tanstack_react_query.UseMutationResult<{
|
|
48
75
|
status: "SUCCESS" | "REQUIRES_TENANT_SELECTION" | "REQUIRES_ROLE_SELECTION";
|
|
@@ -63,6 +90,7 @@ declare function useLogin(options?: MutationOptionsCustom<LoginResponse, LoginRe
|
|
|
63
90
|
roleName: string;
|
|
64
91
|
roleSlug: string;
|
|
65
92
|
}[];
|
|
93
|
+
isImpersonating: boolean;
|
|
66
94
|
} | undefined;
|
|
67
95
|
availableTenants?: {
|
|
68
96
|
id: string;
|
|
@@ -95,6 +123,7 @@ declare function useSelectTenant(options?: MutationOptionsCustom<LoginResponse,
|
|
|
95
123
|
roleName: string;
|
|
96
124
|
roleSlug: string;
|
|
97
125
|
}[];
|
|
126
|
+
isImpersonating: boolean;
|
|
98
127
|
} | undefined;
|
|
99
128
|
availableTenants?: {
|
|
100
129
|
id: string;
|
|
@@ -124,6 +153,7 @@ declare function useSwitchRole(options?: MutationOptionsCustom<AuthSession, Swit
|
|
|
124
153
|
roleName: string;
|
|
125
154
|
roleSlug: string;
|
|
126
155
|
}[];
|
|
156
|
+
isImpersonating: boolean;
|
|
127
157
|
}, SekolaosApiError, {
|
|
128
158
|
academicYearId: string;
|
|
129
159
|
targetRoleId: string;
|
|
@@ -138,4 +168,4 @@ declare function useChangePassword(options?: MutationOptionsCustom<{
|
|
|
138
168
|
newPassword: string;
|
|
139
169
|
}, unknown>;
|
|
140
170
|
|
|
141
|
-
export { type AuthSessionPayload, type AuthUserSummary, changePassword, getMe, login, logout, selectTenant, switchRole, useChangePassword, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole };
|
|
171
|
+
export { type AuthSessionPayload, type AuthUserSummary, changePassword, consumeImpersonation, exitImpersonation, getMe, login, logout, selectTenant, switchRole, useChangePassword, useConsumeImpersonation, useExitImpersonation, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { changePassword, getMe, login, logout, selectTenant, switchRole, useChangePassword, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole } from '../../chunk-
|
|
1
|
+
export { changePassword, consumeImpersonation, exitImpersonation, getMe, login, logout, selectTenant, switchRole, useChangePassword, useConsumeImpersonation, useExitImpersonation, useLogin, useLogout, useMe, useSelectTenant, useSwitchRole } from '../../chunk-H5WMOGLJ.js';
|
|
2
2
|
import '../../chunk-Q5ZX6TKB.js';
|
|
3
3
|
import '../../chunk-6JGO2CUT.js';
|
|
4
4
|
import '../../chunk-GRXFSXG5.js';
|
package/package.json
CHANGED
|
@@ -1,138 +1,137 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@sekolaos/shared-api",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "Shared HTTP API client, TanStack Query hooks, and query key factory for Sekolaos ecosystem aligned with OpenAPI 3.0.3",
|
|
5
|
-
"license": "ISC",
|
|
6
|
-
"author": "Sekolaos",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "./dist/index.cjs",
|
|
9
|
-
"module": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"sideEffects": false,
|
|
12
|
-
"exports": {
|
|
13
|
-
".": {
|
|
14
|
-
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.js",
|
|
16
|
-
"require": "./dist/index.cjs"
|
|
17
|
-
},
|
|
18
|
-
"./client": {
|
|
19
|
-
"types": "./dist/client/index.d.ts",
|
|
20
|
-
"import": "./dist/client/index.js",
|
|
21
|
-
"require": "./dist/client/index.cjs"
|
|
22
|
-
},
|
|
23
|
-
"./keys": {
|
|
24
|
-
"types": "./dist/keys/index.d.ts",
|
|
25
|
-
"import": "./dist/keys/index.js",
|
|
26
|
-
"require": "./dist/keys/index.cjs"
|
|
27
|
-
},
|
|
28
|
-
"./provider": {
|
|
29
|
-
"types": "./dist/provider.d.ts",
|
|
30
|
-
"import": "./dist/provider.js",
|
|
31
|
-
"require": "./dist/provider.cjs"
|
|
32
|
-
},
|
|
33
|
-
"./auth": {
|
|
34
|
-
"types": "./dist/modules/auth/index.d.ts",
|
|
35
|
-
"import": "./dist/modules/auth/index.js",
|
|
36
|
-
"require": "./dist/modules/auth/index.cjs"
|
|
37
|
-
},
|
|
38
|
-
"./tenant": {
|
|
39
|
-
"types": "./dist/modules/tenant/index.d.ts",
|
|
40
|
-
"import": "./dist/modules/tenant/index.js",
|
|
41
|
-
"require": "./dist/modules/tenant/index.cjs"
|
|
42
|
-
},
|
|
43
|
-
"./academic": {
|
|
44
|
-
"types": "./dist/modules/academic/index.d.ts",
|
|
45
|
-
"import": "./dist/modules/academic/index.js",
|
|
46
|
-
"require": "./dist/modules/academic/index.cjs"
|
|
47
|
-
},
|
|
48
|
-
"./classroom": {
|
|
49
|
-
"types": "./dist/modules/classroom/index.d.ts",
|
|
50
|
-
"import": "./dist/modules/classroom/index.js",
|
|
51
|
-
"require": "./dist/modules/classroom/index.cjs"
|
|
52
|
-
},
|
|
53
|
-
"./student": {
|
|
54
|
-
"types": "./dist/modules/student/index.d.ts",
|
|
55
|
-
"import": "./dist/modules/student/index.js",
|
|
56
|
-
"require": "./dist/modules/student/index.cjs"
|
|
57
|
-
},
|
|
58
|
-
"./subject": {
|
|
59
|
-
"types": "./dist/modules/subject/index.d.ts",
|
|
60
|
-
"import": "./dist/modules/subject/index.js",
|
|
61
|
-
"require": "./dist/modules/subject/index.cjs"
|
|
62
|
-
},
|
|
63
|
-
"./teaching-schedule": {
|
|
64
|
-
"types": "./dist/modules/teaching-schedule/index.d.ts",
|
|
65
|
-
"import": "./dist/modules/teaching-schedule/index.js",
|
|
66
|
-
"require": "./dist/modules/teaching-schedule/index.cjs"
|
|
67
|
-
},
|
|
68
|
-
"./user": {
|
|
69
|
-
"types": "./dist/modules/user/index.d.ts",
|
|
70
|
-
"import": "./dist/modules/user/index.js",
|
|
71
|
-
"require": "./dist/modules/user/index.cjs"
|
|
72
|
-
},
|
|
73
|
-
"./attendance": {
|
|
74
|
-
"types": "./dist/modules/attendance/index.d.ts",
|
|
75
|
-
"import": "./dist/modules/attendance/index.js",
|
|
76
|
-
"require": "./dist/modules/attendance/index.cjs"
|
|
77
|
-
},
|
|
78
|
-
"./upload": {
|
|
79
|
-
"types": "./dist/modules/upload/index.d.ts",
|
|
80
|
-
"import": "./dist/modules/upload/index.js",
|
|
81
|
-
"require": "./dist/modules/upload/index.cjs"
|
|
82
|
-
},
|
|
83
|
-
"./lead": {
|
|
84
|
-
"types": "./dist/modules/lead/index.d.ts",
|
|
85
|
-
"import": "./dist/modules/lead/index.js",
|
|
86
|
-
"require": "./dist/modules/lead/index.cjs"
|
|
87
|
-
},
|
|
88
|
-
"./system": {
|
|
89
|
-
"types": "./dist/modules/system/index.d.ts",
|
|
90
|
-
"import": "./dist/modules/system/index.js",
|
|
91
|
-
"require": "./dist/modules/system/index.cjs"
|
|
92
|
-
},
|
|
93
|
-
"./package.json": "./package.json"
|
|
94
|
-
},
|
|
95
|
-
"files": [
|
|
96
|
-
"dist"
|
|
97
|
-
],
|
|
98
|
-
"engines": {
|
|
99
|
-
"node": ">=20.0.0"
|
|
100
|
-
},
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"@
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@sekolaos/shared-api",
|
|
3
|
+
"version": "1.3.1",
|
|
4
|
+
"description": "Shared HTTP API client, TanStack Query hooks, and query key factory for Sekolaos ecosystem aligned with OpenAPI 3.0.3",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "Sekolaos",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./client": {
|
|
19
|
+
"types": "./dist/client/index.d.ts",
|
|
20
|
+
"import": "./dist/client/index.js",
|
|
21
|
+
"require": "./dist/client/index.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./keys": {
|
|
24
|
+
"types": "./dist/keys/index.d.ts",
|
|
25
|
+
"import": "./dist/keys/index.js",
|
|
26
|
+
"require": "./dist/keys/index.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./provider": {
|
|
29
|
+
"types": "./dist/provider.d.ts",
|
|
30
|
+
"import": "./dist/provider.js",
|
|
31
|
+
"require": "./dist/provider.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./auth": {
|
|
34
|
+
"types": "./dist/modules/auth/index.d.ts",
|
|
35
|
+
"import": "./dist/modules/auth/index.js",
|
|
36
|
+
"require": "./dist/modules/auth/index.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./tenant": {
|
|
39
|
+
"types": "./dist/modules/tenant/index.d.ts",
|
|
40
|
+
"import": "./dist/modules/tenant/index.js",
|
|
41
|
+
"require": "./dist/modules/tenant/index.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./academic": {
|
|
44
|
+
"types": "./dist/modules/academic/index.d.ts",
|
|
45
|
+
"import": "./dist/modules/academic/index.js",
|
|
46
|
+
"require": "./dist/modules/academic/index.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./classroom": {
|
|
49
|
+
"types": "./dist/modules/classroom/index.d.ts",
|
|
50
|
+
"import": "./dist/modules/classroom/index.js",
|
|
51
|
+
"require": "./dist/modules/classroom/index.cjs"
|
|
52
|
+
},
|
|
53
|
+
"./student": {
|
|
54
|
+
"types": "./dist/modules/student/index.d.ts",
|
|
55
|
+
"import": "./dist/modules/student/index.js",
|
|
56
|
+
"require": "./dist/modules/student/index.cjs"
|
|
57
|
+
},
|
|
58
|
+
"./subject": {
|
|
59
|
+
"types": "./dist/modules/subject/index.d.ts",
|
|
60
|
+
"import": "./dist/modules/subject/index.js",
|
|
61
|
+
"require": "./dist/modules/subject/index.cjs"
|
|
62
|
+
},
|
|
63
|
+
"./teaching-schedule": {
|
|
64
|
+
"types": "./dist/modules/teaching-schedule/index.d.ts",
|
|
65
|
+
"import": "./dist/modules/teaching-schedule/index.js",
|
|
66
|
+
"require": "./dist/modules/teaching-schedule/index.cjs"
|
|
67
|
+
},
|
|
68
|
+
"./user": {
|
|
69
|
+
"types": "./dist/modules/user/index.d.ts",
|
|
70
|
+
"import": "./dist/modules/user/index.js",
|
|
71
|
+
"require": "./dist/modules/user/index.cjs"
|
|
72
|
+
},
|
|
73
|
+
"./attendance": {
|
|
74
|
+
"types": "./dist/modules/attendance/index.d.ts",
|
|
75
|
+
"import": "./dist/modules/attendance/index.js",
|
|
76
|
+
"require": "./dist/modules/attendance/index.cjs"
|
|
77
|
+
},
|
|
78
|
+
"./upload": {
|
|
79
|
+
"types": "./dist/modules/upload/index.d.ts",
|
|
80
|
+
"import": "./dist/modules/upload/index.js",
|
|
81
|
+
"require": "./dist/modules/upload/index.cjs"
|
|
82
|
+
},
|
|
83
|
+
"./lead": {
|
|
84
|
+
"types": "./dist/modules/lead/index.d.ts",
|
|
85
|
+
"import": "./dist/modules/lead/index.js",
|
|
86
|
+
"require": "./dist/modules/lead/index.cjs"
|
|
87
|
+
},
|
|
88
|
+
"./system": {
|
|
89
|
+
"types": "./dist/modules/system/index.d.ts",
|
|
90
|
+
"import": "./dist/modules/system/index.js",
|
|
91
|
+
"require": "./dist/modules/system/index.cjs"
|
|
92
|
+
},
|
|
93
|
+
"./package.json": "./package.json"
|
|
94
|
+
},
|
|
95
|
+
"files": [
|
|
96
|
+
"dist"
|
|
97
|
+
],
|
|
98
|
+
"engines": {
|
|
99
|
+
"node": ">=20.0.0"
|
|
100
|
+
},
|
|
101
|
+
"peerDependencies": {
|
|
102
|
+
"react": "^19.3.1",
|
|
103
|
+
"react-dom": "^19.3.1"
|
|
104
|
+
},
|
|
105
|
+
"dependencies": {
|
|
106
|
+
"@sekolaos/shared-schema": "1.6.1",
|
|
107
|
+
"@tanstack/react-query": "^5.59.16",
|
|
108
|
+
"axios": "^1.7.7"
|
|
109
|
+
},
|
|
110
|
+
"devDependencies": {
|
|
111
|
+
"@types/node": "^22.9.0",
|
|
112
|
+
"@types/react": "19.0.0",
|
|
113
|
+
"@types/react-dom": "19.0.0",
|
|
114
|
+
"react": "19.3.1",
|
|
115
|
+
"react-dom": "19.3.1",
|
|
116
|
+
"rimraf": "^6.0.1",
|
|
117
|
+
"tsup": "^8.3.5",
|
|
118
|
+
"typescript": "^5.6.3"
|
|
119
|
+
},
|
|
120
|
+
"publishConfig": {
|
|
121
|
+
"access": "public",
|
|
122
|
+
"registry": "https://registry.npmjs.org"
|
|
123
|
+
},
|
|
124
|
+
"keywords": [
|
|
125
|
+
"sekolaos",
|
|
126
|
+
"http-client",
|
|
127
|
+
"axios",
|
|
128
|
+
"tanstack-query",
|
|
129
|
+
"query-key-factory"
|
|
130
|
+
],
|
|
131
|
+
"scripts": {
|
|
132
|
+
"dev": "tsup --watch",
|
|
133
|
+
"build": "tsup",
|
|
134
|
+
"typecheck": "tsc --noEmit",
|
|
135
|
+
"clean": "rimraf dist"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/modules/auth/auth.api.ts"],"names":["API_ENDPOINTS","postData","getData","putData","useQuery","authKeys","useQueryClient","useMutation"],"mappings":";;;;;;;AAkBA,IAAM,WAAWA,+BAAA,CAAc,IAAA;AAgB/B,eAAsB,MAAM,OAAA,EAA+C;AACzE,EAAA,OAAOC,0BAAA,CAAsC,CAAA,EAAG,QAAQ,CAAA,MAAA,CAAA,EAAU,OAAO,CAAA;AAC3E;AAEA,eAAsB,aAAa,OAAA,EAAsD;AACvF,EAAA,OAAOA,0BAAA,CAA6C,CAAA,EAAG,QAAQ,CAAA,cAAA,CAAA,EAAkB,OAAO,CAAA;AAC1F;AAEA,eAAsB,WAAW,OAAA,EAAkD;AACjF,EAAA,OAAOA,0BAAA,CAAyC,CAAA,EAAG,QAAQ,CAAA,YAAA,CAAA,EAAgB,OAAO,CAAA;AACpF;AAEA,eAAsB,MAAA,GAAwB;AAC5C,EAAA,MAAMA,0BAAA,CAAe,CAAA,EAAG,QAAQ,CAAA,OAAA,CAAS,CAAA;AAC3C;AAEA,eAAsB,KAAA,GAA8B;AAClD,EAAA,OAAOC,yBAAA,CAAqB,CAAA,EAAG,QAAQ,CAAA,GAAA,CAAK,CAAA;AAC9C;AAEA,eAAsB,eAAe,OAAA,EAA8D;AACjG,EAAA,OAAOC,yBAAA,CAAoD,CAAA,EAAG,QAAQ,CAAA,gBAAA,CAAA,EAAoB,OAAO,CAAA;AACnG;AAEO,SAAS,MAAM,OAAA,EAAuE;AAC3F,EAAA,OAAOC,mBAAA,CAAS;AAAA,IACd,QAAA,EAAUC,2BAAS,EAAA,EAAG;AAAA,IACtB,OAAA,EAAS,KAAA;AAAA,IACT,OAAA,EAAS,SAAS,OAAA,IAAW,IAAA;AAAA,IAC7B,SAAA,EAAW,GAAA;AAAA,IACX,GAAG;AAAA,GACJ,CAAA;AACH;AAEO,SAAS,SAAS,OAAA,EAA8D;AACrF,EA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A,GAAG;AAAA,GACJ,CAAA;AACH;AAEO,SAAS,UAAU,OAAA,EAA6C;AACrE,EAAA,MAAM,cAAcC,yBAAA,EAAe;AACnC,EAAA,OAAOC,sBAAA,CAAY;AAAA,IACjB,UAAA,EAAY,MAAA;AAAA,IACZ,WAAW,MAAM;AACf,MAAA,WAAA,CAAY,KAAA,EAAM;AAClB,MAAA,OAAA,EAAS,SAAA,GAAY,MAAA,EAAW,MAAA,EAAW,MAAS,CAAA;AAAA,IACtD,CAAA;AAAA,IACA,GAAG;AAAA,GACJ,CAAA;AACH;AAEO,SAAS,kBAAkB,OAAA,EAA6E;AAC7G,EAAA,OAAOA,sBAAA,CAAY;AAAA,IACjB,UAAA,EAAY,cAAA;AAAA,IACZ,GAAG;AAAA,GACJ,CAAA;AACH","file":"chunk-OVHSXH7Z.cjs","sourcesContent":["import type {\r\n AuthSession,\r\n ChangePasswordRequest,\r\n LoginRequest,\r\n LoginResponse,\r\n Role,\r\n SelectTenantRequest,\r\n SwitchRoleRequest,\r\n Tenant,\r\n TenantOption,\r\n UserProfile,\r\n} from \"@sekolaos/shared-schema\";\r\nimport { API_ENDPOINTS } from \"../../common/endpoints\";\r\nimport { getData, postData, putData } from \"../../client/http\";\r\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\r\nimport { authKeys } from \"../../keys\";\r\nimport type { MutationOptionsCustom, QueryOptionsWithoutKey } from \"../../client/types\";\r\n\r\nconst ENDPOINT = API_ENDPOINTS.auth;\r\n\r\nexport interface AuthUserSummary {\r\n id: string;\r\n username: string;\r\n email: string | null;\r\n fullName: string;\r\n}\r\n\r\n/** Payload `GET /auth/me`: sesi + profil ringkas user + tenant aktif. */\r\nexport interface AuthSessionPayload {\r\n session: AuthSession;\r\n user: AuthUserSummary;\r\n tenant: Tenant;\r\n}\r\n\r\nexport async function login(payload: LoginRequest): Promise<LoginResponse> {\r\n return postData<LoginResponse, LoginRequest>(`${ENDPOINT}/login`, payload);\r\n}\r\n\r\nexport async function selectTenant(payload: SelectTenantRequest): Promise<LoginResponse> {\r\n return postData<LoginResponse, SelectTenantRequest>(`${ENDPOINT}/select-tenant`, payload);\r\n}\r\n\r\nexport async function switchRole(payload: SwitchRoleRequest): Promise<AuthSession> {\r\n return postData<AuthSession, SwitchRoleRequest>(`${ENDPOINT}/switch-role`, payload);\r\n}\r\n\r\nexport async function logout(): Promise<void> {\r\n await postData<void>(`${ENDPOINT}/logout`);\r\n}\r\n\r\nexport async function getMe(): Promise<AuthSession> {\r\n return getData<AuthSession>(`${ENDPOINT}/me`);\r\n}\r\n\r\nexport async function changePassword(payload: ChangePasswordRequest): Promise<{ message: string }> {\r\n return putData<{ message: string }, ChangePasswordRequest>(`${ENDPOINT}/change-password`, payload);\r\n}\r\n\r\nexport function useMe(options?: QueryOptionsWithoutKey<AuthSession> & { enabled?: boolean }) {\r\n return useQuery({\r\n queryKey: authKeys.me(),\r\n queryFn: getMe,\r\n enabled: options?.enabled ?? true,\r\n staleTime: 60_000,\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useLogin(options?: MutationOptionsCustom<LoginResponse, LoginRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: login,\r\n onSuccess: (data, variables, context) => {\r\n if (data.status === \"SUCCESS\") {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n }\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useSelectTenant(options?: MutationOptionsCustom<LoginResponse, SelectTenantRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: selectTenant,\r\n onSuccess: (data, variables, context) => {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useSwitchRole(options?: MutationOptionsCustom<AuthSession, SwitchRoleRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: switchRole,\r\n onSuccess: (data, variables, context) => {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useLogout(options?: MutationOptionsCustom<void, void>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: logout,\r\n onSuccess: () => {\r\n queryClient.clear();\r\n options?.onSuccess?.(undefined, undefined, undefined);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useChangePassword(options?: MutationOptionsCustom<{ message: string }, ChangePasswordRequest>) {\r\n return useMutation({\r\n mutationFn: changePassword,\r\n ...options,\r\n });\r\n}\r\n\r\nexport type {\r\n AuthSession,\r\n ChangePasswordRequest,\r\n LoginRequest,\r\n LoginResponse,\r\n Role,\r\n SelectTenantRequest,\r\n SwitchRoleRequest,\r\n TenantOption,\r\n UserProfile,\r\n};\r\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/modules/auth/auth.api.ts"],"names":[],"mappings":";;;;;AAkBA,IAAM,WAAW,aAAA,CAAc,IAAA;AAgB/B,eAAsB,MAAM,OAAA,EAA+C;AACzE,EAAA,OAAO,QAAA,CAAsC,CAAA,EAAG,QAAQ,CAAA,MAAA,CAAA,EAAU,OAAO,CAAA;AAC3E;AAEA,eAAsB,aAAa,OAAA,EAAsD;AACvF,EAAA,OAAO,QAAA,CAA6C,CAAA,EAAG,QAAQ,CAAA,cAAA,CAAA,EAAkB,OAAO,CAAA;AAC1F;AAEA,eAAsB,WAAW,OAAA,EAAkD;AACjF,EAAA,OAAO,QAAA,CAAyC,CAAA,EAAG,QAAQ,CAAA,YAAA,CAAA,EAAgB,OAAO,CAAA;AACpF;AAEA,eAAsB,MAAA,GAAwB;AAC5C,EAAA,MAAM,QAAA,CAAe,CAAA,EAAG,QAAQ,CAAA,OAAA,CAAS,CAAA;AAC3C;AAEA,eAAsB,KAAA,GAA8B;AAClD,EAAA,OAAO,OAAA,CAAq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AW,OAAO,CAAA;AAAA,IAC/C,CAAA;AAAA,IACA,GAAG;AAAA,GACJ,CAAA;AACH;AAEO,SAAS,cAAc,OAAA,EAAiE;AAC7F,EAAA,MAAM,cAAc,cAAA,EAAe;AACnC,EAAA,OAAO,WAAA,CAAY;AAAA,IACjB,UAAA,EAAY,UAAA;AAAA,IACZ,SAAA,EAAW,CAAC,IAAA,EAAM,SAAA,EAAW,OAAA,KAAY;AACvC,MAAA,WAAA,CAAY,iBAAA,CAAkB,EAAE,QAAA,EAAU,QAAA,CAAS,KAAK,CAAA;AACxD,MAAA,OAAA,EAAS,SAAA,GAAY,IAAA,EAAM,SAAA,EAAW,OAAO,CAAA;AAAA,IAC/C,CAAA;AAAA,IACA,GAAG;AAAA,GACJ,CAAA;AACH;AAEO,SAAS,UAAU,OAAA,EAA6C;AACrE,EAAA,MAAM,cAAc,cAAA,EAAe;AACnC,EAAA,OAAO,WAAA,CAAY;AAAA,IACjB,UAAA,EAAY,MAAA;AAAA,IACZ,WAAW,MAAM;AACf,MAAA,WAAA,CAAY,KAAA,EAAM;AAClB,MAAA,OAAA,EAAS,SAAA,GAAY,MAAA,EAAW,MAAA,EAAW,MAAS,CAAA;AAAA,IACtD,CAAA;AAAA,IACA,GAAG;AAAA,GACJ,CAAA;AACH;AAEO,SAAS,kBAAkB,OAAA,EAA6E;AAC7G,EAAA,OAAO,WAAA,CAAY;AAAA,IACjB,UAAA,EAAY,cAAA;AAAA,IACZ,GAAG;AAAA,GACJ,CAAA;AACH","file":"chunk-PMN2DTYF.js","sourcesContent":["import type {\r\n AuthSession,\r\n ChangePasswordRequest,\r\n LoginRequest,\r\n LoginResponse,\r\n Role,\r\n SelectTenantRequest,\r\n SwitchRoleRequest,\r\n Tenant,\r\n TenantOption,\r\n UserProfile,\r\n} from \"@sekolaos/shared-schema\";\r\nimport { API_ENDPOINTS } from \"../../common/endpoints\";\r\nimport { getData, postData, putData } from \"../../client/http\";\r\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\r\nimport { authKeys } from \"../../keys\";\r\nimport type { MutationOptionsCustom, QueryOptionsWithoutKey } from \"../../client/types\";\r\n\r\nconst ENDPOINT = API_ENDPOINTS.auth;\r\n\r\nexport interface AuthUserSummary {\r\n id: string;\r\n username: string;\r\n email: string | null;\r\n fullName: string;\r\n}\r\n\r\n/** Payload `GET /auth/me`: sesi + profil ringkas user + tenant aktif. */\r\nexport interface AuthSessionPayload {\r\n session: AuthSession;\r\n user: AuthUserSummary;\r\n tenant: Tenant;\r\n}\r\n\r\nexport async function login(payload: LoginRequest): Promise<LoginResponse> {\r\n return postData<LoginResponse, LoginRequest>(`${ENDPOINT}/login`, payload);\r\n}\r\n\r\nexport async function selectTenant(payload: SelectTenantRequest): Promise<LoginResponse> {\r\n return postData<LoginResponse, SelectTenantRequest>(`${ENDPOINT}/select-tenant`, payload);\r\n}\r\n\r\nexport async function switchRole(payload: SwitchRoleRequest): Promise<AuthSession> {\r\n return postData<AuthSession, SwitchRoleRequest>(`${ENDPOINT}/switch-role`, payload);\r\n}\r\n\r\nexport async function logout(): Promise<void> {\r\n await postData<void>(`${ENDPOINT}/logout`);\r\n}\r\n\r\nexport async function getMe(): Promise<AuthSession> {\r\n return getData<AuthSession>(`${ENDPOINT}/me`);\r\n}\r\n\r\nexport async function changePassword(payload: ChangePasswordRequest): Promise<{ message: string }> {\r\n return putData<{ message: string }, ChangePasswordRequest>(`${ENDPOINT}/change-password`, payload);\r\n}\r\n\r\nexport function useMe(options?: QueryOptionsWithoutKey<AuthSession> & { enabled?: boolean }) {\r\n return useQuery({\r\n queryKey: authKeys.me(),\r\n queryFn: getMe,\r\n enabled: options?.enabled ?? true,\r\n staleTime: 60_000,\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useLogin(options?: MutationOptionsCustom<LoginResponse, LoginRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: login,\r\n onSuccess: (data, variables, context) => {\r\n if (data.status === \"SUCCESS\") {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n }\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useSelectTenant(options?: MutationOptionsCustom<LoginResponse, SelectTenantRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: selectTenant,\r\n onSuccess: (data, variables, context) => {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useSwitchRole(options?: MutationOptionsCustom<AuthSession, SwitchRoleRequest>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: switchRole,\r\n onSuccess: (data, variables, context) => {\r\n queryClient.invalidateQueries({ queryKey: authKeys.all });\r\n options?.onSuccess?.(data, variables, context);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useLogout(options?: MutationOptionsCustom<void, void>) {\r\n const queryClient = useQueryClient();\r\n return useMutation({\r\n mutationFn: logout,\r\n onSuccess: () => {\r\n queryClient.clear();\r\n options?.onSuccess?.(undefined, undefined, undefined);\r\n },\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useChangePassword(options?: MutationOptionsCustom<{ message: string }, ChangePasswordRequest>) {\r\n return useMutation({\r\n mutationFn: changePassword,\r\n ...options,\r\n });\r\n}\r\n\r\nexport type {\r\n AuthSession,\r\n ChangePasswordRequest,\r\n LoginRequest,\r\n LoginResponse,\r\n Role,\r\n SelectTenantRequest,\r\n SwitchRoleRequest,\r\n TenantOption,\r\n UserProfile,\r\n};\r\n"]}
|