@salesforce/lds-luvio-onestore-graphql-parser 1.413.0 → 1.414.1
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/dist/main.js +102 -29
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -3072,20 +3072,37 @@ function operationKeyBuilder(inputString) {
|
|
|
3072
3072
|
return stripIgnoredCharacters(inputString);
|
|
3073
3073
|
}
|
|
3074
3074
|
function parseDocument(inputString) {
|
|
3075
|
+
var _a;
|
|
3075
3076
|
const operationKey = operationKeyBuilder(inputString);
|
|
3076
3077
|
const cachedDoc = docMap.get(operationKey);
|
|
3077
3078
|
if (cachedDoc !== void 0) {
|
|
3078
3079
|
return cachedDoc;
|
|
3079
3080
|
}
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3081
|
+
try {
|
|
3082
|
+
const parsedDoc = parse(inputString, { noLocation: true });
|
|
3083
|
+
const resolvedDoc = { type: "document", document: parsedDoc };
|
|
3084
|
+
docMap.set(operationKey, resolvedDoc);
|
|
3085
|
+
return resolvedDoc;
|
|
3086
|
+
} catch (e) {
|
|
3087
|
+
if (e instanceof GraphQLError) {
|
|
3088
|
+
const errorDoc = {
|
|
3089
|
+
errors: [
|
|
3090
|
+
{
|
|
3091
|
+
message: e.message || "Failed to parse GraphQL document",
|
|
3092
|
+
locations: (_a = e.locations) == null ? void 0 : _a.map((loc) => ({
|
|
3093
|
+
line: loc.line,
|
|
3094
|
+
column: loc.column
|
|
3095
|
+
})),
|
|
3096
|
+
extensions: e.extensions
|
|
3097
|
+
}
|
|
3098
|
+
]
|
|
3099
|
+
};
|
|
3100
|
+
const resolvedError = { type: "error", error: errorDoc };
|
|
3101
|
+
docMap.set(operationKey, resolvedError);
|
|
3102
|
+
return resolvedError;
|
|
3084
3103
|
}
|
|
3085
|
-
|
|
3104
|
+
throw e;
|
|
3086
3105
|
}
|
|
3087
|
-
docMap.set(operationKey, parsedDoc);
|
|
3088
|
-
return parsedDoc;
|
|
3089
3106
|
}
|
|
3090
3107
|
function insertFragments(doc, fragments) {
|
|
3091
3108
|
fragments.forEach((fragment) => {
|
|
@@ -3111,15 +3128,17 @@ function processSubstitutions(inputString, substitutions) {
|
|
|
3111
3128
|
if (typeof substitution === "string" || typeof substitution === "number") {
|
|
3112
3129
|
outputString += substitution;
|
|
3113
3130
|
} else if (typeof substitution === "object") {
|
|
3114
|
-
const
|
|
3115
|
-
if (
|
|
3131
|
+
const resolved = referenceMap.get(substitution);
|
|
3132
|
+
if (resolved === void 0) {
|
|
3116
3133
|
if (process.env.NODE_ENV !== "production") {
|
|
3117
3134
|
throw new Error("Invalid substitution fragment");
|
|
3118
3135
|
}
|
|
3119
3136
|
return null;
|
|
3120
3137
|
}
|
|
3121
|
-
|
|
3122
|
-
|
|
3138
|
+
if (resolved.type === "document") {
|
|
3139
|
+
for (const def of resolved.document.definitions) {
|
|
3140
|
+
fragments.push(def);
|
|
3141
|
+
}
|
|
3123
3142
|
}
|
|
3124
3143
|
} else {
|
|
3125
3144
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -3134,6 +3153,9 @@ function processSubstitutions(inputString, substitutions) {
|
|
|
3134
3153
|
};
|
|
3135
3154
|
}
|
|
3136
3155
|
const astResolver = function(astReference) {
|
|
3156
|
+
if (typeof astReference !== "object" || astReference === null) {
|
|
3157
|
+
return void 0;
|
|
3158
|
+
}
|
|
3137
3159
|
return referenceMap.get(astReference);
|
|
3138
3160
|
};
|
|
3139
3161
|
function gql(literals, ...subs) {
|
|
@@ -3166,11 +3188,47 @@ function gql(literals, ...subs) {
|
|
|
3166
3188
|
if (document === null) {
|
|
3167
3189
|
return null;
|
|
3168
3190
|
}
|
|
3169
|
-
if (
|
|
3191
|
+
if (document.type === "error") {
|
|
3170
3192
|
return updateReferenceMapAndGetKey(document);
|
|
3171
3193
|
}
|
|
3172
|
-
|
|
3194
|
+
const docNode = document.document;
|
|
3195
|
+
if (inputSubstitutionFragments.length === 0) {
|
|
3196
|
+
return updateReferenceMapAndGetKey({ type: "document", document: docNode });
|
|
3197
|
+
}
|
|
3198
|
+
return updateReferenceMapAndGetKey({
|
|
3199
|
+
type: "document",
|
|
3200
|
+
document: insertFragments(docNode, inputSubstitutionFragments)
|
|
3201
|
+
});
|
|
3202
|
+
}
|
|
3203
|
+
/*!
|
|
3204
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
3205
|
+
* All rights reserved.
|
|
3206
|
+
* For full license text, see the LICENSE.txt file
|
|
3207
|
+
*/
|
|
3208
|
+
class Ok {
|
|
3209
|
+
constructor(value) {
|
|
3210
|
+
this.value = value;
|
|
3211
|
+
}
|
|
3212
|
+
isOk() {
|
|
3213
|
+
return true;
|
|
3214
|
+
}
|
|
3215
|
+
isErr() {
|
|
3216
|
+
return !this.isOk();
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
class Err {
|
|
3220
|
+
constructor(error) {
|
|
3221
|
+
this.error = error;
|
|
3222
|
+
}
|
|
3223
|
+
isOk() {
|
|
3224
|
+
return false;
|
|
3225
|
+
}
|
|
3226
|
+
isErr() {
|
|
3227
|
+
return !this.isOk();
|
|
3228
|
+
}
|
|
3173
3229
|
}
|
|
3230
|
+
const ok = (value) => new Ok(value);
|
|
3231
|
+
const err = (err2) => new Err(err2);
|
|
3174
3232
|
function findExecutableOperation(document, operationName) {
|
|
3175
3233
|
const operations = document.definitions.filter(
|
|
3176
3234
|
(def) => def.kind === Kind.OPERATION_DEFINITION
|
|
@@ -3203,25 +3261,40 @@ function validateGraphQLOperations(config, options) {
|
|
|
3203
3261
|
}
|
|
3204
3262
|
function resolveAst(ast) {
|
|
3205
3263
|
if (ast === null || ast === void 0) {
|
|
3206
|
-
return;
|
|
3264
|
+
return void 0;
|
|
3207
3265
|
}
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3266
|
+
return astResolver(ast);
|
|
3267
|
+
}
|
|
3268
|
+
function resolveAndValidateGraphQLConfig(config, options) {
|
|
3269
|
+
const query = config.query;
|
|
3270
|
+
if (query === null || query === void 0) {
|
|
3271
|
+
return void 0;
|
|
3211
3272
|
}
|
|
3212
|
-
|
|
3273
|
+
const result = resolveAndValidateGraphQLDocument(query, config.operationName, options);
|
|
3274
|
+
if (result.isErr()) {
|
|
3275
|
+
return err(result.error);
|
|
3276
|
+
}
|
|
3277
|
+
return ok({
|
|
3278
|
+
...config,
|
|
3279
|
+
query: result.value
|
|
3280
|
+
});
|
|
3213
3281
|
}
|
|
3214
|
-
function
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
acceptedOperations: (options == null ? void 0 : options.acceptedOperations) ?? ["query"]
|
|
3222
|
-
});
|
|
3282
|
+
function resolveAndValidateGraphQLDocument(query, operationName, options) {
|
|
3283
|
+
const resolved = resolveAst(query);
|
|
3284
|
+
if (resolved === void 0) {
|
|
3285
|
+
throw new Error("Could not resolve AST. Did you parse the query with gql?");
|
|
3286
|
+
}
|
|
3287
|
+
if (resolved.type === "error") {
|
|
3288
|
+
return err(resolved.error);
|
|
3223
3289
|
}
|
|
3224
|
-
|
|
3290
|
+
const document = resolved.document;
|
|
3291
|
+
validateGraphQLOperations(
|
|
3292
|
+
{ query: document, operationName },
|
|
3293
|
+
{
|
|
3294
|
+
acceptedOperations: (options == null ? void 0 : options.acceptedOperations) ?? ["query"]
|
|
3295
|
+
}
|
|
3296
|
+
);
|
|
3297
|
+
return ok(document);
|
|
3225
3298
|
}
|
|
3226
3299
|
|
|
3227
|
-
export { Kind, astResolver, gql, parse, print,
|
|
3300
|
+
export { Kind, astResolver, gql, parse, print, resolveAndValidateGraphQLConfig, visit };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-luvio-onestore-graphql-parser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.414.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "Re-export of the @conduit-client/graphql package for use in adapters",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test:debug": "node --inspect-brk ../../node_modules/.bin/jest --runInBand"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@conduit-client/onestore-graphql-parser": "3.
|
|
31
|
+
"@conduit-client/onestore-graphql-parser": "3.9.0"
|
|
32
32
|
},
|
|
33
33
|
"nx": {
|
|
34
34
|
"targets": {
|