@jahia/data-helper 1.0.6 → 1.0.8

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.
Files changed (62) hide show
  1. package/esm/fragments/PredefinedFragments.js +21 -221
  2. package/esm/fragments/fragments.utils.js +17 -43
  3. package/esm/fragments/getIsNodeTypeFragment.js +2 -15
  4. package/esm/fragments/getPermissionFragment.js +3 -28
  5. package/esm/hooks/useContentPreview/useContentPreview.gql-queries.js +3 -13
  6. package/esm/hooks/useContentPreview/useContentPreview.js +7 -7
  7. package/esm/hooks/useContentPreview/useContentPreview.spec.js +1 -1
  8. package/esm/hooks/useDeepCompareMemo/useDeepCompareMemo.js +0 -2
  9. package/esm/hooks/useDeepCompareMemo/useDeepCompareMemo.spec.js +0 -1
  10. package/esm/hooks/useNodeChecks/useNodeChecks.js +13 -28
  11. package/esm/hooks/useNodeChecks/useNodeChecks.spec.js +156 -68
  12. package/esm/hooks/useNodeInfo/useMemoRequest.js +49 -0
  13. package/esm/hooks/useNodeInfo/useNodeInfo.gql-queries.js +23 -104
  14. package/esm/hooks/useNodeInfo/useNodeInfo.js +139 -57
  15. package/esm/hooks/useNodeInfo/useNodeInfo.spec.js +429 -233
  16. package/esm/hooks/useNodeInfo/useNodeInfo.utils.js +52 -0
  17. package/esm/hooks/useSchemaFields/useSchemaFields.gql-queries.js +2 -12
  18. package/esm/hooks/useSiteInfo/useSiteInfo.gql-queries.js +2 -12
  19. package/esm/hooks/useSiteInfo/useSiteInfo.js +2 -9
  20. package/esm/hooks/useTreeEntries/useTreeEntries.gql-queries.js +2 -12
  21. package/esm/hooks/useTreeEntries/useTreeEntries.js +17 -38
  22. package/esm/legacy/Picker.gql-fragments.js +4 -34
  23. package/esm/legacy/Picker.js +31 -113
  24. package/js/fragments/PredefinedFragments.js +21 -224
  25. package/js/fragments/encodeName.js +0 -2
  26. package/js/fragments/fragments.utils.js +17 -44
  27. package/js/fragments/getIsNodeTypeFragment.js +2 -23
  28. package/js/fragments/getPermissionFragment.js +3 -38
  29. package/js/fragments/index.js +0 -4
  30. package/js/hooks/index.js +0 -10
  31. package/js/hooks/useContentPreview/index.js +0 -2
  32. package/js/hooks/useContentPreview/useContentPreview.gql-queries.js +3 -17
  33. package/js/hooks/useContentPreview/useContentPreview.js +7 -11
  34. package/js/hooks/useContentPreview/useContentPreview.spec.js +1 -3
  35. package/js/hooks/useDeepCompareMemo/index.js +0 -2
  36. package/js/hooks/useDeepCompareMemo/useDeepCompareMemo.js +0 -7
  37. package/js/hooks/useDeepCompareMemo/useDeepCompareMemo.spec.js +0 -2
  38. package/js/hooks/useNodeChecks/index.js +0 -2
  39. package/js/hooks/useNodeChecks/useNodeChecks.js +13 -30
  40. package/js/hooks/useNodeChecks/useNodeChecks.spec.js +157 -70
  41. package/js/hooks/useNodeInfo/index.js +0 -2
  42. package/js/hooks/useNodeInfo/useMemoRequest.js +56 -0
  43. package/js/hooks/useNodeInfo/useNodeInfo.gql-queries.js +25 -111
  44. package/js/hooks/useNodeInfo/useNodeInfo.js +139 -65
  45. package/js/hooks/useNodeInfo/useNodeInfo.spec.js +430 -236
  46. package/js/hooks/useNodeInfo/useNodeInfo.utils.js +60 -0
  47. package/js/hooks/useSchemaFields/index.js +0 -2
  48. package/js/hooks/useSchemaFields/useSchemaFields.gql-queries.js +2 -15
  49. package/js/hooks/useSchemaFields/useSchemaFields.jsx +0 -4
  50. package/js/hooks/useSiteInfo/index.js +0 -2
  51. package/js/hooks/useSiteInfo/useSiteInfo.gql-queries.js +2 -16
  52. package/js/hooks/useSiteInfo/useSiteInfo.js +2 -12
  53. package/js/hooks/useSiteInfo/useSiteInfo.spec.js +0 -4
  54. package/js/hooks/useTreeEntries/index.js +0 -2
  55. package/js/hooks/useTreeEntries/useTreeEntries.gql-queries.js +2 -16
  56. package/js/hooks/useTreeEntries/useTreeEntries.js +17 -43
  57. package/js/hooks/useTreeEntries/useTreeEntries.spec.js +0 -3
  58. package/js/index.js +0 -6
  59. package/js/legacy/Picker.gql-fragments.js +4 -37
  60. package/js/legacy/Picker.js +31 -134
  61. package/js/legacy/index.js +0 -4
  62. package/package.json +1 -1
