npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

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

About

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

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

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

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

Open Software & Tools

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

© 2024 – Pkg Stats / Ryan Hefner

kitres

v1.0.116

Published

Arsenal library

Downloads

1,396

Readme

README do Projeto

Este repositório contém exemplos de código para vários módulos e componentes de um projeto. O projeto inclui funcionalidades relacionadas à manipulação de conexões de banco de dados, recursos, revisões e catálogos.

Estrutura do Projeto

O projeto consiste nos seguintes arquivos e módulos principais:

core.ts

O arquivo core.ts define as configurações de conexão com o banco de dados PostgreSQL e exporta uma instância configurada da classe PgCore.

// Importar os módulos necessários
import { Client, ClientConfig, Pool } from "pg";
import { PgCore } from "kitres";

// Opções de conexão com o PostgreSQL
let opts: ClientConfig = {
    host: "127.0.0.1",
    port: 5432,
    user: "postgres",
    database: "postgres",
    password: "1234"
};

// Exportar a instância configurada do PgCore
export const pgCore: PgCore = new PgCore(  () => new Pool( opts ));

resource.ts

O arquivo resource.ts define uma instância de Resource e configura um recurso usando a configuração pgCore.

// Importar os módulos necessários
import { Resource } from "kitres/src/core/resource";
import { pgCore } from "./core";
import { DataDoc } from "./var/catalog";
import { cataloger } from "./cataloger";

// Criar e configurar uma instância de Resource
export const resource: Resource<DataDoc> = new Resource<DataDoc>(pgCore, {
    catalogReload: false
});

// Usar o catalogador com o recurso
resource.use(cataloger);

revision.ts

O arquivo revision.ts define uma instância de RevisionCore e realiza operações relacionadas a revisões.

// Importar os módulos necessários
import { pgCore } from "./core";
import { RevisionCore, AppVersion } from "kitres";
import Path from "path";

//Iniciar o gerenciador de versão
export const VERSION = new AppVersion({
    readonly: false,
    project: Path.join(__dirname,  "/path/of/root/project" )
})

// Criar e configurar uma instância de RevisionCore
export const revControl = new RevisionCore(pgCore, {
    dirname: Path.join(__dirname, "./var/revision/patches/"),
    schema: "kitres_core",
    VERSION: VERSION
});

// Registrar eventos de revisão
revControl.on("log", (level, message) => {
    console.log(level, message);
});

// Coletar e configurar revisões
revControl.collect();
revControl.setup((error, block) => {
    if (error) console.log(error);
    console.log("Aplicação da revisão bem-sucedida!");
});

catalog.ts

O arquivo catalog.ts define uma instância de Cataloger e lida com a geração de catálogo após revisões.

// Importar os módulos necessários
import { pgCore } from "./core";
import * as Path from "path";
import { revControl } from "./revision";
import { Cataloger } from "kitres";
import { DataDoc } from "./var/catalog";

// Criar e configurar uma instância de Cataloger
export const cataloger: Cataloger<DataDoc> = new Cataloger(pgCore, {
    caseMethodType: "pascalCase",
    className: "DataDoc",
    location: Path.join(__dirname, "./var/catalog/_index"),
    schemas: ["public", "schema1"],
    object:[ "EntryOf", "TableOf", "ViewOf", "ReferenceOf", "RelationOf" ],
});

// Gerar catálogo após revisão
revControl.on("revision", error => {
    if (error) return;
    cataloger.generateCatalog(error1 => {
        if (error1) console.log(error1);
        console.log("Documento gerado com sucesso");
    });
});

res/functions.resolve.ts

O arquivo res/functions.resolve.ts demonstra o uso de funções de recurso após uma revisão.

// Importar os módulos necessários
import { revControl } from "../revision";
import { resource } from "../resource";
import { Result } from "kitres";

// Executar função de recurso após revisão
revControl.once("revision", (error, blocks) => {
    if (error) return;
    resource.call.public.my_function({
        param1: {}, //param value
        param2: "para-valoues",
        param3: SQL.jsonb( [] ), //Param value
        param4: SQL.varchar( null ) //Param value
    }, {
        onResult(error: Error, result?: Result<any, any>): any {
            if (error) return console.error(error);
            console.log(result.rows);
        }
    }).body();
});

res/table.ts

O arquivo res/table.ts demonstra consultas em tabelas e visualizações usando recursos e SQL após uma revisão.

// Importar os módulos necessários
import { pgCore } from "../core";
import { DataDoc, TableOf } from "../var/catalog";
import { revControl } from "../revision";
import { resource } from "../resource";
import { Result, sql, TableDoc, ViewDoc } from "kitres";

// Realizar consultas em tabelas e visualizações após revisão
revControl.once("revision", (error, blocks) => {
    if (error) return;

    // Consultar tabelas usando recurso
    resource.with.public.my_table.select({}, {
        onResult(error: Error, result?: Result<TableDoc<DataDoc, "public", "my_table">, any>) {
            if (error) return;
            result?.rows.forEach(value => {
                console.log(JSON.stringify(value));
            });
        }
    });

    // Consultar tabelas usando SQL
    pgCore.query<TableOf<"kitres_core", "script"> & TableOf<"kitres_core", "patch">, any>(sql`
        select * 
        from kitres_core.script s
        inner join kitres_core.patch p on s.script_patch_id = p.patch_id
    `, {
        onResult(error: Error, result?: Result<TableOf<"kitres_core", "script"> & TableOf<"kitres_core", "patch">, any>) {
            result.rows.forEach(value => {
                delete value["script_sql"];
                console.log(JSON.stringify(value));
            });
        }
    });

    // Consultar visualização usando recurso
    resource.with.kitres_core.vscript.select("patch_id", "script_sql")({}, {
        onResult(error: Error, result?: Result<ViewDoc<DataDoc, "kitres_core", "vscript">, any>): any {
            console.log(result?.rows);
        }
    });
});

Conclusão

Este README fornece uma visão geral dos principais módulos e componentes no projeto, destacando suas funcionalidades e interações. Consulte o código-fonte para obter detalhes mais detalhados sobre a implementação.

Para mais informações, perguntas ou contribuições, sinta-se à vontade para entrar em contato com os mantenedores do projeto.