@executor-js/plugin-graphql 0.0.2 → 0.1.0
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/{chunk-ILBZO52O.js → chunk-EIC5WI6C.js} +242 -107
- package/dist/chunk-EIC5WI6C.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/client.d.ts +1 -334
- package/dist/react/plugin-client.d.ts +2 -0
- package/dist/react/source-plugin.d.ts +1 -1
- package/dist/sdk/plugin.d.ts +118 -2
- package/package.json +3 -3
- package/dist/chunk-ILBZO52O.js.map +0 -1
|
@@ -17,8 +17,80 @@ var GraphqlExtractionError = class extends Schema.TaggedErrorClass()(
|
|
|
17
17
|
var GraphqlInvocationError = class extends Data.TaggedError("GraphqlInvocationError") {
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
// src/sdk/types.ts
|
|
21
|
+
import { Effect, Schema as Schema2 } from "effect";
|
|
22
|
+
import { SecretBackedValue } from "@executor-js/sdk/core";
|
|
23
|
+
var GraphqlOperationKind = Schema2.Literals(["query", "mutation"]);
|
|
24
|
+
var GraphqlArgument = class extends Schema2.Class("GraphqlArgument")({
|
|
25
|
+
name: Schema2.String,
|
|
26
|
+
typeName: Schema2.String,
|
|
27
|
+
required: Schema2.Boolean,
|
|
28
|
+
description: Schema2.OptionFromOptional(Schema2.String)
|
|
29
|
+
}) {
|
|
30
|
+
};
|
|
31
|
+
var ExtractedField = class extends Schema2.Class("ExtractedField")({
|
|
32
|
+
/** e.g. "user", "createUser" */
|
|
33
|
+
fieldName: Schema2.String,
|
|
34
|
+
/** "query" or "mutation" */
|
|
35
|
+
kind: GraphqlOperationKind,
|
|
36
|
+
description: Schema2.OptionFromOptional(Schema2.String),
|
|
37
|
+
arguments: Schema2.Array(GraphqlArgument),
|
|
38
|
+
/** JSON Schema for the input (built from arguments) */
|
|
39
|
+
inputSchema: Schema2.OptionFromOptional(Schema2.Unknown),
|
|
40
|
+
/** The return type name for documentation */
|
|
41
|
+
returnTypeName: Schema2.String
|
|
42
|
+
}) {
|
|
43
|
+
};
|
|
44
|
+
var ExtractionResult = class extends Schema2.Class("ExtractionResult")({
|
|
45
|
+
/** Schema name from introspection */
|
|
46
|
+
schemaName: Schema2.OptionFromOptional(Schema2.String),
|
|
47
|
+
fields: Schema2.Array(ExtractedField)
|
|
48
|
+
}) {
|
|
49
|
+
};
|
|
50
|
+
var OperationBinding = class extends Schema2.Class("OperationBinding")({
|
|
51
|
+
kind: GraphqlOperationKind,
|
|
52
|
+
fieldName: Schema2.String,
|
|
53
|
+
/** The full GraphQL query/mutation string */
|
|
54
|
+
operationString: Schema2.String,
|
|
55
|
+
/** Ordered variable names for mapping */
|
|
56
|
+
variableNames: Schema2.Array(Schema2.String)
|
|
57
|
+
}) {
|
|
58
|
+
};
|
|
59
|
+
var HeaderValue = SecretBackedValue;
|
|
60
|
+
var QueryParamValue = HeaderValue;
|
|
61
|
+
var GraphqlSourceAuth = Schema2.Union(
|
|
62
|
+
[
|
|
63
|
+
Schema2.Struct({ kind: Schema2.Literal("none") }),
|
|
64
|
+
Schema2.Struct({
|
|
65
|
+
kind: Schema2.Literal("oauth2"),
|
|
66
|
+
connectionId: Schema2.String
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
);
|
|
70
|
+
var InvocationConfig = class extends Schema2.Class("InvocationConfig")({
|
|
71
|
+
/** The GraphQL endpoint URL */
|
|
72
|
+
endpoint: Schema2.String,
|
|
73
|
+
/** Headers applied to every request. Values can reference secrets. */
|
|
74
|
+
headers: Schema2.Record(Schema2.String, HeaderValue).pipe(
|
|
75
|
+
Schema2.withDecodingDefault(Effect.succeed({})),
|
|
76
|
+
Schema2.withConstructorDefault(Effect.succeed({}))
|
|
77
|
+
),
|
|
78
|
+
/** Query parameters applied to every request. Values can reference secrets. */
|
|
79
|
+
queryParams: Schema2.Record(Schema2.String, QueryParamValue).pipe(
|
|
80
|
+
Schema2.withDecodingDefault(Effect.succeed({})),
|
|
81
|
+
Schema2.withConstructorDefault(Effect.succeed({}))
|
|
82
|
+
)
|
|
83
|
+
}) {
|
|
84
|
+
};
|
|
85
|
+
var InvocationResult = class extends Schema2.Class("InvocationResult")({
|
|
86
|
+
status: Schema2.Number,
|
|
87
|
+
data: Schema2.NullOr(Schema2.Unknown),
|
|
88
|
+
errors: Schema2.NullOr(Schema2.Unknown)
|
|
89
|
+
}) {
|
|
90
|
+
};
|
|
91
|
+
|
|
20
92
|
// src/sdk/introspect.ts
|
|
21
|
-
import { Effect } from "effect";
|
|
93
|
+
import { Effect as Effect2 } from "effect";
|
|
22
94
|
import { HttpClient, HttpClientRequest } from "effect/unstable/http";
|
|
23
95
|
var INTROSPECTION_QUERY = `
|
|
24
96
|
query IntrospectionQuery {
|
|
@@ -89,7 +161,7 @@ var INTROSPECTION_QUERY = `
|
|
|
89
161
|
}
|
|
90
162
|
}
|
|
91
163
|
`;
|
|
92
|
-
var introspect =
|
|
164
|
+
var introspect = Effect2.fn("GraphQL.introspect")(function* (endpoint, headers, queryParams) {
|
|
93
165
|
const client = yield* HttpClient.HttpClient;
|
|
94
166
|
const requestEndpoint = queryParams && Object.keys(queryParams).length > 0 ? (() => {
|
|
95
167
|
const url = new URL(endpoint);
|
|
@@ -110,8 +182,8 @@ var introspect = Effect.fn("GraphQL.introspect")(function* (endpoint, headers, q
|
|
|
110
182
|
}
|
|
111
183
|
}
|
|
112
184
|
const response = yield* client.execute(request).pipe(
|
|
113
|
-
|
|
114
|
-
|
|
185
|
+
Effect2.tapCause((cause) => Effect2.logError("graphql introspection request failed", cause)),
|
|
186
|
+
Effect2.mapError(
|
|
115
187
|
(err) => new GraphqlIntrospectionError({
|
|
116
188
|
message: `Failed to reach GraphQL endpoint: ${err.message}`
|
|
117
189
|
})
|
|
@@ -123,10 +195,10 @@ var introspect = Effect.fn("GraphQL.introspect")(function* (endpoint, headers, q
|
|
|
123
195
|
});
|
|
124
196
|
}
|
|
125
197
|
const raw = yield* response.json.pipe(
|
|
126
|
-
|
|
127
|
-
(cause) =>
|
|
198
|
+
Effect2.tapCause(
|
|
199
|
+
(cause) => Effect2.logError("graphql introspection JSON parse failed", cause)
|
|
128
200
|
),
|
|
129
|
-
|
|
201
|
+
Effect2.mapError(
|
|
130
202
|
() => new GraphqlIntrospectionError({
|
|
131
203
|
message: `Failed to parse introspection response as JSON`
|
|
132
204
|
})
|
|
@@ -145,7 +217,7 @@ var introspect = Effect.fn("GraphQL.introspect")(function* (endpoint, headers, q
|
|
|
145
217
|
}
|
|
146
218
|
return json.data;
|
|
147
219
|
});
|
|
148
|
-
var parseIntrospectionJson = (text) =>
|
|
220
|
+
var parseIntrospectionJson = (text) => Effect2.try({
|
|
149
221
|
try: () => {
|
|
150
222
|
const parsed = JSON.parse(text);
|
|
151
223
|
const result = parsed.data ?? parsed;
|
|
@@ -159,78 +231,6 @@ var parseIntrospectionJson = (text) => Effect.try({
|
|
|
159
231
|
})
|
|
160
232
|
});
|
|
161
233
|
|
|
162
|
-
// src/sdk/types.ts
|
|
163
|
-
import { Effect as Effect2, Schema as Schema2 } from "effect";
|
|
164
|
-
import { SecretBackedValue } from "@executor-js/sdk/core";
|
|
165
|
-
var GraphqlOperationKind = Schema2.Literals(["query", "mutation"]);
|
|
166
|
-
var GraphqlArgument = class extends Schema2.Class("GraphqlArgument")({
|
|
167
|
-
name: Schema2.String,
|
|
168
|
-
typeName: Schema2.String,
|
|
169
|
-
required: Schema2.Boolean,
|
|
170
|
-
description: Schema2.OptionFromOptional(Schema2.String)
|
|
171
|
-
}) {
|
|
172
|
-
};
|
|
173
|
-
var ExtractedField = class extends Schema2.Class("ExtractedField")({
|
|
174
|
-
/** e.g. "user", "createUser" */
|
|
175
|
-
fieldName: Schema2.String,
|
|
176
|
-
/** "query" or "mutation" */
|
|
177
|
-
kind: GraphqlOperationKind,
|
|
178
|
-
description: Schema2.OptionFromOptional(Schema2.String),
|
|
179
|
-
arguments: Schema2.Array(GraphqlArgument),
|
|
180
|
-
/** JSON Schema for the input (built from arguments) */
|
|
181
|
-
inputSchema: Schema2.OptionFromOptional(Schema2.Unknown),
|
|
182
|
-
/** The return type name for documentation */
|
|
183
|
-
returnTypeName: Schema2.String
|
|
184
|
-
}) {
|
|
185
|
-
};
|
|
186
|
-
var ExtractionResult = class extends Schema2.Class("ExtractionResult")({
|
|
187
|
-
/** Schema name from introspection */
|
|
188
|
-
schemaName: Schema2.OptionFromOptional(Schema2.String),
|
|
189
|
-
fields: Schema2.Array(ExtractedField)
|
|
190
|
-
}) {
|
|
191
|
-
};
|
|
192
|
-
var OperationBinding = class extends Schema2.Class("OperationBinding")({
|
|
193
|
-
kind: GraphqlOperationKind,
|
|
194
|
-
fieldName: Schema2.String,
|
|
195
|
-
/** The full GraphQL query/mutation string */
|
|
196
|
-
operationString: Schema2.String,
|
|
197
|
-
/** Ordered variable names for mapping */
|
|
198
|
-
variableNames: Schema2.Array(Schema2.String)
|
|
199
|
-
}) {
|
|
200
|
-
};
|
|
201
|
-
var HeaderValue = SecretBackedValue;
|
|
202
|
-
var QueryParamValue = HeaderValue;
|
|
203
|
-
var GraphqlSourceAuth = Schema2.Union(
|
|
204
|
-
[
|
|
205
|
-
Schema2.Struct({ kind: Schema2.Literal("none") }),
|
|
206
|
-
Schema2.Struct({
|
|
207
|
-
kind: Schema2.Literal("oauth2"),
|
|
208
|
-
connectionId: Schema2.String
|
|
209
|
-
})
|
|
210
|
-
]
|
|
211
|
-
);
|
|
212
|
-
var InvocationConfig = class extends Schema2.Class("InvocationConfig")({
|
|
213
|
-
/** The GraphQL endpoint URL */
|
|
214
|
-
endpoint: Schema2.String,
|
|
215
|
-
/** Headers applied to every request. Values can reference secrets. */
|
|
216
|
-
headers: Schema2.Record(Schema2.String, HeaderValue).pipe(
|
|
217
|
-
Schema2.withDecodingDefault(Effect2.succeed({})),
|
|
218
|
-
Schema2.withConstructorDefault(Effect2.succeed({}))
|
|
219
|
-
),
|
|
220
|
-
/** Query parameters applied to every request. Values can reference secrets. */
|
|
221
|
-
queryParams: Schema2.Record(Schema2.String, QueryParamValue).pipe(
|
|
222
|
-
Schema2.withDecodingDefault(Effect2.succeed({})),
|
|
223
|
-
Schema2.withConstructorDefault(Effect2.succeed({}))
|
|
224
|
-
)
|
|
225
|
-
}) {
|
|
226
|
-
};
|
|
227
|
-
var InvocationResult = class extends Schema2.Class("InvocationResult")({
|
|
228
|
-
status: Schema2.Number,
|
|
229
|
-
data: Schema2.NullOr(Schema2.Unknown),
|
|
230
|
-
errors: Schema2.NullOr(Schema2.Unknown)
|
|
231
|
-
}) {
|
|
232
|
-
};
|
|
233
|
-
|
|
234
234
|
// src/sdk/extract.ts
|
|
235
235
|
import { Effect as Effect3, Option } from "effect";
|
|
236
236
|
var unwrapTypeName = (ref) => {
|
|
@@ -682,8 +682,139 @@ var makeDefaultGraphqlStore = ({
|
|
|
682
682
|
};
|
|
683
683
|
|
|
684
684
|
// src/sdk/plugin.ts
|
|
685
|
-
import { Effect as
|
|
685
|
+
import { Effect as Effect7, Option as Option3 } from "effect";
|
|
686
686
|
import { FetchHttpClient } from "effect/unstable/http";
|
|
687
|
+
|
|
688
|
+
// src/api/group.ts
|
|
689
|
+
import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
|
|
690
|
+
import { Schema as Schema3 } from "effect";
|
|
691
|
+
import { ScopeId } from "@executor-js/sdk/core";
|
|
692
|
+
import { InternalError } from "@executor-js/api";
|
|
693
|
+
var StoredSourceSchema = Schema3.Struct({
|
|
694
|
+
namespace: Schema3.String,
|
|
695
|
+
name: Schema3.String,
|
|
696
|
+
endpoint: Schema3.String,
|
|
697
|
+
headers: Schema3.Record(Schema3.String, HeaderValue),
|
|
698
|
+
queryParams: Schema3.Record(Schema3.String, HeaderValue),
|
|
699
|
+
auth: GraphqlSourceAuth
|
|
700
|
+
});
|
|
701
|
+
var ScopeParams = {
|
|
702
|
+
scopeId: ScopeId
|
|
703
|
+
};
|
|
704
|
+
var SourceParams = {
|
|
705
|
+
scopeId: ScopeId,
|
|
706
|
+
namespace: Schema3.String
|
|
707
|
+
};
|
|
708
|
+
var AddSourcePayload = Schema3.Struct({
|
|
709
|
+
endpoint: Schema3.String,
|
|
710
|
+
name: Schema3.optional(Schema3.String),
|
|
711
|
+
introspectionJson: Schema3.optional(Schema3.String),
|
|
712
|
+
namespace: Schema3.optional(Schema3.String),
|
|
713
|
+
headers: Schema3.optional(Schema3.Record(Schema3.String, Schema3.Unknown)),
|
|
714
|
+
queryParams: Schema3.optional(Schema3.Record(Schema3.String, Schema3.Unknown)),
|
|
715
|
+
auth: Schema3.optional(GraphqlSourceAuth)
|
|
716
|
+
});
|
|
717
|
+
var UpdateSourcePayload = Schema3.Struct({
|
|
718
|
+
name: Schema3.optional(Schema3.String),
|
|
719
|
+
endpoint: Schema3.optional(Schema3.String),
|
|
720
|
+
headers: Schema3.optional(Schema3.Record(Schema3.String, Schema3.Unknown)),
|
|
721
|
+
queryParams: Schema3.optional(Schema3.Record(Schema3.String, Schema3.Unknown)),
|
|
722
|
+
auth: Schema3.optional(GraphqlSourceAuth)
|
|
723
|
+
});
|
|
724
|
+
var UpdateSourceResponse = Schema3.Struct({
|
|
725
|
+
updated: Schema3.Boolean
|
|
726
|
+
});
|
|
727
|
+
var AddSourceResponse = Schema3.Struct({
|
|
728
|
+
toolCount: Schema3.Number,
|
|
729
|
+
namespace: Schema3.String
|
|
730
|
+
});
|
|
731
|
+
var IntrospectionError = GraphqlIntrospectionError.annotate(
|
|
732
|
+
{ httpApiStatus: 400 }
|
|
733
|
+
);
|
|
734
|
+
var ExtractionError = GraphqlExtractionError.annotate(
|
|
735
|
+
{ httpApiStatus: 400 }
|
|
736
|
+
);
|
|
737
|
+
var GraphqlErrors = [InternalError, IntrospectionError, ExtractionError];
|
|
738
|
+
var GraphqlGroup = HttpApiGroup.make("graphql").add(
|
|
739
|
+
HttpApiEndpoint.post("addSource", "/scopes/:scopeId/graphql/sources", {
|
|
740
|
+
params: ScopeParams,
|
|
741
|
+
payload: AddSourcePayload,
|
|
742
|
+
success: AddSourceResponse,
|
|
743
|
+
error: GraphqlErrors
|
|
744
|
+
})
|
|
745
|
+
).add(
|
|
746
|
+
HttpApiEndpoint.get("getSource", "/scopes/:scopeId/graphql/sources/:namespace", {
|
|
747
|
+
params: SourceParams,
|
|
748
|
+
success: Schema3.NullOr(StoredSourceSchema),
|
|
749
|
+
error: GraphqlErrors
|
|
750
|
+
})
|
|
751
|
+
).add(
|
|
752
|
+
HttpApiEndpoint.patch("updateSource", "/scopes/:scopeId/graphql/sources/:namespace", {
|
|
753
|
+
params: SourceParams,
|
|
754
|
+
payload: UpdateSourcePayload,
|
|
755
|
+
success: UpdateSourceResponse,
|
|
756
|
+
error: GraphqlErrors
|
|
757
|
+
})
|
|
758
|
+
);
|
|
759
|
+
|
|
760
|
+
// src/api/handlers.ts
|
|
761
|
+
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
762
|
+
import { Context, Effect as Effect6 } from "effect";
|
|
763
|
+
import { addGroup, capture } from "@executor-js/api";
|
|
764
|
+
var GraphqlExtensionService = class extends Context.Service()("GraphqlExtensionService") {
|
|
765
|
+
};
|
|
766
|
+
var ExecutorApiWithGraphql = addGroup(GraphqlGroup);
|
|
767
|
+
var GraphqlHandlers = HttpApiBuilder.group(
|
|
768
|
+
ExecutorApiWithGraphql,
|
|
769
|
+
"graphql",
|
|
770
|
+
(handlers) => handlers.handle(
|
|
771
|
+
"addSource",
|
|
772
|
+
({ params: path, payload }) => capture(
|
|
773
|
+
Effect6.gen(function* () {
|
|
774
|
+
const ext = yield* GraphqlExtensionService;
|
|
775
|
+
const result = yield* ext.addSource({
|
|
776
|
+
endpoint: payload.endpoint,
|
|
777
|
+
scope: path.scopeId,
|
|
778
|
+
name: payload.name,
|
|
779
|
+
introspectionJson: payload.introspectionJson,
|
|
780
|
+
namespace: payload.namespace,
|
|
781
|
+
headers: payload.headers,
|
|
782
|
+
queryParams: payload.queryParams,
|
|
783
|
+
auth: payload.auth
|
|
784
|
+
});
|
|
785
|
+
return {
|
|
786
|
+
toolCount: result.toolCount,
|
|
787
|
+
namespace: result.namespace
|
|
788
|
+
};
|
|
789
|
+
})
|
|
790
|
+
)
|
|
791
|
+
).handle(
|
|
792
|
+
"getSource",
|
|
793
|
+
({ params: path }) => capture(
|
|
794
|
+
Effect6.gen(function* () {
|
|
795
|
+
const ext = yield* GraphqlExtensionService;
|
|
796
|
+
return yield* ext.getSource(path.namespace, path.scopeId);
|
|
797
|
+
})
|
|
798
|
+
)
|
|
799
|
+
).handle(
|
|
800
|
+
"updateSource",
|
|
801
|
+
({ params: path, payload }) => capture(
|
|
802
|
+
Effect6.gen(function* () {
|
|
803
|
+
const ext = yield* GraphqlExtensionService;
|
|
804
|
+
yield* ext.updateSource(path.namespace, path.scopeId, {
|
|
805
|
+
name: payload.name,
|
|
806
|
+
endpoint: payload.endpoint,
|
|
807
|
+
headers: payload.headers,
|
|
808
|
+
queryParams: payload.queryParams,
|
|
809
|
+
auth: payload.auth
|
|
810
|
+
});
|
|
811
|
+
return { updated: true };
|
|
812
|
+
})
|
|
813
|
+
)
|
|
814
|
+
)
|
|
815
|
+
);
|
|
816
|
+
|
|
817
|
+
// src/sdk/plugin.ts
|
|
687
818
|
import {
|
|
688
819
|
definePlugin,
|
|
689
820
|
SourceDetectionResult
|
|
@@ -804,18 +935,19 @@ var graphqlPlugin = definePlugin((options) => {
|
|
|
804
935
|
const httpClientLayer = options?.httpClientLayer ?? FetchHttpClient.layer;
|
|
805
936
|
return {
|
|
806
937
|
id: "graphql",
|
|
938
|
+
packageName: "@executor-js/plugin-graphql",
|
|
807
939
|
schema: graphqlSchema,
|
|
808
940
|
storage: (deps) => makeDefaultGraphqlStore(deps),
|
|
809
941
|
extension: (ctx) => {
|
|
810
|
-
const resolveConfigValues = (values) =>
|
|
942
|
+
const resolveConfigValues = (values) => Effect7.gen(function* () {
|
|
811
943
|
if (!values) return void 0;
|
|
812
944
|
const resolved = yield* resolveHeaders(values, ctx.secrets);
|
|
813
945
|
return Object.keys(resolved).length > 0 ? resolved : void 0;
|
|
814
946
|
});
|
|
815
|
-
const resolveOAuthHeader = (auth) =>
|
|
947
|
+
const resolveOAuthHeader = (auth) => Effect7.gen(function* () {
|
|
816
948
|
if (!auth || auth.kind === "none") return void 0;
|
|
817
949
|
const accessToken = yield* ctx.connections.accessToken(auth.connectionId).pipe(
|
|
818
|
-
|
|
950
|
+
Effect7.mapError(
|
|
819
951
|
(err) => new GraphqlIntrospectionError({
|
|
820
952
|
message: `Failed to resolve OAuth connection "${auth.connectionId}": ${"message" in err ? err.message : String(err)}`
|
|
821
953
|
})
|
|
@@ -823,13 +955,13 @@ var graphqlPlugin = definePlugin((options) => {
|
|
|
823
955
|
);
|
|
824
956
|
return { Authorization: `Bearer ${accessToken}` };
|
|
825
957
|
});
|
|
826
|
-
const resolveRequestHeaders = (headers, auth) =>
|
|
958
|
+
const resolveRequestHeaders = (headers, auth) => Effect7.gen(function* () {
|
|
827
959
|
const resolvedHeaders = yield* resolveConfigValues(headers);
|
|
828
960
|
const oauthHeader = yield* resolveOAuthHeader(auth);
|
|
829
961
|
return { ...resolvedHeaders ?? {}, ...oauthHeader ?? {} };
|
|
830
962
|
});
|
|
831
963
|
const addSourceInternal = (config) => ctx.transaction(
|
|
832
|
-
|
|
964
|
+
Effect7.gen(function* () {
|
|
833
965
|
let introspectionResult;
|
|
834
966
|
if (config.introspectionJson) {
|
|
835
967
|
introspectionResult = yield* parseIntrospectionJson(
|
|
@@ -847,7 +979,7 @@ var graphqlPlugin = definePlugin((options) => {
|
|
|
847
979
|
config.endpoint,
|
|
848
980
|
Object.keys(resolvedHeaders).length > 0 ? resolvedHeaders : void 0,
|
|
849
981
|
resolvedQueryParams
|
|
850
|
-
).pipe(
|
|
982
|
+
).pipe(Effect7.provide(httpClientLayer));
|
|
851
983
|
}
|
|
852
984
|
const { result, definitions } = yield* extract(introspectionResult);
|
|
853
985
|
const namespace = config.namespace ?? namespaceFromEndpoint(config.endpoint);
|
|
@@ -899,15 +1031,15 @@ var graphqlPlugin = definePlugin((options) => {
|
|
|
899
1031
|
const configFile = options?.configFile;
|
|
900
1032
|
return {
|
|
901
1033
|
addSource: (config) => addSourceInternal(config).pipe(
|
|
902
|
-
|
|
1034
|
+
Effect7.tap(
|
|
903
1035
|
(result) => configFile ? configFile.upsertSource(
|
|
904
1036
|
toGraphqlConfigEntry(result.namespace, config)
|
|
905
|
-
) :
|
|
1037
|
+
) : Effect7.void
|
|
906
1038
|
)
|
|
907
1039
|
),
|
|
908
|
-
removeSource: (namespace, scope) =>
|
|
1040
|
+
removeSource: (namespace, scope) => Effect7.gen(function* () {
|
|
909
1041
|
yield* ctx.transaction(
|
|
910
|
-
|
|
1042
|
+
Effect7.gen(function* () {
|
|
911
1043
|
yield* ctx.storage.removeSource(namespace, scope);
|
|
912
1044
|
yield* ctx.core.sources.unregister(namespace);
|
|
913
1045
|
})
|
|
@@ -968,20 +1100,20 @@ var graphqlPlugin = definePlugin((options) => {
|
|
|
968
1100
|
]
|
|
969
1101
|
}
|
|
970
1102
|
],
|
|
971
|
-
invokeTool: ({ ctx, toolRow, args }) =>
|
|
1103
|
+
invokeTool: ({ ctx, toolRow, args }) => Effect7.gen(function* () {
|
|
972
1104
|
const toolScope = toolRow.scope_id;
|
|
973
1105
|
const op = yield* ctx.storage.getOperationByToolId(
|
|
974
1106
|
toolRow.id,
|
|
975
1107
|
toolScope
|
|
976
1108
|
);
|
|
977
1109
|
if (!op) {
|
|
978
|
-
return yield*
|
|
1110
|
+
return yield* Effect7.fail(
|
|
979
1111
|
new Error(`No GraphQL operation found for tool "${toolRow.id}"`)
|
|
980
1112
|
);
|
|
981
1113
|
}
|
|
982
1114
|
const source = yield* ctx.storage.getSource(op.sourceId, toolScope);
|
|
983
1115
|
if (!source) {
|
|
984
|
-
return yield*
|
|
1116
|
+
return yield* Effect7.fail(
|
|
985
1117
|
new Error(`No GraphQL source found for "${op.sourceId}"`)
|
|
986
1118
|
);
|
|
987
1119
|
}
|
|
@@ -1009,14 +1141,14 @@ var graphqlPlugin = definePlugin((options) => {
|
|
|
1009
1141
|
);
|
|
1010
1142
|
return result;
|
|
1011
1143
|
}),
|
|
1012
|
-
resolveAnnotations: ({ ctx, sourceId, toolRows }) =>
|
|
1144
|
+
resolveAnnotations: ({ ctx, sourceId, toolRows }) => Effect7.gen(function* () {
|
|
1013
1145
|
const scopes = /* @__PURE__ */ new Set();
|
|
1014
1146
|
for (const row of toolRows) {
|
|
1015
1147
|
scopes.add(row.scope_id);
|
|
1016
1148
|
}
|
|
1017
|
-
const entries = yield*
|
|
1149
|
+
const entries = yield* Effect7.forEach(
|
|
1018
1150
|
[...scopes],
|
|
1019
|
-
(scope) =>
|
|
1151
|
+
(scope) => Effect7.gen(function* () {
|
|
1020
1152
|
const ops = yield* ctx.storage.listOperationsBySource(
|
|
1021
1153
|
sourceId,
|
|
1022
1154
|
scope
|
|
@@ -1036,20 +1168,20 @@ var graphqlPlugin = definePlugin((options) => {
|
|
|
1036
1168
|
return out;
|
|
1037
1169
|
}),
|
|
1038
1170
|
removeSource: ({ ctx, sourceId, scope }) => ctx.storage.removeSource(sourceId, scope),
|
|
1039
|
-
detect: ({ url }) =>
|
|
1171
|
+
detect: ({ url }) => Effect7.gen(function* () {
|
|
1040
1172
|
const trimmed = url.trim();
|
|
1041
1173
|
if (!trimmed) return null;
|
|
1042
|
-
const parsed = yield*
|
|
1174
|
+
const parsed = yield* Effect7.try({
|
|
1043
1175
|
try: () => new URL(trimmed),
|
|
1044
1176
|
catch: (cause) => cause
|
|
1045
1177
|
}).pipe(
|
|
1046
|
-
|
|
1178
|
+
Effect7.option
|
|
1047
1179
|
);
|
|
1048
1180
|
if (Option3.isNone(parsed)) return null;
|
|
1049
1181
|
const ok = yield* introspect(trimmed).pipe(
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1182
|
+
Effect7.provide(httpClientLayer),
|
|
1183
|
+
Effect7.map(() => true),
|
|
1184
|
+
Effect7.catch(() => Effect7.succeed(false))
|
|
1053
1185
|
);
|
|
1054
1186
|
if (!ok) return null;
|
|
1055
1187
|
const name = namespaceFromEndpoint(trimmed);
|
|
@@ -1060,7 +1192,10 @@ var graphqlPlugin = definePlugin((options) => {
|
|
|
1060
1192
|
name,
|
|
1061
1193
|
namespace: name
|
|
1062
1194
|
});
|
|
1063
|
-
})
|
|
1195
|
+
}),
|
|
1196
|
+
routes: () => GraphqlGroup,
|
|
1197
|
+
handlers: () => GraphqlHandlers,
|
|
1198
|
+
extensionService: GraphqlExtensionService
|
|
1064
1199
|
};
|
|
1065
1200
|
});
|
|
1066
1201
|
|
|
@@ -1068,8 +1203,6 @@ export {
|
|
|
1068
1203
|
GraphqlIntrospectionError,
|
|
1069
1204
|
GraphqlExtractionError,
|
|
1070
1205
|
GraphqlInvocationError,
|
|
1071
|
-
introspect,
|
|
1072
|
-
parseIntrospectionJson,
|
|
1073
1206
|
GraphqlOperationKind,
|
|
1074
1207
|
GraphqlArgument,
|
|
1075
1208
|
ExtractedField,
|
|
@@ -1079,6 +1212,8 @@ export {
|
|
|
1079
1212
|
GraphqlSourceAuth,
|
|
1080
1213
|
InvocationConfig,
|
|
1081
1214
|
InvocationResult,
|
|
1215
|
+
introspect,
|
|
1216
|
+
parseIntrospectionJson,
|
|
1082
1217
|
extract,
|
|
1083
1218
|
resolveHeaders,
|
|
1084
1219
|
invoke,
|
|
@@ -1087,4 +1222,4 @@ export {
|
|
|
1087
1222
|
makeDefaultGraphqlStore,
|
|
1088
1223
|
graphqlPlugin
|
|
1089
1224
|
};
|
|
1090
|
-
//# sourceMappingURL=chunk-
|
|
1225
|
+
//# sourceMappingURL=chunk-EIC5WI6C.js.map
|