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

prisma-generator-accel-record

Package Overview
Dependencies
Maintainers
0
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-generator-accel-record - npm Package Compare versions

Comparing version 1.9.1 to 1.10.0

dist/.models.mjs

2

dist/generator.js

@@ -51,3 +51,3 @@ "use strict";

const outputDir = (_a = options.generator.output) === null || _a === void 0 ? void 0 : _a.value;
await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(outputDir, `_types.ts`), (0, index_1.generateIndex)(options));
await (0, writeFileSafely_1.writeFileSafely)(path_1.default.join(outputDir, `_types.ts`), await (0, index_1.generateIndex)(options));
const indexFile = path_1.default.join(outputDir, `index.ts`);

@@ -54,0 +54,0 @@ if (!fs.existsSync(indexFile)) {

@@ -5,7 +5,7 @@ "use strict";

const type_1 = require("./type");
const generateIndex = (options) => {
const generateIndex = async (options) => {
return [
cautionComment,
(0, exports.generateExportAllModels)(options.dmmf.datamodel.models),
(0, type_1.generateTypes)(options),
await (0, type_1.generateTypes)(options),
].join("\n");

@@ -12,0 +12,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateTypes = void 0;
const index_js_1 = require("./index.js");
const relation_js_1 = require("./relation.js");
const wrapper_js_1 = require("./wrapper.js");
const getFilterType = (type) => {

@@ -16,78 +17,3 @@ switch (type) {

};
class FieldWrapper {
constructor(field, datamodel) {
this.field = field;
this.datamodel = datamodel;
this.name = field.name;
this.relationFromFields = field.relationFromFields;
this.hasDefaultValue = field.hasDefaultValue;
this.isRequired = field.isRequired;
this.isList = field.isList;
this.isUpdatedAt = field.isUpdatedAt;
this.type = field.type;
this.relationName = field.relationName;
}
get hasScalarDefault() {
if (typeof this.field.default === "object" &&
"name" in this.field.default) {
return ["uuid", "cuid"].includes(this.field.default.name);
}
return (this.field.default != undefined && typeof this.field.default !== "object");
}
get model() {
const model = this.datamodel.models.find((m) => m.name == this.field.type);
if (model)
return new ModelWrapper(model, this.datamodel);
return undefined;
}
get typeName() {
var _a, _b;
switch (this.field.type) {
case "BigInt":
case "Decimal":
case "Float":
case "Int":
return "number";
case "Bytes":
case "String":
return "string";
case "Boolean":
return "boolean";
case "DateTime":
return "Date";
case "Json":
return "any";
default:
return (_b = (_a = this.model) === null || _a === void 0 ? void 0 : _a.baseModel) !== null && _b !== void 0 ? _b : this.field.type;
}
}
}
class ModelWrapper {
constructor(model, datamodel) {
this.model = model;
this.datamodel = datamodel;
}
get baseModel() {
return `${this.model.name}Model`;
}
get newModel() {
return `New${this.model.name}`;
}
get persistedModel() {
return `${this.model.name}`;
}
get collection() {
return `${this.model.name}Collection`;
}
get meta() {
return `${this.model.name}Meta`;
}
get fileName() {
return (0, index_js_1.toCamelCase)(this.model.name);
}
get fields() {
return this.model.fields.map((f) => new FieldWrapper(f, this.datamodel));
}
}
const generateTypes = (options) => {
const generateTypes = async (options) => {
let data = `import {

@@ -102,2 +28,4 @@ registerModel,

function meta<T>(model: T): Meta<T>;
interface Relation<T, M> {${await (0, relation_js_1.relationMethods)(options)}}
}

@@ -107,3 +35,3 @@

const meta = options.dmmf.datamodel.models
.map((model) => new ModelWrapper(model, options.dmmf.datamodel))
.map((model) => new wrapper_js_1.ModelWrapper(model, options.dmmf.datamodel))
.map((model) => `T extends typeof ${model.baseModel} | ${model.baseModel} ? ${model.meta} :`)

@@ -114,3 +42,3 @@ .join("\n ");

for (const _model of options.dmmf.datamodel.models) {
const model = new ModelWrapper(_model, options.dmmf.datamodel);
const model = new wrapper_js_1.ModelWrapper(_model, options.dmmf.datamodel);
const associationColumns = model.fields

@@ -117,0 +45,0 @@ .filter((f) => { var _a, _b; return f.relationName && ((_b = (_a = f.relationFromFields) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0; })

{
"name": "prisma-generator-accel-record",
"version": "1.9.1",
"version": "1.10.0",
"description": "",

@@ -34,2 +34,3 @@ "main": "dist/generator.js",

"@prisma/generator-helper": "^5.0.0",
"esbuild": ">=0.21.0",
"prettier": "^3.0.0"

@@ -36,0 +37,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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