@@ -1,212 +1,12 @@
1
- function _templateObject20() {
2
- var data = _taggedTemplateLiteral(["fragment NodeInfoResourceNode on JCRNode {\n resourceChildren: children(names: [\"jcr:content\"]) {\n nodes {\n ...NodeCacheRequiredFields\n mimeType: property(name: \"jcr:mimeType\") {\n value\n }\n }\n }\n }"]);
3
-
4
- _templateObject20 = function _templateObject20() {
5
- return data;
6
- };
7
-
8
- return data;
9
- }
10
-
11
- function _templateObject19() {
12
- var data = _taggedTemplateLiteral(["fragment NodeTypeSubTypes on JCRNodeType {\n subTypes {\n nodes {\n name\n displayName(language:$language)\n abstract\n mixin\n }\n }\n }"]);
13
-
14
- _templateObject19 = function _templateObject19() {
15
- return data;
16
- };
17
-
18
- return data;
19
- }
20
-
21
- function _templateObject18() {
22
- var data = _taggedTemplateLiteral(["fragment NodeTypeDisplayName on JCRNodeType {\n displayName(language:$language)\n }"]);
23
-
24
- _templateObject18 = function _templateObject18() {
25
- return data;
26
- };
27
-
28
- return data;
29
- }
30
-
31
- function _templateObject17() {
32
- var data = _taggedTemplateLiteral(["fragment NodeCacheRequiredFields on JCRNode {\n uuid\n workspace\n path\n }"]);
33
-
34
- _templateObject17 = function _templateObject17() {
35
- return data;
36
- };
37
-
38
- return data;
39
- }
40
-
41
- function _templateObject16() {
42
- var data = _taggedTemplateLiteral(["fragment NodeSiteHomePage on JCRNode {\n children(typesFilter:{types:[\"jnt:page\"]}, propertiesFilter:{filters:[{property:\"j:isHomePage\", value:\"true\" }]}) {\n nodes {\n path\n ...NodeCacheRequiredFields\n }\n }\n }"]);
43
-
44
- _templateObject16 = function _templateObject16() {
45
- return data;
46
- };
47
-
48
- return data;
49
- }
50
-
51
- function _templateObject15() {
52
- var data = _taggedTemplateLiteral(["fragment ContentRestriction on JCRNode {\n contributeTypes: property(name: \"j:contributeTypes\") {\n values\n }\n ancestors(fieldFilter: {filters: {evaluation: NOT_EMPTY, fieldName: \"contributeTypes\"}}) {\n ...NodeCacheRequiredFields\n contributeTypes : property(name: \"j:contributeTypes\") {\n values\n }\n }\n }"]);
53
-
54
- _templateObject15 = function _templateObject15() {
55
- return data;
56
- };
57
-
58
- return data;
59
- }
60
-
61
- function _templateObject14() {
62
- var data = _taggedTemplateLiteral(["fragment AllowedChildNodeType on JCRNode {\n allowedChildNodeTypes(includeSubTypes: false) {\n name\n }\n }"]);
63
-
64
- _templateObject14 = function _templateObject14() {
65
- return data;
66
- };
67
-
68
- return data;
69
- }
70
-
71
- function _templateObject13() {
72
- var data = _taggedTemplateLiteral(["fragment SubNodesCount on JCRNode {\n subNodes: children(typesFilter: {types: $subNodesCountTypes, multi: ANY}) {\n pageInfo {\n totalCount\n }\n }\n }"]);
73
-
74
- _templateObject13 = function _templateObject13() {
75
- return data;
76
- };
77
-
78
- return data;
79
- }
80
-
81
- function _templateObject12() {
82
- var data = _taggedTemplateLiteral(["fragment LockInfo on JCRNode {\n lockOwner: property(name: \"jcr:lockOwner\") {\n value\n }\n lockTypes: property(name: \"j:lockTypes\") {\n values\n }\n }"]);
83
-
84
- _templateObject12 = function _templateObject12() {
85
- return data;
86
- };
87
-
88
- return data;
89
- }
90
-
91
- function _templateObject11() {
92
- var data = _taggedTemplateLiteral(["fragment DisplayableNodePath on JCRNode {\n displayableNode {\n path\n ...NodeCacheRequiredFields\n }\n }"]);
93
-
94
- _templateObject11 = function _templateObject11() {
95
- return data;
96
- };
97
-
98
- return data;
99
- }
100
-
101
- function _templateObject10() {
102
- var data = _taggedTemplateLiteral(["fragment SiteLanguages on JCRNode {\n site {\n defaultLanguage\n ...NodeCacheRequiredFields\n languages {\n displayName\n language\n activeInEdit\n }\n }\n }"]);
103
-
104
- _templateObject10 = function _templateObject10() {
105
- return data;
106
- };
107
-
108
- return data;
109
- }
110
-
111
- function _templateObject9() {
112
- var data = _taggedTemplateLiteral(["fragment SiteInstalledModules on JCRNode {\n site {\n installedModulesWithAllDependencies\n ...NodeCacheRequiredFields\n }\n }"]);
113
-
114
- _templateObject9 = function _templateObject9() {
115
- return data;
116
- };
117
-
118
- return data;
119
- }
120
-
121
- function _templateObject8() {
122
- var data = _taggedTemplateLiteral(["fragment NodeProperties on JCRNode {\n properties(names: $getPropertiesNames, language: $language) {\n name\n value\n values\n }\n }"]);
123
-
124
- _templateObject8 = function _templateObject8() {
125
- return data;
126
- };
127
-
128
- return data;
129
- }
130
-
131
- function _templateObject7() {
132
- var data = _taggedTemplateLiteral(["fragment NodeAllProperties on JCRNode {\n properties(language:$language) {\n name\n value\n values\n }\n }"]);
133
-
134
- _templateObject7 = function _templateObject7() {
135
- return data;
136
- };
137
-
138
- return data;
139
- }
140
-
141
- function _templateObject6() {
142
- var data = _taggedTemplateLiteral(["fragment OperationSupport on JCRNode {\n operationsSupport {\n lock\n markForDeletion\n publication\n }\n }"]);
143
-
144
- _templateObject6 = function _templateObject6() {
145
- return data;
146
- };
147
-
148
- return data;
149
- }
150
-
151
- function _templateObject5() {
152
- var data = _taggedTemplateLiteral(["fragment AggregatedPublicationInfoWithExistsInLive on JCRNode {\n aggregatedPublicationInfo(language: $language, subNodes: $aggregatedPublicationInfoSubNodes, references:$aggregatedPublicationInfoIncludeReference) {\n publicationStatus\n existsInLive\n }\n }"]);
153
-
154
- _templateObject5 = function _templateObject5() {
155
- return data;
156
- };
157
-
158
- return data;
159
- }
160
-
161
- function _templateObject4() {
162
- var data = _taggedTemplateLiteral(["fragment AggregatedPublicationInfo on JCRNode {\n aggregatedPublicationInfo(language: $language, subNodes: $aggregatedPublicationInfoSubNodes, references:$aggregatedPublicationInfoIncludeReference) {\n publicationStatus\n }\n }"]);
163
-
164
- _templateObject4 = function _templateObject4() {
165
- return data;
166
- };
167
-
168
- return data;
169
- }
170
-
171
- function _templateObject3() {
172
- var data = _taggedTemplateLiteral(["fragment ParentNodeInfo on JCRNode {\n parent {\n path\n name\n ...NodeCacheRequiredFields\n }\n }"]);
173
-
174
- _templateObject3 = function _templateObject3() {
175
- return data;
176
- };
177
-
178
- return data;
179
- }
180
-
181
- function _templateObject2() {
182
- var data = _taggedTemplateLiteral(["fragment NodeInfoPrimaryNodeType on JCRNode {\n primaryNodeType {\n name\n displayName(language: $displayLanguage) @include(if: $displayLanguageSet)\n icon\n }\n }"]);
183
-
184
- _templateObject2 = function _templateObject2() {
185
- return data;
186
- };
187
-
188
- return data;
189
- }
190
-
191
- function _templateObject() {
192
- var data = _taggedTemplateLiteral(["fragment DisplayName on JCRNode {\n displayName(language:$language)\n }"]);
193
-
194
- _templateObject = function _templateObject() {
195
- return data;
196
- };
197
-
198
- return data;
199
- }
200
-
1
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20;
201
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
202
-
203
3
  import gql from 'graphql-tag';
