dn-react-router-toolkit 0.7.4 → 0.7.6
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/dist/api/create_api_handler.d.mts +3 -2
- package/dist/api/create_api_handler.d.ts +3 -2
- package/dist/api/create_api_handler.js +7 -11
- package/dist/api/create_api_handler.mjs +10 -15
- package/dist/crud/crud_form_provider.d.mts +1 -1
- package/dist/crud/crud_form_provider.d.ts +1 -1
- package/dist/crud/crud_loader.js +7 -11
- package/dist/crud/crud_loader.mjs +12 -17
- package/dist/crud/crud_page.d.mts +1 -1
- package/dist/crud/crud_page.d.ts +1 -1
- package/dist/crud/index.d.mts +1 -0
- package/dist/crud/index.d.ts +1 -0
- package/dist/crud/index.js +11 -11
- package/dist/crud/index.mjs +14 -17
- package/dist/post/index.mjs +4 -5
- package/dist/post/post_form_page.mjs +4 -5
- package/package.json +92 -92
|
@@ -15,12 +15,13 @@ type APIHandlerOptions<T extends Table, TSelect> = {
|
|
|
15
15
|
message?: (value?: InferInsertModel<T>[K]) => string;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
existingConditions
|
|
18
|
+
existingConditions?: {
|
|
19
19
|
[K in keyof InferInsertModel<T>]?: (value: InferInsertModel<T>[K]) => SQLWrapper;
|
|
20
20
|
};
|
|
21
21
|
injectUserId?: boolean;
|
|
22
|
+
roles?: string[];
|
|
22
23
|
};
|
|
23
|
-
declare function apiHandler<T extends Table, TSelect>({ withAuthAction, repository, validators, existingConditions, injectUserId, }: APIHandlerOptions<T, TSelect>): {
|
|
24
|
+
declare function apiHandler<T extends Table, TSelect>({ withAuthAction, repository, validators, existingConditions, injectUserId, roles, }: APIHandlerOptions<T, TSelect>): {
|
|
24
25
|
loader: ({ request }: LoaderFunctionArgs) => Promise<{}>;
|
|
25
26
|
action: (arg: ActionFunctionArgs<any>) => Promise<unknown> | unknown;
|
|
26
27
|
};
|
|
@@ -15,12 +15,13 @@ type APIHandlerOptions<T extends Table, TSelect> = {
|
|
|
15
15
|
message?: (value?: InferInsertModel<T>[K]) => string;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
existingConditions
|
|
18
|
+
existingConditions?: {
|
|
19
19
|
[K in keyof InferInsertModel<T>]?: (value: InferInsertModel<T>[K]) => SQLWrapper;
|
|
20
20
|
};
|
|
21
21
|
injectUserId?: boolean;
|
|
22
|
+
roles?: string[];
|
|
22
23
|
};
|
|
23
|
-
declare function apiHandler<T extends Table, TSelect>({ withAuthAction, repository, validators, existingConditions, injectUserId, }: APIHandlerOptions<T, TSelect>): {
|
|
24
|
+
declare function apiHandler<T extends Table, TSelect>({ withAuthAction, repository, validators, existingConditions, injectUserId, roles, }: APIHandlerOptions<T, TSelect>): {
|
|
24
25
|
loader: ({ request }: LoaderFunctionArgs) => Promise<{}>;
|
|
25
26
|
action: (arg: ActionFunctionArgs<any>) => Promise<unknown> | unknown;
|
|
26
27
|
};
|
|
@@ -71,14 +71,15 @@ function apiHandler({
|
|
|
71
71
|
repository,
|
|
72
72
|
validators,
|
|
73
73
|
existingConditions,
|
|
74
|
-
injectUserId
|
|
74
|
+
injectUserId,
|
|
75
|
+
roles
|
|
75
76
|
}) {
|
|
76
77
|
const loader = async ({ request }) => {
|
|
77
78
|
return {};
|
|
78
79
|
};
|
|
79
80
|
const action = withAuthAction((auth) => async ({ request }) => {
|
|
80
|
-
if (!auth || auth.role
|
|
81
|
-
|
|
81
|
+
if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
|
|
82
|
+
throw (0, import_http.UNAUTHORIZED)();
|
|
82
83
|
}
|
|
83
84
|
switch (request.method) {
|
|
84
85
|
case "POST":
|
|
@@ -87,13 +88,8 @@ function apiHandler({
|
|
|
87
88
|
const serilaizedParams = await request.json();
|
|
88
89
|
const params = deserialize(serilaizedParams);
|
|
89
90
|
if (validators) {
|
|
90
|
-
const paramsForValidation = Object.keys(
|
|
91
|
-
validators
|
|
92
|
-
).filter(
|
|
93
|
-
(key) => Object.prototype.hasOwnProperty.call(
|
|
94
|
-
validators,
|
|
95
|
-
key
|
|
96
|
-
)
|
|
91
|
+
const paramsForValidation = Object.keys(validators).filter(
|
|
92
|
+
(key) => Object.prototype.hasOwnProperty.call(validators, key)
|
|
97
93
|
);
|
|
98
94
|
for (const paramKey of paramsForValidation) {
|
|
99
95
|
const value = params[paramKey];
|
|
@@ -133,7 +129,7 @@ function apiHandler({
|
|
|
133
129
|
}
|
|
134
130
|
const values = {
|
|
135
131
|
id: itemId,
|
|
136
|
-
userId: injectUserId ? auth
|
|
132
|
+
userId: injectUserId ? auth?.userId : void 0,
|
|
137
133
|
...params
|
|
138
134
|
};
|
|
139
135
|
const item = await repository.save(values);
|
|
@@ -4,14 +4,13 @@ import {
|
|
|
4
4
|
CONFLICT,
|
|
5
5
|
CREATED,
|
|
6
6
|
INTERNAL_SERVER_ERROR,
|
|
7
|
-
METHOD_NOT_ALLOWED
|
|
7
|
+
METHOD_NOT_ALLOWED,
|
|
8
|
+
UNAUTHORIZED
|
|
8
9
|
} from "dn-react-toolkit/http";
|
|
9
10
|
import {
|
|
10
11
|
and
|
|
11
12
|
} from "drizzle-orm";
|
|
12
|
-
import
|
|
13
|
-
redirect
|
|
14
|
-
} from "react-router";
|
|
13
|
+
import "react-router";
|
|
15
14
|
import { v4 } from "uuid";
|
|
16
15
|
|
|
17
16
|
// src/crud/serialize.ts
|
|
@@ -57,14 +56,15 @@ function apiHandler({
|
|
|
57
56
|
repository,
|
|
58
57
|
validators,
|
|
59
58
|
existingConditions,
|
|
60
|
-
injectUserId
|
|
59
|
+
injectUserId,
|
|
60
|
+
roles
|
|
61
61
|
}) {
|
|
62
62
|
const loader = async ({ request }) => {
|
|
63
63
|
return {};
|
|
64
64
|
};
|
|
65
65
|
const action = withAuthAction((auth) => async ({ request }) => {
|
|
66
|
-
if (!auth || auth.role
|
|
67
|
-
|
|
66
|
+
if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
|
|
67
|
+
throw UNAUTHORIZED();
|
|
68
68
|
}
|
|
69
69
|
switch (request.method) {
|
|
70
70
|
case "POST":
|
|
@@ -73,13 +73,8 @@ function apiHandler({
|
|
|
73
73
|
const serilaizedParams = await request.json();
|
|
74
74
|
const params = deserialize(serilaizedParams);
|
|
75
75
|
if (validators) {
|
|
76
|
-
const paramsForValidation = Object.keys(
|
|
77
|
-
validators
|
|
78
|
-
).filter(
|
|
79
|
-
(key) => Object.prototype.hasOwnProperty.call(
|
|
80
|
-
validators,
|
|
81
|
-
key
|
|
82
|
-
)
|
|
76
|
+
const paramsForValidation = Object.keys(validators).filter(
|
|
77
|
+
(key) => Object.prototype.hasOwnProperty.call(validators, key)
|
|
83
78
|
);
|
|
84
79
|
for (const paramKey of paramsForValidation) {
|
|
85
80
|
const value = params[paramKey];
|
|
@@ -119,7 +114,7 @@ function apiHandler({
|
|
|
119
114
|
}
|
|
120
115
|
const values = {
|
|
121
116
|
id: itemId,
|
|
122
|
-
userId: injectUserId ? auth
|
|
117
|
+
userId: injectUserId ? auth?.userId : void 0,
|
|
123
118
|
...params
|
|
124
119
|
};
|
|
125
120
|
const item = await repository.save(values);
|
|
@@ -25,7 +25,7 @@ type FormContextProps<TModel> = {
|
|
|
25
25
|
declare const FormContext: React__default.Context<{}>;
|
|
26
26
|
declare function useFormContext<TModel>(): FormContextProps<TModel>;
|
|
27
27
|
type CrudFormProps<TModel> = {
|
|
28
|
-
primaryKey
|
|
28
|
+
primaryKey?: keyof TModel;
|
|
29
29
|
name: string;
|
|
30
30
|
prefix: string;
|
|
31
31
|
item?: TModel;
|
|
@@ -25,7 +25,7 @@ type FormContextProps<TModel> = {
|
|
|
25
25
|
declare const FormContext: React__default.Context<{}>;
|
|
26
26
|
declare function useFormContext<TModel>(): FormContextProps<TModel>;
|
|
27
27
|
type CrudFormProps<TModel> = {
|
|
28
|
-
primaryKey
|
|
28
|
+
primaryKey?: keyof TModel;
|
|
29
29
|
name: string;
|
|
30
30
|
prefix: string;
|
|
31
31
|
item?: TModel;
|
package/dist/crud/crud_loader.js
CHANGED
|
@@ -132,14 +132,15 @@ function apiHandler({
|
|
|
132
132
|
repository,
|
|
133
133
|
validators,
|
|
134
134
|
existingConditions,
|
|
135
|
-
injectUserId
|
|
135
|
+
injectUserId,
|
|
136
|
+
roles
|
|
136
137
|
}) {
|
|
137
138
|
const loader = async ({ request }) => {
|
|
138
139
|
return {};
|
|
139
140
|
};
|
|
140
141
|
const action = withAuthAction((auth) => async ({ request }) => {
|
|
141
|
-
if (!auth || auth.role
|
|
142
|
-
|
|
142
|
+
if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
|
|
143
|
+
throw (0, import_http.UNAUTHORIZED)();
|
|
143
144
|
}
|
|
144
145
|
switch (request.method) {
|
|
145
146
|
case "POST":
|
|
@@ -148,13 +149,8 @@ function apiHandler({
|
|
|
148
149
|
const serilaizedParams = await request.json();
|
|
149
150
|
const params = deserialize(serilaizedParams);
|
|
150
151
|
if (validators) {
|
|
151
|
-
const paramsForValidation = Object.keys(
|
|
152
|
-
validators
|
|
153
|
-
).filter(
|
|
154
|
-
(key) => Object.prototype.hasOwnProperty.call(
|
|
155
|
-
validators,
|
|
156
|
-
key
|
|
157
|
-
)
|
|
152
|
+
const paramsForValidation = Object.keys(validators).filter(
|
|
153
|
+
(key) => Object.prototype.hasOwnProperty.call(validators, key)
|
|
158
154
|
);
|
|
159
155
|
for (const paramKey of paramsForValidation) {
|
|
160
156
|
const value = params[paramKey];
|
|
@@ -194,7 +190,7 @@ function apiHandler({
|
|
|
194
190
|
}
|
|
195
191
|
const values = {
|
|
196
192
|
id: itemId,
|
|
197
|
-
userId: injectUserId ? auth
|
|
193
|
+
userId: injectUserId ? auth?.userId : void 0,
|
|
198
194
|
...params
|
|
199
195
|
};
|
|
200
196
|
const item = await repository.save(values);
|
|
@@ -66,14 +66,13 @@ import {
|
|
|
66
66
|
CONFLICT,
|
|
67
67
|
CREATED,
|
|
68
68
|
INTERNAL_SERVER_ERROR,
|
|
69
|
-
METHOD_NOT_ALLOWED
|
|
69
|
+
METHOD_NOT_ALLOWED,
|
|
70
|
+
UNAUTHORIZED
|
|
70
71
|
} from "dn-react-toolkit/http";
|
|
71
72
|
import {
|
|
72
73
|
and as and2
|
|
73
74
|
} from "drizzle-orm";
|
|
74
|
-
import
|
|
75
|
-
redirect
|
|
76
|
-
} from "react-router";
|
|
75
|
+
import "react-router";
|
|
77
76
|
import { v4 } from "uuid";
|
|
78
77
|
|
|
79
78
|
// src/crud/serialize.ts
|
|
@@ -119,14 +118,15 @@ function apiHandler({
|
|
|
119
118
|
repository,
|
|
120
119
|
validators,
|
|
121
120
|
existingConditions,
|
|
122
|
-
injectUserId
|
|
121
|
+
injectUserId,
|
|
122
|
+
roles
|
|
123
123
|
}) {
|
|
124
124
|
const loader = async ({ request }) => {
|
|
125
125
|
return {};
|
|
126
126
|
};
|
|
127
127
|
const action = withAuthAction((auth) => async ({ request }) => {
|
|
128
|
-
if (!auth || auth.role
|
|
129
|
-
|
|
128
|
+
if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
|
|
129
|
+
throw UNAUTHORIZED();
|
|
130
130
|
}
|
|
131
131
|
switch (request.method) {
|
|
132
132
|
case "POST":
|
|
@@ -135,13 +135,8 @@ function apiHandler({
|
|
|
135
135
|
const serilaizedParams = await request.json();
|
|
136
136
|
const params = deserialize(serilaizedParams);
|
|
137
137
|
if (validators) {
|
|
138
|
-
const paramsForValidation = Object.keys(
|
|
139
|
-
validators
|
|
140
|
-
).filter(
|
|
141
|
-
(key) => Object.prototype.hasOwnProperty.call(
|
|
142
|
-
validators,
|
|
143
|
-
key
|
|
144
|
-
)
|
|
138
|
+
const paramsForValidation = Object.keys(validators).filter(
|
|
139
|
+
(key) => Object.prototype.hasOwnProperty.call(validators, key)
|
|
145
140
|
);
|
|
146
141
|
for (const paramKey of paramsForValidation) {
|
|
147
142
|
const value = params[paramKey];
|
|
@@ -181,7 +176,7 @@ function apiHandler({
|
|
|
181
176
|
}
|
|
182
177
|
const values = {
|
|
183
178
|
id: itemId,
|
|
184
|
-
userId: injectUserId ? auth
|
|
179
|
+
userId: injectUserId ? auth?.userId : void 0,
|
|
185
180
|
...params
|
|
186
181
|
};
|
|
187
182
|
const item = await repository.save(values);
|
|
@@ -204,7 +199,7 @@ function apiHandler({
|
|
|
204
199
|
}
|
|
205
200
|
|
|
206
201
|
// src/api/item_api_handler.ts
|
|
207
|
-
import { UNAUTHORIZED } from "dn-react-toolkit/http";
|
|
202
|
+
import { UNAUTHORIZED as UNAUTHORIZED2 } from "dn-react-toolkit/http";
|
|
208
203
|
import "react-router";
|
|
209
204
|
function itemApiHandler({
|
|
210
205
|
withAuthAction,
|
|
@@ -215,7 +210,7 @@ function itemApiHandler({
|
|
|
215
210
|
};
|
|
216
211
|
const action = withAuthAction((auth) => async ({ params, request }) => {
|
|
217
212
|
if (!auth || auth.role !== "admin") {
|
|
218
|
-
return
|
|
213
|
+
return UNAUTHORIZED2();
|
|
219
214
|
}
|
|
220
215
|
switch (request.method) {
|
|
221
216
|
case "DELETE": {
|
package/dist/crud/crud_page.d.ts
CHANGED
package/dist/crud/index.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ export { CrudPage, CrudPageOptions, crudPage } from './crud_page.mjs';
|
|
|
4
4
|
export { generateHandlers } from './generate_handlers.mjs';
|
|
5
5
|
export { generatePages } from './generate_pages.mjs';
|
|
6
6
|
export { generateCrudRoutes } from './generate_routes.mjs';
|
|
7
|
+
export { deserialize, serialize } from './serialize.mjs';
|
|
7
8
|
import 'react-store-input';
|
|
8
9
|
import 'react';
|
|
9
10
|
import 'react-router';
|
package/dist/crud/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { CrudPage, CrudPageOptions, crudPage } from './crud_page.js';
|
|
|
4
4
|
export { generateHandlers } from './generate_handlers.js';
|
|
5
5
|
export { generatePages } from './generate_pages.js';
|
|
6
6
|
export { generateCrudRoutes } from './generate_routes.js';
|
|
7
|
+
export { deserialize, serialize } from './serialize.js';
|
|
7
8
|
import 'react-store-input';
|
|
8
9
|
import 'react';
|
|
9
10
|
import 'react-router';
|
package/dist/crud/index.js
CHANGED
|
@@ -7596,9 +7596,11 @@ __export(crud_exports, {
|
|
|
7596
7596
|
FormContext: () => FormContext,
|
|
7597
7597
|
crudHandler: () => crudHandler,
|
|
7598
7598
|
crudPage: () => crudPage,
|
|
7599
|
+
deserialize: () => deserialize,
|
|
7599
7600
|
generateCrudRoutes: () => generateCrudRoutes,
|
|
7600
7601
|
generateHandlers: () => generateHandlers,
|
|
7601
7602
|
generatePages: () => generatePages,
|
|
7603
|
+
serialize: () => serialize,
|
|
7602
7604
|
useFormContext: () => useFormContext
|
|
7603
7605
|
});
|
|
7604
7606
|
module.exports = __toCommonJS(crud_exports);
|
|
@@ -8036,14 +8038,15 @@ function apiHandler({
|
|
|
8036
8038
|
repository,
|
|
8037
8039
|
validators,
|
|
8038
8040
|
existingConditions,
|
|
8039
|
-
injectUserId
|
|
8041
|
+
injectUserId,
|
|
8042
|
+
roles
|
|
8040
8043
|
}) {
|
|
8041
8044
|
const loader = async ({ request }) => {
|
|
8042
8045
|
return {};
|
|
8043
8046
|
};
|
|
8044
8047
|
const action = withAuthAction((auth) => async ({ request }) => {
|
|
8045
|
-
if (!auth || auth.role
|
|
8046
|
-
|
|
8048
|
+
if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
|
|
8049
|
+
throw (0, import_http.UNAUTHORIZED)();
|
|
8047
8050
|
}
|
|
8048
8051
|
switch (request.method) {
|
|
8049
8052
|
case "POST":
|
|
@@ -8052,13 +8055,8 @@ function apiHandler({
|
|
|
8052
8055
|
const serilaizedParams = await request.json();
|
|
8053
8056
|
const params = deserialize(serilaizedParams);
|
|
8054
8057
|
if (validators) {
|
|
8055
|
-
const paramsForValidation = Object.keys(
|
|
8056
|
-
validators
|
|
8057
|
-
).filter(
|
|
8058
|
-
(key) => Object.prototype.hasOwnProperty.call(
|
|
8059
|
-
validators,
|
|
8060
|
-
key
|
|
8061
|
-
)
|
|
8058
|
+
const paramsForValidation = Object.keys(validators).filter(
|
|
8059
|
+
(key) => Object.prototype.hasOwnProperty.call(validators, key)
|
|
8062
8060
|
);
|
|
8063
8061
|
for (const paramKey of paramsForValidation) {
|
|
8064
8062
|
const value = params[paramKey];
|
|
@@ -8098,7 +8096,7 @@ function apiHandler({
|
|
|
8098
8096
|
}
|
|
8099
8097
|
const values = {
|
|
8100
8098
|
id: itemId,
|
|
8101
|
-
userId: injectUserId ? auth
|
|
8099
|
+
userId: injectUserId ? auth?.userId : void 0,
|
|
8102
8100
|
...params
|
|
8103
8101
|
};
|
|
8104
8102
|
const item = await repository.save(values);
|
|
@@ -8719,9 +8717,11 @@ function generateCrudRoutes(routes, apiFile, file) {
|
|
|
8719
8717
|
FormContext,
|
|
8720
8718
|
crudHandler,
|
|
8721
8719
|
crudPage,
|
|
8720
|
+
deserialize,
|
|
8722
8721
|
generateCrudRoutes,
|
|
8723
8722
|
generateHandlers,
|
|
8724
8723
|
generatePages,
|
|
8724
|
+
serialize,
|
|
8725
8725
|
useFormContext
|
|
8726
8726
|
});
|
|
8727
8727
|
/*! Bundled license information:
|
package/dist/crud/index.mjs
CHANGED
|
@@ -8018,28 +8018,28 @@ import {
|
|
|
8018
8018
|
CONFLICT,
|
|
8019
8019
|
CREATED,
|
|
8020
8020
|
INTERNAL_SERVER_ERROR,
|
|
8021
|
-
METHOD_NOT_ALLOWED
|
|
8021
|
+
METHOD_NOT_ALLOWED,
|
|
8022
|
+
UNAUTHORIZED
|
|
8022
8023
|
} from "dn-react-toolkit/http";
|
|
8023
8024
|
import {
|
|
8024
8025
|
and as and2
|
|
8025
8026
|
} from "drizzle-orm";
|
|
8026
|
-
import
|
|
8027
|
-
redirect
|
|
8028
|
-
} from "react-router";
|
|
8027
|
+
import "react-router";
|
|
8029
8028
|
import { v4 } from "uuid";
|
|
8030
8029
|
function apiHandler({
|
|
8031
8030
|
withAuthAction,
|
|
8032
8031
|
repository,
|
|
8033
8032
|
validators,
|
|
8034
8033
|
existingConditions,
|
|
8035
|
-
injectUserId
|
|
8034
|
+
injectUserId,
|
|
8035
|
+
roles
|
|
8036
8036
|
}) {
|
|
8037
8037
|
const loader = async ({ request }) => {
|
|
8038
8038
|
return {};
|
|
8039
8039
|
};
|
|
8040
8040
|
const action = withAuthAction((auth) => async ({ request }) => {
|
|
8041
|
-
if (!auth || auth.role
|
|
8042
|
-
|
|
8041
|
+
if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
|
|
8042
|
+
throw UNAUTHORIZED();
|
|
8043
8043
|
}
|
|
8044
8044
|
switch (request.method) {
|
|
8045
8045
|
case "POST":
|
|
@@ -8048,13 +8048,8 @@ function apiHandler({
|
|
|
8048
8048
|
const serilaizedParams = await request.json();
|
|
8049
8049
|
const params = deserialize(serilaizedParams);
|
|
8050
8050
|
if (validators) {
|
|
8051
|
-
const paramsForValidation = Object.keys(
|
|
8052
|
-
validators
|
|
8053
|
-
).filter(
|
|
8054
|
-
(key) => Object.prototype.hasOwnProperty.call(
|
|
8055
|
-
validators,
|
|
8056
|
-
key
|
|
8057
|
-
)
|
|
8051
|
+
const paramsForValidation = Object.keys(validators).filter(
|
|
8052
|
+
(key) => Object.prototype.hasOwnProperty.call(validators, key)
|
|
8058
8053
|
);
|
|
8059
8054
|
for (const paramKey of paramsForValidation) {
|
|
8060
8055
|
const value = params[paramKey];
|
|
@@ -8094,7 +8089,7 @@ function apiHandler({
|
|
|
8094
8089
|
}
|
|
8095
8090
|
const values = {
|
|
8096
8091
|
id: itemId,
|
|
8097
|
-
userId: injectUserId ? auth
|
|
8092
|
+
userId: injectUserId ? auth?.userId : void 0,
|
|
8098
8093
|
...params
|
|
8099
8094
|
};
|
|
8100
8095
|
const item = await repository.save(values);
|
|
@@ -8117,7 +8112,7 @@ function apiHandler({
|
|
|
8117
8112
|
}
|
|
8118
8113
|
|
|
8119
8114
|
// src/api/item_api_handler.ts
|
|
8120
|
-
import { UNAUTHORIZED } from "dn-react-toolkit/http";
|
|
8115
|
+
import { UNAUTHORIZED as UNAUTHORIZED2 } from "dn-react-toolkit/http";
|
|
8121
8116
|
import "react-router";
|
|
8122
8117
|
function itemApiHandler({
|
|
8123
8118
|
withAuthAction,
|
|
@@ -8128,7 +8123,7 @@ function itemApiHandler({
|
|
|
8128
8123
|
};
|
|
8129
8124
|
const action = withAuthAction((auth) => async ({ params, request }) => {
|
|
8130
8125
|
if (!auth || auth.role !== "admin") {
|
|
8131
|
-
return
|
|
8126
|
+
return UNAUTHORIZED2();
|
|
8132
8127
|
}
|
|
8133
8128
|
switch (request.method) {
|
|
8134
8129
|
case "DELETE": {
|
|
@@ -8720,9 +8715,11 @@ export {
|
|
|
8720
8715
|
FormContext,
|
|
8721
8716
|
crudHandler,
|
|
8722
8717
|
crudPage,
|
|
8718
|
+
deserialize,
|
|
8723
8719
|
generateCrudRoutes,
|
|
8724
8720
|
generateHandlers,
|
|
8725
8721
|
generatePages,
|
|
8722
|
+
serialize,
|
|
8726
8723
|
useFormContext
|
|
8727
8724
|
};
|
|
8728
8725
|
/*! Bundled license information:
|
package/dist/post/index.mjs
CHANGED
|
@@ -8083,18 +8083,17 @@ import {
|
|
|
8083
8083
|
CONFLICT,
|
|
8084
8084
|
CREATED,
|
|
8085
8085
|
INTERNAL_SERVER_ERROR,
|
|
8086
|
-
METHOD_NOT_ALLOWED
|
|
8086
|
+
METHOD_NOT_ALLOWED,
|
|
8087
|
+
UNAUTHORIZED
|
|
8087
8088
|
} from "dn-react-toolkit/http";
|
|
8088
8089
|
import {
|
|
8089
8090
|
and as and2
|
|
8090
8091
|
} from "drizzle-orm";
|
|
8091
|
-
import
|
|
8092
|
-
redirect
|
|
8093
|
-
} from "react-router";
|
|
8092
|
+
import "react-router";
|
|
8094
8093
|
import { v4 } from "uuid";
|
|
8095
8094
|
|
|
8096
8095
|
// src/api/item_api_handler.ts
|
|
8097
|
-
import { UNAUTHORIZED } from "dn-react-toolkit/http";
|
|
8096
|
+
import { UNAUTHORIZED as UNAUTHORIZED2 } from "dn-react-toolkit/http";
|
|
8098
8097
|
import "react-router";
|
|
8099
8098
|
|
|
8100
8099
|
// src/crud/crud_page.tsx
|
|
@@ -8085,18 +8085,17 @@ import {
|
|
|
8085
8085
|
CONFLICT,
|
|
8086
8086
|
CREATED,
|
|
8087
8087
|
INTERNAL_SERVER_ERROR,
|
|
8088
|
-
METHOD_NOT_ALLOWED
|
|
8088
|
+
METHOD_NOT_ALLOWED,
|
|
8089
|
+
UNAUTHORIZED
|
|
8089
8090
|
} from "dn-react-toolkit/http";
|
|
8090
8091
|
import {
|
|
8091
8092
|
and as and2
|
|
8092
8093
|
} from "drizzle-orm";
|
|
8093
|
-
import
|
|
8094
|
-
redirect
|
|
8095
|
-
} from "react-router";
|
|
8094
|
+
import "react-router";
|
|
8096
8095
|
import { v4 } from "uuid";
|
|
8097
8096
|
|
|
8098
8097
|
// src/api/item_api_handler.ts
|
|
8099
|
-
import { UNAUTHORIZED } from "dn-react-toolkit/http";
|
|
8098
|
+
import { UNAUTHORIZED as UNAUTHORIZED2 } from "dn-react-toolkit/http";
|
|
8100
8099
|
import "react-router";
|
|
8101
8100
|
|
|
8102
8101
|
// src/crud/crud_page.tsx
|
package/package.json
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
"./db/backup": {
|
|
39
|
-
"types": "./dist/db/backup/index.d.ts",
|
|
40
|
-
"import": "./dist/db/backup/index.mjs",
|
|
41
|
-
"require": "./dist/db/backup/index.js"
|
|
42
|
-
},
|
|
43
|
-
"./table": {
|
|
44
|
-
"types": "./dist/table/index.d.ts",
|
|
45
|
-
"import": "./dist/table/index.mjs",
|
|
46
|
-
"require": "./dist/table/index.js"
|
|
47
|
-
},
|
|
48
|
-
"./crud": {
|
|
49
|
-
"types": "./dist/crud/index.d.ts",
|
|
50
|
-
"import": "./dist/crud/index.mjs",
|
|
51
|
-
"require": "./dist/crud/index.js"
|
|
52
|
-
},
|
|
53
|
-
"./post": {
|
|
54
|
-
"types": "./dist/post/index.d.ts",
|
|
55
|
-
"import": "./dist/post/index.mjs",
|
|
56
|
-
"require": "./dist/post/index.js"
|
|
57
|
-
},
|
|
58
|
-
"./form": {
|
|
59
|
-
"types": "./dist/form/index.d.ts",
|
|
60
|
-
"import": "./dist/form/index.mjs",
|
|
61
|
-
"require": "./dist/form/index.js"
|
|
62
|
-
}
|
|
2
|
+
"name": "dn-react-router-toolkit",
|
|
3
|
+
"version": "0.7.6",
|
|
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"
|
|
63
12
|
},
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
13
|
+
"./auth": {
|
|
14
|
+
"types": "./dist/auth/index.d.ts",
|
|
15
|
+
"import": "./dist/auth/index.mjs",
|
|
16
|
+
"require": "./dist/auth/index.js"
|
|
67
17
|
},
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
18
|
+
"./api": {
|
|
19
|
+
"types": "./dist/api/index.d.ts",
|
|
20
|
+
"import": "./dist/api/index.mjs",
|
|
21
|
+
"require": "./dist/api/index.js"
|
|
71
22
|
},
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
23
|
+
"./client": {
|
|
24
|
+
"types": "./dist/client/index.d.ts",
|
|
25
|
+
"import": "./dist/client/index.mjs",
|
|
26
|
+
"require": "./dist/client/index.js"
|
|
76
27
|
},
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"@types/react": "^19",
|
|
82
|
-
"@types/react-dom": "^19",
|
|
83
|
-
"schema-dts": "^1.1.5",
|
|
84
|
-
"tsup": "^8.5.1",
|
|
85
|
-
"@react-router/dev": "^7.12.0",
|
|
86
|
-
"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"
|
|
87
32
|
},
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"react-store-input": "^0.2.0",
|
|
93
|
-
"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"
|
|
94
37
|
},
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
38
|
+
"./db/backup": {
|
|
39
|
+
"types": "./dist/db/backup/index.d.ts",
|
|
40
|
+
"import": "./dist/db/backup/index.mjs",
|
|
41
|
+
"require": "./dist/db/backup/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./table": {
|
|
44
|
+
"types": "./dist/table/index.d.ts",
|
|
45
|
+
"import": "./dist/table/index.mjs",
|
|
46
|
+
"require": "./dist/table/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./crud": {
|
|
49
|
+
"types": "./dist/crud/index.d.ts",
|
|
50
|
+
"import": "./dist/crud/index.mjs",
|
|
51
|
+
"require": "./dist/crud/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./post": {
|
|
54
|
+
"types": "./dist/post/index.d.ts",
|
|
55
|
+
"import": "./dist/post/index.mjs",
|
|
56
|
+
"require": "./dist/post/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./form": {
|
|
59
|
+
"types": "./dist/form/index.d.ts",
|
|
60
|
+
"import": "./dist/form/index.mjs",
|
|
61
|
+
"require": "./dist/form/index.js"
|
|
100
62
|
}
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsup",
|
|
66
|
+
"dev": "tsup --watch"
|
|
67
|
+
},
|
|
68
|
+
"repository": {
|
|
69
|
+
"type": "git",
|
|
70
|
+
"url": "git+https://github.com/dndnsoft/dn-react-router-toolkit.git"
|
|
71
|
+
},
|
|
72
|
+
"author": "",
|
|
73
|
+
"license": "MIT",
|
|
74
|
+
"bugs": {
|
|
75
|
+
"url": "https://github.com/dndnsoft/dn-react-router-toolkit/issues"
|
|
76
|
+
},
|
|
77
|
+
"homepage": "https://github.com/dndnsoft/dn-react-router-toolkit#readme",
|
|
78
|
+
"description": "",
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@types/node": "^24.10.1",
|
|
81
|
+
"@types/react": "^19",
|
|
82
|
+
"@types/react-dom": "^19",
|
|
83
|
+
"schema-dts": "^1.1.5",
|
|
84
|
+
"tsup": "^8.5.1",
|
|
85
|
+
"@react-router/dev": "^7.12.0",
|
|
86
|
+
"typescript": "^5.7.3"
|
|
87
|
+
},
|
|
88
|
+
"dependencies": {
|
|
89
|
+
"dn-react-text-editor": "^0.3.6",
|
|
90
|
+
"dn-react-toolkit": "^0.2.49",
|
|
91
|
+
"pg": "^8.16.3",
|
|
92
|
+
"react-store-input": "^0.2.0",
|
|
93
|
+
"uuid": "^13.0.0"
|
|
94
|
+
},
|
|
95
|
+
"peerDependencies": {
|
|
96
|
+
"drizzle-orm": "^0.45.1",
|
|
97
|
+
"react": "^19",
|
|
98
|
+
"react-dom": "^19",
|
|
99
|
+
"react-router": "^7.12.0"
|
|
100
|
+
}
|
|
101
101
|
}
|