@vnodes/prisma-plugin-helpers 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/bin/version.mjs +12 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/dto-name-suffixes.d.ts +7 -0
- package/dist/lib/dto-name-suffixes.d.ts.map +1 -0
- package/dist/lib/dto-name-suffixes.js +7 -0
- package/dist/lib/dto-name-suffixes.js.map +1 -0
- package/dist/lib/extract-prop-options.d.ts +2 -0
- package/dist/lib/extract-prop-options.d.ts.map +1 -0
- package/dist/lib/extract-prop-options.js +14 -0
- package/dist/lib/extract-prop-options.js.map +1 -0
- package/dist/lib/is-cout-prop.d.ts +3 -0
- package/dist/lib/is-cout-prop.d.ts.map +1 -0
- package/dist/lib/is-cout-prop.js +15 -0
- package/dist/lib/is-cout-prop.js.map +1 -0
- package/dist/lib/is-find-by-prop.d.ts +3 -0
- package/dist/lib/is-find-by-prop.d.ts.map +1 -0
- package/dist/lib/is-find-by-prop.js +13 -0
- package/dist/lib/is-find-by-prop.js.map +1 -0
- package/dist/lib/is-foreign-key-prop.d.ts +3 -0
- package/dist/lib/is-foreign-key-prop.d.ts.map +1 -0
- package/dist/lib/is-foreign-key-prop.js +8 -0
- package/dist/lib/is-foreign-key-prop.js.map +1 -0
- package/dist/lib/is-input-prop.d.ts +4 -0
- package/dist/lib/is-input-prop.d.ts.map +1 -0
- package/dist/lib/is-input-prop.js +19 -0
- package/dist/lib/is-input-prop.js.map +1 -0
- package/dist/lib/is-relation-prop.d.ts +3 -0
- package/dist/lib/is-relation-prop.d.ts.map +1 -0
- package/dist/lib/is-relation-prop.js +5 -0
- package/dist/lib/is-relation-prop.js.map +1 -0
- package/dist/lib/is-requried-prop.d.ts +4 -0
- package/dist/lib/is-requried-prop.d.ts.map +1 -0
- package/dist/lib/is-requried-prop.js +17 -0
- package/dist/lib/is-requried-prop.js.map +1 -0
- package/dist/lib/is-search-prop.d.ts +3 -0
- package/dist/lib/is-search-prop.d.ts.map +1 -0
- package/dist/lib/is-search-prop.js +11 -0
- package/dist/lib/is-search-prop.js.map +1 -0
- package/dist/lib/is-soft-delete-prop.d.ts +3 -0
- package/dist/lib/is-soft-delete-prop.d.ts.map +1 -0
- package/dist/lib/is-soft-delete-prop.js +5 -0
- package/dist/lib/is-soft-delete-prop.js.map +1 -0
- package/dist/lib/is-timestamp-prop.d.ts +3 -0
- package/dist/lib/is-timestamp-prop.d.ts.map +1 -0
- package/dist/lib/is-timestamp-prop.js +10 -0
- package/dist/lib/is-timestamp-prop.js.map +1 -0
- package/dist/lib/parse-prop-options.d.ts +5 -0
- package/dist/lib/parse-prop-options.d.ts.map +1 -0
- package/dist/lib/parse-prop-options.js +13 -0
- package/dist/lib/parse-prop-options.js.map +1 -0
- package/dist/lib/prop-type.d.ts +4 -0
- package/dist/lib/prop-type.d.ts.map +1 -0
- package/dist/lib/prop-type.js +53 -0
- package/dist/lib/prop-type.js.map +1 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img srcset="./assets/favicon.png, https://vnodes.github.io/vnodes/plugins/prisma-plugin-helpers/assets/favicon.png" alt="Logo" width="200" height="200" style="border-radius: 100%"/>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
## @vnodes/prisma-plugin-helpers
|
|
12
|
+
|
|
13
|
+
@vnodes/prisma-plugin-helpers
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @vnodes/prisma-plugin-helpers
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 💖 Support My Work
|
|
22
|
+
|
|
23
|
+
If you find my open-source contributions or the **@vnodes/prisma-plugin-helpers** project helpful, consider supporting my work. Your sponsorship helps me maintain these projects and explore new enterprise patterns.
|
|
24
|
+
|
|
25
|
+
[](https://cash.app/$puqlib)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🤝 Connect with Me
|
|
30
|
+
|
|
31
|
+
<p align="left">
|
|
32
|
+
<a href="mailto:robert.brightline+vnodes-prisma-plugin-helpers@gmail.com">
|
|
33
|
+
<img src="https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=gmail&logoColor=white" />
|
|
34
|
+
</a>
|
|
35
|
+
</p>
|
package/bin/version.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
const packageJsonPath = join(__dirname, '..', 'package.json');
|
|
10
|
+
const packageJson = readFileSync(packageJsonPath, { encoding: 'utf-8' });
|
|
11
|
+
const version = JSON.parse(packageJson).version;
|
|
12
|
+
console.log(version);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './lib/dto-name-suffixes.js';
|
|
2
|
+
export * from './lib/extract-prop-options.js';
|
|
3
|
+
export * from './lib/is-cout-prop.js';
|
|
4
|
+
export * from './lib/is-find-by-prop.js';
|
|
5
|
+
export * from './lib/is-foreign-key-prop.js';
|
|
6
|
+
export * from './lib/is-input-prop.js';
|
|
7
|
+
export * from './lib/is-relation-prop.js';
|
|
8
|
+
export * from './lib/is-requried-prop.js';
|
|
9
|
+
export * from './lib/is-search-prop.js';
|
|
10
|
+
export * from './lib/is-soft-delete-prop.js';
|
|
11
|
+
export * from './lib/is-timestamp-prop.js';
|
|
12
|
+
export * from './lib/parse-prop-options.js';
|
|
13
|
+
export * from './lib/prop-type.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @index(['./**/*.ts', '!./**/*.{spec,test}.ts'], f => `export * from '${f.path}.js'`)
|
|
2
|
+
export * from './lib/dto-name-suffixes.js';
|
|
3
|
+
export * from './lib/extract-prop-options.js';
|
|
4
|
+
export * from './lib/is-cout-prop.js';
|
|
5
|
+
export * from './lib/is-find-by-prop.js';
|
|
6
|
+
export * from './lib/is-foreign-key-prop.js';
|
|
7
|
+
export * from './lib/is-input-prop.js';
|
|
8
|
+
export * from './lib/is-relation-prop.js';
|
|
9
|
+
export * from './lib/is-requried-prop.js';
|
|
10
|
+
export * from './lib/is-search-prop.js';
|
|
11
|
+
export * from './lib/is-soft-delete-prop.js';
|
|
12
|
+
export * from './lib/is-timestamp-prop.js';
|
|
13
|
+
export * from './lib/parse-prop-options.js';
|
|
14
|
+
export * from './lib/prop-type.js';
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @index(['./**/*.ts', '!./**/*.{spec,test}.ts'], f => `export * from '${f.path}.js'`)\nexport * from './lib/dto-name-suffixes.js';\nexport * from './lib/extract-prop-options.js';\nexport * from './lib/is-cout-prop.js';\nexport * from './lib/is-find-by-prop.js';\nexport * from './lib/is-foreign-key-prop.js';\nexport * from './lib/is-input-prop.js';\nexport * from './lib/is-relation-prop.js';\nexport * from './lib/is-requried-prop.js';\nexport * from './lib/is-search-prop.js';\nexport * from './lib/is-soft-delete-prop.js';\nexport * from './lib/is-timestamp-prop.js';\nexport * from './lib/parse-prop-options.js';\nexport * from './lib/prop-type.js';\n"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,cAAc,6BAA6B;AAC3C,cAAc,gCAAgC;AAC9C,cAAc,wBAAwB;AACtC,cAAc,2BAA2B;AACzC,cAAc,+BAA+B;AAC7C,cAAc,yBAAyB;AACvC,cAAc,4BAA4B;AAC1C,cAAc,4BAA4B;AAC1C,cAAc,0BAA0B;AACxC,cAAc,+BAA+B;AAC7C,cAAc,6BAA6B;AAC3C,cAAc,8BAA8B;AAC5C,cAAc,qBAAqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto-name-suffixes.d.ts","sourceRoot":"","sources":["../../src/lib/dto-name-suffixes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/dto-name-suffixes.ts"],"sourcesContent":["export const DtoNameSuffix = {\n Create: 'Create',\n Update: 'Update',\n Query: 'Query',\n} as const;\n\nexport type DtoNameSuffix = keyof typeof DtoNameSuffix;\n"],"names":["DtoNameSuffix","Create","Update","Query"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB;IACzBC,QAAQ;IACRC,QAAQ;IACRC,OAAO;AACX,EAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-prop-options.d.ts","sourceRoot":"","sources":["../../src/lib/extract-prop-options.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAStE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function extractPropOptions(doc) {
|
|
2
|
+
const matchedAnnotations = doc.matchAll(/@(\w+)\((\d{0,}|\w{0,})\)/gi);
|
|
3
|
+
return [
|
|
4
|
+
...matchedAnnotations
|
|
5
|
+
].reduce((p, c)=>{
|
|
6
|
+
if (c[2] === undefined || c[2] === '') {
|
|
7
|
+
c[2] = 'true';
|
|
8
|
+
}
|
|
9
|
+
p[c[1]] = c[2];
|
|
10
|
+
return p;
|
|
11
|
+
}, {});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=extract-prop-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/extract-prop-options.ts"],"sourcesContent":["export function extractPropOptions(doc: string): Record<string, string> {\n const matchedAnnotations = doc.matchAll(/@(\\w+)\\((\\d{0,}|\\w{0,})\\)/gi);\n return [...matchedAnnotations].reduce((p: Record<string, string>, c) => {\n if (c[2] === undefined || c[2] === '') {\n c[2] = 'true';\n }\n p[c[1]] = c[2];\n return p;\n }, {});\n}\n"],"names":["extractPropOptions","doc","matchedAnnotations","matchAll","reduce","p","c","undefined"],"mappings":"AAAA,OAAO,SAASA,mBAAmBC,GAAW;IAC1C,MAAMC,qBAAqBD,IAAIE,QAAQ,CAAC;IACxC,OAAO;WAAID;KAAmB,CAACE,MAAM,CAAC,CAACC,GAA2BC;QAC9D,IAAIA,CAAC,CAAC,EAAE,KAAKC,aAAaD,CAAC,CAAC,EAAE,KAAK,IAAI;YACnCA,CAAC,CAAC,EAAE,GAAG;QACX;QACAD,CAAC,CAACC,CAAC,CAAC,EAAE,CAAC,GAAGA,CAAC,CAAC,EAAE;QACd,OAAOD;IACX,GAAG,CAAC;AACR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-cout-prop.d.ts","sourceRoot":"","sources":["../../src/lib/is-cout-prop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIrD,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAMtD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isRelationProp } from './is-relation-prop.js';
|
|
2
|
+
import { isTimestampProp } from './is-timestamp-prop.js';
|
|
3
|
+
export function isCountProp(field) {
|
|
4
|
+
if ([
|
|
5
|
+
field.name === 'uuid',
|
|
6
|
+
field.name === 'id',
|
|
7
|
+
isTimestampProp(field),
|
|
8
|
+
isRelationProp(field)
|
|
9
|
+
].some((e)=>e)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=is-cout-prop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/is-cout-prop.ts"],"sourcesContent":["import type { DMMF } from '@prisma/generator-helper';\nimport { isRelationProp } from './is-relation-prop.js';\nimport { isTimestampProp } from './is-timestamp-prop.js';\n\nexport function isCountProp(field: DMMF.Field): boolean {\n if ([field.name === 'uuid', field.name === 'id', isTimestampProp(field), isRelationProp(field)].some((e) => e)) {\n return false;\n }\n\n return true;\n}\n"],"names":["isRelationProp","isTimestampProp","isCountProp","field","name","some","e"],"mappings":"AACA,SAASA,cAAc,QAAQ,wBAAwB;AACvD,SAASC,eAAe,QAAQ,yBAAyB;AAEzD,OAAO,SAASC,YAAYC,KAAiB;IACzC,IAAI;QAACA,MAAMC,IAAI,KAAK;QAAQD,MAAMC,IAAI,KAAK;QAAMH,gBAAgBE;QAAQH,eAAeG;KAAO,CAACE,IAAI,CAAC,CAACC,IAAMA,IAAI;QAC5G,OAAO;IACX;IAEA,OAAO;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-find-by-prop.d.ts","sourceRoot":"","sources":["../../src/lib/is-find-by-prop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIrD,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAM7C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isRelationProp } from './is-relation-prop.js';
|
|
2
|
+
import { isTimestampProp } from './is-timestamp-prop.js';
|
|
3
|
+
export function isFindByProp(field) {
|
|
4
|
+
if ([
|
|
5
|
+
isTimestampProp(field),
|
|
6
|
+
isRelationProp(field)
|
|
7
|
+
].some((e)=>e)) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=is-find-by-prop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/is-find-by-prop.ts"],"sourcesContent":["import type { DMMF } from '@prisma/generator-helper';\nimport { isRelationProp } from './is-relation-prop.js';\nimport { isTimestampProp } from './is-timestamp-prop.js';\n\nexport function isFindByProp(field: DMMF.Field) {\n if ([isTimestampProp(field), isRelationProp(field)].some((e) => e)) {\n return false;\n }\n\n return true;\n}\n"],"names":["isRelationProp","isTimestampProp","isFindByProp","field","some","e"],"mappings":"AACA,SAASA,cAAc,QAAQ,wBAAwB;AACvD,SAASC,eAAe,QAAQ,yBAAyB;AAEzD,OAAO,SAASC,aAAaC,KAAiB;IAC1C,IAAI;QAACF,gBAAgBE;QAAQH,eAAeG;KAAO,CAACC,IAAI,CAAC,CAACC,IAAMA,IAAI;QAChE,OAAO;IACX;IAEA,OAAO;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-foreign-key-prop.d.ts","sourceRoot":"","sources":["../../src/lib/is-foreign-key-prop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,WAOnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/is-foreign-key-prop.ts"],"sourcesContent":["import type { DMMF } from '@prisma/generator-helper';\n\nexport function isForeinkeyProp(model: DMMF.Model, field: DMMF.Field) {\n const found = model.fields\n .filter((e) => e.kind === 'object')\n .find((e) => {\n return e.relationToFields?.includes(field.name);\n });\n return !!found;\n}\n"],"names":["isForeinkeyProp","model","field","found","fields","filter","e","kind","find","relationToFields","includes","name"],"mappings":"AAEA,OAAO,SAASA,gBAAgBC,KAAiB,EAAEC,KAAiB;IAChE,MAAMC,QAAQF,MAAMG,MAAM,CACrBC,MAAM,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,UACzBC,IAAI,CAAC,CAACF;QACH,OAAOA,EAAEG,gBAAgB,EAAEC,SAASR,MAAMS,IAAI;IAClD;IACJ,OAAO,CAAC,CAACR;AACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-input-prop.d.ts","sourceRoot":"","sources":["../../src/lib/is-input-prop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,iBAAiB,WAkB7E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isRelationProp } from './is-relation-prop.js';
|
|
2
|
+
import { isTimestampProp } from './is-timestamp-prop.js';
|
|
3
|
+
export function isInputProp(field, _propOptions) {
|
|
4
|
+
if (field.isId) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
if (field.isGenerated) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (isRelationProp(field)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (isTimestampProp(field)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=is-input-prop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/is-input-prop.ts"],"sourcesContent":["import type { DMMF } from '@prisma/generator-helper';\nimport { isRelationProp } from './is-relation-prop.js';\nimport { isTimestampProp } from './is-timestamp-prop.js';\nimport type { ParsedPropOptions } from './parse-prop-options.js';\n\nexport function isInputProp(field: DMMF.Field, _propOptions: ParsedPropOptions) {\n if (field.isId) {\n return false;\n }\n\n if (field.isGenerated) {\n return false;\n }\n\n if (isRelationProp(field)) {\n return false;\n }\n\n if (isTimestampProp(field)) {\n return false;\n }\n\n return true;\n}\n"],"names":["isRelationProp","isTimestampProp","isInputProp","field","_propOptions","isId","isGenerated"],"mappings":"AACA,SAASA,cAAc,QAAQ,wBAAwB;AACvD,SAASC,eAAe,QAAQ,yBAAyB;AAGzD,OAAO,SAASC,YAAYC,KAAiB,EAAEC,YAA+B;IAC1E,IAAID,MAAME,IAAI,EAAE;QACZ,OAAO;IACX;IAEA,IAAIF,MAAMG,WAAW,EAAE;QACnB,OAAO;IACX;IAEA,IAAIN,eAAeG,QAAQ;QACvB,OAAO;IACX;IAEA,IAAIF,gBAAgBE,QAAQ;QACxB,OAAO;IACX;IAEA,OAAO;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-relation-prop.d.ts","sourceRoot":"","sources":["../../src/lib/is-relation-prop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAE/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/is-relation-prop.ts"],"sourcesContent":["import type { DMMF } from '@prisma/generator-helper';\n\nexport function isRelationProp(field: DMMF.Field) {\n return field.kind === 'object';\n}\n"],"names":["isRelationProp","field","kind"],"mappings":"AAEA,OAAO,SAASA,eAAeC,KAAiB;IAC5C,OAAOA,MAAMC,IAAI,KAAK;AAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-requried-prop.d.ts","sourceRoot":"","sources":["../../src/lib/is-requried-prop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,iBAAiB,WAkB/E"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function isRequiredProp(field, propOptions) {
|
|
2
|
+
if (propOptions.required === 'true') {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
if (propOptions.required === 'false' || propOptions.nullable === 'true') {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (field.isList) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (field.isRequired === true) {
|
|
12
|
+
return !field.hasDefaultValue;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=is-requried-prop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/is-requried-prop.ts"],"sourcesContent":["import type { DMMF } from '@prisma/generator-helper';\nimport type { ParsedPropOptions } from './parse-prop-options.js';\n\nexport function isRequiredProp(field: DMMF.Field, propOptions: ParsedPropOptions) {\n if (propOptions.required === 'true') {\n return true;\n }\n\n if (propOptions.required === 'false' || propOptions.nullable === 'true') {\n return false;\n }\n\n if (field.isList) {\n return false;\n }\n\n if (field.isRequired === true) {\n return !field.hasDefaultValue;\n }\n\n return false;\n}\n"],"names":["isRequiredProp","field","propOptions","required","nullable","isList","isRequired","hasDefaultValue"],"mappings":"AAGA,OAAO,SAASA,eAAeC,KAAiB,EAAEC,WAA8B;IAC5E,IAAIA,YAAYC,QAAQ,KAAK,QAAQ;QACjC,OAAO;IACX;IAEA,IAAID,YAAYC,QAAQ,KAAK,WAAWD,YAAYE,QAAQ,KAAK,QAAQ;QACrE,OAAO;IACX;IAEA,IAAIH,MAAMI,MAAM,EAAE;QACd,OAAO;IACX;IAEA,IAAIJ,MAAMK,UAAU,KAAK,MAAM;QAC3B,OAAO,CAACL,MAAMM,eAAe;IACjC;IAEA,OAAO;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-search-prop.d.ts","sourceRoot":"","sources":["../../src/lib/is-search-prop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAUvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/is-search-prop.ts"],"sourcesContent":["import type { DMMF } from '@prisma/generator-helper';\n\nexport function isSearchProp(field: DMMF.Field): boolean {\n if (field.name === 'uuid' || field.name === 'id') {\n return false;\n }\n\n if (field.type === 'String') {\n return true;\n }\n\n return false;\n}\n"],"names":["isSearchProp","field","name","type"],"mappings":"AAEA,OAAO,SAASA,aAAaC,KAAiB;IAC1C,IAAIA,MAAMC,IAAI,KAAK,UAAUD,MAAMC,IAAI,KAAK,MAAM;QAC9C,OAAO;IACX;IAEA,IAAID,MAAME,IAAI,KAAK,UAAU;QACzB,OAAO;IACX;IAEA,OAAO;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-soft-delete-prop.d.ts","sourceRoot":"","sources":["../../src/lib/is-soft-delete-prop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAEjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/is-soft-delete-prop.ts"],"sourcesContent":["import type { DMMF } from '@prisma/generator-helper';\n\nexport function isSoftDeleteProp(field: DMMF.Field) {\n return /^deletedAt$/i.test(field.name) && field.type === 'DateTime';\n}\n"],"names":["isSoftDeleteProp","field","test","name","type"],"mappings":"AAEA,OAAO,SAASA,iBAAiBC,KAAiB;IAC9C,OAAO,eAAeC,IAAI,CAACD,MAAME,IAAI,KAAKF,MAAMG,IAAI,KAAK;AAC7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-timestamp-prop.d.ts","sourceRoot":"","sources":["../../src/lib/is-timestamp-prop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,WAOhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/is-timestamp-prop.ts"],"sourcesContent":["import type { DMMF } from '@prisma/generator-helper';\n\nexport function isTimestampProp(field: DMMF.Field) {\n if (field.kind === 'scalar') {\n if (field.type === 'DateTime') {\n return /^createdat|updatedat|deletedat$/i.test(field.name);\n }\n }\n return false;\n}\n"],"names":["isTimestampProp","field","kind","type","test","name"],"mappings":"AAEA,OAAO,SAASA,gBAAgBC,KAAiB;IAC7C,IAAIA,MAAMC,IAAI,KAAK,UAAU;QACzB,IAAID,MAAME,IAAI,KAAK,YAAY;YAC3B,OAAO,mCAAmCC,IAAI,CAACH,MAAMI,IAAI;QAC7D;IACJ;IACA,OAAO;AACX"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type PropOptions } from '@vnodes/prop';
|
|
2
|
+
import type { StringRecord } from '@vnodes/types';
|
|
3
|
+
export type ParsedPropOptions = Partial<StringRecord<PropOptions>>;
|
|
4
|
+
export declare function parsePropOptions(options: Record<string, string>): ParsedPropOptions;
|
|
5
|
+
//# sourceMappingURL=parse-prop-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-prop-options.d.ts","sourceRoot":"","sources":["../../src/lib/parse-prop-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;AAEnE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,iBAAiB,CAUnF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { propOptionKeys } from '@vnodes/prop';
|
|
2
|
+
export function parsePropOptions(options) {
|
|
3
|
+
const result = {};
|
|
4
|
+
for (const key of propOptionKeys){
|
|
5
|
+
const value = options[key];
|
|
6
|
+
if (value !== undefined) {
|
|
7
|
+
result[key] = value;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=parse-prop-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/parse-prop-options.ts"],"sourcesContent":["import { type PropOptions, propOptionKeys } from '@vnodes/prop';\nimport type { StringRecord } from '@vnodes/types';\n\nexport type ParsedPropOptions = Partial<StringRecord<PropOptions>>;\n\nexport function parsePropOptions(options: Record<string, string>): ParsedPropOptions {\n const result = {} as ParsedPropOptions;\n\n for (const key of propOptionKeys) {\n const value = options[key];\n if (value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n"],"names":["propOptionKeys","parsePropOptions","options","result","key","value","undefined"],"mappings":"AAAA,SAA2BA,cAAc,QAAQ,eAAe;AAKhE,OAAO,SAASC,iBAAiBC,OAA+B;IAC5D,MAAMC,SAAS,CAAC;IAEhB,KAAK,MAAMC,OAAOJ,eAAgB;QAC9B,MAAMK,QAAQH,OAAO,CAACE,IAAI;QAC1B,IAAIC,UAAUC,WAAW;YACrBH,MAAM,CAACC,IAAI,GAAGC;QAClB;IACJ;IACA,OAAOF;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prop-type.d.ts","sourceRoot":"","sources":["../../src/lib/prop-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGrD,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,UAqC3C;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,UAEzC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { UnsupportedError } from '@vnodes/errors';
|
|
2
|
+
export function __propType(field) {
|
|
3
|
+
switch(field.kind){
|
|
4
|
+
case 'enum':
|
|
5
|
+
case 'object':
|
|
6
|
+
{
|
|
7
|
+
return field.type;
|
|
8
|
+
}
|
|
9
|
+
case 'scalar':
|
|
10
|
+
{
|
|
11
|
+
switch(field.type){
|
|
12
|
+
case 'String':
|
|
13
|
+
{
|
|
14
|
+
return 'string';
|
|
15
|
+
}
|
|
16
|
+
case 'Boolean':
|
|
17
|
+
{
|
|
18
|
+
return 'boolean';
|
|
19
|
+
}
|
|
20
|
+
case 'BigInt':
|
|
21
|
+
{
|
|
22
|
+
return 'BigInt';
|
|
23
|
+
}
|
|
24
|
+
case 'Decimal':
|
|
25
|
+
case 'Int':
|
|
26
|
+
case 'Float':
|
|
27
|
+
{
|
|
28
|
+
return 'number';
|
|
29
|
+
}
|
|
30
|
+
case 'DateTime':
|
|
31
|
+
{
|
|
32
|
+
return 'Date';
|
|
33
|
+
}
|
|
34
|
+
case 'Json':
|
|
35
|
+
{
|
|
36
|
+
return 'any';
|
|
37
|
+
}
|
|
38
|
+
case 'Btypes':
|
|
39
|
+
{
|
|
40
|
+
return 'Buffer';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
throw new UnsupportedError();
|
|
44
|
+
}
|
|
45
|
+
default:
|
|
46
|
+
throw new UnsupportedError();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function propType(field) {
|
|
50
|
+
return `${__propType(field)}${field.isList ? '[]' : ''}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=prop-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/prop-type.ts"],"sourcesContent":["import type { DMMF } from '@prisma/generator-helper';\nimport { UnsupportedError } from '@vnodes/errors';\n\nexport function __propType(field: DMMF.Field) {\n switch (field.kind) {\n case 'enum':\n case 'object': {\n return field.type;\n }\n case 'scalar': {\n switch (field.type) {\n case 'String': {\n return 'string';\n }\n case 'Boolean': {\n return 'boolean';\n }\n case 'BigInt': {\n return 'BigInt';\n }\n case 'Decimal':\n case 'Int':\n case 'Float': {\n return 'number';\n }\n case 'DateTime': {\n return 'Date';\n }\n case 'Json': {\n return 'any';\n }\n case 'Btypes': {\n return 'Buffer';\n }\n }\n throw new UnsupportedError();\n }\n default:\n throw new UnsupportedError();\n }\n}\n\nexport function propType(field: DMMF.Field) {\n return `${__propType(field)}${field.isList ? '[]' : ''}`;\n}\n"],"names":["UnsupportedError","__propType","field","kind","type","propType","isList"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,iBAAiB;AAElD,OAAO,SAASC,WAAWC,KAAiB;IACxC,OAAQA,MAAMC,IAAI;QACd,KAAK;QACL,KAAK;YAAU;gBACX,OAAOD,MAAME,IAAI;YACrB;QACA,KAAK;YAAU;gBACX,OAAQF,MAAME,IAAI;oBACd,KAAK;wBAAU;4BACX,OAAO;wBACX;oBACA,KAAK;wBAAW;4BACZ,OAAO;wBACX;oBACA,KAAK;wBAAU;4BACX,OAAO;wBACX;oBACA,KAAK;oBACL,KAAK;oBACL,KAAK;wBAAS;4BACV,OAAO;wBACX;oBACA,KAAK;wBAAY;4BACb,OAAO;wBACX;oBACA,KAAK;wBAAQ;4BACT,OAAO;wBACX;oBACA,KAAK;wBAAU;4BACX,OAAO;wBACX;gBACJ;gBACA,MAAM,IAAIJ;YACd;QACA;YACI,MAAM,IAAIA;IAClB;AACJ;AAEA,OAAO,SAASK,SAASH,KAAiB;IACtC,OAAO,GAAGD,WAAWC,SAASA,MAAMI,MAAM,GAAG,OAAO,IAAI;AAC5D"}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnodes/prisma-plugin-helpers",
|
|
3
|
+
"version": "0.0.23",
|
|
4
|
+
"description": "@vnodes/prisma-plugin-helpers",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"prisma-plugin-helpers"
|
|
7
|
+
],
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Robert Brightline",
|
|
10
|
+
"email": "robert.brightline+vnodes-prisma-plugin-helpers@gmail.com",
|
|
11
|
+
"url": "https://vnodes.github.io/vnodes"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://vnodes.github.io/vnodes/plugins/prisma-plugin-helpers",
|
|
14
|
+
"icon": "https://vnodes.github.io/vnodes/plugins/prisma-plugin-helpers/assets/favicon.png",
|
|
15
|
+
"funding": [
|
|
16
|
+
"https://cash.app/$puqlib"
|
|
17
|
+
],
|
|
18
|
+
"bin": {
|
|
19
|
+
"version": "./bin/version.mjs"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"module": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
".": {
|
|
28
|
+
"@vnodes/source": "./src/index.ts",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"bin",
|
|
37
|
+
"!**/*.tsbuildinfo"
|
|
38
|
+
],
|
|
39
|
+
"nx": {
|
|
40
|
+
"sourceRoot": "plugins/prisma-plugin-helpers/src",
|
|
41
|
+
"targets": {
|
|
42
|
+
"build": {},
|
|
43
|
+
"doc": {},
|
|
44
|
+
"lint": {}
|
|
45
|
+
},
|
|
46
|
+
"tags": [
|
|
47
|
+
"lib"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@swc/helpers": "~0.5.18"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@prisma/generator-helper": "^7.6.0",
|
|
55
|
+
"@vnodes/errors": "0.0.23",
|
|
56
|
+
"@vnodes/prop": "0.0.23",
|
|
57
|
+
"@vnodes/types": "0.0.23",
|
|
58
|
+
"@vnodes/utils": "0.0.23"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@prisma/generator-helper": "^7.6.0",
|
|
62
|
+
"@vnodes/errors": "0.0.23",
|
|
63
|
+
"@vnodes/prop": "0.0.23",
|
|
64
|
+
"@vnodes/utils": "0.0.23",
|
|
65
|
+
"@vnodes/types": "0.0.23"
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public",
|
|
69
|
+
"tag": "latest"
|
|
70
|
+
}
|
|
71
|
+
}
|