204
4
  export var displayName = {
205
5
  variables: {
206
6
  language: 'String!'
207
7
  },
208
8
  applyFor: 'node',
209
- gql: gql(_templateObject())
9
+ gql: gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["fragment DisplayName on JCRNode {\n displayName(language:$language)\n }"])))
210
10
  };
211
11
  export var primaryNodeType = {
212
12
  variables: {
@@ -214,11 +14,11 @@ export var primaryNodeType = {
214
14
  displayLanguageSet: 'Boolean!'
215
15
  },
216
16
  applyFor: 'node',
217
- gql: gql(_templateObject2())
17
+ gql: gql(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["fragment NodeInfoPrimaryNodeType on JCRNode {\n primaryNodeType {\n name\n displayName(language: $displayLanguage) @include(if: $displayLanguageSet)\n icon\n }\n }"])))
218
18
  };
219
19
  export var parentNode = {
220
20
  applyFor: 'node',
221
- gql: gql(_templateObject3())
21
+ gql: gql(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["fragment ParentNodeInfo on JCRNode {\n parent {\n path\n name\n ...NodeCacheRequiredFields\n }\n }"])))
222
22
  };
223
23
  export var aggregatedPublicationInfo = {
224
24
  variables: {
@@ -227,7 +27,7 @@ export var aggregatedPublicationInfo = {
227
27
  aggregatedPublicationInfoIncludeReference: 'Boolean'
228
28
  },
229
29
  applyFor: 'node',
230
- gql: gql(_templateObject4())
30
+ gql: gql(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["fragment AggregatedPublicationInfo on JCRNode {\n aggregatedPublicationInfo(language: $language, subNodes: $aggregatedPublicationInfoSubNodes, references:$aggregatedPublicationInfoIncludeReference) {\n publicationStatus\n }\n }"])))
231
31
  };
