@webiny/app-aco 6.4.5 → 6.6.0-alpha.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/components/Actions/DeleteFolder/DeleteFolder.js +1 -1
- package/components/Actions/DeleteFolder/DeleteFolder.js.map +1 -1
- package/components/AdvancedSearch/domain/Filter.d.ts +1 -1
- package/components/AdvancedSearch/domain/FilterRepositoryFactory.d.ts +2 -2
- package/components/AdvancedSearch/domain/FilterRepositoryFactory.js.map +1 -1
- package/components/AdvancedSearch/gateways/FiltersGraphQLGateway.d.ts +2 -2
- package/components/AdvancedSearch/gateways/FiltersGraphQLGateway.js +9 -10
- package/components/AdvancedSearch/gateways/FiltersGraphQLGateway.js.map +1 -1
- package/components/AdvancedSearch/gateways/filters.gql.d.ts +5 -5
- package/components/AdvancedSearch/gateways/filters.gql.js +5 -6
- package/components/AdvancedSearch/gateways/filters.gql.js.map +1 -1
- package/components/AdvancedSearch/useFilterRepository.js +7 -2
- package/components/AdvancedSearch/useFilterRepository.js.map +1 -1
- package/components/Table/cells/CellAuthor.d.ts +2 -0
- package/components/Table/cells/CellAuthor.js +10 -0
- package/components/Table/cells/CellAuthor.js.map +1 -0
- package/components/Table/cells/CellCreated.d.ts +2 -0
- package/components/Table/cells/CellCreated.js +13 -0
- package/components/Table/cells/CellCreated.js.map +1 -0
- package/components/Table/cells/CellModified.d.ts +2 -0
- package/components/Table/cells/CellModified.js +13 -0
- package/components/Table/cells/CellModified.js.map +1 -0
- package/components/Table/cells/index.d.ts +3 -0
- package/components/Table/cells/index.js +3 -0
- package/components/Table/createTableData.d.ts +7 -5
- package/components/Table/createTableData.js +22 -7
- package/components/Table/createTableData.js.map +1 -1
- package/components/Table/index.d.ts +2 -2
- package/components/Table/index.js +2 -2
- package/components/index.d.ts +0 -1
- package/components/index.js +0 -1
- package/config/AcoConfig.d.ts +8 -12
- package/config/advanced-search/FieldRenderer.d.ts +3 -1
- package/config/folder/Action.d.ts +1 -1
- package/config/folder/index.d.ts +3 -2
- package/config/index.d.ts +0 -1
- package/config/index.js +0 -1
- package/config/record/Action.d.ts +1 -1
- package/config/record/index.d.ts +1 -1
- package/config/table/Column.d.ts +8 -39
- package/config/table/Column.js +4 -67
- package/config/table/Column.js.map +1 -1
- package/config/table/Sorting.d.ts +2 -11
- package/config/table/Sorting.js +1 -28
- package/config/table/index.d.ts +5 -9
- package/contexts/index.d.ts +0 -3
- package/contexts/index.js +0 -3
- package/dialogs/DialogSetPermissions/graphql.d.ts +1 -1
- package/dialogs/DialogSetPermissions/graphql.js +1 -2
- package/dialogs/DialogSetPermissions/graphql.js.map +1 -1
- package/dialogs/useCreateDialog.js +2 -2
- package/dialogs/useCreateDialog.js.map +1 -1
- package/dialogs/useEditDialog.js +2 -2
- package/dialogs/useEditDialog.js.map +1 -1
- package/dialogs/useSetPermissionsDialog.js +16 -4
- package/dialogs/useSetPermissionsDialog.js.map +1 -1
- package/domain/folder/Folder.d.ts +2 -1
- package/domain/folder/Folder.js.map +1 -1
- package/features/folders/createFolder/CreateFolderGqlGateway.d.ts +3 -3
- package/features/folders/createFolder/CreateFolderGqlGateway.js +15 -16
- package/features/folders/createFolder/CreateFolderGqlGateway.js.map +1 -1
- package/features/folders/deleteFolder/DeleteFolderGqlGateway.d.ts +3 -3
- package/features/folders/deleteFolder/DeleteFolderGqlGateway.js +5 -6
- package/features/folders/deleteFolder/DeleteFolderGqlGateway.js.map +1 -1
- package/features/folders/folderModelProvider/FolderModelProvider.js +29 -31
- package/features/folders/folderModelProvider/FolderModelProvider.js.map +1 -1
- package/features/folders/folderModelProvider/GetFolderModelGqlGateway.d.ts +3 -3
- package/features/folders/folderModelProvider/GetFolderModelGqlGateway.js +5 -7
- package/features/folders/folderModelProvider/GetFolderModelGqlGateway.js.map +1 -1
- package/features/folders/getFolder/GetFolderGqlGateway.d.ts +3 -3
- package/features/folders/getFolder/GetFolderGqlGateway.js +5 -7
- package/features/folders/getFolder/GetFolderGqlGateway.js.map +1 -1
- package/features/folders/getFolderExtensionsFields/GetFolderExtensionsFieldsUseCase.d.ts +3 -3
- package/features/folders/getFolderExtensionsFields/useFolderExtensionsFields.d.ts +3 -3
- package/features/folders/listFolders/ListFoldersGqlGateway.d.ts +1 -1
- package/features/folders/listFolders/ListFoldersGqlGateway.js +1 -2
- package/features/folders/listFolders/ListFoldersGqlGateway.js.map +1 -1
- package/features/folders/listFolders/useListFolders.d.ts +1 -1
- package/features/folders/listFoldersByParentIds/ListFoldersByParentIdsGqlGateway.d.ts +3 -3
- package/features/folders/listFoldersByParentIds/ListFoldersByParentIdsGqlGateway.js +5 -7
- package/features/folders/listFoldersByParentIds/ListFoldersByParentIdsGqlGateway.js.map +1 -1
- package/features/folders/listFoldersByParentIds/useListFoldersByParentIds.d.ts +2 -2
- package/features/folders/loadFolderHierarchy/useLoadFolderHierarchy.d.ts +2 -2
- package/features/folders/updateFolder/UpdateFolderGqlGateway.d.ts +3 -3
- package/features/folders/updateFolder/UpdateFolderGqlGateway.js +5 -6
- package/features/folders/updateFolder/UpdateFolderGqlGateway.js.map +1 -1
- package/hooks/index.d.ts +0 -6
- package/hooks/index.js +0 -6
- package/index.d.ts +3 -2
- package/index.js +2 -2
- package/package.json +16 -23
- package/presentation/folderTree/FolderTreePresenter.js +8 -8
- package/presentation/folderTree/FolderTreePresenter.js.map +1 -1
- package/presentation/folderTree/FolderTreePresenter.test.js +4 -2
- package/presentation/folderTree/FolderTreePresenter.test.js.map +1 -1
- package/table.types.d.ts +2 -9
- package/types.d.ts +5 -26
- package/types.js.map +1 -1
- package/components/Extensions/Extensions.d.ts +0 -2
- package/components/Extensions/Extensions.js +0 -30
- package/components/Extensions/Extensions.js.map +0 -1
- package/components/Extensions/index.d.ts +0 -1
- package/components/Extensions/index.js +0 -1
- package/config/folder/createFolderFieldDecoratorFactory.d.ts +0 -13
- package/config/folder/createFolderFieldDecoratorFactory.js +0 -17
- package/config/folder/createFolderFieldDecoratorFactory.js.map +0 -1
- package/config/table/Sorting.js.map +0 -1
- package/contexts/acoList.d.ts +0 -49
- package/contexts/acoList.js +0 -303
- package/contexts/acoList.js.map +0 -1
- package/contexts/app.d.ts +0 -33
- package/contexts/app.js +0 -47
- package/contexts/app.js.map +0 -1
- package/contexts/folders.d.ts +0 -12
- package/contexts/folders.js +0 -32
- package/contexts/folders.js.map +0 -1
- package/contexts/navigateFolder.d.ts +0 -17
- package/contexts/navigateFolder.js +0 -54
- package/contexts/navigateFolder.js.map +0 -1
- package/contexts/records.d.ts +0 -31
- package/contexts/records.js +0 -316
- package/contexts/records.js.map +0 -1
- package/exports/admin/aco.d.ts +0 -2
- package/exports/admin/aco.js +0 -2
- package/graphql/app.gql.d.ts +0 -17
- package/graphql/app.gql.js +0 -22
- package/graphql/app.gql.js.map +0 -1
- package/graphql/records/common.d.ts +0 -4
- package/graphql/records/common.js +0 -57
- package/graphql/records/common.js.map +0 -1
- package/graphql/records/getRecord.d.ts +0 -2
- package/graphql/records/getRecord.js +0 -5
- package/graphql/records/getRecord.js.map +0 -1
- package/graphql/records/listRecords.d.ts +0 -2
- package/graphql/records/listRecords.js +0 -26
- package/graphql/records/listRecords.js.map +0 -1
- package/graphql/records/moveRecord.d.ts +0 -2
- package/graphql/records/moveRecord.js +0 -16
- package/graphql/records/moveRecord.js.map +0 -1
- package/graphql/records/types.d.ts +0 -108
- package/graphql/records/types.js +0 -0
- package/graphql/records.gql.d.ts +0 -3
- package/graphql/records.gql.js +0 -3
- package/handlers.d.ts +0 -23
- package/handlers.js +0 -22
- package/handlers.js.map +0 -1
- package/hooks/useAcoApp.d.ts +0 -2
- package/hooks/useAcoApp.js +0 -16
- package/hooks/useAcoApp.js.map +0 -1
- package/hooks/useAcoList.d.ts +0 -3
- package/hooks/useAcoList.js +0 -10
- package/hooks/useAcoList.js.map +0 -1
- package/hooks/useFolderModel.d.ts +0 -2
- package/hooks/useFolderModel.js +0 -16
- package/hooks/useFolderModel.js.map +0 -1
- package/hooks/useFoldersType.d.ts +0 -1
- package/hooks/useFoldersType.js +0 -12
- package/hooks/useFoldersType.js.map +0 -1
- package/hooks/useNavigateFolder.d.ts +0 -2
- package/hooks/useNavigateFolder.js +0 -10
- package/hooks/useNavigateFolder.js.map +0 -1
- package/hooks/useRecords.d.ts +0 -62
- package/hooks/useRecords.js +0 -64
- package/hooks/useRecords.js.map +0 -1
- package/hooks/useTags.d.ts +0 -14
- package/hooks/useTags.js +0 -27
- package/hooks/useTags.js.map +0 -1
- package/sorting.d.ts +0 -9
- package/sorting.js +0 -31
- package/sorting.js.map +0 -1
package/contexts/records.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import type { DeletableSearchRecordItem, ListMeta, ListSearchRecordsQueryVariables, ListTagsWhereQueryVariables, Loading, LoadingActions, MovableSearchRecordItem, SearchRecordItem, TagItem } from "../types.js";
|
|
4
|
-
import type { ColumnConfig } from "../config/table/Column.js";
|
|
5
|
-
interface ListTagsParams {
|
|
6
|
-
where?: ListTagsWhereQueryVariables;
|
|
7
|
-
}
|
|
8
|
-
export type ListRecordsParams = ListSearchRecordsQueryVariables;
|
|
9
|
-
interface SearchRecordsContext {
|
|
10
|
-
records: SearchRecordItem[];
|
|
11
|
-
tags: TagItem[];
|
|
12
|
-
loading: Loading<LoadingActions>;
|
|
13
|
-
meta: ListMeta;
|
|
14
|
-
listRecords: (params: ListRecordsParams) => Promise<SearchRecordItem[]>;
|
|
15
|
-
getRecord: (id: string) => Promise<SearchRecordItem | null>;
|
|
16
|
-
createRecord: (record: Omit<SearchRecordItem, "id">) => Promise<SearchRecordItem>;
|
|
17
|
-
updateRecord: (record: SearchRecordItem, contextFolderId?: string) => Promise<SearchRecordItem>;
|
|
18
|
-
moveRecord: (record: MovableSearchRecordItem) => Promise<void>;
|
|
19
|
-
deleteRecord(record: DeletableSearchRecordItem): Promise<true>;
|
|
20
|
-
listTags: (params: ListTagsParams) => Promise<TagItem[]>;
|
|
21
|
-
addRecordToCache: (record: any) => void;
|
|
22
|
-
updateRecordInCache: (record: any) => void;
|
|
23
|
-
removeRecordFromCache: (id: string) => void;
|
|
24
|
-
}
|
|
25
|
-
export declare const SearchRecordsContext: React.Context<SearchRecordsContext | undefined>;
|
|
26
|
-
interface Props {
|
|
27
|
-
columns: ColumnConfig[];
|
|
28
|
-
children: ReactNode;
|
|
29
|
-
}
|
|
30
|
-
export declare const SearchRecordsProvider: ({ columns, children }: Props) => React.JSX.Element;
|
|
31
|
-
export {};
|
package/contexts/records.js
DELETED
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import react, { useMemo } from "react";
|
|
2
|
-
import sortBy from "lodash/sortBy.js";
|
|
3
|
-
import unionBy from "lodash/unionBy.js";
|
|
4
|
-
import merge from "lodash/merge.js";
|
|
5
|
-
import { apolloFetchingHandler, loadingHandler } from "../handlers.js";
|
|
6
|
-
import { createGetRecord, createListRecords, createMoveRecord } from "../graphql/records.gql.js";
|
|
7
|
-
import { validateOrGetDefaultDbSort } from "../sorting.js";
|
|
8
|
-
import { useAcoApp } from "../hooks/index.js";
|
|
9
|
-
import { parseIdentifier } from "@webiny/utils";
|
|
10
|
-
import { useStateIfMounted } from "@webiny/app-admin";
|
|
11
|
-
const SearchRecordsContext = /*#__PURE__*/ react.createContext(void 0);
|
|
12
|
-
const defaultLoading = {
|
|
13
|
-
INIT: true,
|
|
14
|
-
LIST: false,
|
|
15
|
-
LIST_MORE: false,
|
|
16
|
-
GET: false,
|
|
17
|
-
MOVE: false,
|
|
18
|
-
CREATE: false,
|
|
19
|
-
UPDATE: false,
|
|
20
|
-
DELETE: false
|
|
21
|
-
};
|
|
22
|
-
const mergeAndSortTags = (oldTagItems, newTags)=>{
|
|
23
|
-
if (!newTags.length) return oldTagItems;
|
|
24
|
-
const newTagItems = newTags.map((tag)=>({
|
|
25
|
-
tag
|
|
26
|
-
}));
|
|
27
|
-
const mergedTagItems = unionBy(oldTagItems, newTagItems, "tag");
|
|
28
|
-
return sortBy(mergedTagItems, [
|
|
29
|
-
"tag"
|
|
30
|
-
]);
|
|
31
|
-
};
|
|
32
|
-
const getResponseData = (response)=>response?.content || {};
|
|
33
|
-
const defaultMeta = {
|
|
34
|
-
totalCount: 0,
|
|
35
|
-
hasMoreItems: false,
|
|
36
|
-
cursor: null
|
|
37
|
-
};
|
|
38
|
-
const SearchRecordsProvider = ({ columns, children })=>{
|
|
39
|
-
const { app, client } = useAcoApp();
|
|
40
|
-
const { model } = app;
|
|
41
|
-
const fieldIds = columns.map((config)=>config.name).filter(Boolean);
|
|
42
|
-
const [records, setRecords] = useStateIfMounted([]);
|
|
43
|
-
const [tags, setTags] = useStateIfMounted([]);
|
|
44
|
-
const [loading, setLoading] = useStateIfMounted(defaultLoading);
|
|
45
|
-
const [meta, setMeta] = useStateIfMounted(Object.create(defaultMeta));
|
|
46
|
-
const { GET_RECORD, LIST_RECORDS, UPDATE_RECORD, MOVE_RECORD, DELETE_RECORD, CREATE_RECORD, LIST_TAGS } = useMemo(()=>({
|
|
47
|
-
LIST_RECORDS: createListRecords(model, fieldIds),
|
|
48
|
-
UPDATE_RECORD: null,
|
|
49
|
-
MOVE_RECORD: createMoveRecord(model),
|
|
50
|
-
GET_RECORD: createGetRecord(model),
|
|
51
|
-
LIST_TAGS: null,
|
|
52
|
-
DELETE_RECORD: null,
|
|
53
|
-
CREATE_RECORD: null
|
|
54
|
-
}), [
|
|
55
|
-
app.model.modelId,
|
|
56
|
-
fieldIds
|
|
57
|
-
]);
|
|
58
|
-
const context = useMemo(()=>({
|
|
59
|
-
records,
|
|
60
|
-
tags,
|
|
61
|
-
loading,
|
|
62
|
-
meta,
|
|
63
|
-
addRecordToCache: (record)=>{
|
|
64
|
-
setRecords((prev)=>[
|
|
65
|
-
record,
|
|
66
|
-
...prev
|
|
67
|
-
]);
|
|
68
|
-
setMeta((meta)=>({
|
|
69
|
-
...meta,
|
|
70
|
-
totalCount: ++meta.totalCount
|
|
71
|
-
}));
|
|
72
|
-
},
|
|
73
|
-
updateRecordInCache: (record)=>{
|
|
74
|
-
const { id: recordId } = parseIdentifier(record.id);
|
|
75
|
-
setRecords((prev)=>{
|
|
76
|
-
const index = prev.findIndex((item)=>{
|
|
77
|
-
const { id: itemId } = parseIdentifier(item.id);
|
|
78
|
-
return itemId === recordId;
|
|
79
|
-
});
|
|
80
|
-
if (index >= 0) {
|
|
81
|
-
const next = [
|
|
82
|
-
...prev
|
|
83
|
-
];
|
|
84
|
-
next[index] = merge({}, prev[index], record);
|
|
85
|
-
return next;
|
|
86
|
-
}
|
|
87
|
-
return [
|
|
88
|
-
record,
|
|
89
|
-
...prev
|
|
90
|
-
];
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
removeRecordFromCache: (id)=>{
|
|
94
|
-
setRecords((prev)=>prev.filter((record)=>record.id !== id && !record.id.startsWith(`${id}#`)));
|
|
95
|
-
setMeta((meta)=>({
|
|
96
|
-
...meta,
|
|
97
|
-
totalCount: --meta.totalCount
|
|
98
|
-
}));
|
|
99
|
-
},
|
|
100
|
-
async listRecords (params) {
|
|
101
|
-
const { after, limit, sort: sorting, search, where } = params;
|
|
102
|
-
const totalCount = meta?.totalCount || 0;
|
|
103
|
-
if (after && records.length === totalCount) return records;
|
|
104
|
-
const action = after ? "LIST_MORE" : "LIST";
|
|
105
|
-
const sort = validateOrGetDefaultDbSort(sorting);
|
|
106
|
-
const { data: response } = await apolloFetchingHandler(loadingHandler(action, setLoading), ()=>{
|
|
107
|
-
const variables = {
|
|
108
|
-
where,
|
|
109
|
-
search,
|
|
110
|
-
limit,
|
|
111
|
-
after,
|
|
112
|
-
sort
|
|
113
|
-
};
|
|
114
|
-
return client.query({
|
|
115
|
-
query: LIST_RECORDS,
|
|
116
|
-
variables,
|
|
117
|
-
fetchPolicy: "network-only"
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
if (!response) throw new Error("Could not fetch records - no response.");
|
|
121
|
-
const { data, meta: responseMeta, error } = getResponseData(response);
|
|
122
|
-
if (!data || !responseMeta) throw new Error(error?.message || "Could not fetch records.");
|
|
123
|
-
setRecords((prev)=>{
|
|
124
|
-
if (!after) return data;
|
|
125
|
-
return [
|
|
126
|
-
...prev,
|
|
127
|
-
...data
|
|
128
|
-
];
|
|
129
|
-
});
|
|
130
|
-
setMeta(()=>responseMeta);
|
|
131
|
-
setLoading((prev)=>({
|
|
132
|
-
...prev,
|
|
133
|
-
INIT: false
|
|
134
|
-
}));
|
|
135
|
-
return data;
|
|
136
|
-
},
|
|
137
|
-
async getRecord (id) {
|
|
138
|
-
if (!id) throw new Error("Record `id` is mandatory");
|
|
139
|
-
const { id: recordId } = parseIdentifier(id);
|
|
140
|
-
const { data: response } = await apolloFetchingHandler(loadingHandler("GET", setLoading), ()=>client.query({
|
|
141
|
-
query: GET_RECORD,
|
|
142
|
-
variables: {
|
|
143
|
-
entryId: recordId
|
|
144
|
-
},
|
|
145
|
-
fetchPolicy: "network-only"
|
|
146
|
-
}));
|
|
147
|
-
if (!response) throw new Error(`Could not fetch record "${recordId}" - no response.`);
|
|
148
|
-
const { data, error } = getResponseData(response);
|
|
149
|
-
if (error && "NOT_FOUND" !== error.code) throw new Error("Network error while syncing record");
|
|
150
|
-
if (!data) {
|
|
151
|
-
setRecords((prev)=>prev.filter((record)=>record.id !== recordId));
|
|
152
|
-
setMeta((meta)=>({
|
|
153
|
-
...meta,
|
|
154
|
-
totalCount: --meta.totalCount
|
|
155
|
-
}));
|
|
156
|
-
return data;
|
|
157
|
-
}
|
|
158
|
-
setRecords((prev)=>{
|
|
159
|
-
const index = prev.findIndex((record)=>record.id === recordId);
|
|
160
|
-
if (-1 === index) return [
|
|
161
|
-
data,
|
|
162
|
-
...prev
|
|
163
|
-
];
|
|
164
|
-
const next = [
|
|
165
|
-
...prev
|
|
166
|
-
];
|
|
167
|
-
next[index] = data;
|
|
168
|
-
return next;
|
|
169
|
-
});
|
|
170
|
-
setMeta((meta)=>({
|
|
171
|
-
...meta,
|
|
172
|
-
totalCount: ++meta.totalCount
|
|
173
|
-
}));
|
|
174
|
-
setTags((tags)=>{
|
|
175
|
-
if (!data.tags || 0 === data.tags.length) return tags;
|
|
176
|
-
return mergeAndSortTags(tags, data.tags);
|
|
177
|
-
});
|
|
178
|
-
return data;
|
|
179
|
-
},
|
|
180
|
-
async createRecord (record) {
|
|
181
|
-
if (!CREATE_RECORD) throw new Error("Missing CREATE_RECORD operation.");
|
|
182
|
-
const { data: response } = await apolloFetchingHandler(loadingHandler("CREATE", setLoading), ()=>client.mutate({
|
|
183
|
-
mutation: CREATE_RECORD,
|
|
184
|
-
variables: {
|
|
185
|
-
data: record
|
|
186
|
-
}
|
|
187
|
-
}));
|
|
188
|
-
if (!response) throw new Error("Network error while creating search record.");
|
|
189
|
-
const { data, error } = getResponseData(response);
|
|
190
|
-
if (!data) throw new Error(error?.message || "Could not create record");
|
|
191
|
-
setRecords((prev)=>[
|
|
192
|
-
...prev,
|
|
193
|
-
data
|
|
194
|
-
]);
|
|
195
|
-
setMeta((meta)=>({
|
|
196
|
-
...meta,
|
|
197
|
-
totalCount: ++meta.totalCount
|
|
198
|
-
}));
|
|
199
|
-
setTags((tags)=>{
|
|
200
|
-
if (!data.tags || 0 === data.tags.length) return tags;
|
|
201
|
-
return mergeAndSortTags(tags, data.tags);
|
|
202
|
-
});
|
|
203
|
-
return data;
|
|
204
|
-
},
|
|
205
|
-
async updateRecord (record, contextFolderId) {
|
|
206
|
-
if (!contextFolderId) throw new Error("`folderId` is mandatory");
|
|
207
|
-
if (!UPDATE_RECORD) throw new Error("Missing UPDATE_RECORD operation.");
|
|
208
|
-
const { id, location, data, title, content } = record;
|
|
209
|
-
const { data: response } = await apolloFetchingHandler(loadingHandler("UPDATE", setLoading), ()=>client.mutate({
|
|
210
|
-
mutation: UPDATE_RECORD,
|
|
211
|
-
variables: {
|
|
212
|
-
id,
|
|
213
|
-
data: {
|
|
214
|
-
title,
|
|
215
|
-
content,
|
|
216
|
-
location,
|
|
217
|
-
data
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}));
|
|
221
|
-
if (!response) throw new Error("Network error while updating record");
|
|
222
|
-
const { data: result, error } = getResponseData(response);
|
|
223
|
-
if (!result) throw new Error(error?.message || "Could not update record");
|
|
224
|
-
setRecords((records)=>{
|
|
225
|
-
const index = records.findIndex((record)=>record.id === id);
|
|
226
|
-
if (-1 === index) return [
|
|
227
|
-
result,
|
|
228
|
-
...records
|
|
229
|
-
];
|
|
230
|
-
const next = [
|
|
231
|
-
...records
|
|
232
|
-
];
|
|
233
|
-
next[index] = result;
|
|
234
|
-
return next;
|
|
235
|
-
});
|
|
236
|
-
setTags((tags)=>{
|
|
237
|
-
if (!data.tags || 0 === data.tags.length) return tags;
|
|
238
|
-
return mergeAndSortTags(tags, data.tags);
|
|
239
|
-
});
|
|
240
|
-
return result;
|
|
241
|
-
},
|
|
242
|
-
moveRecord: async (record)=>{
|
|
243
|
-
const { id, location } = record;
|
|
244
|
-
const { folderId } = location;
|
|
245
|
-
const { data: response } = await apolloFetchingHandler(loadingHandler("MOVE", setLoading), ()=>client.mutate({
|
|
246
|
-
mutation: MOVE_RECORD,
|
|
247
|
-
variables: {
|
|
248
|
-
id,
|
|
249
|
-
folderId
|
|
250
|
-
}
|
|
251
|
-
}));
|
|
252
|
-
if (!response) throw new Error("Network error while moving record.");
|
|
253
|
-
const { data, error } = getResponseData(response);
|
|
254
|
-
if (!data) throw new Error(error?.message || "Could not move record.");
|
|
255
|
-
setRecords((prev)=>prev.filter((record)=>record.id !== id));
|
|
256
|
-
setMeta((meta)=>({
|
|
257
|
-
...meta,
|
|
258
|
-
totalCount: --meta.totalCount
|
|
259
|
-
}));
|
|
260
|
-
},
|
|
261
|
-
async deleteRecord (record) {
|
|
262
|
-
if (!DELETE_RECORD) throw new Error("Missing DELETE_RECORD operation.");
|
|
263
|
-
const { id } = record;
|
|
264
|
-
const { data: response } = await apolloFetchingHandler(loadingHandler("DELETE", setLoading), ()=>client.mutate({
|
|
265
|
-
mutation: DELETE_RECORD,
|
|
266
|
-
variables: {
|
|
267
|
-
id
|
|
268
|
-
}
|
|
269
|
-
}));
|
|
270
|
-
if (!response) throw new Error("Network error while deleting record.");
|
|
271
|
-
const { data, error } = getResponseData(response);
|
|
272
|
-
if (!data) throw new Error(error?.message || "Could not delete record");
|
|
273
|
-
setRecords((prev)=>prev.filter((record)=>record.id !== id));
|
|
274
|
-
setMeta((meta)=>({
|
|
275
|
-
...meta,
|
|
276
|
-
totalCount: --meta.totalCount
|
|
277
|
-
}));
|
|
278
|
-
return true;
|
|
279
|
-
},
|
|
280
|
-
async listTags (params) {
|
|
281
|
-
if (!LIST_TAGS) throw new Error("Missing LIST_TAGS operation.");
|
|
282
|
-
const { data: response } = await apolloFetchingHandler(loadingHandler("LIST", setLoading), ()=>client.query({
|
|
283
|
-
query: LIST_TAGS,
|
|
284
|
-
variables: {
|
|
285
|
-
where: params.where
|
|
286
|
-
}
|
|
287
|
-
}));
|
|
288
|
-
if (!response) throw new Error("Network error while fetching tags.");
|
|
289
|
-
const { data, error } = getResponseData(response);
|
|
290
|
-
if (!data) throw new Error(error?.message || "Could not fetch tags");
|
|
291
|
-
setTags(data);
|
|
292
|
-
return data;
|
|
293
|
-
}
|
|
294
|
-
}), [
|
|
295
|
-
app.id,
|
|
296
|
-
model.modelId,
|
|
297
|
-
records,
|
|
298
|
-
setRecords,
|
|
299
|
-
tags,
|
|
300
|
-
meta,
|
|
301
|
-
loading,
|
|
302
|
-
GET_RECORD,
|
|
303
|
-
LIST_RECORDS,
|
|
304
|
-
UPDATE_RECORD,
|
|
305
|
-
DELETE_RECORD,
|
|
306
|
-
MOVE_RECORD,
|
|
307
|
-
CREATE_RECORD,
|
|
308
|
-
LIST_TAGS
|
|
309
|
-
]);
|
|
310
|
-
return /*#__PURE__*/ react.createElement(SearchRecordsContext.Provider, {
|
|
311
|
-
value: context
|
|
312
|
-
}, children);
|
|
313
|
-
};
|
|
314
|
-
export { SearchRecordsContext, SearchRecordsProvider };
|
|
315
|
-
|
|
316
|
-
//# sourceMappingURL=records.js.map
|
package/contexts/records.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contexts/records.js","sources":["../../src/contexts/records.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useMemo } from \"react\";\nimport sortBy from \"lodash/sortBy.js\";\nimport unionBy from \"lodash/unionBy.js\";\nimport lodashMerge from \"lodash/merge.js\";\nimport { apolloFetchingHandler, loadingHandler } from \"~/handlers.js\";\nimport { createGetRecord, createListRecords, createMoveRecord } from \"~/graphql/records.gql.js\";\nimport type {\n CreateSearchRecordResponse,\n CreateSearchRecordVariables,\n DeletableSearchRecordItem,\n DeleteSearchRecordResponse,\n DeleteSearchRecordVariables,\n GetSearchRecordQueryVariables,\n GetSearchRecordResponse,\n ListMeta,\n ListSearchRecordsQueryVariables,\n ListSearchRecordsResponse,\n ListTagsQueryVariables,\n ListTagsResponse,\n ListTagsWhereQueryVariables,\n Loading,\n LoadingActions,\n MovableSearchRecordItem,\n MoveSearchRecordResponse,\n MoveSearchRecordVariables,\n SearchRecordItem,\n TagItem,\n UpdateSearchRecordResponse,\n UpdateSearchRecordVariables\n} from \"~/types.js\";\nimport { validateOrGetDefaultDbSort } from \"~/sorting.js\";\nimport { useAcoApp } from \"~/hooks/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { useStateIfMounted } from \"@webiny/app-admin\";\nimport type { ColumnConfig } from \"~/config/table/Column.js\";\n\ninterface ListTagsParams {\n where?: ListTagsWhereQueryVariables;\n}\n\nexport type ListRecordsParams = ListSearchRecordsQueryVariables;\n\ninterface SearchRecordsContext {\n records: SearchRecordItem[];\n tags: TagItem[];\n loading: Loading<LoadingActions>;\n meta: ListMeta;\n listRecords: (params: ListRecordsParams) => Promise<SearchRecordItem[]>;\n getRecord: (id: string) => Promise<SearchRecordItem | null>;\n createRecord: (record: Omit<SearchRecordItem, \"id\">) => Promise<SearchRecordItem>;\n updateRecord: (record: SearchRecordItem, contextFolderId?: string) => Promise<SearchRecordItem>;\n moveRecord: (record: MovableSearchRecordItem) => Promise<void>;\n deleteRecord(record: DeletableSearchRecordItem): Promise<true>;\n listTags: (params: ListTagsParams) => Promise<TagItem[]>;\n addRecordToCache: (record: any) => void;\n updateRecordInCache: (record: any) => void;\n removeRecordFromCache: (id: string) => void;\n}\n\nexport const SearchRecordsContext = React.createContext<SearchRecordsContext | undefined>(\n undefined\n);\n\ninterface Props {\n columns: ColumnConfig[];\n children: ReactNode;\n}\n\nconst defaultLoading: Record<LoadingActions, boolean> = {\n INIT: true,\n LIST: false,\n LIST_MORE: false,\n GET: false,\n MOVE: false,\n CREATE: false,\n UPDATE: false,\n DELETE: false\n};\n\nconst mergeAndSortTags = (oldTagItems: TagItem[], newTags: string[]): TagItem[] => {\n if (!newTags.length) {\n return oldTagItems;\n }\n\n const newTagItems = newTags.map((tag: string) => ({ tag })); // create TagItem[] from array of strings\n const mergedTagItems = unionBy(oldTagItems, newTagItems, \"tag\"); // merge the two arrays\n\n return sortBy(mergedTagItems, [\"tag\"]);\n};\n\nconst getResponseData = (response: any): any => {\n return response?.content || {};\n};\n\nconst defaultMeta: ListMeta = {\n totalCount: 0,\n hasMoreItems: false,\n cursor: null\n};\n\nexport const SearchRecordsProvider = ({ columns, children }: Props) => {\n const { app, client } = useAcoApp();\n const { model } = app;\n\n /**\n * Retrieve all `fieldIds` from the ACO configuration, considering field `name`:\n * The result is a deduplicated flat array of unique field IDs.\n */\n const fieldIds = columns.map(config => config.name).filter(Boolean);\n\n const [records, setRecords] = useStateIfMounted<SearchRecordItem[]>([]);\n const [tags, setTags] = useStateIfMounted<TagItem[]>([]);\n const [loading, setLoading] = useStateIfMounted<Loading<LoadingActions>>(defaultLoading);\n const [meta, setMeta] = useStateIfMounted<ListMeta>(Object.create(defaultMeta));\n\n const {\n GET_RECORD,\n LIST_RECORDS,\n UPDATE_RECORD,\n MOVE_RECORD,\n DELETE_RECORD,\n CREATE_RECORD,\n LIST_TAGS\n } = useMemo(() => {\n return {\n LIST_RECORDS: createListRecords(model, fieldIds),\n UPDATE_RECORD: null,\n MOVE_RECORD: createMoveRecord(model),\n GET_RECORD: createGetRecord(model),\n LIST_TAGS: null,\n DELETE_RECORD: null,\n CREATE_RECORD: null\n };\n }, [app.model.modelId, fieldIds]);\n\n const context = useMemo<SearchRecordsContext>(() => {\n return {\n records,\n tags,\n loading,\n meta,\n addRecordToCache: (record: any) => {\n setRecords(prev => {\n return [record, ...prev];\n });\n setMeta(meta => ({\n ...meta,\n totalCount: ++meta.totalCount\n }));\n },\n updateRecordInCache: (record: any) => {\n const { id: recordId } = parseIdentifier(record.id);\n\n setRecords(prev => {\n const index = prev.findIndex(item => {\n const { id: itemId } = parseIdentifier(item.id);\n return itemId === recordId;\n });\n\n if (index >= 0) {\n const next = [...prev];\n next[index] = lodashMerge({}, prev[index], record);\n return next;\n }\n return [record, ...prev];\n });\n },\n removeRecordFromCache: (id: string) => {\n setRecords(prev => {\n return prev.filter(\n record => record.id !== id && !record.id.startsWith(`${id}#`)\n );\n });\n setMeta(meta => ({\n ...meta,\n totalCount: --meta.totalCount\n }));\n },\n\n async listRecords(params) {\n const { after, limit, sort: sorting, search, where } = params;\n\n /**\n * Avoiding fetching records in case they have already been fetched.\n * This happens when visiting a list with all records loaded and receives \"after\" param.\n */\n const totalCount = meta?.totalCount || 0;\n if (after && records.length === totalCount) {\n return records;\n }\n\n const action = after ? \"LIST_MORE\" : \"LIST\";\n const sort = validateOrGetDefaultDbSort(sorting);\n\n const { data: response } = await apolloFetchingHandler<ListSearchRecordsResponse>(\n loadingHandler(action, setLoading),\n () => {\n const variables: ListSearchRecordsQueryVariables = {\n where,\n search,\n limit,\n after,\n sort\n };\n return client.query<\n ListSearchRecordsResponse,\n ListSearchRecordsQueryVariables\n >({\n query: LIST_RECORDS,\n variables,\n fetchPolicy: \"network-only\"\n });\n }\n );\n\n if (!response) {\n throw new Error(\"Could not fetch records - no response.\");\n }\n\n const { data, meta: responseMeta, error } = getResponseData(response);\n\n if (!data || !responseMeta) {\n throw new Error(error?.message || \"Could not fetch records.\");\n }\n\n setRecords(prev => {\n // If there's no cursor, it means we're receiving a new list of records from scratch.\n if (!after) {\n return data;\n }\n\n return [...prev, ...data];\n });\n\n setMeta(() => responseMeta);\n\n setLoading(prev => {\n return {\n ...prev,\n INIT: false\n };\n });\n\n return data;\n },\n async getRecord(id) {\n if (!id) {\n throw new Error(\"Record `id` is mandatory\");\n }\n\n const { id: recordId } = parseIdentifier(id);\n\n const { data: response } = await apolloFetchingHandler<GetSearchRecordResponse>(\n loadingHandler(\"GET\", setLoading),\n () =>\n client.query<GetSearchRecordResponse, GetSearchRecordQueryVariables>({\n query: GET_RECORD,\n variables: { entryId: recordId },\n fetchPolicy: \"network-only\"\n })\n );\n\n if (!response) {\n throw new Error(`Could not fetch record \"${recordId}\" - no response.`);\n }\n\n const { data, error } = getResponseData(response);\n\n if (error && error.code !== \"NOT_FOUND\") {\n throw new Error(\"Network error while syncing record\");\n }\n\n if (!data) {\n // No record found - must be deleted by previous operation\n setRecords(prev => {\n return prev.filter(record => record.id !== recordId);\n });\n setMeta(meta => ({\n ...meta,\n totalCount: --meta.totalCount\n }));\n return data;\n }\n setRecords(prev => {\n const index = prev.findIndex(record => record.id === recordId);\n\n // No record found in the list - must be added by previous operation\n if (index === -1) {\n return [data, ...prev];\n }\n const next = [...prev];\n next[index] = data;\n return next;\n });\n\n setMeta(meta => ({\n ...meta,\n totalCount: ++meta.totalCount\n }));\n\n setTags(tags => {\n if (!data.tags || data.tags.length === 0) {\n return tags;\n }\n\n return mergeAndSortTags(tags, data.tags);\n });\n\n return data;\n },\n async createRecord(record) {\n if (!CREATE_RECORD) {\n throw new Error(\"Missing CREATE_RECORD operation.\");\n }\n\n const { data: response } = await apolloFetchingHandler<CreateSearchRecordResponse>(\n loadingHandler(\"CREATE\", setLoading),\n () =>\n client.mutate<CreateSearchRecordResponse, CreateSearchRecordVariables>({\n mutation: CREATE_RECORD,\n variables: {\n data: record\n }\n })\n );\n\n if (!response) {\n throw new Error(\"Network error while creating search record.\");\n }\n\n const { data, error } = getResponseData(response);\n\n if (!data) {\n throw new Error(error?.message || \"Could not create record\");\n }\n\n setRecords(prev => {\n return [...prev, data];\n });\n\n setMeta(meta => ({\n ...meta,\n totalCount: ++meta.totalCount\n }));\n\n setTags(tags => {\n if (!data.tags || data.tags.length === 0) {\n return tags;\n }\n\n return mergeAndSortTags(tags, data.tags);\n });\n\n return data;\n },\n async updateRecord(record, contextFolderId) {\n if (!contextFolderId) {\n throw new Error(\"`folderId` is mandatory\");\n }\n if (!UPDATE_RECORD) {\n throw new Error(\"Missing UPDATE_RECORD operation.\");\n }\n\n const { id, location, data, title, content } = record;\n\n const { data: response } = await apolloFetchingHandler(\n loadingHandler(\"UPDATE\", setLoading),\n () =>\n client.mutate<UpdateSearchRecordResponse, UpdateSearchRecordVariables>({\n mutation: UPDATE_RECORD,\n variables: { id, data: { title, content, location, data } }\n })\n );\n\n if (!response) {\n throw new Error(\"Network error while updating record\");\n }\n\n const { data: result, error } = getResponseData(response);\n\n if (!result) {\n throw new Error(error?.message || \"Could not update record\");\n }\n\n setRecords(records => {\n const index = records.findIndex(record => record.id === id);\n if (index === -1) {\n return [result, ...records];\n }\n\n const next = [...records];\n\n next[index] = result;\n\n return next;\n });\n\n setTags(tags => {\n if (!data.tags || data.tags.length === 0) {\n return tags;\n }\n\n return mergeAndSortTags(tags, data.tags);\n });\n\n return result;\n },\n moveRecord: async (record: MovableSearchRecordItem) => {\n const { id, location } = record;\n const { folderId } = location;\n\n const { data: response } = await apolloFetchingHandler(\n loadingHandler(\"MOVE\", setLoading),\n () =>\n client.mutate<MoveSearchRecordResponse, MoveSearchRecordVariables>({\n mutation: MOVE_RECORD,\n variables: {\n id,\n folderId\n }\n })\n );\n\n if (!response) {\n throw new Error(\"Network error while moving record.\");\n }\n\n const { data, error } = getResponseData(response);\n\n if (!data) {\n throw new Error(error?.message || \"Could not move record.\");\n }\n setRecords(prev => {\n return prev.filter(record => record.id !== id);\n });\n setMeta(meta => ({\n ...meta,\n totalCount: --meta.totalCount\n }));\n },\n async deleteRecord(record) {\n if (!DELETE_RECORD) {\n throw new Error(\"Missing DELETE_RECORD operation.\");\n }\n const { id } = record;\n\n const { data: response } = await apolloFetchingHandler(\n loadingHandler(\"DELETE\", setLoading),\n () =>\n client.mutate<DeleteSearchRecordResponse, DeleteSearchRecordVariables>({\n mutation: DELETE_RECORD,\n variables: { id }\n })\n );\n\n if (!response) {\n throw new Error(\"Network error while deleting record.\");\n }\n\n const { data, error } = getResponseData(response);\n\n if (!data) {\n throw new Error(error?.message || \"Could not delete record\");\n }\n\n setRecords(prev => {\n return prev.filter(record => record.id !== id);\n });\n\n setMeta(meta => ({\n ...meta,\n totalCount: --meta.totalCount\n }));\n\n return true;\n },\n async listTags(params) {\n if (!LIST_TAGS) {\n throw new Error(\"Missing LIST_TAGS operation.\");\n }\n\n const { data: response } = await apolloFetchingHandler(\n loadingHandler(\"LIST\", setLoading),\n () =>\n client.query<ListTagsResponse, ListTagsQueryVariables>({\n query: LIST_TAGS,\n variables: {\n where: params.where\n }\n })\n );\n\n if (!response) {\n throw new Error(\"Network error while fetching tags.\");\n }\n\n const { data, error } = getResponseData(response);\n\n if (!data) {\n throw new Error(error?.message || \"Could not fetch tags\");\n }\n\n setTags(data);\n\n return data;\n }\n };\n }, [\n app.id,\n model.modelId,\n records,\n setRecords,\n tags,\n meta,\n loading,\n GET_RECORD,\n LIST_RECORDS,\n UPDATE_RECORD,\n DELETE_RECORD,\n MOVE_RECORD,\n CREATE_RECORD,\n LIST_TAGS\n ]);\n\n return (\n <SearchRecordsContext.Provider value={context}>{children}</SearchRecordsContext.Provider>\n );\n};\n"],"names":["SearchRecordsContext","React","undefined","defaultLoading","mergeAndSortTags","oldTagItems","newTags","newTagItems","tag","mergedTagItems","unionBy","sortBy","getResponseData","response","defaultMeta","SearchRecordsProvider","columns","children","app","client","useAcoApp","model","fieldIds","config","Boolean","records","setRecords","useStateIfMounted","tags","setTags","loading","setLoading","meta","setMeta","Object","GET_RECORD","LIST_RECORDS","UPDATE_RECORD","MOVE_RECORD","DELETE_RECORD","CREATE_RECORD","LIST_TAGS","useMemo","createListRecords","createMoveRecord","createGetRecord","context","record","prev","recordId","parseIdentifier","index","item","itemId","next","lodashMerge","id","params","after","limit","sorting","search","where","totalCount","action","sort","validateOrGetDefaultDbSort","apolloFetchingHandler","loadingHandler","variables","Error","data","responseMeta","error","contextFolderId","location","title","content","result","folderId"],"mappings":";;;;;;;;;;AA4DO,MAAMA,uBAAuB,WAAHA,GAAGC,MAAAA,aAAmB,CACnDC;AAQJ,MAAMC,iBAAkD;IACpD,MAAM;IACN,MAAM;IACN,WAAW;IACX,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;AACZ;AAEA,MAAMC,mBAAmB,CAACC,aAAwBC;IAC9C,IAAI,CAACA,QAAQ,MAAM,EACf,OAAOD;IAGX,MAAME,cAAcD,QAAQ,GAAG,CAAC,CAACE,MAAiB;YAAEA;QAAI;IACxD,MAAMC,iBAAiBC,QAAQL,aAAaE,aAAa;IAEzD,OAAOI,OAAOF,gBAAgB;QAAC;KAAM;AACzC;AAEA,MAAMG,kBAAkB,CAACC,WACdA,UAAU,WAAW,CAAC;AAGjC,MAAMC,cAAwB;IAC1B,YAAY;IACZ,cAAc;IACd,QAAQ;AACZ;AAEO,MAAMC,wBAAwB,CAAC,EAAEC,OAAO,EAAEC,QAAQ,EAAS;IAC9D,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAE,GAAGC;IACxB,MAAM,EAAEC,KAAK,EAAE,GAAGH;IAMlB,MAAMI,WAAWN,QAAQ,GAAG,CAACO,CAAAA,SAAUA,OAAO,IAAI,EAAE,MAAM,CAACC;IAE3D,MAAM,CAACC,SAASC,WAAW,GAAGC,kBAAsC,EAAE;IACtE,MAAM,CAACC,MAAMC,QAAQ,GAAGF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AAU7B;AAExD"}
|
package/exports/admin/aco.d.ts
DELETED
package/exports/admin/aco.js
DELETED
package/graphql/app.gql.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { AcoError, AcoModel } from "../types.js";
|
|
2
|
-
export interface GraphQlAcoApp {
|
|
3
|
-
id: string;
|
|
4
|
-
model: AcoModel;
|
|
5
|
-
}
|
|
6
|
-
export interface GetAppResult {
|
|
7
|
-
aco: {
|
|
8
|
-
app: {
|
|
9
|
-
data: GraphQlAcoApp | null;
|
|
10
|
-
error: AcoError | null;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export interface GetAppVariables {
|
|
15
|
-
id: string;
|
|
16
|
-
}
|
|
17
|
-
export declare const createGetAppQuery: () => import("graphql").DocumentNode;
|
package/graphql/app.gql.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import graphql_tag from "graphql-tag";
|
|
2
|
-
const createGetAppQuery = ()=>graphql_tag`
|
|
3
|
-
query GetApp($id: ID!) {
|
|
4
|
-
aco {
|
|
5
|
-
app: getApp(id: $id) {
|
|
6
|
-
data {
|
|
7
|
-
id
|
|
8
|
-
model
|
|
9
|
-
}
|
|
10
|
-
error {
|
|
11
|
-
code
|
|
12
|
-
message
|
|
13
|
-
data
|
|
14
|
-
stack
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
20
|
-
export { createGetAppQuery };
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=app.gql.js.map
|
package/graphql/app.gql.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/app.gql.js","sources":["../../src/graphql/app.gql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport type { AcoError, AcoModel } from \"~/types.js\";\n\nexport interface GraphQlAcoApp {\n id: string;\n model: AcoModel;\n}\nexport interface GetAppResult {\n aco: {\n app: {\n data: GraphQlAcoApp | null;\n error: AcoError | null;\n };\n };\n}\nexport interface GetAppVariables {\n id: string;\n}\n\nexport const createGetAppQuery = () => {\n return gql`\n query GetApp($id: ID!) {\n aco {\n app: getApp(id: $id) {\n data {\n id\n model\n }\n error {\n code\n message\n data\n stack\n }\n }\n }\n }\n `;\n};\n"],"names":["createGetAppQuery","gql"],"mappings":";AAmBO,MAAMA,oBAAoB,IACtBC,WAAG,CAAC;;;;;;;;;;;;;;;;;IAiBX,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { AcoModel } from "../../types.js";
|
|
2
|
-
export declare const ERROR_FIELD = "\n error {\n code\n data\n message\n }\n";
|
|
3
|
-
export declare const createAppFields: (model: AcoModel) => string;
|
|
4
|
-
export declare const LIST_META_FIELD = "\n meta {\n cursor\n totalCount\n hasMoreItems\n }\n";
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { plugins } from "@webiny/plugins";
|
|
2
|
-
const ERROR_FIELD = `
|
|
3
|
-
error {
|
|
4
|
-
code
|
|
5
|
-
data
|
|
6
|
-
message
|
|
7
|
-
}
|
|
8
|
-
`;
|
|
9
|
-
const defaultFields = [
|
|
10
|
-
"id",
|
|
11
|
-
"createdOn",
|
|
12
|
-
"savedOn",
|
|
13
|
-
"modifiedOn",
|
|
14
|
-
"createdBy {id type displayName}",
|
|
15
|
-
"savedBy {id type displayName}",
|
|
16
|
-
"modifiedBy {id type displayName}"
|
|
17
|
-
];
|
|
18
|
-
const createFieldsList = ({ model, fields })=>{
|
|
19
|
-
const fieldPlugins = plugins.byType("cms-editor-field-type").reduce((acc, item)=>({
|
|
20
|
-
...acc,
|
|
21
|
-
[item.field.type]: item.field
|
|
22
|
-
}), {});
|
|
23
|
-
return fields.reduce((collection, field)=>{
|
|
24
|
-
if (!fieldPlugins[field.type]) {
|
|
25
|
-
console.log(`Unknown field plugin for field type "${field.type}".`);
|
|
26
|
-
return collection;
|
|
27
|
-
}
|
|
28
|
-
const { graphql } = fieldPlugins[field.type];
|
|
29
|
-
if (graphql && graphql.queryField) {
|
|
30
|
-
const { queryField } = graphql;
|
|
31
|
-
const selection = "string" == typeof queryField ? queryField : queryField({
|
|
32
|
-
model,
|
|
33
|
-
field
|
|
34
|
-
});
|
|
35
|
-
collection.push(`${field.fieldId} ${selection}`);
|
|
36
|
-
return collection;
|
|
37
|
-
}
|
|
38
|
-
collection.push(field.fieldId);
|
|
39
|
-
return collection;
|
|
40
|
-
}, [
|
|
41
|
-
...defaultFields
|
|
42
|
-
]).join("\n");
|
|
43
|
-
};
|
|
44
|
-
const createAppFields = (model)=>createFieldsList({
|
|
45
|
-
model,
|
|
46
|
-
fields: model.fields
|
|
47
|
-
});
|
|
48
|
-
const LIST_META_FIELD = `
|
|
49
|
-
meta {
|
|
50
|
-
cursor
|
|
51
|
-
totalCount
|
|
52
|
-
hasMoreItems
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
export { ERROR_FIELD, LIST_META_FIELD, createAppFields };
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=common.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/records/common.js","sources":["../../../src/graphql/records/common.ts"],"sourcesContent":["import type { AcoModel, AcoModelField } from \"~/types.js\";\nimport { plugins } from \"@webiny/plugins\";\n\nexport const ERROR_FIELD = /* GraphQL */ `\n error {\n code\n data\n message\n }\n`;\ninterface CreateFieldsListParams {\n model: AcoModel;\n fields: AcoModelField[];\n}\n\nconst defaultFields = [\n \"id\",\n \"createdOn\",\n \"savedOn\",\n \"modifiedOn\",\n \"createdBy {id type displayName}\",\n \"savedBy {id type displayName}\",\n \"modifiedBy {id type displayName}\"\n];\n\nconst createFieldsList = ({ model, fields }: CreateFieldsListParams): string => {\n const fieldPlugins: Record<string, any> = plugins\n .byType(\"cms-editor-field-type\")\n .reduce((acc: any, item: any) => ({ ...acc, [item.field.type]: item.field }), {});\n\n return fields\n .reduce<string[]>(\n (collection, field) => {\n if (!fieldPlugins[field.type]) {\n console.log(`Unknown field plugin for field type \"${field.type}\".`);\n return collection;\n }\n const { graphql } = fieldPlugins[field.type];\n\n if (graphql && graphql.queryField) {\n const { queryField } = graphql;\n const selection =\n typeof queryField === \"string\" ? queryField : queryField({ model, field });\n\n collection.push(`${field.fieldId} ${selection}`);\n return collection;\n }\n\n collection.push(field.fieldId);\n\n return collection;\n },\n [...defaultFields]\n )\n .join(\"\\n\");\n};\n\nexport const createAppFields = (model: AcoModel) => {\n return createFieldsList({\n model,\n fields: model.fields\n });\n};\n\nexport const LIST_META_FIELD = /* GraphQL */ `\n meta {\n cursor\n totalCount\n hasMoreItems\n }\n`;\n"],"names":["ERROR_FIELD","defaultFields","createFieldsList","model","fields","fieldPlugins","plugins","acc","item","collection","field","console","graphql","queryField","selection","createAppFields","LIST_META_FIELD"],"mappings":";AAGO,MAAMA,cAA4B,CAAC;;;;;;AAM1C,CAAC;AAMD,MAAMC,gBAAgB;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAED,MAAMC,mBAAmB,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAA0B;IAC/D,MAAMC,eAAoCC,QAAAA,MAC/B,CAAC,yBACP,MAAM,CAAC,CAACC,KAAUC,OAAe;YAAE,GAAGD,GAAG;YAAE,CAACC,KAAK,KAAK,CAAC,IAAI,CAAC,EAAEA,KAAK,KAAK;QAAC,IAAI,CAAC;IAEnF,OAAOJ,OACF,MAAM,CACH,CAACK,YAAYC;QACT,IAAI,CAACL,YAAY,CAACK,MAAM,IAAI,CAAC,EAAE;YAC3BC,QAAQ,GAAG,CAAC,CAAC,qCAAqC,EAAED,MAAM,IAAI,CAAC,EAAE,CAAC;YAClE,OAAOD;QACX;QACA,MAAM,EAAEG,OAAO,EAAE,GAAGP,YAAY,CAACK,MAAM,IAAI,CAAC;QAE5C,IAAIE,WAAWA,QAAQ,UAAU,EAAE;YAC/B,MAAM,EAAEC,UAAU,EAAE,GAAGD;YACvB,MAAME,YACF,AAAsB,YAAtB,OAAOD,aAA0BA,aAAaA,WAAW;gBAAEV;gBAAOO;YAAM;YAE5ED,WAAW,IAAI,CAAC,GAAGC,MAAM,OAAO,CAAC,CAAC,EAAEI,WAAW;YAC/C,OAAOL;QACX;QAEAA,WAAW,IAAI,CAACC,MAAM,OAAO;QAE7B,OAAOD;IACX,GACA;WAAIR;KAAc,EAErB,IAAI,CAAC;AACd;AAEO,MAAMc,kBAAkB,CAACZ,QACrBD,iBAAiB;QACpBC;QACA,QAAQA,MAAM,MAAM;IACxB;AAGG,MAAMa,kBAAgC,CAAC;;;;;;AAM9C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/records/getRecord.js","sources":["../../../src/graphql/records/getRecord.ts"],"sourcesContent":["import type { AcoModel } from \"~/types.js\";\nimport { createReadQuery } from \"@webiny/app-headless-cms-common\";\n\nexport const createGetRecord = (model: AcoModel) => {\n return createReadQuery(model);\n};\n"],"names":["createGetRecord","model","createReadQuery"],"mappings":";AAGO,MAAMA,kBAAkB,CAACC,QACrBC,gBAAgBD"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createListQuery } from "@webiny/app-headless-cms-common";
|
|
2
|
-
const createListRecords = (model, fieldIds)=>{
|
|
3
|
-
const defaultFields = model.fields.filter((field)=>[
|
|
4
|
-
"text",
|
|
5
|
-
"number",
|
|
6
|
-
"boolean",
|
|
7
|
-
"file",
|
|
8
|
-
"long-text",
|
|
9
|
-
"ref",
|
|
10
|
-
"datetime"
|
|
11
|
-
].includes(field.type));
|
|
12
|
-
const additionalFields = model.fields.filter((field)=>fieldIds.includes(field.fieldId));
|
|
13
|
-
const uniqueFields = [
|
|
14
|
-
...new Map([
|
|
15
|
-
...defaultFields,
|
|
16
|
-
...additionalFields
|
|
17
|
-
].map((field)=>[
|
|
18
|
-
field.fieldId,
|
|
19
|
-
field
|
|
20
|
-
])).values()
|
|
21
|
-
];
|
|
22
|
-
return createListQuery(model, uniqueFields);
|
|
23
|
-
};
|
|
24
|
-
export { createListRecords };
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=listRecords.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/records/listRecords.js","sources":["../../../src/graphql/records/listRecords.ts"],"sourcesContent":["import type { AcoModel } from \"~/types.js\";\nimport { createListQuery } from \"@webiny/app-headless-cms-common\";\n\nexport const createListRecords = (model: AcoModel, fieldIds: string[]) => {\n /**\n * We will include only the simplest fields.\n * TODO: remove default fields in a future release, as field selection will be injected by ACO configs.\n */\n const defaultFields = model.fields.filter(field => {\n return [\"text\", \"number\", \"boolean\", \"file\", \"long-text\", \"ref\", \"datetime\"].includes(\n field.type\n );\n });\n\n const additionalFields = model.fields.filter(field => {\n return fieldIds.includes(field.fieldId);\n });\n\n const uniqueFields = [\n ...new Map(\n [...defaultFields, ...additionalFields].map(field => [field.fieldId, field])\n ).values()\n ];\n\n return createListQuery(model, uniqueFields);\n};\n"],"names":["createListRecords","model","fieldIds","defaultFields","field","additionalFields","uniqueFields","Map","createListQuery"],"mappings":";AAGO,MAAMA,oBAAoB,CAACC,OAAiBC;IAK/C,MAAMC,gBAAgBF,MAAM,MAAM,CAAC,MAAM,CAACG,CAAAA,QAC/B;YAAC;YAAQ;YAAU;YAAW;YAAQ;YAAa;YAAO;SAAW,CAAC,QAAQ,CACjFA,MAAM,IAAI;IAIlB,MAAMC,mBAAmBJ,MAAM,MAAM,CAAC,MAAM,CAACG,CAAAA,QAClCF,SAAS,QAAQ,CAACE,MAAM,OAAO;IAG1C,MAAME,eAAe;WACd,IAAIC,IACH;eAAIJ;eAAkBE;SAAiB,CAAC,GAAG,CAACD,CAAAA,QAAS;gBAACA,MAAM,OAAO;gBAAEA;aAAM,GAC7E,MAAM;KACX;IAED,OAAOI,gBAAgBP,OAAOK;AAClC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import graphql_tag from "graphql-tag";
|
|
2
|
-
import { ERROR_FIELD } from "./common.js";
|
|
3
|
-
const createMoveRecord = (model)=>{
|
|
4
|
-
const { singularApiName } = model;
|
|
5
|
-
return graphql_tag`
|
|
6
|
-
mutation Move${singularApiName}($id: ID!, $folderId: ID!) {
|
|
7
|
-
content: move${singularApiName}(revision: $id, folderId: $folderId) {
|
|
8
|
-
data
|
|
9
|
-
${ERROR_FIELD}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
`;
|
|
13
|
-
};
|
|
14
|
-
export { createMoveRecord };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=moveRecord.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/records/moveRecord.js","sources":["../../../src/graphql/records/moveRecord.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport type { AcoModel } from \"~/types.js\";\nimport { ERROR_FIELD } from \"./common.js\";\n\nexport const createMoveRecord = (model: AcoModel) => {\n const { singularApiName } = model;\n\n return gql`\n mutation Move${singularApiName}($id: ID!, $folderId: ID!) {\n content: move${singularApiName}(revision: $id, folderId: $folderId) {\n data\n ${ERROR_FIELD}\n }\n }\n `;\n};\n"],"names":["createMoveRecord","model","singularApiName","gql","ERROR_FIELD"],"mappings":";;AAIO,MAAMA,mBAAmB,CAACC;IAC7B,MAAM,EAAEC,eAAe,EAAE,GAAGD;IAE5B,OAAOE,WAAG,CAAC;yBACU,EAAED,gBAAgB;6BACd,EAAEA,gBAAgB;;oBAE3B,EAAEE,YAAY;;;QAG1B,CAAC;AACT"}
|