Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
kanel-kysely
Advanced tools
Generate Kysely types directly from your Postgres database. This packages extends Kanel with some Kysely specific features. Check ./example/.kanelrc.js for how to customize your schema generation.
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
import type { ColumnType, Selectable, Insertable, Updateable } from "kysely";
/** Identifier type for actor */
export type ActorId = number & { __flavor?: "ActorId" };
/** Represents the table public.actor */
export default interface ActorTable {
/** Database type: pg_catalog.int4 */
actor_id: ColumnType<ActorId, ActorId | null, ActorId | null>;
/** Database type: pg_catalog.varchar */
first_name: ColumnType<string, string, string | null>;
/** Database type: pg_catalog.varchar */
last_name: ColumnType<string, string, string | null>;
/** Database type: pg_catalog.timestamp */
last_update: ColumnType<Date, Date | null, Date | null>;
}
export type Actor = Selectable<ActorTable>;
export type NewActor = Insertable<ActorTable>;
export type ActorUpdate = Updateable<ActorTable>;
Assuming you already have Kanel installed, add this with
$ npm i -D kanel-kysely
To use it, add it to your .kanelrc.js
file:
const { makeKyselyHook } = require("kanel-kysely");
module.exports = {
// ... your config here.
preRenderHooks: [makeKyselyHook()],
};
Kanel generates some types with extra guards.
/** Identifier type for actor */
export type ActorId = number & { __flavor?: "ActorId" };
{ __flavor?: 'ActorId' }
exists at build time and not at runtime. It will prevent you from accidentally passing an incorrect value for the Id.
To pass a string value as primary key or foreign key reference, just add a type assertion for the <table>Id
generated type.
In cases such as subqueries, the type assertion will happen automatically.
CamelCasePlugin
If you use Kysely with CamelCasePlugin
then append kyselyCamelCaseHook
to preRenderHooks
:
const { makeKyselyHook, kyselyCamelCaseHook } = require("kanel-kysely");
module.exports = {
// ... your config here.
preRenderHooks: [makeKyselyHook(), kyselyCamelCaseHook],
};
If you're using Kysely for migrations, you might want to filter the types of the migration tables, such as kysely_migration
and kysely_migration_lock
. The kyselyTypeFilter
will do this for you.
const { kyselyTypeFilter } = require("kanel-kysely");
module.exports = {
/// ... your config here.
typeFilter: kyselyTypeFilter,
};
FAQs
Kysely extension for Kanel
The npm package kanel-kysely receives a total of 6,422 weekly downloads. As such, kanel-kysely popularity was classified as popular.
We found that kanel-kysely demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.