232
32
  export var aggregatedPublicationInfoWithExistInLive = {
233
33
  variables: {
@@ -236,18 +36,18 @@ export var aggregatedPublicationInfoWithExistInLive = {
236
36
  aggregatedPublicationInfoIncludeReference: 'Boolean'
237
37
  },
238
38
  applyFor: 'node',
239
- gql: gql(_templateObject5())
39
+ gql: gql(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["fragment AggregatedPublicationInfoWithExistsInLive on JCRNode {\n aggregatedPublicationInfo(language: $language, subNodes: $aggregatedPublicationInfoSubNodes, references:$aggregatedPublicationInfoIncludeReference) {\n publicationStatus\n existsInLive\n }\n }"])))
240
40
  };
241
41
  export var operationSupport = {
242
42
  applyFor: 'node',
243
- gql: gql(_templateObject6())
43
+ gql: gql(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["fragment OperationSupport on JCRNode {\n operationsSupport {\n lock\n markForDeletion\n publication\n }\n }"])))
244
44
  };
245
45
  export var allProperties = {
246
46
  variables: {
247
47
  language: 'String!'
248
48
  },
249
49
  applyFor: 'node',
250
- gql: gql(_templateObject7())
50
+ gql: gql(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["fragment NodeAllProperties on JCRNode {\n properties(language:$language) {\n name\n value\n values\n }\n }"])))
251
51
  };
252
52
  export var getProperties = {
253
53
  variables: {
@@ -255,64 +55,64 @@ export var getProperties = {
255
55
  getPropertiesNames: '[String!]!'
256
56
  },
257
57
  applyFor: 'node',
258
- gql: gql(_templateObject8())
58
+ gql: gql(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["fragment NodeProperties on JCRNode {\n properties(names: $getPropertiesNames, language: $language) {\n name\n value\n values\n }\n }"])))
259
59
  };
260
60
  export var installedModules = {
261
61
  applyFor: 'node',
262
- gql: gql(_templateObject9())
62
+ gql: gql(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["fragment SiteInstalledModules on JCRNode {\n site {\n installedModulesWithAllDependencies\n ...NodeCacheRequiredFields\n }\n }"])))
263
63
  };
264
64
  export var siteLanguages = {
265
65
  applyFor: 'node',
266
- gql: gql(_templateObject10())
66
+ gql: gql(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["fragment SiteLanguages on JCRNode {\n site {\n defaultLanguage\n ...NodeCacheRequiredFields\n languages {\n displayName\n language\n activeInEdit\n }\n }\n }"])))
267
67
  };
268
68
  export var displayableNode = {
269
69
  applyFor: 'node',
270
- gql: gql(_templateObject11())
70
+ gql: gql(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["fragment DisplayableNodePath on JCRNode {\n displayableNode {\n path\n ...NodeCacheRequiredFields\n }\n }"])))
271
71
  };
272
72
  export var lockInfo = {
273
73
  applyFor: 'node',
274
- gql: gql(_templateObject12())
74
+ gql: gql(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["fragment LockInfo on JCRNode {\n lockOwner: property(name: \"jcr:lockOwner\") {\n value\n }\n lockTypes: property(name: \"j:lockTypes\") {\n values\n }\n }"])))
275
75
  };
