[FEAT] updat front back-api
This commit is contained in:
parent
81ad9f842c
commit
ef304bc1fe
@ -6,6 +6,7 @@
|
|||||||
"all": "npm run build && npm run test",
|
"all": "npm run build && npm run test",
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"dev": "ng serve karso --configuration=develop --watch --port 4200",
|
"dev": "ng serve karso --configuration=develop --watch --port 4200",
|
||||||
|
"dev-hot-update": "ng serve karso --configuration=develop --watch --hmr --port 4200",
|
||||||
"dev_edge": "ng serve karso-edge --configuration=develop --watch --port 4199",
|
"dev_edge": "ng serve karso-edge --configuration=develop --watch --port 4199",
|
||||||
"build": "ng build karso --prod",
|
"build": "ng build karso --prod",
|
||||||
"test": "ng test karso",
|
"test": "ng test karso",
|
||||||
|
@ -27,7 +27,7 @@ import {
|
|||||||
ApplicationEditScene,
|
ApplicationEditScene,
|
||||||
} from 'base/scene';
|
} from 'base/scene';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { AdminUserService, ApplicationService, ApplicationTokenService } from 'base/service';
|
import { AdminUserService, ApplicationService, ApplicationTokenService, SettingsService } from 'base/service';
|
||||||
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ import { environment } from 'environments/environment';
|
|||||||
AdminUserService,
|
AdminUserService,
|
||||||
ApplicationService,
|
ApplicationService,
|
||||||
ApplicationTokenService,
|
ApplicationTokenService,
|
||||||
|
SettingsService,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
|
@ -30,7 +30,7 @@ import {
|
|||||||
} from 'base/scene';
|
} from 'base/scene';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
import { AdminUserService, ApplicationService, ApplicationTokenService } from 'base/service';
|
import { AdminUserService, ApplicationService, ApplicationTokenService, SettingsService } from 'base/service';
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
@ -72,6 +72,7 @@ import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
|||||||
AdminUserService,
|
AdminUserService,
|
||||||
ApplicationService,
|
ApplicationService,
|
||||||
ApplicationTokenService,
|
ApplicationTokenService,
|
||||||
|
SettingsService,
|
||||||
|
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
|
@ -12,39 +12,60 @@ import {
|
|||||||
RESTRequestVoid
|
RESTRequestVoid
|
||||||
} from "./rest-tools"
|
} from "./rest-tools"
|
||||||
import {
|
import {
|
||||||
Application,
|
|
||||||
RightDescription,
|
|
||||||
Long,
|
|
||||||
ClientToken,
|
|
||||||
ApplicationSmall,
|
|
||||||
AddUserData,
|
AddUserData,
|
||||||
isApplication,
|
Application,
|
||||||
|
ApplicationSmall,
|
||||||
|
ClientToken,
|
||||||
|
Long,
|
||||||
|
RightDescription,
|
||||||
isRightDescription,
|
isRightDescription,
|
||||||
|
isApplication,
|
||||||
isLong,
|
isLong,
|
||||||
isClientToken,
|
|
||||||
isApplicationSmall,
|
isApplicationSmall,
|
||||||
|
isClientToken,
|
||||||
} from "./model"
|
} from "./model"
|
||||||
export namespace ApplicationResource {
|
export namespace ApplicationResource {
|
||||||
|
|
||||||
export function remove({
|
export function addUser({
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
|
data,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
|
data: AddUserData,
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return RESTRequestVoid({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/application/{id}",
|
endPoint: "/application/{id}/users",
|
||||||
requestType: HTTPRequestModel.DELETE,
|
requestType: HTTPRequestModel.POST,
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
contentType: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
export function create({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: Application,
|
||||||
|
}): Promise<Application> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isApplication);
|
||||||
|
};
|
||||||
export function get({
|
export function get({
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
@ -64,60 +85,6 @@ export namespace ApplicationResource {
|
|||||||
params,
|
params,
|
||||||
}, isApplication);
|
}, isApplication);
|
||||||
};
|
};
|
||||||
export function create({
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
data: Application,
|
|
||||||
}): Promise<Application> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/application",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
}, isApplication);
|
|
||||||
};
|
|
||||||
export function patch({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
data: Application,
|
|
||||||
}): Promise<Application> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/application/{id}",
|
|
||||||
requestType: HTTPRequestModel.PATCH,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
}, isApplication);
|
|
||||||
};
|
|
||||||
export function gets({
|
|
||||||
restConfig,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<Application[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/application",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isApplication);
|
|
||||||
};
|
|
||||||
export function getApplicationUsers({
|
export function getApplicationUsers({
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
@ -151,7 +118,78 @@ export namespace ApplicationResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
}, isApplicationSmall);
|
}, isApplicationSmall);
|
||||||
};
|
};
|
||||||
export function addUser({
|
export function getClientToken({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
application?: string,
|
||||||
|
},
|
||||||
|
}): Promise<ClientToken> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/get_token",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}, isClientToken);
|
||||||
|
};
|
||||||
|
export function getRightsDescription({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<RightDescription[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/{id}/rights",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isRightDescription);
|
||||||
|
};
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Application[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isApplication);
|
||||||
|
};
|
||||||
|
export function logOut({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
application?: string,
|
||||||
|
},
|
||||||
|
}): Promise<string> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/return",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
|
export function patch({
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
@ -160,16 +198,37 @@ export namespace ApplicationResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: AddUserData,
|
data: Application,
|
||||||
}): Promise<void> {
|
}): Promise<Application> {
|
||||||
return RESTRequestVoid({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/application/{id}/users",
|
endPoint: "/application/{id}",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
|
}, isApplication);
|
||||||
|
};
|
||||||
|
export function remove({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
export function removeUser({
|
export function removeUser({
|
||||||
@ -192,61 +251,4 @@ export namespace ApplicationResource {
|
|||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
export function getRightsDescription({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<RightDescription[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/application/{id}/rights",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isRightDescription);
|
|
||||||
};
|
|
||||||
export function getClientToken({
|
|
||||||
restConfig,
|
|
||||||
queries,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
queries: {
|
|
||||||
application?: string,
|
|
||||||
},
|
|
||||||
}): Promise<ClientToken> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/application/get_token",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
queries,
|
|
||||||
}, isClientToken);
|
|
||||||
};
|
|
||||||
export function logOut({
|
|
||||||
restConfig,
|
|
||||||
queries,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
queries: {
|
|
||||||
application?: string,
|
|
||||||
},
|
|
||||||
}): Promise<string> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/application/return",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
queries,
|
|
||||||
}, null);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -13,33 +13,13 @@ import {
|
|||||||
} from "./rest-tools"
|
} from "./rest-tools"
|
||||||
import {
|
import {
|
||||||
ApplicationToken,
|
ApplicationToken,
|
||||||
|
CreateTokenRequest,
|
||||||
Integer,
|
Integer,
|
||||||
Long,
|
Long,
|
||||||
CreateRequest,
|
|
||||||
isApplicationToken,
|
isApplicationToken,
|
||||||
} from "./model"
|
} from "./model"
|
||||||
export namespace ApplicationTokenResource {
|
export namespace ApplicationTokenResource {
|
||||||
|
|
||||||
export function remove({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
tokenId: Integer,
|
|
||||||
applicationId: Long,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/application_token/{applicationId}/{tokenId}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
export function create({
|
export function create({
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
@ -49,12 +29,13 @@ export namespace ApplicationTokenResource {
|
|||||||
params: {
|
params: {
|
||||||
applicationId: Long,
|
applicationId: Long,
|
||||||
},
|
},
|
||||||
data: CreateRequest,
|
data: CreateTokenRequest,
|
||||||
}): Promise<ApplicationToken> {
|
}): Promise<ApplicationToken> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/application_token//{applicationId}/create",
|
endPoint: "/application_token/{applicationId}/create",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -81,4 +62,24 @@ export namespace ApplicationTokenResource {
|
|||||||
params,
|
params,
|
||||||
}, isApplicationToken);
|
}, isApplicationToken);
|
||||||
};
|
};
|
||||||
|
export function remove({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
tokenId: Integer,
|
||||||
|
applicationId: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/application_token/{applicationId}/{tokenId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -16,36 +16,6 @@ import {
|
|||||||
} from "./model"
|
} from "./model"
|
||||||
export namespace DataResource {
|
export namespace DataResource {
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a thumbnail of from the data environment (if resize is possible)
|
|
||||||
*/
|
|
||||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
|
||||||
export function retrieveDataThumbnailId({
|
|
||||||
restConfig,
|
|
||||||
queries,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
queries: {
|
|
||||||
Authorization?: string,
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
uuid: UUID,
|
|
||||||
},
|
|
||||||
data: string,
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/data/thumbnail/{uuid}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
queries,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Get back some data from the data environment (with a beautiful name (permit download with basic name)
|
* Get back some data from the data environment (with a beautiful name (permit download with basic name)
|
||||||
*/
|
*/
|
||||||
@ -77,28 +47,6 @@ export namespace DataResource {
|
|||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Insert a new data in the data environment
|
|
||||||
*/
|
|
||||||
export function uploadFile({
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
data: {
|
|
||||||
file: File,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/data//upload/",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
contentType: HTTPMimeType.MULTIPART,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Get back some data from the data environment
|
* Get back some data from the data environment
|
||||||
*/
|
*/
|
||||||
@ -129,4 +77,56 @@ export namespace DataResource {
|
|||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Get a thumbnail of from the data environment (if resize is possible)
|
||||||
|
*/
|
||||||
|
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||||
|
export function retrieveDataThumbnailId({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
Authorization?: string,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
uuid: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data/thumbnail/{uuid}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Insert a new data in the data environment
|
||||||
|
*/
|
||||||
|
export function uploadFile({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: {
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data//upload/",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ export function isInstant(data: any): data is Instant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodDate = zod.date();
|
export const ZodDate = zod.string().datetime({ precision: 3 });
|
||||||
export type Date = zod.infer<typeof ZodDate>;
|
export type Date = zod.infer<typeof ZodDate>;
|
||||||
export function isDate(data: any): data is Date {
|
export function isDate(data: any): data is Date {
|
||||||
try {
|
try {
|
||||||
@ -81,7 +81,7 @@ export function isDate(data: any): data is Date {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodTimestamp = zod.date();
|
export const ZodTimestamp = zod.string().datetime({ precision: 3 });
|
||||||
export type Timestamp = zod.infer<typeof ZodTimestamp>;
|
export type Timestamp = zod.infer<typeof ZodTimestamp>;
|
||||||
export function isTimestamp(data: any): data is Timestamp {
|
export function isTimestamp(data: any): data is Timestamp {
|
||||||
try {
|
try {
|
||||||
@ -94,7 +94,7 @@ export function isTimestamp(data: any): data is Timestamp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodLocalDate = zod.date();
|
export const ZodLocalDate = zod.string().date();
|
||||||
export type LocalDate = zod.infer<typeof ZodLocalDate>;
|
export type LocalDate = zod.infer<typeof ZodLocalDate>;
|
||||||
export function isLocalDate(data: any): data is LocalDate {
|
export function isLocalDate(data: any): data is LocalDate {
|
||||||
try {
|
try {
|
||||||
@ -107,7 +107,7 @@ export function isLocalDate(data: any): data is LocalDate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodLocalTime = zod.date();
|
export const ZodLocalTime = zod.string().time();
|
||||||
export type LocalTime = zod.infer<typeof ZodLocalTime>;
|
export type LocalTime = zod.infer<typeof ZodLocalTime>;
|
||||||
export function isLocalTime(data: any): data is LocalTime {
|
export function isLocalTime(data: any): data is LocalTime {
|
||||||
try {
|
try {
|
||||||
@ -140,6 +140,21 @@ export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodAddUserData = zod.object({
|
||||||
|
userId: ZodLong.optional()
|
||||||
|
});
|
||||||
|
export type AddUserData = zod.infer<typeof ZodAddUserData>;
|
||||||
|
export function isAddUserData(data: any): data is AddUserData {
|
||||||
|
try {
|
||||||
|
ZodAddUserData.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodGenericTiming = zod.object({
|
export const ZodGenericTiming = zod.object({
|
||||||
// Create time of the object
|
// Create time of the object
|
||||||
createdAt: ZodDate.readonly().optional(),
|
createdAt: ZodDate.readonly().optional(),
|
||||||
@ -231,13 +246,14 @@ export function isApplicationSmall(data: any): data is ApplicationSmall {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodAddUserData = zod.object({
|
export const ZodClientToken = zod.object({
|
||||||
userId: ZodLong
|
url: zod.string().max(255).optional(),
|
||||||
|
jwt: zod.string().max(255).optional()
|
||||||
});
|
});
|
||||||
export type AddUserData = zod.infer<typeof ZodAddUserData>;
|
export type ClientToken = zod.infer<typeof ZodClientToken>;
|
||||||
export function isAddUserData(data: any): data is AddUserData {
|
export function isClientToken(data: any): data is ClientToken {
|
||||||
try {
|
try {
|
||||||
ZodAddUserData.parse(data);
|
ZodClientToken.parse(data);
|
||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(`Fail to parse data ${e}`);
|
console.log(`Fail to parse data ${e}`);
|
||||||
@ -272,22 +288,6 @@ export function isRightDescription(data: any): data is RightDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodClientToken = zod.object({
|
|
||||||
url: zod.string().max(255).optional(),
|
|
||||||
jwt: zod.string().max(255).optional()
|
|
||||||
});
|
|
||||||
export type ClientToken = zod.infer<typeof ZodClientToken>;
|
|
||||||
export function isClientToken(data: any): data is ClientToken {
|
|
||||||
try {
|
|
||||||
ZodClientToken.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
|
export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
|
||||||
parentId: ZodLong.optional(),
|
parentId: ZodLong.optional(),
|
||||||
name: zod.string().optional(),
|
name: zod.string().optional(),
|
||||||
@ -320,14 +320,14 @@ export function isApplicationToken(data: any): data is ApplicationToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodCreateRequest = zod.object({
|
export const ZodCreateTokenRequest = zod.object({
|
||||||
name: zod.string().max(255).optional(),
|
name: zod.string().max(255).optional(),
|
||||||
validity: ZodInteger.optional()
|
validity: ZodInteger.optional()
|
||||||
});
|
});
|
||||||
export type CreateRequest = zod.infer<typeof ZodCreateRequest>;
|
export type CreateTokenRequest = zod.infer<typeof ZodCreateTokenRequest>;
|
||||||
export function isCreateRequest(data: any): data is CreateRequest {
|
export function isCreateTokenRequest(data: any): data is CreateTokenRequest {
|
||||||
try {
|
try {
|
||||||
ZodCreateRequest.parse(data);
|
ZodCreateTokenRequest.parse(data);
|
||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(`Fail to parse data ${e}`);
|
console.log(`Fail to parse data ${e}`);
|
||||||
@ -373,6 +373,25 @@ export function isRight(data: any): data is Right {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodChangePassword = zod.object({
|
||||||
|
method: zod.string().max(32).optional(),
|
||||||
|
login: zod.string().max(512).optional(),
|
||||||
|
time: zod.string().max(64).optional(),
|
||||||
|
password: zod.string().max(128).optional(),
|
||||||
|
newPassword: zod.string().max(128).optional()
|
||||||
|
});
|
||||||
|
export type ChangePassword = zod.infer<typeof ZodChangePassword>;
|
||||||
|
export function isChangePassword(data: any): data is ChangePassword {
|
||||||
|
try {
|
||||||
|
ZodChangePassword.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
||||||
login: zod.string().max(128).optional(),
|
login: zod.string().max(128).optional(),
|
||||||
lastConnection: ZodTimestamp.optional(),
|
lastConnection: ZodTimestamp.optional(),
|
||||||
@ -426,27 +445,6 @@ export function isUserCreate(data: any): data is UserCreate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodUserAuth = ZodUser.extend({
|
|
||||||
password: zod.string().max(128).optional(),
|
|
||||||
email: zod.string().max(512).optional(),
|
|
||||||
emailValidate: ZodTimestamp.optional(),
|
|
||||||
newEmail: zod.string().max(512).optional(),
|
|
||||||
avatar: zod.boolean().optional(),
|
|
||||||
// List of accessible application (if not set the application is not available)
|
|
||||||
applications: zod.array(ZodLong).optional()
|
|
||||||
});
|
|
||||||
export type UserAuth = zod.infer<typeof ZodUserAuth>;
|
|
||||||
export function isUserAuth(data: any): data is UserAuth {
|
|
||||||
try {
|
|
||||||
ZodUserAuth.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodUserOut = zod.object({
|
export const ZodUserOut = zod.object({
|
||||||
id: ZodLong,
|
id: ZodLong,
|
||||||
login: zod.string().max(255).optional()
|
login: zod.string().max(255).optional()
|
||||||
@ -463,25 +461,6 @@ export function isUserOut(data: any): data is UserOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodChangePassword = zod.object({
|
|
||||||
method: zod.string().max(32).optional(),
|
|
||||||
login: zod.string().max(512).optional(),
|
|
||||||
time: zod.string().max(64).optional(),
|
|
||||||
password: zod.string().max(128).optional(),
|
|
||||||
newPassword: zod.string().max(128).optional()
|
|
||||||
});
|
|
||||||
export type ChangePassword = zod.infer<typeof ZodChangePassword>;
|
|
||||||
export function isChangePassword(data: any): data is ChangePassword {
|
|
||||||
try {
|
|
||||||
ZodChangePassword.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodGetToken = zod.object({
|
export const ZodGetToken = zod.object({
|
||||||
jwt: zod.string().optional()
|
jwt: zod.string().optional()
|
||||||
});
|
});
|
||||||
@ -511,6 +490,27 @@ export function isDataGetToken(data: any): data is DataGetToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUserAuth = ZodUser.extend({
|
||||||
|
password: zod.string().max(128).optional(),
|
||||||
|
email: zod.string().max(512).optional(),
|
||||||
|
emailValidate: ZodTimestamp.optional(),
|
||||||
|
newEmail: zod.string().max(512).optional(),
|
||||||
|
avatar: zod.boolean().optional(),
|
||||||
|
// List of accessible application (if not set the application is not available)
|
||||||
|
applications: zod.array(ZodLong).optional()
|
||||||
|
});
|
||||||
|
export type UserAuth = zod.infer<typeof ZodUserAuth>;
|
||||||
|
export function isUserAuth(data: any): data is UserAuth {
|
||||||
|
try {
|
||||||
|
ZodUserAuth.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ZodGetSignUpAvailable = zod.object({
|
export const ZodGetSignUpAvailable = zod.object({
|
||||||
signup: zod.boolean()
|
signup: zod.boolean()
|
||||||
});
|
});
|
||||||
|
@ -95,6 +95,10 @@ export interface RESTRequestType {
|
|||||||
callback?: RESTCallbacks,
|
callback?: RESTCallbacks,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function replaceAll(input, searchValue, replaceValue) {
|
||||||
|
return input.split(searchValue).join(replaceValue);
|
||||||
|
}
|
||||||
|
|
||||||
function removeTrailingSlashes(input: string): string {
|
function removeTrailingSlashes(input: string): string {
|
||||||
if (isNullOrUndefined(input)) {
|
if (isNullOrUndefined(input)) {
|
||||||
return "undefined";
|
return "undefined";
|
||||||
@ -113,7 +117,7 @@ export function RESTUrl({ restModel, restConfig, params, queries }: RESTRequestT
|
|||||||
let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
||||||
if (params !== undefined) {
|
if (params !== undefined) {
|
||||||
for (let key of Object.keys(params)) {
|
for (let key of Object.keys(params)) {
|
||||||
generateUrl = generateUrl.replaceAll(`{${key}}`, `${params[key]}`);
|
generateUrl = replaceAll(generateUrl, `{${key}}`, `${params[key]}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (queries === undefined && (restConfig.token === undefined || restModel.tokenInUrl !== true)) {
|
if (queries === undefined && (restConfig.token === undefined || restModel.tokenInUrl !== true)) {
|
||||||
@ -199,7 +203,7 @@ export function fetchProgress(generateUrl: string, { method, headers, body }: {
|
|||||||
status: xhr.io.status,
|
status: xhr.io.status,
|
||||||
statusText: xhr.io.statusText
|
statusText: xhr.io.statusText
|
||||||
});
|
});
|
||||||
const headersArray = xhr.io.getAllResponseHeaders().trim().replaceAll("\r\n", "\n").split('\n');
|
const headersArray = replaceAll(xhr.io.getAllResponseHeaders().trim(), "\r\n", "\n").split('\n');
|
||||||
headersArray.forEach(function (header) {
|
headersArray.forEach(function (header) {
|
||||||
const firstColonIndex = header.indexOf(':');
|
const firstColonIndex = header.indexOf(':');
|
||||||
if (firstColonIndex !== -1) {
|
if (firstColonIndex !== -1) {
|
||||||
@ -273,7 +277,7 @@ export function RESTRequest({ restModel, restConfig, data, params, queries, call
|
|||||||
action.then((response: Response) => {
|
action.then((response: Response) => {
|
||||||
if (response.status >= 200 && response.status <= 299) {
|
if (response.status >= 200 && response.status <= 299) {
|
||||||
const contentType = response.headers.get('Content-Type');
|
const contentType = response.headers.get('Content-Type');
|
||||||
if (restModel.accept !== contentType) {
|
if (!isNullOrUndefined(restModel.accept) && restModel.accept !== contentType) {
|
||||||
reject({
|
reject({
|
||||||
time: Date().toString(),
|
time: Date().toString(),
|
||||||
status: 901,
|
status: 901,
|
||||||
@ -326,7 +330,10 @@ export function RESTRequest({ restModel, restConfig, data, params, queries, call
|
|||||||
export function RESTRequestJson<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE> {
|
export function RESTRequestJson<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||||
if (checker(value.data)) {
|
if (isNullOrUndefined(checker)) {
|
||||||
|
console.log(`Have no check of MODEL in API: ${RESTUrl(request)}`);
|
||||||
|
resolve(value.data);
|
||||||
|
} else if (checker(value.data)) {
|
||||||
resolve(value.data);
|
resolve(value.data);
|
||||||
} else {
|
} else {
|
||||||
reject({
|
reject({
|
||||||
|
@ -12,31 +12,12 @@ import {
|
|||||||
RESTRequestVoid
|
RESTRequestVoid
|
||||||
} from "./rest-tools"
|
} from "./rest-tools"
|
||||||
import {
|
import {
|
||||||
Right,
|
|
||||||
Long,
|
Long,
|
||||||
|
Right,
|
||||||
isRight,
|
isRight,
|
||||||
} from "./model"
|
} from "./model"
|
||||||
export namespace RightResource {
|
export namespace RightResource {
|
||||||
|
|
||||||
export function remove({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/right/{id}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
export function get({
|
export function get({
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
@ -56,6 +37,20 @@ export namespace RightResource {
|
|||||||
params,
|
params,
|
||||||
}, isRight);
|
}, isRight);
|
||||||
};
|
};
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<Right[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/right",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isRight);
|
||||||
|
};
|
||||||
export function patch({
|
export function patch({
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
@ -97,18 +92,23 @@ export namespace RightResource {
|
|||||||
data,
|
data,
|
||||||
}, isRight);
|
}, isRight);
|
||||||
};
|
};
|
||||||
export function gets({
|
export function remove({
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
}): Promise<Right[]> {
|
params: {
|
||||||
return RESTRequestJsonArray({
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/right",
|
endPoint: "/right/{id}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
accept: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
}, isRight);
|
params,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -12,21 +12,38 @@ import {
|
|||||||
RESTRequestVoid
|
RESTRequestVoid
|
||||||
} from "./rest-tools"
|
} from "./rest-tools"
|
||||||
import {
|
import {
|
||||||
|
ChangePassword,
|
||||||
|
DataGetToken,
|
||||||
GetToken,
|
GetToken,
|
||||||
Long,
|
Long,
|
||||||
UserOut,
|
|
||||||
UserAuthGet,
|
|
||||||
DataGetToken,
|
|
||||||
UserCreate,
|
|
||||||
ChangePassword,
|
|
||||||
UserAuth,
|
UserAuth,
|
||||||
|
UserAuthGet,
|
||||||
|
UserCreate,
|
||||||
|
UserOut,
|
||||||
|
isUserAuth,
|
||||||
isGetToken,
|
isGetToken,
|
||||||
isUserOut,
|
isUserOut,
|
||||||
isUserAuthGet,
|
isUserAuthGet,
|
||||||
isUserAuth,
|
|
||||||
} from "./model"
|
} from "./model"
|
||||||
export namespace UserResource {
|
export namespace UserResource {
|
||||||
|
|
||||||
|
export function changePassword({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: ChangePassword,
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/password",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
export function create({
|
export function create({
|
||||||
restConfig,
|
restConfig,
|
||||||
data,
|
data,
|
||||||
@ -45,19 +62,57 @@ export namespace UserResource {
|
|||||||
data,
|
data,
|
||||||
}, isUserAuthGet);
|
}, isUserAuthGet);
|
||||||
};
|
};
|
||||||
export function getUsers({
|
export function getApplicationRight({
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
}): Promise<UserAuthGet[]> {
|
params: {
|
||||||
return RESTRequestJsonArray({
|
applicationId: Long,
|
||||||
|
userId: Long,
|
||||||
|
},
|
||||||
|
}): Promise<any> {
|
||||||
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/users",
|
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
}, isUserAuthGet);
|
params,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
|
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: DataGetToken,
|
||||||
|
}): Promise<GetToken> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/get_token",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isGetToken);
|
||||||
};
|
};
|
||||||
export function getUser({
|
export function getUser({
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -78,6 +133,58 @@ export namespace UserResource {
|
|||||||
params,
|
params,
|
||||||
}, isUserAuthGet);
|
}, isUserAuthGet);
|
||||||
};
|
};
|
||||||
|
export function getUsers({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<UserAuthGet[]> {
|
||||||
|
return RESTRequestJsonArray({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isUserAuthGet);
|
||||||
|
};
|
||||||
|
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,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
|
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,
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
export function linkApplication({
|
export function linkApplication({
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
@ -101,26 +208,6 @@ export namespace UserResource {
|
|||||||
data,
|
data,
|
||||||
}, isUserAuth);
|
}, isUserAuth);
|
||||||
};
|
};
|
||||||
export function getApplicationRight({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
applicationId: Long,
|
|
||||||
userId: Long,
|
|
||||||
},
|
|
||||||
}): Promise<any> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, null);
|
|
||||||
};
|
|
||||||
export function patchApplicationRight({
|
export function patchApplicationRight({
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
@ -189,91 +276,4 @@ export namespace UserResource {
|
|||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
export function getMe({
|
|
||||||
restConfig,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<UserOut> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users/me",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isUserOut);
|
|
||||||
};
|
|
||||||
export function changePassword({
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
data: ChangePassword,
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users/password",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
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,
|
|
||||||
}, null);
|
|
||||||
};
|
|
||||||
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,
|
|
||||||
}, null);
|
|
||||||
};
|
|
||||||
export function getToken({
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
data: DataGetToken,
|
|
||||||
}): Promise<GetToken> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users/get_token",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
}, isGetToken);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user