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

@ronin/syntax

Package Overview
Dependencies
Maintainers
0
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ronin/syntax - npm Package Compare versions

Comparing version 0.1.11 to 0.2.0-leo-ron-1071-experimental-49

dist/chunk-H6R4HHJJ.js

2

dist/queries.js

@@ -6,3 +6,3 @@ import {

setProperty
} from "./chunk-VG7ICCTT.js";
} from "./chunk-H6R4HHJJ.js";
export {

@@ -9,0 +9,0 @@ getBatchProxy,

@@ -121,3 +121,3 @@ import { P as PublicModel, G as GetInstructions, W as WithInstruction, M as ModelIndex, a as ModelField, b as ModelTrigger, S as SyntaxItem } from './queries-CWtJe_zj.js';

collation?: "BINARY" | "NOCASE" | "RTRIM";
}, "slug" | "type">>) => Chain<FieldOutput<"string">, never>;
}, "type" | "slug">>) => Chain<FieldOutput<"string">, never>;
/**

@@ -150,3 +150,3 @@ * Creates a number field definition returning an object that includes the field type

increment?: boolean;
}, "slug" | "type">>) => Chain<FieldOutput<"number">, never>;
}, "type" | "slug">>) => Chain<FieldOutput<"number">, never>;
/**

@@ -184,3 +184,3 @@ * Creates a link field definition returning an object that includes the field type

};
}, "slug" | "type">>) => Chain<FieldOutput<"link">, never>;
}, "type" | "slug">>) => Chain<FieldOutput<"link">, never>;
/**

@@ -212,3 +212,3 @@ * Creates a JSON field definition returning an object that includes the field type

type: "json";
}, "slug" | "type">>) => Chain<FieldOutput<"json">, never>;
}, "type" | "slug">>) => Chain<FieldOutput<"json">, never>;
/**

@@ -240,3 +240,3 @@ * Creates a date field definition returning an object that includes the field type

type: "date";
}, "slug" | "type">>) => Chain<FieldOutput<"date">, never>;
}, "type" | "slug">>) => Chain<FieldOutput<"date">, never>;
/**

@@ -268,3 +268,3 @@ * Creates a boolean field definition returning an object that includes the field type

type: "boolean";
}, "slug" | "type">>) => Chain<FieldOutput<"boolean">, never>;
}, "type" | "slug">>) => Chain<FieldOutput<"boolean">, never>;
/**

@@ -296,4 +296,4 @@ * Creates a blob field definition returning an object that includes the field type

type: "blob";
}, "slug" | "type">>) => Chain<FieldOutput<"blob">, never>;
}, "type" | "slug">>) => Chain<FieldOutput<"blob">, never>;
export { type SyntaxField, blob, boolean, date, json, link, model, number, string };
import {
getBatchProxy,
getSyntaxProxy
} from "./chunk-VG7ICCTT.js";
// src/utils/errors.ts
var RoninError = class extends Error {
code;
model;
field;
fields;
issues;
constructor(details) {
super(details.message);
this.name = "RoninError";
this.code = details.code;
this.model = details.model;
this.field = details.field;
this.fields = details.fields;
this.issues = details.issues;
}
};
var throwForbiddenModelDefinition = (model2) => {
const { fields, indexes, slug } = model2;
for (const [fieldSlug, _field] of Object.entries(fields ?? {})) {
if (fieldSlug === "id") {
throw new RoninError({
message: 'The field "id" is reserved and cannot be used.',
code: "FIELD_RESERVED",
model: slug,
field: "id"
});
}
}
if (indexes && indexes.length > 0) {
for (const index of indexes) {
if (index.fields.length === 0) {
throw new RoninError({
message: "An index must have at least one field.",
code: "INDEX_NO_FIELDS",
model: slug
});
}
for (const field of index.fields) {
if ("slug" in field && fields && fields[field.slug] === void 0) {
throw new RoninError({
message: `The field ${field.slug} does not exist in this model.`,
code: "FIELD_NOT_DEFINED",
field: field.slug,
model: slug
});
}
}
}
}
};
// src/utils/serializers.ts
var serializeFields = (fields) => {
return Object.entries(fields ?? {}).flatMap(
([key, initialValue]) => {
let value = initialValue?.structure;
if (typeof value === "undefined") {
value = initialValue;
const result = {};
for (const k of Object.keys(value)) {
result[`${key}.${k}`] = value[k];
}
return serializeFields(result);
}
return {
slug: key,
...value
};
}
);
};
var serializePresets = (presets) => {
if (!presets) return void 0;
return Object.entries(presets).map(([key, value]) => {
return {
slug: key,
instructions: value
};
});
};
var serializeTriggers = (triggers) => {
if (!triggers) return void 0;
return triggers.map((trigger) => {
return {
...trigger,
effects: serializeQueries(trigger.effects)
};
});
};
var serializeQueries = (query) => {
const queryObject = getBatchProxy(
() => {
return query();
},
{},
(queries) => {
return queries.map((query2) => query2.structure);
}
);
return queryObject;
};
// src/schema/model.ts
var model = (model2) => {
const {
slug,
pluralSlug,
name,
pluralName,
identifiers,
idPrefix,
fields,
indexes,
presets,
triggers
} = model2;
throwForbiddenModelDefinition(model2);
return {
slug,
pluralSlug,
name,
pluralName,
identifiers,
idPrefix,
fields: serializeFields(fields),
presets: serializePresets(presets),
triggers: serializeTriggers(triggers),
indexes
};
};
// src/schema/primitives.ts
var primitive = (type) => {
return (initialAttributes = {}) => {
return getSyntaxProxy()({ ...initialAttributes, type });
};
};
var string = primitive("string");
var number = primitive("number");
var link = primitive("link");
var json = primitive("json");
var date = primitive("date");
var boolean = primitive("boolean");
var blob = primitive("blob");
blob,
boolean,
date,
json,
link,
model,
number,
string
} from "./chunk-H6R4HHJJ.js";
export {

@@ -152,0 +12,0 @@ blob,

{
"name": "@ronin/syntax",
"version": "0.1.11",
"version": "0.2.0-leo-ron-1071-experimental-49",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Allows for defining RONIN queries and schemas in code.",

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