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
4
Versions
376
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.9.0-leo-ron-1083-experimental-201 to 0.9.0-leo-ron-1083-experimental-202

53

dist/index.js

@@ -620,2 +620,3 @@ // src/utils/helpers.ts

if (field.type === "link") {
if (field.kind === "many") return null;
const actions = field.actions || {};

@@ -733,10 +734,14 @@ const targetTable = getModelBySlug(models, field.target).table;

}
if (entity === "field" && model) {
const existingModel = model;
if (entity === "field") {
if (action === "create") {
const field2 = jsonValue;
field2.type = field2.type || "string";
dependencyStatements.push({
statement: `${statement} ADD COLUMN ${getFieldStatement(models, model, field2)}`,
params: []
});
const fieldStatement = getFieldStatement(models, existingModel, field2);
if (fieldStatement) {
dependencyStatements.push({
statement: `${statement} ADD COLUMN ${fieldStatement}`,
params: []
});
}
} else if (action === "alter") {

@@ -757,3 +762,3 @@ const newSlug = jsonValue?.slug;

}
if (entity === "index" && model) {
if (entity === "index") {
const index = jsonValue;

@@ -767,5 +772,5 @@ const indexName = convertToSnakeCase(slug);

if ("slug" in field2) {
({ fieldSelector } = getFieldFromModel(model, field2.slug, "to"));
({ fieldSelector } = getFieldFromModel(existingModel, field2.slug, "to"));
} else if ("expression" in field2) {
fieldSelector = parseFieldExpression(model, "to", field2.expression);
fieldSelector = parseFieldExpression(existingModel, "to", field2.expression);
}

@@ -778,3 +783,3 @@ if (field2.collation) fieldSelector += ` COLLATE ${field2.collation}`;

if (index.filter) {
const withStatement = handleWith(models, model, params, index.filter);
const withStatement = handleWith(models, existingModel, params, index.filter);
statement2 += ` WHERE (${withStatement})`;

@@ -785,3 +790,3 @@ }

}
if (entity === "trigger" && model) {
if (entity === "trigger") {
const triggerName = convertToSnakeCase(slug);

@@ -802,3 +807,3 @@ const params = [];

const fieldSelectors = trigger.fields.map((field2) => {
return getFieldFromModel(model, field2.slug, "to").fieldSelector;
return getFieldFromModel(existingModel, field2.slug, "to").fieldSelector;
});

@@ -815,3 +820,3 @@ statementParts.push(`OF (${fieldSelectors.join(", ")})`);

models,
{ ...model, tableAlias },
{ ...existingModel, tableAlias },
params,

@@ -825,3 +830,3 @@ trigger.filter

returning: false,
parentModel: model
parentModel: existingModel
}).main.statement;

@@ -838,2 +843,16 @@ });

const field = `${RONIN_MODEL_SYMBOLS.FIELD}${pluralType}`;
const targetEntityIndex = existingModel[pluralType]?.findIndex(
(entity2) => entity2.slug === slug
);
if ((action === "alter" || action === "drop") && (typeof targetEntityIndex === "undefined" || targetEntityIndex === -1)) {
throw new RoninError({
message: `No ${entity} with slug "${slug}" defined in model "${existingModel.name}".`,
code: {
field: "FIELD_NOT_FOUND",
index: "INDEX_NOT_FOUND",
trigger: "TRIGGER_NOT_FOUND",
preset: "PRESET_NOT_FOUND"
}[entity]
});
}
let json;

@@ -844,2 +863,6 @@ switch (action) {

json = `json_insert(${field}, '$.${slug}', ${value})`;
existingModel[pluralType] = [
...existingModel[pluralType] || [],
jsonValue
];
break;

@@ -850,2 +873,4 @@ }

json = `json_set(${field}, '$.${slug}', json_patch(json_extract(${field}, '$.${slug}'), ${value}))`;
const targetEntity = existingModel[pluralType];
targetEntity[targetEntityIndex] = jsonValue;
break;

@@ -855,2 +880,4 @@ }

json = `json_remove(${field}, '$.${slug}')`;
const targetEntity = existingModel[pluralType];
delete targetEntity[targetEntityIndex];
}

@@ -857,0 +884,0 @@ }

{
"name": "@ronin/compiler",
"version": "0.9.0-leo-ron-1083-experimental-201",
"version": "0.9.0-leo-ron-1083-experimental-202",
"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