Skip to content

Meniole/daemon-pricing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@ubiquity-os/daemon-pricing

Helps settings prices and adds label to the issues accordingly.

Technical Architecture

Overview

The daemon-pricing service is a Cloudflare Workers-based application that automates pricing-related operations for GitHub issues. It processes webhook events to manage pricing labels and configurations across Ubiquity repositories.

Core Components

  1. Plugin System

    • Built on @ubiquity-os/plugin-sdk for standardized plugin architecture
    • Handles GitHub webhook events using @octokit/webhooks
    • Supports environment-specific configurations through envSchema
    • Implements error handling with automatic issue commenting
  2. Label Management System

    • Automated pricing label creation and management
    • Supports time-based and priority-based labeling
    • Implements hierarchical label organization
    • Handles parent-child issue relationships
    • Automatic price calculation based on time and priority labels
  3. Permission System

    • Fine-grained access control for label management
    • Collaborator-specific label permissions
    • Public access control configuration
    • Repository-specific exclusion rules
  4. GitHub Integration

    • OAuth App-based authentication
    • Webhook event processing
    • Issue and label manipulation through GitHub API
    • Support for repository-specific configurations

Technology Stack

  • Runtime: Cloudflare Workers (Serverless)
  • Language: TypeScript
  • Key Dependencies:
    • @octokit/rest: GitHub API client
    • @sinclair/typebox: Runtime type checking
    • decimal.js: Precise numerical calculations
    • hono: Lightweight web framework

Development Tools

  • Testing: Jest with comprehensive test suite
  • Linting: ESLint with TypeScript support
  • Formatting: Prettier
  • Spell Checking: CSpell
  • Git Hooks: Husky for pre-commit checks
  • Local Development: Wrangler for Workers simulation

Usage

Example of valid configuration:

- plugin: https://ubiquity-os-daemon-pricing.ubq.fi
  with:
    labels:
      time:
        - name: "Time: <1 Hour"
        - name: "Time: <2 Hours"
        - name: "Time: <4 Hours"
        - name: "Time: <1 Day"
        - name: "Time: <1 Week"
      priority:
        - name: "Priority: 1 (Normal)"
        - name: "Priority: 2 (Medium)"
        - name: "Priority: 3 (High)"
        - name: "Priority: 4 (Urgent)"
        - name: "Priority: 5 (Emergency)"
    basePriceMultiplier: 1
    shouldFundContributorClosedIssue: false
    globalConfigUpdate:
      excludeRepos: ["devpool-directory", "devpool-directory-private"]

Running locally

Supabase

Supabase can be started through the CLI running

supabase start

Worker

Start the Worker by running

bun run worker

Make requests

To trigger the worker, POST requests should be made to http://localhost:4000 with a Content-Type: application/json header and a body looking like

{
  "stateId": "",
  "eventName": "",
  "eventPayload": "",
  "settings": "",
  "ref": ""
}

For convenience, you can find an .http file with a valid request here.

Testing

Jest

To start Jest tests, run

bun run test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 94.9%
  • JavaScript 3.7%
  • CSS 1.1%
  • HTML 0.3%