apps 0.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +191 -0
- package/check-publish.mjs +10 -0
- package/framework-reference.json +1 -0
- package/js/chunk-22WRQZT7.js +389 -0
- package/js/chunk-2OTCEKL2.js +29480 -0
- package/js/chunk-36DNRFZQ.js +34 -0
- package/js/chunk-3ANFZFCV.js +1799 -0
- package/js/chunk-7JXHF5IF.js +138 -0
- package/js/chunk-BCSNKUAC.js +0 -0
- package/js/chunk-BKVL7XAJ.js +47 -0
- package/js/chunk-BPEFS4YF.js +1323 -0
- package/js/chunk-C24KEZXR.js +59 -0
- package/js/chunk-D6BKYP2L.js +877 -0
- package/js/chunk-EP6AEUZO.js +19 -0
- package/js/chunk-HP7E42X6.js +1719 -0
- package/js/chunk-KWTCHVLT.js +284 -0
- package/js/chunk-LOKGDT6B.js +28 -0
- package/js/chunk-MLKGABMK.js +9 -0
- package/js/chunk-OWD2YICM.js +2486 -0
- package/js/chunk-Q2FD5IBM.js +899 -0
- package/js/chunk-R6JMJSVT.js +590 -0
- package/js/chunk-SBKHUC5L.js +56 -0
- package/js/chunk-VFUZI3NY.js +75 -0
- package/js/chunk-W7Q5EOTS.js +4375 -0
- package/js/chunk-WIDTG42X.js +171 -0
- package/js/chunk-X3YBZCJW.js +246 -0
- package/js/chunk-YDR4CPJA.js +2357 -0
- package/js/client.js +1023 -0
- package/js/contracts.js +163 -0
- package/js/effect.js +44 -0
- package/js/graphql.js +392 -0
- package/js/host.js +193 -0
- package/js/index.js +284 -0
- package/js/mcp/effect.js +23 -0
- package/js/mcp/stdio.js +123 -0
- package/js/mcp.js +37 -0
- package/js/openapi.js +246 -0
- package/js/operations/approval.js +9 -0
- package/js/react.js +37 -0
- package/js/storage/facet.js +546 -0
- package/js/ui/auth/contracts.js +19 -0
- package/js/ui/auth.js +28 -0
- package/js/ui/contracts.js +24 -0
- package/js/ui/serving.js +286 -0
- package/package.json +116 -0
- package/runtime.json +1 -0
- package/types/app-data/src/contracts/database.d.ts +193 -0
- package/types/app-data/src/implementation/cursor.d.ts +10 -0
- package/types/app-data/src/implementation/index-key.d.ts +7 -0
- package/types/app-data/src/implementation/promise.d.ts +68 -0
- package/types/app-data/src/implementation/range.d.ts +8 -0
- package/types/app-data/src/implementation/schema.d.ts +33 -0
- package/types/app-data/src/implementation/sqlite.d.ts +11 -0
- package/types/app-data/src/index.d.ts +4 -0
- package/types/apps/src/approval.d.ts +10 -0
- package/types/apps/src/client.d.ts +5 -0
- package/types/apps/src/contracts/app.d.ts +58 -0
- package/types/apps/src/contracts/approval.d.ts +14 -0
- package/types/apps/src/contracts/context.d.ts +25 -0
- package/types/apps/src/contracts/elicitation.d.ts +86 -0
- package/types/apps/src/contracts/graphql.d.ts +102 -0
- package/types/apps/src/contracts/host.d.ts +568 -0
- package/types/apps/src/contracts/http.d.ts +20 -0
- package/types/apps/src/contracts/live.d.ts +26 -0
- package/types/apps/src/contracts/mcp.d.ts +93 -0
- package/types/apps/src/contracts/openapi.d.ts +105 -0
- package/types/apps/src/contracts/operations.d.ts +30 -0
- package/types/apps/src/contracts/optimistic.d.ts +22 -0
- package/types/apps/src/contracts/provider.d.ts +96 -0
- package/types/apps/src/contracts/schedules.d.ts +51 -0
- package/types/apps/src/contracts/schema.d.ts +20 -0
- package/types/apps/src/contracts/storage.d.ts +68 -0
- package/types/apps/src/contracts/tools.d.ts +11 -0
- package/types/apps/src/contracts/ui-auth.d.ts +28 -0
- package/types/apps/src/contracts/ui.d.ts +90 -0
- package/types/apps/src/contracts/webhook-protocol.d.ts +102 -0
- package/types/apps/src/contracts/webhooks.d.ts +53 -0
- package/types/apps/src/contracts/workflows.d.ts +277 -0
- package/types/apps/src/effect.d.ts +10 -0
- package/types/apps/src/facet.d.ts +5 -0
- package/types/apps/src/graphql.d.ts +10 -0
- package/types/apps/src/host.d.ts +16 -0
- package/types/apps/src/implementation/account-operations.d.ts +32 -0
- package/types/apps/src/implementation/app.d.ts +40 -0
- package/types/apps/src/implementation/authoring.d.ts +12 -0
- package/types/apps/src/implementation/elicitation.d.ts +103 -0
- package/types/apps/src/implementation/graphql.d.ts +5 -0
- package/types/apps/src/implementation/host.d.ts +3 -0
- package/types/apps/src/implementation/http.d.ts +5 -0
- package/types/apps/src/implementation/live.d.ts +18 -0
- package/types/apps/src/implementation/mcp-call.d.ts +19 -0
- package/types/apps/src/implementation/mcp-client.d.ts +50 -0
- package/types/apps/src/implementation/mcp-stdio.d.ts +4 -0
- package/types/apps/src/implementation/mcp-tools.d.ts +6 -0
- package/types/apps/src/implementation/mcp.d.ts +4 -0
- package/types/apps/src/implementation/openapi-request.d.ts +11 -0
- package/types/apps/src/implementation/openapi.d.ts +5 -0
- package/types/apps/src/implementation/operations.d.ts +65 -0
- package/types/apps/src/implementation/optimistic.d.ts +30 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +24 -0
- package/types/apps/src/implementation/provider.d.ts +16 -0
- package/types/apps/src/implementation/query-commit.d.ts +10 -0
- package/types/apps/src/implementation/schedules.d.ts +16 -0
- package/types/apps/src/implementation/schema.d.ts +93 -0
- package/types/apps/src/implementation/storage.d.ts +13 -0
- package/types/apps/src/implementation/ui-auth.d.ts +13 -0
- package/types/apps/src/implementation/ui-client.d.ts +16 -0
- package/types/apps/src/implementation/ui-errors.d.ts +2 -0
- package/types/apps/src/implementation/ui-serving.d.ts +16 -0
- package/types/apps/src/implementation/ui-watch.d.ts +2 -0
- package/types/apps/src/implementation/webhooks.d.ts +29 -0
- package/types/apps/src/implementation/workflow-context.d.ts +8 -0
- package/types/apps/src/implementation/workflow-rpc.d.ts +5 -0
- package/types/apps/src/implementation/workflows.d.ts +27 -0
- package/types/apps/src/index.d.ts +58 -0
- package/types/apps/src/mcp-stdio.d.ts +8 -0
- package/types/apps/src/mcp.d.ts +10 -0
- package/types/apps/src/openapi.d.ts +10 -0
- package/types/apps/src/react.d.ts +7 -0
- package/types/apps/src/ui-auth.d.ts +3 -0
- package/types/apps/src/ui-serving.d.ts +3 -0
- package/types/telemetry/src/browser-operations.d.ts +16 -0
- package/types/telemetry/src/browser-performance.d.ts +11 -0
- package/types/telemetry/src/browser-request-timing.d.ts +2 -0
- package/types/telemetry/src/browser.d.ts +27 -0
- package/types/telemetry/src/config.d.ts +83 -0
- package/types/telemetry/src/context.d.ts +14 -0
- package/types/telemetry/src/index.d.ts +9 -0
- package/types/telemetry/src/layer.d.ts +7 -0
- package/types/telemetry/src/measurements.d.ts +8 -0
- package/types/telemetry/src/pending-span.d.ts +7 -0
- package/types/telemetry/src/relay.d.ts +28 -0
- package/types/telemetry/src/span-attributes.d.ts +29 -0
- package/types/telemetry/src/trace-context.d.ts +20 -0
- package/types/telemetry/src/transport.d.ts +6 -0
package/js/contracts.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeclaredAuthMethod,
|
|
3
|
+
DeclaredProvider,
|
|
4
|
+
DeclaredRequirements,
|
|
5
|
+
HostAccountsInvalid,
|
|
6
|
+
HostCallError,
|
|
7
|
+
HostDataError,
|
|
8
|
+
HostDeclarationInvalid,
|
|
9
|
+
HostError,
|
|
10
|
+
HostEvaluationFailed,
|
|
11
|
+
HostInputInvalid,
|
|
12
|
+
HostInspectError,
|
|
13
|
+
HostOperationFailed,
|
|
14
|
+
HostOperationNotFound,
|
|
15
|
+
HostOutputInvalid,
|
|
16
|
+
HostRequest,
|
|
17
|
+
HostRequestInvalid,
|
|
18
|
+
HostRequirementsError,
|
|
19
|
+
HostResponse,
|
|
20
|
+
HostToolApprovalRequired,
|
|
21
|
+
HostToolBlocked,
|
|
22
|
+
HostToolNotFound,
|
|
23
|
+
HostToolPolicyFailed,
|
|
24
|
+
HostedTool,
|
|
25
|
+
HostedWebhook,
|
|
26
|
+
ManualWebhookDescriptor,
|
|
27
|
+
ManualWebhookSetup,
|
|
28
|
+
McpClientLimits,
|
|
29
|
+
OperationToolPrefixes,
|
|
30
|
+
ResolvedAccount,
|
|
31
|
+
ResolvedAccounts,
|
|
32
|
+
ToolResultObservation,
|
|
33
|
+
TrustedToolApproval,
|
|
34
|
+
WebhookCommand,
|
|
35
|
+
WebhookRequestData,
|
|
36
|
+
WebhookResponseData,
|
|
37
|
+
WebhookTransportLimits,
|
|
38
|
+
defaultMcpClientLimits,
|
|
39
|
+
defaultWebhookTransportLimits
|
|
40
|
+
} from "./chunk-22WRQZT7.js";
|
|
41
|
+
import {
|
|
42
|
+
ApprovalElicitation,
|
|
43
|
+
ApprovalResponse,
|
|
44
|
+
CalendarSchedule,
|
|
45
|
+
ElicitationFailed,
|
|
46
|
+
ElicitationLimits,
|
|
47
|
+
ElicitationReply,
|
|
48
|
+
ElicitationResponse,
|
|
49
|
+
FormElicitation,
|
|
50
|
+
HostedWorkflow,
|
|
51
|
+
Interval,
|
|
52
|
+
NonRetryableError,
|
|
53
|
+
OAuthClientAuth,
|
|
54
|
+
OAuthSecretClientAuth,
|
|
55
|
+
OperationSchedule,
|
|
56
|
+
ScheduleTiming,
|
|
57
|
+
WorkflowCommand,
|
|
58
|
+
WorkflowControlCommand,
|
|
59
|
+
WorkflowDuration,
|
|
60
|
+
WorkflowFailure,
|
|
61
|
+
WorkflowName,
|
|
62
|
+
WorkflowReplay,
|
|
63
|
+
WorkflowRpcCommand,
|
|
64
|
+
WorkflowRpcResult,
|
|
65
|
+
WorkflowRun,
|
|
66
|
+
WorkflowRunId,
|
|
67
|
+
WorkflowRunPage,
|
|
68
|
+
WorkflowStepOptions,
|
|
69
|
+
WorkflowValue,
|
|
70
|
+
approvalElicitation,
|
|
71
|
+
defaultElicitationLimits,
|
|
72
|
+
minimumIntervalMilliseconds,
|
|
73
|
+
workflowDurationMillis
|
|
74
|
+
} from "./chunk-HP7E42X6.js";
|
|
75
|
+
import "./chunk-7JXHF5IF.js";
|
|
76
|
+
import {
|
|
77
|
+
AppStorageError,
|
|
78
|
+
AppStorageUnavailable,
|
|
79
|
+
StorageName
|
|
80
|
+
} from "./chunk-EP6AEUZO.js";
|
|
81
|
+
import {
|
|
82
|
+
AccountId,
|
|
83
|
+
HttpUrl
|
|
84
|
+
} from "./chunk-36DNRFZQ.js";
|
|
85
|
+
import "./chunk-2OTCEKL2.js";
|
|
86
|
+
import "./chunk-MLKGABMK.js";
|
|
87
|
+
export {
|
|
88
|
+
AccountId,
|
|
89
|
+
AppStorageError,
|
|
90
|
+
AppStorageUnavailable,
|
|
91
|
+
ApprovalElicitation,
|
|
92
|
+
ApprovalResponse,
|
|
93
|
+
CalendarSchedule,
|
|
94
|
+
DeclaredAuthMethod,
|
|
95
|
+
DeclaredProvider,
|
|
96
|
+
DeclaredRequirements,
|
|
97
|
+
ElicitationFailed,
|
|
98
|
+
ElicitationLimits,
|
|
99
|
+
ElicitationReply,
|
|
100
|
+
ElicitationResponse,
|
|
101
|
+
FormElicitation,
|
|
102
|
+
HostAccountsInvalid,
|
|
103
|
+
HostCallError,
|
|
104
|
+
HostDataError,
|
|
105
|
+
HostDeclarationInvalid,
|
|
106
|
+
HostError,
|
|
107
|
+
HostEvaluationFailed,
|
|
108
|
+
HostInputInvalid,
|
|
109
|
+
HostInspectError,
|
|
110
|
+
HostOperationFailed,
|
|
111
|
+
HostOperationNotFound,
|
|
112
|
+
HostOutputInvalid,
|
|
113
|
+
HostRequest,
|
|
114
|
+
HostRequestInvalid,
|
|
115
|
+
HostRequirementsError,
|
|
116
|
+
HostResponse,
|
|
117
|
+
HostToolApprovalRequired,
|
|
118
|
+
HostToolBlocked,
|
|
119
|
+
HostToolNotFound,
|
|
120
|
+
HostToolPolicyFailed,
|
|
121
|
+
HostedTool,
|
|
122
|
+
HostedWebhook,
|
|
123
|
+
HostedWorkflow,
|
|
124
|
+
HttpUrl,
|
|
125
|
+
Interval,
|
|
126
|
+
ManualWebhookDescriptor,
|
|
127
|
+
ManualWebhookSetup,
|
|
128
|
+
McpClientLimits,
|
|
129
|
+
NonRetryableError,
|
|
130
|
+
OAuthClientAuth,
|
|
131
|
+
OAuthSecretClientAuth,
|
|
132
|
+
OperationSchedule,
|
|
133
|
+
OperationToolPrefixes,
|
|
134
|
+
ResolvedAccount,
|
|
135
|
+
ResolvedAccounts,
|
|
136
|
+
ScheduleTiming,
|
|
137
|
+
StorageName,
|
|
138
|
+
ToolResultObservation,
|
|
139
|
+
TrustedToolApproval,
|
|
140
|
+
WebhookCommand,
|
|
141
|
+
WebhookRequestData,
|
|
142
|
+
WebhookResponseData,
|
|
143
|
+
WebhookTransportLimits,
|
|
144
|
+
WorkflowCommand,
|
|
145
|
+
WorkflowControlCommand,
|
|
146
|
+
WorkflowDuration,
|
|
147
|
+
WorkflowFailure,
|
|
148
|
+
WorkflowName,
|
|
149
|
+
WorkflowReplay,
|
|
150
|
+
WorkflowRpcCommand,
|
|
151
|
+
WorkflowRpcResult,
|
|
152
|
+
WorkflowRun,
|
|
153
|
+
WorkflowRunId,
|
|
154
|
+
WorkflowRunPage,
|
|
155
|
+
WorkflowStepOptions,
|
|
156
|
+
WorkflowValue,
|
|
157
|
+
approvalElicitation,
|
|
158
|
+
defaultElicitationLimits,
|
|
159
|
+
defaultMcpClientLimits,
|
|
160
|
+
defaultWebhookTransportLimits,
|
|
161
|
+
minimumIntervalMilliseconds,
|
|
162
|
+
workflowDurationMillis
|
|
163
|
+
};
|
package/js/effect.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import "./chunk-BCSNKUAC.js";
|
|
2
|
+
import {
|
|
3
|
+
ApprovalDecision,
|
|
4
|
+
createAppHandler,
|
|
5
|
+
prepareElicitation
|
|
6
|
+
} from "./chunk-Q2FD5IBM.js";
|
|
7
|
+
import "./chunk-X3YBZCJW.js";
|
|
8
|
+
import "./chunk-R6JMJSVT.js";
|
|
9
|
+
import "./chunk-C24KEZXR.js";
|
|
10
|
+
import {
|
|
11
|
+
ToolAnnotations
|
|
12
|
+
} from "./chunk-22WRQZT7.js";
|
|
13
|
+
import "./chunk-HP7E42X6.js";
|
|
14
|
+
import "./chunk-7JXHF5IF.js";
|
|
15
|
+
import "./chunk-OWD2YICM.js";
|
|
16
|
+
import "./chunk-VFUZI3NY.js";
|
|
17
|
+
import "./chunk-W7Q5EOTS.js";
|
|
18
|
+
import {
|
|
19
|
+
compileJsonSchemaDecoder,
|
|
20
|
+
decoderOf,
|
|
21
|
+
jsonSchemaDecoder,
|
|
22
|
+
wrap
|
|
23
|
+
} from "./chunk-BPEFS4YF.js";
|
|
24
|
+
import "./chunk-EP6AEUZO.js";
|
|
25
|
+
import {
|
|
26
|
+
HttpUrl,
|
|
27
|
+
JsonObject,
|
|
28
|
+
ValidationError
|
|
29
|
+
} from "./chunk-36DNRFZQ.js";
|
|
30
|
+
import "./chunk-2OTCEKL2.js";
|
|
31
|
+
import "./chunk-MLKGABMK.js";
|
|
32
|
+
export {
|
|
33
|
+
ApprovalDecision,
|
|
34
|
+
HttpUrl,
|
|
35
|
+
JsonObject,
|
|
36
|
+
ToolAnnotations,
|
|
37
|
+
ValidationError,
|
|
38
|
+
compileJsonSchemaDecoder,
|
|
39
|
+
createAppHandler,
|
|
40
|
+
decoderOf,
|
|
41
|
+
jsonSchemaDecoder,
|
|
42
|
+
prepareElicitation,
|
|
43
|
+
wrap
|
|
44
|
+
};
|
package/js/graphql.js
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import {
|
|
2
|
+
protocolOperations
|
|
3
|
+
} from "./chunk-LOKGDT6B.js";
|
|
4
|
+
import "./chunk-BCSNKUAC.js";
|
|
5
|
+
import "./chunk-Q2FD5IBM.js";
|
|
6
|
+
import "./chunk-X3YBZCJW.js";
|
|
7
|
+
import "./chunk-R6JMJSVT.js";
|
|
8
|
+
import "./chunk-C24KEZXR.js";
|
|
9
|
+
import "./chunk-22WRQZT7.js";
|
|
10
|
+
import "./chunk-HP7E42X6.js";
|
|
11
|
+
import "./chunk-7JXHF5IF.js";
|
|
12
|
+
import "./chunk-OWD2YICM.js";
|
|
13
|
+
import {
|
|
14
|
+
FetchHttpClient_exports
|
|
15
|
+
} from "./chunk-VFUZI3NY.js";
|
|
16
|
+
import {
|
|
17
|
+
HttpClientRequest_exports,
|
|
18
|
+
HttpClient_exports
|
|
19
|
+
} from "./chunk-W7Q5EOTS.js";
|
|
20
|
+
import {
|
|
21
|
+
jsonSchemaDecoder
|
|
22
|
+
} from "./chunk-BPEFS4YF.js";
|
|
23
|
+
import "./chunk-EP6AEUZO.js";
|
|
24
|
+
import {
|
|
25
|
+
HttpUrl,
|
|
26
|
+
JsonObject
|
|
27
|
+
} from "./chunk-36DNRFZQ.js";
|
|
28
|
+
import {
|
|
29
|
+
Effect_exports,
|
|
30
|
+
Redacted_exports,
|
|
31
|
+
Schema_exports
|
|
32
|
+
} from "./chunk-2OTCEKL2.js";
|
|
33
|
+
import "./chunk-MLKGABMK.js";
|
|
34
|
+
|
|
35
|
+
// src/implementation/graphql.ts
|
|
36
|
+
import {
|
|
37
|
+
getIntrospectionQuery,
|
|
38
|
+
Kind as Kind2,
|
|
39
|
+
OperationTypeNode,
|
|
40
|
+
parse,
|
|
41
|
+
parseType,
|
|
42
|
+
print
|
|
43
|
+
} from "graphql";
|
|
44
|
+
|
|
45
|
+
// src/contracts/graphql.ts
|
|
46
|
+
var GraphqlClientLimits = Schema_exports.Struct({
|
|
47
|
+
timeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
|
|
48
|
+
maxTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
|
|
49
|
+
});
|
|
50
|
+
var defaultGraphqlClientLimits = GraphqlClientLimits.make({
|
|
51
|
+
timeoutMs: 3e4,
|
|
52
|
+
maxTimeoutMs: 3e5
|
|
53
|
+
});
|
|
54
|
+
var GraphqlToolsOptions = Schema_exports.Struct({
|
|
55
|
+
url: HttpUrl,
|
|
56
|
+
headers: Schema_exports.optional(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
|
|
57
|
+
signal: Schema_exports.optional(Schema_exports.instanceOf(AbortSignal)),
|
|
58
|
+
timeoutMs: Schema_exports.optional(
|
|
59
|
+
Schema_exports.Int.check(
|
|
60
|
+
Schema_exports.isBetween({ minimum: 1, maximum: defaultGraphqlClientLimits.maxTimeoutMs })
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
});
|
|
64
|
+
var GraphqlError = class extends Schema_exports.TaggedError()("GraphqlError", {
|
|
65
|
+
phase: Schema_exports.Literals(["discover", "call"]),
|
|
66
|
+
reason: Schema_exports.Literals([
|
|
67
|
+
"request",
|
|
68
|
+
"unauthorized",
|
|
69
|
+
"invalid_response",
|
|
70
|
+
"invalid_input",
|
|
71
|
+
"timeout",
|
|
72
|
+
"execution"
|
|
73
|
+
]),
|
|
74
|
+
status: Schema_exports.optional(Schema_exports.Number)
|
|
75
|
+
}) {
|
|
76
|
+
};
|
|
77
|
+
var Name = Schema_exports.String.check(Schema_exports.isPattern(/^[_A-Za-z][_0-9A-Za-z]*$/));
|
|
78
|
+
var Kind = Schema_exports.Literals([
|
|
79
|
+
"SCALAR",
|
|
80
|
+
"OBJECT",
|
|
81
|
+
"INTERFACE",
|
|
82
|
+
"UNION",
|
|
83
|
+
"ENUM",
|
|
84
|
+
"INPUT_OBJECT",
|
|
85
|
+
"LIST",
|
|
86
|
+
"NON_NULL"
|
|
87
|
+
]);
|
|
88
|
+
var GraphqlTypeRef = Schema_exports.Struct({
|
|
89
|
+
kind: Kind,
|
|
90
|
+
name: Schema_exports.NullOr(Name),
|
|
91
|
+
ofType: Schema_exports.optional(Schema_exports.NullOr(Schema_exports.suspend(() => GraphqlTypeRef)))
|
|
92
|
+
});
|
|
93
|
+
var Argument = Schema_exports.Struct({
|
|
94
|
+
name: Name,
|
|
95
|
+
description: Schema_exports.NullOr(Schema_exports.String),
|
|
96
|
+
type: GraphqlTypeRef,
|
|
97
|
+
defaultValue: Schema_exports.NullOr(Schema_exports.String)
|
|
98
|
+
});
|
|
99
|
+
var GraphqlField = Schema_exports.Struct({
|
|
100
|
+
name: Name,
|
|
101
|
+
description: Schema_exports.NullOr(Schema_exports.String),
|
|
102
|
+
args: Schema_exports.Array(Argument),
|
|
103
|
+
type: GraphqlTypeRef
|
|
104
|
+
});
|
|
105
|
+
var GraphqlIntrospection = Schema_exports.Struct({
|
|
106
|
+
__schema: Schema_exports.Struct({
|
|
107
|
+
queryType: Schema_exports.NullOr(Schema_exports.Struct({ name: Name })),
|
|
108
|
+
mutationType: Schema_exports.NullOr(Schema_exports.Struct({ name: Name })),
|
|
109
|
+
types: Schema_exports.Array(
|
|
110
|
+
Schema_exports.Struct({
|
|
111
|
+
kind: Kind,
|
|
112
|
+
name: Name,
|
|
113
|
+
fields: Schema_exports.NullOr(Schema_exports.Array(GraphqlField)),
|
|
114
|
+
inputFields: Schema_exports.NullOr(Schema_exports.Array(Argument)),
|
|
115
|
+
enumValues: Schema_exports.NullOr(Schema_exports.Array(Schema_exports.Struct({ name: Name })))
|
|
116
|
+
})
|
|
117
|
+
)
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
var GraphqlResponse = Schema_exports.Struct({
|
|
121
|
+
data: Schema_exports.optional(Schema_exports.NullOr(JsonObject)),
|
|
122
|
+
errors: Schema_exports.optional(Schema_exports.Array(JsonObject))
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// src/implementation/graphql.ts
|
|
126
|
+
function wrapped(type) {
|
|
127
|
+
if (!type.ofType) throw new GraphqlError({ phase: "discover", reason: "invalid_response" });
|
|
128
|
+
return type.ofType;
|
|
129
|
+
}
|
|
130
|
+
function named(type) {
|
|
131
|
+
return type.kind === "LIST" || type.kind === "NON_NULL" ? named(wrapped(type)) : type;
|
|
132
|
+
}
|
|
133
|
+
function typeName(type) {
|
|
134
|
+
if (type.kind === "NON_NULL") return typeName(wrapped(type)) + "!";
|
|
135
|
+
if (type.kind === "LIST") return "[" + typeName(wrapped(type)) + "]";
|
|
136
|
+
if (!type.name) throw new GraphqlError({ phase: "discover", reason: "invalid_response" });
|
|
137
|
+
return type.name;
|
|
138
|
+
}
|
|
139
|
+
function fieldInput(field, catalog) {
|
|
140
|
+
const types = new Map(catalog.__schema.types.map((type) => [type.name, type]));
|
|
141
|
+
const definitions = /* @__PURE__ */ new Map();
|
|
142
|
+
const convert = (ref) => ref.kind === "NON_NULL" ? nonNull(wrapped(ref)) : { anyOf: [nonNull(ref), { type: "null" }] };
|
|
143
|
+
const nonNull = (ref) => {
|
|
144
|
+
if (ref.kind === "LIST") return { type: "array", items: convert(wrapped(ref)) };
|
|
145
|
+
if (!ref.name) throw new GraphqlError({ phase: "discover", reason: "invalid_response" });
|
|
146
|
+
const type = types.get(ref.name);
|
|
147
|
+
if (!type) throw new GraphqlError({ phase: "discover", reason: "invalid_response" });
|
|
148
|
+
if (type.kind === "ENUM" && type.enumValues)
|
|
149
|
+
return { type: "string", enum: type.enumValues.map((item) => item.name) };
|
|
150
|
+
if (type.kind === "INPUT_OBJECT" && type.inputFields) {
|
|
151
|
+
if (!definitions.has(type.name)) {
|
|
152
|
+
definitions.set(type.name, {});
|
|
153
|
+
definitions.set(type.name, argsSchema(type.inputFields));
|
|
154
|
+
}
|
|
155
|
+
return { $ref: "#/$defs/" + type.name };
|
|
156
|
+
}
|
|
157
|
+
if (type.kind !== "SCALAR")
|
|
158
|
+
throw new GraphqlError({ phase: "discover", reason: "invalid_response" });
|
|
159
|
+
switch (type.name) {
|
|
160
|
+
case "Int":
|
|
161
|
+
return { type: "integer", minimum: -2147483648, maximum: 2147483647 };
|
|
162
|
+
case "Float":
|
|
163
|
+
return { type: "number" };
|
|
164
|
+
case "Boolean":
|
|
165
|
+
return { type: "boolean" };
|
|
166
|
+
case "ID":
|
|
167
|
+
return { anyOf: [{ type: "string" }, { type: "integer" }] };
|
|
168
|
+
case "String":
|
|
169
|
+
return { type: "string" };
|
|
170
|
+
default:
|
|
171
|
+
return {};
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const argsSchema = (args) => ({
|
|
175
|
+
type: "object",
|
|
176
|
+
additionalProperties: false,
|
|
177
|
+
properties: Object.fromEntries(
|
|
178
|
+
args.map((arg) => [
|
|
179
|
+
arg.name,
|
|
180
|
+
{ ...convert(arg.type), ...arg.description ? { description: arg.description } : {} }
|
|
181
|
+
])
|
|
182
|
+
),
|
|
183
|
+
required: args.filter((arg) => arg.type.kind === "NON_NULL" && arg.defaultValue === null).map((arg) => arg.name)
|
|
184
|
+
});
|
|
185
|
+
const output = named(field.type);
|
|
186
|
+
const composite = ["OBJECT", "INTERFACE", "UNION"].includes(output.kind);
|
|
187
|
+
const leaves = types.get(output.name ?? "")?.fields?.filter((child) => {
|
|
188
|
+
const type = named(child.type);
|
|
189
|
+
return (type.kind === "SCALAR" || type.kind === "ENUM") && child.args.every((arg) => arg.type.kind !== "NON_NULL" || arg.defaultValue !== null);
|
|
190
|
+
}).map((child) => child.name) ?? [];
|
|
191
|
+
const arguments_ = argsSchema(field.args);
|
|
192
|
+
return {
|
|
193
|
+
composite,
|
|
194
|
+
selection: leaves.length ? leaves.join(" ") : "__typename",
|
|
195
|
+
schema: {
|
|
196
|
+
type: "object",
|
|
197
|
+
additionalProperties: false,
|
|
198
|
+
properties: {
|
|
199
|
+
arguments: arguments_,
|
|
200
|
+
...composite ? {
|
|
201
|
+
select: {
|
|
202
|
+
type: "string",
|
|
203
|
+
minLength: 1,
|
|
204
|
+
description: "Fields to return, e.g. id name items { id title }. Omit to select scalar fields."
|
|
205
|
+
}
|
|
206
|
+
} : {}
|
|
207
|
+
},
|
|
208
|
+
required: field.args.some((arg) => arg.type.kind === "NON_NULL" && arg.defaultValue === null) ? ["arguments"] : [],
|
|
209
|
+
$defs: Object.fromEntries(definitions)
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function selection(text) {
|
|
214
|
+
const document = parse("query { result { " + text + " } }");
|
|
215
|
+
const definition = document.definitions[0];
|
|
216
|
+
if (document.definitions.length !== 1 || definition?.kind !== Kind2.OPERATION_DEFINITION || definition.selectionSet.selections.length !== 1) {
|
|
217
|
+
throw new GraphqlError({ phase: "call", reason: "invalid_input" });
|
|
218
|
+
}
|
|
219
|
+
const field = definition.selectionSet.selections[0];
|
|
220
|
+
if (field?.kind !== Kind2.FIELD || field.name.value !== "result" || !field.selectionSet)
|
|
221
|
+
throw new GraphqlError({ phase: "call", reason: "invalid_input" });
|
|
222
|
+
return field.selectionSet;
|
|
223
|
+
}
|
|
224
|
+
var graphqlToolsEffect = (input) => Effect_exports.gen(function* () {
|
|
225
|
+
const options = yield* Schema_exports.decodeUnknownEffect(GraphqlToolsOptions)(input).pipe(
|
|
226
|
+
Effect_exports.mapError(() => new GraphqlError({ phase: "discover", reason: "invalid_input" }))
|
|
227
|
+
);
|
|
228
|
+
const url = new URL(options.url);
|
|
229
|
+
if (url.username || url.password || url.hash)
|
|
230
|
+
return yield* new GraphqlError({ phase: "discover", reason: "invalid_input" });
|
|
231
|
+
const headers = Redacted_exports.make({ ...options.headers });
|
|
232
|
+
const request = (phase, query, variables = {}) => Effect_exports.scoped(
|
|
233
|
+
Effect_exports.gen(function* () {
|
|
234
|
+
const client = yield* HttpClient_exports.HttpClient;
|
|
235
|
+
const response = yield* HttpClient_exports.withScope(client).execute(
|
|
236
|
+
HttpClientRequest_exports.post(url.href).pipe(
|
|
237
|
+
HttpClientRequest_exports.setHeaders(Redacted_exports.value(headers)),
|
|
238
|
+
HttpClientRequest_exports.bodyJsonUnsafe({ query, variables })
|
|
239
|
+
)
|
|
240
|
+
);
|
|
241
|
+
if (response.status < 200 || response.status >= 300)
|
|
242
|
+
return yield* new GraphqlError({
|
|
243
|
+
phase,
|
|
244
|
+
reason: [401, 403].includes(response.status) ? "unauthorized" : "request",
|
|
245
|
+
status: response.status
|
|
246
|
+
});
|
|
247
|
+
const result = yield* response.json.pipe(
|
|
248
|
+
Effect_exports.withSpan("provider.http.response.read"),
|
|
249
|
+
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(GraphqlResponse)),
|
|
250
|
+
Effect_exports.mapError(() => new GraphqlError({ phase, reason: "invalid_response" }))
|
|
251
|
+
);
|
|
252
|
+
if (result.errors?.length)
|
|
253
|
+
return yield* new GraphqlError({ phase, reason: "execution", status: response.status });
|
|
254
|
+
if (result.data == null)
|
|
255
|
+
return yield* new GraphqlError({ phase, reason: "invalid_response" });
|
|
256
|
+
return result.data;
|
|
257
|
+
})
|
|
258
|
+
).pipe(
|
|
259
|
+
Effect_exports.withSpan("provider.graphql.request", {
|
|
260
|
+
attributes: {
|
|
261
|
+
"executor.operation": phase,
|
|
262
|
+
"server.address": url.hostname
|
|
263
|
+
}
|
|
264
|
+
}),
|
|
265
|
+
Effect_exports.provideService(FetchHttpClient_exports.RequestInit, { redirect: "manual" }),
|
|
266
|
+
Effect_exports.provideService(FetchHttpClient_exports.Fetch, globalThis.fetch),
|
|
267
|
+
Effect_exports.provide(FetchHttpClient_exports.layer),
|
|
268
|
+
Effect_exports.timeoutOrElse({
|
|
269
|
+
duration: options.timeoutMs ?? defaultGraphqlClientLimits.timeoutMs,
|
|
270
|
+
orElse: () => Effect_exports.fail(new GraphqlError({ phase, reason: "timeout" }))
|
|
271
|
+
}),
|
|
272
|
+
Effect_exports.mapError(
|
|
273
|
+
(error) => error instanceof GraphqlError ? error : new GraphqlError({ phase, reason: "request" })
|
|
274
|
+
)
|
|
275
|
+
);
|
|
276
|
+
const catalog = yield* request("discover", getIntrospectionQuery()).pipe(
|
|
277
|
+
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(GraphqlIntrospection)),
|
|
278
|
+
Effect_exports.mapError(
|
|
279
|
+
(error) => error instanceof GraphqlError ? error : new GraphqlError({ phase: "discover", reason: "invalid_response" })
|
|
280
|
+
)
|
|
281
|
+
);
|
|
282
|
+
const roots = [
|
|
283
|
+
{ kind: OperationTypeNode.QUERY, type: catalog.__schema.queryType },
|
|
284
|
+
{ kind: OperationTypeNode.MUTATION, type: catalog.__schema.mutationType }
|
|
285
|
+
].flatMap(
|
|
286
|
+
({ kind, type }) => (catalog.__schema.types.find((item) => item.name === type?.name)?.fields ?? []).map(
|
|
287
|
+
(field) => ({ kind, field })
|
|
288
|
+
)
|
|
289
|
+
);
|
|
290
|
+
const entries = yield* Effect_exports.forEach(
|
|
291
|
+
roots,
|
|
292
|
+
({ kind, field }) => Effect_exports.gen(function* () {
|
|
293
|
+
const definition = yield* Effect_exports.try({
|
|
294
|
+
try: () => fieldInput(field, catalog),
|
|
295
|
+
catch: () => new GraphqlError({ phase: "discover", reason: "invalid_response" })
|
|
296
|
+
});
|
|
297
|
+
const decoder = yield* jsonSchemaDecoder(definition.schema).pipe(
|
|
298
|
+
Effect_exports.mapError(
|
|
299
|
+
() => new GraphqlError({ phase: "discover", reason: "invalid_response" })
|
|
300
|
+
)
|
|
301
|
+
);
|
|
302
|
+
const name = kind + "_" + field.name;
|
|
303
|
+
const tool = {
|
|
304
|
+
description: field.description ?? field.name,
|
|
305
|
+
readOnly: kind === OperationTypeNode.QUERY,
|
|
306
|
+
input: decoder,
|
|
307
|
+
run: (_context, input2) => Effect_exports.gen(function* () {
|
|
308
|
+
const args = yield* Schema_exports.decodeUnknownEffect(decoder)(input2).pipe(
|
|
309
|
+
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(JsonObject)),
|
|
310
|
+
Effect_exports.mapError(() => new GraphqlError({ phase: "call", reason: "invalid_input" }))
|
|
311
|
+
);
|
|
312
|
+
const variables = yield* Schema_exports.decodeUnknownEffect(JsonObject)(
|
|
313
|
+
args.arguments ?? {}
|
|
314
|
+
).pipe(
|
|
315
|
+
Effect_exports.mapError(() => new GraphqlError({ phase: "call", reason: "invalid_input" }))
|
|
316
|
+
);
|
|
317
|
+
const query = yield* Effect_exports.try({
|
|
318
|
+
try: () => {
|
|
319
|
+
const used = field.args.filter((arg) => Object.hasOwn(variables, arg.name));
|
|
320
|
+
return print({
|
|
321
|
+
kind: Kind2.DOCUMENT,
|
|
322
|
+
definitions: [
|
|
323
|
+
{
|
|
324
|
+
kind: Kind2.OPERATION_DEFINITION,
|
|
325
|
+
operation: kind,
|
|
326
|
+
variableDefinitions: used.map((arg) => ({
|
|
327
|
+
kind: Kind2.VARIABLE_DEFINITION,
|
|
328
|
+
variable: {
|
|
329
|
+
kind: Kind2.VARIABLE,
|
|
330
|
+
name: { kind: Kind2.NAME, value: arg.name }
|
|
331
|
+
},
|
|
332
|
+
type: parseType(typeName(arg.type))
|
|
333
|
+
})),
|
|
334
|
+
selectionSet: {
|
|
335
|
+
kind: Kind2.SELECTION_SET,
|
|
336
|
+
selections: [
|
|
337
|
+
{
|
|
338
|
+
kind: Kind2.FIELD,
|
|
339
|
+
name: { kind: Kind2.NAME, value: field.name },
|
|
340
|
+
arguments: used.map((arg) => ({
|
|
341
|
+
kind: Kind2.ARGUMENT,
|
|
342
|
+
name: { kind: Kind2.NAME, value: arg.name },
|
|
343
|
+
value: {
|
|
344
|
+
kind: Kind2.VARIABLE,
|
|
345
|
+
name: { kind: Kind2.NAME, value: arg.name }
|
|
346
|
+
}
|
|
347
|
+
})),
|
|
348
|
+
...definition.composite ? {
|
|
349
|
+
selectionSet: selection(
|
|
350
|
+
typeof args.select === "string" ? args.select : definition.selection
|
|
351
|
+
)
|
|
352
|
+
} : {}
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
]
|
|
358
|
+
});
|
|
359
|
+
},
|
|
360
|
+
catch: () => new GraphqlError({ phase: "call", reason: "invalid_input" })
|
|
361
|
+
});
|
|
362
|
+
const data = yield* request("call", query, variables);
|
|
363
|
+
const value = Object.hasOwn(data, field.name) ? data[field.name] : void 0;
|
|
364
|
+
if (value === void 0)
|
|
365
|
+
return yield* new GraphqlError({ phase: "call", reason: "invalid_response" });
|
|
366
|
+
return value;
|
|
367
|
+
}).pipe(
|
|
368
|
+
Effect_exports.withSpan("provider.graphql.call", {
|
|
369
|
+
attributes: {
|
|
370
|
+
"graphql.operation.type": kind,
|
|
371
|
+
"executor.tool.name": name
|
|
372
|
+
}
|
|
373
|
+
})
|
|
374
|
+
)
|
|
375
|
+
};
|
|
376
|
+
return [name, tool];
|
|
377
|
+
})
|
|
378
|
+
);
|
|
379
|
+
return Object.fromEntries(entries);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// src/graphql.ts
|
|
383
|
+
var graphqlOperations = (options, kinds = {}) => Effect_exports.runPromise(
|
|
384
|
+
graphqlToolsEffect(options).pipe(
|
|
385
|
+
Effect_exports.map((operations) => protocolOperations(operations, kinds))
|
|
386
|
+
),
|
|
387
|
+
options.signal === void 0 ? {} : { signal: options.signal }
|
|
388
|
+
);
|
|
389
|
+
export {
|
|
390
|
+
GraphqlError,
|
|
391
|
+
graphqlOperations
|
|
392
|
+
};
|