276
76
  export var subNodesCount = {
277
77
  variables: {
278
78
  subNodesCountTypes: '[String!]!'
279
79
  },
280
80
  applyFor: 'node',
281
- gql: gql(_templateObject13())
81
+ gql: gql(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["fragment SubNodesCount on JCRNode {\n subNodes: children(typesFilter: {types: $subNodesCountTypes, multi: ANY}) {\n pageInfo {\n totalCount\n }\n }\n }"])))
282
82
  };
283
83
  export var childNodeTypes = {
284
84
  applyFor: 'node',
285
- gql: gql(_templateObject14())
85
+ gql: gql(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["fragment AllowedChildNodeType on JCRNode {\n allowedChildNodeTypes(includeSubTypes: false) {\n name\n }\n }"])))
286
86
  };
287
87
  export var contentRestrictions = {
288
88
  applyFor: 'node',
289
- gql: gql(_templateObject15())
89
+ gql: gql(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["fragment ContentRestriction on JCRNode {\n contributeTypes: property(name: \"j:contributeTypes\") {\n values\n }\n ancestors(fieldFilter: {filters: {evaluation: NOT_EMPTY, fieldName: \"contributeTypes\"}}) {\n ...NodeCacheRequiredFields\n contributeTypes : property(name: \"j:contributeTypes\") {\n values\n }\n }\n }"])))
290
90
  };
291
91
  export var siteHomePage = {
292
92
  applyFor: 'node',
293
- gql: gql(_templateObject16())
93
+ gql: gql(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["fragment NodeSiteHomePage on JCRNode {\n children(typesFilter:{types:[\"jnt:page\"]}, propertiesFilter:{filters:[{property:\"j:isHomePage\", value:\"true\" }]}) {\n nodes {\n path\n ...NodeCacheRequiredFields\n }\n }\n }"])))
294
94
  };
295
95
  export var nodeCacheRequiredFields = {
296
96
  applyFor: 'node',
297
- gql: gql(_templateObject17())
97
+ gql: gql(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["fragment NodeCacheRequiredFields on JCRNode {\n uuid\n workspace\n path\n }"])))
298
98
  };
299
99
  export var nodeTypeDisplayName = {
300
100
  variables: {
301
101
  language: 'String!'
302
102
  },
303
103
  applyFor: 'nodeType',
304
- gql: gql(_templateObject18())
104
+ gql: gql(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["fragment NodeTypeDisplayName on JCRNodeType {\n displayName(language:$language)\n }"])))
305
105
  };
306
106
  export var nodeTypeSubTypes = {
307
107
  variables: {
308
108
  language: 'String!'
309
109
  },
310
110
  applyFor: 'nodeType',
311
- gql: gql(_templateObject19())
111
+ gql: gql(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["fragment NodeTypeSubTypes on JCRNodeType {\n subTypes {\n nodes {\n name\n displayName(language:$language)\n abstract\n mixin\n }\n }\n }"])))
312
112
  };
313
113
  export var mimeTypes = {
314
114
  applyFor: 'node',
315
- gql: gql(_templateObject20())
115
+ gql: gql(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["fragment NodeInfoResourceNode on JCRNode {\n resourceChildren: children(names: [\"jcr:content\"]) {\n nodes {\n ...NodeCacheRequiredFields\n mimeType: property(name: \"jcr:mimeType\") {\n value\n }\n }\n }\n }"])))
316
116
  };
