oda-sid-model
Version:
ODA SID Model Library for TMF APIs
352 lines (339 loc) • 13.7 kB
JavaScript
import axios from 'axios';
/* ODA SID Model Library - Generated by TSUP */
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var _GenericService = class _GenericService {
constructor({
accessToken,
refreshToken,
prefix,
// domain = "https://api-dev-oda.vnpt.vn"
domain = "http://10.165.68.7:30111"
}) {
const token = accessToken || localStorage.getItem("access_token") || "";
const refresh = refreshToken || localStorage.getItem("refresh_token") || "";
const urlPath = domain + prefix;
this.axiosInstance = axios.create({
baseURL: urlPath,
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${token}`,
refresh_token: refresh
}
});
}
/**
* hàm tạo đối tượng
* @param data
*/
async create(data) {
const response = await this.axiosInstance.post("", data);
return response.data;
}
async createList(data) {
return Promise.resolve({});
}
/**
* hàm này nhận vào là query dạng object , rồi từ object đó mới chuyển sang
* dạng string theo cặp key-value
* @param query object param đầu vào
*
* ------------------------
*
* # response
* @data data trả về từ be
* @statusCode mã code của response (belike 200,401,500,501)
* @xTotalCount số lượng item tất cả
* @xTotalResultCount: phần tử hiện tại
*/
async findByQuery(query) {
const response = await this.axiosInstance.get("", { params: query });
console.log(response.headers["Content-Type"]);
console.log(response.headers["content-type"]);
console.log(response.headers["x-total-count"]);
console.log(response.headers["x-result-count"]);
return {
data: response.data,
statusCode: response.status,
xTotalCount: response.headers["x-total-count"],
xTotalResultCount: response.headers["x-result-count"]
};
}
/**
* tìm kiếm theo id
* @param id
*/
async findById(id) {
const response = await this.axiosInstance.get(`/${id}`);
return response.data;
}
/**
* cập nhật dữ liệu theo id và trả về dữ liệu đã được cập nhật
* @param id mã định danh
* @param data dữ liệu cần gửi lên
*/
async patch(id, data) {
const response = await this.axiosInstance.patch(`/${id}`, data);
return response.data;
}
async put(id, data) {
const response = await this.axiosInstance.put(`/${id}`, data);
return response.data;
}
/**
* xoá dữ liệu theo id
* @param id
*/
async delete(id) {
await this.axiosInstance.delete(`/${id}`);
}
};
__name(_GenericService, "GenericService");
var GenericService = _GenericService;
// src/models/shared/generic.repository.ts
var _GenericServiceRepository = class _GenericServiceRepository {
};
__name(_GenericServiceRepository, "GenericServiceRepository");
var GenericServiceRepository = _GenericServiceRepository;
// src/models/constant/apiDomain.ts
var UriConstant = {
URI_TMF620: "/TMFC001/TMF620/v5/",
URI_TMF723: "/TMFC001/TMF723/v4/",
URI_TMF671: "/TMFC001/TMF671/v5/",
URI_TMF806: "/TMFC001/TMF806/v1/",
URI_TMF807: "/TMFC001/TMF807/v1/",
URI_TMF808: "/TMFC001/TMF808/v1/",
URI_TMF809: "/TMFC001/TMF809/v1/",
URI_TMF622: "/TMFC002/TMF622/v5/",
URI_TMF648: "/TMFC002/TMF648/v5/",
URI_TMF663: "/TMFC002/TMF663/v5/",
URI_TMF679: "/TMFC027/TMF679/v5/",
URI_TMF760: "/TMFC027/TMF760/v5/",
URI_TMF637: "/TMFC005/TMF637/v5/",
URI_TMF633: "/TMFC006/TMF633/v5/",
URI_TMF657: "/TMFC006/TMF657/v4/",
URI_TMF641: "/TMFC007/TMF641/v5/",
URI_TMF638: "/TMFC008/TMF638/v5/",
URI_TMF645: "/TMFC009/TMF645/v5/",
URI_TMF634: "/TMFC010/TMF634/v5/",
URI_TMF652: "/TMFC011/TMF652/v4/",
URI_TMF639: "/TMFC012/TMF639/v5/",
URI_TMF685: "/TMFC012/TMF685/v5/",
URI_TMF697: "/TMFC061/TMF697/v5/",
URI_TMF713: "/TMFC061/TMF713/v4/",
URI_TMF714: "/TMFC061/TMF714/v4/",
URI_TMF646: "/TMFC046/TMF646/v5/",
URI_TMF802: "/TMFC100/TMF802/v1/",
URI_TMF803: "/TMFC100/TMF803/v1/",
URI_TMF804: "/TMFC102/TMF804/v1/",
URI_TMF805: "/TMFC102/TMF805/v2/",
URI_TMF701: "/TMFC003/TMF701/v5/",
URI_TMF666: "/TMFC035/TMF666/v5/",
// temporary URIs placed under TMFC001
URI_TMF664: "/TMFC001/TMF664/v4/",
URI_TMF669: "/TMFC035/TMF669/v5/",
URI_TMF673: "/TMFC014/TMF673/v5/",
URI_TMF674: "/TMFC014/TMF674/v5/",
URI_TMF675: "/TMFC014/TMF675/v4/",
URI_TMF629: "/TMFC001/TMF629/v5/",
URI_TMF678: "/TMFC030/TMF678/v5/",
URI_TMF683: "/TMFC023/TMF683/v5/",
URI_TMF687: "/TMFC001/TMF687/v4/",
URI_TMF662: "/TMFC001/TMF662/v4/",
URI_TMF699: "/TMFC036/TMF699/v5/",
URI_TMF632: "/TMFC028/TMF632/v5/",
URI_TMF651: "/TMFC039/TMF651/v5/",
URI_TMF676: "/TMFC029/TMF676/v4/",
URI_TMF716: "/TMFC001/TMF716/v4/",
URI_TMF801: "/TMFC001/TMF801/v5/",
DynamicForm: "/dynamic-form"
};
// src/models/constant/apiUriPath.ts
var UriEntity = {
// TMFC001
ProductCatalog: UriConstant.URI_TMF620 + "productCatalog",
ProductOffering: UriConstant.URI_TMF620 + "productOffering",
ProductOfferingPrice: UriConstant.URI_TMF620 + "productOfferingPrice",
ProductOfferingPriceMatrix: UriConstant.URI_TMF620 + "productOfferingPriceMatrix",
ProductSpecification: UriConstant.URI_TMF620 + "productSpecification",
Category: UriConstant.URI_TMF620 + "category",
Promotion: UriConstant.URI_TMF671 + "promotion",
PolicyAction: UriConstant.URI_TMF723 + "policyAction",
PolicyCondition: UriConstant.URI_TMF723 + "policyCondition",
PolicyEvent: UriConstant.URI_TMF723 + "policyEvent",
PolicyRule: UriConstant.URI_TMF723 + "policyRule",
PolicyVariable: UriConstant.URI_TMF723 + "policyVariable",
PolicyVariableSet: UriConstant.URI_TMF723 + "policyVariableSet",
ActionType: UriConstant.URI_TMF671 + "actionType",
Criteria: UriConstant.URI_TMF671 + "criteria",
CriteriaSet: UriConstant.URI_TMF671 + "criteriaSet",
Association: UriConstant.URI_TMF662 + "association",
AssociationSpecification: UriConstant.URI_TMF662 + "associationSpecification",
WorkIssue: UriConstant.URI_TMF801 + "workIssue",
WorkFlow: UriConstant.URI_TMF801 + "workFlow",
WorkProject: UriConstant.URI_TMF801 + "workProject",
ProductGroup: UriConstant.URI_TMF806 + "productGroup",
ProductProperty: UriConstant.URI_TMF806 + "productProperty",
PropertySpecification: UriConstant.URI_TMF806 + "propertySpecification",
Community: UriConstant.URI_TMF807 + "community",
CommunityGroup: UriConstant.URI_TMF808 + "communityGroup",
OfferInstance: UriConstant.URI_TMF808 + "offerInstance",
DecisionTableSpecification: UriConstant.URI_TMF809 + "decisionTableSpecification",
// TMFC002
CancelProductOrder: UriConstant.URI_TMF622 + "cancelProductOrder",
ProductOrder: UriConstant.URI_TMF622 + "productOrder",
Quote: UriConstant.URI_TMF648 + "quote",
ShoppingCart: UriConstant.URI_TMF663 + "shoppingCart",
// TMFC003
ProcessFlow: UriConstant.URI_TMF701 + "processFlow",
TaskFlow: UriConstant.URI_TMF701 + "taskFlow",
// TMFC005
Product: UriConstant.URI_TMF637 + "product",
// TMFC006
ServiceCatalog: UriConstant.URI_TMF633 + "serviceCatalog",
ServiceCategory: UriConstant.URI_TMF633 + "serviceCategory",
ServiceCandidate: UriConstant.URI_TMF633 + "serviceCandidate",
ServiceSpecification: UriConstant.URI_TMF633 + "serviceSpecification",
ServiceLevelObjective: UriConstant.URI_TMF657 + "serviceLevelObjective",
ServiceLevelSpecification: UriConstant.URI_TMF657 + "serviceLevelSpecification",
// TMFC007
CancelServiceOrder: UriConstant.URI_TMF641 + "cancelServiceOrder",
ServiceOrder: UriConstant.URI_TMF641 + "serviceOrder",
// TMFC008
Service: UriConstant.URI_TMF638 + "shared",
ResourceFacingService: UriConstant.URI_TMF638 + "shared",
CustomerFacingService: UriConstant.URI_TMF638 + "shared",
// TMFC009
CheckServiceQualification: UriConstant.URI_TMF645 + "checkServiceQualification",
QueryServiceQualification: UriConstant.URI_TMF645 + "queryServiceQualification",
// TMFC010
ResourceCatalog: UriConstant.URI_TMF634 + "resourceCatalog",
ResourceCategory: UriConstant.URI_TMF634 + "resourceCategory",
ResourceCandidate: UriConstant.URI_TMF634 + "resourceCandidate",
ResourceSpecification: UriConstant.URI_TMF634 + "resourceSpecification",
LogicalResourceSpecification: UriConstant.URI_TMF634 + "logicalResourceSpecification",
PhysicalResourceSpecification: UriConstant.URI_TMF634 + "physicalResourceSpecification",
ResourceFunctionSpecification: UriConstant.URI_TMF634 + "resourceFunctionSpecification",
// TMFC027
CheckProductOfferingQualification: UriConstant.URI_TMF679 + "checkProductOfferingQualification",
QueryProductOfferingQualification: UriConstant.URI_TMF679 + "queryProductOfferingQualification",
CheckProductConfiguration: UriConstant.URI_TMF760 + "checkProductConfiguration",
QueryProductConfiguration: UriConstant.URI_TMF760 + "queryProductConfiguration",
// TMFC011
CancelResourceOrder: UriConstant.URI_TMF652 + "cancelResourceOrder",
ResourceOrder: UriConstant.URI_TMF652 + "resourceOrder",
// TMFC012
Resource: UriConstant.URI_TMF639 + "resource",
CapacitySpecification: UriConstant.URI_TMF685 + "capacitySpecification",
ResourcePool: UriConstant.URI_TMF685 + "resourcePool",
ResourcePoolSpecification: UriConstant.URI_TMF685 + "resourcePoolSpecification",
// TMFC100
Picklist: UriConstant.URI_TMF802 + "picklist",
CharacteristicCatalog: UriConstant.URI_TMF803 + "characteristicCatalog",
CharacteristicCategory: UriConstant.URI_TMF803 + "characteristicCategory",
CharacteristicSpecification: UriConstant.URI_TMF803 + "characteristicSpecification",
// TMFC102
Proposal: UriConstant.URI_TMF804 + "proposal",
ProposalGroup: UriConstant.URI_TMF805 + "proposalGroup",
ProposalSpecification: UriConstant.URI_TMF805 + "proposalSpecification",
// TMFC061
Work: UriConstant.URI_TMF713 + "work",
WorkSpecification: UriConstant.URI_TMF713 + "workSpecification",
CheckWorkQualification: UriConstant.URI_TMF714 + "checkWorkQualification",
QueryWorkQualification: UriConstant.URI_TMF714 + "queryWorkQualification",
CancelWorkOrder: UriConstant.URI_TMF697 + "cancelWorkOrder",
WorkOrder: UriConstant.URI_TMF697 + "workOrder",
// TMFC046
Appointment: UriConstant.URI_TMF646 + "appointment",
SearchTimeSlot: UriConstant.URI_TMF646 + "searchTimeSlot",
// CancelServiceOrder
DynamicForm: UriConstant.DynamicForm
};
function getApiUrlPath(entityName) {
return UriEntity[entityName] ?? "";
}
__name(getApiUrlPath, "getApiUrlPath");
// src/models/features/TMFC001/ProductSpecification/factory.ts
var _ProductSpecificationFactory = class _ProductSpecificationFactory extends GenericService {
constructor() {
super({
prefix: getApiUrlPath("ProductSpecification")
});
}
};
__name(_ProductSpecificationFactory, "ProductSpecificationFactory");
var ProductSpecificationFactory = _ProductSpecificationFactory;
// src/models/features/TMFC001/ProductCatalog/factory.ts
var _ProductCatalogFactory = class _ProductCatalogFactory extends GenericService {
constructor() {
super({
prefix: getApiUrlPath("ProductCatalog")
});
}
};
__name(_ProductCatalogFactory, "ProductCatalogFactory");
var ProductCatalogFactory = _ProductCatalogFactory;
// src/models/features/TMFC001/Criteria/factory.ts
var _CriteriaFactory = class _CriteriaFactory extends GenericService {
constructor() {
super({
prefix: getApiUrlPath("Criteria")
});
}
};
__name(_CriteriaFactory, "CriteriaFactory");
var CriteriaFactory = _CriteriaFactory;
// src/models/features/TMFC001/ProductGroup/factory.ts
var _ProductGroupFactory = class _ProductGroupFactory extends GenericService {
constructor() {
super({
prefix: getApiUrlPath("ProductGroup")
});
}
};
__name(_ProductGroupFactory, "ProductGroupFactory");
var ProductGroupFactory = _ProductGroupFactory;
// src/models/features/TMFC001/PolicyAction/factory.ts
var _PolicyActionFactory = class _PolicyActionFactory extends GenericService {
constructor() {
super({
prefix: getApiUrlPath("PolicyAction")
});
}
};
__name(_PolicyActionFactory, "PolicyActionFactory");
var PolicyActionFactory = _PolicyActionFactory;
// src/models/features/TMFC001/PolicyCondition/factory.ts
var _PolicyConditionFactory = class _PolicyConditionFactory extends GenericService {
constructor() {
super({
prefix: getApiUrlPath("PolicyCondition")
});
}
};
__name(_PolicyConditionFactory, "PolicyConditionFactory");
var PolicyConditionFactory = _PolicyConditionFactory;
// src/models/features/TMFC001/PolicyEvent/factory.ts
var _PolicyEventFactory = class _PolicyEventFactory extends GenericService {
constructor() {
super({
prefix: getApiUrlPath("PolicyEvent")
});
}
};
__name(_PolicyEventFactory, "PolicyEventFactory");
var PolicyEventFactory = _PolicyEventFactory;
// src/models/features/TMFC001/PolicyRule/factory.ts
var _PolicyRuleFactory = class _PolicyRuleFactory extends GenericService {
constructor() {
super({
prefix: getApiUrlPath("PolicyRule")
});
}
};
__name(_PolicyRuleFactory, "PolicyRuleFactory");
var PolicyRuleFactory = _PolicyRuleFactory;
export { CriteriaFactory, GenericService, GenericServiceRepository, PolicyActionFactory, PolicyConditionFactory, PolicyEventFactory, PolicyRuleFactory, ProductCatalogFactory, ProductGroupFactory, ProductSpecificationFactory, UriConstant, UriEntity, getApiUrlPath };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map