@mpfrontend/data-react 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/README.md +30 -2
- package/dist/index.d.ts +82 -0
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -0
- package/dist/shared.d.ts +54 -0
- package/dist/shared.js +76 -0
- package/dist/shared.js.map +1 -0
- package/package.json +43 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mpfrontend/data-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Local development package. Runtime: client, with a universal shared entry. Public API is exported from
|
|
4
|
+
`src/index.tsx` and `src/shared.ts` and compiled into dist. Nx owns build, typecheck, lint and test targets.
|
|
5
|
+
Consumer applications install packed artifacts. See ../../docs/IMPLEMENTATION-STATUS.md for observed evidence and
|
|
6
|
+
remaining work.
|
|
7
|
+
|
|
8
|
+
The conventions for server data and URL state in client components. `@tanstack/react-query` and `nuqs` are peer
|
|
9
|
+
dependencies: the app owns its `QueryClient` and its nuqs adapter.
|
|
10
|
+
|
|
11
|
+
## Server data: `@mpfrontend/data-react`
|
|
12
|
+
|
|
13
|
+
- `QueryScope` sits inside the app's `QueryClientProvider` and the `AccessProvider` of `@mpfrontend/access-react`.
|
|
14
|
+
When the context reference or the revision of the access snapshot changes, it cancels and removes every query of
|
|
15
|
+
another scope and every query without a scope.
|
|
16
|
+
- `useScopedQuery({operation, params, read})` keys a read by the scope, the operation and the parameters, runs only
|
|
17
|
+
under a valid snapshot, passes an `AbortSignal` that also aborts at a change of scope, and drops an answer that
|
|
18
|
+
arrives after the change. `read` goes through the app's own route or the BFF.
|
|
19
|
+
- `useScopedMutation({operation, write, invalidates})` never retries a write automatically and invalidates the
|
|
20
|
+
named reads of the current scope after it succeeds.
|
|
21
|
+
|
|
22
|
+
## URL state: `@mpfrontend/data-react/shared` and `useTableUrlState`
|
|
23
|
+
|
|
24
|
+
`listUrlState(protocol, {size, sizes, sort})` defines the URL state of a list over a `ListProtocol` of
|
|
25
|
+
`@mpfrontend/ftg-core`: typed keys `page`, `size`, `sort` (`field.asc` or `field.desc`) and one per declared filter,
|
|
26
|
+
with defaults and limits. Only the sort fields and filters that the protocol declares are read; an invalid value
|
|
27
|
+
falls back to its default; values equal to their defaults are left out of the URL. `read(searchParams)` gives the
|
|
28
|
+
state on the server for the first render; `useListUrlState` and `useTableUrlState` give it in the browser, where each
|
|
29
|
+
change is a new history entry and a new size, sort or filter starts at the first page. With field access, a sort or
|
|
30
|
+
a filter on a field the person may not view is dropped and removed from the URL on load. The scope never enters the
|
|
31
|
+
URL. `scopedQueryKey` and `inScope` are the key functions of the convention.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type UseMutationResult, type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import type { ListSort, ListState } from '@mpfrontend/ftg-core';
|
|
4
|
+
import { type ListUrlState, type ViewCheck } from './shared.js';
|
|
5
|
+
export type { QueryScope as QueryKeyScope, ListUrlOptions, ListUrlState, ViewCheck } from './shared.js';
|
|
6
|
+
/**
|
|
7
|
+
* Keeps the app's query cache to the access scope in use. When the context reference or revision changes, every query
|
|
8
|
+
* of another scope, and every query without a scope, is cancelled and removed, so its data never shows again. Place
|
|
9
|
+
* it inside the app's QueryClientProvider and the AccessProvider.
|
|
10
|
+
*/
|
|
11
|
+
export declare function QueryScope({ children }: Readonly<{
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}>): ReactNode;
|
|
14
|
+
type JsonParams = string | number | boolean | null | readonly JsonParams[] | {
|
|
15
|
+
readonly [key: string]: JsonParams | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type ScopedQueryOptions<Params extends JsonParams, Data> = Readonly<{
|
|
18
|
+
/** A stable name of the read, the same for every parameter value. */
|
|
19
|
+
operation: string;
|
|
20
|
+
params: Params;
|
|
21
|
+
/** Reads through the app's own route or the BFF, never a backend directly, and passes the signal on. */
|
|
22
|
+
read: (params: Params, signal: AbortSignal) => Promise<Data>;
|
|
23
|
+
initialData?: Data;
|
|
24
|
+
enabled?: boolean;
|
|
25
|
+
staleTime?: number;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* A server read under the current access scope: its key is the scope, the operation and the parameters. Without a
|
|
29
|
+
* valid snapshot it does not run. A change of scope aborts it, and its late answer is dropped.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useScopedQuery<Params extends JsonParams, Data>(options: ScopedQueryOptions<Params, Data>): UseQueryResult<Data>;
|
|
32
|
+
export type ScopedMutationOptions<Variables, Result> = Readonly<{
|
|
33
|
+
operation: string;
|
|
34
|
+
/** Writes through the app's own route or the BFF and passes the signal on. */
|
|
35
|
+
write: (variables: Variables, signal: AbortSignal) => Promise<Result>;
|
|
36
|
+
/** The reads whose data the write changes; they are invalidated in the current scope after it succeeds. */
|
|
37
|
+
invalidates: readonly string[];
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* A write under the current access scope. It is never retried automatically, after a refusal or any other failure.
|
|
41
|
+
* A change of scope aborts it and its result is not published.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useScopedMutation<Variables, Result>(options: ScopedMutationOptions<Variables, Result>): UseMutationResult<Result, Error, Variables>;
|
|
44
|
+
export type ListStateChange = Readonly<{
|
|
45
|
+
page?: number;
|
|
46
|
+
size?: number;
|
|
47
|
+
sort?: ListSort | undefined;
|
|
48
|
+
filters?: Readonly<Record<string, string>>;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* The list state of the URL. Each change is a new history entry, so back and forward move through pages and filters;
|
|
52
|
+
* a new size, sort or filter starts again at the first page. A sort or a filter on a field the person may not view is
|
|
53
|
+
* dropped, and removed from the URL on load.
|
|
54
|
+
*/
|
|
55
|
+
export declare function useListUrlState(urlState: ListUrlState, options?: Readonly<{
|
|
56
|
+
canView?: ViewCheck;
|
|
57
|
+
}>): readonly [ListState, (change: ListStateChange) => void];
|
|
58
|
+
/** Field access for the URL state: a reader of the access snapshot. */
|
|
59
|
+
export type FieldView = Readonly<{
|
|
60
|
+
field: (key: string) => Readonly<{
|
|
61
|
+
view: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* The controlled values and change events of a ResourceTable bound to the URL: page, size, sort and filters.
|
|
66
|
+
* With `access`, a sort or a filter on a column the person may not view is dropped.
|
|
67
|
+
*/
|
|
68
|
+
export declare function useTableUrlState(urlState: ListUrlState, options?: Readonly<{
|
|
69
|
+
access?: FieldView;
|
|
70
|
+
}>): {
|
|
71
|
+
page: number;
|
|
72
|
+
size: number;
|
|
73
|
+
sort: Readonly<{
|
|
74
|
+
field: string;
|
|
75
|
+
direction: "asc" | "desc";
|
|
76
|
+
}> | undefined;
|
|
77
|
+
filters: Readonly<Record<string, string>>;
|
|
78
|
+
onPageChange: (page: number) => void;
|
|
79
|
+
onSizeChange: (size: number) => void;
|
|
80
|
+
onSortChange: (sort: ListSort | undefined) => void;
|
|
81
|
+
onFiltersChange: (filters: Readonly<Record<string, string>>) => void;
|
|
82
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { useQueryStates } from 'nuqs';
|
|
5
|
+
import { useAccessCapture, useAccessScope } from '@mpfrontend/access-react';
|
|
6
|
+
import { inScope, scopedQueryKey } from './shared.js';
|
|
7
|
+
/**
|
|
8
|
+
* Keeps the app's query cache to the access scope in use. When the context reference or revision changes, every query
|
|
9
|
+
* of another scope, and every query without a scope, is cancelled and removed, so its data never shows again. Place
|
|
10
|
+
* it inside the app's QueryClientProvider and the AccessProvider.
|
|
11
|
+
*/
|
|
12
|
+
export function QueryScope({ children }) {
|
|
13
|
+
const client = useQueryClient(), scope = useAccessScope();
|
|
14
|
+
const key = scope ? scope.contextRef + '\n' + scope.revision : '';
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const stale = { predicate: (query) => !inScope(query.queryKey, scope) };
|
|
17
|
+
void client.cancelQueries(stale);
|
|
18
|
+
client.removeQueries(stale);
|
|
19
|
+
// The scope object changes with its key only.
|
|
20
|
+
}, [client, key]);
|
|
21
|
+
return children ?? null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A server read under the current access scope: its key is the scope, the operation and the parameters. Without a
|
|
25
|
+
* valid snapshot it does not run. A change of scope aborts it, and its late answer is dropped.
|
|
26
|
+
*/
|
|
27
|
+
export function useScopedQuery(options) {
|
|
28
|
+
const scope = useAccessScope(), capture = useAccessCapture();
|
|
29
|
+
return useQuery({
|
|
30
|
+
queryKey: scope ? scopedQueryKey(scope, options.operation, options.params) : ['mpfrontend-closed', options.operation],
|
|
31
|
+
enabled: scope !== undefined && (options.enabled ?? true),
|
|
32
|
+
queryFn: async ({ signal }) => {
|
|
33
|
+
const work = capture();
|
|
34
|
+
const data = await options.read(options.params, AbortSignal.any([signal, work.signal]));
|
|
35
|
+
work.assertCurrent();
|
|
36
|
+
return data;
|
|
37
|
+
},
|
|
38
|
+
...(options.initialData !== undefined ? { initialData: options.initialData } : {}),
|
|
39
|
+
...(options.staleTime !== undefined ? { staleTime: options.staleTime } : {}),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A write under the current access scope. It is never retried automatically, after a refusal or any other failure.
|
|
44
|
+
* A change of scope aborts it and its result is not published.
|
|
45
|
+
*/
|
|
46
|
+
export function useScopedMutation(options) {
|
|
47
|
+
const client = useQueryClient(), scope = useAccessScope(), capture = useAccessCapture();
|
|
48
|
+
return useMutation({
|
|
49
|
+
mutationKey: ['mpfrontend-write', options.operation],
|
|
50
|
+
retry: false,
|
|
51
|
+
mutationFn: async (variables) => {
|
|
52
|
+
const work = capture();
|
|
53
|
+
const result = await options.write(variables, work.signal);
|
|
54
|
+
work.assertCurrent();
|
|
55
|
+
return result;
|
|
56
|
+
},
|
|
57
|
+
onSuccess: async () => {
|
|
58
|
+
if (!scope)
|
|
59
|
+
return;
|
|
60
|
+
await Promise.all(options.invalidates.map(operation => client.invalidateQueries({ queryKey: [...scopedQueryKey(scope, operation)] })));
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The list state of the URL. Each change is a new history entry, so back and forward move through pages and filters;
|
|
66
|
+
* a new size, sort or filter starts again at the first page. A sort or a filter on a field the person may not view is
|
|
67
|
+
* dropped, and removed from the URL on load.
|
|
68
|
+
*/
|
|
69
|
+
export function useListUrlState(urlState, options = {}) {
|
|
70
|
+
const [values, setValues] = useQueryStates(urlState.parsers, { history: 'push' });
|
|
71
|
+
const state = urlState.fromValues(values, options);
|
|
72
|
+
const hidden = urlState.hidden(values, options.canView).join(',');
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (hidden)
|
|
75
|
+
void setValues(Object.fromEntries(hidden.split(',').map(key => [key, null])), { history: 'replace' });
|
|
76
|
+
}, [hidden, setValues]);
|
|
77
|
+
const change = (next) => {
|
|
78
|
+
const update = {};
|
|
79
|
+
if (next.size !== undefined)
|
|
80
|
+
update.size = next.size;
|
|
81
|
+
if ('sort' in next)
|
|
82
|
+
update.sort = next.sort ?? null;
|
|
83
|
+
for (const [name, value] of Object.entries(next.filters ?? {}))
|
|
84
|
+
update[name] = value === '' ? null : value;
|
|
85
|
+
update.page = next.page !== undefined ? next.page : null;
|
|
86
|
+
void setValues(update);
|
|
87
|
+
};
|
|
88
|
+
return [state, change];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The controlled values and change events of a ResourceTable bound to the URL: page, size, sort and filters.
|
|
92
|
+
* With `access`, a sort or a filter on a column the person may not view is dropped.
|
|
93
|
+
*/
|
|
94
|
+
export function useTableUrlState(urlState, options = {}) {
|
|
95
|
+
const access = options.access;
|
|
96
|
+
const [state, change] = useListUrlState(urlState, access ? { canView: key => access.field(key).view } : {});
|
|
97
|
+
return {
|
|
98
|
+
page: state.page, size: state.size, sort: state.sort, filters: state.filters ?? {},
|
|
99
|
+
onPageChange: (page) => change({ page }),
|
|
100
|
+
onSizeChange: (size) => change({ size }),
|
|
101
|
+
onSortChange: (sort) => change({ sort }),
|
|
102
|
+
onFiltersChange: (filters) => change({ filters }),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAC,SAAS,EAAgB,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,QAAQ,EAAC,cAAc,EAA4C,MAAM,uBAAuB,CAAC;AACrH,OAAO,EAAC,cAAc,EAAC,MAAM,MAAM,CAAC;AACpC,OAAO,EAAC,gBAAgB,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAC,OAAO,EAAC,cAAc,EAAkC,MAAM,aAAa,CAAC;AAMpF;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,EAAC,QAAQ,EAAiC;IACnE,MAAM,MAAM,GAAC,cAAc,EAAE,EAAC,KAAK,GAAC,cAA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/server';
|
|
2
|
+
import type { ListProtocol, ListSort, ListState } from '@mpfrontend/ftg-core';
|
|
3
|
+
/** The context reference and revision of the access snapshot in use. It is part of every query key, never of a URL. */
|
|
4
|
+
export type QueryScope = Readonly<{
|
|
5
|
+
contextRef: string;
|
|
6
|
+
revision: string;
|
|
7
|
+
}>;
|
|
8
|
+
type Json = string | number | boolean | null | readonly Json[] | {
|
|
9
|
+
readonly [key: string]: Json | undefined;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The key of a server read: the scope, the operation and its parameters. Data read under one context or revision is
|
|
13
|
+
* kept under keys of that scope only, so it never shows under another. Without parameters it is the prefix that an
|
|
14
|
+
* invalidation of the operation matches.
|
|
15
|
+
*/
|
|
16
|
+
export declare function scopedQueryKey(scope: QueryScope, operation: string, params?: Json): readonly unknown[];
|
|
17
|
+
/** Whether a query key belongs to the scope; a key of no scope belongs to none. */
|
|
18
|
+
export declare function inScope(key: readonly unknown[], scope: QueryScope | undefined): boolean;
|
|
19
|
+
export type ListUrlOptions = Readonly<{
|
|
20
|
+
/** The page size when the URL names none. */
|
|
21
|
+
size: number;
|
|
22
|
+
/** The page sizes offered; without it any size from 1 to the protocol's maximum. */
|
|
23
|
+
sizes?: readonly number[];
|
|
24
|
+
/** The sort when the URL names none. */
|
|
25
|
+
sort?: ListSort;
|
|
26
|
+
/** The highest page number accepted from a URL. */
|
|
27
|
+
maxPage?: number;
|
|
28
|
+
}>;
|
|
29
|
+
/** Which row fields the person may view; a sort or a filter on another field is dropped. */
|
|
30
|
+
export type ViewCheck = (field: string) => boolean;
|
|
31
|
+
export type ListUrlState = Readonly<{
|
|
32
|
+
protocol: ListProtocol;
|
|
33
|
+
/** The parsers of the URL keys: `page`, `size`, `sort` and one per filter of the protocol. */
|
|
34
|
+
parsers: ParserMap;
|
|
35
|
+
defaults: ListState;
|
|
36
|
+
/** The state of a URL, the same way on the server for the first render and in the browser. */
|
|
37
|
+
read: (search: LoaderInput, options?: Readonly<{
|
|
38
|
+
canView?: ViewCheck;
|
|
39
|
+
}>) => ListState;
|
|
40
|
+
/** The state of parsed values. */
|
|
41
|
+
fromValues: (values: Readonly<Record<string, unknown>>, options?: Readonly<{
|
|
42
|
+
canView?: ViewCheck;
|
|
43
|
+
}>) => ListState;
|
|
44
|
+
/** The URL keys of parsed values that name a field the person may not view. */
|
|
45
|
+
hidden: (values: Readonly<Record<string, unknown>>, canView: ViewCheck | undefined) => string[];
|
|
46
|
+
/** The query string of a state, without the values that equal their defaults: '' or '?page=2'. */
|
|
47
|
+
serialize: (state: ListState) => string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* The URL state of a list over one protocol: typed keys with defaults and limits. Only the sort fields and filters
|
|
51
|
+
* that the protocol declares are read; an invalid value falls back to its default. The scope never enters the URL.
|
|
52
|
+
*/
|
|
53
|
+
export declare function listUrlState(protocol: ListProtocol, options: ListUrlOptions): ListUrlState;
|
|
54
|
+
export {};
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { createLoader, createParser, createSerializer } from 'nuqs/server';
|
|
2
|
+
const SCOPED = 'mpfrontend-scoped';
|
|
3
|
+
/**
|
|
4
|
+
* The key of a server read: the scope, the operation and its parameters. Data read under one context or revision is
|
|
5
|
+
* kept under keys of that scope only, so it never shows under another. Without parameters it is the prefix that an
|
|
6
|
+
* invalidation of the operation matches.
|
|
7
|
+
*/
|
|
8
|
+
export function scopedQueryKey(scope, operation, params) {
|
|
9
|
+
return params === undefined ? [SCOPED, scope.contextRef, scope.revision, operation] : [SCOPED, scope.contextRef, scope.revision, operation, params];
|
|
10
|
+
}
|
|
11
|
+
/** Whether a query key belongs to the scope; a key of no scope belongs to none. */
|
|
12
|
+
export function inScope(key, scope) {
|
|
13
|
+
return scope !== undefined && key[0] === SCOPED && key[1] === scope.contextRef && key[2] === scope.revision;
|
|
14
|
+
}
|
|
15
|
+
const RESERVED = new Set(['page', 'size', 'sort']);
|
|
16
|
+
/**
|
|
17
|
+
* The URL state of a list over one protocol: typed keys with defaults and limits. Only the sort fields and filters
|
|
18
|
+
* that the protocol declares are read; an invalid value falls back to its default. The scope never enters the URL.
|
|
19
|
+
*/
|
|
20
|
+
export function listUrlState(protocol, options) {
|
|
21
|
+
const maxPage = options.maxPage ?? 100000;
|
|
22
|
+
const validSize = (size) => Number.isInteger(size) && size >= 1 && size <= protocol.size.max && (!options.sizes || options.sizes.includes(size));
|
|
23
|
+
if (!validSize(options.size) || (options.sizes && !options.sizes.every(validSize)))
|
|
24
|
+
throw new Error('INVALID_LIST_DEFAULT');
|
|
25
|
+
const sort = protocol.sort;
|
|
26
|
+
if (options.sort && (!sort || !sort.fields.includes(options.sort.field)))
|
|
27
|
+
throw new Error('INVALID_LIST_DEFAULT');
|
|
28
|
+
const filters = Object.entries(protocol.filters ?? {});
|
|
29
|
+
for (const [name] of filters)
|
|
30
|
+
if (RESERVED.has(name) || !/^[a-z][A-Za-z0-9_-]{0,39}$/.test(name))
|
|
31
|
+
throw new Error('RESERVED_OR_INVALID_URL_KEY:' + name);
|
|
32
|
+
const integer = (min, max) => (value) => /^\d{1,9}$/.test(value) && Number(value) >= min && Number(value) <= max ? Number(value) : null;
|
|
33
|
+
const parsers = {
|
|
34
|
+
page: createParser({ parse: integer(1, maxPage), serialize: String }).withDefault(1),
|
|
35
|
+
size: createParser({ parse: value => { const size = integer(1, protocol.size.max)(value); return size !== null && validSize(size) ? size : null; }, serialize: String }).withDefault(options.size),
|
|
36
|
+
};
|
|
37
|
+
if (sort) {
|
|
38
|
+
const parser = createParser({
|
|
39
|
+
parse: value => {
|
|
40
|
+
const at = value.lastIndexOf('.'), field = value.slice(0, at), direction = value.slice(at + 1);
|
|
41
|
+
return at > 0 && sort.fields.includes(field) && (direction === 'asc' || direction === 'desc') ? { field, direction } : null;
|
|
42
|
+
},
|
|
43
|
+
serialize: value => value.field + '.' + value.direction,
|
|
44
|
+
eq: (a, b) => a.field === b.field && a.direction === b.direction,
|
|
45
|
+
});
|
|
46
|
+
parsers.sort = options.sort ? parser.withDefault(options.sort) : parser;
|
|
47
|
+
}
|
|
48
|
+
for (const [name, filter] of filters)
|
|
49
|
+
parsers[name] = createParser({ parse: value => value.length <= filter.maxLength ? value : null, serialize: value => value }).withDefault('');
|
|
50
|
+
const hidden = (values, canView) => {
|
|
51
|
+
if (!canView)
|
|
52
|
+
return [];
|
|
53
|
+
const keys = [];
|
|
54
|
+
const current = values.sort;
|
|
55
|
+
if (current && !canView(current.field))
|
|
56
|
+
keys.push('sort');
|
|
57
|
+
for (const [name, filter] of filters)
|
|
58
|
+
if (filter.field !== undefined && values[name] && !canView(filter.field))
|
|
59
|
+
keys.push(name);
|
|
60
|
+
return keys;
|
|
61
|
+
};
|
|
62
|
+
const fromValues = (values, read = {}) => {
|
|
63
|
+
const dropped = new Set(hidden(values, read.canView));
|
|
64
|
+
const current = values.sort;
|
|
65
|
+
return Object.freeze({ page: values.page, size: values.size,
|
|
66
|
+
sort: current && !dropped.has('sort') ? current : undefined,
|
|
67
|
+
filters: Object.freeze(Object.fromEntries(filters.map(([name]) => [name, dropped.has(name) ? '' : String(values[name] ?? '')]))) });
|
|
68
|
+
};
|
|
69
|
+
const loader = createLoader(parsers), serializer = createSerializer(parsers);
|
|
70
|
+
const defaults = fromValues(loader(''));
|
|
71
|
+
return Object.freeze({ protocol, parsers, defaults, hidden, fromValues,
|
|
72
|
+
read: (search, read = {}) => fromValues(loader(search), read),
|
|
73
|
+
serialize: (state) => serializer({ page: state.page, size: state.size, ...(sort ? { sort: state.sort ?? null } : {}),
|
|
74
|
+
...Object.fromEntries(filters.map(([name]) => [name, state.filters?.[name] || null])) }) });
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,YAAY,EAAC,gBAAgB,EAAiC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AAC,EAAE,CAAA,CAAC,IAAI,EAAC,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAE,IAAI,CAAC,CAAC,CAAC,EAAU,CAAC,EAAC,CAAC,CAAC;AACpG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpfrontend/data-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/panahister/mpfrontend.git",
|
|
8
|
+
"directory": "packages/data-react"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./shared": {
|
|
19
|
+
"types": "./dist/shared.d.ts",
|
|
20
|
+
"import": "./dist/shared.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public",
|
|
29
|
+
"provenance": true
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@mpfrontend/access-react": "0.1.0",
|
|
33
|
+
"@mpfrontend/ftg-core": "0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@happy-dom/global-registrator": "20.14.5",
|
|
37
|
+
"@tanstack/react-query": "5.104.0",
|
|
38
|
+
"happy-dom": "20.14.5",
|
|
39
|
+
"nuqs": "2.10.1"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@tanstack/react-query": "^5.104.0",
|
|
43
|
+
"nuqs": "^2.10.1",
|
|
44
|
+
"react": "^19.3.0"
|
|
45
|
+
}
|
|
6
46
|
}
|