dn-react-router-toolkit 0.5.2 → 0.5.3

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.
@@ -1,4 +1,4 @@
1
- import { LoaderFunctionArgs } from 'react-router';
1
+ import { LoaderFunction, LoaderFunctionArgs } from 'react-router';
2
2
  import { TableLoaderOptions } from '../table/loader.mjs';
3
3
  import { TableItemLoaderOptions } from '../table/item_loader.mjs';
4
4
  import { Table } from 'drizzle-orm';
@@ -12,10 +12,14 @@ import 'dn-react-toolkit/auth/server';
12
12
  type CrudHandlerOptions<T extends Table, TSelect> = {
13
13
  repository: TableRepository<T, TSelect>;
14
14
  apiHandlerOptions: Omit<APIHandlerOptions<T, TSelect>, "repository">;
15
- loaderOptions: Omit<TableLoaderOptions<T, TSelect>, "repository">;
16
- itemLoaderOptions: Omit<TableItemLoaderOptions<T, TSelect>, "repository">;
15
+ loaderOptions: Omit<TableLoaderOptions<T, TSelect>, "repository"> & {
16
+ loader?: LoaderFunction;
17
+ };
18
+ itemLoaderOptions: Omit<TableItemLoaderOptions<T, TSelect>, "repository"> & {
19
+ loader?: LoaderFunction;
20
+ };
17
21
  };
18
22
  type CrudHandler = (prefix: string) => (args: LoaderFunctionArgs) => Promise<any>;
19
- declare function crudHandler<T extends Table, TSelect>({ repository, apiHandlerOptions, loaderOptions, itemLoaderOptions, }: CrudHandlerOptions<T, TSelect>): (prefix: string) => (args: LoaderFunctionArgs) => Promise<any>;
23
+ declare function crudHandler<T extends Table, TSelect>({ repository, apiHandlerOptions, loaderOptions, itemLoaderOptions, }: CrudHandlerOptions<T, TSelect>): (prefix: string) => (args: LoaderFunctionArgs) => Promise<unknown>;
20
24
 
21
25
  export { type CrudHandler, type CrudHandlerOptions, crudHandler };
@@ -1,4 +1,4 @@
1
- import { LoaderFunctionArgs } from 'react-router';
1
+ import { LoaderFunction, LoaderFunctionArgs } from 'react-router';
2
2
  import { TableLoaderOptions } from '../table/loader.js';
3
3
  import { TableItemLoaderOptions } from '../table/item_loader.js';
4
4
  import { Table } from 'drizzle-orm';
@@ -12,10 +12,14 @@ import 'dn-react-toolkit/auth/server';
12
12
  type CrudHandlerOptions<T extends Table, TSelect> = {
13
13
  repository: TableRepository<T, TSelect>;
14
14
  apiHandlerOptions: Omit<APIHandlerOptions<T, TSelect>, "repository">;
15
- loaderOptions: Omit<TableLoaderOptions<T, TSelect>, "repository">;
16
- itemLoaderOptions: Omit<TableItemLoaderOptions<T, TSelect>, "repository">;
15
+ loaderOptions: Omit<TableLoaderOptions<T, TSelect>, "repository"> & {
16
+ loader?: LoaderFunction;
17
+ };
18
+ itemLoaderOptions: Omit<TableItemLoaderOptions<T, TSelect>, "repository"> & {
19
+ loader?: LoaderFunction;
20
+ };
17
21
  };
18
22
  type CrudHandler = (prefix: string) => (args: LoaderFunctionArgs) => Promise<any>;
19
- declare function crudHandler<T extends Table, TSelect>({ repository, apiHandlerOptions, loaderOptions, itemLoaderOptions, }: CrudHandlerOptions<T, TSelect>): (prefix: string) => (args: LoaderFunctionArgs) => Promise<any>;
23
+ declare function crudHandler<T extends Table, TSelect>({ repository, apiHandlerOptions, loaderOptions, itemLoaderOptions, }: CrudHandlerOptions<T, TSelect>): (prefix: string) => (args: LoaderFunctionArgs) => Promise<unknown>;
20
24
 
21
25
  export { type CrudHandler, type CrudHandlerOptions, crudHandler };
