@jahia/cypress 3.17.8 → 3.17.9

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.
@@ -7,11 +7,23 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
7
7
  };
8
8
  exports.__esModule = true;
9
9
  exports.getDescriptions = void 0;
10
+ // The type name to be used for further introspection can be located either in
11
+ // the type object itself or in the ofType object
12
+ var addTypes = (function (type, atPath) {
13
+ var newTypes = [];
14
+ if (type.name !== null) {
15
+ newTypes.push({ typeName: type.name, atPath: atPath });
16
+ }
17
+ if (type.ofType && type.ofType.name !== null) {
18
+ newTypes.push({ typeName: type.ofType.name, atPath: atPath });
19
+ }
20
+ return newTypes;
21
+ });
10
22
  // This returns a flat list of all children fields and args for a given GraphQL node
11
23
  // This list can then be used in Cypress tests to look for missing descriptions
12
24
  var getDescriptions = function (rootNode) {
13
25
  cy.log('Starting analysis from GraphQL node: ' + rootNode);
14
- return execIntrospection(rootNode, [], []).then(function (descriptions) {
26
+ return execIntrospection(rootNode, [], [rootNode]).then(function (descriptions) {
15
27
  return descriptions;
16
28
  });
17
29
  };
@@ -44,15 +56,17 @@ var execIntrospection = function (typeName, descriptions, nodePath) {
44
56
  if (responseDataType.fields) {
45
57
  for (var _i = 0, _b = responseDataType.fields; _i < _b.length; _i++) {
46
58
  var graphqlField = _b[_i];
47
- var fieldPath = __spreadArray(__spreadArray([], nodePath), [responseDataType.name, graphqlField.name]);
59
+ var fieldPath = __spreadArray(__spreadArray([], nodePath), [graphqlField.name]);
48
60
  descriptions.push({
49
61
  name: graphqlField.name,
50
62
  description: graphqlField.description,
51
63
  schemaType: '__Field',
52
64
  schemaNode: graphqlField,
65
+ isDeprecated: graphqlField.isDeprecated,
66
+ deprecationReason: graphqlField.deprecationReason,
53
67
  nodePath: fieldPath
54
68
  });
55
- fetchSubTypes_1.push({ typeName: graphqlField.type.name, atPath: fieldPath });
69
+ fetchSubTypes_1 = __spreadArray(__spreadArray([], fetchSubTypes_1), addTypes(graphqlField.type, fieldPath));
56
70
  if (graphqlField.args) {
57
71
  for (var _c = 0, _d = graphqlField.args; _c < _d.length; _c++) {
58
72
  var graphQLInputValue = _d[_c];
@@ -62,9 +76,11 @@ var execIntrospection = function (typeName, descriptions, nodePath) {
62
76
  description: graphQLInputValue.description,
63
77
  schemaType: '__InputValue',
64
78
  schemaNode: graphQLInputValue,
79
+ isDeprecated: graphQLInputValue.isDeprecated,
80
+ deprecationReason: graphQLInputValue.deprecationReason,
65
81
  nodePath: inputValuePath
66
82
  });
67
- fetchSubTypes_1.push({ typeName: graphQLInputValue.type.name, atPath: inputValuePath });
83
+ fetchSubTypes_1 = __spreadArray(__spreadArray([], fetchSubTypes_1), addTypes(graphQLInputValue.type, inputValuePath));
68
84
  }
69
85
  }
70
86
  }
@@ -72,15 +88,14 @@ var execIntrospection = function (typeName, descriptions, nodePath) {
72
88
  if (responseDataType.interfaces) {
73
89
  for (var _e = 0, _f = responseDataType.interfaces; _e < _f.length; _e++) {
74
90
  var graphQLInterfaceType = _f[_e];
75
- var fieldPath = __spreadArray(__spreadArray([], nodePath), [responseDataType.name, graphQLInterfaceType.name]);
76
91
  descriptions.push({
77
92
  name: graphQLInterfaceType.name,
78
93
  description: graphQLInterfaceType.description,
79
94
  schemaType: '__Type',
80
95
  schemaNode: graphQLInterfaceType,
81
- nodePath: fieldPath
96
+ nodePath: nodePath
82
97
  });
83
- fetchSubTypes_1.push({ typeName: graphQLInterfaceType.name, atPath: fieldPath });
98
+ fetchSubTypes_1 = __spreadArray(__spreadArray([], fetchSubTypes_1), addTypes(graphQLInterfaceType, nodePath));
84
99
  }
85
100
  }
86
101
  if (responseDataType.possibleTypes) {
@@ -94,7 +109,7 @@ var execIntrospection = function (typeName, descriptions, nodePath) {
94
109
  schemaNode: graphQLType,
95
110
  nodePath: fieldPath
96
111
  });
97
- fetchSubTypes_1.push({ typeName: graphQLType.name, atPath: fieldPath });
112
+ fetchSubTypes_1 = __spreadArray(__spreadArray([], fetchSubTypes_1), addTypes(graphQLType, fieldPath));
98
113
  }
99
114
  }
100
115
  if (responseDataType.enumValues) {
@@ -106,7 +121,9 @@ var execIntrospection = function (typeName, descriptions, nodePath) {
106
121
  description: graphQLEnumValue.description,
107
122
  schemaType: '__EnumValue',
108
123
  schemaNode: graphQLEnumValue,
109
- nodePath: enumPath
124
+ nodePath: enumPath,
125
+ isDeprecated: graphQLEnumValue.isDeprecated,
126
+ deprecationReason: graphQLEnumValue.deprecationReason
110
127
  });
111
128
  }
112
129
  }
