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
150
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.7.1 to 0.7.2

47

dist/index.js

@@ -190,3 +190,3 @@ // src/utils/helpers.ts

}
if (modelField.type === "reference" && isNested) {
if (modelField.type === "link" && isNested) {
const keys = Object.keys(value);

@@ -494,3 +494,3 @@ const values = Object.values(value);

slug: "model",
type: "reference",
type: "link",
target: { slug: "model" },

@@ -503,4 +503,4 @@ required: true

{ slug: "autoIncrement", type: "boolean" },
// Only allowed for fields of type "reference".
{ slug: "target", type: "reference", target: { slug: "model" } },
// Only allowed for fields of type "link".
{ slug: "target", type: "link", target: { slug: "model" } },
{ slug: "kind", type: "string" },

@@ -522,3 +522,3 @@ { slug: "actions", type: "group" },

slug: "model",
type: "reference",
type: "link",
target: { slug: "model" },

@@ -542,3 +542,3 @@ required: true

slug: "model",
type: "reference",
type: "link",
target: { slug: "model" },

@@ -560,3 +560,3 @@ required: true

slug: "model",
type: "reference",
type: "link",
target: { slug: "model" },

@@ -577,3 +577,3 @@ required: true

for (const field of model.fields || []) {
if (field.type === "reference" && !field.slug.startsWith("ronin.")) {
if (field.type === "link" && !field.slug.startsWith("ronin.")) {
const relatedModel = getModelBySlug(models, field.target.slug);

@@ -590,3 +590,3 @@ let fieldSlug = relatedModel.slug;

slug: "source",
type: "reference",
type: "link",
target: { slug: model.slug }

@@ -596,3 +596,3 @@ },

slug: "target",
type: "reference",
type: "link",
target: { slug: relatedModel.slug }

@@ -612,3 +612,3 @@ }

for (const field of model.fields || []) {
if (field.type === "reference" && !field.slug.startsWith("ronin.")) {
if (field.type === "link" && !field.slug.startsWith("ronin.")) {
const relatedModel = getModelBySlug(list, field.target.slug);

@@ -624,3 +624,3 @@ if (field.kind === "many") continue;

with: {
// Compare the `id` field of the related model to the reference field on
// Compare the `id` field of the related model to the link field on
// the root model (`field.slug`).

@@ -643,3 +643,3 @@ id: {

const field = subModel.fields?.find((field2) => {
return field2.type === "reference" && field2.target.slug === model.slug;
return field2.type === "link" && field2.target.slug === model.slug;
});

@@ -685,3 +685,3 @@ if (!field) return null;

var typesInSQLite = {
reference: "TEXT",
link: "TEXT",
string: "TEXT",

@@ -694,3 +694,3 @@ date: "DATETIME",

};
var getFieldStatement = (field) => {
var getFieldStatement = (model, field) => {
if (field.type === "group") return null;

@@ -703,3 +703,7 @@ let statement = `"${field.slug}" ${typesInSQLite[field.type]}`;

statement += ` DEFAULT ${field.defaultValue}`;
if (field.type === "reference") {
if (typeof field.check !== "undefined") {
const symbol = getSymbol(field.check);
statement += ` CHECK (${parseFieldExpression(model, "to", symbol?.value)})`;
}
if (field.type === "link") {
const actions = field.actions || {};

@@ -864,4 +868,5 @@ const targetTable = convertToSnakeCase(pluralize(field.target.slug));

if (queryType === "create") {
const { fields } = queryInstructions.to;
const columns = fields.map(getFieldStatement).filter(Boolean);
const newModel = queryInstructions.to;
const { fields } = newModel;
const columns = fields.map((field) => getFieldStatement(newModel, field)).filter(Boolean);
dependencyStatements.push({

@@ -871,3 +876,3 @@ statement: `${statement} (${columns.join(", ")})`,

});
models.push(queryInstructions.to);
models.push(newModel);
} else if (queryType === "set") {

@@ -899,3 +904,3 @@ const newSlug = queryInstructions.to?.pluralSlug;

dependencyStatements.push({
statement: `${statement} ADD COLUMN ${getFieldStatement(instructionList)}`,
statement: `${statement} ADD COLUMN ${getFieldStatement(targetModel, instructionList)}`,
params: []

@@ -1222,3 +1227,3 @@ });

const fieldDetails = getFieldFromModel(model, fieldSlug, "to");
if (fieldDetails.field.type === "reference" && fieldDetails.field.kind === "many") {
if (fieldDetails.field.type === "link" && fieldDetails.field.kind === "many") {
delete toInstruction[fieldSlug];

@@ -1225,0 +1230,0 @@ const associativeModelSlug = composeAssociationModelSlug(model, fieldDetails.field);

{
"name": "@ronin/compiler",
"version": "0.7.1",
"version": "0.7.2",
"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