New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ronin/compiler

Package Overview
Dependencies
Maintainers
0
Versions
397
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.5.1 to 0.6.0

59

dist/index.js

@@ -15,2 +15,6 @@ // src/utils/helpers.ts

};
var RONIN_SCHEMA_FIELD_REGEX = new RegExp(
`${RONIN_SCHEMA_SYMBOLS.FIELD}[a-zA-Z0-9]+`,
"g"
);
var RoninError = class extends Error {

@@ -507,3 +511,4 @@ code;

{ slug: "unique", type: "boolean" },
{ slug: "filter", type: "json" }
{ slug: "filter", type: "json" },
{ slug: "fields", type: "json", required: true }
]

@@ -519,6 +524,13 @@ },

{ slug: "slug", type: "string", required: true },
{ slug: "schema", type: "reference", target: { slug: "schema" }, required: true },
{ slug: "cause", type: "string", required: true },
{
slug: "schema",
type: "reference",
target: { slug: "schema" },
required: true
},
{ slug: "when", type: "string", required: true },
{ slug: "action", type: "string", required: true },
{ slug: "filter", type: "json" },
{ slug: "effects", type: "json", required: true }
{ slug: "effects", type: "json", required: true },
{ slug: "fields", type: "json" }
]

@@ -703,6 +715,22 @@ }

const filterQuery = instructionList?.filter;
const fields = instructionList?.fields;
const params = [];
let statement2 = `${tableAction}${unique ? " UNIQUE" : ""} INDEX "${indexName}"`;
if (queryType === "create") {
statement2 += ` ON "${tableName}"`;
const schema = targetSchema;
const columns = fields.map((field) => {
let fieldSelector = "";
if ("slug" in field) {
({ fieldSelector } = getFieldFromSchema(schema, field.slug, "to"));
} else if ("expression" in field) {
fieldSelector = field.expression.replace(RONIN_SCHEMA_FIELD_REGEX, (match) => {
const fieldSlug = match.replace(RONIN_SCHEMA_SYMBOLS.FIELD, "");
return getFieldFromSchema(schema, fieldSlug, "to").fieldSelector;
});
}
if (field.collation) fieldSelector += ` COLLATE ${field.collation}`;
if (field.order) fieldSelector += ` ${field.order}`;
return fieldSelector;
});
statement2 += ` ON "${tableName}" (${columns.join(", ")})`;
if (filterQuery) {

@@ -726,6 +754,21 @@ const withStatement = handleWith(

if (queryType === "create") {
const cause = slugToName(instructionList?.cause).toUpperCase();
const statementParts = [cause, "ON", `"${tableName}"`];
const { when, action } = instructionList;
const statementParts = [`${when} ${action}`];
const effectQueries = instructionList?.effects;
const filterQuery = instructionList?.filter;
const fields = instructionList?.fields;
if (fields) {
if (action !== "UPDATE") {
throw new RoninError({
message: `When ${queryTypeReadable} ${kind}, targeting specific fields requires the \`UPDATE\` action.`,
code: "INVALID_SCHEMA_VALUE",
fields: ["action"]
});
}
const fieldSelectors = fields.map((field) => {
return getFieldFromSchema(targetSchema, field.slug, "to").fieldSelector;
});
statementParts.push(`OF (${fieldSelectors.join(", ")})`);
}
statementParts.push("ON", `"${tableName}"`);
if (filterQuery || effectQueries.some((query) => findInObject(query, RONIN_SCHEMA_SYMBOLS.FIELD))) {

@@ -735,3 +778,3 @@ statementParts.push("FOR EACH ROW");

if (filterQuery) {
const tablePlaceholder = cause.endsWith("DELETE") ? RONIN_SCHEMA_SYMBOLS.FIELD_OLD : RONIN_SCHEMA_SYMBOLS.FIELD_NEW;
const tablePlaceholder = action === "DELETE" ? RONIN_SCHEMA_SYMBOLS.FIELD_OLD : RONIN_SCHEMA_SYMBOLS.FIELD_NEW;
const withStatement = handleWith(

@@ -738,0 +781,0 @@ schemas,

2

package.json
{
"name": "@ronin/compiler",
"version": "0.5.1",
"version": "0.6.0",
"type": "module",

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

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