@executor-js/plugin-graphql 1.5.6 → 1.5.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.
- package/dist/{AddGraphqlSource-P3D3UXRJ.js → AddGraphqlSource-FGT7DNXV.js} +39 -64
- package/dist/AddGraphqlSource-FGT7DNXV.js.map +1 -0
- package/dist/{EditGraphqlSource-FVF67CTP.js → EditGraphqlSource-QELISUYT.js} +4 -4
- package/dist/GraphqlAccountsPanel-U62WSGHR.js +9 -0
- package/dist/api/group.d.ts +54 -21
- package/dist/api/handlers.d.ts +1 -1
- package/dist/api/index.d.ts +55 -22
- package/dist/{chunk-N5GJE7R6.js → chunk-732HGFSH.js} +57 -21
- package/dist/chunk-732HGFSH.js.map +1 -0
- package/dist/{chunk-2Y3J3CVO.js → chunk-HN5FB4DO.js} +35 -55
- package/dist/chunk-HN5FB4DO.js.map +1 -0
- package/dist/{chunk-VCYDSSIK.js → chunk-OGNJZCEF.js} +27 -28
- package/dist/chunk-OGNJZCEF.js.map +1 -0
- package/dist/{chunk-ADQTI2OK.js → chunk-OUZI3QNC.js} +119 -124
- package/dist/chunk-OUZI3QNC.js.map +1 -0
- package/dist/client.js +3 -3
- package/dist/core.js +124 -10
- package/dist/core.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/react/atoms.d.ts +83 -29
- package/dist/react/auth-method-config.d.ts +21 -8
- package/dist/react/client.d.ts +54 -21
- package/dist/react/defaults.d.ts +0 -11
- package/dist/sdk/index.d.ts +4 -1
- package/dist/sdk/introspection-blob-migration.d.ts +7 -0
- package/dist/sdk/migrate-config.d.ts +6 -0
- package/dist/sdk/plugin.d.ts +49 -22
- package/dist/sdk/store.d.ts +11 -1
- package/dist/sdk/types.d.ts +102 -47
- package/package.json +3 -3
- package/dist/AddGraphqlSource-P3D3UXRJ.js.map +0 -1
- package/dist/GraphqlAccountsPanel-GBNFHLFH.js +0 -9
- package/dist/chunk-2Y3J3CVO.js.map +0 -1
- package/dist/chunk-ADQTI2OK.js.map +0 -1
- package/dist/chunk-N5GJE7R6.js.map +0 -1
- package/dist/chunk-VCYDSSIK.js.map +0 -1
- /package/dist/{EditGraphqlSource-FVF67CTP.js.map → EditGraphqlSource-QELISUYT.js.map} +0 -0
- /package/dist/{GraphqlAccountsPanel-GBNFHLFH.js.map → GraphqlAccountsPanel-U62WSGHR.js.map} +0 -0
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
graphqlPresets
|
|
3
3
|
} from "./chunk-D6E4WAYW.js";
|
|
4
4
|
import {
|
|
5
|
-
AuthTemplate,
|
|
6
5
|
ExtractedField,
|
|
7
6
|
ExtractionResult,
|
|
8
7
|
GraphqlArgument,
|
|
8
|
+
GraphqlAuthMethodInput,
|
|
9
9
|
GraphqlAuthRequiredError,
|
|
10
10
|
GraphqlExtractionError,
|
|
11
11
|
GraphqlIntegrationConfig,
|
|
@@ -14,8 +14,10 @@ import {
|
|
|
14
14
|
InvocationResult,
|
|
15
15
|
OperationBinding,
|
|
16
16
|
decodeGraphqlIntegrationConfig,
|
|
17
|
-
decodeGraphqlIntegrationConfigOption
|
|
18
|
-
|
|
17
|
+
decodeGraphqlIntegrationConfigOption,
|
|
18
|
+
expandGraphqlAuthMethodInputs,
|
|
19
|
+
normalizeGraphqlAuthMethods
|
|
20
|
+
} from "./chunk-732HGFSH.js";
|
|
19
21
|
|
|
20
22
|
// src/sdk/introspect.ts
|
|
21
23
|
import { Effect, Option, Schema } from "effect";
|
|
@@ -563,7 +565,8 @@ var rowToOperation = (row) => {
|
|
|
563
565
|
binding: decodeBinding(operation.binding)
|
|
564
566
|
};
|
|
565
567
|
};
|
|
566
|
-
var
|
|
568
|
+
var introspectionBlobKey = (introspectionHash) => `introspection/${introspectionHash}`;
|
|
569
|
+
var makeDefaultGraphqlStore = ({ pluginStorage, blobs }) => {
|
|
567
570
|
const listOperationRows = (integration) => pluginStorage.list({
|
|
568
571
|
collection: OPERATION_COLLECTION,
|
|
569
572
|
keyPrefix: `${integration}.`
|
|
@@ -598,7 +601,11 @@ var makeDefaultGraphqlStore = ({ pluginStorage }) => {
|
|
|
598
601
|
listOperations: (integration) => listOperationRows(integration).pipe(
|
|
599
602
|
Effect4.map((rows) => rows.map(rowToOperation).filter(Predicate.isNotNull))
|
|
600
603
|
),
|
|
601
|
-
removeOperations
|
|
604
|
+
removeOperations,
|
|
605
|
+
putIntrospection: (introspectionHash, introspectionJson) => blobs.put(introspectionBlobKey(introspectionHash), introspectionJson, {
|
|
606
|
+
owner: CATALOG_OWNER
|
|
607
|
+
}),
|
|
608
|
+
getIntrospection: (introspectionHash) => blobs.get(introspectionBlobKey(introspectionHash))
|
|
602
609
|
};
|
|
603
610
|
};
|
|
604
611
|
|
|
@@ -611,9 +618,19 @@ import {
|
|
|
611
618
|
IntegrationAlreadyExistsError,
|
|
612
619
|
IntegrationDetectionResult,
|
|
613
620
|
IntegrationSlug,
|
|
621
|
+
mergeAuthTemplates,
|
|
622
|
+
sha256Hex,
|
|
614
623
|
ToolName,
|
|
615
624
|
ToolResult
|
|
616
625
|
} from "@executor-js/sdk/core";
|
|
626
|
+
import {
|
|
627
|
+
TOKEN_VARIABLE,
|
|
628
|
+
describeApiKeyAuthMethod,
|
|
629
|
+
describeNoneAuthMethod,
|
|
630
|
+
oauthBearerPlacement,
|
|
631
|
+
renderAuthPlacements,
|
|
632
|
+
requiredPlacementVariables
|
|
633
|
+
} from "@executor-js/sdk/http-auth";
|
|
617
634
|
var GraphqlErrorBody = Schema3.Struct({ message: Schema3.String });
|
|
618
635
|
var GraphqlErrorsBody = Schema3.Array(Schema3.Unknown);
|
|
619
636
|
var decodeGraphqlErrorBody = Schema3.decodeUnknownOption(GraphqlErrorBody);
|
|
@@ -621,7 +638,6 @@ var decodeGraphqlErrorsBody = Schema3.decodeUnknownOption(GraphqlErrorsBody);
|
|
|
621
638
|
var decodeGraphqlErrors = (errors) => Option5.getOrUndefined(decodeGraphqlErrorsBody(errors));
|
|
622
639
|
var extractGraphqlErrorMessage = (errors) => errors.map((error) => Option5.getOrUndefined(decodeGraphqlErrorBody(error))?.message).find((message) => message !== void 0 && message.length > 0);
|
|
623
640
|
var GRAPHQL_PLUGIN_ID = "graphql";
|
|
624
|
-
var AuthTemplateSchema = AuthTemplate;
|
|
625
641
|
var GraphqlAddIntegrationInputSchema = Schema3.Struct({
|
|
626
642
|
endpoint: Schema3.String,
|
|
627
643
|
slug: Schema3.optional(Schema3.String),
|
|
@@ -629,17 +645,17 @@ var GraphqlAddIntegrationInputSchema = Schema3.Struct({
|
|
|
629
645
|
introspectionJson: Schema3.optional(Schema3.String),
|
|
630
646
|
headers: Schema3.optional(Schema3.Record(Schema3.String, Schema3.String)),
|
|
631
647
|
queryParams: Schema3.optional(Schema3.Record(Schema3.String, Schema3.String)),
|
|
632
|
-
authenticationTemplate: Schema3.optional(Schema3.Array(
|
|
648
|
+
authenticationTemplate: Schema3.optional(Schema3.Array(GraphqlAuthMethodInput))
|
|
633
649
|
});
|
|
634
650
|
var GraphqlConfigureInputSchema = Schema3.Struct({
|
|
635
651
|
name: Schema3.optional(Schema3.String),
|
|
636
652
|
endpoint: Schema3.optional(Schema3.String),
|
|
637
653
|
headers: Schema3.optional(Schema3.Record(Schema3.String, Schema3.String)),
|
|
638
654
|
queryParams: Schema3.optional(Schema3.Record(Schema3.String, Schema3.String)),
|
|
639
|
-
authenticationTemplate: Schema3.optional(Schema3.Array(
|
|
655
|
+
authenticationTemplate: Schema3.optional(Schema3.Array(GraphqlAuthMethodInput))
|
|
640
656
|
});
|
|
641
657
|
var GraphqlConfigureAuthInputSchema = Schema3.Struct({
|
|
642
|
-
authenticationTemplate: Schema3.Array(
|
|
658
|
+
authenticationTemplate: Schema3.Array(GraphqlAuthMethodInput),
|
|
643
659
|
mode: Schema3.optional(Schema3.Literals(["merge", "replace"]))
|
|
644
660
|
});
|
|
645
661
|
var StaticAddIntegrationOutputSchema = Schema3.Struct({
|
|
@@ -790,17 +806,12 @@ var annotationsFor = (binding) => {
|
|
|
790
806
|
}
|
|
791
807
|
return {};
|
|
792
808
|
};
|
|
793
|
-
var
|
|
794
|
-
if (
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
return { headers: { [header]: `${prefix}${value}` }, queryParams: {} };
|
|
798
|
-
}
|
|
799
|
-
const rendered = template.prefix ? `${template.prefix}${value}` : value;
|
|
800
|
-
if (template.in === "query") {
|
|
801
|
-
return { headers: {}, queryParams: { [template.name]: rendered } };
|
|
809
|
+
var renderGraphqlAuthMethod = (method, values) => {
|
|
810
|
+
if (method.kind === "apikey") return renderAuthPlacements(method.placements, values);
|
|
811
|
+
if (method.kind === "oauth2") {
|
|
812
|
+
return renderAuthPlacements([oauthBearerPlacement(method.header, method.prefix)], values);
|
|
802
813
|
}
|
|
803
|
-
return { headers: {
|
|
814
|
+
return { headers: {}, queryParams: {} };
|
|
804
815
|
};
|
|
805
816
|
var buildToolDefs = (prepared) => prepared.map((p) => ({
|
|
806
817
|
name: ToolName.make(p.toolName),
|
|
@@ -813,24 +824,25 @@ var toStoredOperations = (slug, prepared) => prepared.map((p) => ({
|
|
|
813
824
|
integration: String(slug),
|
|
814
825
|
binding: p.binding
|
|
815
826
|
}));
|
|
816
|
-
var introspectHeadersForConnection = (config,
|
|
827
|
+
var introspectHeadersForConnection = (config, values, templateSlug) => {
|
|
817
828
|
const headers = { ...config.headers ?? {} };
|
|
818
829
|
const queryParams = { ...config.queryParams ?? {} };
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
830
|
+
const method = (templateSlug !== null ? config.authenticationTemplate.find(
|
|
831
|
+
(m) => m.slug === String(templateSlug)
|
|
832
|
+
) : void 0) ?? config.authenticationTemplate[0];
|
|
833
|
+
if (method) {
|
|
834
|
+
const rendered = renderGraphqlAuthMethod(method, values);
|
|
835
|
+
Object.assign(headers, rendered.headers);
|
|
836
|
+
Object.assign(queryParams, rendered.queryParams);
|
|
826
837
|
}
|
|
827
838
|
return { headers, queryParams };
|
|
828
839
|
};
|
|
829
|
-
var
|
|
830
|
-
|
|
831
|
-
|
|
840
|
+
var loadIntrospectionJson = (storage, config) => config.introspectionHash != null ? storage.getIntrospection(config.introspectionHash) : Effect5.succeed(null);
|
|
841
|
+
var introspectForConnection = (config, introspectionJson, values, templateSlug, httpClientLayer) => {
|
|
842
|
+
if (introspectionJson != null) {
|
|
843
|
+
return parseIntrospectionJson(introspectionJson);
|
|
832
844
|
}
|
|
833
|
-
const auth = introspectHeadersForConnection(config,
|
|
845
|
+
const auth = introspectHeadersForConnection(config, values, templateSlug);
|
|
834
846
|
return introspect(
|
|
835
847
|
config.endpoint,
|
|
836
848
|
Object.keys(auth.headers).length > 0 ? auth.headers : void 0,
|
|
@@ -838,19 +850,20 @@ var introspectForConnection = (config, credentialValue, httpClientLayer) => {
|
|
|
838
850
|
).pipe(Effect5.provide(httpClientLayer));
|
|
839
851
|
};
|
|
840
852
|
var materializeOperations = (ctx, integration, config, credential, httpClientLayer) => Effect5.gen(function* () {
|
|
841
|
-
const
|
|
842
|
-
(
|
|
853
|
+
const method = config.authenticationTemplate.find(
|
|
854
|
+
(m) => m.slug === String(credential.template)
|
|
843
855
|
);
|
|
844
856
|
const headers = { ...config.headers ?? {} };
|
|
845
857
|
const queryParams = {
|
|
846
858
|
...config.queryParams ?? {}
|
|
847
859
|
};
|
|
848
|
-
if (
|
|
849
|
-
const rendered =
|
|
860
|
+
if (method) {
|
|
861
|
+
const rendered = renderGraphqlAuthMethod(method, credential.values);
|
|
850
862
|
Object.assign(headers, rendered.headers);
|
|
851
863
|
Object.assign(queryParams, rendered.queryParams);
|
|
852
864
|
}
|
|
853
|
-
const
|
|
865
|
+
const introspectionJson = yield* loadIntrospectionJson(ctx.storage, config);
|
|
866
|
+
const introspection = introspectionJson != null ? yield* parseIntrospectionJson(introspectionJson) : yield* introspect(
|
|
854
867
|
config.endpoint,
|
|
855
868
|
Object.keys(headers).length > 0 ? headers : void 0,
|
|
856
869
|
Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
@@ -867,69 +880,34 @@ var materializeOperations = (ctx, integration, config, credential, httpClientLay
|
|
|
867
880
|
yield* ctx.storage.replaceOperations(integration, stored);
|
|
868
881
|
return stored;
|
|
869
882
|
});
|
|
870
|
-
var graphqlApiKeyLabel = (placement) => `API key (${placement.name || (placement.carrier === "header" ? "header" : "query")})`;
|
|
871
883
|
var describeGraphqlAuthMethods = (record) => {
|
|
872
884
|
const config = Option5.getOrUndefined(decodeGraphqlIntegrationConfigOption(record.config));
|
|
873
885
|
if (!config) return [];
|
|
874
|
-
return config.authenticationTemplate.map((
|
|
875
|
-
|
|
876
|
-
if (
|
|
886
|
+
return config.authenticationTemplate.map((method) => {
|
|
887
|
+
if (method.kind === "apikey") return describeApiKeyAuthMethod(method);
|
|
888
|
+
if (method.kind === "oauth2") {
|
|
877
889
|
return {
|
|
878
|
-
id: slug,
|
|
890
|
+
id: method.slug,
|
|
879
891
|
label: "OAuth",
|
|
880
892
|
kind: "oauth",
|
|
881
|
-
template: slug,
|
|
893
|
+
template: method.slug,
|
|
882
894
|
oauth: {}
|
|
883
895
|
};
|
|
884
896
|
}
|
|
885
|
-
|
|
886
|
-
carrier: template.in,
|
|
887
|
-
name: template.name,
|
|
888
|
-
prefix: template.prefix ?? ""
|
|
889
|
-
};
|
|
890
|
-
return {
|
|
891
|
-
id: slug,
|
|
892
|
-
label: graphqlApiKeyLabel(placement),
|
|
893
|
-
kind: "apikey",
|
|
894
|
-
template: slug,
|
|
895
|
-
placements: [placement]
|
|
896
|
-
};
|
|
897
|
+
return describeNoneAuthMethod(method.slug);
|
|
897
898
|
});
|
|
898
899
|
};
|
|
899
900
|
var describeGraphqlIntegrationDisplay = (record) => {
|
|
900
901
|
const config = Option5.getOrUndefined(decodeGraphqlIntegrationConfigOption(record.config));
|
|
901
902
|
return { url: config?.endpoint };
|
|
902
903
|
};
|
|
903
|
-
var shortId = () => Math.random().toString(36).slice(2, 8);
|
|
904
|
-
var freshCustomSlug = (taken) => {
|
|
905
|
-
let candidate = `custom_${shortId()}`;
|
|
906
|
-
while (taken.has(candidate)) candidate = `custom_${shortId()}`;
|
|
907
|
-
return candidate;
|
|
908
|
-
};
|
|
909
|
-
var mergeGraphqlAuthTemplate = (existing, incoming) => {
|
|
910
|
-
const result = existing.map((entry) => entry);
|
|
911
|
-
const taken = new Set(result.map((entry) => entry.slug));
|
|
912
|
-
for (const entry of incoming) {
|
|
913
|
-
const requested = entry.slug.trim();
|
|
914
|
-
const existingIndex = result.findIndex((current) => current.slug === requested);
|
|
915
|
-
if (requested.length > 0 && existingIndex >= 0) {
|
|
916
|
-
result[existingIndex] = entry;
|
|
917
|
-
continue;
|
|
918
|
-
}
|
|
919
|
-
const slug = requested.length > 0 && !taken.has(requested) ? requested : freshCustomSlug(taken);
|
|
920
|
-
taken.add(slug);
|
|
921
|
-
result.push({ ...entry, slug });
|
|
922
|
-
}
|
|
923
|
-
return result;
|
|
924
|
-
};
|
|
925
904
|
var makeGraphqlExtension = (ctx) => {
|
|
926
905
|
const buildConfig = (input) => GraphqlIntegrationConfig.make({
|
|
927
906
|
endpoint: input.endpoint,
|
|
928
907
|
name: input.name?.trim() || slugFromEndpoint(input.endpoint),
|
|
929
|
-
...input.introspectionJson !== void 0 ? { introspectionJson: input.introspectionJson } : {},
|
|
930
908
|
...input.headers !== void 0 ? { headers: input.headers } : {},
|
|
931
909
|
...input.queryParams !== void 0 ? { queryParams: input.queryParams } : {},
|
|
932
|
-
authenticationTemplate: input.authenticationTemplate
|
|
910
|
+
authenticationTemplate: input.authenticationTemplate ? normalizeGraphqlAuthMethods(input.authenticationTemplate) : []
|
|
933
911
|
});
|
|
934
912
|
const addIntegrationInternal = (input) => Effect5.gen(function* () {
|
|
935
913
|
const slug = IntegrationSlug.make(input.slug ?? slugFromEndpoint(input.endpoint));
|
|
@@ -939,41 +917,48 @@ var makeGraphqlExtension = (ctx) => {
|
|
|
939
917
|
}
|
|
940
918
|
return yield* addIntegrationTransaction(input, slug);
|
|
941
919
|
});
|
|
942
|
-
const addIntegrationTransaction = (input, slug) =>
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
920
|
+
const addIntegrationTransaction = (input, slug) => Effect5.gen(function* () {
|
|
921
|
+
const baseConfig = buildConfig(input);
|
|
922
|
+
if (input.introspectionJson === void 0) {
|
|
923
|
+
yield* ctx.transaction(
|
|
924
|
+
ctx.core.integrations.register({
|
|
947
925
|
slug,
|
|
948
926
|
description: baseConfig.name,
|
|
949
927
|
config: baseConfig,
|
|
950
928
|
canRemove: true,
|
|
951
929
|
canRefresh: true
|
|
930
|
+
})
|
|
931
|
+
);
|
|
932
|
+
return { slug: String(slug), name: baseConfig.name, toolCount: 0 };
|
|
933
|
+
}
|
|
934
|
+
const introspection = yield* parseIntrospectionJson(input.introspectionJson);
|
|
935
|
+
const { result } = yield* extract(introspection);
|
|
936
|
+
const prepared = prepareOperations(result.fields, introspection);
|
|
937
|
+
const snapshotJson = JSON.stringify({ data: introspection });
|
|
938
|
+
const introspectionHash = yield* sha256Hex(snapshotJson);
|
|
939
|
+
const config = GraphqlIntegrationConfig.make({
|
|
940
|
+
...baseConfig,
|
|
941
|
+
introspectionHash
|
|
942
|
+
});
|
|
943
|
+
yield* ctx.storage.putIntrospection(introspectionHash, snapshotJson);
|
|
944
|
+
yield* ctx.transaction(
|
|
945
|
+
Effect5.gen(function* () {
|
|
946
|
+
yield* ctx.storage.replaceOperations(String(slug), toStoredOperations(slug, prepared));
|
|
947
|
+
yield* ctx.core.integrations.register({
|
|
948
|
+
slug,
|
|
949
|
+
description: config.name,
|
|
950
|
+
config,
|
|
951
|
+
canRemove: true,
|
|
952
|
+
canRefresh: true
|
|
952
953
|
});
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
});
|
|
962
|
-
yield* ctx.storage.replaceOperations(String(slug), toStoredOperations(slug, prepared));
|
|
963
|
-
yield* ctx.core.integrations.register({
|
|
964
|
-
slug,
|
|
965
|
-
description: config.name,
|
|
966
|
-
config,
|
|
967
|
-
canRemove: true,
|
|
968
|
-
canRefresh: true
|
|
969
|
-
});
|
|
970
|
-
return {
|
|
971
|
-
slug: String(slug),
|
|
972
|
-
name: config.name,
|
|
973
|
-
toolCount: prepared.length
|
|
974
|
-
};
|
|
975
|
-
})
|
|
976
|
-
);
|
|
954
|
+
})
|
|
955
|
+
);
|
|
956
|
+
return {
|
|
957
|
+
slug: String(slug),
|
|
958
|
+
name: config.name,
|
|
959
|
+
toolCount: prepared.length
|
|
960
|
+
};
|
|
961
|
+
});
|
|
977
962
|
const configureIntegration = (slug, input) => Effect5.gen(function* () {
|
|
978
963
|
const record = yield* ctx.core.integrations.get(IntegrationSlug.make(slug));
|
|
979
964
|
if (!record) return;
|
|
@@ -990,10 +975,10 @@ var makeGraphqlExtension = (ctx) => {
|
|
|
990
975
|
const next = GraphqlIntegrationConfig.make({
|
|
991
976
|
endpoint: input.endpoint ?? current.endpoint,
|
|
992
977
|
name: input.name?.trim() || current.name,
|
|
993
|
-
...current.
|
|
978
|
+
...current.introspectionHash !== void 0 ? { introspectionHash: current.introspectionHash } : {},
|
|
994
979
|
...(input.headers ?? current.headers) !== void 0 ? { headers: input.headers ?? current.headers } : {},
|
|
995
980
|
...(input.queryParams ?? current.queryParams) !== void 0 ? { queryParams: input.queryParams ?? current.queryParams } : {},
|
|
996
|
-
authenticationTemplate: input.authenticationTemplate
|
|
981
|
+
authenticationTemplate: input.authenticationTemplate ? normalizeGraphqlAuthMethods(input.authenticationTemplate) : current.authenticationTemplate
|
|
997
982
|
});
|
|
998
983
|
yield* ctx.core.integrations.update(IntegrationSlug.make(slug), {
|
|
999
984
|
description: next.name,
|
|
@@ -1011,9 +996,11 @@ var makeGraphqlExtension = (ctx) => {
|
|
|
1011
996
|
if (!record) return [];
|
|
1012
997
|
const current = Option5.getOrNull(decodeGraphqlIntegrationConfigOption(record.config));
|
|
1013
998
|
if (!current) return [];
|
|
1014
|
-
const merged = input.mode === "replace" ? input.authenticationTemplate :
|
|
999
|
+
const merged = input.mode === "replace" ? normalizeGraphqlAuthMethods(input.authenticationTemplate) : mergeAuthTemplates(
|
|
1015
1000
|
current.authenticationTemplate,
|
|
1016
|
-
|
|
1001
|
+
expandGraphqlAuthMethodInputs(
|
|
1002
|
+
input.authenticationTemplate
|
|
1003
|
+
)
|
|
1017
1004
|
);
|
|
1018
1005
|
const next = GraphqlIntegrationConfig.make({
|
|
1019
1006
|
...current,
|
|
@@ -1124,15 +1111,22 @@ var graphqlPlugin = definePlugin((options) => {
|
|
|
1124
1111
|
// -----------------------------------------------------------------------
|
|
1125
1112
|
resolveTools: ({
|
|
1126
1113
|
config,
|
|
1127
|
-
|
|
1114
|
+
template,
|
|
1115
|
+
storage,
|
|
1116
|
+
getValues
|
|
1128
1117
|
}) => Effect5.gen(function* () {
|
|
1129
1118
|
const decoded = yield* decodeGraphqlIntegrationConfig(config).pipe(Effect5.option);
|
|
1130
1119
|
if (Option5.isNone(decoded)) return { tools: [] };
|
|
1131
1120
|
const graphqlConfig = decoded.value;
|
|
1132
|
-
const
|
|
1121
|
+
const introspectionJson = yield* loadIntrospectionJson(storage, graphqlConfig);
|
|
1122
|
+
const values = introspectionJson == null ? yield* getValues().pipe(
|
|
1123
|
+
Effect5.catch(() => Effect5.succeed({}))
|
|
1124
|
+
) : {};
|
|
1133
1125
|
const introspection = yield* introspectForConnection(
|
|
1134
1126
|
graphqlConfig,
|
|
1135
|
-
|
|
1127
|
+
introspectionJson,
|
|
1128
|
+
values,
|
|
1129
|
+
template,
|
|
1136
1130
|
options?.httpClientLayer ?? httpClientLayerFallback
|
|
1137
1131
|
).pipe(Effect5.option);
|
|
1138
1132
|
if (Option5.isNone(introspection)) return { tools: [] };
|
|
@@ -1181,23 +1175,24 @@ var graphqlPlugin = definePlugin((options) => {
|
|
|
1181
1175
|
const queryParams = {
|
|
1182
1176
|
...config.queryParams ?? {}
|
|
1183
1177
|
};
|
|
1184
|
-
const
|
|
1185
|
-
(
|
|
1178
|
+
const method = config.authenticationTemplate.find(
|
|
1179
|
+
(m) => m.slug === String(credential.template)
|
|
1186
1180
|
);
|
|
1187
|
-
if (
|
|
1188
|
-
|
|
1181
|
+
if (method && method.kind !== "none") {
|
|
1182
|
+
const missing = (method.kind === "oauth2" ? [TOKEN_VARIABLE] : requiredPlacementVariables(method.placements)).filter((variable) => credential.values[variable] == null);
|
|
1183
|
+
if (missing.length > 0) {
|
|
1189
1184
|
return yield* new GraphqlAuthRequiredError({
|
|
1190
|
-
code:
|
|
1191
|
-
message:
|
|
1185
|
+
code: method.kind === "oauth2" ? "oauth_connection_missing" : "connection_value_missing",
|
|
1186
|
+
message: method.kind === "oauth2" ? `Missing OAuth connection value for GraphQL integration "${integration}" (connection "${credential.connection}")` : `Missing credential value for GraphQL integration "${integration}" (connection "${credential.connection}") for input(s): ${missing.join(", ")}`,
|
|
1192
1187
|
owner: credential.owner,
|
|
1193
1188
|
integration,
|
|
1194
1189
|
connection: String(credential.connection),
|
|
1195
|
-
credentialKind:
|
|
1196
|
-
credentialLabel:
|
|
1190
|
+
credentialKind: method.kind === "oauth2" ? "oauth" : "secret",
|
|
1191
|
+
credentialLabel: method.kind === "oauth2" ? "OAuth sign-in" : "API key",
|
|
1197
1192
|
template: String(credential.template)
|
|
1198
1193
|
});
|
|
1199
1194
|
}
|
|
1200
|
-
const rendered =
|
|
1195
|
+
const rendered = renderGraphqlAuthMethod(method, credential.values);
|
|
1201
1196
|
Object.assign(headers, rendered.headers);
|
|
1202
1197
|
Object.assign(queryParams, rendered.queryParams);
|
|
1203
1198
|
}
|
|
@@ -1306,4 +1301,4 @@ export {
|
|
|
1306
1301
|
describeGraphqlAuthMethods,
|
|
1307
1302
|
graphqlPlugin
|
|
1308
1303
|
};
|
|
1309
|
-
//# sourceMappingURL=chunk-
|
|
1304
|
+
//# sourceMappingURL=chunk-OUZI3QNC.js.map
|