@graphql-mesh/utils 1.0.0-alpha-20230523155104-df277a22b → 1.0.0-alpha-20230523160518-5443a1139

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.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applyResultTransforms = exports.applyRequestTransforms = exports.applySchemaTransforms = void 0;
4
4
  function applySchemaTransforms(originalWrappingSchema, subschemaConfig, transformedSchema, transforms) {
5
- if (transforms?.length) {
5
+ if (transforms === null || transforms === void 0 ? void 0 : transforms.length) {
6
6
  return transforms.reduce((schema, transform) => 'transformSchema' in transform
7
7
  ? transform.transformSchema(schema, subschemaConfig)
8
8
  : schema, originalWrappingSchema);
@@ -13,7 +13,7 @@ exports.applySchemaTransforms = applySchemaTransforms;
13
13
  function applyRequestTransforms(originalRequest, delegationContext, transformationContext, transforms) {
14
14
  transformationContext.contextMap = transformationContext.contextMap || new WeakMap();
15
15
  const contextMap = transformationContext.contextMap;
16
- transforms?.forEach(transform => {
16
+ transforms === null || transforms === void 0 ? void 0 : transforms.forEach(transform => {
17
17
  if (!contextMap.has(transform)) {
18
18
  contextMap.set(transform, {
19
19
  nextIndex: 0,
@@ -42,7 +42,7 @@ function fileUriToPath(uri) {
42
42
  return host + path;
43
43
  }
44
44
  function fileURLToPath(url) {
45
- if (url?.startsWith('file://')) {
45
+ if (url === null || url === void 0 ? void 0 : url.startsWith('file://')) {
46
46
  return fileUriToPath(url);
47
47
  }
48
48
  return url || '';
@@ -4,7 +4,7 @@ exports.groupTransforms = void 0;
4
4
  function groupTransforms(transforms) {
5
5
  const wrapTransforms = [];
6
6
  const noWrapTransforms = [];
7
- transforms?.forEach(transform => {
7
+ transforms === null || transforms === void 0 ? void 0 : transforms.forEach(transform => {
8
8
  if (transform.noWrap) {
9
9
  noWrapTransforms.push(transform);
10
10
  }
@@ -18,7 +18,7 @@ async function tryImport(modulePath, cwd, importFn) {
18
18
  try {
19
19
  return await importFn(modulePath);
20
20
  }
21
- catch {
21
+ catch (_a) {
22
22
  if (!cross_helpers_1.path.isAbsolute(modulePath)) {
23
23
  const absoluteModulePath = cross_helpers_1.path.isAbsolute(modulePath)
24
24
  ? modulePath
package/cjs/logger.js CHANGED
@@ -41,7 +41,7 @@ class DefaultLogger {
41
41
  }
42
42
  return arg;
43
43
  }
44
- else if (typeof arg === 'object' && arg?.stack != null) {
44
+ else if (typeof arg === 'object' && (arg === null || arg === void 0 ? void 0 : arg.stack) != null) {
45
45
  return arg.stack;
46
46
  }
47
47
  return cross_helpers_1.util.inspect(arg);
@@ -104,12 +104,13 @@ async function readFile(fileExpression, { allowUnknownExtensions, cwd, fallbackF
104
104
  }
105
105
  exports.readFile = readFile;
106
106
  async function readUrl(path, config) {
107
+ var _a, _b;
107
108
  const { allowUnknownExtensions, fallbackFormat } = config || {};
108
109
  config.headers = config.headers || {};
109
110
  const response = await config.fetch(path, config);
110
- const contentType = response.headers?.get('content-type') || '';
111
+ const contentType = ((_a = response.headers) === null || _a === void 0 ? void 0 : _a.get('content-type')) || '';
111
112
  const responseText = await response.text();
112
- config?.logger?.debug(`${path} returned `, responseText);
113
+ (_b = config === null || config === void 0 ? void 0 : config.logger) === null || _b === void 0 ? void 0 : _b.debug(`${path} returned `, responseText);
113
114
  if (/json$/.test(path) ||
114
115
  contentType.startsWith('application/json') ||
115
116
  fallbackFormat === 'json') {
@@ -120,7 +121,7 @@ async function readUrl(path, config) {
120
121
  contentType.includes('yaml') ||
121
122
  contentType.includes('yml') ||
122
123
  fallbackFormat === 'yaml') {
123
- return loadYaml(path, responseText, config?.logger);
124
+ return loadYaml(path, responseText, config === null || config === void 0 ? void 0 : config.logger);
124
125
  }
125
126
  else if (!allowUnknownExtensions) {
126
127
  throw new Error(`Failed to parse JSON/YAML. Ensure URL '${path}' has ` +
@@ -28,7 +28,7 @@ function getTypeByPath(type, path) {
28
28
  return getTypeByPath(type, path.slice(1));
29
29
  }
30
30
  const field = fieldMap[currentFieldName];
31
- if (!field?.type) {
31
+ if (!(field === null || field === void 0 ? void 0 : field.type)) {
32
32
  throw new Error(`${type}.${currentFieldName} is not a valid field.`);
33
33
  }
34
34
  return getTypeByPath(field.type, path.slice(1));
@@ -54,7 +54,7 @@ function generateSelectionSetFactory(schema, additionalResolver) {
54
54
  const targetTypeFields = targetType.getFields();
55
55
  const targetField = targetTypeFields[additionalResolver.targetFieldName];
56
56
  const targetFieldType = (0, graphql_1.getNamedType)(targetField.type);
57
- abstractResultTypeName = targetFieldType?.name;
57
+ abstractResultTypeName = targetFieldType === null || targetFieldType === void 0 ? void 0 : targetFieldType.name;
58
58
  }
59
59
  if (abstractResultTypeName !== resultFieldType.name) {
60
60
  const abstractResultType = schema.getType(abstractResultTypeName);
@@ -43,7 +43,7 @@ function removeClosedBrackets(val) {
43
43
  for (;;) {
44
44
  // finds the first and shortest closed bracket match, starting from the left
45
45
  const match = out.match(/\(.+?\)/);
46
- const yesbrack = match?.[0];
46
+ const yesbrack = match === null || match === void 0 ? void 0 : match[0];
47
47
  if (!yesbrack) {
48
48
  break;
49
49
  }
@@ -1,5 +1,5 @@
1
1
  export function applySchemaTransforms(originalWrappingSchema, subschemaConfig, transformedSchema, transforms) {
2
- if (transforms?.length) {
2
+ if (transforms === null || transforms === void 0 ? void 0 : transforms.length) {
3
3
  return transforms.reduce((schema, transform) => 'transformSchema' in transform
4
4
  ? transform.transformSchema(schema, subschemaConfig)
5
5
  : schema, originalWrappingSchema);
@@ -9,7 +9,7 @@ export function applySchemaTransforms(originalWrappingSchema, subschemaConfig, t
9
9
  export function applyRequestTransforms(originalRequest, delegationContext, transformationContext, transforms) {
10
10
  transformationContext.contextMap = transformationContext.contextMap || new WeakMap();
11
11
  const contextMap = transformationContext.contextMap;
12
- transforms?.forEach(transform => {
12
+ transforms === null || transforms === void 0 ? void 0 : transforms.forEach(transform => {
13
13
  if (!contextMap.has(transform)) {
14
14
  contextMap.set(transform, {
15
15
  nextIndex: 0,
@@ -39,7 +39,7 @@ function fileUriToPath(uri) {
39
39
  return host + path;
40
40
  }
41
41
  export function fileURLToPath(url) {
42
- if (url?.startsWith('file://')) {
42
+ if (url === null || url === void 0 ? void 0 : url.startsWith('file://')) {
43
43
  return fileUriToPath(url);
44
44
  }
45
45
  return url || '';
@@ -1,7 +1,7 @@
1
1
  export function groupTransforms(transforms) {
2
2
  const wrapTransforms = [];
3
3
  const noWrapTransforms = [];
4
- transforms?.forEach(transform => {
4
+ transforms === null || transforms === void 0 ? void 0 : transforms.forEach(transform => {
5
5
  if (transform.noWrap) {
6
6
  noWrapTransforms.push(transform);
7
7
  }
@@ -14,7 +14,7 @@ async function tryImport(modulePath, cwd, importFn) {
14
14
  try {
15
15
  return await importFn(modulePath);
16
16
  }
17
- catch {
17
+ catch (_a) {
18
18
  if (!path.isAbsolute(modulePath)) {
19
19
  const absoluteModulePath = path.isAbsolute(modulePath)
20
20
  ? modulePath
package/esm/logger.js CHANGED
@@ -33,7 +33,7 @@ export class DefaultLogger {
33
33
  }
34
34
  return arg;
35
35
  }
36
- else if (typeof arg === 'object' && arg?.stack != null) {
36
+ else if (typeof arg === 'object' && (arg === null || arg === void 0 ? void 0 : arg.stack) != null) {
37
37
  return arg.stack;
38
38
  }
39
39
  return util.inspect(arg);
@@ -97,12 +97,13 @@ export async function readFile(fileExpression, { allowUnknownExtensions, cwd, fa
97
97
  return rawResult;
98
98
  }
99
99
  export async function readUrl(path, config) {
100
+ var _a, _b;
100
101
  const { allowUnknownExtensions, fallbackFormat } = config || {};
101
102
  config.headers = config.headers || {};
102
103
  const response = await config.fetch(path, config);
103
- const contentType = response.headers?.get('content-type') || '';
104
+ const contentType = ((_a = response.headers) === null || _a === void 0 ? void 0 : _a.get('content-type')) || '';
104
105
  const responseText = await response.text();
105
- config?.logger?.debug(`${path} returned `, responseText);
106
+ (_b = config === null || config === void 0 ? void 0 : config.logger) === null || _b === void 0 ? void 0 : _b.debug(`${path} returned `, responseText);
106
107
  if (/json$/.test(path) ||
107
108
  contentType.startsWith('application/json') ||
108
109
  fallbackFormat === 'json') {
@@ -113,7 +114,7 @@ export async function readUrl(path, config) {
113
114
  contentType.includes('yaml') ||
114
115
  contentType.includes('yml') ||
115
116
  fallbackFormat === 'yaml') {
116
- return loadYaml(path, responseText, config?.logger);
117
+ return loadYaml(path, responseText, config === null || config === void 0 ? void 0 : config.logger);
117
118
  }
118
119
  else if (!allowUnknownExtensions) {
119
120
  throw new Error(`Failed to parse JSON/YAML. Ensure URL '${path}' has ` +
@@ -24,7 +24,7 @@ function getTypeByPath(type, path) {
24
24
  return getTypeByPath(type, path.slice(1));
25
25
  }
26
26
  const field = fieldMap[currentFieldName];
27
- if (!field?.type) {
27
+ if (!(field === null || field === void 0 ? void 0 : field.type)) {
28
28
  throw new Error(`${type}.${currentFieldName} is not a valid field.`);
29
29
  }
30
30
  return getTypeByPath(field.type, path.slice(1));
@@ -50,7 +50,7 @@ function generateSelectionSetFactory(schema, additionalResolver) {
50
50
  const targetTypeFields = targetType.getFields();
51
51
  const targetField = targetTypeFields[additionalResolver.targetFieldName];
52
52
  const targetFieldType = getNamedType(targetField.type);
53
- abstractResultTypeName = targetFieldType?.name;
53
+ abstractResultTypeName = targetFieldType === null || targetFieldType === void 0 ? void 0 : targetFieldType.name;
54
54
  }
55
55
  if (abstractResultTypeName !== resultFieldType.name) {
56
56
  const abstractResultType = schema.getType(abstractResultTypeName);
@@ -40,7 +40,7 @@ export function removeClosedBrackets(val) {
40
40
  for (;;) {
41
41
  // finds the first and shortest closed bracket match, starting from the left
42
42
  const match = out.match(/\(.+?\)/);
43
- const yesbrack = match?.[0];
43
+ const yesbrack = match === null || match === void 0 ? void 0 : match[0];
44
44
  if (!yesbrack) {
45
45
  break;
46
46
  }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@graphql-mesh/utils",
3
- "version": "1.0.0-alpha-20230523155104-df277a22b",
3
+ "version": "1.0.0-alpha-20230523160518-5443a1139",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@graphql-mesh/cross-helpers": "0.4.0-alpha-20230523155104-df277a22b",
7
- "@graphql-mesh/types": "1.0.0-alpha-20230523155104-df277a22b",
6
+ "@graphql-mesh/cross-helpers": "0.4.0-alpha-20230523160518-5443a1139",
7
+ "@graphql-mesh/types": "1.0.0-alpha-20230523160518-5443a1139",
8
8
  "@graphql-tools/utils": "^9.2.1",
9
9
  "graphql": "*",
10
10
  "tslib": "^2.4.0"
11
11
  },
12
12
  "dependencies": {
13
- "@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523155104-df277a22b",
13
+ "@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523160518-5443a1139",
14
14
  "@graphql-tools/delegate": "^9.0.32",
15
15
  "dset": "^3.1.2",
16
16
  "js-yaml": "^4.1.0",
@@ -24,9 +24,6 @@
24
24
  "directory": "packages/utils"
25
25
  },
26
26
  "license": "MIT",
27
- "engines": {
28
- "node": ">=16.0.0"
29
- },
30
27
  "main": "cjs/index.js",
31
28
  "module": "esm/index.js",
32
29
  "typings": "typings/index.d.ts",