@truedat/ai 8.10.4 → 8.10.5
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/package.json +3 -3
- package/src/api.js +0 -4
- package/src/components/AiRoutes.js +0 -8
- package/src/components/constants.js +1 -5
- package/src/components/prompts/PromptEditor.js +10 -68
- package/src/components/prompts/Prompts.js +4 -2
- package/src/components/prompts/__tests__/PromptEditor.spec.js +4 -16
- package/src/components/prompts/__tests__/Prompts.spec.js +20 -4
- package/src/components/prompts/__tests__/__snapshots__/PromptEditor.spec.js.snap +39 -628
- package/src/components/prompts/__tests__/__snapshots__/Prompts.spec.js.snap +2 -2
- package/src/components/resourceMappings/ResourceMappingEditor.js +0 -200
- package/src/components/resourceMappings/ResourceMappingFields.js +0 -120
- package/src/components/resourceMappings/ResourceMappings.js +0 -148
- package/src/components/resourceMappings/__tests__/ResourceMappingEditor.spec.js +0 -163
- package/src/components/resourceMappings/__tests__/ResourceMappings.spec.js +0 -78
- package/src/components/resourceMappings/__tests__/__snapshots__/ResourceMappingEditor.spec.js.snap +0 -800
- package/src/components/resourceMappings/__tests__/__snapshots__/ResourceMappings.spec.js.snap +0 -77
- package/src/components/resourceMappings/selectors/DataStructureSelector.js +0 -79
- package/src/components/resourceMappings/selectors/index.js +0 -10
- package/src/hooks/__tests__/useResourceMappings.spec.js +0 -101
- package/src/hooks/useResourceMappings.js +0 -33
package/src/components/resourceMappings/__tests__/__snapshots__/ResourceMappings.spec.js.snap
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<ResourceMappings /> matches the latest snapshot 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="ui segment"
|
|
7
|
-
>
|
|
8
|
-
<h2
|
|
9
|
-
class="ui header"
|
|
10
|
-
>
|
|
11
|
-
<i
|
|
12
|
-
aria-hidden="true"
|
|
13
|
-
class="map signs circular icon"
|
|
14
|
-
/>
|
|
15
|
-
<div
|
|
16
|
-
class="content"
|
|
17
|
-
>
|
|
18
|
-
resourceMappings.header
|
|
19
|
-
<div
|
|
20
|
-
class="sub header"
|
|
21
|
-
>
|
|
22
|
-
resourceMappings.subheader
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
</h2>
|
|
26
|
-
<div
|
|
27
|
-
class="ui grid"
|
|
28
|
-
>
|
|
29
|
-
<div
|
|
30
|
-
class="four wide column"
|
|
31
|
-
>
|
|
32
|
-
<button
|
|
33
|
-
class="ui fluid button"
|
|
34
|
-
>
|
|
35
|
-
resourceMappings.action.new
|
|
36
|
-
</button>
|
|
37
|
-
<div
|
|
38
|
-
class="ui divided selection list"
|
|
39
|
-
role="list"
|
|
40
|
-
>
|
|
41
|
-
<div
|
|
42
|
-
class="item"
|
|
43
|
-
role="listitem"
|
|
44
|
-
>
|
|
45
|
-
<div
|
|
46
|
-
class="content"
|
|
47
|
-
>
|
|
48
|
-
<div
|
|
49
|
-
class="header"
|
|
50
|
-
>
|
|
51
|
-
rm1
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
<div
|
|
58
|
-
class="eleven wide column"
|
|
59
|
-
>
|
|
60
|
-
<h2
|
|
61
|
-
class="ui icon center aligned header"
|
|
62
|
-
>
|
|
63
|
-
<i
|
|
64
|
-
aria-hidden="true"
|
|
65
|
-
class="hand pointer outline icon"
|
|
66
|
-
/>
|
|
67
|
-
<div
|
|
68
|
-
class="sub header"
|
|
69
|
-
>
|
|
70
|
-
resourceMappings.no_selection
|
|
71
|
-
</div>
|
|
72
|
-
</h2>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
|
-
`;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { useIntl } from "react-intl";
|
|
2
|
-
import { Controller, useFormContext } from "react-hook-form";
|
|
3
|
-
import { Form } from "semantic-ui-react";
|
|
4
|
-
|
|
5
|
-
export default function DataStructureSelector() {
|
|
6
|
-
const { formatMessage } = useIntl();
|
|
7
|
-
const { control } = useFormContext();
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<>
|
|
11
|
-
<Controller
|
|
12
|
-
control={control}
|
|
13
|
-
name="selector.type"
|
|
14
|
-
rules={{
|
|
15
|
-
required: formatMessage(
|
|
16
|
-
{ id: "form.validation.required" },
|
|
17
|
-
{
|
|
18
|
-
prop: formatMessage({
|
|
19
|
-
id: "resourceMappings.form.selector.data_structure.type",
|
|
20
|
-
}),
|
|
21
|
-
},
|
|
22
|
-
),
|
|
23
|
-
}}
|
|
24
|
-
render={({
|
|
25
|
-
field: { onBlur, onChange, value },
|
|
26
|
-
fieldState: { error },
|
|
27
|
-
}) => (
|
|
28
|
-
<Form.Input
|
|
29
|
-
autoComplete="off"
|
|
30
|
-
placeholder={formatMessage({
|
|
31
|
-
id: "resourceMappings.form.selector.data_structure.type",
|
|
32
|
-
})}
|
|
33
|
-
error={error?.message}
|
|
34
|
-
label={formatMessage({
|
|
35
|
-
id: "resourceMappings.form.selector.data_structure.type",
|
|
36
|
-
})}
|
|
37
|
-
onBlur={onBlur}
|
|
38
|
-
onChange={(_e, { value }) => onChange(value)}
|
|
39
|
-
value={value}
|
|
40
|
-
required
|
|
41
|
-
/>
|
|
42
|
-
)}
|
|
43
|
-
/>
|
|
44
|
-
<Controller
|
|
45
|
-
control={control}
|
|
46
|
-
name="selector.system_external_id"
|
|
47
|
-
rules={{
|
|
48
|
-
required: formatMessage(
|
|
49
|
-
{ id: "form.validation.required" },
|
|
50
|
-
{
|
|
51
|
-
prop: formatMessage({
|
|
52
|
-
id: "resourceMappings.form.selector.data_structure.system_external_id",
|
|
53
|
-
}),
|
|
54
|
-
},
|
|
55
|
-
),
|
|
56
|
-
}}
|
|
57
|
-
render={({
|
|
58
|
-
field: { onBlur, onChange, value },
|
|
59
|
-
fieldState: { error },
|
|
60
|
-
}) => (
|
|
61
|
-
<Form.Input
|
|
62
|
-
autoComplete="off"
|
|
63
|
-
placeholder={formatMessage({
|
|
64
|
-
id: "resourceMappings.form.selector.data_structure.system_external_id",
|
|
65
|
-
})}
|
|
66
|
-
error={error?.message}
|
|
67
|
-
label={formatMessage({
|
|
68
|
-
id: "resourceMappings.form.selector.data_structure.system_external_id",
|
|
69
|
-
})}
|
|
70
|
-
onBlur={onBlur}
|
|
71
|
-
onChange={(_e, { value }) => onChange(value)}
|
|
72
|
-
value={value}
|
|
73
|
-
required
|
|
74
|
-
/>
|
|
75
|
-
)}
|
|
76
|
-
/>
|
|
77
|
-
</>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import { compile } from "path-to-regexp";
|
|
3
|
-
import useSWR from "swr";
|
|
4
|
-
import useSWRMutations from "swr/mutation";
|
|
5
|
-
import { renderHook } from "@testing-library/react";
|
|
6
|
-
import {
|
|
7
|
-
apiJson,
|
|
8
|
-
apiJsonPost,
|
|
9
|
-
apiJsonPatch,
|
|
10
|
-
apiJsonDelete,
|
|
11
|
-
} from "@truedat/core/services/api";
|
|
12
|
-
import { API_RESOURCE_MAPPINGS, API_RESOURCE_MAPPING } from "../../api";
|
|
13
|
-
import {
|
|
14
|
-
useResourceMappings,
|
|
15
|
-
useResourceMappingCreate,
|
|
16
|
-
useResourceMappingUpdate,
|
|
17
|
-
useResourceMappingDelete,
|
|
18
|
-
} from "../useResourceMappings";
|
|
19
|
-
|
|
20
|
-
jest.mock("swr", () => ({
|
|
21
|
-
__esModule: true,
|
|
22
|
-
...jest.requireActual("swr"),
|
|
23
|
-
default: jest.fn(() => ({
|
|
24
|
-
data: { data: "data" },
|
|
25
|
-
error: null,
|
|
26
|
-
mutate: jest.fn(),
|
|
27
|
-
})),
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
jest.mock("swr/mutation", () => ({
|
|
31
|
-
__esModule: true,
|
|
32
|
-
...jest.requireActual("swr/mutation"),
|
|
33
|
-
default: jest.fn(),
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
jest.mock("@truedat/core/services/api", () => ({
|
|
37
|
-
__esModule: true,
|
|
38
|
-
...jest.requireActual("@truedat/core/services/api"),
|
|
39
|
-
apiJsonPost: jest.fn(),
|
|
40
|
-
apiJsonPatch: jest.fn(),
|
|
41
|
-
apiJsonDelete: jest.fn(),
|
|
42
|
-
}));
|
|
43
|
-
|
|
44
|
-
describe("useResourceMappings", () => {
|
|
45
|
-
it("useResourceMappings calls useSWR with correct api route", () => {
|
|
46
|
-
const { result } = renderHook(() => useResourceMappings());
|
|
47
|
-
|
|
48
|
-
expect(result.current).toMatchObject({
|
|
49
|
-
data: "data",
|
|
50
|
-
error: null,
|
|
51
|
-
loading: false,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
expect(useSWR).toHaveBeenCalledWith(API_RESOURCE_MAPPINGS, apiJson);
|
|
55
|
-
});
|
|
56
|
-
it("useResourceMappingCreate calls useSWRMutations with correct api route", () => {
|
|
57
|
-
renderHook(() => useResourceMappingCreate());
|
|
58
|
-
const [url, func] = _.last(useSWRMutations.mock.calls);
|
|
59
|
-
const arg = { some: "arg" };
|
|
60
|
-
expect(url).toBe(API_RESOURCE_MAPPINGS);
|
|
61
|
-
func(url, { arg });
|
|
62
|
-
|
|
63
|
-
expect(apiJsonPost).toHaveBeenCalledWith(url, arg);
|
|
64
|
-
});
|
|
65
|
-
it("useResourceMappingUpdate calls useSWRMutations with correct api route", () => {
|
|
66
|
-
const id = "8";
|
|
67
|
-
renderHook(() => useResourceMappingUpdate({ id }));
|
|
68
|
-
const [url, func] = _.last(useSWRMutations.mock.calls);
|
|
69
|
-
const arg = { some: "arg" };
|
|
70
|
-
expect(url).toBe(compile(API_RESOURCE_MAPPING)({ id }));
|
|
71
|
-
func(url, { arg });
|
|
72
|
-
|
|
73
|
-
expect(apiJsonPatch).toHaveBeenCalledWith(url, arg);
|
|
74
|
-
});
|
|
75
|
-
it("useResourceMappingUpdate without args will render id 0", () => {
|
|
76
|
-
renderHook(() => useResourceMappingUpdate());
|
|
77
|
-
const [url, func] = _.last(useSWRMutations.mock.calls);
|
|
78
|
-
const arg = { some: "arg" };
|
|
79
|
-
expect(url).toBe(compile(API_RESOURCE_MAPPING)({ id: "0" }));
|
|
80
|
-
func(url, { arg });
|
|
81
|
-
expect(apiJsonPatch).toHaveBeenCalledWith(url, arg);
|
|
82
|
-
});
|
|
83
|
-
it("useResourceMappingDelete calls useSWRMutations with correct api route", () => {
|
|
84
|
-
const id = "8";
|
|
85
|
-
renderHook(() => useResourceMappingDelete({ id }));
|
|
86
|
-
const [url, func] = _.last(useSWRMutations.mock.calls);
|
|
87
|
-
const arg = { some: "arg" };
|
|
88
|
-
expect(url).toBe(compile(API_RESOURCE_MAPPING)({ id }));
|
|
89
|
-
func(url, { arg });
|
|
90
|
-
|
|
91
|
-
expect(apiJsonDelete).toHaveBeenCalledWith(url, arg);
|
|
92
|
-
});
|
|
93
|
-
it("useResourceMappingDelete without args will render id 0", () => {
|
|
94
|
-
renderHook(() => useResourceMappingDelete());
|
|
95
|
-
const [url, func] = _.last(useSWRMutations.mock.calls);
|
|
96
|
-
const arg = { some: "arg" };
|
|
97
|
-
expect(url).toBe(compile(API_RESOURCE_MAPPING)({ id: "0" }));
|
|
98
|
-
func(url, { arg });
|
|
99
|
-
expect(apiJsonDelete).toHaveBeenCalledWith(url, arg);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { compile } from "path-to-regexp";
|
|
2
|
-
import useSWR from "swr";
|
|
3
|
-
import useSWRMutations from "swr/mutation";
|
|
4
|
-
import {
|
|
5
|
-
apiJson,
|
|
6
|
-
apiJsonPost,
|
|
7
|
-
apiJsonPatch,
|
|
8
|
-
apiJsonDelete,
|
|
9
|
-
} from "@truedat/core/services/api";
|
|
10
|
-
import { API_RESOURCE_MAPPINGS, API_RESOURCE_MAPPING } from "../api";
|
|
11
|
-
|
|
12
|
-
export const useResourceMappings = () => {
|
|
13
|
-
const { data, error, mutate } = useSWR(API_RESOURCE_MAPPINGS, apiJson);
|
|
14
|
-
return { data: data?.data, error, loading: !error && !data, mutate };
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const useResourceMappingCreate = () => {
|
|
18
|
-
return useSWRMutations(API_RESOURCE_MAPPINGS, (url, { arg }) =>
|
|
19
|
-
apiJsonPost(url, arg),
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const useResourceMappingUpdate = (func) => {
|
|
24
|
-
const id = func?.id || "0";
|
|
25
|
-
const url = compile(API_RESOURCE_MAPPING)({ id: `${id}` });
|
|
26
|
-
return useSWRMutations(url, (url, { arg }) => apiJsonPatch(url, arg));
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const useResourceMappingDelete = (func) => {
|
|
30
|
-
const id = func?.id || "0";
|
|
31
|
-
const url = compile(API_RESOURCE_MAPPING)({ id: `${id}` });
|
|
32
|
-
return useSWRMutations(url, (url, { arg }) => apiJsonDelete(url, arg));
|
|
33
|
-
};
|