@@ -121,11 +138,11 @@ var execIntrospection = function (typeName, descriptions, nodePath) {
121
138
  schemaNode: graphQLInputValue,
122
139
  nodePath: inputValuePath
123
140
  });
124
- fetchSubTypes_1.push({ typeName: graphQLInputValue.type.name, atPath: inputValuePath });
141
+ fetchSubTypes_1 = __spreadArray(__spreadArray([], fetchSubTypes_1), addTypes(graphQLInputValue.type, inputValuePath));
125
142
  }
126
143
  }
127
144
  if (responseDataType.ofType) {
128
- fetchSubTypes_1.push({ typeName: responseDataType.ofType.name, atPath: nodePath });
145
+ fetchSubTypes_1 = __spreadArray(__spreadArray([], fetchSubTypes_1), addTypes(responseDataType.ofType, nodePath));
129
146
  }
130
147
  var uniqueSubTypes = fetchSubTypes_1
131
148
  // Filter out duplicate types to ensure we don't introspect the same type multiple times
@@ -134,6 +151,10 @@ var execIntrospection = function (typeName, descriptions, nodePath) {
134
151
  .filter(function (subtype) { return subtype.typeName !== null; })
135
152
  // Remove types that might have already been introspected
136
153
  .filter(function (subtype) { return descriptions.find(function (d) { return d.schemaType === '__Type' && d.name === subtype.typeName; }) === undefined; });
154
+ // If there are no subtypes to introspect, we still need to return the descriptions
155
+ if (uniqueSubTypes.length === 0) {
156
+ return descriptions;
157
+ }
137
158
  return Cypress.Promise.each(uniqueSubTypes, function (subType) {
138
159
  return execIntrospection(subType.typeName, descriptions, __spreadArray(__spreadArray([], subType.atPath), [subType.typeName]));
139
160
  }).then(function () { return descriptions; }); // Return descriptions after all recursive calls have completed
@@ -20,15 +20,27 @@ query IntrospectionQuery($typeName: String!) {
20
20
  kind
21
21
  name
22
22
  description
23
+ ofType {
24
+ name
25
+ description
26
+ }
23
27
  }
24
28
  }
25
29
  interfaces {
26
30
  name
27
31
  description
32
+ ofType {
33
+ name
34
+ description
35
+ }
28
36
  }
29
37
  possibleTypes {
30
38
  name
31
39
  description
40
+ ofType {
41
+ name
42
+ description
43
+ }
32
44
  }
