@haakco/custd-react 3.71.1 → 3.72.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 +21 -0
- package/README.md +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/machine-access.d.ts +21 -0
- package/dist/machine-access.js +57 -0
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HaakCo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ function or existing `UseQueryResult`. The session helpers wrap a core
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
pnpm add @haakco/custd-sdk@^3.
|
|
17
|
+
pnpm add @haakco/custd-sdk@^3.72.0 @haakco/custd-react@^3.72.0
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
Use the same released version for both packages; both are public on npmjs. These examples were verified on
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { ConvergenceStory, type ConvergenceStoryLabels, type ConvergenceStoryPro
|
|
|
32
32
|
export { ForecastChart, type ForecastChartLabels, type ForecastChartProps } from "./forecast-chart.js";
|
|
33
33
|
export type { ArrivalHistogramBin, ArrivalHistogramData, ChartFormatters, ConvergenceEstimate, ForecastChartData, ForecastEarlierRun, ForecastInterval, ForecastPoint, ForecastPosteriorLine, } from "./forecast-types.js";
|
|
34
34
|
export { CUSTD_HOSTED_APP_LOADING, CustdHostedAppProvider, type CustdHostedAppProviderProps, type CustdHostedAppState, useCustdHostedApp, } from "./hosted-app.js";
|
|
35
|
+
export { machineAccessQueryKeys, useEffectiveMachineAccess, useMachineAccess, useMachineAccessOverride, useUpdateMachineAccess, useUpdateMachineAccessOverride, } from "./machine-access.js";
|
|
35
36
|
export { MeasureNextPanel, type MeasureNextPanelLabels, type MeasureNextPanelProps, } from "./measure-next-panel.js";
|
|
36
37
|
export { ModelCalculator, type ModelCalculatorInput, type ModelCalculatorLabels, type ModelCalculatorProps, type ModelCalculatorRequest, type ModelCalculatorResult, } from "./model-calculator.js";
|
|
37
38
|
export { downloadSummaryCsv } from "./model-csv.js";
|
package/dist/index.js
CHANGED
|
@@ -56,6 +56,7 @@ export { ArrivalHistogram, } from "./arrival-histogram.js";
|
|
|
56
56
|
export { ConvergenceStory } from "./convergence-story.js";
|
|
57
57
|
export { ForecastChart } from "./forecast-chart.js";
|
|
58
58
|
export { CUSTD_HOSTED_APP_LOADING, CustdHostedAppProvider, useCustdHostedApp, } from "./hosted-app.js";
|
|
59
|
+
export { machineAccessQueryKeys, useEffectiveMachineAccess, useMachineAccess, useMachineAccessOverride, useUpdateMachineAccess, useUpdateMachineAccessOverride, } from "./machine-access.js";
|
|
59
60
|
export { MeasureNextPanel, } from "./measure-next-panel.js";
|
|
60
61
|
export { ModelCalculator, } from "./model-calculator.js";
|
|
61
62
|
export { downloadSummaryCsv } from "./model-csv.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MachineAccessAdminClient, MachineAccessCompanyPolicy, MachineAccessCompanyUpdateRequest, MachineAccessEffective, MachineAccessMachinePolicy, MachineAccessMachineUpdateRequest } from "@haakco/custd-sdk";
|
|
2
|
+
import { type UseMutationResult, type UseQueryResult } from "@tanstack/react-query";
|
|
3
|
+
/**
|
|
4
|
+
* Query keys of the machine access reads, so an app can invalidate them after a change it made
|
|
5
|
+
* elsewhere. `effective()` covers every machine's effective access.
|
|
6
|
+
*/
|
|
7
|
+
export declare const machineAccessQueryKeys: {
|
|
8
|
+
company: (companySlug?: string) => readonly ["custd", "machine-access", "company", string];
|
|
9
|
+
override: (clientId: string) => readonly ["custd", "machine-access", "override", string];
|
|
10
|
+
effective: (clientId?: string) => readonly ["custd", "machine-access", "effective"] | readonly ["custd", "machine-access", "effective", string];
|
|
11
|
+
};
|
|
12
|
+
/** The company's machine access policy. A tenant administrator omits companySlug. */
|
|
13
|
+
export declare function useMachineAccess(client: MachineAccessAdminClient, companySlug?: string): UseQueryResult<MachineAccessCompanyPolicy, Error>;
|
|
14
|
+
/** Changes the company policy; every machine's effective access is read again after it. */
|
|
15
|
+
export declare function useUpdateMachineAccess(client: MachineAccessAdminClient, companySlug?: string): UseMutationResult<MachineAccessCompanyPolicy, Error, MachineAccessCompanyUpdateRequest>;
|
|
16
|
+
/** One machine's per-area override. */
|
|
17
|
+
export declare function useMachineAccessOverride(client: MachineAccessAdminClient, clientId: string): UseQueryResult<MachineAccessMachinePolicy, Error>;
|
|
18
|
+
/** Changes one machine's override; that machine's effective access is read again after it. */
|
|
19
|
+
export declare function useUpdateMachineAccessOverride(client: MachineAccessAdminClient, clientId: string): UseMutationResult<MachineAccessMachinePolicy, Error, MachineAccessMachineUpdateRequest>;
|
|
20
|
+
/** What one machine may do in each area and which setting decided it. */
|
|
21
|
+
export declare function useEffectiveMachineAccess(client: MachineAccessAdminClient, clientId: string): UseQueryResult<MachineAccessEffective, Error>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient, } from "@tanstack/react-query";
|
|
2
|
+
/**
|
|
3
|
+
* Query keys of the machine access reads, so an app can invalidate them after a change it made
|
|
4
|
+
* elsewhere. `effective()` covers every machine's effective access.
|
|
5
|
+
*/
|
|
6
|
+
export const machineAccessQueryKeys = {
|
|
7
|
+
company: (companySlug = "") => ["custd", "machine-access", "company", companySlug],
|
|
8
|
+
override: (clientId) => ["custd", "machine-access", "override", clientId],
|
|
9
|
+
effective: (clientId) => clientId === undefined
|
|
10
|
+
? ["custd", "machine-access", "effective"]
|
|
11
|
+
: ["custd", "machine-access", "effective", clientId],
|
|
12
|
+
};
|
|
13
|
+
/** The company's machine access policy. A tenant administrator omits companySlug. */
|
|
14
|
+
export function useMachineAccess(client, companySlug) {
|
|
15
|
+
return useQuery({
|
|
16
|
+
queryKey: machineAccessQueryKeys.company(companySlug),
|
|
17
|
+
queryFn: ({ signal }) => client.get(companySlug, { signal }),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** Changes the company policy; every machine's effective access is read again after it. */
|
|
21
|
+
export function useUpdateMachineAccess(client, companySlug) {
|
|
22
|
+
const queryClient = useQueryClient();
|
|
23
|
+
return useMutation({
|
|
24
|
+
mutationFn: (body) => client.update(body, companySlug),
|
|
25
|
+
onSuccess: async (saved) => {
|
|
26
|
+
queryClient.setQueryData(machineAccessQueryKeys.company(companySlug), saved);
|
|
27
|
+
await queryClient.invalidateQueries({ queryKey: machineAccessQueryKeys.effective() });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** One machine's per-area override. */
|
|
32
|
+
export function useMachineAccessOverride(client, clientId) {
|
|
33
|
+
return useQuery({
|
|
34
|
+
queryKey: machineAccessQueryKeys.override(clientId),
|
|
35
|
+
queryFn: ({ signal }) => client.getOverride(clientId, { signal }),
|
|
36
|
+
enabled: clientId !== "",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** Changes one machine's override; that machine's effective access is read again after it. */
|
|
40
|
+
export function useUpdateMachineAccessOverride(client, clientId) {
|
|
41
|
+
const queryClient = useQueryClient();
|
|
42
|
+
return useMutation({
|
|
43
|
+
mutationFn: (body) => client.updateOverride(clientId, body),
|
|
44
|
+
onSuccess: async (saved) => {
|
|
45
|
+
queryClient.setQueryData(machineAccessQueryKeys.override(clientId), saved);
|
|
46
|
+
await queryClient.invalidateQueries({ queryKey: machineAccessQueryKeys.effective(clientId) });
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** What one machine may do in each area and which setting decided it. */
|
|
51
|
+
export function useEffectiveMachineAccess(client, clientId) {
|
|
52
|
+
return useQuery({
|
|
53
|
+
queryKey: machineAccessQueryKeys.effective(clientId),
|
|
54
|
+
queryFn: ({ signal }) => client.getEffective(clientId, { signal }),
|
|
55
|
+
enabled: clientId !== "",
|
|
56
|
+
});
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haakco/custd-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.72.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24 <27"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"test": "vitest run src"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@haakco/custd-sdk": ">=3.
|
|
32
|
+
"@haakco/custd-sdk": ">=3.72.0 <4",
|
|
33
33
|
"@tanstack/react-query": ">=5 <6",
|
|
34
34
|
"react": ">=18 <20"
|
|
35
35
|
},
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"typescript": "^7.0.2",
|
|
48
48
|
"vitest": "^5.1.0"
|
|
49
49
|
},
|
|
50
|
-
"license": "
|
|
50
|
+
"license": "MIT",
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
|
53
53
|
"url": "git+https://github.com/haakco/custd-sdk.git",
|