@visulima/crud 1.0.12 → 1.0.14
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 +30 -0
- package/dist/chunk-54HHLITU.mjs +5 -0
- package/dist/chunk-54HHLITU.mjs.map +1 -0
- package/dist/chunk-DOLZ4YNP.js +8 -0
- package/dist/chunk-DOLZ4YNP.js.map +1 -0
- package/dist/index.d.mts +141 -0
- package/dist/index.d.ts +59 -69
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/next/index.d.mts +8 -0
- package/dist/next/index.d.ts +3 -3
- package/dist/next/index.js +4 -4
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +3 -3
- package/dist/next/index.mjs.map +1 -1
- package/dist/{types.d-1fe34cff.d.ts → types.d-21565c86.d.ts} +52 -53
- package/next/package.json +1 -1
- package/package.json +40 -34
- package/dist/chunk-UEL6WWTI.mjs +0 -5
- package/dist/chunk-UEL6WWTI.mjs.map +0 -1
- package/dist/chunk-YZ63YP4Q.js +0 -8
- package/dist/chunk-YZ63YP4Q.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/crud",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "visulima crud",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -61,65 +61,54 @@
|
|
|
61
61
|
"clean": "rimraf node_modules dist .eslintcache",
|
|
62
62
|
"coverage": "vitest run --coverage",
|
|
63
63
|
"dev": "pnpm run build --watch",
|
|
64
|
-
"lint:eslint": "
|
|
64
|
+
"lint:eslint": "eslint . --ext js,cjs,mjs,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.js",
|
|
65
65
|
"lint:eslint:fix": "pnpm run lint:eslint --fix",
|
|
66
|
+
"lint:prettier": "prettier --config=.prettierrc.js --check .",
|
|
67
|
+
"lint:prettier:fix": "prettier --config=.prettierrc.js --write .",
|
|
68
|
+
"lint:types": "tsc --noEmit",
|
|
66
69
|
"test": "vitest run",
|
|
67
70
|
"test:watch": "vitest"
|
|
68
71
|
},
|
|
69
72
|
"dependencies": {
|
|
70
|
-
"@visulima/pagination": "2.0.
|
|
71
|
-
"@visulima/prisma-dmmf-transformer": "1.0.
|
|
73
|
+
"@visulima/pagination": "2.0.6",
|
|
74
|
+
"@visulima/prisma-dmmf-transformer": "1.0.9",
|
|
72
75
|
"http-errors": "^2.0.0",
|
|
73
76
|
"lodash.set": "^4.3.2",
|
|
74
77
|
"path-to-regexp": "^6.2.1"
|
|
75
78
|
},
|
|
76
79
|
"devDependencies": {
|
|
77
|
-
"@anolilab/eslint-config": "^
|
|
78
|
-
"@anolilab/
|
|
79
|
-
"@
|
|
80
|
+
"@anolilab/eslint-config": "^11.0.2",
|
|
81
|
+
"@anolilab/prettier-config": "^5.0.1",
|
|
82
|
+
"@anolilab/semantic-release-preset": "^6.0.2",
|
|
83
|
+
"@prisma/client": "4.16.2",
|
|
80
84
|
"@rushstack/eslint-plugin-security": "^0.6.0",
|
|
81
85
|
"@testing-library/react": "^14.0.0",
|
|
82
86
|
"@testing-library/react-hooks": "^8.0.1",
|
|
83
87
|
"@types/http-errors": "^2.0.1",
|
|
84
88
|
"@types/json-schema": "7.0.12",
|
|
85
89
|
"@types/lodash.set": "^4.3.7",
|
|
86
|
-
"@types/node": "18.16.
|
|
87
|
-
"@
|
|
88
|
-
"@typescript-eslint/parser": "^5.59.8",
|
|
89
|
-
"@vitest/coverage-c8": "^0.31.1",
|
|
90
|
+
"@types/node": "18.16.18",
|
|
91
|
+
"@vitest/coverage-v8": "^0.33.0",
|
|
90
92
|
"cross-env": "^7.0.3",
|
|
91
|
-
"eslint": "^8.
|
|
92
|
-
"eslint-plugin-
|
|
93
|
-
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
94
|
-
"eslint-plugin-import": "^2.27.5",
|
|
95
|
-
"eslint-plugin-json": "^3.1.0",
|
|
93
|
+
"eslint": "^8.46.0",
|
|
94
|
+
"eslint-plugin-etc": "^2.0.3",
|
|
96
95
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
97
|
-
"eslint-plugin-
|
|
98
|
-
"eslint-plugin-no-loops": "^0.3.0",
|
|
99
|
-
"eslint-plugin-no-secrets": "^0.8.9",
|
|
100
|
-
"eslint-plugin-node": "^11.1.0",
|
|
101
|
-
"eslint-plugin-optimize-regex": "^1.2.1",
|
|
102
|
-
"eslint-plugin-promise": "^6.1.1",
|
|
103
|
-
"eslint-plugin-react": "7.32.2",
|
|
104
|
-
"eslint-plugin-react-hooks": "4.6.0",
|
|
105
|
-
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
106
|
-
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
96
|
+
"eslint-plugin-mdx": "^2.1.0",
|
|
107
97
|
"eslint-plugin-testing-library": "^5.11.0",
|
|
108
|
-
"eslint-plugin-
|
|
109
|
-
"eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0",
|
|
110
|
-
"eslint-plugin-you-dont-need-momentjs": "^1.6.0",
|
|
98
|
+
"eslint-plugin-vitest": "^0.2.8",
|
|
111
99
|
"next": "^12.0.0 || ^13.0.0",
|
|
112
100
|
"next-test-api-route-handler": "^4.0.0-canary.1",
|
|
113
101
|
"node-mocks-http": "^1.12.2",
|
|
114
102
|
"openapi-types": "^12.1.3",
|
|
115
|
-
"prettier": "^
|
|
103
|
+
"prettier": "^3.0.0",
|
|
116
104
|
"react": "^18.2.0",
|
|
117
105
|
"react-dom": "^18.2.0",
|
|
118
106
|
"rimraf": "^5.0.1",
|
|
119
|
-
"semantic-release": "^21.0.
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
107
|
+
"semantic-release": "^21.0.7",
|
|
108
|
+
"sort-package-json": "^2.5.1",
|
|
109
|
+
"tsup": "^7.1.0",
|
|
110
|
+
"typescript": "^5.1.6",
|
|
111
|
+
"vitest": "^0.33.0"
|
|
123
112
|
},
|
|
124
113
|
"engines": {
|
|
125
114
|
"node": ">=16.18.0 <=20.*"
|
|
@@ -128,6 +117,23 @@
|
|
|
128
117
|
"access": "public",
|
|
129
118
|
"provenance": true
|
|
130
119
|
},
|
|
120
|
+
"anolilab": {
|
|
121
|
+
"eslint-config": {
|
|
122
|
+
"plugin": {
|
|
123
|
+
"tsdoc": false,
|
|
124
|
+
"react": false,
|
|
125
|
+
"react-usememo": false,
|
|
126
|
+
"react-hooks": false,
|
|
127
|
+
"testing-library": false,
|
|
128
|
+
"@testing-library/dom": false,
|
|
129
|
+
"@testing-library/react": false
|
|
130
|
+
},
|
|
131
|
+
"warn_on_unsupported_typescript_version": false,
|
|
132
|
+
"info_on_disabling_jsx_react_rule": false,
|
|
133
|
+
"info_on_disabling_prettier_conflict_rule": false,
|
|
134
|
+
"info_on_disabling_jsonc_sort_keys_rule": false
|
|
135
|
+
}
|
|
136
|
+
},
|
|
131
137
|
"optionalDependenciest": {
|
|
132
138
|
"next": "^12.0.0 || ^13.0.0",
|
|
133
139
|
"@prisma/client": "^3.0.0 || ^4.0.0"
|
package/dist/chunk-UEL6WWTI.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var a=(e=>(e.CREATE="CREATE",e.READ_ALL="READ_ALL",e.READ_ONE="READ_ONE",e.UPDATE="UPDATE",e.DELETE="DELETE",e))(a||{});var s=(t,n,o="all")=>{let r=o==="none"?[]:["READ_ALL","READ_ONE","UPDATE","DELETE","CREATE"];return Array.isArray(t)&&(r=t),n?.length&&(r=r.filter(i=>!n.includes(i))),r},p=s;
|
|
2
|
-
|
|
3
|
-
export { a, p as b };
|
|
4
|
-
//# sourceMappingURL=out.js.map
|
|
5
|
-
//# sourceMappingURL=chunk-UEL6WWTI.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.d.ts","../src/utils/get-accessible-routes.ts"],"names":["RouteType","getAccessibleRoutes","only","exclude","defaultExposeStrategy","accessibleRoutes","element","get_accessible_routes_default"],"mappings":"AAMO,IAAKA,OACRA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,OAAS,SALDA,OAAA,ICJZ,IAAMC,EAAsB,CAACC,EAAoBC,EAAuBC,EAAwC,QAAuB,CAEnI,IAAIC,EAAgCD,IAA0B,OAAS,CAAC,EAAI,iDAA6F,EAEzK,OAAI,MAAM,QAAQF,CAAI,IAClBG,EAAmBH,GAGnBC,GAAS,SACTE,EAAmBA,EAAiB,OAAQC,GAAY,CAACH,EAAQ,SAASG,CAAO,CAAC,GAG/ED,CACX,EAEOE,EAAQN","sourcesContent":["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 READ_ALL = \"READ_ALL\",\n READ_ONE = \"READ_ONE\",\n UPDATE = \"UPDATE\",\n DELETE = \"DELETE\",\n}\n\nexport type ModelOption = {\n name?: string;\n only?: RouteType[];\n exclude?: RouteType[];\n formatResourceId?: (resourceId: string) => number | string;\n};\n\nexport type ModelsOptions<M extends string = string> = {\n [key in M]?: ModelOption;\n};\n\nexport type HandlerOptions<M extends string = string> = {\n formatResourceId?: (resourceId: string) => number | string;\n models?: ModelsOptions<M>;\n exposeStrategy?: \"all\" | \"none\";\n pagination?: PaginationConfig;\n handlers?: {\n create?: CreateHandler;\n delete?: DeleteHandler;\n get?: GetHandler;\n list?: ListHandler;\n update?: UpdateHandler;\n };\n};\n\nexport type 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 resourceName: string;\n resourceId: number | string;\n}\n\nexport interface Adapter<T, Q, M extends string = string> {\n models?: M[];\n init?: () => Promise<void>;\n parseQuery: (resourceName: M, query: ParsedQueryParameters) => Q;\n getAll: (resourceName: M, query: Q) => Promise<T[]>;\n getOne: (resourceName: M, resourceId: number | string, query: Q) => Promise<T>;\n create: (resourceName: M, data: any, query: Q) => Promise<T>;\n update: (resourceName: M, resourceId: number | string, data: any, query: Q) => Promise<T>;\n delete: (resourceName: M, resourceId: number | string, query: Q) => Promise<T>;\n getPaginationData: (resourceName: M, query: Q) => Promise<PaginationData>;\n getModels: () => M[];\n connect?: () => Promise<void>;\n disconnect?: () => Promise<void>;\n handleError?: (error: Error) => void;\n mapModelsToRouteNames?: () => Promise<{ [key in M]?: string }>;\n}\n\nexport type PaginationData = {\n total: number;\n pageCount: number;\n page: number;\n};\n\nexport type RecursiveField = {\n [key: string]: TRecursiveField | boolean;\n};\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 TWhereOperator]?: TSearchCondition;\n};\n\nexport type Condition = {\n [key: string]: TCondition | TSearchCondition | TWhereCondition;\n};\n\nexport type WhereField = Condition & {\n $and?: TCondition | TCondition[];\n $or?: TCondition | TCondition[];\n $not?: TCondition | TCondition[];\n};\n\nexport type OrderByOperator = \"$asc\" | \"$desc\";\n\nexport type OrderByField = {\n [key: string]: TOrderByOperator;\n};\n\nexport interface ParsedQueryParameters {\n select?: RecursiveField;\n include?: RecursiveField;\n where?: WhereField;\n orderBy?: OrderByField;\n limit?: number;\n skip?: number;\n distinct?: string;\n page?: number;\n originalQuery?: {\n [key: string]: any;\n };\n}\n\nexport type ExecuteHandler<Request, Response> = (request: Request, response: Response) => Promise<void>;\n\nexport type FakePrismaClient = {\n _dmmf?: any;\n _getDmmf?: () => any;\n $connect: () => void;\n $disconnect: () => Promise<void>;\n\n [key: string]: any;\n};\n","import { RouteType } from \"../types.d\";\n\nconst getAccessibleRoutes = (only?: RouteType[], exclude?: RouteType[], defaultExposeStrategy: \"all\" | \"none\" = \"all\"): RouteType[] => {\n // eslint-disable-next-line max-len\n let accessibleRoutes: RouteType[] = 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/chunk-YZ63YP4Q.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var a=(e=>(e.CREATE="CREATE",e.READ_ALL="READ_ALL",e.READ_ONE="READ_ONE",e.UPDATE="UPDATE",e.DELETE="DELETE",e))(a||{});var s=(t,n,o="all")=>{let r=o==="none"?[]:["READ_ALL","READ_ONE","UPDATE","DELETE","CREATE"];return Array.isArray(t)&&(r=t),n?.length&&(r=r.filter(i=>!n.includes(i))),r},p=s;
|
|
4
|
-
|
|
5
|
-
exports.a = a;
|
|
6
|
-
exports.b = p;
|
|
7
|
-
//# sourceMappingURL=out.js.map
|
|
8
|
-
//# sourceMappingURL=chunk-YZ63YP4Q.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.d.ts","../src/utils/get-accessible-routes.ts"],"names":["RouteType","getAccessibleRoutes","only","exclude","defaultExposeStrategy","accessibleRoutes","element","get_accessible_routes_default"],"mappings":"AAMO,IAAKA,OACRA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,OAAS,SALDA,OAAA,ICJZ,IAAMC,EAAsB,CAACC,EAAoBC,EAAuBC,EAAwC,QAAuB,CAEnI,IAAIC,EAAgCD,IAA0B,OAAS,CAAC,EAAI,iDAA6F,EAEzK,OAAI,MAAM,QAAQF,CAAI,IAClBG,EAAmBH,GAGnBC,GAAS,SACTE,EAAmBA,EAAiB,OAAQC,GAAY,CAACH,EAAQ,SAASG,CAAO,CAAC,GAG/ED,CACX,EAEOE,EAAQN","sourcesContent":["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 READ_ALL = \"READ_ALL\",\n READ_ONE = \"READ_ONE\",\n UPDATE = \"UPDATE\",\n DELETE = \"DELETE\",\n}\n\nexport type ModelOption = {\n name?: string;\n only?: RouteType[];\n exclude?: RouteType[];\n formatResourceId?: (resourceId: string) => number | string;\n};\n\nexport type ModelsOptions<M extends string = string> = {\n [key in M]?: ModelOption;\n};\n\nexport type HandlerOptions<M extends string = string> = {\n formatResourceId?: (resourceId: string) => number | string;\n models?: ModelsOptions<M>;\n exposeStrategy?: \"all\" | \"none\";\n pagination?: PaginationConfig;\n handlers?: {\n create?: CreateHandler;\n delete?: DeleteHandler;\n get?: GetHandler;\n list?: ListHandler;\n update?: UpdateHandler;\n };\n};\n\nexport type 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 resourceName: string;\n resourceId: number | string;\n}\n\nexport interface Adapter<T, Q, M extends string = string> {\n models?: M[];\n init?: () => Promise<void>;\n parseQuery: (resourceName: M, query: ParsedQueryParameters) => Q;\n getAll: (resourceName: M, query: Q) => Promise<T[]>;\n getOne: (resourceName: M, resourceId: number | string, query: Q) => Promise<T>;\n create: (resourceName: M, data: any, query: Q) => Promise<T>;\n update: (resourceName: M, resourceId: number | string, data: any, query: Q) => Promise<T>;\n delete: (resourceName: M, resourceId: number | string, query: Q) => Promise<T>;\n getPaginationData: (resourceName: M, query: Q) => Promise<PaginationData>;\n getModels: () => M[];\n connect?: () => Promise<void>;\n disconnect?: () => Promise<void>;\n handleError?: (error: Error) => void;\n mapModelsToRouteNames?: () => Promise<{ [key in M]?: string }>;\n}\n\nexport type PaginationData = {\n total: number;\n pageCount: number;\n page: number;\n};\n\nexport type RecursiveField = {\n [key: string]: TRecursiveField | boolean;\n};\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 TWhereOperator]?: TSearchCondition;\n};\n\nexport type Condition = {\n [key: string]: TCondition | TSearchCondition | TWhereCondition;\n};\n\nexport type WhereField = Condition & {\n $and?: TCondition | TCondition[];\n $or?: TCondition | TCondition[];\n $not?: TCondition | TCondition[];\n};\n\nexport type OrderByOperator = \"$asc\" | \"$desc\";\n\nexport type OrderByField = {\n [key: string]: TOrderByOperator;\n};\n\nexport interface ParsedQueryParameters {\n select?: RecursiveField;\n include?: RecursiveField;\n where?: WhereField;\n orderBy?: OrderByField;\n limit?: number;\n skip?: number;\n distinct?: string;\n page?: number;\n originalQuery?: {\n [key: string]: any;\n };\n}\n\nexport type ExecuteHandler<Request, Response> = (request: Request, response: Response) => Promise<void>;\n\nexport type FakePrismaClient = {\n _dmmf?: any;\n _getDmmf?: () => any;\n $connect: () => void;\n $disconnect: () => Promise<void>;\n\n [key: string]: any;\n};\n","import { RouteType } from \"../types.d\";\n\nconst getAccessibleRoutes = (only?: RouteType[], exclude?: RouteType[], defaultExposeStrategy: \"all\" | \"none\" = \"all\"): RouteType[] => {\n // eslint-disable-next-line max-len\n let accessibleRoutes: RouteType[] = 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"]}
|