@executor-js/plugin-graphql 0.0.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AddGraphqlSource-LGXJQEAR.js +239 -0
- package/dist/AddGraphqlSource-LGXJQEAR.js.map +1 -0
- package/dist/EditGraphqlSource-5Y47ZAZ7.js +251 -0
- package/dist/EditGraphqlSource-5Y47ZAZ7.js.map +1 -0
- package/dist/GraphqlSourceSummary-F3JWR4YN.js +70 -0
- package/dist/GraphqlSourceSummary-F3JWR4YN.js.map +1 -0
- package/dist/api/group.d.ts +169 -13
- package/dist/api/handlers.d.ts +15 -3
- package/dist/api/index.d.ts +410 -0
- package/dist/chunk-7QSGNR4C.js +162 -0
- package/dist/chunk-7QSGNR4C.js.map +1 -0
- package/dist/chunk-HDPYOBBG.js +1633 -0
- package/dist/chunk-HDPYOBBG.js.map +1 -0
- package/dist/chunk-M4SJY6CB.js +45 -0
- package/dist/chunk-M4SJY6CB.js.map +1 -0
- package/dist/chunk-WPRU5C6M.js +182 -0
- package/dist/chunk-WPRU5C6M.js.map +1 -0
- package/dist/client.js +75 -0
- package/dist/client.js.map +1 -0
- package/dist/core.js +32 -10
- package/dist/index.js +2 -1
- package/dist/react/GraphqlSourceFields.d.ts +8 -0
- package/dist/react/GraphqlSourceSummary.d.ts +3 -1
- package/dist/react/atoms.d.ts +170 -10
- package/dist/react/client.d.ts +160 -341
- package/dist/react/plugin-client.d.ts +2 -0
- package/dist/react/source-plugin.d.ts +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/introspect.d.ts +437 -43
- package/dist/sdk/invoke.d.ts +3 -2
- package/dist/sdk/plugin.d.ts +121 -55
- package/dist/sdk/store.d.ts +84 -11
- package/dist/sdk/types.d.ts +107 -3
- package/dist/testing/index.d.ts +52 -0
- package/dist/testing.js +131 -0
- package/dist/testing.js.map +1 -0
- package/package.json +18 -4
- package/dist/chunk-ILBZO52O.js +0 -1090
- package/dist/chunk-ILBZO52O.js.map +0 -1
package/dist/sdk/plugin.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { HttpClient } from "effect/unstable/http";
|
|
3
2
|
import type { Layer } from "effect";
|
|
4
|
-
import {
|
|
3
|
+
import { HttpClient } from "effect/unstable/http";
|
|
4
|
+
import { type PluginCtx, type StorageFailure } from "@executor-js/sdk/core";
|
|
5
5
|
import { type ConfigFileSink } from "@executor-js/config";
|
|
6
|
-
import {
|
|
6
|
+
import { GraphqlIntrospectionError } from "./errors";
|
|
7
7
|
import { type GraphqlStore, type StoredGraphqlSource } from "./store";
|
|
8
|
-
import { type
|
|
8
|
+
import { GraphqlSourceBindingInput, GraphqlSourceBindingRef, type ConfiguredGraphqlCredentialValue, type GraphqlCredentialInput, type HeaderValue as HeaderValueValue, type GraphqlSourceAuthInput } from "./types";
|
|
9
9
|
export type HeaderValue = HeaderValueValue;
|
|
10
|
+
export type GraphqlCredentialValue = ConfiguredGraphqlCredentialValue;
|
|
10
11
|
export interface GraphqlSourceConfig {
|
|
11
12
|
/** The GraphQL endpoint URL */
|
|
12
13
|
readonly endpoint: string;
|
|
@@ -23,50 +24,25 @@ export interface GraphqlSourceConfig {
|
|
|
23
24
|
readonly introspectionJson?: string;
|
|
24
25
|
/** Namespace for the tools (derived from endpoint if not provided) */
|
|
25
26
|
readonly namespace?: string;
|
|
26
|
-
/** Headers applied to every request.
|
|
27
|
-
readonly headers?: Record<string,
|
|
28
|
-
/** Query parameters applied to every request.
|
|
29
|
-
readonly queryParams?: Record<string,
|
|
30
|
-
/**
|
|
31
|
-
|
|
27
|
+
/** Headers applied to every request. Direct secrets are rewritten to slots. */
|
|
28
|
+
readonly headers?: Record<string, GraphqlCredentialInput>;
|
|
29
|
+
/** Query parameters applied to every request. Direct secrets are rewritten to slots. */
|
|
30
|
+
readonly queryParams?: Record<string, GraphqlCredentialInput>;
|
|
31
|
+
/**
|
|
32
|
+
* Scope that owns any direct credentials supplied on this call. Required
|
|
33
|
+
* whenever headers/queryParams/auth carry direct secret or connection ids.
|
|
34
|
+
*/
|
|
35
|
+
readonly credentialTargetScope?: string;
|
|
36
|
+
/** Optional OAuth2 credential used as a Bearer token for every request. */
|
|
37
|
+
readonly auth?: GraphqlSourceAuthInput;
|
|
32
38
|
}
|
|
33
39
|
export interface GraphqlUpdateSourceInput {
|
|
34
40
|
readonly name?: string;
|
|
35
41
|
readonly endpoint?: string;
|
|
36
|
-
readonly headers?: Record<string,
|
|
37
|
-
readonly queryParams?: Record<string,
|
|
38
|
-
readonly
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Errors any GraphQL extension method may surface. `GraphqlIntrospectionError`
|
|
42
|
-
* and `GraphqlExtractionError` are plugin-domain tagged errors that flow
|
|
43
|
-
* directly to clients (4xx, each carrying its own `HttpApiSchema` status).
|
|
44
|
-
* `StorageFailure` covers raw backend failures (`StorageError` plus
|
|
45
|
-
* `UniqueViolationError`); the HTTP edge (`@executor-js/api`'s `withCapture`)
|
|
46
|
-
* translates `StorageError` to the opaque `InternalError({ traceId })` at
|
|
47
|
-
* Layer composition.
|
|
48
|
-
*/
|
|
49
|
-
export type GraphqlExtensionFailure = GraphqlIntrospectionError | GraphqlExtractionError | StorageFailure;
|
|
50
|
-
export interface GraphqlPluginExtension {
|
|
51
|
-
/** Add a GraphQL endpoint and register its operations as tools */
|
|
52
|
-
readonly addSource: (config: GraphqlSourceConfig) => Effect.Effect<{
|
|
53
|
-
readonly toolCount: number;
|
|
54
|
-
readonly namespace: string;
|
|
55
|
-
}, GraphqlExtensionFailure>;
|
|
56
|
-
/** Remove all tools from a previously added GraphQL source by namespace.
|
|
57
|
-
* `scope` pins the cleanup to the exact row — without it a shadowed
|
|
58
|
-
* outer-scope source with the same namespace could be wiped instead. */
|
|
59
|
-
readonly removeSource: (namespace: string, scope: string) => Effect.Effect<void, StorageFailure>;
|
|
60
|
-
/** Fetch the full stored source by namespace (or null if missing).
|
|
61
|
-
* `scope` returns the exact row at that scope. For fall-through
|
|
62
|
-
* reads across the executor's scope stack, use `executor.sources.*`. */
|
|
63
|
-
readonly getSource: (namespace: string, scope: string) => Effect.Effect<StoredGraphqlSource | null, StorageFailure>;
|
|
64
|
-
/** Update config (endpoint, headers) for an existing GraphQL source.
|
|
65
|
-
* Does NOT re-introspect or re-register tools — just patches the
|
|
66
|
-
* stored endpoint/headers used at invoke time. `scope` pins the
|
|
67
|
-
* mutation to a single row so shadowed rows at other scopes are
|
|
68
|
-
* untouched. */
|
|
69
|
-
readonly updateSource: (namespace: string, scope: string, input: GraphqlUpdateSourceInput) => Effect.Effect<void, StorageFailure>;
|
|
42
|
+
readonly headers?: Record<string, GraphqlCredentialInput>;
|
|
43
|
+
readonly queryParams?: Record<string, GraphqlCredentialInput>;
|
|
44
|
+
readonly credentialTargetScope?: string;
|
|
45
|
+
readonly auth?: GraphqlSourceAuthInput;
|
|
70
46
|
}
|
|
71
47
|
export interface GraphqlPluginOptions {
|
|
72
48
|
readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient>;
|
|
@@ -74,14 +50,30 @@ export interface GraphqlPluginOptions {
|
|
|
74
50
|
* (best-effort — file errors are logged, not raised). */
|
|
75
51
|
readonly configFile?: ConfigFileSink;
|
|
76
52
|
}
|
|
53
|
+
declare const makeGraphqlExtension: (ctx: PluginCtx<GraphqlStore>, httpClientLayer: Layer.Layer<HttpClient.HttpClient>, configFile: ConfigFileSink | undefined) => {
|
|
54
|
+
addSource: (config: GraphqlSourceConfig) => Effect.Effect<{
|
|
55
|
+
toolCount: number;
|
|
56
|
+
namespace: string;
|
|
57
|
+
}, StorageFailure | GraphqlIntrospectionError | import("./errors").GraphqlExtractionError, never>;
|
|
58
|
+
removeSource: (namespace: string, scope: string) => Effect.Effect<void, StorageFailure, never>;
|
|
59
|
+
getSource: (namespace: string, scope: string) => Effect.Effect<StoredGraphqlSource | null, StorageFailure, never>;
|
|
60
|
+
updateSource: (namespace: string, scope: string, input: GraphqlUpdateSourceInput) => Effect.Effect<void, StorageFailure | GraphqlIntrospectionError, never>;
|
|
61
|
+
listSourceBindings: (sourceId: string, sourceScope: string) => Effect.Effect<readonly GraphqlSourceBindingRef[], StorageFailure, never>;
|
|
62
|
+
setSourceBinding: (input: GraphqlSourceBindingInput) => Effect.Effect<GraphqlSourceBindingRef, StorageFailure, never>;
|
|
63
|
+
removeSourceBinding: (sourceId: string, sourceScope: string, slot: string, scope: string) => Effect.Effect<void, StorageFailure, never>;
|
|
64
|
+
};
|
|
65
|
+
export type GraphqlPluginExtension = ReturnType<typeof makeGraphqlExtension>;
|
|
77
66
|
export declare const graphqlPlugin: import("@executor-js/sdk/core").ConfiguredPlugin<"graphql", {
|
|
78
67
|
addSource: (config: GraphqlSourceConfig) => Effect.Effect<{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, StorageFailure | GraphqlIntrospectionError | GraphqlExtractionError, never>;
|
|
68
|
+
toolCount: number;
|
|
69
|
+
namespace: string;
|
|
70
|
+
}, StorageFailure | GraphqlIntrospectionError | import("./errors").GraphqlExtractionError, never>;
|
|
82
71
|
removeSource: (namespace: string, scope: string) => Effect.Effect<void, StorageFailure, never>;
|
|
83
72
|
getSource: (namespace: string, scope: string) => Effect.Effect<StoredGraphqlSource | null, StorageFailure, never>;
|
|
84
|
-
updateSource: (namespace: string, scope: string, input: GraphqlUpdateSourceInput) => Effect.Effect<void, StorageFailure, never>;
|
|
73
|
+
updateSource: (namespace: string, scope: string, input: GraphqlUpdateSourceInput) => Effect.Effect<void, StorageFailure | GraphqlIntrospectionError, never>;
|
|
74
|
+
listSourceBindings: (sourceId: string, sourceScope: string) => Effect.Effect<readonly GraphqlSourceBindingRef[], StorageFailure, never>;
|
|
75
|
+
setSourceBinding: (input: GraphqlSourceBindingInput) => Effect.Effect<GraphqlSourceBindingRef, StorageFailure, never>;
|
|
76
|
+
removeSourceBinding: (sourceId: string, sourceScope: string, slot: string, scope: string) => Effect.Effect<void, StorageFailure, never>;
|
|
85
77
|
}, GraphqlStore, GraphqlPluginOptions, {
|
|
86
78
|
readonly graphql_source: {
|
|
87
79
|
readonly fields: {
|
|
@@ -102,16 +94,89 @@ export declare const graphqlPlugin: import("@executor-js/sdk/core").ConfiguredPl
|
|
|
102
94
|
readonly type: "string";
|
|
103
95
|
readonly required: true;
|
|
104
96
|
};
|
|
105
|
-
readonly
|
|
106
|
-
readonly type: "
|
|
97
|
+
readonly auth_kind: {
|
|
98
|
+
readonly type: ["none", "oauth2"];
|
|
99
|
+
readonly required: true;
|
|
100
|
+
readonly defaultValue: "none";
|
|
101
|
+
};
|
|
102
|
+
readonly auth_connection_slot: {
|
|
103
|
+
readonly type: "string";
|
|
107
104
|
readonly required: false;
|
|
108
105
|
};
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
readonly graphql_source_header: {
|
|
109
|
+
readonly fields: {
|
|
110
|
+
readonly id: {
|
|
111
|
+
readonly type: "string";
|
|
112
|
+
readonly required: true;
|
|
113
|
+
};
|
|
114
|
+
readonly scope_id: {
|
|
115
|
+
readonly type: "string";
|
|
116
|
+
readonly required: true;
|
|
117
|
+
readonly index: true;
|
|
118
|
+
};
|
|
119
|
+
readonly source_id: {
|
|
120
|
+
readonly type: "string";
|
|
121
|
+
readonly required: true;
|
|
122
|
+
readonly index: true;
|
|
123
|
+
};
|
|
124
|
+
readonly name: {
|
|
125
|
+
readonly type: "string";
|
|
126
|
+
readonly required: true;
|
|
127
|
+
};
|
|
128
|
+
readonly kind: {
|
|
129
|
+
readonly type: ["text", "binding"];
|
|
130
|
+
readonly required: true;
|
|
131
|
+
};
|
|
132
|
+
readonly text_value: {
|
|
133
|
+
readonly type: "string";
|
|
111
134
|
readonly required: false;
|
|
112
135
|
};
|
|
113
|
-
readonly
|
|
114
|
-
readonly type: "
|
|
136
|
+
readonly slot_key: {
|
|
137
|
+
readonly type: "string";
|
|
138
|
+
readonly required: false;
|
|
139
|
+
};
|
|
140
|
+
readonly prefix: {
|
|
141
|
+
readonly type: "string";
|
|
142
|
+
readonly required: false;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
readonly graphql_source_query_param: {
|
|
147
|
+
readonly fields: {
|
|
148
|
+
readonly id: {
|
|
149
|
+
readonly type: "string";
|
|
150
|
+
readonly required: true;
|
|
151
|
+
};
|
|
152
|
+
readonly scope_id: {
|
|
153
|
+
readonly type: "string";
|
|
154
|
+
readonly required: true;
|
|
155
|
+
readonly index: true;
|
|
156
|
+
};
|
|
157
|
+
readonly source_id: {
|
|
158
|
+
readonly type: "string";
|
|
159
|
+
readonly required: true;
|
|
160
|
+
readonly index: true;
|
|
161
|
+
};
|
|
162
|
+
readonly name: {
|
|
163
|
+
readonly type: "string";
|
|
164
|
+
readonly required: true;
|
|
165
|
+
};
|
|
166
|
+
readonly kind: {
|
|
167
|
+
readonly type: ["text", "binding"];
|
|
168
|
+
readonly required: true;
|
|
169
|
+
};
|
|
170
|
+
readonly text_value: {
|
|
171
|
+
readonly type: "string";
|
|
172
|
+
readonly required: false;
|
|
173
|
+
};
|
|
174
|
+
readonly slot_key: {
|
|
175
|
+
readonly type: "string";
|
|
176
|
+
readonly required: false;
|
|
177
|
+
};
|
|
178
|
+
readonly prefix: {
|
|
179
|
+
readonly type: "string";
|
|
115
180
|
readonly required: false;
|
|
116
181
|
};
|
|
117
182
|
};
|
|
@@ -138,4 +203,5 @@ export declare const graphqlPlugin: import("@executor-js/sdk/core").ConfiguredPl
|
|
|
138
203
|
};
|
|
139
204
|
};
|
|
140
205
|
};
|
|
141
|
-
}>;
|
|
206
|
+
}, undefined, Layer.Layer<unknown, never, never>, import("effect/unstable/httpapi/HttpApiGroup").Any>;
|
|
207
|
+
export {};
|
package/dist/sdk/store.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { type StorageDeps, type StorageFailure } from "@executor-js/sdk/core";
|
|
3
|
-
import { OperationBinding, type
|
|
3
|
+
import { OperationBinding, type ConfiguredGraphqlCredentialValue, type GraphqlSourceAuth } from "./types";
|
|
4
4
|
export declare const graphqlSchema: {
|
|
5
5
|
readonly graphql_source: {
|
|
6
6
|
readonly fields: {
|
|
@@ -21,16 +21,89 @@ export declare const graphqlSchema: {
|
|
|
21
21
|
readonly type: "string";
|
|
22
22
|
readonly required: true;
|
|
23
23
|
};
|
|
24
|
-
readonly
|
|
25
|
-
readonly type: "
|
|
24
|
+
readonly auth_kind: {
|
|
25
|
+
readonly type: ["none", "oauth2"];
|
|
26
|
+
readonly required: true;
|
|
27
|
+
readonly defaultValue: "none";
|
|
28
|
+
};
|
|
29
|
+
readonly auth_connection_slot: {
|
|
30
|
+
readonly type: "string";
|
|
26
31
|
readonly required: false;
|
|
27
32
|
};
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
readonly graphql_source_header: {
|
|
36
|
+
readonly fields: {
|
|
37
|
+
readonly id: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
readonly required: true;
|
|
40
|
+
};
|
|
41
|
+
readonly scope_id: {
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
readonly required: true;
|
|
44
|
+
readonly index: true;
|
|
45
|
+
};
|
|
46
|
+
readonly source_id: {
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
readonly required: true;
|
|
49
|
+
readonly index: true;
|
|
50
|
+
};
|
|
51
|
+
readonly name: {
|
|
52
|
+
readonly type: "string";
|
|
53
|
+
readonly required: true;
|
|
54
|
+
};
|
|
55
|
+
readonly kind: {
|
|
56
|
+
readonly type: ["text", "binding"];
|
|
57
|
+
readonly required: true;
|
|
58
|
+
};
|
|
59
|
+
readonly text_value: {
|
|
60
|
+
readonly type: "string";
|
|
30
61
|
readonly required: false;
|
|
31
62
|
};
|
|
32
|
-
readonly
|
|
33
|
-
readonly type: "
|
|
63
|
+
readonly slot_key: {
|
|
64
|
+
readonly type: "string";
|
|
65
|
+
readonly required: false;
|
|
66
|
+
};
|
|
67
|
+
readonly prefix: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
readonly required: false;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
readonly graphql_source_query_param: {
|
|
74
|
+
readonly fields: {
|
|
75
|
+
readonly id: {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
readonly required: true;
|
|
78
|
+
};
|
|
79
|
+
readonly scope_id: {
|
|
80
|
+
readonly type: "string";
|
|
81
|
+
readonly required: true;
|
|
82
|
+
readonly index: true;
|
|
83
|
+
};
|
|
84
|
+
readonly source_id: {
|
|
85
|
+
readonly type: "string";
|
|
86
|
+
readonly required: true;
|
|
87
|
+
readonly index: true;
|
|
88
|
+
};
|
|
89
|
+
readonly name: {
|
|
90
|
+
readonly type: "string";
|
|
91
|
+
readonly required: true;
|
|
92
|
+
};
|
|
93
|
+
readonly kind: {
|
|
94
|
+
readonly type: ["text", "binding"];
|
|
95
|
+
readonly required: true;
|
|
96
|
+
};
|
|
97
|
+
readonly text_value: {
|
|
98
|
+
readonly type: "string";
|
|
99
|
+
readonly required: false;
|
|
100
|
+
};
|
|
101
|
+
readonly slot_key: {
|
|
102
|
+
readonly type: "string";
|
|
103
|
+
readonly required: false;
|
|
104
|
+
};
|
|
105
|
+
readonly prefix: {
|
|
106
|
+
readonly type: "string";
|
|
34
107
|
readonly required: false;
|
|
35
108
|
};
|
|
36
109
|
};
|
|
@@ -67,8 +140,8 @@ export interface StoredGraphqlSource {
|
|
|
67
140
|
readonly scope: string;
|
|
68
141
|
readonly name: string;
|
|
69
142
|
readonly endpoint: string;
|
|
70
|
-
readonly headers: Record<string,
|
|
71
|
-
readonly queryParams: Record<string,
|
|
143
|
+
readonly headers: Record<string, ConfiguredGraphqlCredentialValue>;
|
|
144
|
+
readonly queryParams: Record<string, ConfiguredGraphqlCredentialValue>;
|
|
72
145
|
readonly auth: GraphqlSourceAuth;
|
|
73
146
|
}
|
|
74
147
|
export interface StoredOperation {
|
|
@@ -81,8 +154,8 @@ export interface GraphqlStore {
|
|
|
81
154
|
readonly updateSourceMeta: (namespace: string, scope: string, patch: {
|
|
82
155
|
readonly name?: string;
|
|
83
156
|
readonly endpoint?: string;
|
|
84
|
-
readonly headers?: Record<string,
|
|
85
|
-
readonly queryParams?: Record<string,
|
|
157
|
+
readonly headers?: Record<string, ConfiguredGraphqlCredentialValue>;
|
|
158
|
+
readonly queryParams?: Record<string, ConfiguredGraphqlCredentialValue>;
|
|
86
159
|
readonly auth?: GraphqlSourceAuth;
|
|
87
160
|
}) => Effect.Effect<void, StorageFailure>;
|
|
88
161
|
readonly getSource: (namespace: string, scope: string) => Effect.Effect<StoredGraphqlSource | null, StorageFailure>;
|
package/dist/sdk/types.d.ts
CHANGED
|
@@ -50,24 +50,128 @@ export declare const QueryParamValue: Schema.Union<readonly [Schema.String, Sche
|
|
|
50
50
|
readonly prefix: Schema.optional<Schema.String>;
|
|
51
51
|
}>]>;
|
|
52
52
|
export type QueryParamValue = typeof QueryParamValue.Type;
|
|
53
|
+
export declare const ConfiguredGraphqlCredentialValue: Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
54
|
+
readonly kind: Schema.Literal<"binding">;
|
|
55
|
+
readonly slot: Schema.String;
|
|
56
|
+
readonly prefix: Schema.optional<Schema.String>;
|
|
57
|
+
}>]>;
|
|
58
|
+
export type ConfiguredGraphqlCredentialValue = typeof ConfiguredGraphqlCredentialValue.Type;
|
|
59
|
+
export declare const GraphqlCredentialInput: Schema.Union<readonly [Schema.Struct<{
|
|
60
|
+
readonly secretId: Schema.String;
|
|
61
|
+
readonly prefix: Schema.optional<Schema.String>;
|
|
62
|
+
readonly targetScope: Schema.brand<Schema.String, "ScopeId">;
|
|
63
|
+
readonly secretScopeId: Schema.optional<Schema.brand<Schema.String, "ScopeId">>;
|
|
64
|
+
}>, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
65
|
+
readonly secretId: Schema.String;
|
|
66
|
+
readonly prefix: Schema.optional<Schema.String>;
|
|
67
|
+
}>]>, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
68
|
+
readonly kind: Schema.Literal<"binding">;
|
|
69
|
+
readonly slot: Schema.String;
|
|
70
|
+
readonly prefix: Schema.optional<Schema.String>;
|
|
71
|
+
}>]>]>;
|
|
72
|
+
export type GraphqlCredentialInput = typeof GraphqlCredentialInput.Type;
|
|
73
|
+
export declare const graphqlHeaderSlot: (name: string) => string;
|
|
74
|
+
export declare const graphqlQueryParamSlot: (name: string) => string;
|
|
75
|
+
export declare const GRAPHQL_OAUTH_CONNECTION_SLOT = "auth:oauth2:connection";
|
|
53
76
|
export declare const GraphqlSourceAuth: Schema.Union<readonly [Schema.Struct<{
|
|
54
77
|
readonly kind: Schema.Literal<"none">;
|
|
55
78
|
}>, Schema.Struct<{
|
|
56
79
|
readonly kind: Schema.Literal<"oauth2">;
|
|
57
|
-
readonly
|
|
80
|
+
readonly connectionSlot: Schema.String;
|
|
58
81
|
}>]>;
|
|
59
82
|
export type GraphqlSourceAuth = typeof GraphqlSourceAuth.Type;
|
|
83
|
+
export declare const GraphqlSourceAuthInput: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
84
|
+
readonly kind: Schema.Literal<"none">;
|
|
85
|
+
}>, Schema.Struct<{
|
|
86
|
+
readonly kind: Schema.Literal<"oauth2">;
|
|
87
|
+
readonly connectionSlot: Schema.String;
|
|
88
|
+
}>]>, Schema.Struct<{
|
|
89
|
+
readonly kind: Schema.Literal<"oauth2">;
|
|
90
|
+
readonly connectionId: Schema.String;
|
|
91
|
+
}>]>;
|
|
92
|
+
export type GraphqlSourceAuthInput = typeof GraphqlSourceAuthInput.Type;
|
|
93
|
+
export declare const GraphqlSourceBindingValue: Schema.Union<readonly [Schema.Struct<{
|
|
94
|
+
readonly kind: Schema.Literal<"text">;
|
|
95
|
+
readonly text: Schema.String;
|
|
96
|
+
}>, Schema.Struct<{
|
|
97
|
+
readonly kind: Schema.Literal<"secret">;
|
|
98
|
+
readonly secretId: Schema.brand<Schema.String, "SecretId">;
|
|
99
|
+
readonly secretScopeId: Schema.optional<Schema.brand<Schema.String, "ScopeId">>;
|
|
100
|
+
}>, Schema.Struct<{
|
|
101
|
+
readonly kind: Schema.Literal<"connection">;
|
|
102
|
+
readonly connectionId: Schema.brand<Schema.String, "ConnectionId">;
|
|
103
|
+
}>]>;
|
|
104
|
+
export type GraphqlSourceBindingValue = typeof GraphqlSourceBindingValue.Type;
|
|
105
|
+
export declare const GraphqlSourceBindingInputSchema: Schema.Struct<{
|
|
106
|
+
readonly sourceId: Schema.String;
|
|
107
|
+
readonly sourceScope: Schema.brand<Schema.String, "ScopeId">;
|
|
108
|
+
readonly scope: Schema.brand<Schema.String, "ScopeId">;
|
|
109
|
+
readonly slot: Schema.String;
|
|
110
|
+
readonly value: Schema.Union<readonly [Schema.Struct<{
|
|
111
|
+
readonly kind: Schema.Literal<"text">;
|
|
112
|
+
readonly text: Schema.String;
|
|
113
|
+
}>, Schema.Struct<{
|
|
114
|
+
readonly kind: Schema.Literal<"secret">;
|
|
115
|
+
readonly secretId: Schema.brand<Schema.String, "SecretId">;
|
|
116
|
+
readonly secretScopeId: Schema.optional<Schema.brand<Schema.String, "ScopeId">>;
|
|
117
|
+
}>, Schema.Struct<{
|
|
118
|
+
readonly kind: Schema.Literal<"connection">;
|
|
119
|
+
readonly connectionId: Schema.brand<Schema.String, "ConnectionId">;
|
|
120
|
+
}>]>;
|
|
121
|
+
}>;
|
|
122
|
+
declare const GraphqlSourceBindingInput_base: Schema.Class<GraphqlSourceBindingInput, Schema.Struct<{
|
|
123
|
+
readonly sourceId: Schema.String;
|
|
124
|
+
readonly sourceScope: Schema.brand<Schema.String, "ScopeId">;
|
|
125
|
+
readonly scope: Schema.brand<Schema.String, "ScopeId">;
|
|
126
|
+
readonly slot: Schema.String;
|
|
127
|
+
readonly value: Schema.Union<readonly [Schema.Struct<{
|
|
128
|
+
readonly kind: Schema.Literal<"text">;
|
|
129
|
+
readonly text: Schema.String;
|
|
130
|
+
}>, Schema.Struct<{
|
|
131
|
+
readonly kind: Schema.Literal<"secret">;
|
|
132
|
+
readonly secretId: Schema.brand<Schema.String, "SecretId">;
|
|
133
|
+
readonly secretScopeId: Schema.optional<Schema.brand<Schema.String, "ScopeId">>;
|
|
134
|
+
}>, Schema.Struct<{
|
|
135
|
+
readonly kind: Schema.Literal<"connection">;
|
|
136
|
+
readonly connectionId: Schema.brand<Schema.String, "ConnectionId">;
|
|
137
|
+
}>]>;
|
|
138
|
+
}>, {}>;
|
|
139
|
+
export declare class GraphqlSourceBindingInput extends GraphqlSourceBindingInput_base {
|
|
140
|
+
}
|
|
141
|
+
declare const GraphqlSourceBindingRef_base: Schema.Class<GraphqlSourceBindingRef, Schema.Struct<{
|
|
142
|
+
readonly sourceId: Schema.String;
|
|
143
|
+
readonly sourceScopeId: Schema.brand<Schema.String, "ScopeId">;
|
|
144
|
+
readonly scopeId: Schema.brand<Schema.String, "ScopeId">;
|
|
145
|
+
readonly slot: Schema.String;
|
|
146
|
+
readonly value: Schema.Union<readonly [Schema.Struct<{
|
|
147
|
+
readonly kind: Schema.Literal<"text">;
|
|
148
|
+
readonly text: Schema.String;
|
|
149
|
+
}>, Schema.Struct<{
|
|
150
|
+
readonly kind: Schema.Literal<"secret">;
|
|
151
|
+
readonly secretId: Schema.brand<Schema.String, "SecretId">;
|
|
152
|
+
readonly secretScopeId: Schema.optional<Schema.brand<Schema.String, "ScopeId">>;
|
|
153
|
+
}>, Schema.Struct<{
|
|
154
|
+
readonly kind: Schema.Literal<"connection">;
|
|
155
|
+
readonly connectionId: Schema.brand<Schema.String, "ConnectionId">;
|
|
156
|
+
}>]>;
|
|
157
|
+
readonly createdAt: Schema.Date;
|
|
158
|
+
readonly updatedAt: Schema.Date;
|
|
159
|
+
}>, {}>;
|
|
160
|
+
export declare class GraphqlSourceBindingRef extends GraphqlSourceBindingRef_base {
|
|
161
|
+
}
|
|
60
162
|
declare const InvocationConfig_base: Schema.Class<InvocationConfig, Schema.Struct<{
|
|
61
163
|
/** The GraphQL endpoint URL */
|
|
62
164
|
readonly endpoint: Schema.String;
|
|
63
165
|
/** Headers applied to every request. Values can reference secrets. */
|
|
64
166
|
readonly headers: Schema.withConstructorDefault<Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
65
|
-
readonly
|
|
167
|
+
readonly kind: Schema.Literal<"binding">;
|
|
168
|
+
readonly slot: Schema.String;
|
|
66
169
|
readonly prefix: Schema.optional<Schema.String>;
|
|
67
170
|
}>]>>>>;
|
|
68
171
|
/** Query parameters applied to every request. Values can reference secrets. */
|
|
69
172
|
readonly queryParams: Schema.withConstructorDefault<Schema.withDecodingDefault<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
70
|
-
readonly
|
|
173
|
+
readonly kind: Schema.Literal<"binding">;
|
|
174
|
+
readonly slot: Schema.String;
|
|
71
175
|
readonly prefix: Schema.optional<Schema.String>;
|
|
72
176
|
}>]>>>>;
|
|
73
177
|
}>, {}>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Schema as EffectSchema, Scope } from "effect";
|
|
2
|
+
import { GraphQLSchema } from "graphql";
|
|
3
|
+
declare const GraphqlRequestPayload: EffectSchema.Struct<{
|
|
4
|
+
readonly query: EffectSchema.optional<EffectSchema.String>;
|
|
5
|
+
readonly variables: EffectSchema.optional<EffectSchema.$Record<EffectSchema.String, EffectSchema.Unknown>>;
|
|
6
|
+
readonly operationName: EffectSchema.optional<EffectSchema.NullOr<EffectSchema.String>>;
|
|
7
|
+
}>;
|
|
8
|
+
type GraphqlRequestPayload = typeof GraphqlRequestPayload.Type;
|
|
9
|
+
export interface GraphqlTestRequest {
|
|
10
|
+
readonly url: string;
|
|
11
|
+
readonly method: string;
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
14
|
+
readonly payload: GraphqlRequestPayload;
|
|
15
|
+
}
|
|
16
|
+
export interface GraphqlTestContext {
|
|
17
|
+
readonly request: GraphqlTestRequest;
|
|
18
|
+
}
|
|
19
|
+
export interface GraphqlTestServerOptions {
|
|
20
|
+
readonly schema: GraphQLSchema;
|
|
21
|
+
readonly path?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface GraphqlTestServerShape {
|
|
24
|
+
readonly endpoint: string;
|
|
25
|
+
readonly schema: GraphQLSchema;
|
|
26
|
+
readonly requests: Effect.Effect<readonly GraphqlTestRequest[]>;
|
|
27
|
+
readonly clearRequests: Effect.Effect<void>;
|
|
28
|
+
}
|
|
29
|
+
declare const GraphqlTestServerAddressError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
30
|
+
readonly _tag: "GraphqlTestServerAddressError";
|
|
31
|
+
} & Readonly<A>;
|
|
32
|
+
declare class GraphqlTestServerAddressError extends GraphqlTestServerAddressError_base<{
|
|
33
|
+
readonly address: unknown;
|
|
34
|
+
}> {
|
|
35
|
+
}
|
|
36
|
+
declare const GraphqlTestServerHandlerError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
37
|
+
readonly _tag: "GraphqlTestServerHandlerError";
|
|
38
|
+
} & Readonly<A>;
|
|
39
|
+
declare class GraphqlTestServerHandlerError extends GraphqlTestServerHandlerError_base<{
|
|
40
|
+
readonly cause: unknown;
|
|
41
|
+
}> {
|
|
42
|
+
}
|
|
43
|
+
export declare const serveGraphqlTestServer: (options: GraphqlTestServerOptions) => Effect.Effect<GraphqlTestServerShape, GraphqlTestServerAddressError | GraphqlTestServerHandlerError, Scope.Scope>;
|
|
44
|
+
declare const GraphqlTestServer_base: Context.ServiceClass<GraphqlTestServer, "@executor-js/plugin-graphql/testing/GraphqlTestServer", GraphqlTestServerShape>;
|
|
45
|
+
export declare class GraphqlTestServer extends GraphqlTestServer_base {
|
|
46
|
+
static readonly layer: (options: GraphqlTestServerOptions) => Layer.Layer<GraphqlTestServer, GraphqlTestServerAddressError | GraphqlTestServerHandlerError, never>;
|
|
47
|
+
}
|
|
48
|
+
export declare const makeGreetingGraphqlSchema: () => GraphQLSchema;
|
|
49
|
+
export declare const TestLayers: {
|
|
50
|
+
greeting: () => Layer.Layer<GraphqlTestServer, GraphqlTestServerAddressError | GraphqlTestServerHandlerError, never>;
|
|
51
|
+
};
|
|
52
|
+
export {};
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// src/testing/index.ts
|
|
2
|
+
import {
|
|
3
|
+
Context,
|
|
4
|
+
Data,
|
|
5
|
+
Effect,
|
|
6
|
+
Layer,
|
|
7
|
+
Predicate,
|
|
8
|
+
Ref,
|
|
9
|
+
Schema as EffectSchema
|
|
10
|
+
} from "effect";
|
|
11
|
+
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
12
|
+
import { GraphQLNonNull, GraphQLObjectType, GraphQLSchema, GraphQLString } from "graphql";
|
|
13
|
+
import { createYoga } from "graphql-yoga";
|
|
14
|
+
import { serveTestHttpApp } from "@executor-js/sdk/testing";
|
|
15
|
+
var GraphqlRequestPayload = EffectSchema.Struct({
|
|
16
|
+
query: EffectSchema.optional(EffectSchema.String),
|
|
17
|
+
variables: EffectSchema.optional(EffectSchema.Record(EffectSchema.String, EffectSchema.Unknown)),
|
|
18
|
+
operationName: EffectSchema.optional(EffectSchema.NullOr(EffectSchema.String))
|
|
19
|
+
});
|
|
20
|
+
var GraphqlTestServerAddressError = class extends Data.TaggedError("GraphqlTestServerAddressError") {
|
|
21
|
+
};
|
|
22
|
+
var GraphqlTestServerHandlerError = class extends Data.TaggedError("GraphqlTestServerHandlerError") {
|
|
23
|
+
};
|
|
24
|
+
var headersFromRequest = (headers) => Object.fromEntries(headers.entries());
|
|
25
|
+
var payloadFromParams = (params) => ({
|
|
26
|
+
query: params.query,
|
|
27
|
+
variables: typeof params.variables === "object" && params.variables !== null ? params.variables : void 0,
|
|
28
|
+
operationName: params.operationName ?? null
|
|
29
|
+
});
|
|
30
|
+
var captureRequest = (initial, requests) => {
|
|
31
|
+
const url = new URL(initial.request.url);
|
|
32
|
+
const captured = {
|
|
33
|
+
url: initial.request.url,
|
|
34
|
+
method: initial.request.method,
|
|
35
|
+
path: url.pathname,
|
|
36
|
+
headers: headersFromRequest(initial.request.headers),
|
|
37
|
+
payload: payloadFromParams(initial.params)
|
|
38
|
+
};
|
|
39
|
+
return Effect.runPromise(
|
|
40
|
+
Ref.update(requests, (all) => [...all, captured]).pipe(Effect.as(captured))
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
var serveGraphqlTestServer = (options) => Effect.gen(function* () {
|
|
44
|
+
const requests = yield* Ref.make([]);
|
|
45
|
+
const path = options.path ?? "/graphql";
|
|
46
|
+
const yoga = createYoga({
|
|
47
|
+
schema: options.schema,
|
|
48
|
+
graphqlEndpoint: path,
|
|
49
|
+
graphiql: false,
|
|
50
|
+
landingPage: false,
|
|
51
|
+
logging: false,
|
|
52
|
+
maskedErrors: false,
|
|
53
|
+
context: (initial) => captureRequest(initial, requests).then((request) => ({
|
|
54
|
+
request
|
|
55
|
+
}))
|
|
56
|
+
});
|
|
57
|
+
const server = yield* serveTestHttpApp(
|
|
58
|
+
(request) => Effect.gen(function* () {
|
|
59
|
+
const webRequest = yield* HttpServerRequest.toWeb(request);
|
|
60
|
+
const response = yield* Effect.promise(() => Promise.resolve(yoga.handle(webRequest, {})));
|
|
61
|
+
return HttpServerResponse.fromWeb(response);
|
|
62
|
+
}).pipe(
|
|
63
|
+
Effect.catch(
|
|
64
|
+
() => Effect.succeed(
|
|
65
|
+
HttpServerResponse.text("GraphQL test server failed", {
|
|
66
|
+
status: 500,
|
|
67
|
+
contentType: "text/plain"
|
|
68
|
+
})
|
|
69
|
+
)
|
|
70
|
+
)
|
|
71
|
+
)
|
|
72
|
+
).pipe(
|
|
73
|
+
Effect.mapError(
|
|
74
|
+
(error) => Predicate.isTagged(error, "TestHttpServerAddressError") ? new GraphqlTestServerAddressError({ address: error.address }) : new GraphqlTestServerHandlerError({ cause: error.cause })
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
return {
|
|
78
|
+
endpoint: server.url(path),
|
|
79
|
+
schema: options.schema,
|
|
80
|
+
requests: Ref.get(requests),
|
|
81
|
+
clearRequests: Ref.set(requests, [])
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
var GraphqlTestServer = class _GraphqlTestServer extends Context.Service()(
|
|
85
|
+
"@executor-js/plugin-graphql/testing/GraphqlTestServer"
|
|
86
|
+
) {
|
|
87
|
+
static layer = (options) => Layer.effect(_GraphqlTestServer, serveGraphqlTestServer(options));
|
|
88
|
+
};
|
|
89
|
+
var stringArgument = (args, key, fallback) => {
|
|
90
|
+
const value = args[key];
|
|
91
|
+
return typeof value === "string" ? value : fallback;
|
|
92
|
+
};
|
|
93
|
+
var makeGreetingGraphqlSchema = () => {
|
|
94
|
+
const Query = new GraphQLObjectType({
|
|
95
|
+
name: "Query",
|
|
96
|
+
fields: {
|
|
97
|
+
hello: {
|
|
98
|
+
type: GraphQLString,
|
|
99
|
+
description: "Say hello",
|
|
100
|
+
args: {
|
|
101
|
+
name: { type: GraphQLString }
|
|
102
|
+
},
|
|
103
|
+
resolve: (_source, args) => `Hello ${stringArgument(args, "name", "world")}`
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
const Mutation = new GraphQLObjectType({
|
|
108
|
+
name: "Mutation",
|
|
109
|
+
fields: {
|
|
110
|
+
setGreeting: {
|
|
111
|
+
type: GraphQLString,
|
|
112
|
+
description: "Set greeting message",
|
|
113
|
+
args: {
|
|
114
|
+
message: { type: new GraphQLNonNull(GraphQLString) }
|
|
115
|
+
},
|
|
116
|
+
resolve: (_source, args) => stringArgument(args, "message", "")
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return new GraphQLSchema({ query: Query, mutation: Mutation });
|
|
121
|
+
};
|
|
122
|
+
var TestLayers = {
|
|
123
|
+
greeting: () => GraphqlTestServer.layer({ schema: makeGreetingGraphqlSchema() })
|
|
124
|
+
};
|
|
125
|
+
export {
|
|
126
|
+
GraphqlTestServer,
|
|
127
|
+
TestLayers,
|
|
128
|
+
makeGreetingGraphqlSchema,
|
|
129
|
+
serveGraphqlTestServer
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=testing.js.map
|