@visulima/crud 2.0.13 → 2.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.
@@ -38,20 +38,17 @@ declare enum RouteType {
38
38
  DELETE = "DELETE",
39
39
  READ_ALL = "READ_ALL",
40
40
  READ_ONE = "READ_ONE",
41
- UPDATE = "UPDATE",
41
+ UPDATE = "UPDATE"
42
42
  }
43
-
44
43
  interface ModelOption {
45
44
  exclude?: RouteType[];
46
45
  formatResourceId?: (resourceId: string) => number | string;
47
46
  name?: string;
48
47
  only?: RouteType[];
49
48
  }
50
-
51
49
  type ModelsOptions<M extends string = string> = {
52
50
  [key in M]?: ModelOption;
53
51
  };
54
-
55
52
  interface HandlerOptions<M extends string = string> {
56
53
  exposeStrategy?: "all" | "none";
57
54
  formatResourceId?: (resourceId: string) => number | string;
@@ -65,24 +62,20 @@ interface HandlerOptions<M extends string = string> {
65
62
  models?: ModelsOptions<M>;
66
63
  pagination?: PaginationConfig;
67
64
  }
68
-
69
65
  interface PaginationConfig {
70
66
  perPage: number;
71
67
  }
72
-
73
68
  interface HandlerParameters<T, Q> {
74
69
  adapter: Adapter<T, Q>;
75
70
  query: Q;
76
71
  resourceName: string;
77
72
  }
78
-
79
73
  interface UniqueResourceHandlerParameters<T, Q> {
80
74
  adapter: Adapter<T, Q>;
81
75
  query: Q;
82
76
  resourceId: number | string;
83
77
  resourceName: string;
84
78
  }
85
-
86
79
  interface Adapter<T, Q, M extends string = string> {
87
80
  connect?: () => Promise<void>;
88
81
  create: (resourceName: M, data: any, query: Q) => Promise<T>;
@@ -94,66 +87,51 @@ interface Adapter<T, Q, M extends string = string> {
94
87
  getPaginationData: (resourceName: M, query: Q) => Promise<PaginationData>;
95
88
  handleError?: (error: Error) => void;
96
89
  init?: () => Promise<void>;
97
- mapModelsToRouteNames?: () => Promise<{ [key in M]?: string }>;
90
+ mapModelsToRouteNames?: () => Promise<{
91
+ [key in M]?: string;
92
+ }>;
98
93
  models?: M[];
99
94
  parseQuery: (resourceName: M, query: ParsedQueryParameters) => Q;
100
95
  update: (resourceName: M, resourceId: number | string, data: any, query: Q) => Promise<T>;
101
96
  }
102
-
103
97
  interface PaginationData {
104
98
  page: number;
105
99
  pageCount: number;
106
100
  total: number;
107
101
  }
108
-
109
102
  type RecursiveField = Record<string, Record<string, boolean> | boolean>;
110
-
111
103
  type WhereOperator = "$cont" | "$ends" | "$eq" | "$gt" | "$gte" | "$in" | "$isnull" | "$lt" | "$lte" | "$neq" | "$notin" | "$starts";
112
-
113
104
  type SearchCondition = Date | boolean | number | string | null;
114
-
115
105
  type WhereCondition = {
116
106
  [key in WhereOperator]?: SearchCondition;
117
107
  };
118
-
119
- // TODO: find the correct way to type this
120
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
121
- type Condition = Record<string, Condition | SearchCondition | WhereCondition>;
122
-
123
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
108
+ type Condition = {
109
+ [key: string]: Condition | SearchCondition | WhereCondition;
110
+ };
124
111
  type WhereField = Condition & {
125
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
126
112
  $and?: Condition | Condition[];
127
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
128
113
  $not?: Condition | Condition[];
129
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
130
114
  $or?: Condition | Condition[];
131
115
  };
132
-
133
116
  type OrderByOperator = "$asc" | "$desc";
134
-
135
117
  type OrderByField = Record<string, OrderByOperator>;
136
-
137
118
  interface ParsedQueryParameters {
138
119
  distinct?: string;
139
120
  include?: RecursiveField;
140
- limit?: number;
121
+ limit?: number | undefined;
141
122
  orderBy?: OrderByField;
142
123
  originalQuery?: Record<string, any>;
143
- page?: number;
124
+ page?: number | undefined;
144
125
  select?: RecursiveField;
145
- skip?: number;
126
+ skip?: number | undefined;
146
127
  where?: WhereField;
147
128
  }
148
-
149
129
  type ExecuteHandler<Request, Response> = (request: Request, response: Response) => Promise<void>;
150
-
151
130
  interface FakePrismaClient {
152
131
  $connect: () => void;
153
132
  $disconnect: () => Promise<void>;
154
133
  [key: string]: any;
155
134
  _dmmf?: any;
156
-
157
135
  _getDmmf?: () => any;
158
136
  }
159
137
 
@@ -38,20 +38,17 @@ declare enum RouteType {
38
38
  DELETE = "DELETE",
39
39
  READ_ALL = "READ_ALL",
40
40
  READ_ONE = "READ_ONE",
41
- UPDATE = "UPDATE",
41
+ UPDATE = "UPDATE"
42
42
  }
43
-
44
43
  interface ModelOption {
45
44
  exclude?: RouteType[];
46
45
  formatResourceId?: (resourceId: string) => number | string;
47
46
  name?: string;
48
47
  only?: RouteType[];
49
48
  }
50
-
51
49
  type ModelsOptions<M extends string = string> = {
52
50
  [key in M]?: ModelOption;
53
51
  };
54
-
55
52
  interface HandlerOptions<M extends string = string> {
56
53
  exposeStrategy?: "all" | "none";
57
54
  formatResourceId?: (resourceId: string) => number | string;
@@ -65,24 +62,20 @@ interface HandlerOptions<M extends string = string> {
65
62
  models?: ModelsOptions<M>;
66
63
  pagination?: PaginationConfig;
67
64
  }
68
-
69
65
  interface PaginationConfig {
70
66
  perPage: number;
71
67
  }
72
-
73
68
  interface HandlerParameters<T, Q> {
74
69
  adapter: Adapter<T, Q>;
75
70
  query: Q;
76
71
  resourceName: string;
77
72
  }
78
-
79
73
  interface UniqueResourceHandlerParameters<T, Q> {
80
74
  adapter: Adapter<T, Q>;
81
75
  query: Q;
82
76
  resourceId: number | string;
83
77
  resourceName: string;
84
78
  }
85
-
86
79
  interface Adapter<T, Q, M extends string = string> {
87
80
  connect?: () => Promise<void>;
88
81
  create: (resourceName: M, data: any, query: Q) => Promise<T>;
@@ -94,66 +87,51 @@ interface Adapter<T, Q, M extends string = string> {
94
87
  getPaginationData: (resourceName: M, query: Q) => Promise<PaginationData>;
95
88
  handleError?: (error: Error) => void;
96
89
  init?: () => Promise<void>;
97
- mapModelsToRouteNames?: () => Promise<{ [key in M]?: string }>;
90
+ mapModelsToRouteNames?: () => Promise<{
91
+ [key in M]?: string;
92
+ }>;
98
93
  models?: M[];
99
94
  parseQuery: (resourceName: M, query: ParsedQueryParameters) => Q;
100
95
  update: (resourceName: M, resourceId: number | string, data: any, query: Q) => Promise<T>;
101
96
  }
102
-
103
97
  interface PaginationData {
104
98
  page: number;
105
99
  pageCount: number;
106
100
  total: number;
107
101
  }
108
-
109
102
  type RecursiveField = Record<string, Record<string, boolean> | boolean>;
110
-
111
103
  type WhereOperator = "$cont" | "$ends" | "$eq" | "$gt" | "$gte" | "$in" | "$isnull" | "$lt" | "$lte" | "$neq" | "$notin" | "$starts";
112
-
113
104
  type SearchCondition = Date | boolean | number | string | null;
114
-
115
105
  type WhereCondition = {
116
106
  [key in WhereOperator]?: SearchCondition;
117
107
  };
118
-
119
- // TODO: find the correct way to type this
120
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
121
- type Condition = Record<string, Condition | SearchCondition | WhereCondition>;
122
-
123
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
108
+ type Condition = {
109
+ [key: string]: Condition | SearchCondition | WhereCondition;
110
+ };
124
111
  type WhereField = Condition & {
125
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
126
112
  $and?: Condition | Condition[];
127
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
128
113
  $not?: Condition | Condition[];
129
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
130
114
  $or?: Condition | Condition[];
131
115
  };
132
-
133
116
  type OrderByOperator = "$asc" | "$desc";
134
-
135
117
  type OrderByField = Record<string, OrderByOperator>;
136
-
137
118
  interface ParsedQueryParameters {
138
119
  distinct?: string;
139
120
  include?: RecursiveField;
140
- limit?: number;
121
+ limit?: number | undefined;
141
122
  orderBy?: OrderByField;
142
123
  originalQuery?: Record<string, any>;
143
- page?: number;
124
+ page?: number | undefined;
144
125
  select?: RecursiveField;
145
- skip?: number;
126
+ skip?: number | undefined;
146
127
  where?: WhereField;
147
128
  }
148
-
149
129
  type ExecuteHandler<Request, Response> = (request: Request, response: Response) => Promise<void>;
150
-
151
130
  interface FakePrismaClient {
152
131
  $connect: () => void;
153
132
  $disconnect: () => Promise<void>;
154
133
  [key: string]: any;
155
134
  _dmmf?: any;
156
-
157
135
  _getDmmf?: () => any;
158
136
  }
159
137
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/crud",
3
- "version": "2.0.13",
3
+ "version": "2.0.14",
4
4
  "description": "visulima crud",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -59,7 +59,6 @@
59
59
  "module": "dist/index.mjs",
60
60
  "types": "dist/index.d.ts",
61
61
  "files": [
62
- "next/**",
63
62
  "dist/**",
64
63
  "README.md",
65
64
  "CHANGELOG.md",
@@ -82,8 +81,8 @@
82
81
  "test:watch": "vitest"
83
82
  },
84
83
  "dependencies": {
85
- "@visulima/pagination": "3.0.11",
86
- "@visulima/prisma-dmmf-transformer": "2.0.13",
84
+ "@visulima/pagination": "3.0.12",
85
+ "@visulima/prisma-dmmf-transformer": "2.0.14",
87
86
  "http-errors": "^2.0.0",
88
87
  "lodash.set": "^4.3.2",
89
88
  "path-to-regexp": "^6.2.1"
@@ -92,17 +91,17 @@
92
91
  "@anolilab/eslint-config": "^15.0.3",
93
92
  "@anolilab/prettier-config": "^5.0.14",
94
93
  "@anolilab/semantic-release-preset": "^8.0.3",
95
- "@babel/core": "^7.23.9",
94
+ "@babel/core": "^7.24.0",
96
95
  "@prisma/client": "4.16.2",
97
- "@rushstack/eslint-plugin-security": "^0.8.0",
96
+ "@rushstack/eslint-plugin-security": "^0.8.1",
98
97
  "@types/http-errors": "^2.0.4",
99
98
  "@types/json-schema": "7.0.15",
100
99
  "@types/lodash.set": "^4.3.9",
101
- "@types/node": "18.18.8",
102
- "@vitest/coverage-v8": "^1.2.2",
103
- "@vitest/ui": "^1.2.2",
100
+ "@types/node": "18.18.14",
101
+ "@vitest/coverage-v8": "^1.3.1",
102
+ "@vitest/ui": "^1.3.1",
104
103
  "cross-env": "^7.0.3",
105
- "eslint": "^8.56.0",
104
+ "eslint": "^8.57.0",
106
105
  "eslint-plugin-deprecation": "^2.0.0",
107
106
  "eslint-plugin-etc": "^2.0.3",
108
107
  "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
@@ -110,19 +109,19 @@
110
109
  "eslint-plugin-mdx": "^3.1.5",
111
110
  "eslint-plugin-ssr-friendly": "^1.3.0",
112
111
  "eslint-plugin-validate-jsx-nesting": "^0.1.1",
113
- "eslint-plugin-vitest": "^0.3.21",
112
+ "eslint-plugin-vitest": "^0.3.22",
114
113
  "eslint-plugin-vitest-globals": "^1.4.0",
115
114
  "next": "^12.0.0 || ^13.0.0",
116
- "next-test-api-route-handler": "^4.0.3",
115
+ "next-test-api-route-handler": "^4.0.5",
117
116
  "node-mocks-http": "^1.14.1",
118
117
  "openapi-types": "^12.1.3",
119
- "prettier": "^3.2.4",
118
+ "prettier": "^3.2.5",
120
119
  "rimraf": "^5.0.5",
121
- "semantic-release": "^23.0.0",
122
- "sort-package-json": "^2.7.0",
123
- "tsup": "^8.0.1",
120
+ "semantic-release": "^23.0.2",
121
+ "sort-package-json": "^2.8.0",
122
+ "tsup": "^8.0.2",
124
123
  "typescript": "^5.3.3",
125
- "vitest": "^1.2.2"
124
+ "vitest": "^1.3.1"
126
125
  },
127
126
  "engines": {
128
127
  "node": ">=18.* <=21.*"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.0.1_postcss@8.4.33_typescript@5.3.3/node_modules/tsup/assets/esm_shims.js","../src/types.d.ts","../src/utils/get-accessible-routes.ts"],"names":["fileURLToPath","path","getFilename","getDirname","__dirname","init_esm_shims","__esmMin","RouteType","getAccessibleRoutes","only","exclude","defaultExposeStrategy","accessibleRoutes","element","get_accessible_routes_default"],"mappings":"4iBACA,OAAS,iBAAAA,MAAqB,MAC9B,OAAOC,MAAU,OAFjB,IAIMC,EACAC,EAEOC,EAPbC,EAAAC,EAAA,kBAIMJ,EAAc,IAAMF,EAAc,YAAY,GAAG,EACjDG,EAAa,IAAMF,EAAK,QAAQC,EAAY,CAAC,EAEtCE,EAA4BD,EAAW,ICPpDE,IAMO,IAAKE,OACRA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,OAAS,SALDA,OAAA,ICNZF,IAEA,IAAMG,EAAsB,CAACC,EAAoBC,EAAuBC,EAAwC,QAAuB,CACnI,IAAIC,EACAD,IAA0B,OAAS,CAAC,EAAI,iDAA6F,EAEzI,OAAI,MAAM,QAAQF,CAAI,IAClBG,EAAmBH,GAGnBC,GAAS,SACTE,EAAmBA,EAAiB,OAAQC,GAAY,CAACH,EAAQ,SAASG,CAAO,CAAC,GAG/ED,CACX,EAEOE,EAAQN","sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\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\n// TODO: find the correct way to type this\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nexport type Condition = Record<string, Condition | SearchCondition | WhereCondition>;\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nexport type WhereField = Condition & {\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n $and?: Condition | Condition[];\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n $not?: Condition | Condition[];\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\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;\n orderBy?: OrderByField;\n originalQuery?: Record<string, any>;\n page?: number;\n select?: RecursiveField;\n skip?: number;\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.d\";\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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.0.1_postcss@8.4.33_typescript@5.3.3/node_modules/tsup/assets/cjs_shims.js","../src/types.d.ts","../src/utils/get-accessible-routes.ts"],"names":["init_cjs_shims","__esmMin","RouteType","getAccessibleRoutes","only","exclude","defaultExposeStrategy","accessibleRoutes","element","get_accessible_routes_default"],"mappings":"4iBAAA,IAAAA,EAAAC,EAAA,oBCAAD,IAMO,IAAKE,OACRA,EAAA,OAAS,SACTA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,OAAS,SALDA,OAAA,ICNZF,IAEA,IAAMG,EAAsB,CAACC,EAAoBC,EAAuBC,EAAwC,QAAuB,CACnI,IAAIC,EACAD,IAA0B,OAAS,CAAC,EAAI,iDAA6F,EAEzI,OAAI,MAAM,QAAQF,CAAI,IAClBG,EAAmBH,GAGnBC,GAAS,SACTE,EAAmBA,EAAiB,OAAQC,GAAY,CAACH,EAAQ,SAASG,CAAO,CAAC,GAG/ED,CACX,EAEOE,EAAQN","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.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\n// TODO: find the correct way to type this\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nexport type Condition = Record<string, Condition | SearchCondition | WhereCondition>;\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nexport type WhereField = Condition & {\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n $and?: Condition | Condition[];\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n $not?: Condition | Condition[];\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\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;\n orderBy?: OrderByField;\n originalQuery?: Record<string, any>;\n page?: number;\n select?: RecursiveField;\n skip?: number;\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.d\";\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/next/package.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "name": "@visulima/crud-next",
3
- "version": "0.0.0",
4
- "private": true,
5
- "description": "visulima crud next",
6
- "license": "MIT",
7
- "exports": {
8
- ".": {
9
- "types": "./../dist/next/index.d.ts",
10
- "require": "./../dist/next/index.js",
11
- "import": "./../dist/next/index.mjs"
12
- },
13
- "./package.json": "./package.json"
14
- },
15
- "main": "../dist/next/index.js",
16
- "module": "../dist/next/index.mjs",
17
- "types": "../dist/next/index.d.ts"
18
- }