0.0.98 • Published 3 years ago

towify-data-engine v0.0.98

Weekly downloads
85
License
ISC
Repository
-
Last release
3 years ago

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 => {
    });

wechat

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 => {
      });
0.0.98

3 years ago

0.0.97

3 years ago

0.0.96

3 years ago

0.0.95

3 years ago

0.0.93

3 years ago

0.0.94

3 years ago

0.0.92

3 years ago

0.0.91

3 years ago

0.0.90

3 years ago

0.0.89

3 years ago

0.0.87

3 years ago

0.0.88

3 years ago

0.0.86

3 years ago

0.0.85

3 years ago

0.0.84

3 years ago

0.0.83

3 years ago

0.0.82

3 years ago

0.0.81

3 years ago

0.0.80

3 years ago

0.0.79

3 years ago

0.0.78

3 years ago

0.0.77

3 years ago

0.0.76

3 years ago

0.0.75

3 years ago

0.0.74

3 years ago

0.0.73

3 years ago

0.0.72

3 years ago

0.0.71

3 years ago

0.0.70

3 years ago

0.0.69

3 years ago

0.0.68

3 years ago

0.0.67

3 years ago

0.0.66

3 years ago

0.0.65

3 years ago

0.0.64

3 years ago

0.0.63

3 years ago

0.0.62

3 years ago

0.0.61

3 years ago

0.0.60

3 years ago

0.0.59

3 years ago

0.0.57

3 years ago

0.0.58

3 years ago

0.0.56

3 years ago

0.0.54

3 years ago

0.0.55

3 years ago

0.0.53

3 years ago

0.0.52

3 years ago

0.0.51

3 years ago

0.0.50

3 years ago

0.0.48

3 years ago

0.0.49

3 years ago

0.0.46

3 years ago

0.0.47

3 years ago

0.0.45

3 years ago

0.0.44

3 years ago

0.0.41

3 years ago

0.0.42

3 years ago

0.0.43

3 years ago

0.0.40

3 years ago

0.0.37

3 years ago

0.0.38

3 years ago

0.0.36

3 years ago

0.0.35

3 years ago

0.0.34

3 years ago

0.0.33

3 years ago

0.0.32

3 years ago

0.0.30

3 years ago

0.0.31

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.0.27

3 years ago

0.0.26

4 years ago

0.0.25

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.17

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago