This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from FernandVEYRIER/feat/package
feat: ubiquibot configuration package
- Loading branch information
Showing
23 changed files
with
6,829 additions
and
6,816 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
price-multiplier: 1.5 | ||
command-settings: | ||
- name: start | ||
enabled: false | ||
# newContributorGreeting: | ||
# enabled: true | ||
# header: "Thank you for contributing to UbiquiBot! Please be sure to set your wallet address before completing your first bounty so that the automatic payout upon task completion will work for you." | ||
# helpMenu: true | ||
# footer: "###### Also please star this repository and [@ubiquity/devpool-directory](https://github.com/ubiquity/devpool-directory/) to show your support. It helps a lot!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: publish-package | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
with: | ||
release-type: node | ||
package-name: @ubiquibot/configuration | ||
default-branch: main | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.10.0' | ||
registry-url: https://registry.npmjs.org/ | ||
- run: | | ||
yarn install --immutable --immutable-cache --check-cache | ||
yarn pack | ||
yarn publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,6 @@ node_modules | |
.pnp.cjs | ||
.pnp.loader.mjs | ||
static/dist | ||
.env | ||
.env | ||
|
||
*.tgz |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
# `@ubiquity/ts-template` | ||
# `@ubiquibot/configuration` | ||
|
||
This template repository includes support for the following: | ||
|
||
- TypeScript | ||
- Environment Variables | ||
- Conventional Commits | ||
- Automatic deployment to Cloudflare Pages | ||
Helpers to parse and merge configuration files for Ubiquibot. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./types"; | ||
export * from "./utils"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { ObjectOptions, Static, StaticDecode, StringOptions, TProperties, Type as T } from "@sinclair/typebox"; | ||
import ms from "ms"; | ||
import { LogLevel } from "ubiquibot-logger/pretty-logs"; | ||
|
||
import { ajv } from "../utils/ajv"; | ||
import { validHTMLElements } from "./valid-html-elements"; | ||
|
||
const promotionComment = | ||
"###### If you enjoy the DevPool experience, please follow [Ubiquity on GitHub](https://github.com/ubiquity) and star [this repo](https://github.com/ubiquity/devpool-directory) to show your support. It helps a lot!"; | ||
const defaultGreetingHeader = | ||
"Thank you for contributing! Please be sure to set your wallet address before completing your first task so that you can collect your reward."; | ||
|
||
const htmlEntities = validHTMLElements.map((value) => T.Literal(value)); | ||
|
||
const allHtmlElementsSetToZero = validHTMLElements.reduce( | ||
(accumulator, current) => { | ||
accumulator[current] = 0; | ||
return accumulator; | ||
}, | ||
{} as Record<keyof HTMLElementTagNameMap, number> | ||
); | ||
|
||
const allCommands = ["start", "stop", "help", "query", "ask", "multiplier", "labels", "authorize", "wallet"] as const; | ||
|
||
const defaultTimeLabels = ["Time: <1 Hour", "Time: <2 Hours", "Time: <4 Hours", "Time: <1 Day", "Time: <1 Week"]; | ||
|
||
const defaultPriorityLabels = ["Priority: 1 (Normal)", "Priority: 2 (Medium)", "Priority: 3 (High)", "Priority: 4 (Urgent)", "Priority: 5 (Emergency)"]; | ||
|
||
function strictObject<T extends TProperties>(obj: T, options?: ObjectOptions) { | ||
return T.Object<T>(obj, { additionalProperties: false, default: {}, ...options }); | ||
} | ||
|
||
export function stringDuration(options?: StringOptions) { | ||
return T.Transform(T.String(options)) | ||
.Decode((value) => { | ||
const decoded = ms(value); | ||
if (decoded === undefined || isNaN(decoded)) { | ||
throw new Error(`Invalid duration string: ${value}`); | ||
} | ||
return ms(value); | ||
}) | ||
.Encode((value) => ms(value)); | ||
} | ||
|
||
const envConfigSchema = T.Object({ | ||
WEBHOOK_PROXY_URL: T.Optional(T.String({ format: "uri" })), // optional for production | ||
LOG_LEVEL: T.Enum(LogLevel, { default: LogLevel.DEBUG }), | ||
LOG_RETRY_LIMIT: T.Number({ default: 8 }), | ||
SUPABASE_URL: T.String({ format: "uri" }), | ||
SUPABASE_KEY: T.String(), | ||
PRIVATE_KEY: T.String(), | ||
APP_ID: T.Number(), | ||
}); | ||
|
||
export const validateEnvConfig = ajv.compile(envConfigSchema); | ||
export type EnvConfig = Static<typeof envConfigSchema>; | ||
|
||
const botConfigSchema = strictObject( | ||
{ | ||
keys: strictObject({ | ||
evmPrivateEncrypted: T.Optional(T.String()), | ||
openAi: T.Optional(T.String()), | ||
}), | ||
features: strictObject({ | ||
assistivePricing: T.Boolean({ default: false }), | ||
defaultLabels: T.Array(T.String(), { default: [] }), | ||
newContributorGreeting: strictObject({ | ||
enabled: T.Boolean({ default: false }), | ||
header: T.String({ default: defaultGreetingHeader }), | ||
displayHelpMenu: T.Boolean({ default: true }), | ||
footer: T.String({ default: promotionComment }), | ||
}), | ||
publicAccessControl: strictObject({ | ||
setLabel: T.Boolean({ default: true }), | ||
fundExternalClosedIssue: T.Boolean({ default: true }), | ||
}), | ||
isNftRewardEnabled: T.Boolean({ default: false }), | ||
}), | ||
|
||
timers: strictObject({ | ||
reviewDelayTolerance: stringDuration({ default: "1 day" }), | ||
taskStaleTimeoutDuration: stringDuration({ default: "4 weeks" }), | ||
taskFollowUpDuration: stringDuration({ default: "0.5 weeks" }), | ||
taskDisqualifyDuration: stringDuration({ default: "1 week" }), | ||
}), | ||
payments: strictObject({ | ||
maxPermitPrice: T.Number({ default: Number.MAX_SAFE_INTEGER }), | ||
evmNetworkId: T.Number({ default: 1 }), | ||
basePriceMultiplier: T.Number({ default: 1 }), | ||
issueCreatorMultiplier: T.Number({ default: 1 }), | ||
}), | ||
disabledCommands: T.Array(T.String(), { default: allCommands }), | ||
incentives: strictObject({ | ||
comment: strictObject({ | ||
elements: T.Record(T.Union(htmlEntities), T.Number({ default: 0 }), { default: allHtmlElementsSetToZero }), | ||
totals: strictObject({ | ||
character: T.Number({ default: 0, minimum: 0 }), | ||
word: T.Number({ default: 0, minimum: 0 }), | ||
sentence: T.Number({ default: 0, minimum: 0 }), | ||
paragraph: T.Number({ default: 0, minimum: 0 }), | ||
comment: T.Number({ default: 0, minimum: 0 }), | ||
}), | ||
}), | ||
}), | ||
labels: strictObject({ | ||
time: T.Array(T.String(), { default: defaultTimeLabels }), | ||
priority: T.Array(T.String(), { default: defaultPriorityLabels }), | ||
}), | ||
miscellaneous: strictObject({ | ||
maxConcurrentTasks: T.Number({ default: Number.MAX_SAFE_INTEGER }), | ||
promotionComment: T.String({ default: promotionComment }), | ||
registerWalletWithVerification: T.Boolean({ default: false }), | ||
openAiTokenLimit: T.Number({ default: 100000 }), | ||
}), | ||
}, | ||
{ default: undefined } // top level object can't have default! | ||
); | ||
export const validateBotConfig = ajv.compile(botConfigSchema); | ||
|
||
export type BotConfig = StaticDecode<typeof botConfigSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./configuration-types"; | ||
export * from "./valid-html-elements"; |
Oops, something went wrong.
2333281
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pavlovcik Valid configuration.
Warning! Unnecessary properties:
.price-multiplier
.command-settings