317
117
  export var PredefinedFragments = {
318
118
  displayName: displayName,
@@ -1,55 +1,37 @@
1
1
  import _cloneDeep from "lodash/cloneDeep";
2
-
3
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
-
5
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
-
7
4
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
-
9
5
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
10
-
11
6
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
12
-
13
7
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
-
15
8
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
-
17
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
-
19
10
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
-
21
11
  import { parseType } from 'graphql';
22
12
  import { PredefinedFragments } from '../fragments';
23
-
24
13
  function findParametersInDocument(doc) {
25
14
  if (doc && doc.definitions) {
26
15
  return doc.definitions.flatMap(function (def) {
27
16
  return findParametersInSelectionSet(def.selectionSet);
28
17
  });
29
18
  }
30
-
31
19
  return [];
32
20
  }
33
-
34
21
  var queryCache = {};
35
-
36
22
  function replaceFragmentsInDocument(doc, fragments) {
37
23
  if (!fragments) {
38
24
  fragments = [];
39
25
  }
40
-
41
26
  var key = doc.definitions[0].name.value + '__' + fragments.map(function (f) {
42
27
  return typeof f === 'string' ? PredefinedFragments[f] : f;
43
28
  }).map(function (f) {
44
29
  return f.gql.definitions[0].name.value;
45
30
  }).sort().join('_');
46
-
47
31
  if (queryCache[key]) {
48
32
  return queryCache[key];
49
33
  }
50
-
51
34
  var clonedQuery = null;
52
-
53
35
  if (doc && doc.definitions) {
54
36
  clonedQuery = _cloneDeep(doc);
55
37
  clonedQuery.definitions.forEach(function (def) {
@@ -57,11 +39,9 @@ function replaceFragmentsInDocument(doc, fragments) {
57
39
  });
58
40
  clonedQuery.definitions[0].name.value = key;
59
41
  }
60
-
61
42
  queryCache[key] = clonedQuery;
62
43
  return clonedQuery;
63
44
  }
64
-
65
45
  function findParametersInSelectionSet(selectionSet) {
66
46
  if (selectionSet && selectionSet.selections) {
67
47
  return selectionSet.selections.flatMap(function (sel) {
@@ -74,10 +54,8 @@ function findParametersInSelectionSet(selectionSet) {
74
54
  });
75
55
  });
76
56
  }
77
-
78
57
  return [];
79
58
  }
80
-
81
59
  function findFragmentsInSelectionSet(selectionSet) {
82
60
  if (selectionSet && selectionSet.selections) {
83
61
  return selectionSet.selections.filter(function (sel) {
@@ -88,17 +66,14 @@ function findFragmentsInSelectionSet(selectionSet) {
88
66
  return findFragmentsInSelectionSet(sel.selectionSet);
89
67
  }));
90
68
  }
91
-
92
69
  return [];
93
70
  }
94
-
95
71
  function replaceFragmentsInSelectionSet(selectionSet, fragments, def, document) {
96
72
  if (selectionSet && selectionSet.selections) {
97
73
  var _selectionSet$selecti;
98
-
99
74
  var newFragmentsSpreads = [];
100
- var removedFragmentSpreads = []; // Look for all existing fragment spreads in selection set
101
-
75
+ var removedFragmentSpreads = [];
76
+ // Look for all existing fragment spreads in selection set
102
77
  selectionSet.selections.filter(function (sel) {
103
78
  return sel.kind === 'FragmentSpread';
104
79
  }).forEach(function (sel) {
@@ -108,11 +83,11 @@ function replaceFragmentsInSelectionSet(selectionSet, fragments, def, document)
108
83
  var existing = document.definitions.find(function (definition) {
109
84
  return definition.kind === 'FragmentDefinition' && definition.name.value === sel.name.value;
110
85
  });
111
-
112
86
  if (!existing) {
113
87
  // First remove the spread, as it has no match in document
114
- removedFragmentSpreads.push(sel); // Check if a replacement is provided for this pseudo-fragment, then insert spreads and definitions
88
+ removedFragmentSpreads.push(sel);
115
89
 
90
+ // Check if a replacement is provided for this pseudo-fragment, then insert spreads and definitions
116
91
  if (fragments) {
117
92
  fragments = fragments.map(function (frag) {
118
93
  return typeof frag === 'string' ? PredefinedFragments[frag] : frag;
@@ -124,31 +99,29 @@ function replaceFragmentsInSelectionSet(selectionSet, fragments, def, document)
124
99
  return fragment.gql.definitions;
125
100
  }).forEach(function (frag) {
126
101
  var newSpread = _cloneDeep(sel);
127
-
128
102
  newSpread.name.value = frag.name.value;
129
- newFragmentsSpreads.push(newSpread); // Add the new fragment definition in document if it has not already been added
103
+ newFragmentsSpreads.push(newSpread);
130
104
 
105
+ // Add the new fragment definition in document if it has not already been added
131
106
  var existing = document.definitions.find(function (definition) {
132
107
  return definition.kind === 'FragmentDefinition' && definition.name.value === frag.name.value;
133
108
  });
134
-
135
109
  if (!existing) {
136
110
  document.definitions.push(frag);
137
111
  }
138
- }); // Adds the associated variables to the query
112
+ });
139
113
 
114
+ // Adds the associated variables to the query
140
115
  var allVariables = applyableFragments.reduce(function (result, n) {
141
- return _objectSpread({}, result, {}, n.variables);
116
+ return _objectSpread(_objectSpread({}, result), n.variables);
142
117
  }, {});
143
118
  Object.entries(allVariables).forEach(function (_ref) {
144
119
  var _ref2 = _slicedToArray(_ref, 2),
145
- name = _ref2[0],
146
- value = _ref2[1];
147
-
120
+ name = _ref2[0],
121
+ value = _ref2[1];
148
122
  var existing = def.variableDefinitions.find(function (def) {
149
123
  return def.variable.name.value === name;
150
124
  });
151
-
152
125
  if (!existing) {
153
126
  var type = parseType(value, {
154
127
  noLocation: true
@@ -169,19 +142,20 @@ function replaceFragmentsInSelectionSet(selectionSet, fragments, def, document)
169
142
  }
170
143
  }
171
144
  }
172
- }); // Removed replaced spreads
145
+ });
173
146
 
147
+ // Removed replaced spreads
174
148
  selectionSet.selections = selectionSet.selections.filter(function (sel) {
175
149
  return removedFragmentSpreads.indexOf(sel) === -1;
176
- }); // Add all new spreads
177
-
178
- (_selectionSet$selecti = selectionSet.selections).push.apply(_selectionSet$selecti, newFragmentsSpreads); // Recursively call on sub-selections set
150
+ });
179
151
 
152
+ // Add all new spreads
153
+ (_selectionSet$selecti = selectionSet.selections).push.apply(_selectionSet$selecti, newFragmentsSpreads);
180
154
 
155
+ // Recursively call on sub-selections set
181
156
  selectionSet.selections.forEach(function (sel) {
182
157
  return replaceFragmentsInSelectionSet(sel.selectionSet, fragments, def, document);
183
158
  });
184
159
  }