33
45
  enumValues(includeDeprecated: true) {
34
46
  name
@@ -43,11 +55,19 @@ query IntrospectionQuery($typeName: String!) {
43
55
  kind
44
56
  name
45
57
  description
58
+ ofType {
59
+ name
60
+ description
61
+ }
46
62
  }
47
63
  }
48
64
  ofType {
49
65
  name
50
66
  description
67
+ ofType {
68
+ name
69
+ description
70
+ }
51
71
  }
52
72
  }
53
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "3.17.8",
3
+ "version": "3.17.9",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts"
@@ -9,14 +9,31 @@ interface GraphQLDescription {
9
9
  description: string; // Description of the element in the schema
10
10
  schemaType: string; // Type of the element in the schema according to the GraphQL spec
11
11
  schemaNode: GraphQLField; // The actual node fetched from the schema
12
- nodePath: string[] // The path to the node in the schema
12
+ nodePath: string[]; // The path to the node in the schema
13
+ isDeprecated?: boolean;
14
+ deprecationReason?: string;
13
15
  }
14
16
 
17
+ // The type name to be used for further introspection can be located either in
18
+ // the type object itself or in the ofType object
19
+ const addTypes = ((type, atPath) => {
20
+ const newTypes = [];
21
+ if (type.name !== null) {
22
+ newTypes.push({typeName: type.name, atPath: atPath});
23
+ }
24
+
25
+ if (type.ofType && type.ofType.name !== null) {
26
+ newTypes.push({typeName: type.ofType.name, atPath: atPath});
27
+ }
28
+
29
+ return newTypes;
30
+ });
31
+
15
32
  // This returns a flat list of all children fields and args for a given GraphQL node
16
33
  // This list can then be used in Cypress tests to look for missing descriptions
