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

@ronin/compiler

Package Overview
Dependencies
Maintainers
0
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ronin/compiler - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

91

dist/index.js

@@ -163,3 +163,3 @@ // src/utils/index.ts

type: "reference",
schema: "account",
target: "account",
slug: "ronin.createdBy"

@@ -175,3 +175,3 @@ },

type: "reference",
schema: "account",
target: "account",
slug: "ronin.updatedBy"

@@ -206,5 +206,6 @@ }

{ slug: "name", type: "string" },
{ slug: "slug", type: "string" },
{ slug: "type", type: "string" },
{ slug: "schema", type: "reference", schema: "schema" },
{ slug: "slug", type: "string", required: true },
{ slug: "type", type: "string", required: true },
{ slug: "schema", type: "reference", target: "schema" },
{ slug: "target", type: "reference", target: "schema" },
{ slug: "required", type: "boolean" },

@@ -223,3 +224,3 @@ { slug: "defaultValue", type: "string" },

if (field.type === "reference" && !field.slug.startsWith("ronin.")) {
const relatedSchema = getSchemaBySlug(list, field.schema);
const relatedSchema = getSchemaBySlug(list, field.target);
let fieldSlug = relatedSchema.slug;

@@ -233,5 +234,5 @@ if (field.kind === "many") {

{
slug: "origin",
slug: "source",
type: "reference",
schema: schema.slug
target: schema.slug
},

@@ -241,3 +242,3 @@ {

type: "reference",
schema: relatedSchema.slug
target: relatedSchema.slug
}

@@ -258,3 +259,3 @@ ]

};
const relatedSchemaToModify = list.find((schema2) => schema2.slug === field.schema);
const relatedSchemaToModify = list.find((schema2) => schema2.slug === field.target);
if (!relatedSchemaToModify) throw new Error("Missing related schema");

@@ -388,16 +389,24 @@ relatedSchemaToModify.including = {

// src/instructions/with.ts
var WITH_CONDITIONS = [
"being",
"notBeing",
"startingWith",
"notStartingWith",
"endingWith",
"notEndingWith",
"containing",
"notContaining",
"greaterThan",
"greaterOrEqual",
"lessThan",
"lessOrEqual"
];
var getMatcher = (value, negative) => {
if (negative) {
if (value === null) return "IS NOT";
return "!=";
}
if (value === null) return "IS";
return "=";
};
var WITH_CONDITIONS = {
being: (value, baseValue) => `${getMatcher(baseValue, false)} ${value}`,
notBeing: (value, baseValue) => `${getMatcher(baseValue, true)} ${value}`,
startingWith: (value) => `LIKE ${value}%`,
notStartingWith: (value) => `NOT LIKE ${value}%`,
endingWith: (value) => `LIKE %${value}`,
notEndingWith: (value) => `NOT LIKE %${value}`,
containing: (value) => `LIKE %${value}%`,
notContaining: (value) => `NOT LIKE %${value}%`,
greaterThan: (value) => `> ${value}`,
greaterOrEqual: (value) => `>= ${value}`,
lessThan: (value) => `< ${value}`,
lessOrEqual: (value) => `<= ${value}`
};
var handleWith = (schemas, schema, statementValues, instruction, rootTable) => {

@@ -458,23 +467,7 @@ const subStatement = composeConditions(

if (options.type === "values") return conditionValue;
const conditionTypes = {
being: [getMatcher(value, false), conditionValue],
notBeing: [getMatcher(value, true), conditionValue],
startingWith: ["LIKE", `${conditionValue}%`],
notStartingWith: ["NOT LIKE", `${conditionValue}%`],
endingWith: ["LIKE", `%${conditionValue}`],
notEndingWith: ["NOT LIKE", `%${conditionValue}`],
containing: ["LIKE", `%${conditionValue}%`],
notContaining: ["NOT LIKE", `%${conditionValue}%`],
greaterThan: [">", conditionValue],
greaterOrEqual: [">=", conditionValue],
lessThan: ["<", conditionValue],
lessOrEqual: ["<=", conditionValue]
};
return `${conditionSelector} ${conditionTypes[options.condition || "being"].join(" ")}`;
return `${conditionSelector} ${WITH_CONDITIONS[options.condition || "being"](conditionValue, value)}`;
};
var composeConditions = (schemas, schema, statementValues, instructionName, value, options) => {
const isNested = isObject(value) && Object.keys(value).length > 0;
if (isNested && Object.keys(value).every(
(key) => WITH_CONDITIONS.includes(key)
)) {
if (isNested && Object.keys(value).every((key) => key in WITH_CONDITIONS)) {
const conditions = Object.entries(value).map(

@@ -515,3 +508,3 @@ ([conditionType, checkValue]) => composeConditions(schemas, schema, statementValues, instructionName, checkValue, {

} else {
const relatedSchema = getSchemaBySlug(schemas, schemaField.schema);
const relatedSchema = getSchemaBySlug(schemas, schemaField.target);
const subQuery = {

@@ -570,10 +563,2 @@ get: {

};
var getMatcher = (value, negative) => {
if (negative) {
if (value === null) return "IS NOT";
return "!=";
}
if (value === null) return "IS";
return "=";
};
var formatIdentifiers = ({ identifiers }, queryInstructions) => {

@@ -889,4 +874,4 @@ if (!queryInstructions) return queryInstructions;

const composeStatement = (subQueryType, value) => {
const origin = queryType === "create" ? { id: toInstruction.id } : withInstruction;
const recordDetails = { origin };
const source = queryType === "create" ? { id: toInstruction.id } : withInstruction;
const recordDetails = { source };
if (value) recordDetails.target = value;

@@ -893,0 +878,0 @@ const { readStatement } = compileQueryInput(

{
"name": "@ronin/compiler",
"version": "0.1.0",
"version": "0.1.1",
"type": "module",

@@ -11,3 +11,5 @@ "description": "Compiles RONIN queries to SQL statements.",

"types": "./dist/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"scripts": {

@@ -22,3 +24,7 @@ "lint": "bun run --bun lint:tsc && bun run --bun lint:biome",

},
"keywords": ["query", "compiler", "sql"],
"keywords": [
"query",
"compiler",
"sql"
],
"author": "ronin",

@@ -25,0 +31,0 @@ "license": "MIT",

Sorry, the diff of this file is too big to display

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