185
160
  }
186
-
187
161
  export { replaceFragmentsInDocument, findParametersInDocument, findFragmentsInSelectionSet };
@@ -1,32 +1,19 @@
1
- function _templateObject() {
2
- var data = _taggedTemplateLiteral(["fragment NodeType_", " on JCRNode {\n ", ":isNodeType(type: $", ")\n }"]);
3
-
4
- _templateObject = function _templateObject() {
5
- return data;
6
- };
7
-
8
- return data;
9
- }
10
-
1
+ var _templateObject;
11
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
12
-
13
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
-
15
4
  import gql from 'graphql-tag';
16
5
  import { encodeName } from './encodeName';
17
6
  var fragments = {};
18
7
  export var getNodeTypeFragment = function getNodeTypeFragment(name) {
19
8
  var encodedName = getEncodedNodeTypeName(name);
20
-
21
9
  if (!fragments[encodedName]) {
22
10
  var fragment = {
23
11
  applyFor: 'node',
24
12
  variables: _defineProperty({}, encodedName, 'InputNodeTypesInput!'),
25
- gql: gql(_templateObject(), encodedName, encodedName, encodedName)
13
+ gql: gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["fragment NodeType_", " on JCRNode {\n ", ":isNodeType(type: $", ")\n }"])), encodedName, encodedName, encodedName)
26
14
  };
27
15
  fragments[encodedName] = fragment;
28
16
  }
