@visulima/crud 2.0.46 → 3.0.0-alpha.2
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/CHANGELOG.md +32 -0
- package/README.md +29 -18
- package/dist/{chunk-LBXJKEOF.mjs → chunk-542OFGDD.mjs} +3 -3
- package/dist/chunk-542OFGDD.mjs.map +1 -0
- package/dist/{chunk-5I2B5KQG.js → chunk-AW3MPEJW.js} +4 -4
- package/dist/{chunk-LBXJKEOF.mjs.map → chunk-AW3MPEJW.js.map} +1 -1
- package/dist/index.js +20 -20
- package/dist/index.mjs +2 -2
- package/dist/next/index.js +278 -267
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +146 -135
- package/dist/next/index.mjs.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-5I2B5KQG.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
## @visulima/crud [3.0.0-alpha.2](https://github.com/visulima/visulima/compare/@visulima/crud@3.0.0-alpha.1...@visulima/crud@3.0.0-alpha.2) (2025-12-06)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* add new package image, fixed readme rendering on npm, fixed building of packages ([b790ba2](https://github.com/visulima/visulima/commit/b790ba253ea07fef83528fd822a678facf021b5f))
|
|
6
|
+
* update package.json description and keywords ([#578](https://github.com/visulima/visulima/issues/578)) ([154709c](https://github.com/visulima/visulima/commit/154709c05e71d1ffd3e360b27e12febd817912f0))
|
|
7
|
+
|
|
8
|
+
### Miscellaneous Chores
|
|
9
|
+
|
|
10
|
+
* update @anolilab/semantic-release-pnpm and @anolilab/semantic-release-preset to versions 3.2.2 and 12.1.2 across multiple package.json files for improved compatibility ([3921626](https://github.com/visulima/visulima/commit/3921626141fe5da398749bf0ba675f1596f18afb))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Dependencies
|
|
14
|
+
|
|
15
|
+
* **@visulima/pagination:** upgraded to 5.0.0-alpha.2
|
|
16
|
+
* **@visulima/prisma-dmmf-transformer:** upgraded to 3.0.0-alpha.2
|
|
17
|
+
|
|
18
|
+
## @visulima/crud [3.0.0-alpha.1](https://github.com/visulima/visulima/compare/@visulima/crud@2.0.46...@visulima/crud@3.0.0-alpha.1) (2025-12-05)
|
|
19
|
+
|
|
20
|
+
### ⚠ BREAKING CHANGES
|
|
21
|
+
|
|
22
|
+
* change min node version to 22.13
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* update Node.js engine version requirement to >=22.13 in multiple package.json files for improved compatibility ([b828e9a](https://github.com/visulima/visulima/commit/b828e9aeaebfc798eecddccd90e6ec7560c6d36a))
|
|
27
|
+
|
|
28
|
+
### Miscellaneous Chores
|
|
29
|
+
|
|
30
|
+
* moved all packages into groups ([0615e9d](https://github.com/visulima/visulima/commit/0615e9d14a8a886e11da529ce150cf31ca973c10))
|
|
31
|
+
* update dependencies across multiple packages to improve compatibility and performance, including upgrading `@anolilab/semantic-release-pnpm` and `@anolilab/semantic-release-preset` to versions 3.2.0 and 12.1.0 respectively, and updating `react`, `react-dom`, and `next` versions to 19.2.1 and 16.0.7 in various package.json files ([aee8fcd](https://github.com/visulima/visulima/commit/aee8fcd796ae9b8d055903260e7150996ea9f53d))
|
|
32
|
+
|
|
1
33
|
## @visulima/crud [2.0.46](https://github.com/visulima/visulima/compare/@visulima/crud@2.0.45...@visulima/crud@2.0.46) (2025-11-13)
|
|
2
34
|
|
|
3
35
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
<h3>Visulima crud</h3>
|
|
3
|
-
<p>
|
|
4
|
-
Visulima crud is built on top of
|
|
1
|
+
<!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
[node-rate-limiter-flexible](https://github.com/animir/node-rate-limiter-flexible),
|
|
8
|
-
[@visulima/connect](https://github.com/visulima/visulima/tree/main/packages/connect)
|
|
3
|
+
<a href="https://www.anolilab.com/open-source" align="center">
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
<img src="__assets__/package-og.svg" alt="crud" />
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
</a>
|
|
8
|
+
|
|
9
|
+
<h3 align="center">A comprehensive CRUD library for building RESTful APIs with Prisma, providing automatic CRUD operations, filtering, sorting, and pagination.</h3>
|
|
10
|
+
|
|
11
|
+
<!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
14
12
|
|
|
15
13
|
<br />
|
|
16
14
|
|
|
17
15
|
<div align="center">
|
|
18
16
|
|
|
19
|
-
[![typescript-image]
|
|
17
|
+
[![typescript-image][typescript-badge]][typescript-url]
|
|
18
|
+
[![mit licence][license-badge]][license]
|
|
19
|
+
[![npm downloads][npm-downloads-badge]][npm-downloads]
|
|
20
|
+
[![Chat][chat-badge]][chat]
|
|
21
|
+
[![PRs Welcome][prs-welcome-badge]][prs-welcome]
|
|
20
22
|
|
|
21
23
|
</div>
|
|
22
24
|
|
|
@@ -118,14 +120,23 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
118
120
|
- [Daniel Bannert](https://github.com/prisis)
|
|
119
121
|
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
120
122
|
|
|
123
|
+
## Made with ❤️ at Anolilab
|
|
124
|
+
|
|
125
|
+
This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!
|
|
126
|
+
|
|
121
127
|
## License
|
|
122
128
|
|
|
123
|
-
The visulima crud is open-sourced software licensed under the [MIT][license
|
|
129
|
+
The visulima crud is open-sourced software licensed under the [MIT][license]
|
|
124
130
|
|
|
125
|
-
|
|
131
|
+
<!-- badges -->
|
|
126
132
|
|
|
127
|
-
[
|
|
128
|
-
[license
|
|
129
|
-
[
|
|
130
|
-
[npm-
|
|
131
|
-
[
|
|
133
|
+
[license-badge]: https://img.shields.io/npm/l/@visulima/crud?style=for-the-badge
|
|
134
|
+
[license]: https://github.com/visulima/visulima/blob/main/LICENSE
|
|
135
|
+
[npm-downloads-badge]: https://img.shields.io/npm/dm/@visulima/crud?style=for-the-badge
|
|
136
|
+
[npm-downloads]: https://www.npmjs.com/package/@visulima/crud
|
|
137
|
+
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
|
|
138
|
+
[prs-welcome]: https://github.com/visulima/visulima/blob/main/.github/CONTRIBUTING.md
|
|
139
|
+
[chat-badge]: https://img.shields.io/discord/932323359193186354.svg?style=for-the-badge
|
|
140
|
+
[chat]: https://discord.gg/TtFJY8xkFK
|
|
141
|
+
[typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
142
|
+
[typescript-url]: https://www.typescriptlang.org/
|
|
@@ -36,7 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
37
|
var getFilename, getDirname, __dirname$1;
|
|
38
38
|
var init_esm_shims = __esm({
|
|
39
|
-
"
|
|
39
|
+
"../../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.13.5_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/esm_shims.js"() {
|
|
40
40
|
getFilename = () => fileURLToPath(import.meta.url);
|
|
41
41
|
getDirname = () => path.dirname(getFilename());
|
|
42
42
|
__dirname$1 = /* @__PURE__ */ getDirname();
|
|
@@ -69,5 +69,5 @@ var getAccessibleRoutes = (only, exclude, defaultExposeStrategy = "all") => {
|
|
|
69
69
|
var get_accessible_routes_default = getAccessibleRoutes;
|
|
70
70
|
|
|
71
71
|
export { RouteType, __commonJS, __dirname$1 as __dirname, __esm, __export, __toCommonJS, __toESM, get_accessible_routes_default, init_esm_shims };
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
73
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-542OFGDD.mjs.map
|
|
73
|
+
//# sourceMappingURL=chunk-542OFGDD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.13.5_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/esm_shims.js","../src/types.ts","../src/utils/get-accessible-routes.ts"],"names":["__dirname","RouteType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAIM,aACA,UAAA,CAAA,CAEOA;AAPb,IAAA,cAAA,GAAA,KAAA,CAAA;AAAA,EAAA,+JAAA,GAAA;AAIA,IAAM,WAAA,GAAc,MAAM,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACvD,IAAM,UAAA,GAAa,MAAM,IAAA,CAAK,OAAA,CAAQ,aAAa,CAAA;AAE5C,IAAMA,8BAA4B,UAAA,EAAW;AAAA,EAAA;AAAA,CAAA;;;ACPpD,cAAA,EAAA;AAMO,IAAK,SAAA,qBAAAC,UAAAA,KAAL;AACH,EAAAA,WAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,WAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,WAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,WAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,WAAA,QAAA,CAAA,GAAS,QAAA;AALD,EAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA;;;ACNZ,cAAA,EAAA;AAEA,IAAM,mBAAA,GAAsB,CAAC,IAAA,EAAoB,OAAA,EAAuB,wBAAwC,KAAA,KAAuB;AACnI,EAAA,IAAI,gBAAA,GACE,qBAAA,KAA0B,MAAA,GAAS,KAAK,CAAA,UAAA,iBAAA,UAAA,iBAAA,QAAA,eAAA,QAAA,eAAA,QAAA,cAA6F;AAE3I,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG;AACrB,IAAA,gBAAA,GAAmB,IAAA;AAAA,EACvB;AAEA,EAAA,IAAI,SAAS,MAAA,EAAQ;AACjB,IAAA,gBAAA,GAAmB,gBAAA,CAAiB,OAAO,CAAC,OAAA,KAAY,CAAC,OAAA,CAAQ,QAAA,CAAS,OAAO,CAAC,CAAA;AAAA,EACtF;AAEA,EAAA,OAAO,gBAAA;AACX,CAAA;AAEA,IAAO,6BAAA,GAAQ","file":"chunk-542OFGDD.mjs","sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import type { Handler as CreateHandler } from \"./handler/create\";\nimport type { Handler as DeleteHandler } from \"./handler/delete\";\nimport type { Handler as ListHandler } from \"./handler/list\";\nimport type { Handler as GetHandler } from \"./handler/read\";\nimport type { Handler as UpdateHandler } from \"./handler/update\";\n\nexport enum RouteType {\n CREATE = \"CREATE\",\n DELETE = \"DELETE\",\n READ_ALL = \"READ_ALL\",\n READ_ONE = \"READ_ONE\",\n UPDATE = \"UPDATE\",\n}\n\nexport interface ModelOption {\n exclude?: RouteType[];\n formatResourceId?: (resourceId: string) => number | string;\n name?: string;\n only?: RouteType[];\n}\n\nexport type ModelsOptions<M extends string = string> = {\n [key in M]?: ModelOption;\n};\n\nexport interface HandlerOptions<M extends string = string> {\n exposeStrategy?: \"all\" | \"none\";\n formatResourceId?: (resourceId: string) => number | string;\n handlers?: {\n create?: CreateHandler;\n delete?: DeleteHandler;\n get?: GetHandler;\n list?: ListHandler;\n update?: UpdateHandler;\n };\n models?: ModelsOptions<M>;\n pagination?: PaginationConfig;\n}\n\nexport interface PaginationConfig {\n perPage: number;\n}\n\nexport interface HandlerParameters<T, Q> {\n adapter: Adapter<T, Q>;\n query: Q;\n resourceName: string;\n}\n\nexport interface UniqueResourceHandlerParameters<T, Q> {\n adapter: Adapter<T, Q>;\n query: Q;\n resourceId: number | string;\n resourceName: string;\n}\n\nexport interface Adapter<T, Q, M extends string = string> {\n connect?: () => Promise<void>;\n create: (resourceName: M, data: any, query: Q) => Promise<T>;\n delete: (resourceName: M, resourceId: number | string, query: Q) => Promise<T>;\n disconnect?: () => Promise<void>;\n getAll: (resourceName: M, query: Q) => Promise<T[]>;\n getModels: () => M[];\n getOne: (resourceName: M, resourceId: number | string, query: Q) => Promise<T>;\n getPaginationData: (resourceName: M, query: Q) => Promise<PaginationData>;\n handleError?: (error: Error) => void;\n init?: () => Promise<void>;\n mapModelsToRouteNames?: () => Promise<{ [key in M]?: string }>;\n models?: M[];\n parseQuery: (resourceName: M, query: ParsedQueryParameters) => Q;\n update: (resourceName: M, resourceId: number | string, data: any, query: Q) => Promise<T>;\n}\n\nexport interface PaginationData {\n page: number;\n pageCount: number;\n total: number;\n}\n\nexport type RecursiveField = Record<string, Record<string, boolean> | boolean>;\n\nexport type WhereOperator = \"$cont\" | \"$ends\" | \"$eq\" | \"$gt\" | \"$gte\" | \"$in\" | \"$isnull\" | \"$lt\" | \"$lte\" | \"$neq\" | \"$notin\" | \"$starts\";\n\nexport type SearchCondition = Date | boolean | number | string | null;\n\nexport type WhereCondition = {\n [key in WhereOperator]?: SearchCondition;\n};\n\nexport type Condition = { [key: string]: Condition | SearchCondition | WhereCondition };\n\nexport type WhereField = Condition & {\n $and?: Condition | Condition[];\n $not?: Condition | Condition[];\n $or?: Condition | Condition[];\n};\n\nexport type OrderByOperator = \"$asc\" | \"$desc\";\n\nexport type OrderByField = Record<string, OrderByOperator>;\n\nexport interface ParsedQueryParameters {\n distinct?: string;\n include?: RecursiveField;\n limit?: number | undefined;\n orderBy?: OrderByField;\n originalQuery?: Record<string, any>;\n page?: number | undefined;\n select?: RecursiveField;\n skip?: number | undefined;\n where?: WhereField;\n}\n\nexport type ExecuteHandler<Request, Response> = (request: Request, response: Response) => Promise<void>;\n\nexport interface FakePrismaClient {\n $connect: () => void;\n $disconnect: () => Promise<void>;\n [key: string]: any;\n _dmmf?: any;\n\n _getDmmf?: () => any;\n}\n","import { RouteType } from \"../types\";\n\nconst getAccessibleRoutes = (only?: RouteType[], exclude?: RouteType[], defaultExposeStrategy: \"all\" | \"none\" = \"all\"): RouteType[] => {\n let accessibleRoutes: RouteType[]\n = defaultExposeStrategy === \"none\" ? [] : [RouteType.READ_ALL, RouteType.READ_ONE, RouteType.UPDATE, RouteType.DELETE, RouteType.CREATE];\n\n if (Array.isArray(only)) {\n accessibleRoutes = only;\n }\n\n if (exclude?.length) {\n accessibleRoutes = accessibleRoutes.filter((element) => !exclude.includes(element));\n }\n\n return accessibleRoutes;\n};\n\nexport default getAccessibleRoutes;\n"]}
|
|
@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
34
|
));
|
|
35
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
36
|
|
|
37
|
-
//
|
|
37
|
+
// ../../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.13.5_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
|
|
38
38
|
var init_cjs_shims = __esm({
|
|
39
|
-
"
|
|
39
|
+
"../../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.13.5_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js"() {
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
|
|
@@ -73,5 +73,5 @@ exports.__toCommonJS = __toCommonJS;
|
|
|
73
73
|
exports.__toESM = __toESM;
|
|
74
74
|
exports.get_accessible_routes_default = get_accessible_routes_default;
|
|
75
75
|
exports.init_cjs_shims = init_cjs_shims;
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-AW3MPEJW.js.map
|
|
77
|
+
//# sourceMappingURL=chunk-AW3MPEJW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.13.5_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","../src/types.ts","../src/utils/get-accessible-routes.ts"],"names":["RouteType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,cAAA,GAAA,KAAA,CAAA;AAAA,EAAA,+JAAA,GAAA;AAAA,EAAA;AAAA,CAAA;;;ACAA,cAAA,EAAA;AAMO,IAAK,SAAA,qBAAAA,UAAAA,KAAL;AACH,EAAAA,WAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,WAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,WAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,WAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,WAAA,QAAA,CAAA,GAAS,QAAA;AALD,EAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA;;;ACNZ,cAAA,EAAA;AAEA,IAAM,mBAAA,GAAsB,CAAC,IAAA,EAAoB,OAAA,EAAuB,wBAAwC,KAAA,KAAuB;AACnI,EAAA,IAAI,gBAAA,GACE,qBAAA,KAA0B,MAAA,GAAS,KAAK,CAAA,UAAA,iBAAA,UAAA,iBAAA,QAAA,eAAA,QAAA,eAAA,QAAA,cAA6F;AAE3I,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG;AACrB,IAAA,gBAAA,GAAmB,IAAA;AAAA,EACvB;AAEA,EAAA,IAAI,SAAS,MAAA,EAAQ;AACjB,IAAA,gBAAA,GAAmB,gBAAA,CAAiB,OAAO,CAAC,OAAA,KAAY,CAAC,OAAA,CAAQ,QAAA,CAAS,OAAO,CAAC,CAAA;AAAA,EACtF;AAEA,EAAA,OAAO,gBAAA;AACX,CAAA;AAEA,IAAO,6BAAA,GAAQ","file":"chunk-AW3MPEJW.js","sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import type { Handler as CreateHandler } from \"./handler/create\";\nimport type { Handler as DeleteHandler } from \"./handler/delete\";\nimport type { Handler as ListHandler } from \"./handler/list\";\nimport type { Handler as GetHandler } from \"./handler/read\";\nimport type { Handler as UpdateHandler } from \"./handler/update\";\n\nexport enum RouteType {\n CREATE = \"CREATE\",\n DELETE = \"DELETE\",\n READ_ALL = \"READ_ALL\",\n READ_ONE = \"READ_ONE\",\n UPDATE = \"UPDATE\",\n}\n\nexport interface ModelOption {\n exclude?: RouteType[];\n formatResourceId?: (resourceId: string) => number | string;\n name?: string;\n only?: RouteType[];\n}\n\nexport type ModelsOptions<M extends string = string> = {\n [key in M]?: ModelOption;\n};\n\nexport interface HandlerOptions<M extends string = string> {\n exposeStrategy?: \"all\" | \"none\";\n formatResourceId?: (resourceId: string) => number | string;\n handlers?: {\n create?: CreateHandler;\n delete?: DeleteHandler;\n get?: GetHandler;\n list?: ListHandler;\n update?: UpdateHandler;\n };\n models?: ModelsOptions<M>;\n pagination?: PaginationConfig;\n}\n\nexport interface PaginationConfig {\n perPage: number;\n}\n\nexport interface HandlerParameters<T, Q> {\n adapter: Adapter<T, Q>;\n query: Q;\n resourceName: string;\n}\n\nexport interface UniqueResourceHandlerParameters<T, Q> {\n adapter: Adapter<T, Q>;\n query: Q;\n resourceId: number | string;\n resourceName: string;\n}\n\nexport interface Adapter<T, Q, M extends string = string> {\n connect?: () => Promise<void>;\n create: (resourceName: M, data: any, query: Q) => Promise<T>;\n delete: (resourceName: M, resourceId: number | string, query: Q) => Promise<T>;\n disconnect?: () => Promise<void>;\n getAll: (resourceName: M, query: Q) => Promise<T[]>;\n getModels: () => M[];\n getOne: (resourceName: M, resourceId: number | string, query: Q) => Promise<T>;\n getPaginationData: (resourceName: M, query: Q) => Promise<PaginationData>;\n handleError?: (error: Error) => void;\n init?: () => Promise<void>;\n mapModelsToRouteNames?: () => Promise<{ [key in M]?: string }>;\n models?: M[];\n parseQuery: (resourceName: M, query: ParsedQueryParameters) => Q;\n update: (resourceName: M, resourceId: number | string, data: any, query: Q) => Promise<T>;\n}\n\nexport interface PaginationData {\n page: number;\n pageCount: number;\n total: number;\n}\n\nexport type RecursiveField = Record<string, Record<string, boolean> | boolean>;\n\nexport type WhereOperator = \"$cont\" | \"$ends\" | \"$eq\" | \"$gt\" | \"$gte\" | \"$in\" | \"$isnull\" | \"$lt\" | \"$lte\" | \"$neq\" | \"$notin\" | \"$starts\";\n\nexport type SearchCondition = Date | boolean | number | string | null;\n\nexport type WhereCondition = {\n [key in WhereOperator]?: SearchCondition;\n};\n\nexport type Condition = { [key: string]: Condition | SearchCondition | WhereCondition };\n\nexport type WhereField = Condition & {\n $and?: Condition | Condition[];\n $not?: Condition | Condition[];\n $or?: Condition | Condition[];\n};\n\nexport type OrderByOperator = \"$asc\" | \"$desc\";\n\nexport type OrderByField = Record<string, OrderByOperator>;\n\nexport interface ParsedQueryParameters {\n distinct?: string;\n include?: RecursiveField;\n limit?: number | undefined;\n orderBy?: OrderByField;\n originalQuery?: Record<string, any>;\n page?: number | undefined;\n select?: RecursiveField;\n skip?: number | undefined;\n where?: WhereField;\n}\n\nexport type ExecuteHandler<Request, Response> = (request: Request, response: Response) => Promise<void>;\n\nexport interface FakePrismaClient {\n $connect: () => void;\n $disconnect: () => Promise<void>;\n [key: string]: any;\n _dmmf?: any;\n\n _getDmmf?: () => any;\n}\n","import { RouteType } from \"../types\";\n\nconst getAccessibleRoutes = (only?: RouteType[], exclude?: RouteType[], defaultExposeStrategy: \"all\" | \"none\" = \"all\"): RouteType[] => {\n let accessibleRoutes: RouteType[]\n = defaultExposeStrategy === \"none\" ? [] : [RouteType.READ_ALL, RouteType.READ_ONE, RouteType.UPDATE, RouteType.DELETE, RouteType.CREATE];\n\n if (Array.isArray(only)) {\n accessibleRoutes = only;\n }\n\n if (exclude?.length) {\n accessibleRoutes = accessibleRoutes.filter((element) => !exclude.includes(element));\n }\n\n return accessibleRoutes;\n};\n\nexport default getAccessibleRoutes;\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAW3MPEJW_js = require('./chunk-AW3MPEJW.js');
|
|
4
4
|
var createHttpError = require('http-errors');
|
|
5
5
|
var pagination = require('@visulima/pagination');
|
|
6
6
|
var prismaDmmfTransformer = require('@visulima/prisma-dmmf-transformer');
|
|
@@ -10,13 +10,13 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
10
10
|
var createHttpError__default = /*#__PURE__*/_interopDefault(createHttpError);
|
|
11
11
|
|
|
12
12
|
// src/index.ts
|
|
13
|
-
|
|
13
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
14
14
|
|
|
15
15
|
// src/adapter/prisma/index.ts
|
|
16
|
-
|
|
16
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
17
17
|
|
|
18
18
|
// src/adapter/prisma/utils/models-to-route-names.ts
|
|
19
|
-
|
|
19
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
20
20
|
var modelsToRouteNames = (mappingsMap, models) => {
|
|
21
21
|
const routesMap = {};
|
|
22
22
|
models.forEach((model) => {
|
|
@@ -27,10 +27,10 @@ var modelsToRouteNames = (mappingsMap, models) => {
|
|
|
27
27
|
var models_to_route_names_default = modelsToRouteNames;
|
|
28
28
|
|
|
29
29
|
// src/adapter/prisma/utils/parse-cursor.ts
|
|
30
|
-
|
|
30
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
31
31
|
|
|
32
32
|
// src/utils/is-primitive.ts
|
|
33
|
-
|
|
33
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
34
34
|
var primitiveTypes = /* @__PURE__ */ new Set(["boolean", "number", "string"]);
|
|
35
35
|
var isPrimitive = (value) => primitiveTypes.has(typeof value);
|
|
36
36
|
var is_primitive_default = isPrimitive;
|
|
@@ -52,7 +52,7 @@ var parsePrismaCursor = (cursor) => {
|
|
|
52
52
|
var parse_cursor_default = parsePrismaCursor;
|
|
53
53
|
|
|
54
54
|
// src/adapter/prisma/utils/parse-order-by.ts
|
|
55
|
-
|
|
55
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
56
56
|
var operatorsAssociation = {
|
|
57
57
|
$asc: "asc",
|
|
58
58
|
$desc: "desc"
|
|
@@ -68,7 +68,7 @@ var parsePrismaOrderBy = (orderBy) => {
|
|
|
68
68
|
var parse_order_by_default = parsePrismaOrderBy;
|
|
69
69
|
|
|
70
70
|
// src/adapter/prisma/utils/parse-recursive.ts
|
|
71
|
-
|
|
71
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
72
72
|
var parsePrismaRecursiveField = (select, fieldName) => {
|
|
73
73
|
const parsed = {};
|
|
74
74
|
Object.keys(select).forEach((field) => {
|
|
@@ -81,7 +81,7 @@ var parsePrismaRecursiveField = (select, fieldName) => {
|
|
|
81
81
|
var parse_recursive_default = parsePrismaRecursiveField;
|
|
82
82
|
|
|
83
83
|
// src/adapter/prisma/utils/parse-where.ts
|
|
84
|
-
|
|
84
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
85
85
|
var isObject = (a) => a instanceof Object;
|
|
86
86
|
var operatorsAssociation2 = {
|
|
87
87
|
$cont: "contains",
|
|
@@ -359,13 +359,13 @@ var PrismaAdapter = class {
|
|
|
359
359
|
};
|
|
360
360
|
|
|
361
361
|
// src/swagger/adapter/prisma/index.ts
|
|
362
|
-
|
|
362
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
363
363
|
|
|
364
364
|
// src/swagger/json-schema-parser.ts
|
|
365
|
-
|
|
365
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
366
366
|
|
|
367
367
|
// src/swagger/utils/format-schema-ref.ts
|
|
368
|
-
|
|
368
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
369
369
|
var formatSchemaReference = (schemaName) => `#/components/schemas/${schemaName}`;
|
|
370
370
|
var format_schema_ref_default = formatSchemaReference;
|
|
371
371
|
|
|
@@ -682,29 +682,29 @@ var PrismaJsonSchemaParser = class {
|
|
|
682
682
|
var json_schema_parser_default = PrismaJsonSchemaParser;
|
|
683
683
|
|
|
684
684
|
// src/swagger/utils/get-models-accessible-routes.ts
|
|
685
|
-
|
|
685
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
686
686
|
var getModelsAccessibleRoutes = (modelNames, models, defaultExposeStrategy = "all") => (
|
|
687
687
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
688
688
|
modelNames.reduce((accumulator, modelName) => {
|
|
689
689
|
if (models?.[modelName]) {
|
|
690
690
|
return {
|
|
691
691
|
...accumulator,
|
|
692
|
-
[modelName]:
|
|
692
|
+
[modelName]: chunkAW3MPEJW_js.get_accessible_routes_default(models[modelName].only, models[modelName].exclude, defaultExposeStrategy)
|
|
693
693
|
};
|
|
694
694
|
}
|
|
695
695
|
return {
|
|
696
696
|
...accumulator,
|
|
697
|
-
[modelName]:
|
|
697
|
+
[modelName]: chunkAW3MPEJW_js.get_accessible_routes_default(void 0, void 0, defaultExposeStrategy)
|
|
698
698
|
};
|
|
699
699
|
}, {})
|
|
700
700
|
);
|
|
701
701
|
var get_models_accessible_routes_default = getModelsAccessibleRoutes;
|
|
702
702
|
|
|
703
703
|
// src/swagger/utils/get-swagger-paths.ts
|
|
704
|
-
|
|
704
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
705
705
|
|
|
706
706
|
// src/swagger/parameters.ts
|
|
707
|
-
|
|
707
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
708
708
|
var queryParameters = {
|
|
709
709
|
distinct: {
|
|
710
710
|
description: "Fields to distinctively retrieve",
|
|
@@ -784,7 +784,7 @@ var getQueryParameters = (routeType, additionalQueryParameters = []) => {
|
|
|
784
784
|
};
|
|
785
785
|
|
|
786
786
|
// src/swagger/utils/format-example-ref.ts
|
|
787
|
-
|
|
787
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
788
788
|
var formatExampleReference = (schemaName) => `#/components/examples/${schemaName}`;
|
|
789
789
|
var format_example_ref_default = formatExampleReference;
|
|
790
790
|
|
|
@@ -995,7 +995,7 @@ var getSwaggerPaths = ({ models, modelsConfig, routes, routesMap }) => (
|
|
|
995
995
|
var get_swagger_paths_default = getSwaggerPaths;
|
|
996
996
|
|
|
997
997
|
// src/swagger/utils/get-swagger-tags.ts
|
|
998
|
-
|
|
998
|
+
chunkAW3MPEJW_js.init_cjs_shims();
|
|
999
999
|
var getSwaggerTags = (modelNames, modelsConfig) => modelNames.map((modelName) => {
|
|
1000
1000
|
if (modelsConfig?.[modelName]?.tag) {
|
|
1001
1001
|
return modelsConfig[modelName].tag;
|
|
@@ -1087,7 +1087,7 @@ var prisma_default = modelsToOpenApi;
|
|
|
1087
1087
|
|
|
1088
1088
|
Object.defineProperty(exports, "RouteType", {
|
|
1089
1089
|
enumerable: true,
|
|
1090
|
-
get: function () { return
|
|
1090
|
+
get: function () { return chunkAW3MPEJW_js.RouteType; }
|
|
1091
1091
|
});
|
|
1092
1092
|
exports.PrismaAdapter = PrismaAdapter;
|
|
1093
1093
|
exports.modelsToOpenApi = prisma_default;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_esm_shims, get_accessible_routes_default } from './chunk-
|
|
2
|
-
export { RouteType } from './chunk-
|
|
1
|
+
import { init_esm_shims, get_accessible_routes_default } from './chunk-542OFGDD.mjs';
|
|
2
|
+
export { RouteType } from './chunk-542OFGDD.mjs';
|
|
3
3
|
import createHttpError from 'http-errors';
|
|
4
4
|
import { createPaginationMetaSchemaObject } from '@visulima/pagination';
|
|
5
5
|
import { getJSONSchemaProperty, transformDMMF } from '@visulima/prisma-dmmf-transformer';
|