@executor-js/plugin-graphql 0.0.1 → 0.0.2

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 CHANGED
@@ -1,51 +1,62 @@
1
- # @executor/plugin-graphql
1
+ # @executor-js/plugin-graphql
2
2
 
3
3
  Introspect a GraphQL endpoint and expose its queries and mutations as invokable tools on an executor.
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```sh
8
- bun add @executor/sdk @executor/plugin-graphql
8
+ bun add @executor-js/sdk @executor-js/plugin-graphql
9
9
  # or
10
- npm install @executor/sdk @executor/plugin-graphql
10
+ npm install @executor-js/sdk @executor-js/plugin-graphql
11
11
  ```
12
12
 
13
13
  ## Usage
14
14
 
15
15
  ```ts
16
- import { createExecutor } from "@executor/sdk";
17
- import { graphqlPlugin } from "@executor/plugin-graphql";
16
+ import { createExecutor } from "@executor-js/sdk";
17
+ import { graphqlPlugin } from "@executor-js/plugin-graphql";
18
18
 
19
19
  const executor = await createExecutor({
20
- scope: { name: "my-app" },
20
+ onElicitation: "accept-all",
21
21
  plugins: [graphqlPlugin()] as const,
22
22
  });
23
23
 
24
24
  // Public endpoint — no auth
25
25
  await executor.graphql.addSource({
26
+ scope: executor.scopes[0]!.id,
26
27
  endpoint: "https://graphql.anilist.co",
27
28
  namespace: "anilist",
28
29
  });
29
30
 
30
31
  const tools = await executor.tools.list();
31
- const result = await executor.tools.invoke(
32
- "anilist.Media",
33
- { search: "Frieren" },
34
- { onElicitation: "accept-all" },
35
- );
32
+ const result = await executor.tools.invoke("anilist.Media", {
33
+ search: "Frieren",
34
+ });
36
35
  ```
37
36
 
38
37
  ## Secret-backed auth
39
38
 
40
39
  ```ts
40
+ import { createExecutor } from "@executor-js/sdk";
41
+ import { graphqlPlugin } from "@executor-js/plugin-graphql";
42
+ import { fileSecretsPlugin } from "@executor-js/plugin-file-secrets";
43
+
44
+ const executor = await createExecutor({
45
+ onElicitation: "accept-all",
46
+ plugins: [fileSecretsPlugin(), graphqlPlugin()] as const,
47
+ });
48
+
49
+ const scope = executor.scopes[0]!.id;
50
+
41
51
  await executor.secrets.set({
42
52
  id: "github-token",
43
53
  name: "GitHub Token",
44
54
  value: "ghp_...",
45
- purpose: "authentication",
55
+ scope,
46
56
  });
47
57
 
48
58
  await executor.graphql.addSource({
59
+ scope,
49
60
  endpoint: "https://api.github.com/graphql",
50
61
  namespace: "github",
51
62
  headers: {
@@ -56,10 +67,10 @@ await executor.graphql.addSource({
56
67
 
57
68
  ## Using with Effect
58
69
 
59
- If you're building on `@executor/sdk` (the raw Effect entry), import this plugin from its `/core` subpath instead:
70
+ If you're building on `@executor-js/sdk/core` (the raw Effect entry), import this plugin from its `/core` subpath instead — it returns the Effect-shaped plugin with `Effect.Effect<...>`-returning methods rather than promisified wrappers:
60
71
 
61
72
  ```ts
