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

kaoqin-services

v2.0.4

Published

考勤系统服务库 (重构版 - 支持n8n webhook)

Downloads

16

Readme

kaoqin-services

考勤系统服务库,提供考勤相关服务功能。重构版支持 n8n webhook 接口。

特性

  • ✅ 支持 n8n webhook 接口调用
  • ✅ 灵活的考勤记录处理和转换
  • ✅ 多种通知方式(微信、Ntfy)
  • ✅ 节假日判断功能
  • ✅ 状态管理和时间控制
  • ✅ 出差、迟到等特殊状态处理

安装

npm install kaoqin-services

或者使用yarn:

yarn add kaoqin-services

版本说明

v2.0.0 (重构版)

  • 🔄 重构考勤记录获取接口,支持 n8n webhook
  • 🆕 新增数据格式转换功能
  • 🆕 支持出差、迟到等特殊考勤状态
  • 🆕 增强调试日志输出
  • ⚡ 简化用户初始化流程

v1.x.x (传统版)

  • 基于原有 API 接口的考勤服务

核心服务

KaoqinService

考勤服务,处理用户初始化、打卡记录查询和通知发送

ApiService

API服务,处理HTTP请求和响应

HolidayService

节假日服务,判断日期是否为工作日

NotificationServices

通知服务集合,包含多种通知方式

使用示例

const { 
  KaoqinService, 
  ApiService, 
  HolidayService, 
  NotificationServices 
} = require('kaoqin-services');
const { StateManager } = require('kaoqin-utils');

// 配置管理器
class ConfigManager {
  constructor() {
    this.config = {
      USERNAME: '您的用户名',
      API_BASE_URL: 'https://appsy.jbysoft.com',
      NTFY: {
        serverUrl: "https://ntfy.example.com",
        topic: "test",
        enabled: true
      },
      REMINDER: {
        morningStart: { hour: 6, minute: 0 },
        morningEnd: { hour: 10, minute: 0 },
        eveningStart: { hour: 18, minute: 0 },
        eveningEnd: { hour: 23, minute: 59 }
      }
    };
  }
  
  get(key) {
    return key.split('.').reduce((obj, k) => obj && obj[k], this.config);
  }
}

// 初始化服务
const configManager = new ConfigManager();
const stateManager = new StateManager('./kaoqin-state.json');
const apiService = new ApiService(configManager);

// 创建通知服务
const { CompositeNotificationService, NtfyService, WeChatService } = NotificationServices;
const notificationService = new CompositeNotificationService([
  new NtfyService(configManager),
  new WeChatService(configManager)
]);

// 创建假日服务
const holidayService = new HolidayService({
  holidayFilePath: './holiday.json',
  stateManager
});

// 创建考勤服务
const kaoqinService = new KaoqinService({
  configManager,
  stateManager,
  apiService,
  notificationService,
  holidayService
});

async function main() {
  // 初始化服务
  const userInfo = await kaoqinService.initialize();
  if (!userInfo) {
    console.error('用户初始化失败');
    return;
  }

  // 处理考勤记录
  await kaoqinService.processKaoqinRecords();
}

main().catch(console.error);

配置说明

n8n Webhook 配置

服务会调用 n8n webhook 接口获取考勤数据:

const webhookConfig = {
  url: 'https://n8n.201807.xyz/webhook/dkjl',
  timeout: 10000,
  auth: 'Basic <base64编码的认证信息>'
};

支持的考勤状态

  • 出差: 自动根据时间判断上班/下班
  • 迟到: 识别为上班打卡
  • 早退: 识别为下班打卡
  • 其他状态: 按默认规则处理

API 文档

KaoqinService

initialize(username?)

初始化考勤服务

  • username: 可选,用户名

queryKaoqinRecords(date)

查询指定日期的考勤记录

  • date: 查询日期

processKaoqinRecords(date?)

处理考勤记录并发送通知

  • date: 可选,处理日期

testNtfyNotification()

测试 Ntfy 通知功能

resetNotificationStatus()

重置通知状态

变更日志

v2.0.0

  • 重构接口调用方式,支持 n8n webhook
  • 新增考勤状态智能识别
  • 优化数据转换逻辑
  • 增强错误处理和日志输出

许可证

ISC