1.2.4 • Published 2 months ago

omnx v1.2.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

說明

安裝

yarn add omnx && npm install omnx

使用

  • 引用omnx

    import *as omnx from 'omnx'

  • 創建omnx對象

 const cf = new omnx.ClientFile({
        serverApi: config.CLIENT_SERVER_API,
        signKey: config.CLIENT_SIGN_KEY,
        systemCode: config.SYSTEM_CODE,
        systemName: config.SYSTEM_NAME,
        dynamicFieldTemplateId: config.DYNAMIC_FIELD_TEMPLATE_ID,
        interval:5000,//默認5000ms
        ...
    })
  • 常用方法
     cf.start(async dynamicFieldDatas => {
           console.log('收集所需字段模板',dynamicFieldDatas)
           //創建對應數據
           const dynamicModelData: {
               [dynamicFieldKey: string]: any;
           } = {}
           // 返回一個promise<{dynamicModelData,onEnd}>
           return {
               dynamicModelData,
               onEnd: (e) => {
                   logger.info(`是否報錯!`, e)
               }
           }
       })
##  對象說明 (作為參考、具體以最新版本數據為準)
#### ClientFile

```ts
export declare class ClientFile {
   
    constructor(props: ClientFileProps);
  
    /**
     * !!!!!!! 启动
     * @param callBack 回调参数是 PostClientDynamicFieldDataRes ,注意:callBack里面也要返回一个对象,具体看下面参数
     */
    start(callBack: (data: PostClientDynamicFieldDataRes[]) => Promise<{
        dynamicModelData: {
            [dynamicFieldKey: string]: any;
        };
        onEnd?(kind: PostClientDynamicModelErrorCode | 'ok', message?: string | undefined): void;
    }>): Promise<void>;
    /**
     * readFileDir
     */
    static readFileDir(): Promise<FileJsonData[]>;
    static deleteFile(fileId: string): void;

    /**
     * 停止
     */
    stop: () => void;
}

ClientFileProps

    serverApi: string;
    signKey: string;
    systemCode: string;
    projectCode?: string;
    projectName?: string;
    systemName: string;
    dynamicFieldTemplateId: string;
    /**
     * 时间间隔 默认5000Ms 使用方式 :https://crontab.guru/
     */
    cronExpression?: string;

PostClientDynamicFieldDataRes

    id: string;
    /**
     * 动态模板ID
     */
    dynamicFieldTemplateId: string;
    /**
     * 字段绰号
     */
    label: string;
    /**
     * 字段名
     */
    key: string;
    /**
     * 类别
     */
    type: 'string' | 'number' | 'boolean';
    /**
     * 类别单位
     */
    typeUnit?: string;
    /**
     * 是否必填
     */
    required?: boolean;
    createdAt: string;

PostClientDynamicModelErrorCode

 'INVALID_PARAMS' |
 'INVALID_PERMISSION'|
 'INVALID_DYNAMIC_FIELD_TEMPLATE' |
 'INVALID_DYNAMIC_FIELD_KEY' |
 'INVALID_VALUE' |
 'INVALID_SIGN' |
 'SERVER_ERROR'

FileJsonData

 fileId: string;
 systemCode: string;
 projectCode?: string;
 systemName: string;
 projectName?: string;
 createdAt: string;
 dynamicFieldTemplateId: string;
 data: {
     [x: string]: any;
 };
1.2.4

2 months ago

1.2.3

2 months ago

1.2.2

4 months ago

1.2.0

7 months ago

1.2.1

7 months ago

1.1.9

8 months ago

1.1.8

8 months ago

1.1.7

8 months ago

1.1.6

8 months ago

1.1.4

8 months ago

1.1.3

8 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago