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
100
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.10 to 0.1.11-leo-ron-1071-experimental-48

dist/chunk-M3PT4GSI.js

2

dist/queries.js

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

setProperty
} from "./chunk-3QDU3COW.js";
} from "./chunk-M3PT4GSI.js";
export {

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

import {
getBatchProxy,
getSyntaxProxy
} from "./chunk-3QDU3COW.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-M3PT4GSI.js";
export {

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

{
"name": "@ronin/syntax",
"version": "0.1.10",
"version": "0.1.11-leo-ron-1071-experimental-48",
"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