29
-
30
17
  return {
31
18
  fragment: fragments[encodedName],
32
19
  variables: _defineProperty({}, encodedName, {
@@ -1,42 +1,19 @@
1
- function _templateObject2() {
2
- var data = _taggedTemplateLiteral(["fragment SiteNodePermission_", " on JCRNode {\n site {\n ...NodeCacheRequiredFields\n ", ":hasPermission(permissionName: $", ")\n }\n }"]);
3
-
4
- _templateObject2 = function _templateObject2() {
5
- return data;
6
- };
7
-
8
- return data;
9
- }
10
-
11
- function _templateObject() {
12
- var data = _taggedTemplateLiteral(["fragment NodePermission_", " on JCRNode {\n ", ":hasPermission(permissionName: $", ")\n }"]);
13
-
14
- _templateObject = function _templateObject() {
15
- return data;
16
- };
17
-
18
- return data;
19
- }
20
-
1
+ var _templateObject, _templateObject2;
21
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
22
-
23
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
-
25
4
  import gql from 'graphql-tag';
26
5
  import { encodeName } from './encodeName';
27
6
  var fragments = {};
28
7
  export var getPermissionFragment = function getPermissionFragment(name) {
29
8
  var encodedName = getEncodedPermissionName(name);
30
-
31
9
  if (!fragments[encodedName]) {
32
10
  var fragment = {
33
11
  applyFor: 'node',
34
12
  variables: _defineProperty({}, encodedName, 'String!'),
35
- gql: gql(_templateObject(), encodedName, encodedName, encodedName)
13
+ gql: gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["fragment NodePermission_", " on JCRNode {\n ", ":hasPermission(permissionName: $", ")\n }"])), encodedName, encodedName, encodedName)
36
14
  };
37
15
  fragments[encodedName] = fragment;
38
16
  }
39
-
40
17
  return {
41
18
  fragment: fragments[encodedName],
42
19
  variables: _defineProperty({}, encodedName, name)
@@ -44,16 +21,14 @@ export var getPermissionFragment = function getPermissionFragment(name) {
44
21
  };
45
22
  export var getSitePermissionFragment = function getSitePermissionFragment(name) {
46
23
  var encodedName = getEncodedPermissionName(name);
47
-
48
24
  if (!fragments['site_' + encodedName]) {
49
25
  var fragment = {
50
26
  applyFor: 'node',
51
27
  variables: _defineProperty({}, encodedName, 'String!'),
52
- gql: gql(_templateObject2(), encodedName, encodedName, encodedName)
28
+ gql: gql(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["fragment SiteNodePermission_", " on JCRNode {\n site {\n ...NodeCacheRequiredFields\n ", ":hasPermission(permissionName: $", ")\n }\n }"])), encodedName, encodedName, encodedName)
53
29
  };
54
30
  fragments['site_' + encodedName] = fragment;
55
31
  }
56
-
57
32
  return {
58
33
  fragment: fragments['site_' + encodedName],
59
34
  variables: _defineProperty({}, encodedName, name)
@@ -1,15 +1,5 @@
1
- function _templateObject() {
2
- var data = _taggedTemplateLiteral(["query previewQueryByWorkspace($path: String!, $templateType: String!, $view: String!, $contextConfiguration: String!, $language: String!, $workspace: Workspace!, $requestAttributes: [InputRenderRequestAttributeInput]) {\n jcr(workspace: $workspace) {\n nodeByPath(path: $path) {\n id: uuid\n isFile: isNodeType(type: {types: [\"jnt:file\"]})\n path\n lastModified: property(name: \"jcr:lastModified\", language: $language) {\n value\n }\n renderedContent(templateType: $templateType, view: $view, contextConfiguration: $contextConfiguration, language: $language, requestAttributes: $requestAttributes) {\n output\n staticAssets(type: \"css\") {\n key\n }\n }\n ...NodeCacheRequiredFields\n }\n }\n}", ""]);
3
-
4
- _templateObject = function _templateObject() {
5
- return data;
6
- };
7
-
8
- return data;
9
- }
10
-
1
+ var _templateObject;
11
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
12
-
13
3
  import gql from 'graphql-tag';
14
- import { nodeCacheRequiredFields } from '../../fragments/PredefinedFragments';
15
- export var CONTENT_PREVIEW_QUERY = gql(_templateObject(), nodeCacheRequiredFields.gql);
4
+ import { mimeTypes, nodeCacheRequiredFields } from '../../fragments';
5
+ export var CONTENT_PREVIEW_QUERY = gql(_templateObject || (_templateObject = _taggedTemplateLiteral(["query previewQueryByWorkspace($path: String!, $templateType: String!, $view: String!, $contextConfiguration: String!, $language: String!, $workspace: Workspace!, $requestAttributes: [InputRenderRequestAttributeInput]) {\n jcr(workspace: $workspace) {\n nodeByPath(path: $path) {\n id: uuid\n isFile: isNodeType(type: {types: [\"jnt:file\"]})\n path\n lastModified: property(name: \"jcr:lastModified\", language: $language) {\n value\n }\n renderedContent(templateType: $templateType, view: $view, contextConfiguration: $contextConfiguration, language: $language, requestAttributes: $requestAttributes) {\n output\n staticAssets(type: \"css\") {\n key\n }\n }\n ...NodeInfoResourceNode\n ...NodeCacheRequiredFields\n }\n }\n}", "", ""])), nodeCacheRequiredFields.gql, mimeTypes.gql);
@@ -2,13 +2,13 @@ import { useQuery } from 'react-apollo';
2
2
  import { CONTENT_PREVIEW_QUERY } from './useContentPreview.gql-queries';
3
3
  export var useContentPreview = function useContentPreview(_ref) {
4
4
  var path = _ref.path,
5
- workspace = _ref.workspace,
6
- language = _ref.language,
7
- templateType = _ref.templateType,
8
- view = _ref.view,
9
- contextConfiguration = _ref.contextConfiguration,
10
- requestAttributes = _ref.requestAttributes,
11
- fetchPolicy = _ref.fetchPolicy;
5
+ workspace = _ref.workspace,
6
+ language = _ref.language,
7
+ templateType = _ref.templateType,
8
+ view = _ref.view,
9
+ contextConfiguration = _ref.contextConfiguration,
10
+ requestAttributes = _ref.requestAttributes,
11
+ fetchPolicy = _ref.fetchPolicy;
12
12
  var variables = {
13
13
  path: path,
14
14
  templateType: templateType,
@@ -28,7 +28,7 @@ describe('useContentPreview', function () {
28
28
  useContentPreview(args);
29
29
  expect(useQuery).toHaveBeenCalled();
30
30
  });
31
- it('should return empty object when return emtpy data', function () {
31
+ it('should return empty object when return empty data', function () {
32
32
  expect(useContentPreview(args).data).toEqual({});
33
33
  });
34
34
  });