├── .dockerignore ├── .github └── FUNDING.yml ├── .gitignore ├── sync-and-run.sh ├── .env.example ├── docs └── assets │ └── layout-structure-1.png ├── Dockerfile ├── src ├── models │ ├── Experiment.ts │ ├── File.ts │ └── Build.ts ├── cli │ └── experiments.ts ├── util │ └── ast │ │ └── ASTVisitor.ts ├── experimentParser │ ├── ExperimentParser.ts │ └── ExperimentASTVisitor.ts ├── Database.ts ├── Constants.ts ├── downloader │ ├── PromiseQueue.ts │ ├── Worker.ts │ └── BuildDownloader.ts └── index.ts ├── STRUCTURE.md ├── README.md ├── package.json ├── prisma └── schema.prisma ├── pnpm-lock.yaml └── LICENSE /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: MeguminSama 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | out.json 3 | .env 4 | blobs 5 | blobs-sep 6 | -------------------------------------------------------------------------------- /sync-and-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | npx prisma db push 4 | npm run start 5 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # Postgres DB connection string 2 | DATABASE_URL="postgresql://username:password@127.0.0.1:5432/database?schema=dev" 3 | -------------------------------------------------------------------------------- /docs/assets/layout-structure-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Discord-Build-Logger/Runtime-Legacy/HEAD/docs/assets/layout-structure-1.png -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18 2 | 3 | WORKDIR /usr/src/runtime 4 | COPY package*.json ./ 5 | COPY prisma ./prisma/ 6 | RUN npm install 7 | 8 | RUN npx prisma generate 9 | 10 | COPY . . 11 | 12 | EXPOSE 8080 13 | 14 | # need to run `npx prisma db push` after database service is running. 15 | CMD ["./sync-and-run.sh"] 16 | ENTRYPOINT ["/bin/bash"] 17 | -------------------------------------------------------------------------------- /src/models/Experiment.ts: -------------------------------------------------------------------------------- 1 | export enum ExperimentKind { 2 | GUILD = "guild", 3 | USER = "user", 4 | } 5 | 6 | export interface Experiment { 7 | kind: ExperimentKind; 8 | id: string; 9 | label: string; 10 | /** I think this is always set, but just want to be safe... */ 11 | defaultConfig?: Record; 12 | treatments: ExperimentTreatment[]; 13 | } 14 | 15 | export interface ExperimentTreatment { 16 | id: number; 17 | label: string; 18 | config: Record; 19 | } 20 | 21 | export default Experiment; 22 | -------------------------------------------------------------------------------- /src/cli/experiments.ts: -------------------------------------------------------------------------------- 1 | import fs from "node:fs"; 2 | import ExperimentParser from "../experimentParser/ExperimentParser"; 3 | 4 | const files = process.argv.slice(2); 5 | 6 | if (files.length === 0) { 7 | console.error("Usage: esno src/cli/experiments.ts FILE..."); 8 | process.exit(1); 9 | } 10 | 11 | const parser = new ExperimentParser(); 12 | 13 | for (const file of files) { 14 | const script = fs.readFileSync(file, "utf8"); 15 | parser.parseScript(script); 16 | } 17 | 18 | console.log(JSON.stringify(parser.experiments, null, 2)); 19 | -------------------------------------------------------------------------------- /STRUCTURE.md: -------------------------------------------------------------------------------- 1 | # Project Structure 2 | 3 | This document attempts to outline how the runtime works, and how data is linked. 4 | 5 | As a brief overview, a `Build` will contain a list of `File`s which individually contain a lsit of `Experiment`s. 6 | 7 | ![](docs/assets/layout-structure-1.png) 8 | 9 | This somewhat odd layout allows for better de-duplication. Any builds that share identical files, will also share identical experiments. 10 | 11 | Unsure whether to give experiments a unique ID / their own db table so that we can do experiment tracking as experiments get modified? 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Runtime 2 | 3 | The Discord Build Logger Runtime Process 4 | 5 | ## Information 6 | 7 | This is a heavily WIP open-source rewrite of the [Discord Build Logger](https://discord.sale/). 8 | Do not expect it to work yet. 9 | 10 | ## Following Updates, Contributing, Etc. 11 | 12 | Join our [Discord](https://discord.gg/r5bmSXBEPC) to follow along with development! 13 | 14 | ## Setting up the database 15 | 16 | ### Generating Types 17 | 18 | ```shell 19 | pnpm prisma generate 20 | ``` 21 | 22 | ### Pushing to database 23 | 24 | ```shell 25 | pnpm prisma db push 26 | ``` 27 | -------------------------------------------------------------------------------- /src/util/ast/ASTVisitor.ts: -------------------------------------------------------------------------------- 1 | import * as acorn from "acorn"; 2 | import * as walk from "acorn-walk"; 3 | import { RecursiveWalkerFn, SimpleWalkerFn } from "acorn-walk"; 4 | 5 | export abstract class RecursiveASTVisitor { 6 | [key: string]: RecursiveWalkerFn; 7 | 8 | walk(node: acorn.Node, state: TState) { 9 | walk.recursive(node, state, this); 10 | } 11 | } 12 | 13 | export abstract class ASTVisitor { 14 | [key: string]: SimpleWalkerFn; 15 | 16 | walk(node: acorn.Node, state: TState) { 17 | walk.simple(node, this, undefined, state); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dsale/runtime", 3 | "license": "GPL-3.0", 4 | "type": "module", 5 | "author": { 6 | "name": "Rie Takahashi", 7 | "email": "megumin@megu.dev", 8 | "url": "https://github.com/MeguminSama" 9 | }, 10 | "funding": { 11 | "type": "github", 12 | "url": "https://github.com/sponsors/MeguminSama" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/discord-build-logger/runtime" 17 | }, 18 | "scripts": { 19 | "start": "tsx src/index.ts --allowSyntheticDefaultImports=true --esModuleInterop=true", 20 | "build": "tsc src/index.ts" 21 | }, 22 | "devDependencies": { 23 | "@types/amqplib": "^0.10.1", 24 | "@types/node": "^18.14.6", 25 | "prisma": "^4.11.0", 26 | "typescript": "^4.9.5" 27 | }, 28 | "dependencies": { 29 | "@prisma/client": "^4.11.0", 30 | "acorn": "^8.8.2", 31 | "acorn-walk": "^8.2.0", 32 | "amqplib": "^0.10.3", 33 | "node-worker-threads-pool": "^1.5.1", 34 | "tsx": "^3.12.7" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | generator client { 2 | provider = "prisma-client-js" 3 | } 4 | 5 | datasource db { 6 | provider = "postgresql" 7 | url = env("DATABASE_URL") 8 | } 9 | 10 | enum ReleaseChannel { 11 | CANARY 12 | PTB 13 | STABLE 14 | STAGING 15 | } 16 | 17 | enum BuildEnv { 18 | PRODUCTION 19 | DEVELOPMENT 20 | STAGING 21 | } 22 | 23 | model Build { 24 | id String @id 25 | // Build date 26 | date DateTime 27 | 28 | releaseChannel ReleaseChannel 29 | buildEnv BuildEnv 30 | 31 | // JS/Stylesheets 32 | files File[] 33 | // Misc assets (images, videos, etc.) 34 | assets String[] 35 | 36 | globalEnv Json 37 | } 38 | 39 | model File { 40 | // filename 41 | name String @id 42 | // list of builds that use this file 43 | builds Build[] 44 | // list of tags that this file has 45 | tags String[] 46 | // date the file was last modified 47 | date DateTime 48 | // list of referenced files 49 | referencedFiles String[] 50 | // list of experiments in this file 51 | experiments Json[] // TODO: Should this be it's own model? 52 | } 53 | -------------------------------------------------------------------------------- /src/experimentParser/ExperimentParser.ts: -------------------------------------------------------------------------------- 1 | import * as acorn from "acorn"; 2 | import Experiment from "../models/Experiment"; 3 | import ExperimentASTVisitor from "./ExperimentASTVisitor"; 4 | 5 | const defaultAcornOptions: acorn.Options = { 6 | ecmaVersion: "latest", 7 | }; 8 | 9 | class ExperimentParser { 10 | /** 11 | * List of all found experiments. 12 | */ 13 | experiments: Experiment[]; 14 | 15 | /** 16 | * Default options to pass to acorn AST parser. 17 | */ 18 | acornOptions: acorn.Options; 19 | 20 | constructor() { 21 | this.experiments = []; 22 | this.acornOptions = defaultAcornOptions; 23 | } 24 | 25 | /** 26 | * Parses a script and adds all found experiments to ExperimentParser.experiments. 27 | * @param script The script to parse, in form of JavaScript code. 28 | */ 29 | parseScript(script: string) { 30 | const ast = acorn.parse(script, this.acornOptions); 31 | new ExperimentASTVisitor().walk(ast, [script, this]); 32 | } 33 | 34 | addExperiment(experiment: Experiment) { 35 | const existing = this.experiments.find((exp) => exp.id === experiment.id); 36 | if (existing) { 37 | return; 38 | } 39 | 40 | this.experiments.push(experiment); 41 | } 42 | } 43 | 44 | export default ExperimentParser; 45 | -------------------------------------------------------------------------------- /src/Database.ts: -------------------------------------------------------------------------------- 1 | import { Prisma, PrismaClient } from "@prisma/client"; 2 | import Build, { BuildEnv, ReleaseChannel } from "./models/Build"; 3 | 4 | /** 5 | * Main database singleton. 6 | */ 7 | export const database = new PrismaClient(); 8 | 9 | export async function getBuildById(id: string) { 10 | return database.build.findUnique({ 11 | where: { 12 | id, 13 | }, 14 | }); 15 | } 16 | 17 | // make a function for creating a build and its files 18 | export async function createBuild(build: Build) { 19 | return database.build.create({ 20 | data: { 21 | id: build.id, 22 | releaseChannel: ReleaseChannel[build.releaseChannel], 23 | buildEnv: BuildEnv[build.buildEnv], 24 | date: build.date, 25 | assets: build.assets, 26 | globalEnv: build.globalEnv, 27 | files: { 28 | connectOrCreate: build.files.map((file) => ({ 29 | where: { name: file.fileName }, 30 | create: { 31 | name: file.fileName, 32 | tags: file.tags, 33 | date: file.metadata.lastModified 34 | ? new Date(file.metadata.lastModified) 35 | : new Date(), 36 | referencedFiles: file.referencedFiles, 37 | experiments: file.experiments as unknown as Prisma.JsonArray, 38 | }, 39 | })), 40 | }, 41 | }, 42 | }); 43 | } 44 | -------------------------------------------------------------------------------- /src/Constants.ts: -------------------------------------------------------------------------------- 1 | import path from "node:path"; 2 | import { ReleaseChannel } from "./models/Build"; 3 | 4 | export const BLOBS_DIR = path.join(process.cwd(), "blobs"); 5 | 6 | export const Domains = { 7 | [ReleaseChannel.STABLE]: "https://discord.com", 8 | [ReleaseChannel.PTB]: "https://ptb.discord.com", 9 | [ReleaseChannel.CANARY]: "https://canary.discord.com", 10 | [ReleaseChannel.STAGING]: "https://staging.discord.co", 11 | }; 12 | 13 | export const Paths = { 14 | assets: "/assets", 15 | app: "/app", 16 | developers: "/developers", 17 | }; 18 | 19 | export const Regexes = { 20 | htmlScripts: /(?:; 28 | } 29 | 30 | export default Build; 31 | 32 | /** Release Channels is the name discord uses for the "Branch" of a build. */ 33 | export enum ReleaseChannel { 34 | /* Public Release Channels */ 35 | CANARY = "CANARY", 36 | PTB = "PTB", 37 | STABLE = "STABLE", 38 | /** This is usually set for BuildEnv.DEVELOPMENT and BuildEnv.STAGING */ 39 | STAGING = "STAGING", 40 | } 41 | 42 | /** Build env is the environment it's running in. Canary/PTB/Stable are all Production. */ 43 | export enum BuildEnv { 44 | /** Production Discord, aka *.discord.com */ 45 | PRODUCTION = "PRODUCTION", 46 | /** Development Discord, aka localhost */ 47 | DEVELOPMENT = "DEVELOPMENT", 48 | /** Staging Discord, aka *.discord.co */ 49 | STAGING = "STAGING", 50 | } 51 | 52 | export interface BuildOverride { 53 | /** Build ID or Branch of the override */ 54 | id: string; 55 | /** 56 | * If the type is "id", it uses the commit hash. 57 | * If "branch", it uses the latest build of a GitHub branch. 58 | */ 59 | type: "id" | "branch"; 60 | } 61 | 62 | export interface BuildOverrideMeta { 63 | /** Release channel that the override targets. */ 64 | releaseChannel: `${ReleaseChannel}` | null; 65 | expiresAt: string; 66 | validForUserIds: string[]; 67 | /** TODO: I believe this is referring to the ReleaseChannel. */ 68 | allowedVersions?: string[]; 69 | /** Overrides can have different targets depending on platform. */ 70 | targetBuildOverride: { 71 | discord_web?: BuildOverride; 72 | discord_ios?: BuildOverride; 73 | discord_android?: BuildOverride; 74 | discord_marketing?: BuildOverride; 75 | }; 76 | } 77 | -------------------------------------------------------------------------------- /src/downloader/PromiseQueue.ts: -------------------------------------------------------------------------------- 1 | interface IPromiseQueueOpts { 2 | concurrency: number; 3 | } 4 | 5 | type PromiseThunk = () => Promise; 6 | 7 | class PromiseQueue { 8 | private queue: Array<() => any>; 9 | private pauseQueue: boolean; 10 | private ongoingCount: number; 11 | public readonly concurrency: number; 12 | private emptyPromiseResolve: ((value?: void) => void) | null; 13 | private anyPromiseResolve: ((value?: void) => void) | null; 14 | 15 | constructor(opts: IPromiseQueueOpts) { 16 | this.queue = []; 17 | this.pauseQueue = false; 18 | opts = Object.assign( 19 | { 20 | concurrency: 1, 21 | }, 22 | opts 23 | ); 24 | 25 | if (opts.concurrency < 1) { 26 | throw new TypeError( 27 | "Expected `concurrency` to be an integer which is bigger than 0" 28 | ); 29 | } 30 | 31 | this.ongoingCount = 0; 32 | this.concurrency = opts.concurrency; 33 | } 34 | 35 | public pause() { 36 | this.pauseQueue = true; 37 | } 38 | 39 | public resume() { 40 | this.pauseQueue = false; 41 | this.next(); 42 | } 43 | 44 | public add(fn: PromiseThunk | PromiseThunk[]): PromiseQueue | TypeError { 45 | if (Array.isArray(fn)) { 46 | if (fn.length > 1) { 47 | const res = this.add(fn.shift()!); 48 | if (!(res instanceof TypeError)) { 49 | return this.add(fn); 50 | } 51 | } 52 | return this.add(fn[0]); 53 | } else { 54 | new Promise((resolve, reject) => { 55 | const run = () => { 56 | this.ongoingCount++; 57 | (fn as () => Promise)().then( 58 | (val: any) => { 59 | resolve(val); 60 | this.ongoingCount--; 61 | this.next(); 62 | }, 63 | (err: Error) => { 64 | reject(err); 65 | this.ongoingCount--; 66 | this.next(); 67 | } 68 | ); 69 | }; 70 | 71 | if (this.ongoingCount < this.concurrency && !this.pauseQueue) { 72 | run(); 73 | } else { 74 | this.queue.push(run); 75 | } 76 | }); 77 | return this; 78 | } 79 | } 80 | 81 | // Promises which are not ready yet to run in the queue. 82 | get waitingCount() { 83 | return this.queue.length; 84 | } 85 | 86 | public awaitAll(): Promise { 87 | return new Promise((resolve) => { 88 | this.emptyPromiseResolve = resolve; 89 | }); 90 | } 91 | 92 | public awaitAny(): Promise { 93 | return new Promise((resolve) => { 94 | this.anyPromiseResolve = resolve; 95 | }); 96 | } 97 | 98 | private resolveEmpty: () => void = () => undefined; 99 | 100 | private next() { 101 | if (this.ongoingCount >= this.concurrency || this.pauseQueue) { 102 | return; 103 | } 104 | 105 | if (this.anyPromiseResolve) { 106 | this.anyPromiseResolve(); 107 | this.anyPromiseResolve = null; 108 | } 109 | 110 | if (this.ongoingCount === 0 && this.emptyPromiseResolve) { 111 | this.emptyPromiseResolve(); 112 | this.emptyPromiseResolve = null; 113 | } 114 | 115 | if (this.queue.length > 0) { 116 | const firstQueueTask = this.queue.shift(); 117 | if (firstQueueTask) { 118 | firstQueueTask(); 119 | } 120 | } else { 121 | this.resolveEmpty(); 122 | } 123 | } 124 | } 125 | 126 | export default PromiseQueue; 127 | -------------------------------------------------------------------------------- /src/experimentParser/ExperimentASTVisitor.ts: -------------------------------------------------------------------------------- 1 | import { Node } from "acorn"; 2 | import Experiment from "../models/Experiment"; 3 | import { ASTVisitor } from "../util/ast/ASTVisitor"; 4 | import ExperimentParser from "./ExperimentParser"; 5 | 6 | function hasProperty(node: any, name: string) { 7 | if (node.type !== "ObjectExpression") { 8 | return false; 9 | } 10 | 11 | return node.properties.some((prop: any) => { 12 | if (!prop.key) return false; 13 | 14 | if (prop.key.type === "Identifier") { 15 | return prop.key.name === name; 16 | } else if (prop.key.type === "Literal") { 17 | return prop.key.value === name; 18 | } 19 | 20 | return false; 21 | }); 22 | } 23 | 24 | function isEnumExpression(node: any) { 25 | if (node.type !== "MemberExpression") { 26 | return false; 27 | } 28 | 29 | if (node.object.type === "MemberExpression" && !node.computed) { 30 | return isEnumExpression(node.object); 31 | } else if (node.object.type === "Identifier" && !node.computed) { 32 | return node.property.type === "Identifier"; 33 | } 34 | 35 | return false; 36 | } 37 | 38 | /** 39 | * Serializes an AST node to a JS value. 40 | */ 41 | function astToJSValue(script: string, node: any) { 42 | if (node.type === "Literal") { 43 | return node.value; 44 | } else if (node.type === "ObjectExpression") { 45 | const obj: any = {}; 46 | 47 | for (const prop of node.properties) { 48 | if (!prop.key) continue; 49 | 50 | if (prop.key.type === "Identifier") { 51 | obj[prop.key.name] = astToJSValue(script, prop.value); 52 | } else if (prop.key.type === "Literal") { 53 | obj[prop.key.value] = astToJSValue(script, prop.value); 54 | } 55 | } 56 | 57 | return obj; 58 | } else if (node.type === "ArrayExpression") { 59 | return node.elements.map((elem: any) => astToJSValue(script, elem)); 60 | } else if (node.type === "UnaryExpression" && node.operator === "!") { 61 | const value = astToJSValue(script, node.argument); 62 | if (typeof value === "number") { 63 | if (value === 0) { 64 | return true; 65 | } else if (value === 1) { 66 | return false; 67 | } 68 | } 69 | } else if (isEnumExpression(node)) { 70 | return node.property.name; 71 | } 72 | 73 | // if we can't serialize it, let's return raw JS code as string otherwise for now 74 | if (node.start === undefined || node.end === undefined) { 75 | return undefined; 76 | } 77 | 78 | return script.substring(node.start, node.end); 79 | } 80 | 81 | const experimentProperties = ["kind", "id", "label"]; 82 | 83 | function isExperiment(node: any) { 84 | if (node.type !== "ObjectExpression") { 85 | return false; 86 | } 87 | 88 | return experimentProperties.every((property) => hasProperty(node, property)); 89 | } 90 | 91 | class ExperimentASTVisitor extends ASTVisitor<[string, ExperimentParser]> { 92 | ObjectExpression(node: Node, state: [string, ExperimentParser]) { 93 | if (!isExperiment(node)) { 94 | return; 95 | } 96 | 97 | const [script, parser] = state; 98 | 99 | const serialized = astToJSValue(script, node); 100 | const experiment: Experiment = { 101 | kind: serialized.kind, 102 | id: serialized.id, 103 | label: serialized.label, 104 | treatments: serialized.treatments || [], 105 | defaultConfig: serialized.defaultConfig, 106 | }; 107 | 108 | parser.addExperiment(experiment); 109 | } 110 | } 111 | 112 | export default ExperimentASTVisitor; 113 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { writeFileSync } from "node:fs"; 2 | import amqplib from "amqplib"; 3 | import { createBuild, getBuildById } from "./Database"; 4 | import BuildDownloader from "./downloader/BuildDownloader"; 5 | import { ReleaseChannel } from "./models/Build"; 6 | 7 | const USE_RABBITMQ = process.env.USE_RABBITMQ ? true : false; 8 | const SAVE_TO_DISK = process.env.SAVE_TO_DISK ? true : false; 9 | 10 | const queue = "tasks"; 11 | let conn: amqplib.Channel; 12 | 13 | const connect = async () => { 14 | try { 15 | const connection = await amqplib.connect( 16 | "amqp://guest:guest@rabbitmq:5672" 17 | ); 18 | console.log("Connected to RabbitMQ"); 19 | const channel = await connection.createChannel(); 20 | await channel.assertQueue(queue); 21 | return channel; 22 | } catch (error) { 23 | console.log(error); 24 | } 25 | }; 26 | 27 | const CHECK_INTERVAL = parseInt(process.env.CHECK_INTERVAL ?? "5000"); 28 | 29 | const active = new Map(); 30 | 31 | async function run(branch: ReleaseChannel, downloader: BuildDownloader) { 32 | const rootInfo = await downloader.getRootInfo().catch(console.error); 33 | if (!rootInfo) return; 34 | 35 | const buildExists = await getBuildById(rootInfo.id).catch(console.error); 36 | if (buildExists) return; 37 | 38 | console.log(`[${branch}]: Starting build ${rootInfo.id}...`); 39 | 40 | const build = await downloader.start(rootInfo).catch(console.error); 41 | if (!build) return; 42 | 43 | const newBuild = await createBuild(build).catch(console.error); 44 | if (newBuild) console.log(`[${branch}]: Finished build ${rootInfo.id}...`); 45 | } 46 | 47 | async function main() { 48 | conn = (await connect()) as amqplib.Channel; 49 | if (!conn) throw new Error("Failed to connect to RabbitMQ"); 50 | 51 | conn.prefetch(1); 52 | 53 | conn.consume(queue, async (msg) => { 54 | if (!msg?.content) return conn.ack(msg!); 55 | const downloader = new BuildDownloader(ReleaseChannel.CANARY, { 56 | saveToDisk: false, 57 | }); 58 | 59 | const id = msg.content.toString(); 60 | if (!/^[a-z0-9]+$/i.test(id)) { 61 | console.log("Invalid build id"); 62 | downloader.threadPool.destroy(); 63 | return conn.ack(msg); 64 | } 65 | 66 | const rootInfo = await downloader.getRootInfo({ id }).catch(console.error); 67 | if (!rootInfo) return conn.ack(msg); 68 | 69 | const buildExists = await getBuildById(rootInfo.id).catch(console.error); 70 | if (buildExists) { 71 | downloader.threadPool.destroy(); 72 | return conn.ack(msg); 73 | } 74 | 75 | console.log(`[CANARY]: Starting build ${rootInfo.id}...`); 76 | 77 | const build = await downloader.start(rootInfo).catch(console.error); 78 | if (!build) { 79 | downloader.threadPool.destroy(); 80 | return conn.ack(msg); 81 | } 82 | 83 | downloader.threadPool.destroy(); 84 | 85 | const newBuild = await createBuild(build).catch(console.error); 86 | if (newBuild) console.log(`[CANARY]: Finished build ${rootInfo.id}...`); 87 | 88 | conn.ack(msg); 89 | }); 90 | } 91 | 92 | // Regular check interval 93 | setInterval(() => { 94 | if (active.get(ReleaseChannel.CANARY)) return; 95 | active.set(ReleaseChannel.CANARY, true); 96 | const downloader = new BuildDownloader(ReleaseChannel.CANARY, { 97 | saveToDisk: SAVE_TO_DISK, 98 | }); 99 | run(ReleaseChannel.CANARY, downloader) 100 | .catch(console.error) 101 | .finally(() => { 102 | active.set(ReleaseChannel.CANARY, false); 103 | downloader.threadPool.destroy(); 104 | }); 105 | }, CHECK_INTERVAL); 106 | 107 | if (USE_RABBITMQ) main(); 108 | -------------------------------------------------------------------------------- /src/downloader/Worker.ts: -------------------------------------------------------------------------------- 1 | import cluster, { parentPort } from "node:worker_threads"; 2 | import { 3 | AppMainChecks, 4 | MainStylesheetChecks, 5 | Regexes, 6 | WebpackChunkChecks, 7 | WebpackVendorChecks, 8 | } from "../Constants"; 9 | import ExperimentParser from "../experimentParser/ExperimentParser"; 10 | import File, { FileTags } from "../models/File"; 11 | import { FileMetadata } from "./BuildDownloader"; 12 | 13 | function handle(file: string, meta: FileMetadata): File | null { 14 | if (!meta.text) return null; 15 | 16 | const { text } = meta; 17 | 18 | if (meta.contentType === "text/css" || file.endsWith(".css")) { 19 | return new File({ 20 | fileName: file, 21 | tags: [FileTags.StyleSheet], 22 | referencedFiles: [], // TODO: Extract asset URLs from CSS 23 | metadata: meta, 24 | }); 25 | } 26 | 27 | if (meta.contentType === "application/javascript") { 28 | const newFile = new File({ 29 | fileName: file, 30 | metadata: meta, 31 | tags: [FileTags.JavaScript], 32 | }); 33 | 34 | const experimentParser = new ExperimentParser(); 35 | experimentParser.parseScript(text); 36 | if (experimentParser.experiments.length) { 37 | newFile.experiments = experimentParser.experiments; 38 | } 39 | 40 | // Detect webpack chunks 41 | if (WebpackChunkChecks.every((check) => text.includes(check))) { 42 | newFile.tags.push(FileTags.WebpackChunk); 43 | } 44 | 45 | // Whether the "type" has been found (webpack loader, vendor, etc.) 46 | let typeFound = false; 47 | 48 | // Detect webpack loader file 49 | if (!typeFound) { 50 | const moduleMap = Regexes.wpLoaderModules.exec(text); 51 | if (moduleMap?.[1]) { 52 | const modules = Object.values( 53 | new Function(`return ${moduleMap[1]} || {}`)() 54 | ); 55 | if (modules.length) { 56 | newFile.referencedFiles.push(...modules.map((m) => `${m}.js`)); 57 | } 58 | newFile.tags.push(FileTags.WebpackChunkLoader); 59 | typeFound = true; 60 | } 61 | } 62 | 63 | // Detect webpack vendor file 64 | if ( 65 | !typeFound && 66 | WebpackVendorChecks.some((check) => text.includes(check)) 67 | ) { 68 | newFile.tags.push(FileTags.WebpackVendor); 69 | typeFound = true; 70 | } 71 | 72 | // Detect webpack style mapper file 73 | if (!typeFound) { 74 | const stylesheetMatches = MainStylesheetChecks.reduce((prev, curr) => { 75 | return prev + (text.includes(curr) ? 1 : 0); 76 | }, 0); 77 | 78 | // Must match at least 5 styles. TODO: Add more checks for better security. 79 | if (stylesheetMatches >= 5) { 80 | newFile.tags.push(FileTags.WebpackStyleMapper); 81 | typeFound = true; 82 | } 83 | } 84 | 85 | // Detect app main file 86 | if (!typeFound && AppMainChecks.every((check) => text.includes(check))) { 87 | newFile.tags.push(FileTags.AppMain); 88 | } 89 | 90 | return newFile; 91 | } 92 | 93 | // If type not found, return a generic File. 94 | return new File({ 95 | fileName: file, 96 | metadata: meta, 97 | }); 98 | } 99 | 100 | if (cluster.isMainThread) { 101 | throw new Error("Not main thread!"); 102 | } 103 | 104 | if (!parentPort) { 105 | throw new Error("No parentPort!"); 106 | } 107 | 108 | parentPort.on("message", async (param) => { 109 | if (typeof param !== "object") return; 110 | if (!param.fileName || !param.fileMeta) return; 111 | // console.log(`[Worker ${cluster.threadId}] => ${param.fileName}`); 112 | 113 | const file = handle(param.fileName, param.fileMeta); 114 | 115 | parentPort!.postMessage(file); 116 | }); 117 | -------------------------------------------------------------------------------- /src/downloader/BuildDownloader.ts: -------------------------------------------------------------------------------- 1 | import { StaticPool } from "node-worker-threads-pool"; 2 | import fs, { writeFileSync } from "node:fs"; 3 | import os from "node:os"; 4 | import path from "node:path"; 5 | import cluster from "node:worker_threads"; 6 | import { BLOBS_DIR, Domains, Paths, Regexes } from "../Constants"; 7 | import Build, { BuildEnv, ReleaseChannel } from "../models/Build"; 8 | import File from "../models/File"; 9 | import PromiseQueue from "./PromiseQueue"; 10 | 11 | /** 12 | * Config for main thread. 13 | */ 14 | interface BuildDownloaderConfig { 15 | /** Will use all available threads by default. */ 16 | maxThreads?: number; 17 | /** 18 | * Save downloaded files to disk. 19 | * @default false 20 | */ 21 | saveToDisk?: boolean; 22 | } 23 | 24 | const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); 25 | 26 | type ThreadPoolFn = (param: { 27 | fileName: string; 28 | fileMeta: FileMetadata; 29 | }) => Promise; 30 | 31 | class BuildDownloader { 32 | private saveToDisk = false; 33 | private maxThreads: number; 34 | private downloadQueue = new PromiseQueue({ concurrency: 32 }); 35 | private downloadRetryAttempts = 5; 36 | private downloadRetryDelay = 2000; 37 | public threadPool: StaticPool; 38 | 39 | private handledFiles: string[] = []; 40 | 41 | private downloadResults: Record = {}; 42 | 43 | constructor( 44 | private releaseChannel: ReleaseChannel, 45 | config?: BuildDownloaderConfig 46 | ) { 47 | if (!cluster.isMainThread) throw new Error("Not main thread!"); 48 | 49 | // Delegate to workers. Maximum of os.cpus().length threads. 50 | this.maxThreads = config?.maxThreads 51 | ? Math.min(os.cpus().length, config.maxThreads) 52 | : os.cpus().length; 53 | 54 | this.threadPool = new StaticPool({ 55 | size: this.maxThreads, 56 | task: path.join(process.cwd(), "src", "downloader", "Worker"), 57 | }); 58 | 59 | if (config?.saveToDisk) { 60 | this.saveToDisk = true; 61 | if (!fs.existsSync(BLOBS_DIR)) fs.mkdirSync(BLOBS_DIR); 62 | } 63 | } 64 | 65 | async start(rootinfo?: { 66 | id: string; 67 | date: string; 68 | files: string[]; 69 | body: string; 70 | }): Promise { 71 | if (!cluster.isMainThread) throw new Error("Not main thread!"); 72 | 73 | const build = new Build(); 74 | 75 | build.releaseChannel = this.releaseChannel; 76 | 77 | switch (this.releaseChannel) { 78 | case ReleaseChannel.CANARY: 79 | case ReleaseChannel.PTB: 80 | case ReleaseChannel.STABLE: 81 | build.buildEnv = BuildEnv.PRODUCTION; 82 | break; 83 | case ReleaseChannel.STAGING: 84 | build.buildEnv = BuildEnv.STAGING; 85 | break; 86 | } 87 | 88 | const { 89 | files: rootFiles, 90 | date, 91 | id, 92 | body: rootBody, 93 | } = rootinfo ?? (await this.getRootInfo()); 94 | 95 | build.id = id; 96 | build.date = new Date(date); 97 | 98 | const globalEnv = Regexes.htmlGlobalEnv.exec(rootBody)?.[1] ?? "{}"; 99 | build.globalEnv = Function( 100 | `return ${globalEnv.replace("Date.now()", '"Date.now()"')}` 101 | )(); 102 | 103 | // console.log(`[Downloader Main] Threads: ${this.maxThreads}`); 104 | // console.log(`[Downloader Main] Root Files: ${rootFiles.length}`); 105 | 106 | for (const file of rootFiles) { 107 | this.downloadQueue.add(() => this.download(file)); 108 | } 109 | 110 | await this.downloadQueue.awaitAll(); 111 | 112 | const files = await this.process(rootFiles); 113 | 114 | build.files = files; 115 | // TODO: Set build.assets 116 | 117 | return build; 118 | } 119 | 120 | async process(files: string[]): Promise { 121 | if (!cluster.isMainThread) throw new Error("Not main thread!"); 122 | // console.log(`[Downloader Main] Processing ${files.length} files...`); 123 | 124 | const results: File[] = []; 125 | 126 | const newFiles: string[] = []; 127 | 128 | const promises = files.map(async (file) => { 129 | const result = await this.threadPool 130 | .createExecutor() 131 | .setTimeout(15_000) 132 | .exec({ 133 | fileName: file, 134 | fileMeta: this.downloadResults[file], 135 | }); 136 | if (result?.referencedFiles?.length) { 137 | this.downloadQueue.add( 138 | result.referencedFiles.map((f) => () => this.download(f)) 139 | ); 140 | newFiles.push(...result.referencedFiles); 141 | } 142 | this.handledFiles.push(file); 143 | results.push(result); 144 | }); 145 | 146 | await Promise.all(promises); 147 | 148 | // @ts-ignore awaitAll doesn't resolve if queue is empty 149 | if (this.downloadQueue.queue.length) await this.downloadQueue.awaitAll(); 150 | 151 | if (newFiles.filter((f) => !this.handledFiles.includes(f)).length) { 152 | const files = await this.process( 153 | newFiles.filter((f) => !this.handledFiles.includes(f)) 154 | ); 155 | results.push(...files); 156 | } 157 | 158 | this.threadPool.destroy(); 159 | 160 | return results; 161 | } 162 | 163 | async getRootInfo(opts?: { id?: string }): Promise<{ 164 | id: string; 165 | date: string; 166 | files: string[]; 167 | body: string; 168 | }> { 169 | if (!cluster.isMainThread) throw new Error("Not main thread!"); 170 | 171 | const files: string[] = []; 172 | 173 | if (opts?.id) { 174 | if (!process.env.INTERNAL_BUILD_GRABBER_URL) 175 | throw new Error("INTERNAL_BUILD_GRABBER_URL not set!"); 176 | if (!process.env.INTERNAL_BUILD_GRABBER_AUTH) 177 | throw new Error("INTERNAL_BUILD_GRABBER_AUTH not set!"); 178 | } 179 | 180 | let url: URL; 181 | 182 | if (opts?.id) { 183 | url = new URL(process.env.INTERNAL_BUILD_GRABBER_URL!); 184 | url.searchParams.set("auth", process.env.INTERNAL_BUILD_GRABBER_AUTH!); 185 | url.searchParams.set("hash", opts.id); 186 | } else { 187 | url = new URL(`${Domains[this.releaseChannel]}${Paths.app}`); 188 | } 189 | 190 | const response = await fetch(url.toString()); 191 | 192 | if (!response.ok) { 193 | throw new Error(`HTTP error! status: ${response.status}`); 194 | } 195 | 196 | const body = await response.text(); 197 | 198 | let asset: any; 199 | while ((asset = Regexes.htmlScripts.exec(body))) { 200 | if (!asset[1]) continue; 201 | files.push(asset[1]); 202 | } 203 | 204 | while ((asset = Regexes.htmlStylesheets.exec(body))) { 205 | if (!asset[1]) continue; 206 | files.push(asset[1]); 207 | } 208 | 209 | const id = response.headers.get("x-build-id") || ""; 210 | const date = response.headers.get("last-modified") || ""; 211 | 212 | return { 213 | id, 214 | date, 215 | files, 216 | body, 217 | }; 218 | } 219 | 220 | async download(file: string, attempt = 0) { 221 | if (!cluster.isMainThread) throw new Error("Not main thread!"); 222 | let response!: Response; 223 | 224 | try { 225 | response = await fetch( 226 | `${Domains[this.releaseChannel]}${Paths.assets}/${file}` 227 | ); 228 | } catch (e) { 229 | if (attempt < this.downloadRetryAttempts) { 230 | console.error( 231 | `[Downloader Main] Caught error (attempt ${attempt}) ${file}` 232 | ); 233 | await sleep(this.downloadRetryDelay); 234 | return this.download(file, attempt + 1); 235 | } 236 | } 237 | 238 | if (!response?.ok) { 239 | if (attempt < this.downloadRetryAttempts) { 240 | console.error( 241 | `[Downloader Main] HTTP status: ${response.status} (attempt ${attempt}) ${file}` 242 | ); 243 | await sleep(this.downloadRetryDelay); 244 | return this.download(file, attempt + 1); 245 | } else { 246 | throw new Error(`HTTP error! status: ${response.status}`); 247 | } 248 | } 249 | 250 | const headers = response.headers; 251 | 252 | this.downloadResults[file] = { 253 | contentType: headers.get("content-type") || null, 254 | lastModified: headers.get("last-modified") || null, 255 | text: null, 256 | }; 257 | 258 | const data = await response.text(); 259 | 260 | if (!data) { 261 | if (attempt < this.downloadRetryAttempts) { 262 | console.error( 263 | `[Downloader] HTTP status: ${response.status} (attempt ${attempt}) ${file}` 264 | ); 265 | await sleep(this.downloadRetryDelay); 266 | return this.download(file, attempt + 1); 267 | } else { 268 | throw new Error(`No data!`); 269 | } 270 | } 271 | 272 | this.downloadResults[file].text = data.replace("\n", ""); 273 | 274 | if (this.saveToDisk) { 275 | // download to "builds" folder 276 | const location = path.join(__dirname, "..", "..", "blobs", file); 277 | writeFileSync(location, data); 278 | } 279 | } 280 | } 281 | 282 | export default BuildDownloader; 283 | 284 | export interface FileMetadata { 285 | contentType: string | null; 286 | lastModified: string | null; 287 | text: string | null; 288 | } 289 | -------------------------------------------------------------------------------- /pnpm-lock.yaml: -------------------------------------------------------------------------------- 1 | lockfileVersion: '6.0' 2 | 3 | dependencies: 4 | '@prisma/client': 5 | specifier: ^4.11.0 6 | version: 4.11.0(prisma@4.11.0) 7 | acorn: 8 | specifier: ^8.8.2 9 | version: 8.8.2 10 | acorn-walk: 11 | specifier: ^8.2.0 12 | version: 8.2.0 13 | amqplib: 14 | specifier: ^0.10.3 15 | version: 0.10.3 16 | node-worker-threads-pool: 17 | specifier: ^1.5.1 18 | version: 1.5.1 19 | tsx: 20 | specifier: ^3.12.7 21 | version: 3.12.7 22 | 23 | devDependencies: 24 | '@types/amqplib': 25 | specifier: ^0.10.1 26 | version: 0.10.1 27 | '@types/node': 28 | specifier: ^18.14.6 29 | version: 18.14.6 30 | prisma: 31 | specifier: ^4.11.0 32 | version: 4.11.0 33 | typescript: 34 | specifier: ^4.9.5 35 | version: 4.9.5 36 | 37 | packages: 38 | 39 | /@acuminous/bitsyntax@0.1.2: 40 | resolution: {integrity: sha512-29lUK80d1muEQqiUsSo+3A0yP6CdspgC95EnKBMi22Xlwt79i/En4Vr67+cXhU+cZjbti3TgGGC5wy1stIywVQ==} 41 | engines: {node: '>=0.8'} 42 | dependencies: 43 | buffer-more-ints: 1.0.0 44 | debug: 4.3.4 45 | safe-buffer: 5.1.2 46 | transitivePeerDependencies: 47 | - supports-color 48 | dev: false 49 | 50 | /@esbuild-kit/cjs-loader@2.4.2: 51 | resolution: {integrity: sha512-BDXFbYOJzT/NBEtp71cvsrGPwGAMGRB/349rwKuoxNSiKjPraNNnlK6MIIabViCjqZugu6j+xeMDlEkWdHHJSg==} 52 | dependencies: 53 | '@esbuild-kit/core-utils': 3.1.0 54 | get-tsconfig: 4.4.0 55 | dev: false 56 | 57 | /@esbuild-kit/core-utils@3.1.0: 58 | resolution: {integrity: sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw==} 59 | dependencies: 60 | esbuild: 0.17.11 61 | source-map-support: 0.5.21 62 | dev: false 63 | 64 | /@esbuild-kit/esm-loader@2.5.5: 65 | resolution: {integrity: sha512-Qwfvj/qoPbClxCRNuac1Du01r9gvNOT+pMYtJDapfB1eoGN1YlJ1BixLyL9WVENRx5RXgNLdfYdx/CuswlGhMw==} 66 | dependencies: 67 | '@esbuild-kit/core-utils': 3.1.0 68 | get-tsconfig: 4.4.0 69 | dev: false 70 | 71 | /@esbuild/android-arm64@0.17.11: 72 | resolution: {integrity: sha512-QnK4d/zhVTuV4/pRM4HUjcsbl43POALU2zvBynmrrqZt9LPcLA3x1fTZPBg2RRguBQnJcnU059yKr+bydkntjg==} 73 | engines: {node: '>=12'} 74 | cpu: [arm64] 75 | os: [android] 76 | requiresBuild: true 77 | dev: false 78 | optional: true 79 | 80 | /@esbuild/android-arm@0.17.11: 81 | resolution: {integrity: sha512-CdyX6sRVh1NzFCsf5vw3kULwlAhfy9wVt8SZlrhQ7eL2qBjGbFhRBWkkAzuZm9IIEOCKJw4DXA6R85g+qc8RDw==} 82 | engines: {node: '>=12'} 83 | cpu: [arm] 84 | os: [android] 85 | requiresBuild: true 86 | dev: false 87 | optional: true 88 | 89 | /@esbuild/android-x64@0.17.11: 90 | resolution: {integrity: sha512-3PL3HKtsDIXGQcSCKtWD/dy+mgc4p2Tvo2qKgKHj9Yf+eniwFnuoQ0OUhlSfAEpKAFzF9N21Nwgnap6zy3L3MQ==} 91 | engines: {node: '>=12'} 92 | cpu: [x64] 93 | os: [android] 94 | requiresBuild: true 95 | dev: false 96 | optional: true 97 | 98 | /@esbuild/darwin-arm64@0.17.11: 99 | resolution: {integrity: sha512-pJ950bNKgzhkGNO3Z9TeHzIFtEyC2GDQL3wxkMApDEghYx5Qers84UTNc1bAxWbRkuJOgmOha5V0WUeh8G+YGw==} 100 | engines: {node: '>=12'} 101 | cpu: [arm64] 102 | os: [darwin] 103 | requiresBuild: true 104 | dev: false 105 | optional: true 106 | 107 | /@esbuild/darwin-x64@0.17.11: 108 | resolution: {integrity: sha512-iB0dQkIHXyczK3BZtzw1tqegf0F0Ab5texX2TvMQjiJIWXAfM4FQl7D909YfXWnB92OQz4ivBYQ2RlxBJrMJOw==} 109 | engines: {node: '>=12'} 110 | cpu: [x64] 111 | os: [darwin] 112 | requiresBuild: true 113 | dev: false 114 | optional: true 115 | 116 | /@esbuild/freebsd-arm64@0.17.11: 117 | resolution: {integrity: sha512-7EFzUADmI1jCHeDRGKgbnF5sDIceZsQGapoO6dmw7r/ZBEKX7CCDnIz8m9yEclzr7mFsd+DyasHzpjfJnmBB1Q==} 118 | engines: {node: '>=12'} 119 | cpu: [arm64] 120 | os: [freebsd] 121 | requiresBuild: true 122 | dev: false 123 | optional: true 124 | 125 | /@esbuild/freebsd-x64@0.17.11: 126 | resolution: {integrity: sha512-iPgenptC8i8pdvkHQvXJFzc1eVMR7W2lBPrTE6GbhR54sLcF42mk3zBOjKPOodezzuAz/KSu8CPyFSjcBMkE9g==} 127 | engines: {node: '>=12'} 128 | cpu: [x64] 129 | os: [freebsd] 130 | requiresBuild: true 131 | dev: false 132 | optional: true 133 | 134 | /@esbuild/linux-arm64@0.17.11: 135 | resolution: {integrity: sha512-Qxth3gsWWGKz2/qG2d5DsW/57SeA2AmpSMhdg9TSB5Svn2KDob3qxfQSkdnWjSd42kqoxIPy3EJFs+6w1+6Qjg==} 136 | engines: {node: '>=12'} 137 | cpu: [arm64] 138 | os: [linux] 139 | requiresBuild: true 140 | dev: false 141 | optional: true 142 | 143 | /@esbuild/linux-arm@0.17.11: 144 | resolution: {integrity: sha512-M9iK/d4lgZH0U5M1R2p2gqhPV/7JPJcRz+8O8GBKVgqndTzydQ7B2XGDbxtbvFkvIs53uXTobOhv+RyaqhUiMg==} 145 | engines: {node: '>=12'} 146 | cpu: [arm] 147 | os: [linux] 148 | requiresBuild: true 149 | dev: false 150 | optional: true 151 | 152 | /@esbuild/linux-ia32@0.17.11: 153 | resolution: {integrity: sha512-dB1nGaVWtUlb/rRDHmuDQhfqazWE0LMro/AIbT2lWM3CDMHJNpLckH+gCddQyhhcLac2OYw69ikUMO34JLt3wA==} 154 | engines: {node: '>=12'} 155 | cpu: [ia32] 156 | os: [linux] 157 | requiresBuild: true 158 | dev: false 159 | optional: true 160 | 161 | /@esbuild/linux-loong64@0.17.11: 162 | resolution: {integrity: sha512-aCWlq70Q7Nc9WDnormntGS1ar6ZFvUpqr8gXtO+HRejRYPweAFQN615PcgaSJkZjhHp61+MNLhzyVALSF2/Q0g==} 163 | engines: {node: '>=12'} 164 | cpu: [loong64] 165 | os: [linux] 166 | requiresBuild: true 167 | dev: false 168 | optional: true 169 | 170 | /@esbuild/linux-mips64el@0.17.11: 171 | resolution: {integrity: sha512-cGeGNdQxqY8qJwlYH1BP6rjIIiEcrM05H7k3tR7WxOLmD1ZxRMd6/QIOWMb8mD2s2YJFNRuNQ+wjMhgEL2oCEw==} 172 | engines: {node: '>=12'} 173 | cpu: [mips64el] 174 | os: [linux] 175 | requiresBuild: true 176 | dev: false 177 | optional: true 178 | 179 | /@esbuild/linux-ppc64@0.17.11: 180 | resolution: {integrity: sha512-BdlziJQPW/bNe0E8eYsHB40mYOluS+jULPCjlWiHzDgr+ZBRXPtgMV1nkLEGdpjrwgmtkZHEGEPaKdS/8faLDA==} 181 | engines: {node: '>=12'} 182 | cpu: [ppc64] 183 | os: [linux] 184 | requiresBuild: true 185 | dev: false 186 | optional: true 187 | 188 | /@esbuild/linux-riscv64@0.17.11: 189 | resolution: {integrity: sha512-MDLwQbtF+83oJCI1Cixn68Et/ME6gelmhssPebC40RdJaect+IM+l7o/CuG0ZlDs6tZTEIoxUe53H3GmMn8oMA==} 190 | engines: {node: '>=12'} 191 | cpu: [riscv64] 192 | os: [linux] 193 | requiresBuild: true 194 | dev: false 195 | optional: true 196 | 197 | /@esbuild/linux-s390x@0.17.11: 198 | resolution: {integrity: sha512-4N5EMESvws0Ozr2J94VoUD8HIRi7X0uvUv4c0wpTHZyZY9qpaaN7THjosdiW56irQ4qnJ6Lsc+i+5zGWnyqWqQ==} 199 | engines: {node: '>=12'} 200 | cpu: [s390x] 201 | os: [linux] 202 | requiresBuild: true 203 | dev: false 204 | optional: true 205 | 206 | /@esbuild/linux-x64@0.17.11: 207 | resolution: {integrity: sha512-rM/v8UlluxpytFSmVdbCe1yyKQd/e+FmIJE2oPJvbBo+D0XVWi1y/NQ4iTNx+436WmDHQBjVLrbnAQLQ6U7wlw==} 208 | engines: {node: '>=12'} 209 | cpu: [x64] 210 | os: [linux] 211 | requiresBuild: true 212 | dev: false 213 | optional: true 214 | 215 | /@esbuild/netbsd-x64@0.17.11: 216 | resolution: {integrity: sha512-4WaAhuz5f91h3/g43VBGdto1Q+X7VEZfpcWGtOFXnggEuLvjV+cP6DyLRU15IjiU9fKLLk41OoJfBFN5DhPvag==} 217 | engines: {node: '>=12'} 218 | cpu: [x64] 219 | os: [netbsd] 220 | requiresBuild: true 221 | dev: false 222 | optional: true 223 | 224 | /@esbuild/openbsd-x64@0.17.11: 225 | resolution: {integrity: sha512-UBj135Nx4FpnvtE+C8TWGp98oUgBcmNmdYgl5ToKc0mBHxVVqVE7FUS5/ELMImOp205qDAittL6Ezhasc2Ev/w==} 226 | engines: {node: '>=12'} 227 | cpu: [x64] 228 | os: [openbsd] 229 | requiresBuild: true 230 | dev: false 231 | optional: true 232 | 233 | /@esbuild/sunos-x64@0.17.11: 234 | resolution: {integrity: sha512-1/gxTifDC9aXbV2xOfCbOceh5AlIidUrPsMpivgzo8P8zUtczlq1ncFpeN1ZyQJ9lVs2hILy1PG5KPp+w8QPPg==} 235 | engines: {node: '>=12'} 236 | cpu: [x64] 237 | os: [sunos] 238 | requiresBuild: true 239 | dev: false 240 | optional: true 241 | 242 | /@esbuild/win32-arm64@0.17.11: 243 | resolution: {integrity: sha512-vtSfyx5yRdpiOW9yp6Ax0zyNOv9HjOAw8WaZg3dF5djEHKKm3UnoohftVvIJtRh0Ec7Hso0RIdTqZvPXJ7FdvQ==} 244 | engines: {node: '>=12'} 245 | cpu: [arm64] 246 | os: [win32] 247 | requiresBuild: true 248 | dev: false 249 | optional: true 250 | 251 | /@esbuild/win32-ia32@0.17.11: 252 | resolution: {integrity: sha512-GFPSLEGQr4wHFTiIUJQrnJKZhZjjq4Sphf+mM76nQR6WkQn73vm7IsacmBRPkALfpOCHsopSvLgqdd4iUW2mYw==} 253 | engines: {node: '>=12'} 254 | cpu: [ia32] 255 | os: [win32] 256 | requiresBuild: true 257 | dev: false 258 | optional: true 259 | 260 | /@esbuild/win32-x64@0.17.11: 261 | resolution: {integrity: sha512-N9vXqLP3eRL8BqSy8yn4Y98cZI2pZ8fyuHx6lKjiG2WABpT2l01TXdzq5Ma2ZUBzfB7tx5dXVhge8X9u0S70ZQ==} 262 | engines: {node: '>=12'} 263 | cpu: [x64] 264 | os: [win32] 265 | requiresBuild: true 266 | dev: false 267 | optional: true 268 | 269 | /@prisma/client@4.11.0(prisma@4.11.0): 270 | resolution: {integrity: sha512-0INHYkQIqgAjrt7NzhYpeDQi8x3Nvylc2uDngKyFDDj1tTRQ4uV1HnVmd1sQEraeVAN63SOK0dgCKQHlvjL0KA==} 271 | engines: {node: '>=14.17'} 272 | requiresBuild: true 273 | peerDependencies: 274 | prisma: '*' 275 | peerDependenciesMeta: 276 | prisma: 277 | optional: true 278 | dependencies: 279 | '@prisma/engines-version': 4.11.0-57.8fde8fef4033376662cad983758335009d522acb 280 | prisma: 4.11.0 281 | dev: false 282 | 283 | /@prisma/engines-version@4.11.0-57.8fde8fef4033376662cad983758335009d522acb: 284 | resolution: {integrity: sha512-3Vd8Qq06d5xD8Ch5WauWcUUrsVPdMC6Ge8ILji8RFfyhUpqon6qSyGM0apvr1O8n8qH8cKkEFqRPsYjuz5r83g==} 285 | dev: false 286 | 287 | /@prisma/engines@4.11.0: 288 | resolution: {integrity: sha512-0AEBi2HXGV02cf6ASsBPhfsVIbVSDC9nbQed4iiY5eHttW9ZtMxHThuKZE1pnESbr8HRdgmFSa/Kn4OSNYuibg==} 289 | requiresBuild: true 290 | 291 | /@types/amqplib@0.10.1: 292 | resolution: {integrity: sha512-j6ANKT79ncUDnAs/+9r9eDujxbeJoTjoVu33gHHcaPfmLQaMhvfbH2GqSe8KUM444epAp1Vl3peVOQfZk3UIqA==} 293 | dependencies: 294 | '@types/node': 18.14.6 295 | dev: true 296 | 297 | /@types/node@18.14.6: 298 | resolution: {integrity: sha512-93+VvleD3mXwlLI/xASjw0FzKcwzl3OdTCzm1LaRfqgS21gfFtK3zDXM5Op9TeeMsJVOaJ2VRDpT9q4Y3d0AvA==} 299 | dev: true 300 | 301 | /acorn-walk@8.2.0: 302 | resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==} 303 | engines: {node: '>=0.4.0'} 304 | dev: false 305 | 306 | /acorn@8.8.2: 307 | resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} 308 | engines: {node: '>=0.4.0'} 309 | dev: false 310 | 311 | /amqplib@0.10.3: 312 | resolution: {integrity: sha512-UHmuSa7n8vVW/a5HGh2nFPqAEr8+cD4dEZ6u9GjP91nHfr1a54RyAKyra7Sb5NH7NBKOUlyQSMXIp0qAixKexw==} 313 | engines: {node: '>=10'} 314 | dependencies: 315 | '@acuminous/bitsyntax': 0.1.2 316 | buffer-more-ints: 1.0.0 317 | readable-stream: 1.1.14 318 | url-parse: 1.5.10 319 | transitivePeerDependencies: 320 | - supports-color 321 | dev: false 322 | 323 | /buffer-from@1.1.2: 324 | resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} 325 | dev: false 326 | 327 | /buffer-more-ints@1.0.0: 328 | resolution: {integrity: sha512-EMetuGFz5SLsT0QTnXzINh4Ksr+oo4i+UGTXEshiGCQWnsgSs7ZhJ8fzlwQ+OzEMs0MpDAMr1hxnblp5a4vcHg==} 329 | dev: false 330 | 331 | /core-util-is@1.0.3: 332 | resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} 333 | dev: false 334 | 335 | /debug@4.3.4: 336 | resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} 337 | engines: {node: '>=6.0'} 338 | peerDependencies: 339 | supports-color: '*' 340 | peerDependenciesMeta: 341 | supports-color: 342 | optional: true 343 | dependencies: 344 | ms: 2.1.2 345 | dev: false 346 | 347 | /esbuild@0.17.11: 348 | resolution: {integrity: sha512-pAMImyokbWDtnA/ufPxjQg0fYo2DDuzAlqwnDvbXqHLphe+m80eF++perYKVm8LeTuj2zUuFXC+xgSVxyoHUdg==} 349 | engines: {node: '>=12'} 350 | hasBin: true 351 | requiresBuild: true 352 | optionalDependencies: 353 | '@esbuild/android-arm': 0.17.11 354 | '@esbuild/android-arm64': 0.17.11 355 | '@esbuild/android-x64': 0.17.11 356 | '@esbuild/darwin-arm64': 0.17.11 357 | '@esbuild/darwin-x64': 0.17.11 358 | '@esbuild/freebsd-arm64': 0.17.11 359 | '@esbuild/freebsd-x64': 0.17.11 360 | '@esbuild/linux-arm': 0.17.11 361 | '@esbuild/linux-arm64': 0.17.11 362 | '@esbuild/linux-ia32': 0.17.11 363 | '@esbuild/linux-loong64': 0.17.11 364 | '@esbuild/linux-mips64el': 0.17.11 365 | '@esbuild/linux-ppc64': 0.17.11 366 | '@esbuild/linux-riscv64': 0.17.11 367 | '@esbuild/linux-s390x': 0.17.11 368 | '@esbuild/linux-x64': 0.17.11 369 | '@esbuild/netbsd-x64': 0.17.11 370 | '@esbuild/openbsd-x64': 0.17.11 371 | '@esbuild/sunos-x64': 0.17.11 372 | '@esbuild/win32-arm64': 0.17.11 373 | '@esbuild/win32-ia32': 0.17.11 374 | '@esbuild/win32-x64': 0.17.11 375 | dev: false 376 | 377 | /fsevents@2.3.2: 378 | resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} 379 | engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} 380 | os: [darwin] 381 | requiresBuild: true 382 | dev: false 383 | optional: true 384 | 385 | /get-tsconfig@4.4.0: 386 | resolution: {integrity: sha512-0Gdjo/9+FzsYhXCEFueo2aY1z1tpXrxWZzP7k8ul9qt1U5o8rYJwTJYmaeHdrVosYIVYkOy2iwCJ9FdpocJhPQ==} 387 | dev: false 388 | 389 | /inherits@2.0.4: 390 | resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} 391 | dev: false 392 | 393 | /isarray@0.0.1: 394 | resolution: {integrity: sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==} 395 | dev: false 396 | 397 | /ms@2.1.2: 398 | resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} 399 | dev: false 400 | 401 | /node-worker-threads-pool@1.5.1: 402 | resolution: {integrity: sha512-7TXAhpMm+jO4MfESxYLtMGSnJWv+itdNHMdaFmeZuPXxwFGU90mtEB42BciUULXOUAxYBfXILAuvrSG3rQZ7mw==} 403 | dev: false 404 | 405 | /prisma@4.11.0: 406 | resolution: {integrity: sha512-4zZmBXssPUEiX+GeL0MUq/Yyie4ltiKmGu7jCJFnYMamNrrulTBc+D+QwAQSJ01tyzeGHlD13kOnqPwRipnlNw==} 407 | engines: {node: '>=14.17'} 408 | hasBin: true 409 | requiresBuild: true 410 | dependencies: 411 | '@prisma/engines': 4.11.0 412 | 413 | /querystringify@2.2.0: 414 | resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==} 415 | dev: false 416 | 417 | /readable-stream@1.1.14: 418 | resolution: {integrity: sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==} 419 | dependencies: 420 | core-util-is: 1.0.3 421 | inherits: 2.0.4 422 | isarray: 0.0.1 423 | string_decoder: 0.10.31 424 | dev: false 425 | 426 | /requires-port@1.0.0: 427 | resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} 428 | dev: false 429 | 430 | /safe-buffer@5.1.2: 431 | resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} 432 | dev: false 433 | 434 | /source-map-support@0.5.21: 435 | resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} 436 | dependencies: 437 | buffer-from: 1.1.2 438 | source-map: 0.6.1 439 | dev: false 440 | 441 | /source-map@0.6.1: 442 | resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} 443 | engines: {node: '>=0.10.0'} 444 | dev: false 445 | 446 | /string_decoder@0.10.31: 447 | resolution: {integrity: sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==} 448 | dev: false 449 | 450 | /tsx@3.12.7: 451 | resolution: {integrity: sha512-C2Ip+jPmqKd1GWVQDvz/Eyc6QJbGfE7NrR3fx5BpEHMZsEHoIxHL1j+lKdGobr8ovEyqeNkPLSKp6SCSOt7gmw==} 452 | hasBin: true 453 | dependencies: 454 | '@esbuild-kit/cjs-loader': 2.4.2 455 | '@esbuild-kit/core-utils': 3.1.0 456 | '@esbuild-kit/esm-loader': 2.5.5 457 | optionalDependencies: 458 | fsevents: 2.3.2 459 | dev: false 460 | 461 | /typescript@4.9.5: 462 | resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} 463 | engines: {node: '>=4.2.0'} 464 | dev: true 465 | 466 | /url-parse@1.5.10: 467 | resolution: {integrity: sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==} 468 | dependencies: 469 | querystringify: 2.2.0 470 | requires-port: 1.0.0 471 | dev: false 472 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------