Skip to content

Commit

Permalink
chore: Update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
unlight committed Sep 21, 2021
1 parent d757988 commit 21446a2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 17 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020
Copyright (c) 2021

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"eslint:fix": "npm run eslint -- --fix",
"build": "sh Taskfile bundle",
"prisma:g": "node node_modules/prisma/build/index.js generate",
"format": "npx prettier src --write",
"format": "npx prettier ./@generated --write",
"regen": "rm -rf src/@generated && npm run prisma:g && npm run eslint:fix && npm run format",
"example": "ts-node-dev src/example/main.ts",
"example": "ts-node-dev example/main.ts",
"clean_cache": "rm -rf node_modules/.cache",
"compatibilty_check": "sh Taskfile compatibilty_check",
"commit": "cz"
Expand All @@ -47,7 +47,7 @@
}
},
"dependencies": {
"@prisma/generator-helper": "^3.0.1",
"@prisma/generator-helper": "^3.0.2",
"await-event-emitter": "^2.0.2",
"filenamify": "4.X",
"flat": "^5.0.2",
Expand All @@ -59,9 +59,7 @@
"pupa": "2.X",
"ts-morph": ">=11 <=12"
},
"peerDependencies": {
"@prisma/client": ">=2.16 <=3"
},
"peerDependencies": {},
"devDependencies": {
"@arkweid/lefthook": "0.7.6",
"@commitlint/cli": "^13.1.0",
Expand All @@ -70,20 +68,20 @@
"@nestjs/core": "^8.0.6",
"@nestjs/graphql": "^9.0.4",
"@nestjs/platform-express": "^8.0.6",
"@paljs/plugins": "^3.8.3",
"@prisma/client": "^3.0.1",
"@paljs/plugins": "^4.0.7",
"@prisma/client": "^3.0.2",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.1",
"@types/find-cache-dir": "^3.2.1",
"@types/flat": "^5.0.2",
"@types/lodash": "^4.14.172",
"@types/mocha": "^9.0.0",
"@types/node": "^16.7.13",
"@types/node": "^16.9.1",
"@types/pluralize": "^0.0.29",
"@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0",
"apollo-server-express": "^3.3.0",
"c8": "^7.8.0",
"c8": "^7.9.0",
"class-transformer": "^0.4.0",
"class-validator": "^0.13.1",
"commitizen": "^4.2.4",
Expand All @@ -103,7 +101,7 @@
"eslint-plugin-total-functions": "^4.10.1",
"eslint-plugin-unicorn": "^35.0.0",
"eslint-plugin-wix-editor": "^3.3.0",
"expect": "^27.1.0",
"expect": "^27.1.1",
"find-cache-dir": "^3.3.2",
"git-branch-is": "^4.0.0",
"graphql": "^15.5.3",
Expand All @@ -112,8 +110,8 @@
"mocha": "^9.1.1",
"ololog": "^1.1.175",
"precise-commits": "^1.0.2",
"prettier": "^2.3.2",
"prisma": "^3.0.1",
"prettier": "^2.4.0",
"prisma": "^3.0.2",
"prisma-graphql-type-decimal": "^1.0.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.3.0",
Expand Down
2 changes: 0 additions & 2 deletions src/handlers/args-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export function argsType(field: SchemaField, args: EventArguments) {
fields: [...field.args],
};

// console.dir(field, { depth: 4 });

if (
!field.args.some(x => x.name === '_count') &&
[`${modelName}AggregateArgs`, `${modelName}GroupByArgs`].includes(className)
Expand Down
42 changes: 41 additions & 1 deletion src/helpers/create-config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import { ok } from 'assert';
import filenamify from 'filenamify';
import { unflatten } from 'flat';
import JSON5 from 'json5';
import { Dictionary, merge, trim } from 'lodash';
import outmatch from 'outmatch';

import { ReExport } from '../handlers/re-export';
import { FieldSetting } from '../types';

type ConfigFieldSetting = Partial<Omit<FieldSetting, 'name'>>;
type DecorateElement = {
isMatchField: (s: string) => boolean;
isMatchType: (s: string) => boolean;
from: string;
name: string;
arguments?: string[];
namedImport: boolean;
defaultImport?: string | true;
namespaceImport?: string;
};

export function createConfig(data: Record<string, unknown>) {
const config = merge({}, unflatten(data, { delimiter: '_' })) as Record<
string,
Expand Down Expand Up @@ -37,7 +52,6 @@ export function createConfig(data: Record<string, unknown>) {
}
}

type ConfigFieldSetting = Partial<Omit<FieldSetting, 'name'>>;
const fields: Record<string, ConfigFieldSetting | undefined> = Object.fromEntries(
Object.entries<Dictionary<string | undefined>>(
(config.fields ?? {}) as Record<string, Dictionary<string | undefined>>,
Expand All @@ -58,6 +72,31 @@ export function createConfig(data: Record<string, unknown>) {
}),
);

const decorate: DecorateElement[] = [];
const configDecorate: (Record<string, string> | undefined)[] = Object.values(
(config.decorate as any) || {},
);

for (const element of configDecorate) {
if (!element) continue;
ok(
element.from && element.name,
`Missed 'from' or 'name' part in configuration for decorate`,
);
decorate.push({
isMatchField: outmatch(element.field, { separator: false }),
isMatchType: outmatch(element.type, { separator: false }),
from: element.from,
name: element.name,
namedImport: toBoolean(element.namedImport),
defaultImport: toBoolean(element.defaultImport)
? true
: element.defaultImport,
namespaceImport: element.namespaceImport,
arguments: element.arguments ? JSON5.parse(element.arguments) : undefined,
});
}

return {
outputFilePattern,
tsConfigFilePath: undefined as string | undefined,
Expand All @@ -71,6 +110,7 @@ export function createConfig(data: Record<string, unknown>) {
purgeOutput: toBoolean(config.purgeOutput),
useInputType: createUseInputType(config.useInputType as any),
noTypeId: toBoolean(config.noTypeId),
decorate,
};
}

Expand Down

0 comments on commit 21446a2

Please sign in to comment.