62
- import { graphqlPlugin } from "@executor/plugin-graphql";
73
+ import { graphqlPlugin } from "@executor-js/plugin-graphql/core";
63
74
  ```
64
75
 
65
76
  ## Status
@@ -1,34 +1,139 @@
1
- import { HttpApiEndpoint, HttpApiGroup } from "@effect/platform";
1
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
2
+ import { Schema } from "effect";
3
+ import { InternalError } from "@executor-js/api";
2
4
  import { GraphqlIntrospectionError, GraphqlExtractionError } from "../sdk/errors";
3
- import { StoredSourceSchema } from "../sdk/stored-source";
4
- declare const GraphqlGroup_base: HttpApiGroup.HttpApiGroup<"graphql", HttpApiEndpoint.HttpApiEndpoint<"addSource", "POST", {
5
- readonly scopeId: string & import("effect/Brand").Brand<"ScopeId">;
6
- }, never, {
7
- readonly name?: string | undefined;
8
- readonly endpoint: string;
9
- readonly namespace?: string | undefined;
10
- readonly headers?: {
11
- readonly [x: string]: unknown;
12
- } | undefined;
13
- readonly introspectionJson?: string | undefined;
14
- }, never, {
15
- readonly namespace: string;
16
- readonly toolCount: number;
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>;
32
- export declare class GraphqlGroup extends GraphqlGroup_base {
33
- }
34
- export {};
5
+ export declare const StoredSourceSchema: Schema.Struct<{
6
+ readonly namespace: Schema.String;
7
+ readonly name: Schema.String;
8
+ readonly endpoint: Schema.String;
9
+ readonly headers: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
10
+ readonly secretId: Schema.String;
11
+ readonly prefix: Schema.optional<Schema.String>;
12
+ }>]>>;
13
+ readonly queryParams: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
14
+ readonly secretId: Schema.String;
15
+ readonly prefix: Schema.optional<Schema.String>;
16
+ }>]>>;
17
+ readonly auth: Schema.Union<readonly [Schema.Struct<{
18
+ readonly kind: Schema.Literal<"none">;
19
+ }>, Schema.Struct<{
20
+ readonly kind: Schema.Literal<"oauth2">;
21
+ readonly connectionId: Schema.String;
22
+ }>]>;
23
+ }>;
24
+ export declare const GraphqlGroup: HttpApiGroup.HttpApiGroup<"graphql", HttpApiEndpoint.HttpApiEndpoint<"addSource", "POST", "/scopes/:scopeId/graphql/sources", HttpApiEndpoint.StringTree<Schema.Struct<{
25
+ scopeId: Schema.brand<Schema.String, "ScopeId">;
26
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
27
+ readonly endpoint: Schema.String;
28
+ readonly name: Schema.optional<Schema.String>;
29
+ readonly introspectionJson: Schema.optional<Schema.String>;
30
+ readonly namespace: Schema.optional<Schema.String>;
31
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
32
+ readonly queryParams: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
33
+ readonly auth: Schema.optional<Schema.Union<readonly [Schema.Struct<{
34
+ readonly kind: Schema.Literal<"none">;
35
+ }>, Schema.Struct<{
36
+ readonly kind: Schema.Literal<"oauth2">;
37
+ readonly connectionId: Schema.String;
38
+ }>]>>;
39
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
40
+ readonly toolCount: Schema.Number;
41
+ readonly namespace: Schema.String;
42
+ }>>, HttpApiEndpoint.Json<typeof InternalError | Schema.decodeTo<Schema.declareConstructor<GraphqlIntrospectionError, {
43
+ readonly message: string;
44
+ readonly _tag: "GraphqlIntrospectionError";
45
+ }, readonly [Schema.TaggedStruct<"GraphqlIntrospectionError", {
46
+ readonly message: Schema.String;
47
+ }>], {
48
+ readonly message: string;
49
+ readonly _tag: "GraphqlIntrospectionError";
50
+ }>, Schema.TaggedStruct<"GraphqlIntrospectionError", {
51
+ readonly message: Schema.String;
52
+ }>, never, never> | Schema.decodeTo<Schema.declareConstructor<GraphqlExtractionError, {
53
+ readonly message: string;
54
+ readonly _tag: "GraphqlExtractionError";
55
+ }, readonly [Schema.TaggedStruct<"GraphqlExtractionError", {
56
+ readonly message: Schema.String;
57
+ }>], {
58
+ readonly message: string;
59
+ readonly _tag: "GraphqlExtractionError";
60
+ }>, Schema.TaggedStruct<"GraphqlExtractionError", {
61
+ readonly message: Schema.String;
62
+ }>, never, never>>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getSource", "GET", "/scopes/:scopeId/graphql/sources/:namespace", HttpApiEndpoint.StringTree<Schema.Struct<{
63
+ scopeId: Schema.brand<Schema.String, "ScopeId">;
64
+ namespace: Schema.String;
65
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.NullOr<Schema.Struct<{
66
+ readonly namespace: Schema.String;
67
+ readonly name: Schema.String;
68
+ readonly endpoint: Schema.String;
69
+ readonly headers: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
70
+ readonly secretId: Schema.String;
71
+ readonly prefix: Schema.optional<Schema.String>;
72
+ }>]>>;
73
+ readonly queryParams: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
74
+ readonly secretId: Schema.String;
75
+ readonly prefix: Schema.optional<Schema.String>;
76
+ }>]>>;
77
+ readonly auth: Schema.Union<readonly [Schema.Struct<{
78
+ readonly kind: Schema.Literal<"none">;
79
+ }>, Schema.Struct<{
80
+ readonly kind: Schema.Literal<"oauth2">;
81
+ readonly connectionId: Schema.String;
82
+ }>]>;
83
+ }>>>, HttpApiEndpoint.Json<typeof InternalError | Schema.decodeTo<Schema.declareConstructor<GraphqlIntrospectionError, {
84
+ readonly message: string;
85
+ readonly _tag: "GraphqlIntrospectionError";
86
+ }, readonly [Schema.TaggedStruct<"GraphqlIntrospectionError", {
87
+ readonly message: Schema.String;
88
+ }>], {
89
+ readonly message: string;
90
+ readonly _tag: "GraphqlIntrospectionError";
91
+ }>, Schema.TaggedStruct<"GraphqlIntrospectionError", {
92
+ readonly message: Schema.String;
93
+ }>, never, never> | Schema.decodeTo<Schema.declareConstructor<GraphqlExtractionError, {
94
+ readonly message: string;
95
+ readonly _tag: "GraphqlExtractionError";
96
+ }, readonly [Schema.TaggedStruct<"GraphqlExtractionError", {
97
+ readonly message: Schema.String;
98
+ }>], {
99
+ readonly message: string;
100
+ readonly _tag: "GraphqlExtractionError";
101
+ }>, Schema.TaggedStruct<"GraphqlExtractionError", {
102
+ readonly message: Schema.String;
103
+ }>, never, never>>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"updateSource", "PATCH", "/scopes/:scopeId/graphql/sources/:namespace", HttpApiEndpoint.StringTree<Schema.Struct<{
104
+ scopeId: Schema.brand<Schema.String, "ScopeId">;
105
+ namespace: Schema.String;
106
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
107
+ readonly name: Schema.optional<Schema.String>;
108
+ readonly endpoint: Schema.optional<Schema.String>;
109
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
110
+ readonly queryParams: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
111
+ readonly auth: Schema.optional<Schema.Union<readonly [Schema.Struct<{
112
+ readonly kind: Schema.Literal<"none">;
113
+ }>, Schema.Struct<{
114
+ readonly kind: Schema.Literal<"oauth2">;
115
+ readonly connectionId: Schema.String;
116
+ }>]>>;
117
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
118
+ readonly updated: Schema.Boolean;
119
+ }>>, HttpApiEndpoint.Json<typeof InternalError | Schema.decodeTo<Schema.declareConstructor<GraphqlIntrospectionError, {
120
+ readonly message: string;
121
+ readonly _tag: "GraphqlIntrospectionError";
122
+ }, readonly [Schema.TaggedStruct<"GraphqlIntrospectionError", {
123
+ readonly message: Schema.String;
124
+ }>], {
125
+ readonly message: string;
126
+ readonly _tag: "GraphqlIntrospectionError";
127
+ }>, Schema.TaggedStruct<"GraphqlIntrospectionError", {
128
+ readonly message: Schema.String;
129
+ }>, never, never> | Schema.decodeTo<Schema.declareConstructor<GraphqlExtractionError, {
130
+ readonly message: string;
131
+ readonly _tag: "GraphqlExtractionError";
132
+ }, readonly [Schema.TaggedStruct<"GraphqlExtractionError", {
133
+ readonly message: Schema.String;
134
+ }>], {
135
+ readonly message: string;
136
+ readonly _tag: "GraphqlExtractionError";
137
+ }>, Schema.TaggedStruct<"GraphqlExtractionError", {
138
+ readonly message: Schema.String;
139
+ }>, never, never>>, never, never>, false>;
@@ -1,7 +1,7 @@
1
1
  import { Context } from "effect";
2
2
  import type { GraphqlPluginExtension } from "../sdk/plugin";
3
- declare const GraphqlExtensionService_base: Context.TagClass<GraphqlExtensionService, "GraphqlExtensionService", GraphqlPluginExtension>;
3
+ declare const GraphqlExtensionService_base: Context.ServiceClass<GraphqlExtensionService, "GraphqlExtensionService", GraphqlPluginExtension>;
4
4
  export declare class GraphqlExtensionService extends GraphqlExtensionService_base {
5
5
  }
6
- export declare const GraphqlHandlers: import("effect/Layer").Layer<import("@effect/platform/HttpApiGroup").ApiGroup<"executor", "graphql">, never, GraphqlExtensionService>;
6
+ export declare const GraphqlHandlers: import("effect/Layer").Layer<import("effect/unstable/httpapi/HttpApiGroup").ApiGroup<"executor", "graphql">, never, import("effect/unstable/http/HttpRouter").Request<"Requires", GraphqlExtensionService>>;
7
7
  export {};