@@ -69,24 +69,16 @@ function tableLoader({
69
69
 
70
70
  // src/table/item_loader.tsx
71
71
  var tableItemloader = ({
72
- loader,
73
72
  repository
74
73
  }) => {
75
- return async ({ params }) => {
76
- const body = loader ? await (async () => {
77
- const result = await loader({ params });
78
- if (result instanceof Response) {
79
- return result.json();
80
- }
81
- return result;
82
- })() : {};
74
+ return async (args) => {
75
+ const { params } = args;
83
76
  if (params["itemId"] === "new") {
84
- return { item: void 0, ...body };
77
+ return { item: void 0 };
85
78
  }
86
79
  const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
87
80
  return {
88
- item,
89
- ...body
81
+ item
90
82
  };
91
83
  };
92
84
  };
@@ -272,13 +264,35 @@ function crudHandler({
272
264
  }
273
265
  }
274
266
  if (pattern === prefix) {
275
- return tableLoader({
267
+ const body = await tableLoader({
276
268
  ...loaderOptions,
277
269
  repository
278
270
  })(args);
271
+ if (loaderOptions.loader) {
272
+ const result = await loaderOptions.loader(args);
273
+ if (typeof result === "object") {
274
+ return {
275
+ ...result,
276
+ ...body
277
+ };
278
+ }
279
+ }
280
+ return body;
279
281
  }
280
282
  if (pattern.startsWith(prefix)) {
281
- return tableItemloader({ ...itemLoaderOptions, repository })(args);
283
+ const body = await tableItemloader({ ...itemLoaderOptions, repository })(
284
+ args
285
+ );
286
+ if (itemLoaderOptions.loader) {
287
+ const result = await itemLoaderOptions.loader(args);
288
+ if (typeof result === "object") {
289
+ return {
290
+ ...result,
291
+ ...body
292
+ };
293
+ }
294
+ }
295
+ return body;
282
296
  }
283
297
  };
284
298
  }
@@ -46,24 +46,16 @@ function tableLoader({
46
46
 
47
47
  // src/table/item_loader.tsx
48
48
  var tableItemloader = ({
49
- loader,
50
49
  repository
51
50
  }) => {
52
- return async ({ params }) => {
53
- const body = loader ? await (async () => {
54
- const result = await loader({ params });
55
- if (result instanceof Response) {
56
- return result.json();
57
- }
58
- return result;
59
- })() : {};
51
+ return async (args) => {
52
+ const { params } = args;
60
53
  if (params["itemId"] === "new") {
61
- return { item: void 0, ...body };
54
+ return { item: void 0 };
62
55
  }
63
56
  const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
64
57
  return {
65
- item,
66
- ...body
58
+ item
67
59
  };
68
60
  };
69
61
  };
@@ -258,13 +250,35 @@ function crudHandler({
258
250
  }
259
251
  }
260
252
  if (pattern === prefix) {
261
- return tableLoader({
253
+ const body = await tableLoader({
262
254
  ...loaderOptions,
263
255
  repository
264
256
  })(args);
257
+ if (loaderOptions.loader) {
258
+ const result = await loaderOptions.loader(args);
259
+ if (typeof result === "object") {
260
+ return {
261
+ ...result,
262
+ ...body
263
+ };
264
+ }
265
+ }
266
+ return body;
265
267
  }
266
268
  if (pattern.startsWith(prefix)) {
267
- return tableItemloader({ ...itemLoaderOptions, repository })(args);
269
+ const body = await tableItemloader({ ...itemLoaderOptions, repository })(
270
+ args
271
+ );
272
+ if (itemLoaderOptions.loader) {
273
+ const result = await itemLoaderOptions.loader(args);
274
+ if (typeof result === "object") {
275
+ return {
276
+ ...result,
277
+ ...body
278
+ };
279
+ }
280
+ }
281
+ return body;
268
282
  }
269
283
  };
270
284
  }
@@ -248,24 +248,16 @@ function tableLoader({
248
248
 
249
249
  // src/table/item_loader.tsx
250
250
  var tableItemloader = ({
251
- loader,
252
251
  repository
253
252
  }) => {
254
- return async ({ params }) => {
255
- const body = loader ? await (async () => {
256
- const result = await loader({ params });
257
- if (result instanceof Response) {
258
- return result.json();
259
- }
260
- return result;
261
- })() : {};
253
+ return async (args) => {
254
+ const { params } = args;
262
255
  if (params["itemId"] === "new") {
263
- return { item: void 0, ...body };
256
+ return { item: void 0 };
264
257
  }
265
258
  const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
266
259
  return {
267
- item,
268
- ...body
260
+ item
269
261
  };
270
262
  };
271
263
  };
@@ -451,13 +443,35 @@ function crudHandler({
451
443
  }
452
444
  }
453
445
  if (pattern === prefix2) {
454
- return tableLoader({
446
+ const body = await tableLoader({
455
447
  ...loaderOptions,
456
448
  repository
457
449
  })(args);
450
+ if (loaderOptions.loader) {
451
+ const result = await loaderOptions.loader(args);
452
+ if (typeof result === "object") {
453
+ return {
454
+ ...result,
455
+ ...body
456
+ };
457
+ }
458
+ }
459
+ return body;
458
460
  }
459
461
  if (pattern.startsWith(prefix2)) {
460
- return tableItemloader({ ...itemLoaderOptions, repository })(args);
462
+ const body = await tableItemloader({ ...itemLoaderOptions, repository })(
463
+ args
464
+ );
465
+ if (itemLoaderOptions.loader) {
466
+ const result = await itemLoaderOptions.loader(args);
467
+ if (typeof result === "object") {
468
+ return {
469
+ ...result,
470
+ ...body
471
+ };
472
+ }
473
+ }
474
+ return body;
461
475
  }
462
476
  };
463
477
  }
@@ -209,24 +209,16 @@ function tableLoader({
209
209
 
210
210
  // src/table/item_loader.tsx
211
211
  var tableItemloader = ({
212
- loader,
213
212
  repository
214
213
  }) => {
215
- return async ({ params }) => {
216
- const body = loader ? await (async () => {
217
- const result = await loader({ params });
218
- if (result instanceof Response) {
219
- return result.json();
220
- }
221
- return result;
222
- })() : {};
214
+ return async (args) => {
215
+ const { params } = args;
223
216
  if (params["itemId"] === "new") {
224
- return { item: void 0, ...body };
217
+ return { item: void 0 };
225
218
  }
226
219
  const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
227
220
  return {
228
- item,
229
- ...body
221
+ item
230
222
  };
231
223
  };
232
224
  };
@@ -421,13 +413,35 @@ function crudHandler({
421
413
  }
422
414
  }
423
415
  if (pattern === prefix2) {
424
- return tableLoader({
416
+ const body = await tableLoader({
425
417
  ...loaderOptions,
426
418
  repository
427
419
  })(args);
420
+ if (loaderOptions.loader) {
421
+ const result = await loaderOptions.loader(args);
422
+ if (typeof result === "object") {
423
+ return {
424
+ ...result,
425
+ ...body
426
+ };
427
+ }
428
+ }
429
+ return body;
428
430
  }
429
431
  if (pattern.startsWith(prefix2)) {
430
- return tableItemloader({ ...itemLoaderOptions, repository })(args);
432
+ const body = await tableItemloader({ ...itemLoaderOptions, repository })(
433
+ args
434
+ );
435
+ if (itemLoaderOptions.loader) {
436
+ const result = await itemLoaderOptions.loader(args);
437
+ if (typeof result === "object") {
438
+ return {
439
+ ...result,
440
+ ...body
441
+ };
442
+ }
443
+ }
444
+ return body;
431
445
  }
432
446
  };
433
447
  }
@@ -158,24 +158,16 @@ function TablePageButtons({
158
158
 
159
159
  // src/table/item_loader.tsx
160
160
  var tableItemloader = ({
161
- loader,
162
161
  repository
163
162
  }) => {
164
- return async ({ params }) => {
165
- const body = loader ? await (async () => {
166
- const result = await loader({ params });
167
- if (result instanceof Response) {
168
- return result.json();
169
- }
170
- return result;
171
- })() : {};
163
+ return async (args) => {
164
+ const { params } = args;
172
165
  if (params["itemId"] === "new") {
173
- return { item: void 0, ...body };
166
+ return { item: void 0 };
174
167
  }
175
168
  const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
176
169
  return {
177
- item,
178
- ...body
170
+ item
179
171
  };
180
172
  };
181
173
  };
@@ -123,24 +123,16 @@ function TablePageButtons({
123
123
 
124
124
  // src/table/item_loader.tsx
125
125
  var tableItemloader = ({
126
- loader,
127
126
  repository
128
127
  }) => {
129
- return async ({ params }) => {
130
- const body = loader ? await (async () => {
131
- const result = await loader({ params });
132
- if (result instanceof Response) {
133
- return result.json();
134
- }
135
- return result;
136
- })() : {};
128
+ return async (args) => {
129
+ const { params } = args;
137
130
  if (params["itemId"] === "new") {
138
- return { item: void 0, ...body };
131
+ return { item: void 0 };
139
132
  }
140
133
  const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
141
134
  return {
142
- item,
143
- ...body
135
+ item
144
136
  };
145
137
  };
146
138
  };
@@ -4,9 +4,10 @@ import { LoaderFunctionArgs } from 'react-router';
4
4
  import 'drizzle-orm/pg-core';
5
5
 
6
6
  type TableItemLoaderOptions<T extends Table, TSelect> = {
7
- loader?: (args: LoaderFunctionArgs) => Promise<any>;
8
7
  repository: TableRepository<T, TSelect>;
9
8
  };
10
- declare const tableItemloader: <T extends Table, TSelect>({ loader, repository, }: TableItemLoaderOptions<T, TSelect>) => ({ params }: LoaderFunctionArgs) => Promise<any>;
9
+ declare const tableItemloader: <T extends Table, TSelect>({ repository, }: TableItemLoaderOptions<T, TSelect>) => (args: LoaderFunctionArgs) => Promise<{
10
+ item: Awaited<TSelect> | undefined;
11
+ }>;
11
12
 
12
13
  export { type TableItemLoaderOptions, tableItemloader };
@@ -4,9 +4,10 @@ import { LoaderFunctionArgs } from 'react-router';
4
4
  import 'drizzle-orm/pg-core';
5
5
 
6
6
  type TableItemLoaderOptions<T extends Table, TSelect> = {
7
- loader?: (args: LoaderFunctionArgs) => Promise<any>;
8
7
  repository: TableRepository<T, TSelect>;
9
8
  };
10
- declare const tableItemloader: <T extends Table, TSelect>({ loader, repository, }: TableItemLoaderOptions<T, TSelect>) => ({ params }: LoaderFunctionArgs) => Promise<any>;
9
+ declare const tableItemloader: <T extends Table, TSelect>({ repository, }: TableItemLoaderOptions<T, TSelect>) => (args: LoaderFunctionArgs) => Promise<{
10
+ item: Awaited<TSelect> | undefined;
11
+ }>;
11
12
 
12
13
  export { type TableItemLoaderOptions, tableItemloader };
@@ -24,24 +24,16 @@ __export(item_loader_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(item_loader_exports);
26
26
  var tableItemloader = ({
27
- loader,
28
27
  repository
29
28
  }) => {
30
- return async ({ params }) => {
31
- const body = loader ? await (async () => {
32
- const result = await loader({ params });
33
- if (result instanceof Response) {
34
- return result.json();
35
- }
36
- return result;
37
- })() : {};
29
+ return async (args) => {
30
+ const { params } = args;
38
31
  if (params["itemId"] === "new") {
39
- return { item: void 0, ...body };
32
+ return { item: void 0 };
40
33
  }
41
34
  const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
42
35
  return {
43
- item,
44
- ...body
36
+ item
45
37
  };
46
38
  };
47
39
  };
@@ -1,23 +1,15 @@
1
1
  // src/table/item_loader.tsx
2
2
  var tableItemloader = ({
3
- loader,
4
3
  repository
5
4
  }) => {
6
- return async ({ params }) => {
7
- const body = loader ? await (async () => {
8
- const result = await loader({ params });
9
- if (result instanceof Response) {
10
- return result.json();
11
- }
12
- return result;
13
- })() : {};
5
+ return async (args) => {
6
+ const { params } = args;
14
7
  if (params["itemId"] === "new") {
15
- return { item: void 0, ...body };
8
+ return { item: void 0 };
16
9
  }
17
10
  const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
18
11
  return {
19
- item,
20
- ...body
12
+ item
21
13
  };
22
14
  };
23
15
  };
package/package.json CHANGED
@@ -1,84 +1,84 @@
1
1
  {
2
- "name": "dn-react-router-toolkit",
3
- "version": "0.5.2",
4
- "types": "./dist/index.d.ts",
5
- "main": "./dist/index.mjs",
6
- "module": "./dist/index.js",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.mjs",
11
- "require": "./dist/index.js"
12
- },
13
- "./auth": {
14
- "types": "./dist/auth/index.d.ts",
15
- "import": "./dist/auth/index.mjs",
16
- "require": "./dist/auth/index.js"
17
- },
18
- "./api": {
19
- "types": "./dist/api/index.d.ts",
20
- "import": "./dist/api/index.mjs",
21
- "require": "./dist/api/index.js"
22
- },
23
- "./client": {
24
- "types": "./dist/client/index.d.ts",
25
- "import": "./dist/client/index.mjs",
26
- "require": "./dist/client/index.js"
27
- },
28
- "./seo": {
29
- "types": "./dist/seo/index.d.ts",
30
- "import": "./dist/seo/index.mjs",
31
- "require": "./dist/seo/index.js"
32
- },
33
- "./db": {
34
- "types": "./dist/db/index.d.ts",
35
- "import": "./dist/db/index.mjs",
36
- "require": "./dist/db/index.js"
37
- },
38
- "./table": {
39
- "types": "./dist/table/index.d.ts",
40
- "import": "./dist/table/index.mjs",
41
- "require": "./dist/table/index.js"
42
- },
43
- "./crud": {
44
- "types": "./dist/crud/index.d.ts",
45
- "import": "./dist/crud/index.mjs",
46
- "require": "./dist/crud/index.js"
47
- }
2
+ "name": "dn-react-router-toolkit",
3
+ "version": "0.5.3",
4
+ "types": "./dist/index.d.ts",
5
+ "main": "./dist/index.mjs",
6
+ "module": "./dist/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js"
48
12
  },
49
- "scripts": {
50
- "build": "tsup",
51
- "dev": "tsup --watch"
13
+ "./auth": {
14
+ "types": "./dist/auth/index.d.ts",
15
+ "import": "./dist/auth/index.mjs",
16
+ "require": "./dist/auth/index.js"
52
17
  },
53
- "repository": {
54
- "type": "git",
55
- "url": "git+https://github.com/dndnsoft/dn-react-router-toolkit.git"
18
+ "./api": {
19
+ "types": "./dist/api/index.d.ts",
20
+ "import": "./dist/api/index.mjs",
21
+ "require": "./dist/api/index.js"
56
22
  },
57
- "author": "",
58
- "license": "MIT",
59
- "bugs": {
60
- "url": "https://github.com/dndnsoft/dn-react-router-toolkit/issues"
23
+ "./client": {
24
+ "types": "./dist/client/index.d.ts",
25
+ "import": "./dist/client/index.mjs",
26
+ "require": "./dist/client/index.js"
61
27
  },
62
- "homepage": "https://github.com/dndnsoft/dn-react-router-toolkit#readme",
63
- "description": "",
64
- "devDependencies": {
65
- "@types/node": "^24.10.1",
66
- "@types/react": "^19",
67
- "@types/react-dom": "^19",
68
- "schema-dts": "^1.1.5",
69
- "tsup": "^8.5.1",
70
- "typescript": "^5.7.3"
28
+ "./seo": {
29
+ "types": "./dist/seo/index.d.ts",
30
+ "import": "./dist/seo/index.mjs",
31
+ "require": "./dist/seo/index.js"
71
32
  },
72
- "dependencies": {
73
- "@react-router/dev": "^7.11.0",
74
- "dn-react-toolkit": "0.2.36",
75
- "pg": "^8.16.3",
76
- "uuid": "^13.0.0"
33
+ "./db": {
34
+ "types": "./dist/db/index.d.ts",
35
+ "import": "./dist/db/index.mjs",
36
+ "require": "./dist/db/index.js"
77
37
  },
78
- "peerDependencies": {
79
- "drizzle-orm": "0.45.1",
80
- "react": "^19",
81
- "react-dom": "^19",
82
- "react-router": "^7"
38
+ "./table": {
39
+ "types": "./dist/table/index.d.ts",
40
+ "import": "./dist/table/index.mjs",
41
+ "require": "./dist/table/index.js"
42
+ },
43
+ "./crud": {
44
+ "types": "./dist/crud/index.d.ts",
45
+ "import": "./dist/crud/index.mjs",
46
+ "require": "./dist/crud/index.js"
83
47
  }
48
+ },
49
+ "scripts": {
50
+ "build": "tsup",
51
+ "dev": "tsup --watch"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/dndnsoft/dn-react-router-toolkit.git"
56
+ },
57
+ "author": "",
58
+ "license": "MIT",
59
+ "bugs": {
60
+ "url": "https://github.com/dndnsoft/dn-react-router-toolkit/issues"
61
+ },
62
+ "homepage": "https://github.com/dndnsoft/dn-react-router-toolkit#readme",
63
+ "description": "",
64
+ "devDependencies": {
65
+ "@types/node": "^24.10.1",
66
+ "@types/react": "^19",
67
+ "@types/react-dom": "^19",
68
+ "schema-dts": "^1.1.5",
69
+ "tsup": "^8.5.1",
70
+ "typescript": "^5.7.3"
71
+ },
72
+ "dependencies": {
73
+ "@react-router/dev": "^7.11.0",
74
+ "pg": "^8.16.3",
75
+ "uuid": "^13.0.0"
76
+ },
77
+ "peerDependencies": {
78
+ "dn-react-toolkit": "^0.2.43",
79
+ "drizzle-orm": "^0.45.1",
80
+ "react": "^19",
81
+ "react-dom": "^19",
82
+ "react-router": "^7"
83
+ }
84
84
  }