Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sql-light

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-light - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

lib/types.d.ts

6

lib/index.d.ts

@@ -7,3 +7,3 @@ /// <reference types="node" />

[K in Extract<keyof Schema, string> as `:${K}`]: K;
} & (<K extends Extract<keyof Schema, string>[]>(...keys: K) => string);
} & (<K extends `${Extract<keyof Schema, string>}${string}`[]>(...keys: K) => K);
declare namespace sql {

@@ -13,3 +13,3 @@ /**

*/
export type Value = string | number | null | Buffer;
export type ParamsValue = string | number | null | Buffer;
type EndToken = ',' | ' ' | ';' | ')';

@@ -19,3 +19,3 @@ type Analyze<T extends string, Current extends string = ''> = T extends `${infer Char}${infer Rest}` ? CharCheck<Char, Current, Rest> : T extends EndToken ? {} : PropObject<`${Current}${T}`>;

type PropObject<Name extends string> = {
[K in `$${Name}`]: Value;
[K in `$${Name}`]: ParamsValue;
};

@@ -22,0 +22,0 @@ type SliceEnd<T extends string, Token extends string> = T extends `${string}${Token}${infer Rest}` ? Rest : '';

// @bun
class S extends Function{$;init;cols;constructor($){super();this.options=$;const{name:n,schema:x,primaryKeys:j,foreignKeys:v,withoutRowID:A}=this.options,d=[];for(let E in x)d.push(`${E} ${x[E]}`);if(Array.isArray(j))d.push(`PRIMARY KEY(${j.join(",")})`);if(Array.isArray(v))for(let E of v)d.push(`FOREIGN KEY(${E.keys.join(",")}) REFERENCES ${E.ref}`);this.init=`CREATE TABLE IF NOT EXISTS ${n} (${d.join(",")})${A===!0?" WITHOUT ROWID":""}`;const z=[];for(let E in x)z.push(E);this.cols=z}toString=()=>this.options.name}var C={apply:($,n,x)=>`${$.options.name}(${x.join(",")})`,get:($,n)=>{if(n in $)return Reflect.get($,n);if(typeof n==="string"){switch(n[0]){case"$":Reflect.set($,n,`${$.options.name}.${n.substring(1)}`);break;case":":Reflect.set($,n,n.substring(1));break}return Reflect.get($,n)}return null}},U;(function(I){function $(x){return new Proxy(new S(x),C)}I.table=$;function n(x){return x}I.query=n})(U||(U={}));var L=U;export{L as default};
class N extends Function{d;init;cols;constructor(d){super();this.options=d;const{name:n,schema:S,primaryKeys:R,foreignKeys:$,withoutRowID:j}=this.options,E=[];for(let C in S)E.push(`${C} ${S[C]}`);if(Array.isArray(R))E.push(`PRIMARY KEY(${R.join(",")})`);if(Array.isArray($))for(let C of $)E.push(`FOREIGN KEY(${C.keys.join(",")}) REFERENCES ${C.ref}`);this.init=`CREATE TABLE IF NOT EXISTS ${n} (${E.join(",")})${j===!0?" WITHOUT ROWID":""}`;const i=[];for(let C in S)i.push(C);this.cols=i}ref(...d){return`${this.options.name}(${d.join(",")})`}toString=()=>this.options.name}var u={apply:(d,n,S)=>S,get:(d,n)=>{if(n in d)return Reflect.get(d,n);if(typeof n==="string"){switch(n[0]){case"$":Reflect.set(d,n,`${d.options.name}.${n.substring(1)}`);break;case":":Reflect.set(d,n,n.substring(1));break}return Reflect.get(d,n)}return null}},Q;(function(A){function d(S){return new Proxy(new N(S),u)}A.table=d;function n(S){return S}A.query=n})(Q||(Q={}));var G=Q;export{G as default};

@@ -0,1 +1,2 @@

import type { Join, TupleUnion } from './types';
export type BaseSchema = Record<string, string>;

@@ -13,5 +14,2 @@ export interface ForeignKeysConstraint<Keys extends string> {

}
type TupleUnion<U extends string, R extends any[] = []> = {
[S in U]: Exclude<U, S> extends never ? [...R, S] : TupleUnion<Exclude<U, S>, [...R, S]>;
}[U];
export declare class Table<Name extends string, Schema extends BaseSchema> extends Function {

@@ -29,2 +27,6 @@ readonly options: TableOptions<Name, Schema>;

/**
* Get references string
*/
ref<Keys extends Extract<keyof Schema, string>[]>(...keys: Keys): `${Name}(${Join<Keys>})`;
/**
* Get the name of the table

@@ -34,2 +36,1 @@ */

}
export {};
{
"name": "sql-light",
"version": "1.0.5",
"module": "lib/index.ts",
"version": "1.0.6",
"module": "lib/index.js",
"types": "lib/index.d.ts",

@@ -6,0 +6,0 @@ "description": "SQLite query builder for ya smol project",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc