@executor-js/plugin-graphql 0.0.1-beta.5 → 0.0.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/README.md +2 -2
- package/dist/api/group.d.ts +17 -1
- package/dist/{chunk-QP62AGHJ.js → chunk-AC5VPNLE.js} +122 -102
- package/dist/chunk-AC5VPNLE.js.map +1 -0
- package/dist/core.js +44 -2
- package/dist/core.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/promise.d.ts +1 -1
- package/dist/sdk/config-file-store.d.ts +10 -0
- package/dist/sdk/index.d.ts +3 -2
- package/dist/sdk/invoke.d.ts +1 -1
- package/dist/sdk/kv-operation-store.d.ts +1 -1
- package/dist/sdk/operation-store.d.ts +7 -3
- package/dist/sdk/plugin.d.ts +13 -2
- package/dist/sdk/stored-source.d.ts +51 -0
- package/package.json +33 -31
- package/dist/chunk-QP62AGHJ.js.map +0 -1
package/README.md
CHANGED
|
@@ -56,10 +56,10 @@ await executor.graphql.addSource({
|
|
|
56
56
|
|
|
57
57
|
## Using with Effect
|
|
58
58
|
|
|
59
|
-
If you're building on `@executor/sdk
|
|
59
|
+
If you're building on `@executor/sdk` (the raw Effect entry), import this plugin from its `/core` subpath instead:
|
|
60
60
|
|
|
61
61
|
```ts
|
|
62
|
-
import { graphqlPlugin } from "@executor/plugin-graphql
|
|
62
|
+
import { graphqlPlugin } from "@executor/plugin-graphql";
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
## Status
|
package/dist/api/group.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { HttpApiEndpoint, HttpApiGroup } from "@effect/platform";
|
|
2
2
|
import { GraphqlIntrospectionError, GraphqlExtractionError } from "../sdk/errors";
|
|
3
|
+
import { StoredSourceSchema } from "../sdk/stored-source";
|
|
3
4
|
declare const GraphqlGroup_base: HttpApiGroup.HttpApiGroup<"graphql", HttpApiEndpoint.HttpApiEndpoint<"addSource", "POST", {
|
|
4
5
|
readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
|
|
5
6
|
}, never, {
|
|
7
|
+
readonly name?: string | undefined;
|
|
6
8
|
readonly endpoint: string;
|
|
7
9
|
readonly namespace?: string | undefined;
|
|
8
10
|
readonly headers?: {
|
|
@@ -12,7 +14,21 @@ declare const GraphqlGroup_base: HttpApiGroup.HttpApiGroup<"graphql", HttpApiEnd
|
|
|
12
14
|
}, never, {
|
|
13
15
|
readonly namespace: string;
|
|
14
16
|
readonly toolCount: number;
|
|
15
|
-
}, GraphqlIntrospectionError | GraphqlExtractionError, never, never
|
|
17
|
+
}, GraphqlIntrospectionError | GraphqlExtractionError, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getSource", "GET", {
|
|
18
|
+
readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
|
|
19
|
+
readonly namespace: string;
|
|
20
|
+
}, never, never, never, StoredSourceSchema | null, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"updateSource", "PATCH", {
|
|
21
|
+
readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
|
|
22
|
+
readonly namespace: string;
|
|
23
|
+
}, never, {
|
|
24
|
+
readonly name?: string | undefined;
|
|
25
|
+
readonly endpoint?: string | undefined;
|
|
26
|
+
readonly headers?: {
|
|
27
|
+
readonly [x: string]: unknown;
|
|
28
|
+
} | undefined;
|
|
29
|
+
}, never, {
|
|
30
|
+
readonly updated: boolean;
|
|
31
|
+
}, never, never, never>, never, never, false>;
|
|
16
32
|
export declare class GraphqlGroup extends GraphqlGroup_base {
|
|
17
33
|
}
|
|
18
34
|
export {};
|
|
@@ -14,9 +14,7 @@ var GraphqlExtractionError = class extends Schema.TaggedError()(
|
|
|
14
14
|
}
|
|
15
15
|
) {
|
|
16
16
|
};
|
|
17
|
-
var GraphqlInvocationError = class extends Data.TaggedError(
|
|
18
|
-
"GraphqlInvocationError"
|
|
19
|
-
) {
|
|
17
|
+
var GraphqlInvocationError = class extends Data.TaggedError("GraphqlInvocationError") {
|
|
20
18
|
};
|
|
21
19
|
|
|
22
20
|
// src/sdk/introspect.ts
|
|
@@ -105,9 +103,7 @@ var introspect = Effect.fn("GraphQL.introspect")(function* (endpoint, headers) {
|
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
105
|
const response = yield* client.execute(request).pipe(
|
|
108
|
-
Effect.tapErrorCause(
|
|
109
|
-
(cause) => Effect.logError("graphql introspection request failed", cause)
|
|
110
|
-
),
|
|
106
|
+
Effect.tapErrorCause((cause) => Effect.logError("graphql introspection request failed", cause)),
|
|
111
107
|
Effect.mapError(
|
|
112
108
|
(err) => new GraphqlIntrospectionError({
|
|
113
109
|
message: `Failed to reach GraphQL endpoint: ${err.message}`
|
|
@@ -159,18 +155,14 @@ var parseIntrospectionJson = (text) => Effect.try({
|
|
|
159
155
|
// src/sdk/types.ts
|
|
160
156
|
import { Schema as Schema2 } from "effect";
|
|
161
157
|
var GraphqlOperationKind = Schema2.Literal("query", "mutation");
|
|
162
|
-
var GraphqlArgument = class extends Schema2.Class(
|
|
163
|
-
"GraphqlArgument"
|
|
164
|
-
)({
|
|
158
|
+
var GraphqlArgument = class extends Schema2.Class("GraphqlArgument")({
|
|
165
159
|
name: Schema2.String,
|
|
166
160
|
typeName: Schema2.String,
|
|
167
161
|
required: Schema2.Boolean,
|
|
168
162
|
description: Schema2.optionalWith(Schema2.String, { as: "Option" })
|
|
169
163
|
}) {
|
|
170
164
|
};
|
|
171
|
-
var ExtractedField = class extends Schema2.Class(
|
|
172
|
-
"ExtractedField"
|
|
173
|
-
)({
|
|
165
|
+
var ExtractedField = class extends Schema2.Class("ExtractedField")({
|
|
174
166
|
/** e.g. "user", "createUser" */
|
|
175
167
|
fieldName: Schema2.String,
|
|
176
168
|
/** "query" or "mutation" */
|
|
@@ -183,17 +175,13 @@ var ExtractedField = class extends Schema2.Class(
|
|
|
183
175
|
returnTypeName: Schema2.String
|
|
184
176
|
}) {
|
|
185
177
|
};
|
|
186
|
-
var ExtractionResult = class extends Schema2.Class(
|
|
187
|
-
"ExtractionResult"
|
|
188
|
-
)({
|
|
178
|
+
var ExtractionResult = class extends Schema2.Class("ExtractionResult")({
|
|
189
179
|
/** Schema name from introspection */
|
|
190
180
|
schemaName: Schema2.optionalWith(Schema2.String, { as: "Option" }),
|
|
191
181
|
fields: Schema2.Array(ExtractedField)
|
|
192
182
|
}) {
|
|
193
183
|
};
|
|
194
|
-
var OperationBinding = class extends Schema2.Class(
|
|
195
|
-
"OperationBinding"
|
|
196
|
-
)({
|
|
184
|
+
var OperationBinding = class extends Schema2.Class("OperationBinding")({
|
|
197
185
|
kind: GraphqlOperationKind,
|
|
198
186
|
fieldName: Schema2.String,
|
|
199
187
|
/** The full GraphQL query/mutation string */
|
|
@@ -209,21 +197,16 @@ var HeaderValue = Schema2.Union(
|
|
|
209
197
|
prefix: Schema2.optional(Schema2.String)
|
|
210
198
|
})
|
|
211
199
|
);
|
|
212
|
-
var InvocationConfig = class extends Schema2.Class(
|
|
213
|
-
"InvocationConfig"
|
|
214
|
-
)({
|
|
200
|
+
var InvocationConfig = class extends Schema2.Class("InvocationConfig")({
|
|
215
201
|
/** The GraphQL endpoint URL */
|
|
216
202
|
endpoint: Schema2.String,
|
|
217
203
|
/** Headers applied to every request. Values can reference secrets. */
|
|
218
|
-
headers: Schema2.optionalWith(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
)
|
|
204
|
+
headers: Schema2.optionalWith(Schema2.Record({ key: Schema2.String, value: HeaderValue }), {
|
|
205
|
+
default: () => ({})
|
|
206
|
+
})
|
|
222
207
|
}) {
|
|
223
208
|
};
|
|
224
|
-
var InvocationResult = class extends Schema2.Class(
|
|
225
|
-
"InvocationResult"
|
|
226
|
-
)({
|
|
209
|
+
var InvocationResult = class extends Schema2.Class("InvocationResult")({
|
|
227
210
|
status: Schema2.Number,
|
|
228
211
|
data: Schema2.NullOr(Schema2.Unknown),
|
|
229
212
|
errors: Schema2.NullOr(Schema2.Unknown)
|
|
@@ -371,18 +354,8 @@ var extract = (introspection) => Effect2.try({
|
|
|
371
354
|
typeMap.set(t.name, t);
|
|
372
355
|
}
|
|
373
356
|
const definitions = buildDefinitions(typeMap);
|
|
374
|
-
const queryFields = extractFields(
|
|
375
|
-
|
|
376
|
-
"query",
|
|
377
|
-
schema.queryType?.name,
|
|
378
|
-
typeMap
|
|
379
|
-
);
|
|
380
|
-
const mutationFields = extractFields(
|
|
381
|
-
schema,
|
|
382
|
-
"mutation",
|
|
383
|
-
schema.mutationType?.name,
|
|
384
|
-
typeMap
|
|
385
|
-
);
|
|
357
|
+
const queryFields = extractFields(schema, "query", schema.queryType?.name, typeMap);
|
|
358
|
+
const mutationFields = extractFields(schema, "mutation", schema.mutationType?.name, typeMap);
|
|
386
359
|
return {
|
|
387
360
|
result: new ExtractionResult({
|
|
388
361
|
schemaName: Option.none(),
|
|
@@ -402,7 +375,7 @@ import { HttpClient as HttpClient2, HttpClientRequest as HttpClientRequest2 } fr
|
|
|
402
375
|
import {
|
|
403
376
|
ToolInvocationResult,
|
|
404
377
|
ToolInvocationError
|
|
405
|
-
} from "@executor-js/sdk
|
|
378
|
+
} from "@executor-js/sdk";
|
|
406
379
|
var resolveHeaders = (headers, secrets, scopeId) => Effect3.gen(function* () {
|
|
407
380
|
const resolved = {};
|
|
408
381
|
for (const [name, value] of Object.entries(headers)) {
|
|
@@ -492,12 +465,17 @@ var makeGraphqlInvoker = (opts) => ({
|
|
|
492
465
|
cause: void 0
|
|
493
466
|
});
|
|
494
467
|
}
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
468
|
+
const source = yield* opts.operationStore.getSource(entry.namespace);
|
|
469
|
+
if (!source) {
|
|
470
|
+
return yield* new ToolInvocationError({
|
|
471
|
+
toolId,
|
|
472
|
+
message: `No source found for namespace "${entry.namespace}"`,
|
|
473
|
+
cause: void 0
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
const { binding } = entry;
|
|
477
|
+
const { invocationConfig: config } = source;
|
|
478
|
+
const resolvedHeaders = yield* resolveHeaders(config.headers, opts.secrets, opts.scopeId);
|
|
501
479
|
const result = yield* invoke(
|
|
502
480
|
binding,
|
|
503
481
|
args ?? {},
|
|
@@ -526,42 +504,55 @@ var makeGraphqlInvoker = (opts) => ({
|
|
|
526
504
|
});
|
|
527
505
|
|
|
528
506
|
// src/sdk/kv-operation-store.ts
|
|
529
|
-
import { Effect as Effect4, Schema as
|
|
530
|
-
import { scopeKv, makeInMemoryScopedKv } from "@executor-js/sdk
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}) {
|
|
536
|
-
};
|
|
537
|
-
var encodeEntry = Schema3.encodeSync(Schema3.parseJson(StoredEntry));
|
|
538
|
-
var decodeEntry = Schema3.decodeUnknownSync(Schema3.parseJson(StoredEntry));
|
|
539
|
-
var StoredSourceSchema = Schema3.Struct({
|
|
507
|
+
import { Effect as Effect4, Schema as Schema4 } from "effect";
|
|
508
|
+
import { scopeKv, makeInMemoryScopedKv } from "@executor-js/sdk";
|
|
509
|
+
|
|
510
|
+
// src/sdk/stored-source.ts
|
|
511
|
+
import { Schema as Schema3 } from "effect";
|
|
512
|
+
var StoredSourceSchema = class extends Schema3.Class("GraphqlStoredSource")({
|
|
540
513
|
namespace: Schema3.String,
|
|
541
514
|
name: Schema3.String,
|
|
542
515
|
config: Schema3.Struct({
|
|
543
516
|
endpoint: Schema3.String,
|
|
544
517
|
introspectionJson: Schema3.optional(Schema3.String),
|
|
545
518
|
namespace: Schema3.optional(Schema3.String),
|
|
546
|
-
headers: Schema3.optional(
|
|
547
|
-
|
|
548
|
-
|
|
519
|
+
headers: Schema3.optional(Schema3.Record({ key: Schema3.String, value: HeaderValue }))
|
|
520
|
+
}),
|
|
521
|
+
// TODO(migration): make required once all rows have been migrated to
|
|
522
|
+
// carry invocationConfig. Left optional for decode compat with rows
|
|
523
|
+
// written before the source-level invocationConfig refactor.
|
|
524
|
+
invocationConfig: Schema3.optional(InvocationConfig)
|
|
525
|
+
}) {
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
// src/sdk/kv-operation-store.ts
|
|
529
|
+
var StoredEntry = class extends Schema4.Class("StoredEntry")({
|
|
530
|
+
namespace: Schema4.String,
|
|
531
|
+
binding: OperationBinding
|
|
532
|
+
}) {
|
|
533
|
+
};
|
|
534
|
+
var encodeEntry = Schema4.encodeSync(Schema4.parseJson(StoredEntry));
|
|
535
|
+
var decodeEntry = Schema4.decodeUnknownSync(Schema4.parseJson(StoredEntry));
|
|
536
|
+
var encodeSource = Schema4.encodeSync(Schema4.parseJson(StoredSourceSchema));
|
|
537
|
+
var decodeSource = Schema4.decodeUnknownSync(Schema4.parseJson(StoredSourceSchema));
|
|
538
|
+
var rehydrate = (source) => source.invocationConfig ? source : {
|
|
539
|
+
...source,
|
|
540
|
+
invocationConfig: new InvocationConfig({
|
|
541
|
+
endpoint: source.config.endpoint,
|
|
542
|
+
headers: source.config.headers ?? {}
|
|
549
543
|
})
|
|
550
|
-
}
|
|
551
|
-
var encodeSource = Schema3.encodeSync(Schema3.parseJson(StoredSourceSchema));
|
|
552
|
-
var decodeSource = Schema3.decodeUnknownSync(Schema3.parseJson(StoredSourceSchema));
|
|
544
|
+
};
|
|
553
545
|
var makeStore = (bindings, sources) => ({
|
|
554
546
|
get: (toolId) => Effect4.gen(function* () {
|
|
555
547
|
const raw = yield* bindings.get(toolId);
|
|
556
548
|
if (!raw) return null;
|
|
557
549
|
const entry = decodeEntry(raw);
|
|
558
|
-
return { binding: entry.binding,
|
|
550
|
+
return { binding: entry.binding, namespace: entry.namespace };
|
|
559
551
|
}),
|
|
560
|
-
put: (toolId, namespace, binding
|
|
561
|
-
toolId,
|
|
562
|
-
|
|
563
|
-
),
|
|
564
|
-
remove: (toolId) => bindings.delete(toolId).pipe(Effect4.asVoid),
|
|
552
|
+
put: (toolId, namespace, binding) => bindings.set([
|
|
553
|
+
{ key: toolId, value: encodeEntry(new StoredEntry({ namespace, binding })) }
|
|
554
|
+
]),
|
|
555
|
+
remove: (toolId) => bindings.delete([toolId]).pipe(Effect4.asVoid),
|
|
565
556
|
listByNamespace: (namespace) => Effect4.gen(function* () {
|
|
566
557
|
const entries = yield* bindings.list();
|
|
567
558
|
const ids = [];
|
|
@@ -576,31 +567,38 @@ var makeStore = (bindings, sources) => ({
|
|
|
576
567
|
const ids = [];
|
|
577
568
|
for (const e of entries) {
|
|
578
569
|
const entry = decodeEntry(e.value);
|
|
579
|
-
if (entry.namespace === namespace)
|
|
580
|
-
ids.push(e.key);
|
|
581
|
-
yield* bindings.delete(e.key);
|
|
582
|
-
}
|
|
570
|
+
if (entry.namespace === namespace) ids.push(e.key);
|
|
583
571
|
}
|
|
572
|
+
if (ids.length > 0) yield* bindings.delete(ids);
|
|
584
573
|
return ids;
|
|
585
574
|
}),
|
|
586
|
-
putSource: (source) => sources.set(source.namespace, encodeSource(source)),
|
|
587
|
-
removeSource: (namespace) => sources.delete(namespace).pipe(Effect4.asVoid),
|
|
575
|
+
putSource: (source) => sources.set([{ key: source.namespace, value: encodeSource(source) }]),
|
|
576
|
+
removeSource: (namespace) => sources.delete([namespace]).pipe(Effect4.asVoid),
|
|
588
577
|
listSources: () => Effect4.gen(function* () {
|
|
589
578
|
const entries = yield* sources.list();
|
|
590
|
-
return entries.map((e) => decodeSource(e.value));
|
|
579
|
+
return entries.map((e) => rehydrate(decodeSource(e.value)));
|
|
580
|
+
}),
|
|
581
|
+
getSource: (namespace) => Effect4.gen(function* () {
|
|
582
|
+
const raw = yield* sources.get(namespace);
|
|
583
|
+
if (!raw) return null;
|
|
584
|
+
const source = decodeSource(raw);
|
|
585
|
+
if (source.invocationConfig) return source;
|
|
586
|
+
const healed = rehydrate(source);
|
|
587
|
+
yield* sources.set([{ key: namespace, value: encodeSource(healed) }]);
|
|
588
|
+
return healed;
|
|
589
|
+
}),
|
|
590
|
+
getSourceConfig: (namespace) => Effect4.gen(function* () {
|
|
591
|
+
const raw = yield* sources.get(namespace);
|
|
592
|
+
if (!raw) return null;
|
|
593
|
+
const source = decodeSource(raw);
|
|
594
|
+
return source.config;
|
|
591
595
|
})
|
|
592
596
|
});
|
|
593
|
-
var makeKvOperationStore = (kv, namespace) => makeStore(
|
|
594
|
-
|
|
595
|
-
scopeKv(kv, `${namespace}.sources`)
|
|
596
|
-
);
|
|
597
|
-
var makeInMemoryOperationStore = () => makeStore(
|
|
598
|
-
makeInMemoryScopedKv(),
|
|
599
|
-
makeInMemoryScopedKv()
|
|
600
|
-
);
|
|
597
|
+
var makeKvOperationStore = (kv, namespace) => makeStore(scopeKv(kv, `${namespace}.bindings`), scopeKv(kv, `${namespace}.sources`));
|
|
598
|
+
var makeInMemoryOperationStore = () => makeStore(makeInMemoryScopedKv(), makeInMemoryScopedKv());
|
|
601
599
|
|
|
602
600
|
// src/sdk/plugin.ts
|
|
603
|
-
import { Effect as Effect5, Option as Option3, Schema as
|
|
601
|
+
import { Effect as Effect5, Option as Option3, Schema as Schema5 } from "effect";
|
|
604
602
|
import { FetchHttpClient } from "@effect/platform";
|
|
605
603
|
import {
|
|
606
604
|
Source,
|
|
@@ -609,18 +607,17 @@ import {
|
|
|
609
607
|
registerRuntimeTools,
|
|
610
608
|
runtimeTool,
|
|
611
609
|
ToolId
|
|
612
|
-
} from "@executor-js/sdk
|
|
613
|
-
var AddSourceInputSchema =
|
|
614
|
-
endpoint:
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
)
|
|
610
|
+
} from "@executor-js/sdk";
|
|
611
|
+
var AddSourceInputSchema = Schema5.Struct({
|
|
612
|
+
endpoint: Schema5.String,
|
|
613
|
+
name: Schema5.optional(Schema5.String),
|
|
614
|
+
introspectionJson: Schema5.optional(Schema5.String),
|
|
615
|
+
namespace: Schema5.optional(Schema5.String),
|
|
616
|
+
headers: Schema5.optional(Schema5.Record({ key: Schema5.String, value: HeaderValue }))
|
|
620
617
|
});
|
|
621
|
-
var AddSourceOutputSchema =
|
|
622
|
-
sourceId:
|
|
623
|
-
toolCount:
|
|
618
|
+
var AddSourceOutputSchema = Schema5.Struct({
|
|
619
|
+
sourceId: Schema5.String,
|
|
620
|
+
toolCount: Schema5.Number
|
|
624
621
|
});
|
|
625
622
|
var namespaceFromEndpoint = (endpoint) => {
|
|
626
623
|
try {
|
|
@@ -714,9 +711,11 @@ var graphqlPlugin = (options) => {
|
|
|
714
711
|
id: s.namespace,
|
|
715
712
|
name: s.name,
|
|
716
713
|
kind: "graphql",
|
|
714
|
+
url: s.config.endpoint,
|
|
717
715
|
runtime: false,
|
|
718
716
|
canRemove: true,
|
|
719
|
-
canRefresh: false
|
|
717
|
+
canRefresh: false,
|
|
718
|
+
canEdit: true
|
|
720
719
|
})
|
|
721
720
|
)
|
|
722
721
|
)
|
|
@@ -811,20 +810,21 @@ var graphqlPlugin = (options) => {
|
|
|
811
810
|
operationString,
|
|
812
811
|
variableNames: extractedField.arguments.map((a) => a.name)
|
|
813
812
|
});
|
|
814
|
-
return operationStore.put(reg.id, namespace, binding
|
|
813
|
+
return operationStore.put(reg.id, namespace, binding);
|
|
815
814
|
},
|
|
816
815
|
{ discard: true }
|
|
817
816
|
);
|
|
818
817
|
yield* ctx.tools.register(registrations);
|
|
819
818
|
yield* operationStore.putSource({
|
|
820
819
|
namespace,
|
|
821
|
-
name: namespace,
|
|
820
|
+
name: config.name?.trim() || namespace,
|
|
822
821
|
config: {
|
|
823
822
|
endpoint: config.endpoint,
|
|
824
823
|
introspectionJson: config.introspectionJson,
|
|
825
824
|
namespace: config.namespace,
|
|
826
825
|
headers: config.headers
|
|
827
|
-
}
|
|
826
|
+
},
|
|
827
|
+
invocationConfig
|
|
828
828
|
});
|
|
829
829
|
return { sourceId: namespace, toolCount: registrations.length };
|
|
830
830
|
});
|
|
@@ -864,6 +864,26 @@ var graphqlPlugin = (options) => {
|
|
|
864
864
|
yield* ctx.tools.unregister(toolIds);
|
|
865
865
|
}
|
|
866
866
|
yield* operationStore.removeSource(namespace);
|
|
867
|
+
}),
|
|
868
|
+
getSource: (namespace) => operationStore.getSource(namespace),
|
|
869
|
+
updateSource: (namespace, input) => Effect5.gen(function* () {
|
|
870
|
+
const existing = yield* operationStore.getSource(namespace);
|
|
871
|
+
if (!existing) return;
|
|
872
|
+
const updatedConfig = {
|
|
873
|
+
...existing.config,
|
|
874
|
+
...input.endpoint !== void 0 ? { endpoint: input.endpoint } : {},
|
|
875
|
+
...input.headers !== void 0 ? { headers: input.headers } : {}
|
|
876
|
+
};
|
|
877
|
+
const newInvocationConfig = new InvocationConfig({
|
|
878
|
+
endpoint: updatedConfig.endpoint,
|
|
879
|
+
headers: updatedConfig.headers ?? {}
|
|
880
|
+
});
|
|
881
|
+
yield* operationStore.putSource({
|
|
882
|
+
namespace,
|
|
883
|
+
name: input.name?.trim() || existing.name,
|
|
884
|
+
config: updatedConfig,
|
|
885
|
+
invocationConfig: newInvocationConfig
|
|
886
|
+
});
|
|
867
887
|
})
|
|
868
888
|
},
|
|
869
889
|
close: () => runtimeTools.close()
|
|
@@ -893,4 +913,4 @@ export {
|
|
|
893
913
|
makeInMemoryOperationStore,
|
|
894
914
|
graphqlPlugin
|
|
895
915
|
};
|
|
896
|
-
//# sourceMappingURL=chunk-
|
|
916
|
+
//# sourceMappingURL=chunk-AC5VPNLE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sdk/errors.ts","../src/sdk/introspect.ts","../src/sdk/types.ts","../src/sdk/extract.ts","../src/sdk/invoke.ts","../src/sdk/kv-operation-store.ts","../src/sdk/stored-source.ts","../src/sdk/plugin.ts"],"sourcesContent":["import { Data, Schema } from \"effect\";\nimport type { Option } from \"effect\";\n\nexport class GraphqlIntrospectionError extends Schema.TaggedError<GraphqlIntrospectionError>()(\n \"GraphqlIntrospectionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlExtractionError extends Schema.TaggedError<GraphqlExtractionError>()(\n \"GraphqlExtractionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlInvocationError extends Data.TaggedError(\"GraphqlInvocationError\")<{\n readonly message: string;\n readonly statusCode: Option.Option<number>;\n readonly cause?: unknown;\n}> {}\n","import { Effect } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"@effect/platform\";\n\nimport { GraphqlIntrospectionError } from \"./errors\";\n\n// ---------------------------------------------------------------------------\n// Introspection query — standard GraphQL introspection\n// ---------------------------------------------------------------------------\n\nconst INTROSPECTION_QUERY = `\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n types {\n kind\n name\n description\n fields(includeDeprecated: false) {\n name\n description\n args {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n type {\n ...TypeRef\n }\n }\n inputFields {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n enumValues(includeDeprecated: false) {\n name\n description\n }\n }\n }\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Introspection result types\n// ---------------------------------------------------------------------------\n\nexport interface IntrospectionTypeRef {\n readonly kind: string;\n readonly name: string | null;\n readonly ofType: IntrospectionTypeRef | null;\n}\n\nexport interface IntrospectionInputValue {\n readonly name: string;\n readonly description: string | null;\n readonly type: IntrospectionTypeRef;\n readonly defaultValue: string | null;\n}\n\nexport interface IntrospectionField {\n readonly name: string;\n readonly description: string | null;\n readonly args: readonly IntrospectionInputValue[];\n readonly type: IntrospectionTypeRef;\n}\n\nexport interface IntrospectionEnumValue {\n readonly name: string;\n readonly description: string | null;\n}\n\nexport interface IntrospectionType {\n readonly kind: string;\n readonly name: string;\n readonly description: string | null;\n readonly fields: readonly IntrospectionField[] | null;\n readonly inputFields: readonly IntrospectionInputValue[] | null;\n readonly enumValues: readonly IntrospectionEnumValue[] | null;\n}\n\nexport interface IntrospectionSchema {\n readonly queryType: { readonly name: string } | null;\n readonly mutationType: { readonly name: string } | null;\n readonly types: readonly IntrospectionType[];\n}\n\nexport interface IntrospectionResult {\n readonly __schema: IntrospectionSchema;\n}\n\n// ---------------------------------------------------------------------------\n// Introspect a GraphQL endpoint\n// ---------------------------------------------------------------------------\n\nexport const introspect = Effect.fn(\"GraphQL.introspect\")(function* (\n endpoint: string,\n headers?: Record<string, string>,\n) {\n const client = yield* HttpClient.HttpClient;\n\n let request = HttpClientRequest.post(endpoint).pipe(\n HttpClientRequest.setHeader(\"Content-Type\", \"application/json\"),\n HttpClientRequest.bodyUnsafeJson({\n query: INTROSPECTION_QUERY,\n }),\n );\n\n if (headers) {\n for (const [k, v] of Object.entries(headers)) {\n request = HttpClientRequest.setHeader(request, k, v);\n }\n }\n\n const response = yield* client.execute(request).pipe(\n Effect.tapErrorCause((cause) => Effect.logError(\"graphql introspection request failed\", cause)),\n Effect.mapError(\n (err) =>\n new GraphqlIntrospectionError({\n message: `Failed to reach GraphQL endpoint: ${err.message}`,\n }),\n ),\n );\n\n if (response.status !== 200) {\n return yield* new GraphqlIntrospectionError({\n message: `Introspection failed with status ${response.status}`,\n });\n }\n\n const raw = yield* response.json.pipe(\n Effect.tapErrorCause((cause) =>\n Effect.logError(\"graphql introspection JSON parse failed\", cause),\n ),\n Effect.mapError(\n () =>\n new GraphqlIntrospectionError({\n message: `Failed to parse introspection response as JSON`,\n }),\n ),\n );\n\n const json = raw as { data?: IntrospectionResult; errors?: unknown[] };\n\n if (json.errors && Array.isArray(json.errors) && json.errors.length > 0) {\n return yield* new GraphqlIntrospectionError({\n message: `Introspection returned ${json.errors.length} error(s)`,\n });\n }\n\n if (!json.data?.__schema) {\n return yield* new GraphqlIntrospectionError({\n message: \"Introspection response missing __schema\",\n });\n }\n\n return json.data;\n});\n\n// ---------------------------------------------------------------------------\n// Parse an introspection result from a JSON string (for offline/text input)\n// ---------------------------------------------------------------------------\n\nexport const parseIntrospectionJson = (\n text: string,\n): Effect.Effect<IntrospectionResult, GraphqlIntrospectionError> =>\n Effect.try({\n try: () => {\n const parsed = JSON.parse(text);\n // Accept both { data: { __schema } } and { __schema } formats\n const result = parsed.data ?? parsed;\n if (!result.__schema) {\n throw new Error(\"Missing __schema in introspection JSON\");\n }\n return result as IntrospectionResult;\n },\n catch: (err) =>\n new GraphqlIntrospectionError({\n message: `Failed to parse introspection JSON: ${err instanceof Error ? err.message : String(err)}`,\n }),\n });\n","import { Schema } from \"effect\";\n\n// ---------------------------------------------------------------------------\n// GraphQL operation kind\n// ---------------------------------------------------------------------------\n\nexport const GraphqlOperationKind = Schema.Literal(\"query\", \"mutation\");\nexport type GraphqlOperationKind = typeof GraphqlOperationKind.Type;\n\n// ---------------------------------------------------------------------------\n// Extracted field (becomes a tool)\n// ---------------------------------------------------------------------------\n\nexport class GraphqlArgument extends Schema.Class<GraphqlArgument>(\"GraphqlArgument\")({\n name: Schema.String,\n typeName: Schema.String,\n required: Schema.Boolean,\n description: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n}) {}\n\nexport class ExtractedField extends Schema.Class<ExtractedField>(\"ExtractedField\")({\n /** e.g. \"user\", \"createUser\" */\n fieldName: Schema.String,\n /** \"query\" or \"mutation\" */\n kind: GraphqlOperationKind,\n description: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n arguments: Schema.Array(GraphqlArgument),\n /** JSON Schema for the input (built from arguments) */\n inputSchema: Schema.optionalWith(Schema.Unknown, { as: \"Option\" }),\n /** The return type name for documentation */\n returnTypeName: Schema.String,\n}) {}\n\nexport class ExtractionResult extends Schema.Class<ExtractionResult>(\"ExtractionResult\")({\n /** Schema name from introspection */\n schemaName: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n fields: Schema.Array(ExtractedField),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Operation binding — minimal data needed to invoke\n// ---------------------------------------------------------------------------\n\nexport class OperationBinding extends Schema.Class<OperationBinding>(\"OperationBinding\")({\n kind: GraphqlOperationKind,\n fieldName: Schema.String,\n /** The full GraphQL query/mutation string */\n operationString: Schema.String,\n /** Ordered variable names for mapping */\n variableNames: Schema.Array(Schema.String),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Invocation\n// ---------------------------------------------------------------------------\n\nexport const HeaderValue = Schema.Union(\n Schema.String,\n Schema.Struct({\n secretId: Schema.String,\n prefix: Schema.optional(Schema.String),\n }),\n);\nexport type HeaderValue = typeof HeaderValue.Type;\n\nexport class InvocationConfig extends Schema.Class<InvocationConfig>(\"InvocationConfig\")({\n /** The GraphQL endpoint URL */\n endpoint: Schema.String,\n /** Headers applied to every request. Values can reference secrets. */\n headers: Schema.optionalWith(Schema.Record({ key: Schema.String, value: HeaderValue }), {\n default: () => ({}),\n }),\n}) {}\n\nexport class InvocationResult extends Schema.Class<InvocationResult>(\"InvocationResult\")({\n status: Schema.Number,\n data: Schema.NullOr(Schema.Unknown),\n errors: Schema.NullOr(Schema.Unknown),\n}) {}\n","import { Effect, Option } from \"effect\";\n\nimport { GraphqlExtractionError } from \"./errors\";\nimport type {\n IntrospectionResult,\n IntrospectionSchema,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionInputValue,\n} from \"./introspect\";\nimport {\n ExtractedField,\n ExtractionResult,\n GraphqlArgument,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Type ref helpers\n// ---------------------------------------------------------------------------\n\n/** Unwrap NON_NULL / LIST wrappers to get the leaf type name */\nconst unwrapTypeName = (ref: IntrospectionTypeRef): string => {\n if (ref.name) return ref.name;\n if (ref.ofType) return unwrapTypeName(ref.ofType);\n return \"Unknown\";\n};\n\n/** Check if a type ref is non-null (required) */\nconst isNonNull = (ref: IntrospectionTypeRef): boolean => ref.kind === \"NON_NULL\";\n\n// ---------------------------------------------------------------------------\n// Build shared definitions from all INPUT_OBJECT and ENUM types\n// ---------------------------------------------------------------------------\n\nconst buildDefinitions = (\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> => {\n const defs: Record<string, unknown> = {};\n\n for (const [name, type] of types) {\n // Skip internal types\n if (name.startsWith(\"__\")) continue;\n\n if (type.kind === \"INPUT_OBJECT\" && type.inputFields) {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const field of type.inputFields) {\n const schema = typeRefToJsonSchema(field.type, types);\n if (field.description) {\n (schema as Record<string, unknown>).description = field.description;\n }\n properties[field.name] = schema;\n if (isNonNull(field.type)) {\n required.push(field.name);\n }\n }\n\n const def: Record<string, unknown> = { type: \"object\", properties };\n if (required.length > 0) def.required = required;\n if (type.description) def.description = type.description;\n defs[name] = def;\n }\n\n if (type.kind === \"ENUM\" && type.enumValues) {\n defs[name] = {\n type: \"string\",\n enum: type.enumValues.map((v) => v.name),\n ...(type.description ? { description: type.description } : {}),\n };\n }\n }\n\n return defs;\n};\n\n// ---------------------------------------------------------------------------\n// Convert a type ref to JSON Schema using $ref for complex types\n// ---------------------------------------------------------------------------\n\nconst typeRefToJsonSchema = (\n ref: IntrospectionTypeRef,\n // oxlint-disable-next-line only-used-in-recursion\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? typeRefToJsonSchema(ref.ofType, types) : {};\n\n case \"LIST\":\n return {\n type: \"array\",\n items: ref.ofType ? typeRefToJsonSchema(ref.ofType, types) : {},\n };\n\n case \"SCALAR\":\n return scalarToJsonSchema(ref.name ?? \"String\");\n\n case \"ENUM\":\n // Reference the shared definition\n return ref.name ? { $ref: `#/$defs/${ref.name}` } : { type: \"string\" };\n\n case \"INPUT_OBJECT\":\n // Reference the shared definition — no recursive expansion needed\n return ref.name ? { $ref: `#/$defs/${ref.name}` } : { type: \"object\" };\n\n case \"OBJECT\":\n case \"INTERFACE\":\n case \"UNION\":\n return { type: \"object\" };\n\n default:\n return {};\n }\n};\n\nconst scalarToJsonSchema = (name: string): Record<string, unknown> => {\n switch (name) {\n case \"String\":\n case \"ID\":\n return { type: \"string\" };\n case \"Int\":\n return { type: \"integer\" };\n case \"Float\":\n return { type: \"number\" };\n case \"Boolean\":\n return { type: \"boolean\" };\n default:\n return { type: \"string\", description: `Custom scalar: ${name}` };\n }\n};\n\n// ---------------------------------------------------------------------------\n// Build input JSON Schema from field arguments\n// ---------------------------------------------------------------------------\n\nconst buildInputSchema = (\n args: readonly IntrospectionInputValue[],\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> | undefined => {\n if (args.length === 0) return undefined;\n\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const arg of args) {\n const schema = typeRefToJsonSchema(arg.type, types);\n if (arg.description) {\n (schema as Record<string, unknown>).description = arg.description;\n }\n properties[arg.name] = schema;\n if (isNonNull(arg.type)) {\n required.push(arg.name);\n }\n }\n\n const inputSchema: Record<string, unknown> = {\n type: \"object\",\n properties,\n };\n if (required.length > 0) inputSchema.required = required;\n return inputSchema;\n};\n\n/** Format a type ref back to GraphQL type notation (e.g. \"[String!]!\") */\nconst formatTypeRef = (ref: IntrospectionTypeRef): string => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? `${formatTypeRef(ref.ofType)}!` : \"Unknown!\";\n case \"LIST\":\n return ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : \"[Unknown]\";\n default:\n return ref.name ?? \"Unknown\";\n }\n};\n\n// ---------------------------------------------------------------------------\n// Extract fields from schema\n// ---------------------------------------------------------------------------\n\nconst extractFields = (\n _schema: IntrospectionSchema,\n kind: GraphqlOperationKind,\n typeName: string | null | undefined,\n types: ReadonlyMap<string, IntrospectionType>,\n): ExtractedField[] => {\n if (!typeName) return [];\n\n const type = types.get(typeName);\n if (!type?.fields) return [];\n\n return type.fields\n .filter((f) => !f.name.startsWith(\"__\"))\n .map((field) => {\n const args = field.args.map(\n (arg) =>\n new GraphqlArgument({\n name: arg.name,\n typeName: formatTypeRef(arg.type),\n required: isNonNull(arg.type),\n description: arg.description ? Option.some(arg.description) : Option.none(),\n }),\n );\n\n const inputSchema = buildInputSchema(field.args, types);\n\n return new ExtractedField({\n fieldName: field.name,\n kind,\n description: field.description ? Option.some(field.description) : Option.none(),\n arguments: args,\n inputSchema: inputSchema ? Option.some(inputSchema) : Option.none(),\n returnTypeName: unwrapTypeName(field.type),\n });\n });\n};\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\nexport interface ExtractionOutput {\n readonly result: ExtractionResult;\n /** Shared JSON Schema definitions for INPUT_OBJECT and ENUM types.\n * Tool input schemas use `$ref` pointers into these. */\n readonly definitions: Record<string, unknown>;\n}\n\nexport const extract = (\n introspection: IntrospectionResult,\n): Effect.Effect<ExtractionOutput, GraphqlExtractionError> =>\n Effect.try({\n try: () => {\n const schema = introspection.__schema;\n const typeMap = new Map<string, IntrospectionType>();\n for (const t of schema.types) {\n typeMap.set(t.name, t);\n }\n\n const definitions = buildDefinitions(typeMap);\n\n const queryFields = extractFields(schema, \"query\", schema.queryType?.name, typeMap);\n const mutationFields = extractFields(schema, \"mutation\", schema.mutationType?.name, typeMap);\n\n return {\n result: new ExtractionResult({\n schemaName: Option.none(),\n fields: [...queryFields, ...mutationFields],\n }),\n definitions,\n };\n },\n catch: (err) =>\n new GraphqlExtractionError({\n message: `Failed to extract GraphQL schema: ${err instanceof Error ? err.message : String(err)}`,\n }),\n });\n","import { Effect, Layer, Option } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"@effect/platform\";\n\nimport {\n type ToolId,\n type ToolInvoker,\n ToolInvocationResult,\n ToolInvocationError,\n type ScopeId,\n type SecretId,\n} from \"@executor/sdk\";\n\nimport { GraphqlInvocationError } from \"./errors\";\nimport type { GraphqlOperationStore } from \"./operation-store\";\nimport {\n type HeaderValue,\n type OperationBinding,\n InvocationConfig,\n InvocationResult,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Header resolution — resolves secret refs at invocation time\n// ---------------------------------------------------------------------------\n\nconst resolveHeaders = (\n headers: Record<string, HeaderValue>,\n secrets: {\n readonly resolve: (secretId: SecretId, scopeId: ScopeId) => Effect.Effect<string, unknown>;\n },\n scopeId: ScopeId,\n): Effect.Effect<Record<string, string>, ToolInvocationError> =>\n Effect.gen(function* () {\n const resolved: Record<string, string> = {};\n for (const [name, value] of Object.entries(headers)) {\n if (typeof value === \"string\") {\n resolved[name] = value;\n } else {\n const secret = yield* secrets.resolve(value.secretId as SecretId, scopeId).pipe(\n Effect.mapError(\n () =>\n new ToolInvocationError({\n toolId: \"\" as ToolId,\n message: `Failed to resolve secret \"${value.secretId}\" for header \"${name}\"`,\n cause: undefined,\n }),\n ),\n );\n resolved[name] = value.prefix ? `${value.prefix}${secret}` : secret;\n }\n }\n return resolved;\n });\n\n// ---------------------------------------------------------------------------\n// Response helpers\n// ---------------------------------------------------------------------------\n\nconst isJsonContentType = (ct: string | null | undefined): boolean => {\n if (!ct) return false;\n const normalized = ct.split(\";\")[0]?.trim().toLowerCase() ?? \"\";\n return (\n normalized === \"application/json\" || normalized.includes(\"+json\") || normalized.includes(\"json\")\n );\n};\n\n// ---------------------------------------------------------------------------\n// Public API — execute a GraphQL operation\n// ---------------------------------------------------------------------------\n\nexport const invoke = Effect.fn(\"GraphQL.invoke\")(function* (\n operation: OperationBinding,\n args: Record<string, unknown>,\n config: InvocationConfig,\n resolvedHeaders?: Record<string, string>,\n) {\n const client = yield* HttpClient.HttpClient;\n\n // Build the GraphQL request body\n const variables: Record<string, unknown> = {};\n for (const varName of operation.variableNames) {\n if (args[varName] !== undefined) {\n variables[varName] = args[varName];\n }\n }\n\n // Also pick up any variables from a \"variables\" container\n if (typeof args.variables === \"object\" && args.variables !== null) {\n Object.assign(variables, args.variables);\n }\n\n let request = HttpClientRequest.post(config.endpoint).pipe(\n HttpClientRequest.setHeader(\"Content-Type\", \"application/json\"),\n HttpClientRequest.bodyUnsafeJson({\n query: operation.operationString,\n variables: Object.keys(variables).length > 0 ? variables : undefined,\n }),\n );\n\n // Apply resolved headers\n if (resolvedHeaders) {\n for (const [name, value] of Object.entries(resolvedHeaders)) {\n request = HttpClientRequest.setHeader(request, name, value);\n }\n }\n\n const response = yield* client.execute(request).pipe(\n Effect.mapError(\n (err) =>\n new GraphqlInvocationError({\n message: `GraphQL request failed: ${err.message}`,\n statusCode: Option.none(),\n cause: err,\n }),\n ),\n );\n\n const status = response.status;\n const contentType = response.headers[\"content-type\"] ?? null;\n\n const body: unknown = isJsonContentType(contentType)\n ? yield* response.json.pipe(Effect.catchAll(() => response.text))\n : yield* response.text;\n\n // GraphQL responses are always 200 with { data, errors }\n const gqlBody = body as { data?: unknown; errors?: unknown[] } | null;\n const hasErrors = Array.isArray(gqlBody?.errors) && gqlBody.errors.length > 0;\n\n return new InvocationResult({\n status,\n data: gqlBody?.data ?? null,\n errors: hasErrors ? gqlBody!.errors : null,\n });\n});\n\n// ---------------------------------------------------------------------------\n// ToolInvoker — bridges operation store + HTTP client into SDK invoker\n// ---------------------------------------------------------------------------\n\nexport const makeGraphqlInvoker = (opts: {\n readonly operationStore: GraphqlOperationStore;\n readonly httpClientLayer: Layer.Layer<HttpClient.HttpClient>;\n readonly secrets: {\n readonly resolve: (secretId: SecretId, scopeId: ScopeId) => Effect.Effect<string, unknown>;\n };\n readonly scopeId: ScopeId;\n}): ToolInvoker => ({\n resolveAnnotations: (toolId: ToolId) =>\n Effect.gen(function* () {\n const entry = yield* opts.operationStore.get(toolId);\n if (!entry) return undefined;\n // Mutations require approval, queries don't\n if (entry.binding.kind === \"mutation\") {\n return {\n requiresApproval: true,\n approvalDescription: `mutation ${entry.binding.fieldName}`,\n };\n }\n return {};\n }),\n\n invoke: (toolId: ToolId, args: unknown) =>\n Effect.gen(function* () {\n const entry = yield* opts.operationStore.get(toolId);\n if (!entry) {\n return yield* new ToolInvocationError({\n toolId,\n message: `No GraphQL operation found for tool \"${toolId}\"`,\n cause: undefined,\n });\n }\n\n const source = yield* opts.operationStore.getSource(entry.namespace);\n if (!source) {\n return yield* new ToolInvocationError({\n toolId,\n message: `No source found for namespace \"${entry.namespace}\"`,\n cause: undefined,\n });\n }\n\n const { binding } = entry;\n const { invocationConfig: config } = source;\n\n // Resolve secret-backed headers\n const resolvedHeaders = yield* resolveHeaders(config.headers, opts.secrets, opts.scopeId);\n\n const result = yield* invoke(\n binding,\n (args ?? {}) as Record<string, unknown>,\n config,\n resolvedHeaders,\n ).pipe(Effect.provide(opts.httpClientLayer));\n\n return new ToolInvocationResult({\n data: result.data,\n error: result.errors,\n status: result.status,\n });\n }).pipe(\n Effect.catchAll((err) => {\n if (\n typeof err === \"object\" &&\n err !== null &&\n \"_tag\" in err &&\n (err as { _tag: string })._tag === \"ToolInvocationError\"\n ) {\n return Effect.fail(err as ToolInvocationError);\n }\n return Effect.fail(\n new ToolInvocationError({\n toolId,\n message: `GraphQL invocation failed: ${err instanceof Error ? err.message : String(err)}`,\n cause: err,\n }),\n );\n }),\n ),\n});\n","// ---------------------------------------------------------------------------\n// KV-backed GraphqlOperationStore\n// ---------------------------------------------------------------------------\n\nimport { Effect, Schema } from \"effect\";\nimport { scopeKv, makeInMemoryScopedKv, type Kv, type ToolId, type ScopedKv } from \"@executor/sdk\";\n\nimport type { GraphqlOperationStore, StoredSource } from \"./operation-store\";\nimport { InvocationConfig, OperationBinding } from \"./types\";\nimport { StoredSourceSchema } from \"./stored-source\";\n\n// ---------------------------------------------------------------------------\n// Stored schemas\n// ---------------------------------------------------------------------------\n\nclass StoredEntry extends Schema.Class<StoredEntry>(\"StoredEntry\")({\n namespace: Schema.String,\n binding: OperationBinding,\n}) {}\n\nconst encodeEntry = Schema.encodeSync(Schema.parseJson(StoredEntry));\nconst decodeEntry = Schema.decodeUnknownSync(Schema.parseJson(StoredEntry));\n\nconst encodeSource = Schema.encodeSync(Schema.parseJson(StoredSourceSchema));\nconst decodeSource = Schema.decodeUnknownSync(Schema.parseJson(StoredSourceSchema));\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n// TODO(migration): remove DecodedSource + rehydrate once all source rows\n// have been migrated to carry invocationConfig. For GraphQL the endpoint\n// is always user-provided in SourceConfig, so rehydration is lossless.\ntype DecodedSource = Omit<StoredSource, \"invocationConfig\"> & {\n invocationConfig?: InvocationConfig;\n};\n\nconst rehydrate = (source: DecodedSource): StoredSource =>\n source.invocationConfig\n ? (source as StoredSource)\n : {\n ...source,\n invocationConfig: new InvocationConfig({\n endpoint: source.config.endpoint,\n headers: source.config.headers ?? {},\n }),\n };\n\nconst makeStore = (bindings: ScopedKv, sources: ScopedKv): GraphqlOperationStore => ({\n get: (toolId) =>\n Effect.gen(function* () {\n const raw = yield* bindings.get(toolId);\n if (!raw) return null;\n const entry = decodeEntry(raw);\n return { binding: entry.binding, namespace: entry.namespace };\n }),\n\n put: (toolId, namespace, binding) =>\n bindings.set([\n { key: toolId, value: encodeEntry(new StoredEntry({ namespace, binding })) },\n ]),\n\n remove: (toolId) => bindings.delete([toolId]).pipe(Effect.asVoid),\n\n listByNamespace: (namespace) =>\n Effect.gen(function* () {\n const entries = yield* bindings.list();\n const ids: ToolId[] = [];\n for (const e of entries) {\n const entry = decodeEntry(e.value);\n if (entry.namespace === namespace) ids.push(e.key as ToolId);\n }\n return ids;\n }),\n\n removeByNamespace: (namespace) =>\n Effect.gen(function* () {\n const entries = yield* bindings.list();\n const ids: ToolId[] = [];\n for (const e of entries) {\n const entry = decodeEntry(e.value);\n if (entry.namespace === namespace) ids.push(e.key as ToolId);\n }\n if (ids.length > 0) yield* bindings.delete(ids);\n return ids;\n }),\n\n putSource: (source) => sources.set([{ key: source.namespace, value: encodeSource(source) }]),\n\n removeSource: (namespace) => sources.delete([namespace]).pipe(Effect.asVoid),\n\n listSources: () =>\n Effect.gen(function* () {\n const entries = yield* sources.list();\n // TODO(migration): rehydrate in memory only — avoid N writes per list.\n return entries.map((e) => rehydrate(decodeSource(e.value) as DecodedSource));\n }),\n\n getSource: (namespace) =>\n Effect.gen(function* () {\n const raw = yield* sources.get(namespace);\n if (!raw) return null;\n const source = decodeSource(raw) as DecodedSource;\n if (source.invocationConfig) return source as StoredSource;\n // TODO(migration): self-heal — rehydrate and write back once.\n const healed = rehydrate(source);\n yield* sources.set([{ key: namespace, value: encodeSource(healed) }]);\n return healed;\n }),\n\n getSourceConfig: (namespace) =>\n Effect.gen(function* () {\n const raw = yield* sources.get(namespace);\n if (!raw) return null;\n const source = decodeSource(raw) as StoredSource;\n return source.config;\n }),\n});\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nexport const makeKvOperationStore = (kv: Kv, namespace: string): GraphqlOperationStore =>\n makeStore(scopeKv(kv, `${namespace}.bindings`), scopeKv(kv, `${namespace}.sources`));\n\nexport const makeInMemoryOperationStore = (): GraphqlOperationStore =>\n makeStore(makeInMemoryScopedKv(), makeInMemoryScopedKv());\n","import { Schema } from \"effect\";\n\nimport { HeaderValue, InvocationConfig } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Stored source — the shape persisted by the operation store and exposed\n// via the getSource HTTP endpoint.\n// ---------------------------------------------------------------------------\n\nexport class StoredSourceSchema extends Schema.Class<StoredSourceSchema>(\"GraphqlStoredSource\")({\n namespace: Schema.String,\n name: Schema.String,\n config: Schema.Struct({\n endpoint: Schema.String,\n introspectionJson: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record({ key: Schema.String, value: HeaderValue })),\n }),\n // TODO(migration): make required once all rows have been migrated to\n // carry invocationConfig. Left optional for decode compat with rows\n // written before the source-level invocationConfig refactor.\n invocationConfig: Schema.optional(InvocationConfig),\n}) {}\n\nexport type StoredSourceSchemaType = typeof StoredSourceSchema.Type;\n","import { Effect, Option, Schema } from \"effect\";\nimport { FetchHttpClient, HttpClient } from \"@effect/platform\";\nimport type { Layer } from \"effect\";\n\nimport {\n Source,\n SourceDetectionResult,\n definePlugin,\n registerRuntimeTools,\n runtimeTool,\n type ExecutorPlugin,\n type PluginContext,\n ToolId,\n type SecretId,\n type ToolRegistration,\n} from \"@executor/sdk\";\n\nimport {\n introspect,\n parseIntrospectionJson,\n type IntrospectionResult,\n type IntrospectionType,\n type IntrospectionField,\n} from \"./introspect\";\nimport { extract } from \"./extract\";\nimport { GraphqlExtractionError } from \"./errors\";\nimport { makeGraphqlInvoker } from \"./invoke\";\nimport type { GraphqlOperationStore, StoredSource } from \"./operation-store\";\nimport { makeInMemoryOperationStore } from \"./kv-operation-store\";\nimport {\n ExtractedField,\n HeaderValue as HeaderValueSchema,\n InvocationConfig,\n OperationBinding,\n type HeaderValue as HeaderValueValue,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Plugin config\n// ---------------------------------------------------------------------------\n\nexport type HeaderValue = HeaderValueValue;\n\nexport interface GraphqlSourceConfig {\n /** The GraphQL endpoint URL */\n readonly endpoint: string;\n /** Display name for the source. Falls back to namespace if not provided. */\n readonly name?: string;\n /** Optional: introspection JSON text (if endpoint doesn't support introspection) */\n readonly introspectionJson?: string;\n /** Namespace for the tools (derived from endpoint if not provided) */\n readonly namespace?: string;\n /** Headers applied to every request. Values can reference secrets. */\n readonly headers?: Record<string, HeaderValue>;\n}\n\n// ---------------------------------------------------------------------------\n// Plugin extension\n// ---------------------------------------------------------------------------\n\nexport interface GraphqlUpdateSourceInput {\n readonly name?: string;\n readonly endpoint?: string;\n readonly headers?: Record<string, HeaderValue>;\n}\n\nexport interface GraphqlPluginExtension {\n /** Add a GraphQL endpoint and register its operations as tools */\n readonly addSource: (\n config: GraphqlSourceConfig,\n ) => Effect.Effect<{ readonly toolCount: number }, Error>;\n\n /** Remove all tools from a previously added GraphQL source by namespace */\n readonly removeSource: (namespace: string) => Effect.Effect<void>;\n\n /** Fetch the full stored source by namespace (or null if missing) */\n readonly getSource: (namespace: string) => Effect.Effect<StoredSource | null>;\n\n /** Update config (endpoint, headers) for an existing GraphQL source */\n readonly updateSource: (\n namespace: string,\n input: GraphqlUpdateSourceInput,\n ) => Effect.Effect<void>;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst AddSourceInputSchema = Schema.Struct({\n endpoint: Schema.String,\n name: Schema.optional(Schema.String),\n introspectionJson: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(Schema.Record({ key: Schema.String, value: HeaderValueSchema })),\n});\ntype AddSourceInput = typeof AddSourceInputSchema.Type;\n\nconst AddSourceOutputSchema = Schema.Struct({\n sourceId: Schema.String,\n toolCount: Schema.Number,\n});\n\n/** Derive a namespace from an endpoint URL */\nconst namespaceFromEndpoint = (endpoint: string): string => {\n try {\n const url = new URL(endpoint);\n return url.hostname.replace(/[^a-z0-9]+/gi, \"_\").toLowerCase();\n } catch {\n return \"graphql\";\n }\n};\n\nconst buildOperationStringForField = (\n kind: GraphqlOperationKind,\n field: IntrospectionField,\n types: ReadonlyMap<string, IntrospectionType>,\n): string => {\n const opType = kind === \"query\" ? \"query\" : \"mutation\";\n\n const varDefs = field.args.map((arg) => {\n const typeName = formatTypeRef(arg.type);\n return `$${arg.name}: ${typeName}`;\n });\n\n const argPasses = field.args.map((arg) => `${arg.name}: $${arg.name}`);\n const selectionSet = buildSelectionSet(field.type, types, 0, new Set());\n\n const varDefsStr = varDefs.length > 0 ? `(${varDefs.join(\", \")})` : \"\";\n const argPassStr = argPasses.length > 0 ? `(${argPasses.join(\", \")})` : \"\";\n\n return `${opType}${varDefsStr} { ${field.name}${argPassStr}${selectionSet ? ` ${selectionSet}` : \"\"} }`;\n};\n\nimport type { IntrospectionTypeRef } from \"./introspect\";\n\nconst formatTypeRef = (ref: IntrospectionTypeRef): string => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? `${formatTypeRef(ref.ofType)}!` : \"Unknown!\";\n case \"LIST\":\n return ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : \"[Unknown]\";\n default:\n return ref.name ?? \"Unknown\";\n }\n};\n\nconst unwrapTypeName = (ref: IntrospectionTypeRef): string => {\n if (ref.name) return ref.name;\n if (ref.ofType) return unwrapTypeName(ref.ofType);\n return \"Unknown\";\n};\n\nconst buildSelectionSet = (\n ref: IntrospectionTypeRef,\n types: ReadonlyMap<string, IntrospectionType>,\n depth: number,\n seen: Set<string>,\n): string => {\n if (depth > 2) return \"\";\n\n const leafName = unwrapTypeName(ref);\n if (seen.has(leafName)) return \"\";\n\n const objectType = types.get(leafName);\n if (!objectType?.fields) return \"\";\n\n const kind = objectType.kind;\n if (kind === \"SCALAR\" || kind === \"ENUM\") return \"\";\n\n seen.add(leafName);\n\n const subFields = objectType.fields\n .filter((f) => !f.name.startsWith(\"__\"))\n .slice(0, 12)\n .map((f) => {\n const sub = buildSelectionSet(f.type, types, depth + 1, seen);\n return sub ? `${f.name} ${sub}` : f.name;\n });\n\n seen.delete(leafName);\n\n return subFields.length > 0 ? `{ ${subFields.join(\" \")} }` : \"\";\n};\n\nconst toRegistration = (field: ExtractedField, namespace: string): ToolRegistration => {\n const prefix = field.kind === \"mutation\" ? \"mutation\" : \"query\";\n const toolPath = `${prefix}.${field.fieldName}`;\n const description = Option.getOrElse(\n field.description,\n () => `GraphQL ${field.kind}: ${field.fieldName} -> ${field.returnTypeName}`,\n );\n\n return {\n id: ToolId.make(`${namespace}.${toolPath}`),\n pluginKey: \"graphql\",\n sourceId: namespace,\n name: toolPath,\n description,\n inputSchema: Option.getOrUndefined(field.inputSchema),\n outputSchema: undefined,\n };\n};\n\n// ---------------------------------------------------------------------------\n// Plugin factory\n// ---------------------------------------------------------------------------\n\nexport const graphqlPlugin = (options?: {\n readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient>;\n readonly operationStore?: GraphqlOperationStore;\n}): ExecutorPlugin<\"graphql\", GraphqlPluginExtension> => {\n const httpClientLayer = options?.httpClientLayer ?? FetchHttpClient.layer;\n const operationStore = options?.operationStore ?? makeInMemoryOperationStore();\n\n return definePlugin({\n key: \"graphql\",\n init: (ctx: PluginContext) =>\n Effect.gen(function* () {\n yield* ctx.tools.registerInvoker(\n \"graphql\",\n makeGraphqlInvoker({\n operationStore,\n httpClientLayer,\n secrets: ctx.secrets,\n scopeId: ctx.scope.id,\n }),\n );\n\n yield* ctx.sources.addManager({\n kind: \"graphql\",\n\n list: () =>\n operationStore.listSources().pipe(\n Effect.map((metas) =>\n metas.map(\n (s) =>\n new Source({\n id: s.namespace,\n name: s.name,\n kind: \"graphql\",\n url: s.config.endpoint,\n runtime: false,\n canRemove: true,\n canRefresh: false,\n canEdit: true,\n }),\n ),\n ),\n ),\n\n remove: (sourceId: string) =>\n Effect.gen(function* () {\n yield* operationStore.removeByNamespace(sourceId);\n yield* operationStore.removeSource(sourceId);\n yield* ctx.tools.unregisterBySource(sourceId);\n }),\n\n detect: (url: string) =>\n Effect.gen(function* () {\n const trimmed = url.trim();\n if (!trimmed) return null;\n const parsed = yield* Effect.try(() => new URL(trimmed)).pipe(Effect.option);\n if (parsed._tag === \"None\") return null;\n\n const ok = yield* introspect(trimmed).pipe(\n Effect.provide(httpClientLayer),\n Effect.map(() => true),\n Effect.catchAll(() => Effect.succeed(false)),\n );\n\n if (!ok) return null;\n\n const name = namespaceFromEndpoint(trimmed);\n return new SourceDetectionResult({\n kind: \"graphql\",\n confidence: \"high\",\n endpoint: trimmed,\n name,\n namespace: name,\n });\n }),\n });\n\n const addSourceInternal = (config: GraphqlSourceConfig) =>\n Effect.gen(function* () {\n // Get introspection result — either by querying the endpoint or parsing provided JSON\n let introspectionResult: IntrospectionResult;\n if (config.introspectionJson) {\n introspectionResult = yield* parseIntrospectionJson(config.introspectionJson);\n } else {\n // Resolve all headers (including secret refs) for introspection\n const resolvedHeaders: Record<string, string> = {};\n if (config.headers) {\n for (const [name, value] of Object.entries(config.headers)) {\n if (typeof value === \"string\") {\n resolvedHeaders[name] = value;\n } else {\n const secret = yield* ctx.secrets\n .resolve(value.secretId as SecretId, ctx.scope.id)\n .pipe(Effect.catchAll(() => Effect.succeed(\"\")));\n if (secret) {\n resolvedHeaders[name] = value.prefix ? `${value.prefix}${secret}` : secret;\n }\n }\n }\n }\n\n introspectionResult = yield* introspect(\n config.endpoint,\n Object.keys(resolvedHeaders).length > 0 ? resolvedHeaders : undefined,\n ).pipe(Effect.provide(httpClientLayer));\n }\n\n const { result, definitions } = yield* extract(introspectionResult);\n const namespace = config.namespace ?? namespaceFromEndpoint(config.endpoint);\n\n // Register shared JSON Schema definitions ($ref targets)\n if (Object.keys(definitions).length > 0) {\n yield* ctx.tools.registerDefinitions(definitions);\n }\n\n const invocationConfig = new InvocationConfig({\n endpoint: config.endpoint,\n headers: config.headers ?? {},\n });\n\n // Build type map for operation string generation\n const typeMap = new Map<string, IntrospectionType>();\n for (const t of introspectionResult.__schema.types) {\n typeMap.set(t.name, t);\n }\n\n // Build field map for operation strings\n const fieldMap = new Map<\n string,\n { kind: GraphqlOperationKind; field: IntrospectionField }\n >();\n const schema = introspectionResult.__schema;\n\n for (const rootKind of [\"query\", \"mutation\"] as const) {\n const typeName =\n rootKind === \"query\" ? schema.queryType?.name : schema.mutationType?.name;\n if (!typeName) continue;\n const rootType = typeMap.get(typeName);\n if (!rootType?.fields) continue;\n for (const f of rootType.fields) {\n if (!f.name.startsWith(\"__\")) {\n fieldMap.set(`${rootKind}.${f.name}`, { kind: rootKind, field: f });\n }\n }\n }\n\n const registrations: ToolRegistration[] = [];\n\n yield* Effect.forEach(\n result.fields,\n (extractedField) => {\n const reg = toRegistration(extractedField, namespace);\n registrations.push(reg);\n\n const key = `${extractedField.kind}.${extractedField.fieldName}`;\n const entry = fieldMap.get(key);\n\n const operationString = entry\n ? buildOperationStringForField(entry.kind, entry.field, typeMap)\n : `${extractedField.kind} { ${extractedField.fieldName} }`;\n\n const binding = new OperationBinding({\n kind: extractedField.kind,\n fieldName: extractedField.fieldName,\n operationString,\n variableNames: extractedField.arguments.map((a) => a.name),\n });\n\n return operationStore.put(reg.id, namespace, binding);\n },\n { discard: true },\n );\n\n yield* ctx.tools.register(registrations);\n\n yield* operationStore.putSource({\n namespace,\n name: config.name?.trim() || namespace,\n config: {\n endpoint: config.endpoint,\n introspectionJson: config.introspectionJson,\n namespace: config.namespace,\n headers: config.headers,\n },\n invocationConfig,\n });\n\n return { sourceId: namespace, toolCount: registrations.length };\n });\n\n const runtimeTools = yield* registerRuntimeTools({\n registry: ctx.tools,\n sources: ctx.sources,\n pluginKey: \"graphql\",\n source: {\n id: \"built-in\",\n name: \"Built In\",\n kind: \"built-in\",\n },\n tools: [\n runtimeTool({\n id: \"graphql.addSource\",\n name: \"graphql.addSource\",\n description: \"Add a GraphQL endpoint and register its operations as tools\",\n inputSchema: AddSourceInputSchema,\n outputSchema: AddSourceOutputSchema,\n handler: (input: AddSourceInput) => addSourceInternal(input),\n }),\n ],\n });\n\n return {\n extension: {\n addSource: (config: GraphqlSourceConfig) =>\n addSourceInternal(config).pipe(\n Effect.map(({ toolCount }) => ({ toolCount })),\n Effect.mapError(\n (err) =>\n new GraphqlExtractionError({\n message: err instanceof Error ? err.message : String(err),\n }),\n ),\n ),\n\n removeSource: (namespace: string) =>\n Effect.gen(function* () {\n const toolIds = yield* operationStore.removeByNamespace(namespace);\n if (toolIds.length > 0) {\n yield* ctx.tools.unregister(toolIds);\n }\n yield* operationStore.removeSource(namespace);\n }),\n\n getSource: (namespace: string) => operationStore.getSource(namespace),\n\n updateSource: (namespace: string, input: GraphqlUpdateSourceInput) =>\n Effect.gen(function* () {\n const existing = yield* operationStore.getSource(namespace);\n if (!existing) return;\n\n const updatedConfig = {\n ...existing.config,\n ...(input.endpoint !== undefined ? { endpoint: input.endpoint } : {}),\n ...(input.headers !== undefined\n ? { headers: input.headers as Record<string, HeaderValueValue> }\n : {}),\n };\n\n const newInvocationConfig = new InvocationConfig({\n endpoint: updatedConfig.endpoint,\n headers: (updatedConfig.headers ?? {}) as Record<string, HeaderValueValue>,\n });\n\n yield* operationStore.putSource({\n namespace,\n name: input.name?.trim() || existing.name,\n config: updatedConfig,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AAe,UAAU;AAAA,cAC9B;AAAA,cACA,MAAM,MAAM,MAAM,KAAK,KAAK,SAAS;AAAA,cACrC,QAAQ;AAAA,cACR,kBAAkB;AAAA,YACpB,CAAC;AAAA,UACH,CAAC;AAAA,QACL;AAAA,QAEA,OAAO,MAAM,aAAa,MAAM;AAAA,MAClC;AAAA,IACF,CAAC;AAAA,EACL,CAAC;AACH;","names":["Schema","Effect","Effect","Effect","Option","HttpClient","HttpClientRequest","Effect","HttpClient","HttpClientRequest","Option","Effect","Schema","Schema","Schema","Schema","Effect","Effect","Option","Schema","Schema","formatTypeRef","unwrapTypeName","Option","Effect"]}
|
package/dist/core.js
CHANGED
|
@@ -18,7 +18,48 @@ import {
|
|
|
18
18
|
makeInMemoryOperationStore,
|
|
19
19
|
makeKvOperationStore,
|
|
20
20
|
parseIntrospectionJson
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-AC5VPNLE.js";
|
|
22
|
+
|
|
23
|
+
// src/sdk/config-file-store.ts
|
|
24
|
+
import { Effect } from "effect";
|
|
25
|
+
import { addSourceToConfig, removeSourceFromConfig, SECRET_REF_PREFIX } from "@executor/config";
|
|
26
|
+
var translateSecretHeaders = (headers) => {
|
|
27
|
+
if (!headers) return void 0;
|
|
28
|
+
const result = {};
|
|
29
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
30
|
+
if (typeof value === "string") {
|
|
31
|
+
result[key] = value;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const ref = `${SECRET_REF_PREFIX}${value.secretId}`;
|
|
35
|
+
result[key] = value.prefix ? { value: ref, prefix: value.prefix } : ref;
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
var toSourceConfig = (source) => ({
|
|
40
|
+
kind: "graphql",
|
|
41
|
+
endpoint: source.config.endpoint,
|
|
42
|
+
introspectionJson: source.config.introspectionJson,
|
|
43
|
+
namespace: source.namespace,
|
|
44
|
+
headers: translateSecretHeaders(source.config.headers)
|
|
45
|
+
});
|
|
46
|
+
var withConfigFile = (inner, configPath, fsLayer) => ({
|
|
47
|
+
...inner,
|
|
48
|
+
putSource: (source) => Effect.gen(function* () {
|
|
49
|
+
yield* inner.putSource(source);
|
|
50
|
+
yield* addSourceToConfig(configPath, toSourceConfig(source)).pipe(
|
|
51
|
+
Effect.provide(fsLayer),
|
|
52
|
+
Effect.catchAll(() => Effect.void)
|
|
53
|
+
);
|
|
54
|
+
}),
|
|
55
|
+
removeSource: (namespace) => Effect.gen(function* () {
|
|
56
|
+
yield* inner.removeSource(namespace);
|
|
57
|
+
yield* removeSourceFromConfig(configPath, namespace).pipe(
|
|
58
|
+
Effect.provide(fsLayer),
|
|
59
|
+
Effect.catchAll(() => Effect.void)
|
|
60
|
+
);
|
|
61
|
+
})
|
|
62
|
+
});
|
|
22
63
|
export {
|
|
23
64
|
ExtractedField,
|
|
24
65
|
ExtractionResult,
|
|
@@ -38,6 +79,7 @@ export {
|
|
|
38
79
|
makeGraphqlInvoker,
|
|
39
80
|
makeInMemoryOperationStore,
|
|
40
81
|
makeKvOperationStore,
|
|
41
|
-
parseIntrospectionJson
|
|
82
|
+
parseIntrospectionJson,
|
|
83
|
+
withConfigFile
|
|
42
84
|
};
|
|
43
85
|
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/sdk/config-file-store.ts"],"sourcesContent":["/**\n * Config-file wrapper for GraphqlOperationStore.\n *\n * Decorates an underlying store so that `putSource` and `removeSource` also\n * write to executor.jsonc.\n */\n\nimport { Effect } from \"effect\";\nimport { FileSystem } from \"@effect/platform\";\nimport type { Layer } from \"effect\";\n\nimport { addSourceToConfig, removeSourceFromConfig, SECRET_REF_PREFIX } from \"@executor/config\";\nimport type { SourceConfig as ConfigFileSourceConfig, ConfigHeaderValue } from \"@executor/config\";\n\nimport type { GraphqlOperationStore, StoredSource } from \"./operation-store\";\n\ntype PluginHeaderValue = string | { readonly secretId: string; readonly prefix?: string };\n\nconst translateSecretHeaders = (\n headers: Readonly<Record<string, PluginHeaderValue>> | undefined,\n): Record<string, ConfigHeaderValue> | undefined => {\n if (!headers) return undefined;\n const result: Record<string, ConfigHeaderValue> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (typeof value === \"string\") {\n result[key] = value;\n continue;\n }\n const ref = `${SECRET_REF_PREFIX}${value.secretId}`;\n result[key] = value.prefix ? { value: ref, prefix: value.prefix } : ref;\n }\n return result;\n};\n\nconst toSourceConfig = (source: StoredSource): ConfigFileSourceConfig => ({\n kind: \"graphql\",\n endpoint: source.config.endpoint,\n introspectionJson: source.config.introspectionJson,\n namespace: source.namespace,\n headers: translateSecretHeaders(source.config.headers),\n});\n\nexport const withConfigFile = (\n inner: GraphqlOperationStore,\n configPath: string,\n fsLayer: Layer.Layer<FileSystem.FileSystem>,\n): GraphqlOperationStore => ({\n ...inner,\n putSource: (source) =>\n Effect.gen(function* () {\n yield* inner.putSource(source);\n yield* addSourceToConfig(configPath, toSourceConfig(source)).pipe(\n Effect.provide(fsLayer),\n Effect.catchAll(() => Effect.void),\n );\n }),\n removeSource: (namespace) =>\n Effect.gen(function* () {\n yield* inner.removeSource(namespace);\n yield* removeSourceFromConfig(configPath, namespace).pipe(\n Effect.provide(fsLayer),\n Effect.catchAll(() => Effect.void),\n );\n }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAS,cAAc;AAIvB,SAAS,mBAAmB,wBAAwB,yBAAyB;AAO7E,IAAM,yBAAyB,CAC7B,YACkD;AAClD,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,SAA4C,CAAC;AACnD,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,GAAG,IAAI;AACd;AAAA,IACF;AACA,UAAM,MAAM,GAAG,iBAAiB,GAAG,MAAM,QAAQ;AACjD,WAAO,GAAG,IAAI,MAAM,SAAS,EAAE,OAAO,KAAK,QAAQ,MAAM,OAAO,IAAI;AAAA,EACtE;AACA,SAAO;AACT;AAEA,IAAM,iBAAiB,CAAC,YAAkD;AAAA,EACxE,MAAM;AAAA,EACN,UAAU,OAAO,OAAO;AAAA,EACxB,mBAAmB,OAAO,OAAO;AAAA,EACjC,WAAW,OAAO;AAAA,EAClB,SAAS,uBAAuB,OAAO,OAAO,OAAO;AACvD;AAEO,IAAM,iBAAiB,CAC5B,OACA,YACA,aAC2B;AAAA,EAC3B,GAAG;AAAA,EACH,WAAW,CAAC,WACV,OAAO,IAAI,aAAa;AACtB,WAAO,MAAM,UAAU,MAAM;AAC7B,WAAO,kBAAkB,YAAY,eAAe,MAAM,CAAC,EAAE;AAAA,MAC3D,OAAO,QAAQ,OAAO;AAAA,MACtB,OAAO,SAAS,MAAM,OAAO,IAAI;AAAA,IACnC;AAAA,EACF,CAAC;AAAA,EACH,cAAc,CAAC,cACb,OAAO,IAAI,aAAa;AACtB,WAAO,MAAM,aAAa,SAAS;AACnC,WAAO,uBAAuB,YAAY,SAAS,EAAE;AAAA,MACnD,OAAO,QAAQ,OAAO;AAAA,MACtB,OAAO,SAAS,MAAM,OAAO,IAAI;AAAA,IACnC;AAAA,EACF,CAAC;AACL;","names":[]}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/promise.ts"],"sourcesContent":["import { graphqlPlugin as graphqlPluginEffect } from \"./sdk/plugin\";\n\nexport type { GraphqlSourceConfig } from \"./sdk/plugin\";\nexport type { HeaderValue } from \"./sdk/types\";\nexport type { GraphqlOperationStore } from \"./sdk/operation-store\";\n\nexport interface GraphqlPluginOptions {\n readonly operationStore?: import(\"./sdk/operation-store\").GraphqlOperationStore;\n}\n\nexport const graphqlPlugin = (options?: GraphqlPluginOptions)
|
|
1
|
+
{"version":3,"sources":["../src/promise.ts"],"sourcesContent":["import { graphqlPlugin as graphqlPluginEffect } from \"./sdk/plugin\";\n\nexport type { GraphqlSourceConfig } from \"./sdk/plugin\";\nexport type { HeaderValue } from \"./sdk/types\";\nexport type { GraphqlOperationStore } from \"./sdk/operation-store\";\n\nexport interface GraphqlPluginOptions {\n readonly operationStore?: import(\"./sdk/operation-store\").GraphqlOperationStore;\n}\n\nexport const graphqlPlugin = (options?: GraphqlPluginOptions) => graphqlPluginEffect(options);\n"],"mappings":";;;;;AAUO,IAAMA,iBAAgB,CAAC,YAAmC,cAAoB,OAAO;","names":["graphqlPlugin"]}
|
package/dist/promise.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export type { GraphqlOperationStore } from "./sdk/operation-store";
|
|
|
4
4
|
export interface GraphqlPluginOptions {
|
|
5
5
|
readonly operationStore?: import("./sdk/operation-store").GraphqlOperationStore;
|
|
6
6
|
}
|
|
7
|
-
export declare const graphqlPlugin: (options?: GraphqlPluginOptions) => import("@executor-js/sdk
|
|
7
|
+
export declare const graphqlPlugin: (options?: GraphqlPluginOptions) => import("@executor-js/sdk").ExecutorPlugin<"graphql", import("./sdk").GraphqlPluginExtension>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config-file wrapper for GraphqlOperationStore.
|
|
3
|
+
*
|
|
4
|
+
* Decorates an underlying store so that `putSource` and `removeSource` also
|
|
5
|
+
* write to executor.jsonc.
|
|
6
|
+
*/
|
|
7
|
+
import { FileSystem } from "@effect/platform";
|
|
8
|
+
import type { Layer } from "effect";
|
|
9
|
+
import type { GraphqlOperationStore } from "./operation-store";
|
|
10
|
+
export declare const withConfigFile: (inner: GraphqlOperationStore, configPath: string, fsLayer: Layer.Layer<FileSystem.FileSystem>) => GraphqlOperationStore;
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { introspect, parseIntrospectionJson } from "./introspect";
|
|
2
2
|
export { extract, type ExtractionOutput } from "./extract";
|
|
3
3
|
export { invoke, makeGraphqlInvoker } from "./invoke";
|
|
4
|
-
export { graphqlPlugin, type GraphqlSourceConfig, type GraphqlPluginExtension
|
|
4
|
+
export { graphqlPlugin, type GraphqlSourceConfig, type GraphqlPluginExtension } from "./plugin";
|
|
5
5
|
export { type GraphqlOperationStore, type StoredSource, type SourceConfig, } from "./operation-store";
|
|
6
|
-
export { makeKvOperationStore, makeInMemoryOperationStore
|
|
6
|
+
export { makeKvOperationStore, makeInMemoryOperationStore } from "./kv-operation-store";
|
|
7
|
+
export { withConfigFile } from "./config-file-store";
|
|
7
8
|
export { GraphqlIntrospectionError, GraphqlExtractionError, GraphqlInvocationError, } from "./errors";
|
|
8
9
|
export { ExtractedField, ExtractionResult, GraphqlArgument, GraphqlOperationKind, InvocationConfig, InvocationResult, OperationBinding, HeaderValue, } from "./types";
|
package/dist/sdk/invoke.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, Layer } from "effect";
|
|
2
2
|
import { HttpClient } from "@effect/platform";
|
|
3
|
-
import { type ToolInvoker, type ScopeId, type SecretId } from "@executor-js/sdk
|
|
3
|
+
import { type ToolInvoker, type ScopeId, type SecretId } from "@executor-js/sdk";
|
|
4
4
|
import { GraphqlInvocationError } from "./errors";
|
|
5
5
|
import type { GraphqlOperationStore } from "./operation-store";
|
|
6
6
|
import { type OperationBinding, InvocationConfig, InvocationResult } from "./types";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Kv } from "@executor-js/sdk
|
|
1
|
+
import { type Kv } from "@executor-js/sdk";
|
|
2
2
|
import type { GraphqlOperationStore } from "./operation-store";
|
|
3
3
|
export declare const makeKvOperationStore: (kv: Kv, namespace: string) => GraphqlOperationStore;
|
|
4
4
|
export declare const makeInMemoryOperationStore: () => GraphqlOperationStore;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Effect } from "effect";
|
|
2
|
-
import type { ToolId } from "@executor-js/sdk
|
|
2
|
+
import type { ToolId } from "@executor-js/sdk";
|
|
3
3
|
import type { OperationBinding, InvocationConfig, HeaderValue } from "./types";
|
|
4
4
|
export interface SourceConfig {
|
|
5
5
|
readonly endpoint: string;
|
|
@@ -11,17 +11,21 @@ export interface StoredSource {
|
|
|
11
11
|
readonly namespace: string;
|
|
12
12
|
readonly name: string;
|
|
13
13
|
readonly config: SourceConfig;
|
|
14
|
+
/** Pre-resolved runtime invocation config (endpoint, headers). */
|
|
15
|
+
readonly invocationConfig: InvocationConfig;
|
|
14
16
|
}
|
|
15
17
|
export interface GraphqlOperationStore {
|
|
16
18
|
readonly get: (toolId: ToolId) => Effect.Effect<{
|
|
17
19
|
binding: OperationBinding;
|
|
18
|
-
|
|
20
|
+
namespace: string;
|
|
19
21
|
} | null>;
|
|
20
|
-
readonly put: (toolId: ToolId, namespace: string, binding: OperationBinding
|
|
22
|
+
readonly put: (toolId: ToolId, namespace: string, binding: OperationBinding) => Effect.Effect<void>;
|
|
21
23
|
readonly remove: (toolId: ToolId) => Effect.Effect<void>;
|
|
22
24
|
readonly listByNamespace: (namespace: string) => Effect.Effect<readonly ToolId[]>;
|
|
23
25
|
readonly removeByNamespace: (namespace: string) => Effect.Effect<readonly ToolId[]>;
|
|
24
26
|
readonly putSource: (source: StoredSource) => Effect.Effect<void>;
|
|
25
27
|
readonly removeSource: (namespace: string) => Effect.Effect<void>;
|
|
26
28
|
readonly listSources: () => Effect.Effect<readonly StoredSource[]>;
|
|
29
|
+
readonly getSource: (namespace: string) => Effect.Effect<StoredSource | null>;
|
|
30
|
+
readonly getSourceConfig: (namespace: string) => Effect.Effect<SourceConfig | null>;
|
|
27
31
|
}
|
package/dist/sdk/plugin.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { HttpClient } from "@effect/platform";
|
|
3
3
|
import type { Layer } from "effect";
|
|
4
|
-
import { type ExecutorPlugin } from "@executor-js/sdk
|
|
5
|
-
import type { GraphqlOperationStore } from "./operation-store";
|
|
4
|
+
import { type ExecutorPlugin } from "@executor-js/sdk";
|
|
5
|
+
import type { GraphqlOperationStore, StoredSource } from "./operation-store";
|
|
6
6
|
import { type HeaderValue as HeaderValueValue } from "./types";
|
|
7
7
|
export type HeaderValue = HeaderValueValue;
|
|
8
8
|
export interface GraphqlSourceConfig {
|
|
9
9
|
/** The GraphQL endpoint URL */
|
|
10
10
|
readonly endpoint: string;
|
|
11
|
+
/** Display name for the source. Falls back to namespace if not provided. */
|
|
12
|
+
readonly name?: string;
|
|
11
13
|
/** Optional: introspection JSON text (if endpoint doesn't support introspection) */
|
|
12
14
|
readonly introspectionJson?: string;
|
|
13
15
|
/** Namespace for the tools (derived from endpoint if not provided) */
|
|
@@ -15,6 +17,11 @@ export interface GraphqlSourceConfig {
|
|
|
15
17
|
/** Headers applied to every request. Values can reference secrets. */
|
|
16
18
|
readonly headers?: Record<string, HeaderValue>;
|
|
17
19
|
}
|
|
20
|
+
export interface GraphqlUpdateSourceInput {
|
|
21
|
+
readonly name?: string;
|
|
22
|
+
readonly endpoint?: string;
|
|
23
|
+
readonly headers?: Record<string, HeaderValue>;
|
|
24
|
+
}
|
|
18
25
|
export interface GraphqlPluginExtension {
|
|
19
26
|
/** Add a GraphQL endpoint and register its operations as tools */
|
|
20
27
|
readonly addSource: (config: GraphqlSourceConfig) => Effect.Effect<{
|
|
@@ -22,6 +29,10 @@ export interface GraphqlPluginExtension {
|
|
|
22
29
|
}, Error>;
|
|
23
30
|
/** Remove all tools from a previously added GraphQL source by namespace */
|
|
24
31
|
readonly removeSource: (namespace: string) => Effect.Effect<void>;
|
|
32
|
+
/** Fetch the full stored source by namespace (or null if missing) */
|
|
33
|
+
readonly getSource: (namespace: string) => Effect.Effect<StoredSource | null>;
|
|
34
|
+
/** Update config (endpoint, headers) for an existing GraphQL source */
|
|
35
|
+
readonly updateSource: (namespace: string, input: GraphqlUpdateSourceInput) => Effect.Effect<void>;
|
|
25
36
|
}
|
|
26
37
|
export declare const graphqlPlugin: (options?: {
|
|
27
38
|
readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { InvocationConfig } from "./types";
|
|
3
|
+
declare const StoredSourceSchema_base: Schema.Class<StoredSourceSchema, {
|
|
4
|
+
namespace: typeof Schema.String;
|
|
5
|
+
name: typeof Schema.String;
|
|
6
|
+
config: Schema.Struct<{
|
|
7
|
+
endpoint: typeof Schema.String;
|
|
8
|
+
introspectionJson: Schema.optional<typeof Schema.String>;
|
|
9
|
+
namespace: Schema.optional<typeof Schema.String>;
|
|
10
|
+
headers: Schema.optional<Schema.Record$<typeof Schema.String, Schema.Union<[typeof Schema.String, Schema.Struct<{
|
|
11
|
+
secretId: typeof Schema.String;
|
|
12
|
+
prefix: Schema.optional<typeof Schema.String>;
|
|
13
|
+
}>]>>>;
|
|
14
|
+
}>;
|
|
15
|
+
invocationConfig: Schema.optional<typeof InvocationConfig>;
|
|
16
|
+
}, Schema.Struct.Encoded<{
|
|
17
|
+
namespace: typeof Schema.String;
|
|
18
|
+
name: typeof Schema.String;
|
|
19
|
+
config: Schema.Struct<{
|
|
20
|
+
endpoint: typeof Schema.String;
|
|
21
|
+
introspectionJson: Schema.optional<typeof Schema.String>;
|
|
22
|
+
namespace: Schema.optional<typeof Schema.String>;
|
|
23
|
+
headers: Schema.optional<Schema.Record$<typeof Schema.String, Schema.Union<[typeof Schema.String, Schema.Struct<{
|
|
24
|
+
secretId: typeof Schema.String;
|
|
25
|
+
prefix: Schema.optional<typeof Schema.String>;
|
|
26
|
+
}>]>>>;
|
|
27
|
+
}>;
|
|
28
|
+
invocationConfig: Schema.optional<typeof InvocationConfig>;
|
|
29
|
+
}>, never, {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
} & {
|
|
32
|
+
readonly namespace: string;
|
|
33
|
+
} & {
|
|
34
|
+
readonly invocationConfig?: InvocationConfig | undefined;
|
|
35
|
+
} & {
|
|
36
|
+
readonly config: {
|
|
37
|
+
readonly endpoint: string;
|
|
38
|
+
readonly namespace?: string | undefined;
|
|
39
|
+
readonly headers?: {
|
|
40
|
+
readonly [x: string]: string | {
|
|
41
|
+
readonly secretId: string;
|
|
42
|
+
readonly prefix?: string | undefined;
|
|
43
|
+
};
|
|
44
|
+
} | undefined;
|
|
45
|
+
readonly introspectionJson?: string | undefined;
|
|
46
|
+
};
|
|
47
|
+
}, {}, {}>;
|
|
48
|
+
export declare class StoredSourceSchema extends StoredSourceSchema_base {
|
|
49
|
+
}
|
|
50
|
+
export type StoredSourceSchemaType = typeof StoredSourceSchema.Type;
|
|
51
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@executor-js/plugin-graphql",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"homepage": "https://github.com/RhysSullivan/executor/tree/main/packages/plugins/graphql",
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/RhysSullivan/executor/issues"
|
|
7
|
+
},
|
|
5
8
|
"license": "MIT",
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "git+https://github.com/RhysSullivan/executor.git",
|
|
9
12
|
"directory": "packages/plugins/graphql"
|
|
10
13
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
15
18
|
"exports": {
|
|
16
19
|
".": {
|
|
17
20
|
"import": {
|
|
@@ -26,24 +29,41 @@
|
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
29
35
|
"scripts": {
|
|
30
36
|
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
|
|
31
|
-
"typecheck": "
|
|
37
|
+
"typecheck": "tsgo --noEmit",
|
|
32
38
|
"test": "vitest run",
|
|
33
|
-
"test:watch": "vitest"
|
|
39
|
+
"test:watch": "vitest",
|
|
40
|
+
"typecheck:slow": "bunx tsc --noEmit -p tsconfig.json"
|
|
34
41
|
},
|
|
35
42
|
"dependencies": {
|
|
36
43
|
"@effect/platform": "^0.96.0",
|
|
37
44
|
"@effect/platform-node": "^0.106.0",
|
|
38
|
-
"@executor
|
|
45
|
+
"@executor/config": "1.4.3",
|
|
46
|
+
"@executor-js/sdk": "0.0.1",
|
|
39
47
|
"effect": "^3.21.0"
|
|
40
48
|
},
|
|
41
|
-
"
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
51
|
+
"@effect/vitest": "^0.29.0",
|
|
52
|
+
"@executor/api": "1.4.3",
|
|
53
|
+
"@executor/react": "1.4.3",
|
|
54
|
+
"@types/node": "^24.3.1",
|
|
55
|
+
"@types/react": "^19.1.0",
|
|
56
|
+
"bun-types": "^1.2.22",
|
|
42
57
|
"react": "^19.1.0",
|
|
58
|
+
"tsup": "^8.5.0",
|
|
59
|
+
"vitest": "^4.1.3"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
43
62
|
"@effect-atom/atom-react": "^0.5.0",
|
|
63
|
+
"@executor/api": "1.4.3",
|
|
64
|
+
"@executor/react": "1.4.3",
|
|
44
65
|
"@tanstack/react-router": "^1.168.10",
|
|
45
|
-
"
|
|
46
|
-
"@executor/react": "1.4.2"
|
|
66
|
+
"react": "^19.1.0"
|
|
47
67
|
},
|
|
48
68
|
"peerDependenciesMeta": {
|
|
49
69
|
"react": {
|
|
@@ -61,23 +81,5 @@
|
|
|
61
81
|
"@executor/react": {
|
|
62
82
|
"optional": true
|
|
63
83
|
}
|
|
64
|
-
}
|
|
65
|
-
"devDependencies": {
|
|
66
|
-
"react": "^19.1.0",
|
|
67
|
-
"@effect-atom/atom-react": "^0.5.0",
|
|
68
|
-
"@executor/api": "1.4.2",
|
|
69
|
-
"@executor/react": "1.4.2",
|
|
70
|
-
"@types/react": "^19.1.0",
|
|
71
|
-
"@effect/vitest": "^0.29.0",
|
|
72
|
-
"@types/node": "^24.3.1",
|
|
73
|
-
"bun-types": "^1.2.22",
|
|
74
|
-
"vitest": "^4.1.3",
|
|
75
|
-
"tsup": "^8.5.0"
|
|
76
|
-
},
|
|
77
|
-
"publishConfig": {
|
|
78
|
-
"access": "public"
|
|
79
|
-
},
|
|
80
|
-
"files": [
|
|
81
|
-
"dist"
|
|
82
|
-
]
|
|
84
|
+
}
|
|
83
85
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdk/errors.ts","../src/sdk/introspect.ts","../src/sdk/types.ts","../src/sdk/extract.ts","../src/sdk/invoke.ts","../src/sdk/kv-operation-store.ts","../src/sdk/plugin.ts"],"sourcesContent":["import { Data, Schema } from \"effect\";\nimport type { Option } from \"effect\";\n\nexport class GraphqlIntrospectionError extends Schema.TaggedError<GraphqlIntrospectionError>()(\n \"GraphqlIntrospectionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlExtractionError extends Schema.TaggedError<GraphqlExtractionError>()(\n \"GraphqlExtractionError\",\n {\n message: Schema.String,\n },\n) {}\n\nexport class GraphqlInvocationError extends Data.TaggedError(\n \"GraphqlInvocationError\",\n)<{\n readonly message: string;\n readonly statusCode: Option.Option<number>;\n readonly cause?: unknown;\n}> {}\n","import { Effect } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"@effect/platform\";\n\nimport { GraphqlIntrospectionError } from \"./errors\";\n\n// ---------------------------------------------------------------------------\n// Introspection query — standard GraphQL introspection\n// ---------------------------------------------------------------------------\n\nconst INTROSPECTION_QUERY = `\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n types {\n kind\n name\n description\n fields(includeDeprecated: false) {\n name\n description\n args {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n type {\n ...TypeRef\n }\n }\n inputFields {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n enumValues(includeDeprecated: false) {\n name\n description\n }\n }\n }\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Introspection result types\n// ---------------------------------------------------------------------------\n\nexport interface IntrospectionTypeRef {\n readonly kind: string;\n readonly name: string | null;\n readonly ofType: IntrospectionTypeRef | null;\n}\n\nexport interface IntrospectionInputValue {\n readonly name: string;\n readonly description: string | null;\n readonly type: IntrospectionTypeRef;\n readonly defaultValue: string | null;\n}\n\nexport interface IntrospectionField {\n readonly name: string;\n readonly description: string | null;\n readonly args: readonly IntrospectionInputValue[];\n readonly type: IntrospectionTypeRef;\n}\n\nexport interface IntrospectionEnumValue {\n readonly name: string;\n readonly description: string | null;\n}\n\nexport interface IntrospectionType {\n readonly kind: string;\n readonly name: string;\n readonly description: string | null;\n readonly fields: readonly IntrospectionField[] | null;\n readonly inputFields: readonly IntrospectionInputValue[] | null;\n readonly enumValues: readonly IntrospectionEnumValue[] | null;\n}\n\nexport interface IntrospectionSchema {\n readonly queryType: { readonly name: string } | null;\n readonly mutationType: { readonly name: string } | null;\n readonly types: readonly IntrospectionType[];\n}\n\nexport interface IntrospectionResult {\n readonly __schema: IntrospectionSchema;\n}\n\n// ---------------------------------------------------------------------------\n// Introspect a GraphQL endpoint\n// ---------------------------------------------------------------------------\n\nexport const introspect = Effect.fn(\"GraphQL.introspect\")(function* (\n endpoint: string,\n headers?: Record<string, string>,\n) {\n const client = yield* HttpClient.HttpClient;\n\n let request = HttpClientRequest.post(endpoint).pipe(\n HttpClientRequest.setHeader(\"Content-Type\", \"application/json\"),\n HttpClientRequest.bodyUnsafeJson({\n query: INTROSPECTION_QUERY,\n }),\n );\n\n if (headers) {\n for (const [k, v] of Object.entries(headers)) {\n request = HttpClientRequest.setHeader(request, k, v);\n }\n }\n\n const response = yield* client.execute(request).pipe(\n Effect.tapErrorCause((cause) =>\n Effect.logError(\"graphql introspection request failed\", cause),\n ),\n Effect.mapError(\n (err) =>\n new GraphqlIntrospectionError({\n message: `Failed to reach GraphQL endpoint: ${err.message}`,\n }),\n ),\n );\n\n if (response.status !== 200) {\n return yield* new GraphqlIntrospectionError({\n message: `Introspection failed with status ${response.status}`,\n });\n }\n\n const raw = yield* response.json.pipe(\n Effect.tapErrorCause((cause) =>\n Effect.logError(\"graphql introspection JSON parse failed\", cause),\n ),\n Effect.mapError(\n () =>\n new GraphqlIntrospectionError({\n message: `Failed to parse introspection response as JSON`,\n }),\n ),\n );\n\n const json = raw as { data?: IntrospectionResult; errors?: unknown[] };\n\n if (json.errors && Array.isArray(json.errors) && json.errors.length > 0) {\n return yield* new GraphqlIntrospectionError({\n message: `Introspection returned ${json.errors.length} error(s)`,\n });\n }\n\n if (!json.data?.__schema) {\n return yield* new GraphqlIntrospectionError({\n message: \"Introspection response missing __schema\",\n });\n }\n\n return json.data;\n});\n\n// ---------------------------------------------------------------------------\n// Parse an introspection result from a JSON string (for offline/text input)\n// ---------------------------------------------------------------------------\n\nexport const parseIntrospectionJson = (\n text: string,\n): Effect.Effect<IntrospectionResult, GraphqlIntrospectionError> =>\n Effect.try({\n try: () => {\n const parsed = JSON.parse(text);\n // Accept both { data: { __schema } } and { __schema } formats\n const result = parsed.data ?? parsed;\n if (!result.__schema) {\n throw new Error(\"Missing __schema in introspection JSON\");\n }\n return result as IntrospectionResult;\n },\n catch: (err) =>\n new GraphqlIntrospectionError({\n message: `Failed to parse introspection JSON: ${err instanceof Error ? err.message : String(err)}`,\n }),\n });\n","import { Schema } from \"effect\";\n\n// ---------------------------------------------------------------------------\n// GraphQL operation kind\n// ---------------------------------------------------------------------------\n\nexport const GraphqlOperationKind = Schema.Literal(\"query\", \"mutation\");\nexport type GraphqlOperationKind = typeof GraphqlOperationKind.Type;\n\n// ---------------------------------------------------------------------------\n// Extracted field (becomes a tool)\n// ---------------------------------------------------------------------------\n\nexport class GraphqlArgument extends Schema.Class<GraphqlArgument>(\n \"GraphqlArgument\",\n)({\n name: Schema.String,\n typeName: Schema.String,\n required: Schema.Boolean,\n description: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n}) {}\n\nexport class ExtractedField extends Schema.Class<ExtractedField>(\n \"ExtractedField\",\n)({\n /** e.g. \"user\", \"createUser\" */\n fieldName: Schema.String,\n /** \"query\" or \"mutation\" */\n kind: GraphqlOperationKind,\n description: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n arguments: Schema.Array(GraphqlArgument),\n /** JSON Schema for the input (built from arguments) */\n inputSchema: Schema.optionalWith(Schema.Unknown, { as: \"Option\" }),\n /** The return type name for documentation */\n returnTypeName: Schema.String,\n}) {}\n\nexport class ExtractionResult extends Schema.Class<ExtractionResult>(\n \"ExtractionResult\",\n)({\n /** Schema name from introspection */\n schemaName: Schema.optionalWith(Schema.String, { as: \"Option\" }),\n fields: Schema.Array(ExtractedField),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Operation binding — minimal data needed to invoke\n// ---------------------------------------------------------------------------\n\nexport class OperationBinding extends Schema.Class<OperationBinding>(\n \"OperationBinding\",\n)({\n kind: GraphqlOperationKind,\n fieldName: Schema.String,\n /** The full GraphQL query/mutation string */\n operationString: Schema.String,\n /** Ordered variable names for mapping */\n variableNames: Schema.Array(Schema.String),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Invocation\n// ---------------------------------------------------------------------------\n\nexport const HeaderValue = Schema.Union(\n Schema.String,\n Schema.Struct({\n secretId: Schema.String,\n prefix: Schema.optional(Schema.String),\n }),\n);\nexport type HeaderValue = typeof HeaderValue.Type;\n\nexport class InvocationConfig extends Schema.Class<InvocationConfig>(\n \"InvocationConfig\",\n)({\n /** The GraphQL endpoint URL */\n endpoint: Schema.String,\n /** Headers applied to every request. Values can reference secrets. */\n headers: Schema.optionalWith(\n Schema.Record({ key: Schema.String, value: HeaderValue }),\n { default: () => ({}) },\n ),\n}) {}\n\nexport class InvocationResult extends Schema.Class<InvocationResult>(\n \"InvocationResult\",\n)({\n status: Schema.Number,\n data: Schema.NullOr(Schema.Unknown),\n errors: Schema.NullOr(Schema.Unknown),\n}) {}\n","import { Effect, Option } from \"effect\";\n\nimport { GraphqlExtractionError } from \"./errors\";\nimport type {\n IntrospectionResult,\n IntrospectionSchema,\n IntrospectionType,\n IntrospectionTypeRef,\n IntrospectionInputValue,\n} from \"./introspect\";\nimport {\n ExtractedField,\n ExtractionResult,\n GraphqlArgument,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Type ref helpers\n// ---------------------------------------------------------------------------\n\n/** Unwrap NON_NULL / LIST wrappers to get the leaf type name */\nconst unwrapTypeName = (ref: IntrospectionTypeRef): string => {\n if (ref.name) return ref.name;\n if (ref.ofType) return unwrapTypeName(ref.ofType);\n return \"Unknown\";\n};\n\n/** Check if a type ref is non-null (required) */\nconst isNonNull = (ref: IntrospectionTypeRef): boolean =>\n ref.kind === \"NON_NULL\";\n\n// ---------------------------------------------------------------------------\n// Build shared definitions from all INPUT_OBJECT and ENUM types\n// ---------------------------------------------------------------------------\n\nconst buildDefinitions = (\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> => {\n const defs: Record<string, unknown> = {};\n\n for (const [name, type] of types) {\n // Skip internal types\n if (name.startsWith(\"__\")) continue;\n\n if (type.kind === \"INPUT_OBJECT\" && type.inputFields) {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const field of type.inputFields) {\n const schema = typeRefToJsonSchema(field.type, types);\n if (field.description) {\n (schema as Record<string, unknown>).description = field.description;\n }\n properties[field.name] = schema;\n if (isNonNull(field.type)) {\n required.push(field.name);\n }\n }\n\n const def: Record<string, unknown> = { type: \"object\", properties };\n if (required.length > 0) def.required = required;\n if (type.description) def.description = type.description;\n defs[name] = def;\n }\n\n if (type.kind === \"ENUM\" && type.enumValues) {\n defs[name] = {\n type: \"string\",\n enum: type.enumValues.map((v) => v.name),\n ...(type.description ? { description: type.description } : {}),\n };\n }\n }\n\n return defs;\n};\n\n// ---------------------------------------------------------------------------\n// Convert a type ref to JSON Schema using $ref for complex types\n// ---------------------------------------------------------------------------\n\nconst typeRefToJsonSchema = (\n ref: IntrospectionTypeRef,\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? typeRefToJsonSchema(ref.ofType, types) : {};\n\n case \"LIST\":\n return {\n type: \"array\",\n items: ref.ofType ? typeRefToJsonSchema(ref.ofType, types) : {},\n };\n\n case \"SCALAR\":\n return scalarToJsonSchema(ref.name ?? \"String\");\n\n case \"ENUM\":\n // Reference the shared definition\n return ref.name ? { $ref: `#/$defs/${ref.name}` } : { type: \"string\" };\n\n case \"INPUT_OBJECT\":\n // Reference the shared definition — no recursive expansion needed\n return ref.name ? { $ref: `#/$defs/${ref.name}` } : { type: \"object\" };\n\n case \"OBJECT\":\n case \"INTERFACE\":\n case \"UNION\":\n return { type: \"object\" };\n\n default:\n return {};\n }\n};\n\nconst scalarToJsonSchema = (name: string): Record<string, unknown> => {\n switch (name) {\n case \"String\":\n case \"ID\":\n return { type: \"string\" };\n case \"Int\":\n return { type: \"integer\" };\n case \"Float\":\n return { type: \"number\" };\n case \"Boolean\":\n return { type: \"boolean\" };\n default:\n return { type: \"string\", description: `Custom scalar: ${name}` };\n }\n};\n\n// ---------------------------------------------------------------------------\n// Build input JSON Schema from field arguments\n// ---------------------------------------------------------------------------\n\nconst buildInputSchema = (\n args: readonly IntrospectionInputValue[],\n types: ReadonlyMap<string, IntrospectionType>,\n): Record<string, unknown> | undefined => {\n if (args.length === 0) return undefined;\n\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const arg of args) {\n const schema = typeRefToJsonSchema(arg.type, types);\n if (arg.description) {\n (schema as Record<string, unknown>).description = arg.description;\n }\n properties[arg.name] = schema;\n if (isNonNull(arg.type)) {\n required.push(arg.name);\n }\n }\n\n const inputSchema: Record<string, unknown> = {\n type: \"object\",\n properties,\n };\n if (required.length > 0) inputSchema.required = required;\n return inputSchema;\n};\n\n/** Format a type ref back to GraphQL type notation (e.g. \"[String!]!\") */\nconst formatTypeRef = (ref: IntrospectionTypeRef): string => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? `${formatTypeRef(ref.ofType)}!` : \"Unknown!\";\n case \"LIST\":\n return ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : \"[Unknown]\";\n default:\n return ref.name ?? \"Unknown\";\n }\n};\n\n// ---------------------------------------------------------------------------\n// Extract fields from schema\n// ---------------------------------------------------------------------------\n\nconst extractFields = (\n _schema: IntrospectionSchema,\n kind: GraphqlOperationKind,\n typeName: string | null | undefined,\n types: ReadonlyMap<string, IntrospectionType>,\n): ExtractedField[] => {\n if (!typeName) return [];\n\n const type = types.get(typeName);\n if (!type?.fields) return [];\n\n return type.fields\n .filter((f) => !f.name.startsWith(\"__\"))\n .map((field) => {\n const args = field.args.map(\n (arg) =>\n new GraphqlArgument({\n name: arg.name,\n typeName: formatTypeRef(arg.type),\n required: isNonNull(arg.type),\n description: arg.description ? Option.some(arg.description) : Option.none(),\n }),\n );\n\n const inputSchema = buildInputSchema(field.args, types);\n\n return new ExtractedField({\n fieldName: field.name,\n kind,\n description: field.description\n ? Option.some(field.description)\n : Option.none(),\n arguments: args,\n inputSchema: inputSchema ? Option.some(inputSchema) : Option.none(),\n returnTypeName: unwrapTypeName(field.type),\n });\n });\n};\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\nexport interface ExtractionOutput {\n readonly result: ExtractionResult;\n /** Shared JSON Schema definitions for INPUT_OBJECT and ENUM types.\n * Tool input schemas use `$ref` pointers into these. */\n readonly definitions: Record<string, unknown>;\n}\n\nexport const extract = (\n introspection: IntrospectionResult,\n): Effect.Effect<ExtractionOutput, GraphqlExtractionError> =>\n Effect.try({\n try: () => {\n const schema = introspection.__schema;\n const typeMap = new Map<string, IntrospectionType>();\n for (const t of schema.types) {\n typeMap.set(t.name, t);\n }\n\n const definitions = buildDefinitions(typeMap);\n\n const queryFields = extractFields(\n schema,\n \"query\",\n schema.queryType?.name,\n typeMap,\n );\n const mutationFields = extractFields(\n schema,\n \"mutation\",\n schema.mutationType?.name,\n typeMap,\n );\n\n return {\n result: new ExtractionResult({\n schemaName: Option.none(),\n fields: [...queryFields, ...mutationFields],\n }),\n definitions,\n };\n },\n catch: (err) =>\n new GraphqlExtractionError({\n message: `Failed to extract GraphQL schema: ${err instanceof Error ? err.message : String(err)}`,\n }),\n });\n","import { Effect, Layer, Option } from \"effect\";\nimport { HttpClient, HttpClientRequest } from \"@effect/platform\";\n\nimport {\n type ToolId,\n type ToolInvoker,\n ToolInvocationResult,\n ToolInvocationError,\n type ScopeId,\n type SecretId,\n} from \"@executor/sdk/core\";\n\nimport { GraphqlInvocationError } from \"./errors\";\nimport type { GraphqlOperationStore } from \"./operation-store\";\nimport {\n type HeaderValue,\n type OperationBinding,\n InvocationConfig,\n InvocationResult,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Header resolution — resolves secret refs at invocation time\n// ---------------------------------------------------------------------------\n\nconst resolveHeaders = (\n headers: Record<string, HeaderValue>,\n secrets: { readonly resolve: (secretId: SecretId, scopeId: ScopeId) => Effect.Effect<string, unknown> },\n scopeId: ScopeId,\n): Effect.Effect<Record<string, string>, ToolInvocationError> =>\n Effect.gen(function* () {\n const resolved: Record<string, string> = {};\n for (const [name, value] of Object.entries(headers)) {\n if (typeof value === \"string\") {\n resolved[name] = value;\n } else {\n const secret = yield* secrets.resolve(value.secretId as SecretId, scopeId).pipe(\n Effect.mapError(() =>\n new ToolInvocationError({\n toolId: \"\" as ToolId,\n message: `Failed to resolve secret \"${value.secretId}\" for header \"${name}\"`,\n cause: undefined,\n }),\n ),\n );\n resolved[name] = value.prefix ? `${value.prefix}${secret}` : secret;\n }\n }\n return resolved;\n });\n\n// ---------------------------------------------------------------------------\n// Response helpers\n// ---------------------------------------------------------------------------\n\nconst isJsonContentType = (ct: string | null | undefined): boolean => {\n if (!ct) return false;\n const normalized = ct.split(\";\")[0]?.trim().toLowerCase() ?? \"\";\n return (\n normalized === \"application/json\" ||\n normalized.includes(\"+json\") ||\n normalized.includes(\"json\")\n );\n};\n\n// ---------------------------------------------------------------------------\n// Public API — execute a GraphQL operation\n// ---------------------------------------------------------------------------\n\nexport const invoke = Effect.fn(\"GraphQL.invoke\")(function* (\n operation: OperationBinding,\n args: Record<string, unknown>,\n config: InvocationConfig,\n resolvedHeaders?: Record<string, string>,\n) {\n const client = yield* HttpClient.HttpClient;\n\n // Build the GraphQL request body\n const variables: Record<string, unknown> = {};\n for (const varName of operation.variableNames) {\n if (args[varName] !== undefined) {\n variables[varName] = args[varName];\n }\n }\n\n // Also pick up any variables from a \"variables\" container\n if (typeof args.variables === \"object\" && args.variables !== null) {\n Object.assign(variables, args.variables);\n }\n\n let request = HttpClientRequest.post(config.endpoint).pipe(\n HttpClientRequest.setHeader(\"Content-Type\", \"application/json\"),\n HttpClientRequest.bodyUnsafeJson({\n query: operation.operationString,\n variables: Object.keys(variables).length > 0 ? variables : undefined,\n }),\n );\n\n // Apply resolved headers\n if (resolvedHeaders) {\n for (const [name, value] of Object.entries(resolvedHeaders)) {\n request = HttpClientRequest.setHeader(request, name, value);\n }\n }\n\n const response = yield* client.execute(request).pipe(\n Effect.mapError(\n (err) =>\n new GraphqlInvocationError({\n message: `GraphQL request failed: ${err.message}`,\n statusCode: Option.none(),\n cause: err,\n }),\n ),\n );\n\n const status = response.status;\n const contentType = response.headers[\"content-type\"] ?? null;\n\n const body: unknown = isJsonContentType(contentType)\n ? yield* response.json.pipe(Effect.catchAll(() => response.text))\n : yield* response.text;\n\n // GraphQL responses are always 200 with { data, errors }\n const gqlBody = body as { data?: unknown; errors?: unknown[] } | null;\n const hasErrors = Array.isArray(gqlBody?.errors) && gqlBody.errors.length > 0;\n\n return new InvocationResult({\n status,\n data: gqlBody?.data ?? null,\n errors: hasErrors ? gqlBody!.errors : null,\n });\n});\n\n// ---------------------------------------------------------------------------\n// ToolInvoker — bridges operation store + HTTP client into SDK invoker\n// ---------------------------------------------------------------------------\n\nexport const makeGraphqlInvoker = (opts: {\n readonly operationStore: GraphqlOperationStore;\n readonly httpClientLayer: Layer.Layer<HttpClient.HttpClient>;\n readonly secrets: { readonly resolve: (secretId: SecretId, scopeId: ScopeId) => Effect.Effect<string, unknown> };\n readonly scopeId: ScopeId;\n}): ToolInvoker => ({\n resolveAnnotations: (toolId: ToolId) =>\n Effect.gen(function* () {\n const entry = yield* opts.operationStore.get(toolId);\n if (!entry) return undefined;\n // Mutations require approval, queries don't\n if (entry.binding.kind === \"mutation\") {\n return {\n requiresApproval: true,\n approvalDescription: `mutation ${entry.binding.fieldName}`,\n };\n }\n return {};\n }),\n\n invoke: (toolId: ToolId, args: unknown) =>\n Effect.gen(function* () {\n const entry = yield* opts.operationStore.get(toolId);\n if (!entry) {\n return yield* new ToolInvocationError({\n toolId,\n message: `No GraphQL operation found for tool \"${toolId}\"`,\n cause: undefined,\n });\n }\n\n const { binding, config } = entry;\n\n // Resolve secret-backed headers\n const resolvedHeaders = yield* resolveHeaders(\n config.headers,\n opts.secrets,\n opts.scopeId,\n );\n\n const result = yield* invoke(\n binding,\n (args ?? {}) as Record<string, unknown>,\n config,\n resolvedHeaders,\n ).pipe(Effect.provide(opts.httpClientLayer));\n\n return new ToolInvocationResult({\n data: result.data,\n error: result.errors,\n status: result.status,\n });\n }).pipe(\n Effect.catchAll((err) => {\n if (\n typeof err === \"object\" &&\n err !== null &&\n \"_tag\" in err &&\n (err as { _tag: string })._tag === \"ToolInvocationError\"\n ) {\n return Effect.fail(err as ToolInvocationError);\n }\n return Effect.fail(\n new ToolInvocationError({\n toolId,\n message: `GraphQL invocation failed: ${err instanceof Error ? err.message : String(err)}`,\n cause: err,\n }),\n );\n }),\n ),\n});\n","// ---------------------------------------------------------------------------\n// KV-backed GraphqlOperationStore\n// ---------------------------------------------------------------------------\n\nimport { Effect, Schema } from \"effect\";\nimport { scopeKv, makeInMemoryScopedKv, type Kv, type ToolId, type ScopedKv } from \"@executor/sdk/core\";\n\nimport type { GraphqlOperationStore, StoredSource } from \"./operation-store\";\nimport { OperationBinding, InvocationConfig, HeaderValue } from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Stored schemas\n// ---------------------------------------------------------------------------\n\nclass StoredEntry extends Schema.Class<StoredEntry>(\"StoredEntry\")({\n namespace: Schema.String,\n binding: OperationBinding,\n config: InvocationConfig,\n}) {}\n\nconst encodeEntry = Schema.encodeSync(Schema.parseJson(StoredEntry));\nconst decodeEntry = Schema.decodeUnknownSync(Schema.parseJson(StoredEntry));\n\nconst StoredSourceSchema = Schema.Struct({\n namespace: Schema.String,\n name: Schema.String,\n config: Schema.Struct({\n endpoint: Schema.String,\n introspectionJson: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(\n Schema.Record({ key: Schema.String, value: HeaderValue }),\n ),\n }),\n});\nconst encodeSource = Schema.encodeSync(Schema.parseJson(StoredSourceSchema));\nconst decodeSource = Schema.decodeUnknownSync(Schema.parseJson(StoredSourceSchema));\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\nconst makeStore = (\n bindings: ScopedKv,\n sources: ScopedKv,\n): GraphqlOperationStore => ({\n get: (toolId) =>\n Effect.gen(function* () {\n const raw = yield* bindings.get(toolId);\n if (!raw) return null;\n const entry = decodeEntry(raw);\n return { binding: entry.binding, config: entry.config };\n }),\n\n put: (toolId, namespace, binding, config) =>\n bindings.set(\n toolId,\n encodeEntry(new StoredEntry({ namespace, binding, config })),\n ),\n\n remove: (toolId) => bindings.delete(toolId).pipe(Effect.asVoid),\n\n listByNamespace: (namespace) =>\n Effect.gen(function* () {\n const entries = yield* bindings.list();\n const ids: ToolId[] = [];\n for (const e of entries) {\n const entry = decodeEntry(e.value);\n if (entry.namespace === namespace) ids.push(e.key as ToolId);\n }\n return ids;\n }),\n\n removeByNamespace: (namespace) =>\n Effect.gen(function* () {\n const entries = yield* bindings.list();\n const ids: ToolId[] = [];\n for (const e of entries) {\n const entry = decodeEntry(e.value);\n if (entry.namespace === namespace) {\n ids.push(e.key as ToolId);\n yield* bindings.delete(e.key);\n }\n }\n return ids;\n }),\n\n putSource: (source) =>\n sources.set(source.namespace, encodeSource(source)),\n\n removeSource: (namespace) =>\n sources.delete(namespace).pipe(Effect.asVoid),\n\n listSources: () =>\n Effect.gen(function* () {\n const entries = yield* sources.list();\n return entries.map((e) => decodeSource(e.value) as StoredSource);\n }),\n});\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nexport const makeKvOperationStore = (\n kv: Kv,\n namespace: string,\n): GraphqlOperationStore =>\n makeStore(\n scopeKv(kv, `${namespace}.bindings`),\n scopeKv(kv, `${namespace}.sources`),\n );\n\nexport const makeInMemoryOperationStore = (): GraphqlOperationStore =>\n makeStore(\n makeInMemoryScopedKv(),\n makeInMemoryScopedKv(),\n );\n","import { Effect, Option, Schema } from \"effect\";\nimport { FetchHttpClient, HttpClient } from \"@effect/platform\";\nimport type { Layer } from \"effect\";\n\nimport {\n Source,\n SourceDetectionResult,\n definePlugin,\n registerRuntimeTools,\n runtimeTool,\n type ExecutorPlugin,\n type PluginContext,\n ToolId,\n type SecretId,\n type ToolRegistration,\n} from \"@executor/sdk/core\";\n\nimport { introspect, parseIntrospectionJson, type IntrospectionResult, type IntrospectionType, type IntrospectionField } from \"./introspect\";\nimport { extract } from \"./extract\";\nimport {\n GraphqlExtractionError,\n} from \"./errors\";\nimport { makeGraphqlInvoker } from \"./invoke\";\nimport type { GraphqlOperationStore } from \"./operation-store\";\nimport { makeInMemoryOperationStore } from \"./kv-operation-store\";\nimport {\n ExtractedField,\n HeaderValue as HeaderValueSchema,\n InvocationConfig,\n OperationBinding,\n type HeaderValue as HeaderValueValue,\n type GraphqlOperationKind,\n} from \"./types\";\n\n// ---------------------------------------------------------------------------\n// Plugin config\n// ---------------------------------------------------------------------------\n\nexport type HeaderValue = HeaderValueValue;\n\nexport interface GraphqlSourceConfig {\n /** The GraphQL endpoint URL */\n readonly endpoint: string;\n /** Optional: introspection JSON text (if endpoint doesn't support introspection) */\n readonly introspectionJson?: string;\n /** Namespace for the tools (derived from endpoint if not provided) */\n readonly namespace?: string;\n /** Headers applied to every request. Values can reference secrets. */\n readonly headers?: Record<string, HeaderValue>;\n}\n\n// ---------------------------------------------------------------------------\n// Plugin extension\n// ---------------------------------------------------------------------------\n\nexport interface GraphqlPluginExtension {\n /** Add a GraphQL endpoint and register its operations as tools */\n readonly addSource: (\n config: GraphqlSourceConfig,\n ) => Effect.Effect<{ readonly toolCount: number }, Error>;\n\n /** Remove all tools from a previously added GraphQL source by namespace */\n readonly removeSource: (namespace: string) => Effect.Effect<void>;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst AddSourceInputSchema = Schema.Struct({\n endpoint: Schema.String,\n introspectionJson: Schema.optional(Schema.String),\n namespace: Schema.optional(Schema.String),\n headers: Schema.optional(\n Schema.Record({ key: Schema.String, value: HeaderValueSchema }),\n ),\n});\ntype AddSourceInput = typeof AddSourceInputSchema.Type;\n\nconst AddSourceOutputSchema = Schema.Struct({\n sourceId: Schema.String,\n toolCount: Schema.Number,\n});\n\n/** Derive a namespace from an endpoint URL */\nconst namespaceFromEndpoint = (endpoint: string): string => {\n try {\n const url = new URL(endpoint);\n return url.hostname.replace(/[^a-z0-9]+/gi, \"_\").toLowerCase();\n } catch {\n return \"graphql\";\n }\n};\n\nconst buildOperationStringForField = (\n kind: GraphqlOperationKind,\n field: IntrospectionField,\n types: ReadonlyMap<string, IntrospectionType>,\n): string => {\n const opType = kind === \"query\" ? \"query\" : \"mutation\";\n\n const varDefs = field.args.map((arg) => {\n const typeName = formatTypeRef(arg.type);\n return `$${arg.name}: ${typeName}`;\n });\n\n const argPasses = field.args.map((arg) => `${arg.name}: $${arg.name}`);\n const selectionSet = buildSelectionSet(field.type, types, 0, new Set());\n\n const varDefsStr = varDefs.length > 0 ? `(${varDefs.join(\", \")})` : \"\";\n const argPassStr = argPasses.length > 0 ? `(${argPasses.join(\", \")})` : \"\";\n\n return `${opType}${varDefsStr} { ${field.name}${argPassStr}${selectionSet ? ` ${selectionSet}` : \"\"} }`;\n};\n\nimport type { IntrospectionTypeRef } from \"./introspect\";\n\nconst formatTypeRef = (ref: IntrospectionTypeRef): string => {\n switch (ref.kind) {\n case \"NON_NULL\":\n return ref.ofType ? `${formatTypeRef(ref.ofType)}!` : \"Unknown!\";\n case \"LIST\":\n return ref.ofType ? `[${formatTypeRef(ref.ofType)}]` : \"[Unknown]\";\n default:\n return ref.name ?? \"Unknown\";\n }\n};\n\nconst unwrapTypeName = (ref: IntrospectionTypeRef): string => {\n if (ref.name) return ref.name;\n if (ref.ofType) return unwrapTypeName(ref.ofType);\n return \"Unknown\";\n};\n\nconst buildSelectionSet = (\n ref: IntrospectionTypeRef,\n types: ReadonlyMap<string, IntrospectionType>,\n depth: number,\n seen: Set<string>,\n): string => {\n if (depth > 2) return \"\";\n\n const leafName = unwrapTypeName(ref);\n if (seen.has(leafName)) return \"\";\n\n const objectType = types.get(leafName);\n if (!objectType?.fields) return \"\";\n\n const kind = objectType.kind;\n if (kind === \"SCALAR\" || kind === \"ENUM\") return \"\";\n\n seen.add(leafName);\n\n const subFields = objectType.fields\n .filter((f) => !f.name.startsWith(\"__\"))\n .slice(0, 12)\n .map((f) => {\n const sub = buildSelectionSet(f.type, types, depth + 1, seen);\n return sub ? `${f.name} ${sub}` : f.name;\n });\n\n seen.delete(leafName);\n\n return subFields.length > 0 ? `{ ${subFields.join(\" \")} }` : \"\";\n};\n\nconst toRegistration = (\n field: ExtractedField,\n namespace: string,\n): ToolRegistration => {\n const prefix = field.kind === \"mutation\" ? \"mutation\" : \"query\";\n const toolPath = `${prefix}.${field.fieldName}`;\n const description = Option.getOrElse(field.description, () =>\n `GraphQL ${field.kind}: ${field.fieldName} -> ${field.returnTypeName}`,\n );\n\n return {\n id: ToolId.make(`${namespace}.${toolPath}`),\n pluginKey: \"graphql\",\n sourceId: namespace,\n name: toolPath,\n description,\n inputSchema: Option.getOrUndefined(field.inputSchema),\n outputSchema: undefined,\n };\n};\n\n// ---------------------------------------------------------------------------\n// Plugin factory\n// ---------------------------------------------------------------------------\n\nexport const graphqlPlugin = (options?: {\n readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient>;\n readonly operationStore?: GraphqlOperationStore;\n}): ExecutorPlugin<\"graphql\", GraphqlPluginExtension> => {\n const httpClientLayer = options?.httpClientLayer ?? FetchHttpClient.layer;\n const operationStore =\n options?.operationStore ?? makeInMemoryOperationStore();\n\n return definePlugin({\n key: \"graphql\",\n init: (ctx: PluginContext) =>\n Effect.gen(function* () {\n yield* ctx.tools.registerInvoker(\n \"graphql\",\n makeGraphqlInvoker({\n operationStore,\n httpClientLayer,\n secrets: ctx.secrets,\n scopeId: ctx.scope.id,\n }),\n );\n\n yield* ctx.sources.addManager({\n kind: \"graphql\",\n\n list: () =>\n operationStore.listSources().pipe(\n Effect.map((metas) =>\n metas.map(\n (s) =>\n new Source({\n id: s.namespace,\n name: s.name,\n kind: \"graphql\",\n runtime: false,\n canRemove: true,\n canRefresh: false,\n }),\n ),\n ),\n ),\n\n remove: (sourceId: string) =>\n Effect.gen(function* () {\n yield* operationStore.removeByNamespace(sourceId);\n yield* operationStore.removeSource(sourceId);\n yield* ctx.tools.unregisterBySource(sourceId);\n }),\n\n detect: (url: string) =>\n Effect.gen(function* () {\n const trimmed = url.trim();\n if (!trimmed) return null;\n const parsed = yield* Effect.try(() => new URL(trimmed)).pipe(Effect.option);\n if (parsed._tag === \"None\") return null;\n\n const ok = yield* introspect(trimmed).pipe(\n Effect.provide(httpClientLayer),\n Effect.map(() => true),\n Effect.catchAll(() => Effect.succeed(false)),\n );\n\n if (!ok) return null;\n\n const name = namespaceFromEndpoint(trimmed);\n return new SourceDetectionResult({\n kind: \"graphql\",\n confidence: \"high\",\n endpoint: trimmed,\n name,\n namespace: name,\n });\n }),\n });\n\n const addSourceInternal = (config: GraphqlSourceConfig) =>\n Effect.gen(function* () {\n // Get introspection result — either by querying the endpoint or parsing provided JSON\n let introspectionResult: IntrospectionResult;\n if (config.introspectionJson) {\n introspectionResult = yield* parseIntrospectionJson(config.introspectionJson);\n } else {\n // Resolve all headers (including secret refs) for introspection\n const resolvedHeaders: Record<string, string> = {};\n if (config.headers) {\n for (const [name, value] of Object.entries(config.headers)) {\n if (typeof value === \"string\") {\n resolvedHeaders[name] = value;\n } else {\n const secret = yield* ctx.secrets\n .resolve(value.secretId as SecretId, ctx.scope.id)\n .pipe(Effect.catchAll(() => Effect.succeed(\"\")));\n if (secret) {\n resolvedHeaders[name] = value.prefix\n ? `${value.prefix}${secret}`\n : secret;\n }\n }\n }\n }\n\n introspectionResult = yield* introspect(\n config.endpoint,\n Object.keys(resolvedHeaders).length > 0 ? resolvedHeaders : undefined,\n ).pipe(Effect.provide(httpClientLayer));\n }\n\n const { result, definitions } = yield* extract(introspectionResult);\n const namespace = config.namespace ?? namespaceFromEndpoint(config.endpoint);\n\n // Register shared JSON Schema definitions ($ref targets)\n if (Object.keys(definitions).length > 0) {\n yield* ctx.tools.registerDefinitions(definitions);\n }\n\n const invocationConfig = new InvocationConfig({\n endpoint: config.endpoint,\n headers: config.headers ?? {},\n });\n\n // Build type map for operation string generation\n const typeMap = new Map<string, IntrospectionType>();\n for (const t of introspectionResult.__schema.types) {\n typeMap.set(t.name, t);\n }\n\n // Build field map for operation strings\n const fieldMap = new Map<string, { kind: GraphqlOperationKind; field: IntrospectionField }>();\n const schema = introspectionResult.__schema;\n\n for (const rootKind of [\"query\", \"mutation\"] as const) {\n const typeName = rootKind === \"query\"\n ? schema.queryType?.name\n : schema.mutationType?.name;\n if (!typeName) continue;\n const rootType = typeMap.get(typeName);\n if (!rootType?.fields) continue;\n for (const f of rootType.fields) {\n if (!f.name.startsWith(\"__\")) {\n fieldMap.set(`${rootKind}.${f.name}`, { kind: rootKind, field: f });\n }\n }\n }\n\n const registrations: ToolRegistration[] = [];\n\n yield* Effect.forEach(\n result.fields,\n (extractedField) => {\n const reg = toRegistration(extractedField, namespace);\n registrations.push(reg);\n\n const key = `${extractedField.kind}.${extractedField.fieldName}`;\n const entry = fieldMap.get(key);\n\n const operationString = entry\n ? buildOperationStringForField(entry.kind, entry.field, typeMap)\n : `${extractedField.kind} { ${extractedField.fieldName} }`;\n\n const binding = new OperationBinding({\n kind: extractedField.kind,\n fieldName: extractedField.fieldName,\n operationString,\n variableNames: extractedField.arguments.map((a) => a.name),\n });\n\n return operationStore.put(reg.id, namespace, binding, invocationConfig);\n },\n { discard: true },\n );\n\n yield* ctx.tools.register(registrations);\n\n yield* operationStore.putSource({\n namespace,\n name: namespace,\n config: {\n endpoint: config.endpoint,\n introspectionJson: config.introspectionJson,\n namespace: config.namespace,\n headers: config.headers,\n },\n });\n\n return { sourceId: namespace, toolCount: registrations.length };\n });\n\n const runtimeTools = yield* registerRuntimeTools({\n registry: ctx.tools,\n sources: ctx.sources,\n pluginKey: \"graphql\",\n source: {\n id: \"built-in\",\n name: \"Built In\",\n kind: \"built-in\",\n },\n tools: [\n runtimeTool({\n id: \"graphql.addSource\",\n name: \"graphql.addSource\",\n description:\n \"Add a GraphQL endpoint and register its operations as tools\",\n inputSchema: AddSourceInputSchema,\n outputSchema: AddSourceOutputSchema,\n handler: (input: AddSourceInput) => addSourceInternal(input),\n }),\n ],\n });\n\n return {\n extension: {\n addSource: (config: GraphqlSourceConfig) =>\n addSourceInternal(config).pipe(\n Effect.map(({ toolCount }) => ({ toolCount })),\n Effect.mapError(\n (err) =>\n new GraphqlExtractionError({\n message:\n err instanceof Error ? err.message : String(err),\n }),\n ),\n ),\n\n removeSource: (namespace: string) =>\n Effect.gen(function* () {\n const toolIds =\n yield* operationStore.removeByNamespace(namespace);\n if (toolIds.length > 0) {\n yield* ctx.tools.unregister(toolIds);\n }\n yield* operationStore.removeSource(namespace);\n }),\n },\n\n close: () => runtimeTools.close(),\n };\n }),\n });\n};\n"],"mappings":";AAAA,SAAS,MAAM,cAAc;AAGtB,IAAM,4BAAN,cAAwC,OAAO,YAAuC;AAAA,EAC3F;AAAA,EACA;AAAA,IACE,SAAS,OAAO;AAAA,EAClB;AACF,EAAE;AAAC;AAEI,IAAM,yBAAN,cAAqC,OAAO,YAAoC;AAAA,EACrF;AAAA,EACA;AAAA,IACE,SAAS,OAAO;AAAA,EAClB;AACF,EAAE;AAAC;AAEI,IAAM,yBAAN,cAAqC,KAAK;AAAA,EAC/C;AACF,EAIG;AAAC;;;ACvBJ,SAAS,cAAc;AACvB,SAAS,YAAY,yBAAyB;AAQ9C,IAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0HrB,IAAM,aAAa,OAAO,GAAG,oBAAoB,EAAE,WACxD,UACA,SACA;AACA,QAAM,SAAS,OAAO,WAAW;AAEjC,MAAI,UAAU,kBAAkB,KAAK,QAAQ,EAAE;AAAA,IAC7C,kBAAkB,UAAU,gBAAgB,kBA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UAAU,WAAW,WAAW,cAAc,OAAO;AAAA,MAChE,CAAC;AAEH,YAAM,eAAe,OAAO,qBAAqB;AAAA,QAC/C,UAAU,IAAI;AAAA,QACd,SAAS,IAAI;AAAA,QACb,WAAW;AAAA,QACX,QAAQ;AAAA,UACN,IAAI;AAAA,UACJ,MAAM;AAAA,UACN,MAAM;AAAA,QACR;AAAA,QACA,OAAO;AAAA,UACL,YAAY;AAAA,YACV,IAAI;AAAA,YACJ,MAAM;AAAA,YACN,aACE;AAAA,YACF,aAAa;AAAA,YACb,cAAc;AAAA,YACd,SAAS,CAAC,UAA0B,kBAAkB,KAAK;AAAA,UAC7D,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAED,aAAO;AAAA,QACL,WAAW;AAAA,UACT,WAAW,CAAC,WACV,kBAAkB,MAAM,EAAE;AAAA,YACxBA,QAAO,IAAI,CAAC,EAAE,UAAU,OAAO,EAAE,UAAU,EAAE;AAAA,YAC7CA,QAAO;AAAA,cACL,CAAC,QACC,IAAI,uBAAuB;AAAA,gBACzB,SACE,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,cACnD,CAAC;AAAA,YACL;AAAA,UACF;AAAA,UAEF,cAAc,CAAC,cACbA,QAAO,IAAI,aAAa;AACtB,kBAAM,UACJ,OAAO,eAAe,kBAAkB,SAAS;AACnD,gBAAI,QAAQ,SAAS,GAAG;AACtB,qBAAO,IAAI,MAAM,WAAW,OAAO;AAAA,YACrC;AACA,mBAAO,eAAe,aAAa,SAAS;AAAA,UAC9C,CAAC;AAAA,QACL;AAAA,QAEA,OAAO,MAAM,aAAa,MAAM;AAAA,MAClC;AAAA,IACF,CAAC;AAAA,EACL,CAAC;AACH;","names":["Schema","Effect","Effect","Effect","Option","HttpClient","HttpClientRequest","Effect","HttpClient","HttpClientRequest","Option","Effect","Schema","Schema","Effect","Effect","Option","Schema","Schema","formatTypeRef","unwrapTypeName","Option","Effect"]}
|