17
34
  export const getDescriptions = (rootNode: string): Cypress.Chainable => {
18
35
  cy.log('Starting analysis from GraphQL node: ' + rootNode);
19
- return execIntrospection(rootNode, [], []).then(descriptions => {
36
+ return execIntrospection(rootNode, [], [rootNode]).then(descriptions => {
20
37
  return descriptions;
21
38
  });
22
39
  };
@@ -36,7 +53,7 @@ const execIntrospection = (typeName: string, descriptions: GraphQLDescription[],
36
53
  if (responseDataType) {
37
54
  // This array will be populated with types identified in the introspection query
38
55
  // These will then be further introspected to get their children fields and args
39
- const fetchSubTypes: {typeName: string, atPath: string[]}[] = [];
56
+ let fetchSubTypes: {typeName: string, atPath: string[]}[] = [];
40
57
 
41
58
  descriptions.push({
42
59
  name: responseDataType.name,
@@ -50,15 +67,17 @@ const execIntrospection = (typeName: string, descriptions: GraphQLDescription[],
50
67
  // spec available at https://github.com/graphql/graphql-spec/blob/main/spec/Section%204%20--%20Introspection.md
51
68
  if (responseDataType.fields) {
52
69
  for (const graphqlField of responseDataType.fields) {
53
- const fieldPath = [...nodePath, responseDataType.name, graphqlField.name];
70
+ const fieldPath = [...nodePath, graphqlField.name];
54
71
  descriptions.push({
55
72
  name: graphqlField.name,
56
73
  description: graphqlField.description,
57
74
  schemaType: '__Field',
58
75
  schemaNode: graphqlField,
76
+ isDeprecated: graphqlField.isDeprecated,
77
+ deprecationReason: graphqlField.deprecationReason,
59
78
  nodePath: fieldPath
60
79
  });
61
- fetchSubTypes.push({typeName: graphqlField.type.name, atPath: fieldPath});
80
+ fetchSubTypes = [...fetchSubTypes, ...addTypes(graphqlField.type, fieldPath)];
62
81
 
63
82
  if (graphqlField.args) {
64
83
  for (const graphQLInputValue of graphqlField.args) {
@@ -68,9 +87,11 @@ const execIntrospection = (typeName: string, descriptions: GraphQLDescription[],
68
87
  description: graphQLInputValue.description,
69
88
  schemaType: '__InputValue',
70
89
  schemaNode: graphQLInputValue,
90
+ isDeprecated: graphQLInputValue.isDeprecated,
91
+ deprecationReason: graphQLInputValue.deprecationReason,
71
92
  nodePath: inputValuePath
72
93
  });
73
- fetchSubTypes.push({typeName: graphQLInputValue.type.name, atPath: inputValuePath});
94
+ fetchSubTypes = [...fetchSubTypes, ...addTypes(graphQLInputValue.type, inputValuePath)];
74
95
  }
75
96
  }
76
97
  }
@@ -78,15 +99,14 @@ const execIntrospection = (typeName: string, descriptions: GraphQLDescription[],
78
99
 
79
100
  if (responseDataType.interfaces) {
80
101
  for (const graphQLInterfaceType of responseDataType.interfaces) {
81
- const fieldPath = [...nodePath, responseDataType.name, graphQLInterfaceType.name];
82
102
  descriptions.push({
83
103
  name: graphQLInterfaceType.name,
84
104
  description: graphQLInterfaceType.description,
85
105
  schemaType: '__Type',
86
106
  schemaNode: graphQLInterfaceType,
87
- nodePath: fieldPath
107
+ nodePath
88
108
  });
89
- fetchSubTypes.push({typeName: graphQLInterfaceType.name, atPath: fieldPath});
109
+ fetchSubTypes = [...fetchSubTypes, ...addTypes(graphQLInterfaceType, nodePath)];
90
110
  }
91
111
  }
92
112
 
@@ -100,7 +120,7 @@ const execIntrospection = (typeName: string, descriptions: GraphQLDescription[],
100
120
  schemaNode: graphQLType,
101
121
  nodePath: fieldPath
102
122
  });
103
- fetchSubTypes.push({typeName: graphQLType.name, atPath: fieldPath});
123
+ fetchSubTypes = [...fetchSubTypes, ...addTypes(graphQLType, fieldPath)];
104
124
  }
105
125
  }
106
126
 
@@ -112,7 +132,9 @@ const execIntrospection = (typeName: string, descriptions: GraphQLDescription[],
112
132
  description: graphQLEnumValue.description,
113
133
  schemaType: '__EnumValue',
114
134
  schemaNode: graphQLEnumValue,
115
- nodePath: enumPath
135
+ nodePath: enumPath,
136
+ isDeprecated: graphQLEnumValue.isDeprecated,
137
+ deprecationReason: graphQLEnumValue.deprecationReason
116
138
  });
117
139
  }
118
140
  }
@@ -127,12 +149,12 @@ const execIntrospection = (typeName: string, descriptions: GraphQLDescription[],
127
149
  schemaNode: graphQLInputValue,
128
150
  nodePath: inputValuePath
129
151
  });
130
- fetchSubTypes.push({typeName: graphQLInputValue.type.name, atPath: inputValuePath});
152
+ fetchSubTypes = [...fetchSubTypes, ...addTypes(graphQLInputValue.type, inputValuePath)];
131
153
  }
132
154
  }
133
155
 
134
156
  if (responseDataType.ofType) {
135
- fetchSubTypes.push({typeName: responseDataType.ofType.name, atPath: nodePath});
157
+ fetchSubTypes = [...fetchSubTypes, ...addTypes(responseDataType.ofType, nodePath)];
136
158
  }
137
159
 
138
160
  const uniqueSubTypes = fetchSubTypes
@@ -143,6 +165,11 @@ const execIntrospection = (typeName: string, descriptions: GraphQLDescription[],
143
165
  // Remove types that might have already been introspected
144
166
  .filter(subtype => descriptions.find(d => d.schemaType === '__Type' && d.name === subtype.typeName) === undefined);
145
167
 
168
+ // If there are no subtypes to introspect, we still need to return the descriptions
169
+ if (uniqueSubTypes.length === 0) {
170
+ return descriptions;
171
+ }
172
+
146
173
  return Cypress.Promise.each(uniqueSubTypes, subType => {
147
174
  return execIntrospection(subType.typeName, descriptions, [...subType.atPath, subType.typeName]);
148
175
  }).then(() => descriptions); // Return descriptions after all recursive calls have completed