towify-data-engine v0.0.98
TowifyDataEngine
if you want use TowifyDataEngine in your project, first you should prepare apiUrl and resourceUrl to init TowifyDataEngine:
import {TowifyDataEngine} from 'towify-data-engine';
const dataEngine = new TowifyDataEngine({
apiUrl: '',
resourceUrl: '',
token: '',
projectId: ''
});
after login \ register you must update token and after create \ change project you must update projectId
uploader
if you want upload file, you can user uplader in TowifyDataEngine
upload file:
uploadFile(params: { file: File, fileName?: string }): FileUploaderInterface;
// eg
dataEngine
.uploader
.uploadFile({
file
}).subscribe({
start: event => {
// upload file start
},
progress: progress => {
// upload file progress
},
complete: result => {
// upload file complete
},
err: error => {
// upload file error
}
});
update
mange update installed data eg: installed kit
check total api update status
checkTotalApiUpdateStatusByMd5s(): Promise<boolean>;
// eg
dataEngine
.updater
.checkTotalApiUpdateStatusByMd5s()
.then(result => {
// update complete
}, error => {
// update error
});
project
if you want manage you project, you can use project in TowifyDataEngine to manage project
get project image
getProjectImageList(params: {
// get project image cout
count: number,
// current page index
pageIndex: number,
// order by, default createdAt
orderBy?: OrderType,
// sort by, default Desc
sortBy?: SortType
}): Promise<ImageItem[]>;
// eg
dataEngine
.project
.getProjectImageList({
count: 10,
pageIndex: 0
}).then(result => {
// get image file list success
}, error => {
// get image file list error
});
delete file by key
deleteFileByKey(key: string): Promise<Boolean>;
// eg
dataEngine
.project
.deleteFileByKey('5f8914eaf10edc5ba4077721')
.then(result => {
// delete file success
}, error => {
// delete file error
});
kit
if you want mange you kit, you can use kit in TowifyDataEngine to manage kit, In kit controller have local and store, store is manage kit store function ,local is mange kit local function
setKitType
if you want to use the 'kit' manager in the dataEngine, you must set kitType first ,or it will throw exception.
dataEngine
.kit
.setKitType(KitType.IconKit);
kit store
if you want get store kit info , you can use kit store function
get store kit list
import { PageSizeType } from "./common.type";
// PageSizeType: small\medium\large
getList(pageSizeType: PageSizeType): SubscriptionInterface<KitModel[]>;
// eg
// don't forget to setKitType first.
dataEngine
.kit
.setKitType(KitType.IconKit);
dataEngine
.kit
.store
.getList(PageSizeType.Small)
.subscribe(result => {
// back new kit list from service
}, error => {
// get kit list error
});
// load more
dataEngine
.kit
.store
.getList(PageSizeType.Small)
.loadMore()
.subscribe(result => {
// back new kit list from service
}, error => {
// get kit list error
});
get store installed kit list
import { PageSizeType } from "./common.type";
// PageSizeType: small\medium\large
getInstalledList(pageSizeType: PageSizeType): SubscriptionInterface<KitModel[]>;
// eg
dataEngine
.kit
.setKitType(KitType.IconKit);
dataEngine
.kit
.store
.getInstalledList(PageSizeType.Small)
.subscribe(result => {
// get kit item list success
}, error => {
// get kit item list error
});
// load more
dataEngine
.kit
.store
.getInstalledList(PageSizeType.Small)
.loadMore()
.subscribe(result => {
// back new kit list from service
}, error => {
// get kit list error
});
set preview kit
if you want get store kit detail, you should set previewKit first
setPreviewKit(kit: KitModel): void;
// eg
dataEngine
.kit
.setKitType(KitType.IconKit);
dataEngine
.kit
.store
.setPreviewKit(kit);
get store kit preview list
after set preview kit, you can use getPreviewList function get kit preview icon list from service
getPreviewList(count: number): SubscriptionInterface<{ name: string, url: string }[]>;
// eg
dataEngine
.kit
.setKitType(KitType.IconKit);
dataEngine
.kit
.store
.getPreviewList(10)
.subscribe((result) => {
}, (error) => {
});
// load more
dataEngine
.kit
.store
.getPreviewList(10)
.loadMore()
.subscribe(result => {
// back new kit list from service
}, error => {
// get kit list error
});
install kit
after set preview kit, you can use install function install kit from service to local
install(): ProgressSubscriptionInterface<boolean>;
// eg
dataEngine
.kit
.setKitType(KitType.IconKit);
dataEngine
.kit
.store
.install()
.subscribe({
complete: result => {
// install complete
},
progress: progress => {
// install progress
},
start: event => {
// install start
},
err: error => {
// install error
}
});
uninstall kit
after set preview kit, you can use uninstall function remove local kit data
uninstall(): Promise<boolean>;
// eg
dataEngine
.kit
.setKitType(KitType.IconKit);
dataEngine
.kit
.store
.uninstall
.then(result => {
// uninstall success
}, error => {
// uninstall error
});
kit local
if you want get local kit info, you can ust kit local function
import { PageSizeType } from "./common.type";
// PageSizeType: small\medium\large
getList(pageSizeType: PageSizeType): SubscriptionInterface<{ id: string, name: string }[]>;
// eg
dataEngine
.kit
.setKitType(KitType.IconKit);
dataEngine
.kit
.local
.getList(PageSizeType.Small)
.subscribe((result) => {
// back new kit list from local
}, (error) => {
// get kit list error
});
// load more
dataEngine
.kit
.local
.getList(PageSizeType.Small)
.loadMore()
.subscribe((result) => {
// back new kit list from local
}, (error) => {
// get kit list error
});
set preview kit
if you want get local kit detail, you should set previewKit first if local kit is broken(delete or uninstalled), call setPreviewKitById function will download and install this kit first
setPreviewKitById(kitId: string): Promise<boolean>;
// eg
dataEngine
.kit
.setKitType(KitType.IconKit);
dataEngine
.kit
.local
.setPreviewKitById('5f8914eaf10edc5ba4077720')
.then((result) => {
// set preview kit success
}, (error) => {
// set preview kit error
});
get kit category and style list
after set preview kit, you can get preview kit category and style list
categoryList: { id: string, name: string }[];
styleList: { id: string, name: string }[];
// eg
dataEngine
.kit
.setKitType(KitType.IconKit);
dataEngine
.kit
.local
.categoryList
dataEngine
.kit
.local
.styleList
get kit icon list
after set preview kit, you can get preview kit icon list by category id and style id if you don't set category id and style id, back icon list belong first category and first style
getList(params: {
categoryId?: string,
styleId?: string
}): Promise<KitIconModel[]>;
// eg
dataEngine
.kit
.setKitType(KitType.IconKit);
dataEngine
.kit
.local
.icon
.getList({
categoryId: '5fa0d04bc0a03b6ce9b9dc3c',
styleId: '5fa0e565c0a03b6ce9b9dc4d'
})
.then((result) => {
}, (error) => {
});
custom font
if you want upload a custom font, you can use kit custom function.
attention: you should call "setKitType" and set "KitType.FontKit" first.
upload custom font
upload(fontFile: File): ProgressSubscriptionInterface<boolean>;
// eg
dataEngine
.kit
.setKitType(KitType.FontKit);
dataEngine
.kit
.custom
.upload(this.uploadFile)
.subscribe({
complete: result => {
// upload result: true or false
},
progress: progress => {
// upload progress
},
err: error => {
// upload error
}
});
get custom font list from local
this method return the local data, not server data
getList(pageSize: number): SubscriptionInterface<KitCustomFontModel[]>;
// eg
dataEngine
.kit
.setKitType(KitType.FontKit);
// get the list from page 0
dataEngine
.kit
.custom
.getList(10)
.subscribe(
(list)=>{
// get the result
},
(error)=>{
// get the error
}
)
// get more list
dataEngine
.kit.custom
.getList(10)
.loadMore()
.subscribe(
(list)=>{
// get next page result
},
(error)=>{
// get the error
}
)
set polling interval and repeatCount
to configure the interval and repeatCount when polling server for upload state.
setPollingIntervalAndRepeatCount(
interval: number,
repeatCount: number
): FontKitCustomManagerInterface;
//eg
dataEngine
.kit
.custom
.setPollingIntervalAndRepeatCount(10,20);
synchronize custom font
synchronize(): ProgressSubscriptionInterface<boolean>;
//eg
dataEngine
.kit
.setKitType(KitType.FontKit);
dataEngine
.kit
.custom
.synchronize()
.subscribe({
complete: result => {
// install result: true or false
},
progress: progress => {
// install progress
},
err: error => {
// install error
}
});
user
if you want to login or get user information, you can use 'user' in TowifyDataEngine.
get SMS Code:
getSMSCodeByPhone(phone: string): Promise<boolean>;
//eg
dataEngine
.user
.getSMSCodeByPhone(
'15510481046'
)
.then(
result => {
// judge the 'result' is true or false
},
error => {
}
);
register by phone:
registerByPhone(params: {
phone: string;
password: string;
confirmedPassword: string;
code: string;
}): Promise< { success: boolean; message: string } >;
//eg
dataEngine
.user
.registerByPhone({
phone: '15510481046',
password: '111111',
confirmedPassword: '111111',
smsCode: '2275'
})
.then(
result => {
// judge the 'result.success' is true or false
// if 'result.success' is false, check 'result.message' to get information
},
error => {
}
);
login by phone:
loginByPhone(
phone: string,
password: string
): Promise<{
success: boolean;
message: string
}>;
//eg
dataEngine
.user
.loginByPhone(
'15510481046',
'111111')
.then(
result => {
// judge the 'result.success' is true or false
// if 'result.success' is false, check 'result.message' to get information
},
error => {
}
);
login by SMS code:
loginBySMSCode(
phone: string,
SMSCode: string
): Promise<{
success: boolean;
message: string
}>;
//eg
dataEngine
.user
.loginBySMSCode(
'15510481046',
'2834')
.then(
result => {
// judge the 'result.success' is true or false
// if 'result.success' is false, check 'result.message' to get information
},
error => {
}
);
update password:
updatePassword(
password: string,
confirmedPassword: string
): Promise<{ success: boolean; message: string }>;
//eg
dataEngine
.user
.updatePassword(
'111111',
'111111')
.then(
result => {
// judge the 'result.success' is true or false
// if 'result.success' is false, check 'result.message' to get information
},
error => {
});
get user information:
getUserInformation(): Promise<UserModel>;
//eg
dataEngine
.user
.getUserInformation()
.then(
result => {
// result is a list about users
},
error => {
});
get current token:
// after login, you will get token
dataEngine.user.getCurrentToken()
update user information:
updateUserInformation(params: UserUpdateKey): Promise<{
success: boolean;
message: string
}>;
//eg
dataEngine.user.updatePassword(
'111111',
'111111')
.then(
result => {
// judge the 'result.success' is true or false
// if 'result.success' is false, check 'result.message' to get information
},
error => {
});
register by email:
registerByEmail(email: string, password: string): Promise< {
success: boolean;
message: string
} >;
//eg
dataEngine
.user
.registerByEmail(
'gotozhangqi@163.com',
'111111'
).then(
result => {
// judge the 'result.success' is true or false
// if 'result.success' is false, check 'result.message' to get information
},
error => {
});
confirm email:
confirmEmail(email: string, code: string): Promise< {
success: boolean;
message: string
} >;
//eg
dataEngine
.user
.confirmEmail(
'gotozhangqi@163.com',
'708016'
).then(
result => {
// judge the 'result.success' is true or false
// if 'result.success' is false, check 'result.message' to get information
},
error => {
});
resend email code:
resendEmailCode(email: string): Promise<boolean>;
//eg
dataEngine
.user
.resendEmailCode(
'gotozhangqi@163.com'
).then(
result => {
// judge the 'result' is true or false
},
error => {
});
login by email:
loginByEmail(email: string, password: string): Promise<{
success: boolean;
message: string
}>;
//eg
dataEngine
.user
.loginByEmail(
'gotozhangqi@163.com',
'111111'
).then(
result => {
// judge the 'result.success' is true or false
// if 'result.success' is false, check 'result.message' to get information
},
error => {
});
if you want operate about wechat, for example do login by wechat, you can use "wechat" in TowifyDataEngine.
getQRCode:
getQRCode(): Promise<{ success: boolean; codeUrl:string; message: string }>;
//eg
dataEngine
.wechat
.getQRCode()
.then(
result => {
// judge the 'result.success' is true or false
// if 'result.success' is false, check 'result.message' to get information
// if 'result.success' is true, get the codeImageUrl from 'result.codeUrl'
},
error => {
});
startPollingForLoginState:
startPollingForLoginState(interval: number, repeatCount?: number): Promise<{ success: boolean; message: string }>;
//eg
dataEngine
.wechat
.startPollingForLoginState(2,20)
.then(
result => {
// callback happen and the polling timer stop when :
// 1、login succeed
// 2、reach the limit about repeat count which you set or default
// 3、network service error
// 4、manual stop polling by the API
},
error => {
});
stopPollingForLoginState:
stopPollingForLoginState(): boolean;
//eg
dataEngine.wechat.stopPollingForLoginState();
checkLoginState:
checkLoginState(): Promise<{ success: boolean; message: string }>;
//eg
dataEngine.wechat.checkLoginState()
.then(
result => {
// judge the 'result.success' is true or false
// if 'result.success' is false, check 'result.message' to get information
},
error => {
});
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago