325 lines
6.6 KiB
TypeScript
325 lines
6.6 KiB
TypeScript
/**
|
|
* Interface of the server (auto-generated code)
|
|
*/
|
|
import {
|
|
HTTPMimeType,
|
|
HTTPRequestModel,
|
|
RESTConfig,
|
|
RESTRequestJson,
|
|
RESTRequestVoid,
|
|
} from "../rest-tools";
|
|
|
|
import { z as zod } from "zod"
|
|
import {
|
|
ChangePasswordWrite,
|
|
DataGetTokenWrite,
|
|
GetToken,
|
|
Long,
|
|
PartRight,
|
|
UserAuth,
|
|
UserAuthGet,
|
|
UserCreateWrite,
|
|
UserOut,
|
|
ZodPartRight,
|
|
ZodUserAuthGet,
|
|
isGetToken,
|
|
isUserAuth,
|
|
isUserAuthGet,
|
|
isUserOut,
|
|
} from "../model";
|
|
|
|
export namespace UserResource {
|
|
|
|
export function changePassword({
|
|
restConfig,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
data: ChangePasswordWrite,
|
|
}): Promise<void> {
|
|
return RESTRequestVoid({
|
|
restModel: {
|
|
endPoint: "/users/password",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
data,
|
|
});
|
|
};
|
|
export function create({
|
|
restConfig,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
data: UserCreateWrite,
|
|
}): Promise<UserAuthGet> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
data,
|
|
}, isUserAuthGet);
|
|
};
|
|
export function get({
|
|
restConfig,
|
|
params,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
}): Promise<UserAuthGet> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/{id}",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isUserAuthGet);
|
|
};
|
|
|
|
export const ZodGetApplicationRightTypeReturn = zod.record(zod.string(), ZodPartRight);
|
|
export type GetApplicationRightTypeReturn = zod.infer<typeof ZodGetApplicationRightTypeReturn>;
|
|
|
|
export function isGetApplicationRightTypeReturn(data: any): data is GetApplicationRightTypeReturn {
|
|
try {
|
|
ZodGetApplicationRightTypeReturn.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodGetApplicationRightTypeReturn' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function getApplicationRight({
|
|
restConfig,
|
|
params,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
applicationId: Long,
|
|
userId: Long,
|
|
},
|
|
}): Promise<GetApplicationRightTypeReturn> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
}, isGetApplicationRightTypeReturn);
|
|
};
|
|
export function getMe({
|
|
restConfig,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
}): Promise<UserOut> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/me",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
}, isUserOut);
|
|
};
|
|
export function getToken({
|
|
restConfig,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
data: DataGetTokenWrite,
|
|
}): Promise<GetToken> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/get_token",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
data,
|
|
}, isGetToken);
|
|
};
|
|
|
|
export const ZodGetsTypeReturn = zod.array(ZodUserAuthGet);
|
|
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
|
|
|
export function isGetsTypeReturn(data: any): data is GetsTypeReturn {
|
|
try {
|
|
ZodGetsTypeReturn.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodGetsTypeReturn' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function gets({
|
|
restConfig,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
}): Promise<GetsTypeReturn> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
}, isGetsTypeReturn);
|
|
};
|
|
export function isEmailExist({
|
|
restConfig,
|
|
queries,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
queries: {
|
|
email?: string,
|
|
},
|
|
}): Promise<boolean> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/is_email_exist",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
queries,
|
|
});
|
|
};
|
|
export function isLoginExist({
|
|
restConfig,
|
|
queries,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
queries: {
|
|
login?: string,
|
|
},
|
|
}): Promise<boolean> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/is_login_exist",
|
|
requestType: HTTPRequestModel.GET,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
queries,
|
|
});
|
|
};
|
|
export function linkApplication({
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
applicationId: Long,
|
|
userId: Long,
|
|
},
|
|
data: boolean,
|
|
}): Promise<UserAuth> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/{userId}/application/{applicationId}/link",
|
|
requestType: HTTPRequestModel.POST,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}, isUserAuth);
|
|
};
|
|
|
|
export const ZodPatchApplicationRightTypeReturn = zod.record(zod.string(), ZodPartRight);
|
|
export type PatchApplicationRightTypeReturn = zod.infer<typeof ZodPatchApplicationRightTypeReturn>;
|
|
|
|
export function isPatchApplicationRightTypeReturn(data: any): data is PatchApplicationRightTypeReturn {
|
|
try {
|
|
ZodPatchApplicationRightTypeReturn.parse(data);
|
|
return true;
|
|
} catch (e: any) {
|
|
console.log(`Fail to parse data type='ZodPatchApplicationRightTypeReturn' error=${e}`);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function patchApplicationRight({
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
applicationId: Long,
|
|
userId: Long,
|
|
},
|
|
data: {[key: string]: PartRight;},
|
|
}): Promise<PatchApplicationRightTypeReturn> {
|
|
return RESTRequestJson({
|
|
restModel: {
|
|
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
|
requestType: HTTPRequestModel.PATCH,
|
|
contentType: HTTPMimeType.JSON,
|
|
accept: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}, isPatchApplicationRightTypeReturn);
|
|
};
|
|
export function setAdmin({
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
data: boolean,
|
|
}): Promise<void> {
|
|
return RESTRequestVoid({
|
|
restModel: {
|
|
endPoint: "/users/{id}/set_admin",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
});
|
|
};
|
|
export function setBlocked({
|
|
restConfig,
|
|
params,
|
|
data,
|
|
}: {
|
|
restConfig: RESTConfig,
|
|
params: {
|
|
id: Long,
|
|
},
|
|
data: boolean,
|
|
}): Promise<void> {
|
|
return RESTRequestVoid({
|
|
restModel: {
|
|
endPoint: "/users/{id}/set_blocked",
|
|
requestType: HTTPRequestModel.POST,
|
|
contentType: HTTPMimeType.JSON,
|
|
},
|
|
restConfig,
|
|
params,
|
|
data,
|
|
});
|
|
};
|
|
}
|