Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔒 security: Upgrade deps #59

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,907 changes: 582 additions & 2,325 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,23 @@
"url": "https://github.com/notiz-dev/prisma-dbml-generator/issues"
},
"dependencies": {
"@prisma/generator-helper": "5.0.0",
"@prisma/internals": "5.0.0"
"@prisma/generator-helper": "5.22.0",
"@prisma/internals": "5.22.0"
},
"devDependencies": {
"@prisma/client": "5.0.0",
"@antfu/ni": "^0.21.4",
"@opentelemetry/api": "^1.9.0",
"@prisma/client": "5.22.0",
"@types/jest": "^29.2.4",
"@types/node": "18.11.0",
"dotenv": "^16.4.7",
"fp-ts": "^2.16.9",
"fs-jetpack": "^5.1.0",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.5",
"jest": "29.7.0",
"prettier": "3.2.5",
"prisma": "5.0.0",
"prisma": "5.22.0",
"ts-jest": "29.1.2",
"ts-toolbelt": "^9.6.0",
"typescript": "5.3.3"
Expand Down
6 changes: 3 additions & 3 deletions src/generator/enums.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DMMF } from '@prisma/generator-helper';
import { DMMF, ReadonlyDeep } from '@prisma/generator-helper';

export function generateEnums(enums: DMMF.DatamodelEnum[]): string[] {
export function generateEnums(enums: ReadonlyDeep<DMMF.DatamodelEnum[]>): string[] {
return enums.map(
(e) => `Enum ${e.name} {\n` + generateEnumValues(e.values) + '\n}',
);
}

const generateEnumValues = (values: DMMF.EnumValue[]): string => {
const generateEnumValues = (values: ReadonlyDeep<DMMF.EnumValue[]>): string => {
return values.map((value) => ` ${value.name}`).join('\n');
};
14 changes: 7 additions & 7 deletions src/generator/many-to-many-tables.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getModelByType } from './model';
import { DMMF } from '@prisma/generator-helper';
import { DMMF, ReadonlyDeep } from '@prisma/generator-helper';

export function generateManyToManyTables(
models: DMMF.Model[],
models: ReadonlyDeep<DMMF.Model[]>,
mapToDbSchema: boolean = false,
): string[] {
const manyToManyFields = filterManyToManyRelationFields(models);
Expand All @@ -14,7 +14,7 @@ export function generateManyToManyTables(

function generateTables(
manyToManyFields: DMMF.Field[],
models: DMMF.Model[],
models: ReadonlyDeep<DMMF.Model[]>,
manyToManyTables: string[] = [],
mapToDbSchema: boolean = false,
): string[] {
Expand Down Expand Up @@ -54,7 +54,7 @@ function generateTables(

function generateJoinFields(
fields: [DMMF.Field, DMMF.Field],
models: DMMF.Model[],
models: ReadonlyDeep<DMMF.Model[]>,
mapToDbSchema: boolean = false,
): string {
return fields
Expand All @@ -64,7 +64,7 @@ function generateJoinFields(

function joinField(
field: DMMF.Field,
models: DMMF.Model[],
models: ReadonlyDeep<DMMF.Model[]>,
mapToDbSchema: boolean = false,
): string {
const fieldName = mapToDbSchema
Expand All @@ -77,7 +77,7 @@ function joinField(
)} [ref: > ${fieldName}.${field.relationToFields![0]}]`;
}

function getJoinIdType(joinField: DMMF.Field, models: DMMF.Model[]): string {
function getJoinIdType(joinField: DMMF.Field, models: ReadonlyDeep<DMMF.Model[]>): string {
const joinIdField = models
.filter((model) => model.name === joinField.type)
.map(
Expand All @@ -90,7 +90,7 @@ function getJoinIdType(joinField: DMMF.Field, models: DMMF.Model[]): string {
return joinIdField.type;
}

function filterManyToManyRelationFields(models: DMMF.Model[]): DMMF.Field[] {
function filterManyToManyRelationFields(models: ReadonlyDeep<DMMF.Model[]>): DMMF.Field[] {
return models
.map((model) =>
model.fields
Expand Down
4 changes: 2 additions & 2 deletions src/generator/model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DMMF } from '@prisma/generator-helper';
import { DMMF, ReadonlyDeep } from '@prisma/generator-helper';

export const getModelByType = (
models: DMMF.Model[],
models: ReadonlyDeep<DMMF.Model[]>,
type: string,
): DMMF.Model | undefined => {
return models.find((model) => model.name === type);
Expand Down
10 changes: 5 additions & 5 deletions src/generator/relations.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { DMMF } from '@prisma/generator-helper';
import { DMMF, ReadonlyDeep } from '@prisma/generator-helper';
import { getModelByType } from './model';

export const oneToOne = '-';
export const oneToMany = '<';
export const manyToOne = '>';

export function generateRelations(
models: DMMF.Model[],
models: ReadonlyDeep<DMMF.Model[]>,
mapToDbSchema: boolean = false,
): string[] {
const refs: string[] = [];
Expand Down Expand Up @@ -54,7 +54,7 @@ export function generateRelations(
}

const getRelationOperator = (
models: DMMF.Model[],
models: ReadonlyDeep<DMMF.Model[]>,
from: string,
to: string,
): string => {
Expand All @@ -65,12 +65,12 @@ const getRelationOperator = (

// Composite foreign keys:
// Ref: merchant_periods.(merchant_id, country_code) > merchants.(id, country_code)
const combineKeys = (keys: string[]): string => {
const combineKeys = (keys: Readonly<string[]>): string => {
return keys.length > 1 ? `(${keys.join(', ')})` : keys[0];
};

const getReferentialActions = (
models: DMMF.Model[],
models: ReadonlyDeep<DMMF.Model[]>,
from: string,
to: string,
): string => {
Expand Down
14 changes: 7 additions & 7 deletions src/generator/table.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DBMLKeywords, PrismaScalars } from './../keywords';
import { DMMF } from '@prisma/generator-helper';
import { DMMF, ReadonlyDeep } from '@prisma/generator-helper';
import { getModelByType } from './model';

export function generateTables(
models: DMMF.Model[],
models: ReadonlyDeep<DMMF.Model[]>,
mapToDbSchema: boolean = false,
includeRelationFields: boolean = true,
): string[] {
Expand Down Expand Up @@ -40,19 +40,19 @@ const generateTableIndexes = (model: DMMF.Model): string => {
: '';
};

const hasCompositeUniqueIndices = (uniqueFields: string[][]): boolean => {
const hasCompositeUniqueIndices = (uniqueFields: ReadonlyDeep<ReadonlyDeep<string[]>[]>): boolean => {
return uniqueFields.filter((composite) => composite.length > 1).length > 0;
};

const generateTableBlockId = (primaryFields: string[] | undefined): string => {
const generateTableBlockId = (primaryFields: ReadonlyDeep<string[]> | undefined): string => {
if (primaryFields === undefined || primaryFields.length === 0) {
return '';
}
return ` (${primaryFields.join(', ')}) [${DBMLKeywords.Pk}]`;
};

const generateTableCompositeUniqueIndex = (
uniqueFields: string[][],
uniqueFields: ReadonlyDeep<ReadonlyDeep<string[]>[]>,
): string => {
return uniqueFields
.filter((composite) => composite.length > 1)
Expand All @@ -68,8 +68,8 @@ const generateTableDocumentation = (model: DMMF.Model): string => {
};

const generateFields = (
fields: DMMF.Field[],
models: DMMF.Model[],
fields: ReadonlyDeep<DMMF.Field[]>,
models: ReadonlyDeep<DMMF.Model[]>,
mapToDbSchema: boolean = false,
includeRelationFields: boolean = true,
): string => {
Expand Down
Loading