npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hanmotec/aoss-service-api

v0.0.6

Published

AOSS-服务端API接口集成

Readme

AOSS Service API

AOSS Service API是用于第三方系统和Aoss Service交互的类库,当前提供同步各类数据的接口。

安装

npm i -D  @hanmotec/aoss-service-api  

使用方法

import SyncContext from "@hanmotec/aoss-service-api";

const initializeAossSyncTasks = () => {
    let syncCtx = SyncContext.initialize("your-app-api-key", "your-security-key", "http://aoss-service")
}

定时任务管理器

CronTasks 定时任务管理可以调度管理当前的定时任务,按照预定的间隔执行同步任务

addTask

addTask 增加一个同步任务并实现定时调用

  • 参数:
    • service (BaseSynService): 同步数据的服务类
    • cronTime (string): cron调度规则,同linux的crontab
    • onComplete (any): 任务执行完毕的回调函数
//增加同步租户任务,0,5,10是5分钟的整数倍的时候执行任务
cronTasks.addTask(new SynTenantService(beanFactory.getInstance(Types.TenantDAO.name)), '* */5 * * * * *');

租户同步服务

用于实现同步租户的数据,使用的时候仅仅需要注入同步租户的DAO的实现类即可。

用户同步服务

用于实现同步用户数据,使用的时候仅仅需要注入同步用户的DAO的实现类即可。

数据字典同步服务

用于实现同步数据字典数据,多个数据字典同步需要依次注入每个数据字典的同步DAO实现类。

数据同步DAO接口

SyncDataDAO 接口定义了与数据库同步数据的方法,包括更新、创建和获取最新时间戳的数据条目。需要在项目中实现这个接口。

syncUpdate

更新现有数据条目,如果更新成功过返回1,如果当前数据库中没有这个条目,返回0。

  • 参数:
    • conn (DBConnection): 数据库连接对象。
    • data (any): 要更新的数据。
  • 返回值:
    • Promise<number>: 一个返回更新行数的 Promise。
createNew

createNew在数据库中新增一个条目

  • 参数:
    • conn (DBConnection): 数据库连接对象。
    • data (any): 要插入的数据。
  • 返回值:
    • Promise<void>: 一个在数据插入完成时解析的 Promise。
getLatestTimestamp

getLatestTimestamp获取目标数据集中的最新时间戳,用于同步这个时间戳以后的变更数据。

  • 参数:
    • conn (DBConnection): 数据库连接对象。
  • 返回值:
    • Promise<Date>: 返回数据集最新时间戳的 Promise。

示例代码

下面的示例代码为同步租户


export default class TenantDAOImpl extends BaseDAO implements SyncDataDAO {

    
    async createNew(conn: DBConnection, item: Tenant): Promise<void> {
        await conn.executeUpdate(SQL_INSERT, [item.code, item.name, item.abbr, item.status,
            item.latestUpdated]);
    }


    syncUpdate(conn: DBConnection, item: Tenant): Promise<number> {
        return conn.executeUpdate(SQL_SYNC_UPDATE, [item.code, item.name, item.abbr, item.status,
            item.latestUpdated]);
    }

    async getLatestTimestamp(conn: DBConnection): Promise<Date> {
        let result: any = await conn.find(SQL_GET_LATEST_TS);
        return result?.ts;
    }

}